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.