Page alias or id from Title

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
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Page alias or id from Title

Post by spcherub »

Is there a quick way to find a page id or alias from its Title? I could write a UDT to query the database, but I was wondering if there was an existing method, UDT or module that was already capable of doing this. I realize that the function (if it existed) would return an array of matching page ids/aliases (not juts a single one), but that is ok as well.

TIA,
Sanjay
cyberman

Re: Page alias or id from Title

Post by cyberman »

Not sure if it will be for your needs but make a look for CGSimpleSmarty

http://dev.cmsmadesimple.org/projects/cgsimplesmarty
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Page alias or id from Title

Post by spcherub »

Cyberman,

I already looked into the functions supported by CGSimpleSmarty. Unfortunately the function I am looking for does not exist there (yet). I can use it to get title by alias, but I am looking to do the opposite - get alias by title.

Thanks,
Sanjay
cyberman

Re: Page alias or id from Title

Post by cyberman »

Maybe an advanced/modified version of this udt can help

http://wiki.cmsmadesimple.org/index.php ... ps_.5B1.5D

(not checked yet)
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Page alias or id from Title

Post by Wishbone »

nevermind.. I misread the original post.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Page alias or id from Title

Post by Dr.CSS »

You could just hover the name in content > pages and it will show it in (page alias)...

Of course it would help if you said why you want them or what your going to do with them...
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Page alias or id from Title

Post by Wishbone »

Here's your UDT:

aliasfromtitle:

Code: Select all

global $gCms;
$cntnt = $gCms->getContentOperations();

foreach ($cntnt->GetAllContent() as $page) {
  if ($page->mName == $params['title']) {
    echo($page->mAlias);
    break;
  }
}
Usage:

Code: Select all

{aliasfromtitle title="Practice"}
Note that if you have two pages with the same title, it will return the first one found.
Dr.CSS wrote: Of course it would help if you said why you want them or what your going to do with them...
I'm sorta curious myself how this UDT could possibly be useful, or if there is a better way to do what you are trying to do.
Last edited by Wishbone on Sat Oct 30, 2010 11:25 pm, edited 1 time in total.
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Page alias or id from Title

Post by spcherub »

@Wishbone - thanks for the UDT. I will give it a try

@Wishbone and @Dr.CSS - Kinda hard to explain why I need this, but will try.

Let's say I'm modeling Album Releases (for a record company) as a set of pages (1 per release) and have them listed under a section header "Releases". The page template for a release contains a list of tracks (track titles and associated mp3 files) - done using content blocks and GBFilePicker.

Now I am being asked to "associate" some of these releases with the Artist pages which are separate pages under a separate Section Header - the purpose is to feature some tracks from the associated release on the Artist page. I know I could use Attach module, but I am also required to allow the editor to select the order in which these releases appear - which I think the Attach module does not allow. To complicate this, featured videos also need to be associated with the Artist pages. So I created a sequence of sub-pages for associated releases and featured videos. I don't want the author to have to make a second copy of the release just for this purpose. I was hoping to allow them to simply enter the title and have the system find the existing page with the same title elsewhere and extract the content for display.

I did try using an InternalLink content type (pointing to the existing release page). But CGSimpleSmarty is not (currently) capable of reading "through" a link to underlying target page.

Hence my need for this UDT. Hope that makes sense!

Thanks.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Page alias or id from Title

Post by Dr.CSS »

There is a couple of ways I've heard about doing this...

1) CGSimpleSmarty to pull content from one page to another...

2) ContentDump module which basically, from what I've heard, does the same thing...

I've never used either one...
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Page alias or id from Title

Post by spcherub »

The way I have addressed this for now is:
- Created sub-pages using the InternalLink content type. Sub-pages point to actual release pages elsewhere on the site (where actual content resides)
- Within a MenuManager template, I parse out the value of $node->url and get the alias value of the target
- Use CGSimpleSmarty to pull required content fields from this alias

I wish there was a way to create a simple "shortcut" or "alias" to an existing page, which when accessed will appear to be just like the original page (content and all). This will allow me to put these shortcuts in many places but only have to edit the actual page in one place.

Thanks for the advice.

Sanjay
Post Reply

Return to “CMSMS Core”