How to get Hyperlink field to work

QuestionsHow to get Hyperlink field to work
Glenn asked 9 years ago

I can get the hyperlink to work if it is the domain but if there is a subpage it goes to a blank page.
eg: website.com works but website.com/contactus goes to a blank page.

All the links show, however when I hover over the links the website.com/contactus link is blank.
I have tried a few ways as seen below.
$col = array();
$col["title"] = "Url"; // caption of column
$col["name"] = "url";
// $col["default"] = "<a href='{url}' target='_blank'>{url}</a>";
// $col["link"] ="<a href='{url}' target='_blank'></a>";
$col["link"] = "http://www.{url}";
$col["linkoptions"] = "target='_blank'"; // opens in new tab
$acols[] = $col;

Thanks

3 Answers
Abu Ghufran answered 9 years ago

Code seems fine.

1) $col["default"] = "<a href='{url}' target='_blank'>{url}</a>";
2) $col["link"] = "http://www.{url}";

Both should work. Please share complete code or online link for review.
You can email at [email protected]

Glenn answered 9 years ago

Thanks Abu,
I have modified your Editing: Bulk Edit demo to show you what I mean.

http://x2.guaranteedseo.com/phpgrid/index.php
I changed a clients name in the database to a link.
Antonio Moreno
to
plus.google.com/+IBM/posts
Then I changed the code as below. You can see it when you go to the site.
//$col["link"] = "http://localhost/?id={id}"; // e.g. http://domain.com?id={id} given that, there is a column with $col["name"] = "id" exist
$col["link"] = "https://{name}";

Abu Ghufran answered 9 years ago

The problem seems to be with urlencoding. Try following:

$col["on_data_display"] = array("make_url","");
function make_url($data)
{
$name = $data["name"];
return "<a target='_blank' href='http://$name'>$name</a>&quot;;
}

Full code: http://hastebin.com/ewibiwihox.php

Your Answer

9 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?