Page 1 of 1

Create UDT using pretty url from news

Posted: Wed Mar 18, 2009 10:42 pm
by xmas3
Hi all,
I would like to create an UDT that will generate a link to file, using the pretty url parameter inside.
F.e. if the page pretty url is like news/12/6/my-first-article then the UDT will create the
link to the file named my-first-article.pdf

something like this

Code: Select all

echo '<a href="../images/'.$pretty-url.'.pdf">';
echo 'Click here'</a>';
How to extract the pretty-url article name and put it into the UDT?

Thanks a lot,
Miro

Re: Create UDT using pretty url from news

Posted: Thu Mar 19, 2009 4:14 pm
by JeremyBASS
if your wanting the name of the article from the URL, try something like this

http://forum.cmsmadesimple.org/index.ph ... #msg145249



just remove the |replace:'-':' ' from

{assign var=newstitle value=$URLSS|replace:'.html':''|regex_replace:'/(http.*?\/72\/)/':''|replace:'-':' '}

and
http://domain.tld/news/12/6/my-first-article

should trun in to


my-first-article



so end product would be something like


{capture assign='URLSS'}{URLhere}{/capture}
{assign var=newstitle value=$URLSS|replace:'.html':''|regex_replace:'/(http.*?\/72\/)/':''}
   

in the template... but you always just use the news title with the |replace there too

Many ways to skin this cat...




cheers
jeremyBass

*********edit**************


you may also do this

{assign var=newstitle value=$URLSS|replace:".html":''|regex_replace:"/(http.*?\/`$content_id`\/)/":""}