Dynamic URL within text block attribute

Author Message

Lo' F.

Friday 19 November 2010 6:00:21 am

Hi!

How to set a dynamic link to a node/page within a "text block" attribute (.. the footer text of "Template look" class)?

ezurl or eznode don't work in there. If I just give the node id - e.g. <a href="507">, it returns /content/view/full/507 but depending on the page I bowse it changes to something else and can't always find the object.

Because I cannot give the full URL for some other reasons, how can I pass that dynamically?

Thanks a lot!

loredanaebook.it

Romeo Antony

Sunday 21 November 2010 2:59:58 am

Lo' F,

/*

How to set a dynamic link to a node/page within a "text block" attribute (.. the footer text of "Template look" class)?

*/

If I am correct you want to setup a dynamic link in text block attribute .

I think you thinks in wrong way.

May be it should be like this

You have objects(suppose this object is of class article) with one of its attribute is of text block.

If you want to set up a dynamic link from one of its textblock attributes, what you do is,

extend the class article with a url datatype attribte, so that for each object you create you can add some URL to that obejct.

So in your template you can use it with a href whenever click on text block attribute. Set it as it your needs. Hope you understand.

Regards

Romeo

Gaetano Giunta

Sunday 21 November 2010 3:20:28 am

I do not think text block attributes support parsing any of the text you put in them, be they links or other.

Simple solution: use an xml block instead of the text block

Convoluted solution: write your own template operator that given a text block only parses the <a href=""> tags in it, looks up the node id of objects and substitutes it with the proper url alias. Then add an override for the template content/datatype/view/eztext.tpl that passes the text block text through this operator of yore instead of through wash( xhtml )|nl2br

Principal Consultant International Business
Member of the Community Project Board

Romeo Antony

Sunday 21 November 2010 3:33:19 am

Lo'F , you may try the the the first option Gaetano suggested simple , change the textblock to xml block attribute.

If you try the 2nd option ,it will be time consuming

you need to create custom template operator.

custom template for eztext.tpl.

Lo' F.

Thursday 02 December 2010 6:50:28 am

Thanks Gaetano and Romeo and sorry for my delay in getting back to this topic! Had to give priority to some other issues...

Changing the text block into xml was definitely the most strightforward solution, no doubt, but for this I tried another solution which seems to work after all.

I passed the url to a javascript variable set within the page_footer template

...
{literal}<script type="text/javascript">{/literal}

{def $link_to_page=fetch('content', 'node', hash('node_id', 507))}
{literal}link_to_page={/literal}{$link_to_page.url|ezurl}

{literal}</script>{/literal}
...

and then handed it over inside the "footer text" [text block] attribute this way...

...
<script>
document.write("<a href=" + link_to_page + ">Policy and Privacy</a>");
</script>
...

loredanaebook.it

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 10:29:12
Script start
Timing: Jan 18 2025 10:29:12
Module start 'layout'
Timing: Jan 18 2025 10:29:12
Module start 'content'
Timing: Jan 18 2025 10:29:13
Module end 'content'
Timing: Jan 18 2025 10:29:13
Script end

Main resources:

Total runtime0.8246 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.0078152.6250
Module start 'layout' 0.00560.0028 740.632839.4531
Module start 'content' 0.00840.8149 780.0859612.1406
Module end 'content' 0.82330.0012 1,392.226616.1563
Script end 0.8245  1,408.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4231160.0002
Check MTime0.00130.1587160.0001
Mysql Total
Database connection0.00080.099810.0008
Mysqli_queries0.749990.9420650.0115
Looping result0.00060.0744630.0000
Template Total0.780994.720.3904
Template load0.00220.265620.0011
Template processing0.778694.432420.3893
Template load and register function0.00010.013710.0001
states
state_id_array0.00260.314010.0026
state_identifier_array0.00110.137320.0006
Override
Cache load0.00190.2350480.0000
Sytem overhead
Fetch class attribute can translate value0.00060.072230.0002
Fetch class attribute name0.00120.150180.0002
XML
Image XML parsing0.00150.179830.0005
class_abstraction
Instantiating content class attribute0.00000.0023100.0000
General
dbfile0.00630.7650280.0002
String conversion0.00000.001040.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
2content/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: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs