Create UDT using pretty url from news

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
xmas3
Forum Members
Forum Members
Posts: 41
Joined: Sat Jul 28, 2007 9:22 am
Location: Bratislava / Slovakia

Create UDT using pretty url from news

Post 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
JeremyBASS

Re: Create UDT using pretty url from news

Post 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`\/)/":""}
Last edited by JeremyBASS on Thu Mar 19, 2009 4:17 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”