Forums / Developer / embedding a toc template

embedding a toc template

Author Message

paul bolger

Wednesday 24 February 2010 3:10:46 pm

I'm trying to make an embeddable table of contents. Here's what I've done:
Created directories

extension/ezwebin_custom/settings/siteaccess/ezwebin_site_clean_user
extension/ezwebin_custom/settings/siteaccess/ezwebin_site_clean_admin

added override.ini.append.php to both with this rule:

<?php /* #?ini charset="utf-8"?
[tableofcontents]
Source=content/view/embed.tpl
MatchFile=embed/tableofcontents.tpl
Subdir=templates
Match[classification]=tableofcontents
*/
 ?>

Created embed/tableofcontents.tpl

<div style="padding:1em;position:fixed;border:1px solid 
blue;background-color:#aaa;width:200px;right:0; top:300px">
<h3>table of contents</h3>
{eztoc( $node.object.data_map.description )}
</div>

Created content.ini.append.php in extension/ezwebin_custom/settings/ with the following:

<?php /* #?ini charset="utf-8"?
[embed]
AvailableClasses[]=tableofcontents
ClassDescription[tableofcontents]=Table
 of Contents
*/ ?>

Now, I'm seeing the class in the embed dialogue. The div is showing with the heading, but $node or $node|attribute(show,2) or $module_result or anything else I can think of don't seem to produce any output.

The embed templates included with ezwebin seem to use $node, so I must be missing something. Anybody got any ideas?

Paul Bolger

paul bolger

Saturday 27 February 2010 11:58:07 pm

Looks like I'm replying to my own question. The only way I've found to what I needed was to use a 'universal variable'

So

 {eztoc( $#node.object.data_map.description )}

works. Thanks to the chap with the Russian sounding name... (can't find the post again!) for the tip.

Also: I read that this isn't used much any more. If anyone has a better way of doing it I'd be interested to hear.

BTW: I ended up using a custom tag rather than an embedded object. A custom tag is slightly easier for the user, but an embedded object would allow you to insert a toc for a page other than the current one - which may be handy in some situations.

Paul Bolger

Nicolas Pastorino

Tuesday 02 March 2010 1:18:19 am

Hi Paul,

Although i would instinctively had gone for your second solution, i investigated a bit on the first issue you raised. It appears that in the embed templates, the only variable always present is $object, representing the embedded content object. Additionally, you may have a $object_parameters variable, containing various attributes (editable in the small popup appearing when embedding an object).

About the $#node notation, altough indeed not used often, it is fine, and i do use it often.

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

eZ debug

Timing: Jan 18 2025 04:25:56
Script start
Timing: Jan 18 2025 04:25:56
Module start 'content'
Timing: Jan 18 2025 04:25:58
Module end 'content'
Timing: Jan 18 2025 04:25:58
Script end

Main resources:

Total runtime1.3308 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 588.8281180.8359
Module start 'content' 0.00701.1964 769.6641558.0000
Module end 'content' 1.20340.1274 1,327.6641336.7500
Script end 1.3308  1,664.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00460.3421210.0002
Check MTime0.00190.1422210.0001
Mysql Total
Database connection0.00110.082410.0011
Mysqli_queries1.255594.34281940.0065
Looping result0.00200.15111920.0000
Template Total1.289796.920.6448
Template load0.00310.233220.0016
Template processing1.286696.675920.6433
Template load and register function0.00020.018010.0002
states
state_id_array0.00110.082010.0011
state_identifier_array0.00150.113120.0008
Override
Cache load0.00270.2052290.0001
Sytem overhead
Fetch class attribute can translate value0.00120.087330.0004
Fetch class attribute name0.00150.115450.0003
XML
Image XML parsing0.00120.089030.0004
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00190.1461330.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs