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

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
soportepro
Forum Members
Forum Members
Posts: 57
Joined: Fri Nov 04, 2011 10:10 pm

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

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
soportepro
Forum Members
Forum Members
Posts: 57
Joined: Fri Nov 04, 2011 10:10 pm

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

Post by soportepro »

Thanks very much. :)
Post Reply

Return to “The Lounge”