Page 1 of 1
how to get the url of a specified page from its alias or id [SOLVED]
Posted: Sat Feb 20, 2010 3:56 am
by isaacd
I would like to be able to have some way to get the url of a page with certain alias, or ID. I would like to be able to specify an alias/id and then get the url of that page.
Thanks in advance.
Isaac.
Re: how to get the url of a specified page from its alias or id
Posted: Sat Feb 20, 2010 4:47 am
by jmcgin51
not sure exactly what you're asking.
if your page alias is "home", then the url for that page is
http://www.yourdomain.tld/index.php?page=home
or, if you're using pretty URLs
http://www.yourdomain.tld/home.html (or .php, or .whatever)
I'm assuming you already know all of this, and are looking for something else, but I'm not sure what...
Re: how to get the url of a specified page from its alias or id
Posted: Sat Feb 20, 2010 6:48 pm
by isaacd
I have pretty URLs set up like this:
-Hierarchy enabled
-No page extension
I would like to be able to get the url of a page simply by providing an alias. I would like the url to include the hierarchy. Conceptually, something like this:
{get_page_url alias="mission" assign="$url"}
{$url}
And then that would display this:
http://www.trilliumcharterschool.org/about/mission
I would just add the page alias on the end of
http://www.trilliumcharterschool.org but I need hierarchy in the url (ie in the example above, I need /about before /mission).
Re: how to get the url of a specified page from its alias or id
Posted: Sat Feb 20, 2010 9:27 pm
by nhaack
If you have the alias already at hand, why not use cms_selflink?
E.g.
Code: Select all
{cms_selflink page=$the_alias}
or
{cms_selflink page="mission"}
This will generate a link to the corresponding page, using the CMSMS hierarchy settings. It is also possible to only receive the href value or to specify the text used for the link. E.g.
Just check the information that comes with the tag. It will tell you about the options available - it's a very versatile tag.
Best
Nils
Re: how to get the url of a specified page from its alias or id
Posted: Sun Feb 21, 2010 12:02 am
by isaacd
I am not looking for a link, I am looking for a variable, so I can use an if statement. Something like this:
{if $url == "blah"}
do something
{else}
do something else
{/if}
This has to be a URL. I can not use an alias.
Thanks.
Re: how to get the url of a specified page from its alias or id
Posted: Sun Feb 21, 2010 2:05 am
by Jeff
Then use the 'href' parameter and use {capture} if you need it in a variable.
Re: how to get the url of a specified page from its alias or id
Posted: Sun Feb 21, 2010 4:59 am
by nhaack
Or use the assign parameter of the cms_selflink tag
Code: Select all
{cms_selflink href="mission" assign="what"}
{if $what== "http://...."}
do something
{else}
do something else
{/if}
again, most of the core tags and module and many other tags and module have enough documentation to get things going. Please read such stuff.
Best
Nils
Re: how to get the url of a specified page from its alias or id
Posted: Sun Feb 21, 2010 8:21 pm
by isaacd
{cms_selflink href="the page" assign="url"} worked for me. Thanks.