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.

eZ debug

Timing: Jan 19 2025 02:29:08
Script start
Timing: Jan 19 2025 02:29:08
Module start 'layout'
Timing: Jan 19 2025 02:29:08
Module start 'content'
Timing: Jan 19 2025 02:29:08
Module end 'content'
Timing: Jan 19 2025 02:29:08
Script end

Main resources:

Total runtime0.0155 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 589.3828152.6406
Module start 'layout' 0.00680.0033 742.023439.4766
Module start 'content' 0.01010.0032 781.500089.3672
Module end 'content' 0.01330.0022 870.867230.3047
Script end 0.0155  901.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002515.8338140.0002
Check MTime0.00117.0732140.0001
Mysql Total
Database connection0.00117.386410.0011
Mysqli_queries0.003019.291330.0010
Looping result0.00000.122810.0000
Template Total0.001912.110.0019
Template load0.00085.326010.0008
Template processing0.00116.781510.0011
Override
Cache load0.00063.856710.0006
General
dbfile0.00021.160780.0000
String conversion0.00000.046140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs