Link based on link in database column [SOLVED]

Talk about link fields or link implementations

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

dkochan
Senior
Senior
Posts: 30
Joined: Dec 2nd, '09, 16:23

Link based on link in database column [SOLVED]

Postby dkochan » Mar 10th, '10, 16:15

How do I create a link based on what is stored in a column of a database table? For example, I have a column in my database called map_link. The map_link column stores a web address to an external website. When in details mode I want the user to be able to click on the link and go to that website. How do I do this?
Last edited by dkochan on Mar 19th, '10, 02:08, edited 1 time in total.

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Link based on link in database column

Postby administrator » Mar 14th, '10, 08:04

In a definition of "link" type there are attributes: "field_key"=>"field_name_0" and "field_data"=>"field_name_2"
When DataGrid translates them you see on the screen following:

<a href="field_key">field_data</a>

so.. you just need to define in "field_key" filed from your database, that stores the requested URL

dkochan
Senior
Senior
Posts: 30
Joined: Dec 2nd, '09, 16:23

Re: Link based on link in database column

Postby dkochan » Mar 19th, '10, 02:07

Thanks! I followed your advice. Here is my code:

Code: Select all

"map_link" =>array("header"=>"Map Link", "type"=>"link", "on_js_event"=>"", "field_key"=>"map_link", "field_data"=>"map_link", "target"=>"_blank", "href"=>"{0}", "title"=>"Map Link"),
                 );

map_link is the name of the field in my table that stores the url. When storing the url in your database, you must include http:// at the beginning of the web address. For example, store "http://www.website.com" instead of "www.website.com" in your database.

asawyer13
Senior
Senior
Posts: 32
Joined: Jul 19th, '11, 11:26

Re: Link based on link in database column [SOLVED]

Postby asawyer13 » Feb 12th, '14, 15:12

I have everything working, but for some reason my url is appearing as the actual data in the column also.
I really want to display something like "Click Here" probably in blue and underlined.

I didn't figure out how to underline and make it blue, but I figured out how to do the other.

I added a 'View Detail' as viewdetail to me query

then used that field with it has the field_data and the url field as the field_key



Return to “Field type: "link"”