Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] Create link to external url

[SOLVED] Create link to external url 28 Mar 2012 07:42 #1755

Hi, I'm creating a component called Books. when the user clicks on a book it takes them to 'bookitem'.
I want them to be able to click on a field that displays a link to an external book store.
In the backend administrators can type in an external website link.

Am using a 'string' datatype to provide a field to input this external web URL so that when users click on the link it will take them to a specific page on the external bookstore, here is the code below:

Link field in bookitem :

<td>
<?php echo JDom::_('html.fly', array(
'href' => 'link',
'dataKey' => 'link',
'dataObject' => $this->booksitem
));
?>
</td>

What do I have to add/change to make this field go to the external link?

kind regards,
Terry.
Last Edit: 28 Mar 2012 08:00 by 8churchpath.
The administrator has disabled public write access.

[SOLVED] Create link to external url 28 Mar 2012 07:59 #1756

Actually I revisited the component and changed the field from a string to Rich Text. Then I was able to create a link using the link button in the editor to the external website. kind regards, Terry.
The administrator has disabled public write access.

[SOLVED] Create link to external url 28 Mar 2012 17:05 #1762

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Here the solution

STATIC
<?php echo JDom::_('html.fly', array(
'href' => 'www.google.com',  	//HERE
'dataKey' => 'link',
'dataObject' => $this->booksitem
));
?>

DYNAMIC
<?php echo JDom::_('html.fly', array(
'href' => $this->booksitem->link,  	//HERE
'dataKey' => 'link',
'dataObject' => $this->booksitem
));
?>
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: VeCrea

Re: [SOLVED] Create link to external url 28 Mar 2012 17:08 #1763

Thank you, much appreciated, kind regards, Terry.
The administrator has disabled public write access.

[SOLVED] Create link to external url 20 Jul 2015 03:21 #13357

  • jonathanbell
  • jonathanbell's Avatar
  • Offline
  • Premium Member
  • Posts: 147
  • Thank you received: 5
  • Karma: 1
How would you do this in the new version?

I currently have
<td style="text-align:center">
					<?php echo JDom::_('html.fly', array(
						'dataKey' => 'link',
						'dataObject' => $row,
						'route' => array('view' => $row->link),
						'target' => '_blank'
					));?>
				</td>

How do I get this to only open the link from the field?
The administrator has disabled public write access.
Time to create page: 0.072 seconds

Get Started