Page 1 of 1

To get parent_id of a child-page ?

Posted: Fri Oct 10, 2008 10:31 am
by Trangsene
Hello I try do do a simple thing, to get the parent_id of a child-page.
I've installed CGSimpleSmarty which permits me to get the parent's alias. So it's quite what I needed.

But I was wandering, is there a quick smarty syntax to get the parent_id of a child-page ???
Something like (not working) :

Code: Select all

global $gCms;
$thispage = "";
$thispage = $gCms->variables['parent_id'];
echo "<p>Parent ID : ".$thispage."</p>";
Or I have to go through an SQL request using the content_id of the child-page in order to get the parent_id ?

Re: To get parent_id of a child-page ?

Posted: Wed Oct 15, 2008 4:41 pm
by Augustas
I think there is no such quick way to do it.
Use cgsimplesmarty to get Parent Alias, and once you have it - make simple SQL query to the Content table to get the ID of the page whose Alias you already know.