X-Cart/Smarty Custom PHP Scripts

Discussion in 'PHP' started by cesarcesar, Mar 16, 2008.

  1. #1
    i have what may be a very simple question for someone who has worked with X-Cart or Smarty.

    I am adding a rollover image next to the category names in the main navigation. The following is my stripped down for this post version.
            
    {foreach from=$categories item=c}
    
         <div>
    
              <div><img name="{$c.category}_" src="{$ImagesDir}/custom/paw.gif"></div>
              <div><a href="home.php?cat={$c.categoryid}">{$c.category}</a></div>
    
         </div>
    
    {/foreach}
    
    PHP:
    I need to remove spaces in the names given at
    name="{$c.category}_"
    Code (markup):
    I want to make it
    name="{str_replace(" ","_",$c.category)}_"
    Code (markup):
    My attempts don't work and I get this error
    My question is.. How can I make PHP functions work in X-Cart/Smarty?

    I cant even find where $c.category is set. Thanks much.
     
    cesarcesar, Mar 16, 2008 IP
  2. cesarcesar

    cesarcesar Peon

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Thanks Jay. Here's the solution-
    {$c.category|replace:" ":""}
    Code (markup):
    im now finding that slashes are not allowed either.
    {$c.category|replace:" ":""|replace:"/":""}
    Code (markup):
    works too. sweet.
     
    cesarcesar, Mar 16, 2008 IP