ThatScriptGuy
12-10-2007, 03:39 PM
Hopefully a smarty guru can come and help me with this today - It's not a horribly complicated problem...
I have a PHP page that assigns a lot of data to a smarty template. One of those things is an array, which looks like this:
[id]=>name
Besides assigning that array, the page also assigns a lot of variables, which are arrays themselves. Let me try to demonstrate this:
$categories=array('cat_2'=>'Test Category',
'cat_4'=>'Test Category 2');
Besides the $categories array, two more arrays are also assigned. They are $cat_2 and $cat_4
Now, what *should* be happening is this: When smarty creates the page, it makes a separate section for each category. In this case, a section will be created for Test Category and Test Category 2
In each section, there is an HTML dropdown, which should show the options from the relevant variable (In this case, $cat_2 or $cat_4)
My problem is this: I'm not sure how to access the variables from smarty using the array index from $categories. I know that smarty has some ability to use variable variables, but in all of my tinkering, I haven't been able to figure out how to tell it to take the indexes of $categories and look up the array data for that index(variable)
I hope I've been clear enough in this post. This would be very simple to accomplish using just PHP, but I'm trying to get in the habit of templatizing (<--new word) everything.
Any help here would be appreciated. I suppose if nobody else knows, though, it wouldn't hurt to make *just this page* straight PHP ;)
Kevin
I have a PHP page that assigns a lot of data to a smarty template. One of those things is an array, which looks like this:
[id]=>name
Besides assigning that array, the page also assigns a lot of variables, which are arrays themselves. Let me try to demonstrate this:
$categories=array('cat_2'=>'Test Category',
'cat_4'=>'Test Category 2');
Besides the $categories array, two more arrays are also assigned. They are $cat_2 and $cat_4
Now, what *should* be happening is this: When smarty creates the page, it makes a separate section for each category. In this case, a section will be created for Test Category and Test Category 2
In each section, there is an HTML dropdown, which should show the options from the relevant variable (In this case, $cat_2 or $cat_4)
My problem is this: I'm not sure how to access the variables from smarty using the array index from $categories. I know that smarty has some ability to use variable variables, but in all of my tinkering, I haven't been able to figure out how to tell it to take the indexes of $categories and look up the array data for that index(variable)
I hope I've been clear enough in this post. This would be very simple to accomplish using just PHP, but I'm trying to get in the habit of templatizing (<--new word) everything.
Any help here would be appreciated. I suppose if nobody else knows, though, it wouldn't hurt to make *just this page* straight PHP ;)
Kevin
