glenleslie
Založený: 10.11.2009
Príspevky: 5
Zaslal: 2011-08-28 07:05
Návrat hore
Odpovedať s citátom
|
If my database has the following columns
ID, Title, URL_for_Title
1, "Fast and furious", "http://imdb.com/movies/fnf.html"
2, Bambi, http://disneystory.com/bambi.html
How do I get URL_for_Title to link for the column "Title"?
I just want "Fast and Furious" and "Bambi" to be linked in the display.
Thanks for pointers.
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2011-08-29 17:22
Návrat hore
Odpovedať s citátom
|
Search the forum for CONCAT in order to locate examples of creating custom links. Consider creating a virtual / dummy field.
| Kód: |
$opts['fdd']['dummy2'] = array (
'name' => 'Thumbnail',
'sql|VLF' => 'if(category = "other",
CONCAT("<a href=\"", dir, "/", filename, "\" target=\"_blank\">link</a>"),
if(category = "thumb", CONCAT("<a rel=\"example_group\" href=\"", REPLACE(dir, "/tn", "/"), filename, "\" target=\"_blank\"><img src=\"", dir, "/", filename, "\" ", " alt=\"\" border=\"0\"></a><br><a href=\"fancybox.change.php?upld_id=", upld_id, "\">Replace</a>"), ""))',
'options' => 'VLF',
'input' => 'R',
'escape' => false,
'sort' => false
); |
|
glenleslie
Založený: 10.11.2009
Príspevky: 5
Zaslal: 2011-09-05 18:35
Návrat hore
Odpovedať s citátom
|
Somehow I'm missing the basic syntax of the quoting.
this statement:
| Kód: |
$opts['fdd']['dummy1'] = array(
'name' => 'lnk',
'sql' => 'CONCAT("<a href=\", URL, \">, Title, </a>")',
'options' => 'VLF',
'input' => 'R',
'escape' => 'false',
'sort' => 'true'
);
|
yields these results in the web page display:
<a href=", URL, ">, Title, </a>
(problem: instead of replacing URL and Title with their values from the database, they are just treated as plain text). Not sure where I went wrong there.
troubleshooting attempts:
1. using no quotes around then entire <a href="" </a>, I get a syntax error back from mysql.
| Kód: |
| 'sql' => 'CONCAT(<a href=\"', URL, '\">', Title, '</a>)', |
2. tried single quotes within the parens on the CONCAT - mysql error.
| Kód: |
| 'sql' => 'CONCAT('<a href=\", URL, \">, Title, </a>')', |
3. tried single quoting each value which is text in the ConCat (per mySQL reference for CONCAT). mysql error.
| Kód: |
| 'sql' => 'CONCAT('<a href=\"', URL, '\">', Title, '</a>')', |
4. using no href and just concatenating the values URL and Title, i get the proper values back.
Anyway, please send me to RTFM if I really haven't studied either the manual or the examples closely enough. Have tried it a couple of days without success for this simple task.
TIA
|
glenleslie
Založený: 10.11.2009
Príspevky: 5
Zaslal: 2011-09-10 03:53
Návrat hore
Odpovedať s citátom
|
finally got it... seems like it would be good to add a complete example like this to the documentation...
| Kód: |
$opts['fdd']['linkedfield'] = array(
'name' => 'Titles',
'URL' => true,
'URLtarget' => '_blank',
'sql|VLF' => 'CONCAT("<a href=\"",LINKURL,"\">",Title,"</a>")',
'options' => 'VLF',
'escape' => false,
'input' => 'R',
'sort' => true
); |
It also seems like URLdisp command would take care of all of the trouble here if it could just point out another column in the record (you already provide a variable for the key ($key) of the record why not a $column[<name>]... maybe there's a way to do that with a cgi or php variable and I'm just not seeing it...
p.s. this approach is also messy when you look at the resulting HTML code-- by invokig the URL command you already create an href in your html output but then this "outer" href link is dummied to "1" then the concat method creates another href within the href... seems really messy... ?
l8r
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2011-09-10 15:33
Návrat hore
Odpovedať s citátom
|
The CONCAT method is intended for cases when you need to pass multiple columns in the link, or in the link text, which is what I (mistakenly) thought was the goal. If you only need to pass one column then stick to the documented URL feature.
| Kód: |
$opts['fdd']['linkedfield'] = array(
'name' => 'Titles',
'sql|VLF' => 'CONCAT("<a href=\"",LINKURL," target=\"_blank\"\">",Title," - ",SomeOtherField,"</a>")',
'options' => 'VLF',
'escape' => false,
'input' => 'R',
'sort' => true
); |
Naposledy upravil doug dňa 2011-09-10 15:38, celkom upravené 1 krát
|
|
Odoslať novú tému
Odpovedať na tému
|
|