• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Navigator and Page Title
PostPosted: Wed Mar 21, 2018 6:05 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Sep 14, 2007 1:05 pm
Posts: 140
Location: South Derbyshire – UK
Hi

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

Code:
{* 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:
$node->pagetitle
and
Code:
$node->title


This is what generated:
Code:
<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


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Navigator and Page Title
PostPosted: Thu Mar 22, 2018 9:16 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Dec 09, 2005 12:36 pm
Posts: 228
Location: Marlow, UK
You can use print_r as a modifier on Smarty tags to show what variables are available. So for example if I do

Code:
{$node|print_r}

to my menu template I get the following info (and a very messy page of course):
Code:
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:
{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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Navigator and Page Title
PostPosted: Thu Mar 22, 2018 3:16 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3028
Location: The Netherlands
Check also the page_attr tag which is available in latest CMSMS:

Quote:
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:
svn: cmsmadesimple - branches/v2.3_dev (rev: 11614) calguy1000: Adds the title property to each navigator node.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Hosting Nation - Managed CMSMS Hosting