• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

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,
0
noshankus
Asked:
noshankus
  • 2
1 Solution
 
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
 
PAQ_ManCommented:
Question Closed, 80 points refunded.
PAQ_Man
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now