Page 1 of 1
Accessing current page alias in a userdefined tag
Posted: Wed Mar 21, 2007 8:18 pm
by anthony
I am creating my own UDT and am having trouble figuring out how I can access the current page alias.
What really would be helfpul is any type of documentation that would list out everything that is available in the $GLOBALS['gCms'] array because ultimately I would like to use the full-path to the current file for a custom form that I am creating.
For example if I could figure out this full path,
http://www.domain.com/contact/form/, from inside the tag if the 'form' page is the current page that I am on it would make life easier.
If that makes sense, any help would be appreciated. If you need some clarification, just let me know.
Re: Accessing current page alias in a userdefined tag
Posted: Wed Mar 21, 2007 8:41 pm
by RonnyK
You could give
{get_template_vars} on a content-page to see all passed variables.
I used the "mailtofriend"-tag to pass the referer-URL in the message-subject. The code initially passed the current-page (your request), but that would put the page on which te mailtofriend-tag was shown instead of request.
Ronny
I think that things like currenturl, referer etc... are existing PHP-parameters, that can be called without real scrpting required. If you chec:
http://www.phpfreaks.com/PHP_Reference/ ... bles/8.php
you'll find some usefull predefined variables.
Re: Accessing current page alias in a userdefined tag
Posted: Wed Mar 21, 2007 8:44 pm
by anthony
I guess that is a good point. So far, I've noticed whenever I try to do a bit more coding I eventually find out that there already is some pre-existing code to do what I was trying in CMSMS. While it makes me feel not all that smart, it does reinforce the community for sure.
Re: Accessing current page alias in a userdefined tag
Posted: Tue Mar 27, 2007 11:44 am
by RonnyK
You might check here for some standard PHP-variables.
http://www.phpfreaks.com/PHP_Reference/ ... bles/8.php
You might have to combine two variables to get the complete set. But basically thez
Ronny
Re: Accessing current page alias in a userdefined tag
Posted: Tue Mar 27, 2007 5:18 pm
by calguy1000
the $page_alias variable in smarty contains the current page alias.
To access this within a UDT, you'd do this:
Code: Select all
global $gCms;
$smarty =& $gCms->GetSmarty();
$page_alias = $smarty->get_template_vars('page_alias');
Re: Accessing current page alias in a userdefined tag
Posted: Tue Mar 27, 2007 5:55 pm
by anthony
calguy1000 wrote:
the $page_alias variable in smarty contains the current page alias.
To access this within a UDT, you'd do this:
Code: Select all
global $gCms;
$smarty =& $gCms->GetSmarty();
$page_alias = $smarty->get_template_vars('page_alias');
As I suspected, it was built in already. Thanks

.