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

smarty concatenation/modifer problem

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-20-2009, 09:20 AM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default smarty concatenation/modifer problem

I've got the following piece of code:
Code:
<a href="product.php?productid={$parts[part].productid}&amp;cat={$cat}&amp;page={$navigation_page}{if $featured eq 'Y'}&amp;featured{/if}">{include file="product_thumbnail.tpl" productid=$parts[part].productid image_x=$config.Appearance.thumbnail_width product=$parts[part].product tmbn_url=$parts[part].image_path}</a>

I need change the "adjust" the value for tmbn_url so that it is a complete path to the thumbnail ie: http://www.mysite.com/images/T/tn_partnumber.jpg

Now the $parts[part].image path has data right from table xcart_images_T that looks like ".\images\T\tn_partnumber.jpg"

The $parts array also has many other fields such as productid, productcode, filename (of the T image), etc.

Can someone help me piece these chunks together to make a path or more specifically, how do I replace the "." in the image_path with http://www.mysite.com and change the \ to / ??

Thanks.
__________________
Adam
X-Cart Gold 4.4.5 - Live
X-Cart Gold 4.1.11 - Retired
X-Payments 1.0.4
CDSEO Pro
EWD Hosting
Reply With Quote
  #2  
Old 03-21-2009, 07:59 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: smarty concatenation/modifer problem

Sounds like you have something custom going on here. You really shouldn't try to do this in Smarty, it should be done by the PHP that is providing the $parts array to your template.

If you look at product.php you'll see that it uses func_select_product to get product information into an array before making it available to the product.tpl template. func_select_product uses func_get_image_url to turn the image file name in the database into a real URL.

It would be best if your custom code did the same thing - use func_select_product to get product data so that all of the array elements work just like you are used to in the stock templates.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #3  
Old 03-23-2009, 06:50 AM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default Re: smarty concatenation/modifer problem

Yes its custom. What I've done is made a product (auto parts in our case) look up based on vehicle make, model, year. Once you've picked your vehicle the "results" page which is my modified products.tpl shows all the parts that fit you car. But I need more info in the $products array than xcart provides such as part position, qty per position, notes, power steering, 4WD, bodystyle, etc. in order to correctly narrow down the search on the results page.

My make, model, year results array is somewhat abbreviated compared to $products. I'll attempt to modify and get it more inline with $products. Also, the buy-now button on my results page is not working correctly either. I'm assuming it's due to the fact that I'm missing some of the info from $products array.

BTW, why does my custom lookup work on my local WAMP server but not on the Unix server the site is located at? It is successfully using image.php to pull the images on my 'results' page, but on products.php page after a category search, the sourcecode shows the thumbnail images with a complete path. Another thing, my admin side is using image.php to get images for the product page and it is not working either with no custom code on the admin side. Any thoughts?
__________________
Adam
X-Cart Gold 4.4.5 - Live
X-Cart Gold 4.1.11 - Retired
X-Payments 1.0.4
CDSEO Pro
EWD Hosting
Reply With Quote
  #4  
Old 03-23-2009, 08:27 AM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default Re: smarty concatenation/modifer problem

Solution or work around found. Found an old post that addressed the difference between Windows using \ in the URL and Unix using /. Changed all the backslashes to forwardslashes and all's well again. Solved the image problem in the backend and my missing thumbnails.
__________________
Adam
X-Cart Gold 4.4.5 - Live
X-Cart Gold 4.1.11 - Retired
X-Payments 1.0.4
CDSEO Pro
EWD Hosting
Reply With Quote
  #5  
Old 03-24-2009, 05:41 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: smarty concatenation/modifer problem

Quote:
Originally Posted by AMMoyer
But I need more info in the $products array than xcart provides such as part position, qty per position, notes, power steering, 4WD, bodystyle, etc. in order to correctly narrow down the search on the results page.

The best way to deal with this is to use func_select_product to get the product data and merge your additional data into the product array it returns or assign your additional data array to a different smarty variable.

Quote:
BTW, why does my custom lookup work on my local WAMP server but not on the Unix server the site is located at? It is successfully using image.php to pull the images on my 'results' page, but on products.php page after a category search, the sourcecode shows the thumbnail images with a complete path. Another thing, my admin side is using image.php to get images for the product page and it is not working either with no custom code on the admin side. Any thoughts?
You found out about the \ vs / between Linux & Windows. The reason your custom results page uses image.php and the category search uses the full URL is probably because you aren't using func_get_image_url to turn the image file name in the database into a real URL as I mentioned before. If you don't do things the same way X-Cart does you can't expect the same results.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
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 01:46 AM.

   

 
X-Cart forums © 2001-2020