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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:10:39
Script start
Timing: Jan 18 2025 11:10:39
Module start 'layout'
Timing: Jan 18 2025 11:10:39
Module start 'content'
Timing: Jan 18 2025 11:10:40
Module end 'content'
Timing: Jan 18 2025 11:10:40
Script end

Main resources:

Total runtime1.3691 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.9141152.6250
Module start 'layout' 0.00550.0036 740.539139.4453
Module start 'content' 0.00911.3585 779.9844552.9219
Module end 'content' 1.36760.0015 1,332.906312.1641
Script end 1.3691  1,345.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2593160.0002
Check MTime0.00150.1078160.0001
Mysql Total
Database connection0.00050.039710.0005
Mysqli_queries1.311295.7693570.0230
Looping result0.00070.0490550.0000
Template Total1.330997.220.6654
Template load0.00190.137720.0009
Template processing1.329097.068520.6645
Template load and register function0.00010.005810.0001
states
state_id_array0.00310.228510.0031
state_identifier_array0.00130.096620.0007
Override
Cache load0.00160.1205290.0001
Sytem overhead
Fetch class attribute can translate value0.00100.075420.0005
Fetch class attribute name0.00140.100150.0003
XML
Image XML parsing0.00120.085220.0006
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00230.1697220.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs