adding a url to details display item

16 views
Skip to first unread message

tom wible

unread,
Jul 13, 2021, 10:13:24 AMJul 13
to Xataface
i have a table of artworks, and the details page displays the artist's name via the fields.ini directives:
[artistID]
widget:type = select
vocabulary = selectArtist
column:label = "artist"

and valuelist.ini directives:
[selectArtist]
__sql__ = "select lalo_artists.artistID, CONCAT(lalo_artists.firstNAME, ' ', lalo_artists.lastNAME) as artistList
  FROM lalo_artists
  order by lalo_artists.lastNAME, lalo_artists.firstNAME;"
 
what i would like to do is make the artist name a link to that artist's record in the artist table...i'm sure it's possible, i just haven't found the sekrit incantation;-)

can i buy a clue, pls?-)

Steve Hannah

unread,
Jul 13, 2021, 10:33:55 AMJul 13
to xata...@googlegroups.com
Use fieldname__renderCell() to customize the cell content for this field in list view, and include a <a href="..."> tag.


--
You received this message because you are subscribed to the Google Groups "Xataface" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xataface+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xataface/ba7bdec4-7ca4-4054-9982-f051e2f5661an%40googlegroups.com.


--
Steve Hannah
Web Lite Solutions Corp.

tom wible

unread,
Jul 13, 2021, 12:57:34 PMJul 13
to Xataface
ah, exxxcellent, thanx:-) ur definitive guide only mentions ...renderCell() in relation to the needed noLinkFromListView directive, and ur old howto page doesn't mention ...renderCell()-:

and will that apply to the detail view as well as list? 
      label="artist" 
doesn't change the detail view as 
     column:label = "artist"
does for the list view...
 

tom wible

unread,
Jul 13, 2021, 1:00:16 PMJul 13
to Xataface
o-wait, old howto page does mention  ...renderCell, just not renderCell()-;

tom wible

unread,
Jul 13, 2021, 1:06:46 PMJul 13
to Xataface
and after rtfm, i c 

"If you want to change the way a field is rendered in both the list tab and the view tab it may be better to use the %fieldname%__display() method."

tom wible

unread,
Jul 13, 2021, 4:26:00 PMJul 13
to Xataface
so i added this to my artworks.php (artistList is from the vocabulary = selectArtist):

    function artistID__display( &$record ){
       return '(<a href="/lalo_DB/index.php?-table=lalo_artists&artistID='
        . $record->strval('artistID'). '">' . $record->strval('artistList') . '</a>)'; 
    }

this to fields.ini:

[artistID]
widget:type = select
vocabulary = selectArtist
column:label = "artist"
label = "artist"
noLinkFromListView = 1

and on the details view:

ArtistID       (<a href="/lalo_DB/index.php?-table=lalo_artists&artistID=41"></a>)

note the field name is still artistID, not artist, but hey, it got the artistID right;-) 
but in the list view, all i get is a column of empty parens () containing but hey, the column name is artist;-)

replacing the __display() with __renderCell() results in the same non-link ArtistID in details view, but the list view's empty parens contain the correct link, so that's progress;-)

tom wible

unread,
Jul 13, 2021, 4:46:21 PMJul 13
to Xataface
okeydokey, i've got the artworks list to make the artist name into the correct link, as explained in 

    function artistID__renderCell( &$record ){
       return '(<a href="/lalo_DB/index.php?-table=lalo_artists&artistID='
        . $record->strval('artistID'). '">name=' . $record->display('artistID') . '</a>)';
    }

but the view detail still only shows the name without link:-\

tom wible

unread,
Jul 14, 2021, 9:51:04 AMJul 14
to Xataface
is there a way to set noLinkFromListView globally, so i don't have to turn off links for each field?
Reply all
Reply to author
Forward
0 new messages