![]() |
spitting variables
Hi
Im trying to find a way that i can split up each part of the $location[position] variable into seperate variables. ie.. if $location[position] is "home.php home.php?cat=..." $var1 home.php $var2 home.php?cat=... etc etc thank you all |
Re: spitting variables
In location.tpl location is assign through {foreach} loop. You can use it to do this just place your code inside it
|
Re: spitting variables
Thanks for that however that doesnt seem to do what im trying to acheive.
{foreach from=$location[position] item=foo} {$foo} {/foreach} looks good & lists the array however it doesnt break it down, i need to try to get each component of the $location[position] array into seperate variables ie .... var1 home.php var2 cat.php etc etc no matter the length of the array each component will be in a seperate variable, sorry i hope that makes sense. |
Re: spitting variables
What I meant is that this loop reads each location and adds to path. You can include in this loop code that adds number to 'var' with time and assigns $foo to var1, var2.....
|
Re: spitting variables
Sorry Im not sure if thats right.
An example would be if Ive gone from home page to category 1 and subcat 1 then the $location[position] would equal home.php category1 subcat 1 .. etc i assume thats in an array $location[position] if i run the loop in the last post & display each element of the array i get {$foo[0]} gives me h - i need home.php {$foo[1]} gives me o - i need category 1 etc ... would you happen to have an example of what you mean please ? thank you |
Re: spitting variables
I am away from my desk at the moment I'll check on this later
|
Re: spitting variables
I am getting a litle confused here. Why do you need to assign them to new variables? You can PM me if you want to.
All locations are already in $location array so you just need to use it properly. $location array contains arrays (0, 1, 2, 3...) for each location and each of these arrays contains name (0) and location (1). If you are on home page $location will have one array (0) and this array will have record 0 - Home and record 1 - home.php so $location[0].0 will give you "Home" and $location[0].1 will give you "home.php". If you are in category $location will have all of the above + one more array (1) which will have record 0 - cat name and record - 1 home.php?cat= so you can call it like this $location[1].0 will give you "cat name" and $location[1].1 will give you "home.php?cat=" |
Re: spitting variables
Try this:
Code:
{foreach from=$location item=foo} (removed the [position]) |
Re: spitting variables
You are welcome Andy. Glad to help
|
All times are GMT -8. The time now is 08:04 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.