Navigator and Page 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
howey
Forum Members
Forum Members
Posts: 158
Joined: Fri Sep 14, 2007 1:05 pm

Navigator and Page Title

Post by howey »

Hi

I am trying to use the page title in a simple menu based on page images. I have tried the code below:

Code: Select all

{* image matrix navigation *}
{if !isset($depth)}{$depth=0}{/if}
{if isset($nodes)}{strip}
  {foreach $nodes as $node}
  
    <div class="content-image">
        <img src='{$node->image}' alt='{$node->title}' >
        <a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}>
            <p>{$node->pagetitle}<br>{$node->titleattribute}</p>
        </a>
    </div>

  {/foreach}
{/strip}{/if}
Everything works apart from accessing the Page Title. I've tried

Code: Select all

$node->pagetitle
and

Code: Select all

$node->title
This is what generated:

Code: Select all

<div class="content-image"><img src='http://localhost:8888/ida/uploads/images/project_pages/test-image.jpg' alt='' ><a href="http://localhost:8888/ida/index.php?page=test-project"><p><br>Description</p></a></div>
You'll see the alt tag is empty and the first bit in the p tag is empty.

The guide isn't clear whether you can use page titles in navigation

$node->titleattribute -- Description, or Title attribute (title), if defined.

There isn't a specific mention of Page title in the nodes.

Probably really obvious, but I can't get there.

Thanks
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm
Location: Marlow, UK

Re: Navigator and Page Title

Post by scooper »

You can use print_r as a modifier on Smarty tags to show what variables are available. So for example if I do

Code: Select all

{$node|print_r}
to my menu template I get the following info (and a very messy page of course):

Code: Select all

NavigatorNode Object
(
    [id] => 37
    [url] => https://www.millipedia.co.uk/example-page.html
    [accesskey] => 
    [type] => content
    [tabindex] => 0
    [titleattribute] => 
    [modified] => 1516716138
    [created] => 1513343652
    [hierarchy] => 2.1
    [depth] => 1
    [menutext] => Example Page
    [raw_menutext] => Example Page
    [target] => 
    [alias] => example-page
    [current] => 
    [parent] => 
    [has_children] => 
    [children_exist] => 
    [extra1] => 
    [extra2] => 
    [extra3] => 
)
So that's telling me that $node doesn't have the page title attribute stored - although it does have 'menutext' which might do you...

If you really want the page title rather than the menu text then you'll have to do some extra work to grab it.
I'd jump straight for the CGSimpleSmarty module which will get page titles for you. Once you have CGSimpletSmarty installed then you can use something like

Code: Select all

{cgsimple::get_page_title($node->alias)}
in your menu template. It might slow things down a bit but I'm sure we've done it in the past and it worked ok.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Navigator and Page Title

Post by velden »

Check also the page_attr tag which is available in latest CMSMS:
What does this do?
This tag can be used to return the value of the attributes of a certain page.

How do I use it?
Insert the tag into the template like: {page_attr key="extra1"}.

What parameters does it take?
(optional) page (int|string) - An optional page id or alias to fetch the content from. If not specified, the current page is assumed.
key [required] The key to return the attribute of.
The key can either be a block name, or from a set of standard properties associated with a content page. Some of the accepted standard properties are:

_dflt_ - (string) The value for the default content block (an alias for content_en).
title
description
...
Further, I *think* in 2.3 (or perhaps earlier 2.2.x releases) the title attribute might be available in Navigator. I think so because of a recent submit in svn:

Code: Select all

svn: cmsmadesimple - branches/v2.3_dev (rev: 11614) calguy1000: Adds the title property to each navigator node.
Post Reply

Return to “CMSMS Core”