Not logged in. · Lost password · Register
Forum: General Help and Support Templates and Layout RSS
Metadata: p_get_metadata($ID,'internal toc') returns true even if there's no TOC content
Avatar
ClairelyClaire #1
Member since Mar 2019 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Metadata: p_get_metadata($ID,'internal toc') returns true even if there's no TOC content
Basically what the subject says.

Live repro:
http://www.abettergeek.com/start

The NAV element for the table of contents is wrapped in this conditional:
<?php if (p_get_metadata($ID,'internal toc') || strstr($_SERVER['QUERY_STRING'],'do=admin&page=config')) : ?>

TOC is returning "true" even though no TOC is passed to the renderer.
Avatar
turnermm (Moderator) #2
Member since Oct 2009 · 4711 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
I did a quick check.  The toc key returns true if the page can display a toc, not if it currently has one.  So, if you add the ~~NOTOC~~ macro to the page, then the value for the toc key will be false.

Attached is a script that will read meta files (and as a bonus) unpack .gz files.  It will have to be unzipped.

You use it from the command line: 
[root@dirname meta]# get_inf.php <metafile.meta>


If your php binary doesn't happen to be in the default directory you will have to use: php get_inf.php
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
The author has attached one file to this post:
get_inf.zip 532 Bytes
You have no permission to open this file.
Avatar
ClairelyClaire #3
Member since Mar 2019 · 4 posts
Group memberships: Members
Show profile · Link to this post
Oh...that's a bit confusing. What should I use in my template if I want to hide the frame elements containing the TOC, if there's no actual TOC present? Is there an existing function for this?

ETA: Okay, I think I figured this out. The comments in the function seem to indicate the opposite of what actually happens:

* @param bool $return Should the TOC be returned instead to be printed?

This defaults to false, and the language of the comment in code suggests that it should be "true" if the TOC should be "returned to be printed". False returns the TOC; True does not, and instead returns a string of the TOC content. I think this should be more clear in the source code.
This post was edited on 2019-09-15, 07:15 by ClairelyClaire.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-10-16, 06:54:58 (UTC +02:00)