Monday, August 24, 2009

Anchor based redirection in Smarty

Ciao,

There are few situations when we have to hyperlink another server directories or files. Apart from doing it with coding there is a solution in Smarty template (assuming that your path is stored in database like \\ab\bc\cd\ef.doc

< a href="http://{$Myresults[uses].directory|replace:"\\ab":"pq/yz"|replace:"\\":"/"|escape:"htmlall"}" target="dynamic" >
Remember there are 2 replace (called modifiers in smarty). First one changes the base directory to another directory. Second one replaces all backslash (\) to a Slash (/). And at the end escape works fine for each occurrences of slash.


happy coding.

No comments:

Post a Comment