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

Add emphasis to category heading in smarty

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-21-2010, 01:05 AM
 
Bellarama Bellarama is offline
 

Newbie
  
Join Date: Oct 2010
Posts: 1
 

Default Add emphasis to category heading in smarty

Hello,

Just looking for some guidance on how to add in some em tags within smarty

In my template is the following code:
Code:
{if $page_title} <h1>{$page_title|escape}</h1> {/if}

What I would like to do, is detect whether the title is more than one word, and if it is wrap the subsquent words in em tags, so I can style them different.

So for example this is what i want to achieve:
HTML Code:
<h1>New <em>Arrivals</em></h1>

I tried to write some code using the same syntax as the rest of the smarty template, like so:
Code:
{if $page_title} {$space_location = strpos($page_title," "); }{*finds the location of the first space, if there is one*} {if $space_location}{*if there is a space (a second word exists in the subject)*} {*take the location between first position and space and add an em tag*} {$thisPageTitle = substr($page_title, 0, $space_location) . "<em>" . substr($page_title, $space_location)} {*add a closing em tag to end of string*} {$thisPageTitle = thisPageTitle . "</em>"} {else} {$thisPageTitle = $page_title} {/if} <h1>{$thisPageTitle|escape}</h1> {/if}

However this actually doesn't work, so I was wondering if it is possible to do what I want and if so how would I do that??


Many Thanks!!!

Christine
__________________
X-Cart Version 4.4.1
Reply With Quote
  #2  
Old 10-21-2010, 12:09 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Add emphasis to category heading in smarty

You can use this method which acts similar to a split:

Code:
{ assign var=pageTitleArray value=" "|explode:$page_title }
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
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 02:27 PM.

   

 
X-Cart forums © 2001-2020