Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[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.

Please Log in or Create an account to join the conversation.

Last edit: by 8churchpath.

[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.

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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 following user(s) said Thank You: VeCrea

Please Log in or Create an account to join the conversation.

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

Thank you, much appreciated, kind regards, Terry.

Please Log in or Create an account to join the conversation.

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

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?

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.116 seconds

For starters it's just so easy to design an app in a way that I'm used to i.e. database first then views followed by customization. The fork system is pure brilliance from a developer standpoint as I can override things and still add and update my projects with minimal effort! Truly amazing to be able to build components in Joomla using incremental refinement without having to do everything by hand. Thanks for the great tool! I am so much more productive now than ever and I can't imagine building components any other way!!!!
Dave (Forum)

Get Started