Page 1 of 1

how to get the current url in a user defined tag [SOLVED]

Posted: Sun Feb 14, 2010 3:33 pm
by isaacd
Hello.

I am trying to get the current url in a user defined tag. I tried the method suggested on http://wiki.cmsmadesimple.org/index.php ... fined_Tags , and it did not work correctly. This is what it is:

 global $gCms;
 $hm =& $gCms->GetHierarchyManager();
 $curnode =& $hm->getNodeById($page_content_id);
 $curcontent =& $curnode->GetContent();
 echo 'Page URL: ' . $curcontent->GetURL();

I also tried changing $page_content_id to $page_id, and $content_id (I looked at the template vars and I think $contnet_id is correct).

What happens is any content below the tag is simply not displayed.

Thanks in advance
   Isaac.

Re: how to get the current url in a user defined tag

Posted: Sun Feb 14, 2010 4:12 pm
by JeremyBASS
that only works if you’re on a page... ie: if you’re in let’s say news, and you move to an article it'll fail... so there is a udt I wrote .. I think it's in the tips and tricks that get the url no matter where in the site your at... if you can't find it in the tips and tricks area (it's from 6mnt-a year ago) I can dig it up.. It'll just be a bit...

Cheers
Jeremy

Re: how to get the current url in a user defined tag

Posted: Sun Feb 14, 2010 6:13 pm
by isaacd
JeremyBASS,

I found this of yours:

http://forum.cmsmadesimple.org/index.ph ... 018.0.html

The second block of code gets the url, with the exception that "assume_mod_rewrite" is changed to "url_rewriting", and the option "true" is changed to "mod_rewrite".

Thanks

Re: how to get the current url in a user defined tag [SOLVED]

Posted: Sun Feb 14, 2010 10:41 pm
by JeremyBASS
Super, Glad I was some help... good karma for the soul :D... yeah that post was in the time of cmsms 1.5.4 ... so it needs some updating... glad you got it.. Cheers -Jeremy