how to get the url of a specified page from its alias or id [SOLVED]

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

how to get the url of a specified page from its alias or id [SOLVED]

Post 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.
Last edited by isaacd on Sun Feb 21, 2010 8:22 pm, edited 1 time in total.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: how to get the url of a specified page from its alias or id

Post 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...
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Re: how to get the url of a specified page from its alias or id

Post 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).
nhaack

Re: how to get the url of a specified page from its alias or id

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

Code: Select all


{cms_selflink href="mission"}

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
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Re: how to get the url of a specified page from its alias or id

Post 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.
Last edited by isaacd on Sun Feb 21, 2010 12:04 am, edited 1 time in total.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: how to get the url of a specified page from its alias or id

Post by Jeff »

Then use the 'href' parameter and use {capture} if you need it in a variable.
nhaack

Re: how to get the url of a specified page from its alias or id

Post 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
isaacd
Forum Members
Forum Members
Posts: 32
Joined: Wed Dec 16, 2009 12:54 am

Re: how to get the url of a specified page from its alias or id

Post by isaacd »

{cms_selflink href="the page" assign="url"} worked for me. Thanks.
Post Reply

Return to “CMSMS Core”