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.

eZ debug

Timing: Jan 31 2025 01:33:36
Script start
Timing: Jan 31 2025 01:33:36
Module start 'layout'
Timing: Jan 31 2025 01:33:36
Module start 'content'
Timing: Jan 31 2025 01:33:36
Module end 'content'
Timing: Jan 31 2025 01:33:36
Script end

Main resources:

Total runtime0.0252 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.1406151.2109
Module start 'layout' 0.00550.0042 739.3516220.6875
Module start 'content' 0.00960.0138 960.0391997.9141
Module end 'content' 0.02340.0017 1,957.953133.9922
Script end 0.0251  1,991.9453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002610.4689140.0002
Check MTime0.00103.9838140.0001
Mysql Total
Database connection0.00114.289910.0011
Mysqli_queries0.00259.806430.0008
Looping result0.00000.052110.0000
Template Total0.00135.310.0013
Template load0.00104.006510.0010
Template processing0.00031.244510.0003
Override
Cache load0.00062.583810.0006
General
dbfile0.00124.909880.0002
String conversion0.00000.019940.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