Page 1 of 1

How to: create UDT to convert $page_alias string to...

Posted: Thu Jan 23, 2014 11:27 pm
by soportepro
I do not hav experience with UDT, and now my brain is off :)

Really I thing that this is simple but however I need your help, please.

pagealias is "string-string-string"
gallery dir is "string_string_string"

I try to call page alias inside gallery tag as this:
{Gallery dir="$page_alias"}

It works, but...

But it fails when the alias have "-" and the created gallery dir have "_"

I think that I need an UDT that use this php function:

$alias2dir = str_replace('-', '_', $page_alias);

This is where my brain fails.
I do not understand how to complete my udt.

udt input: page_alias
udt output: alias string converted to dir string

My suggested UDT name is: alias2dir

Thanks in advance for all your help.

Re: How to: create UDT to convert $page_alias string to...

Posted: Fri Jan 24, 2014 4:06 am
by Jo Morg
You don't need an UDT for that. Just use some Smarty magic:

Code: Select all

{Gallery dir=$page_alias|replace:"-":"_"}
That should do the trick.

Re: How to: create UDT to convert $page_alias string to...

Posted: Fri Jan 24, 2014 5:03 pm
by soportepro
Thanks very much. :)