Convert URL to hyperlink

Author Message

Will Diaz

Thursday 16 March 2006 2:56:51 pm

I have a variable called event_details, which has the following value:

Event Name:
Such and Such

Event Date:
March 21st, 2006

Event Website:
www.domain.com

Currently, the code display the variable with the following line:

{attribute_view_gui attribute=$node.object.data_map.event_details}

Now, what I need to do is to take that URL and turn it into a hyperlink on the fly, like so:

<a href="http://www.domain.com">www.domain.com</a>

How can this be accomplished?

Nabil Alimi

Friday 17 March 2006 3:41:38 am

Hi will,

What kind of datatype is your 'event_details' attribute ?

Text block ?

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Betsy Gamrat

Friday 17 March 2006 5:33:36 am

Check to make sure that the website field is a URL - then it should be displayed as a link by default.

The URL attribute allows you to enter text and the URL, then delivers the content as a standard link.

Sascha Frinken

Friday 17 March 2006 8:32:31 am

I guess your attribute is a textfield...

I would write a template operator that parses the text.
This is the php code you need to make your text a clickable link:

$click_text = preg_replace( "#(^Event.*Website:\n)(.*)#sm", "\\1<a href=\"http://\\2\">\\2</a>", $your_attribute );    

HTH
Sascha

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