Judah Raine
Total posts: 332
18 Nov 2012 03:21

Ok, hopefully this is my very last question...

I am doing the custom article template based on information received via a form.

I need the url field to output as a link on an image that is existing, i.e. not uploaded with the form, e.g. a buy button which is standard but which the url is added to as a link.

Oh lordy, hope I explained that properly.... any and all help much appreciated. The end is in site and this seems to be my last issue.

Thank you

Last Modified: 02 Mar 2014


Sackgesicht VIP
Total posts: 1,636
18 Nov 2012 05:19

Judah,

if i understood correctly what you described, the best way to achieve this is with a URL-field template.

Please read this article to understand the procedure.


Sackgesicht VIP
Total posts: 1,636
18 Nov 2012 05:55

Judah,

the following url output template will add the first link stored in a URL field to a predefined image and will open the image depending to your "open url in" parameter.

<?php

defined('_JEXEC') or die;

$value = $this->value; 

$options = $this->params->get('params.open_url', 1) ? ' target="_blank"' : '';

 echo JHtml::link('http://' . $value[0]['url'], "<img src='".JURI::root()."media/mint/icons/68/payment.png'", $options ) ;

?>

Save the template under /components/com_cobalt/fields/url/tmpl/output/image.php and select it in your field parameters.

Adjust the path to your predefined image ...


Judah Raine
Total posts: 332
18 Nov 2012 07:13

:D Oh oh oh, thank you so much:D:D:D:D Worked like a charm, and the end is in sight (I think)


Sackgesicht VIP
Total posts: 1,636
18 Nov 2012 21:21

In the rush i missed a closing tag .. please use this:

<?php

defined('_JEXEC') or die;

$value = $this->value; 

$options = $this->params->get('params.open_url', 1) ? ' target="_blank"' : '';

 echo JHtml::link('http://' . $value[0]['url'], "<img src='".JURI::root()."media/mint/icons/68/payment.png'>", $options);

?>

Judah Raine
Total posts: 332
18 Nov 2012 22:37

:D:D:D Not to worry, I worked it out, thank you!

Powered by Cobalt