Changing link behavior based on target node (w/o hacks)

Author Message

Massimiliano Bariola

Friday 10 February 2006 3:15:51 am

Hi,

I am presented with an interesting problem. I have 2 classes: the first (class A) contains an XML block and some other fields, the second one (class B) has a file attribute and some other fields.

users can insert eznode links into the XML field of class A , which will get translated via link.tpl to the <a href ....> link.

The desired behavior is :

- links to nodes of classes other than B should work normally
- links to nodes of class B should start the download of the file contained into the file attribute of class B.

So far, I have patched this by creating an override tpl for class B which , via JS, redirects to the download of the file. but users are left with a blank page underneath and need to press "back" to return to the site. Not nice.

Another solution would be to generate the link based on what kind of class is the node I am pointing to.

By browsing kernel/classes/datatypes/ezxmltext/handlers/output/ezhtmlxmloutput.php and link.tpl for ezxml link tags I can see that no parameters are passed to the tpl which could help e.g. node or object id. so I'd need a kernel hack to pass this value too.
Another solution could be to intercept the output of link.tpl and reparse it to check if the pointed node is in the folder for objects of class B, but then I have the uncertain task of trying to find a node based on parsing an URL.

Any ideas?

TIA

Max

Thomas Nunninger

Friday 10 February 2006 3:46:42 am

Hi,

have you tried fetch('content', 'node')? You can fetch by node_path (cf. http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/node). But perhaps you will have problems with a trailing index.php/<siteaccess> or what else...

Have a nice day

Thomas

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