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

NEED HELP FAST !!!

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-23-2003, 06:50 AM
 
garryhs garryhs is offline
 

Senior Member
  
Join Date: Sep 2002
Location: Australia
Posts: 159
 

Default NEED HELP FAST !!!

I have a value in a template, lets call it {$code}
This value is 4 characters long. (ie "SDUI")
I need to display the 2nd character only.

Remember that I am in a template. In VB it would be something like
SUBSTR($code,2,1).

How do you display the 2nd character on the screen, without showing the other three characters from within a .tpl file.....

PLEASE HELP ANYBODY ???
__________________
All versions of X-Cart

Been in eCommerce 10 years, Coding, PM, SEO, Social. X-Cart 11 years. IT 30+ years.

Head of Web Dev for Australia's largest eCommerce 2 years.

Attended conferences, Velocity 2009 US, CeBit 2009, MySQL 2010 US, Online Retailer 2010, Web 2.0 2011 US, MySQL 2012 US (Percona).

Specialise in High Performance, High Volume, PHP, MySQL, HTML, CSS, JAVASCRIPT, SMARTY, MEMCACHED, APACHE, LIGHTTPD, FREEBSD, LINUX.

Email your requests to xcart@gazwebtech.com
Reply With Quote
  #2  
Old 07-23-2003, 10:39 AM
  kpayne's Avatar 
kpayne kpayne is offline
 

X-Adept
  
Join Date: Dec 2002
Location: Firetanksoftware.com
Posts: 469
 

Default

I couldn't find a smarty modifier to do this automatically, so here's the plan:

In your smarty.php file, add this code:

Code:
$smarty->register_modifier("substr", "substr");

Right above this line:

Code:
$mail_smarty = $smarty;

Then in your templates, you can say:

Code:
{$code|substr:1,1}

Remeber that the 1st character of a string is in position 0 so the 2nd character is in position 1.

Hope this helps!

(This is untested, BTW)
__________________
X-cart Featured Products Manager from http://www.firetanksoftware.com - Put your products where you want, how you want.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:10 PM.

   

 
X-Cart forums © 2001-2020