Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    55

    Unanswered: 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 Code:
    {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} 
    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.category) (Smarty_Compiler.class.php, line 436) in C:\apache2triad\htdocs\clients\sitename.com\www\Sm arty-2.6.12\Smarty.class.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.

  2. #2
    Join Date
    Mar 2008
    Posts
    55
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •