X-Cart/Smarty Custom PHP Scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • empiresolutions
    New Member
    • Apr 2006
    • 162

    X-Cart/Smarty Custom PHP Scripts

    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.
    [php]
    {foreach from=$categorie s item=c}

    <div>

    <div><img name="{$c.categ ory}_" src="{$ImagesDi r}/custom/paw.gif"></div>
    <div><a href="home.php? cat={$c.categor yid}">{$c.categ ory}</a></div>

    </div>

    {/foreach}
    [/php]I need to remove spaces in the names given at
    Code:
    name="{$c.category}_"
    I want to make it
    Code:
    name="{str_replace(" ","_",$c.category)}_"
    My attempts don't work and I get this error
    Error: Smarty error: [in customer/categories.tpl line 26]: syntax error: unrecognized tag: str_replace(" ","_",$c.catego ry) (Smarty_Compile r.class.php, line 436) in C:\apache2triad \htdocs\clients \sitename.com\w ww\Smarty-2.6.12\Smarty.c lass.php on line 1095
    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.
  • empiresolutions
    New Member
    • Apr 2006
    • 162

    #2
    Thanks Jay. Here's the solution-
    Code:
    {$c.category|replace:" ":""}
    im now finding that slashes are not allowed either.
    Code:
    {$c.category|replace:" ":""|replace:"/":""}
    works too. sweet.

    Comment

    Working...