Page 1 of 1
Page alias or id from Title
Posted: Sat Oct 30, 2010 12:03 pm
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
Re: Page alias or id from Title
Posted: Sat Oct 30, 2010 12:45 pm
by cyberman
Not sure if it will be for your needs but make a look for CGSimpleSmarty
http://dev.cmsmadesimple.org/projects/cgsimplesmarty
Re: Page alias or id from Title
Posted: Sat Oct 30, 2010 12:48 pm
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
Re: Page alias or id from Title
Posted: Sat Oct 30, 2010 12:57 pm
by cyberman
Maybe an advanced/modified version of this udt can help
http://wiki.cmsmadesimple.org/index.php ... ps_.5B1.5D
(not checked yet)
Re: Page alias or id from Title
Posted: Sat Oct 30, 2010 3:07 pm
by Wishbone
nevermind.. I misread the original post.
Re: Page alias or id from Title
Posted: Sat Oct 30, 2010 4:41 pm
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...
Re: Page alias or id from Title
Posted: Sat Oct 30, 2010 10:02 pm
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:
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.
Re: Page alias or id from Title
Posted: Sun Oct 31, 2010 2:08 pm
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.
Re: Page alias or id from Title
Posted: Sun Oct 31, 2010 8:12 pm
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...
Re: Page alias or id from Title
Posted: Sun Oct 31, 2010 8:20 pm
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