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.089 seconds

Although I found this tool some time ago I just started learning experimenting and building this first component on Monday and now on Thursday afternoon it's already online. Although I already had a working version done with another tool this is much easier to build and at the end you have the freedom to own your own component. Once you know how to use Cook you will boost your productivity as the learning curve is really moderate compared to many other tools.
Giori (Forum)

Get Started