Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

spitting variables

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-28-2009, 05:36 AM
 
Knickershack Knickershack is offline
 

Member
  
Join Date: Apr 2008
Posts: 25
 

Default 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
__________________
Branch 4.1.11

Lingerie site
Reply With Quote
  #2  
Old 08-28-2009, 05:47 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 09-01-2009, 02:23 PM
 
Knickershack Knickershack is offline
 

Member
  
Join Date: Apr 2008
Posts: 25
 

Default 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.
__________________
Branch 4.1.11

Lingerie site
Reply With Quote
  #4  
Old 09-01-2009, 02:32 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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.....
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 09-01-2009, 02:43 PM
 
Knickershack Knickershack is offline
 

Member
  
Join Date: Apr 2008
Posts: 25
 

Default 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
__________________
Branch 4.1.11

Lingerie site
Reply With Quote
  #6  
Old 09-01-2009, 02:49 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: spitting variables

I am away from my desk at the moment I'll check on this later
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 09-01-2009, 04:27 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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="
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #8  
Old 09-02-2009, 05:59 AM
  rogue's Avatar 
rogue rogue is offline
 

X-Adept
  
Join Date: Apr 2007
Location: Loveland, Ohio
Posts: 770
 

Default Re: spitting variables

Try this:

Code:
{foreach from=$location item=foo} {$foo} {/foreach}

(removed the [position])
__________________
Richard Williams
Rogue Wave Limited

Initial Inventory Imports
Daily Inventory Updates
Daily Inventory Reports
Drop Ship Support
Order Export to Shipper/Supplier
Shopping Feeds That Work
Programming for X-Cart

richard@roguewavelimited.com
http://www.roguewavelimited.com
Reply With Quote
  #9  
Old 09-02-2009, 06:16 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: spitting variables

You are welcome Andy. Glad to help
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:21 PM.

   

 
X-Cart forums © 2001-2020