embedded template assigns

Hello,

I'm new to the whole PHP and template scene.

I have some code where I assign a value in the template like this:

$search_tpl->assign ('my_choice', '
                <input type="radio" name="type2" value="0" {openmy_checked}>All
                <input type="radio" name="type2" value="1" {my_checked}>My
                <input type="radio" name="type2" value="2" {open_checked}>Open
        ');

Now,  only a select few get to see these options, thats why I can't put it straight into the template.

After this, I try to keep the current option selected by grabbing the $_GET data:

if (isset($_GET['type2'])) {
                switch ($_GET['type2']) {
                        case 1: // Me
                                $search_tpl->assign('my_checked', 'checked');
                                break;
                        case 2: // Open
                                $search_tpl->assign('open_checked', 'checked');
                                break;
                        default: // All selected
                                $search_tpl->assign('openmy_checked', 'checked');
                }
}
else {
                $search_tpl->assign('openmy_checked', 'checked');
}


Now, I'm guess that it doesn't work because in the search.tpl I only have the {my_choice} .

So my question is, how would I go about doing something like this:

$search_tpl->assign('my_choice', assign('openmy_checked', 'checked'));

??

Any help on this one would be greatly appreciated!
Thank a lot and best regards,
noshankusAsked:
Who is Participating?
 
PAQ_ManCommented:
Question Closed, 80 points refunded.
PAQ_Man
Community Support Moderator
0
 
RoonaanCommented:
Could you have something like a hidden input?

$search_tpl->assign ('my_choice', '<input type='hidden" name="type2" value="0" />');

I am not sure about the way the template engine works, because there are tons of different ones.

-r-
0
 
noshankusAuthor Commented:
Nevermind.

Solved the problem by having a switch with 3 options and only then defining the radio buttons.
Doesn't look nice, but it works =)
0
 
RoonaanCommented:
no problems with it.

-r-
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.