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