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