How to use this function in Smarty?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    How to use this function in Smarty?

    Hi,

    Can someone please help me, i am trying to use this function but simply wont display when i try it.

    The function is:

    [php]function stripres($value ){

    $value = strtr($value, "éèêàëâúóíáABCD EFGHIJKLMNOPQRS TUVWXYZ. ","eeeaeauoiaab cdefghijklmnopq rstuvwxyz--");
    $value = ereg_replace('[^a-zA-Z0-9_-]', '', $value);

    return $value;

    }[/php]

    I am trying to use this by:

    {stripres($resu lt.subcategory) }

    What am i doing wrong?

    Cheers,
    Adam
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Originally posted by adamjblakey
    Hi,

    Can someone please help me, i am trying to use this function but simply wont display when i try it.

    The function is:

    [php]function stripres($value ){

    $value = strtr($value, "éèêàëâúóíáABCD EFGHIJKLMNOPQRS TUVWXYZ. ","eeeaeauoiaab cdefghijklmnopq rstuvwxyz--");
    $value = ereg_replace('[^a-zA-Z0-9_-]', '', $value);

    return $value;

    }[/php]

    I am trying to use this by:

    {stripres($resu lt.subcategory) }

    What am i doing wrong?

    Cheers,
    Adam
    i don't think you can access PHP functions like that from smarty. You can modify smarty and add that custom function to smarty class.

    Where is your smarty assign() lines?

    My suggestion, put that into a class, create an instance, assign it to smarty and access it like this

    {$assignedName->stripres($resu lt.category)}

    IF YOU WANT TO CONVERT TO LOWERCASE DO THIS

    {$result.catego ry|lower}

    change lower to upper if you want it upper case.

    Comment

    Working...