SOLVED - PHP: How to get the TITLE of a page

General project discussion. NOT for help questions.
Post Reply
jsmonzani
Forum Members
Forum Members
Posts: 54
Joined: Mon Apr 03, 2006 10:58 am

SOLVED - PHP: How to get the TITLE of a page

Post by jsmonzani »

Hello my friends,

I've already spent a few hours on this and can't find the answer  ???

I'm writing a code which lists the direct children of a page: I currently display the MenuText that corresponds to each children, but I would like now to display their full title instead. I've tried TitleAttribute first but noticed that it was a complete different attribute.

Is the title stored in the Content object? I can't find it out.
Can anybody help me finding *where* this title is stored, please?

EDIT: I've just discovered that these nodes are from the class Tree (lib/tree/Tree.php) which I couldn't find in the documentation http://www.cmsmadesimple.org/apidoc/ ... but I don't think the TreeNode handle the titles anyway.


Thank you very much for your help

Code: Select all

global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
  echo '<ul>';
  foreach ($nodes as $node) {
     $content= $node->getContent();
     $url = $content->GetURL();
    echo "<li><a href=\"".$url."\">";
    echo $content->MenuText();
    echo"</a> </li>";

  }
  echo "</ul>";


}
Last edited by jsmonzani on Wed Jan 23, 2008 1:36 pm, edited 1 time in total.
An approach to mutli-lingual CMSMS using only content blocks:
http://forum.cmsmadesimple.org/index.ph ... 756.0.html
jsmonzani
Forum Members
Forum Members
Posts: 54
Joined: Mon Apr 03, 2006 10:58 am

Re: SOLVED - PHP: How to get the TITLE of a page

Post by jsmonzani »

OK, I've found the solution, but I had to dig into Content.inc.php.

Basically, the name of the title is stored in the mName attribute

Therefore, using

Code: Select all

echo $content->mName; 
instead of the of the menu name in the previous code will work.

Not that straightforward. I hope it will help others  ;D
An approach to mutli-lingual CMSMS using only content blocks:
http://forum.cmsmadesimple.org/index.ph ... 756.0.html
Post Reply

Return to “General Discussion”