Page alias or id from Title
Page alias or id from Title
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
TIA,
Sanjay
Re: Page alias or id from Title
Not sure if it will be for your needs but make a look for CGSimpleSmarty
http://dev.cmsmadesimple.org/projects/cgsimplesmarty
http://dev.cmsmadesimple.org/projects/cgsimplesmarty
Re: Page alias or id from Title
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
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
Maybe an advanced/modified version of this udt can help
http://wiki.cmsmadesimple.org/index.php ... ps_.5B1.5D
(not checked yet)
http://wiki.cmsmadesimple.org/index.php ... ps_.5B1.5D
(not checked yet)
Re: Page alias or id from Title
nevermind.. I misread the original post.
Re: Page alias or id from Title
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...
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
Here's your UDT:
aliasfromtitle:
Usage:
Note that if you have two pages with the same title, it will return the first one found.
aliasfromtitle:
Code: Select all
global $gCms;
$cntnt = $gCms->getContentOperations();
foreach ($cntnt->GetAllContent() as $page) {
if ($page->mName == $params['title']) {
echo($page->mAlias);
break;
}
}
Code: Select all
{aliasfromtitle title="Practice"}
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.Dr.CSS wrote: Of course it would help if you said why you want them or what your going to do with them...
Last edited by Wishbone on Sat Oct 30, 2010 11:25 pm, edited 1 time in total.
Re: Page alias or id from Title
@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.
@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
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...
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
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
- 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