Accessing current page alias in a userdefined tag

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
anthony
Forum Members
Forum Members
Posts: 37
Joined: Thu Jun 22, 2006 12:50 am

Accessing current page alias in a userdefined tag

Post 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.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Accessing current page alias in a userdefined tag

Post 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.
anthony
Forum Members
Forum Members
Posts: 37
Joined: Thu Jun 22, 2006 12:50 am

Re: Accessing current page alias in a userdefined tag

Post by anthony »

RonnyK wrote: 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.
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.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Accessing current page alias in a userdefined tag

Post 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
Last edited by RonnyK on Tue Mar 27, 2007 11:47 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Accessing current page alias in a userdefined tag

Post 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');
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
anthony
Forum Members
Forum Members
Posts: 37
Joined: Thu Jun 22, 2006 12:50 am

Re: Accessing current page alias in a userdefined tag

Post 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 :-).
Post Reply

Return to “Developers Discussion”