This topic is locked
[SOLVED]

 Thumbnail Image On List As Hyperlink To Detail

5/27/2013 3:35:22 PM
PHPRunner General questions
S
salus1 authorDevClub member

Does anyone know how to configure a thumbnail image on a list view as a link to the corresponding record's detail page?

Thanks!

C
cgphp 5/27/2013
  1. Check what is the url of the image
  2. Set the field on the list page as "Custom"
  3. Format the field value as:

<a href="url/of/the/detail/page"><img src="path/to/the/image" alt="image"/></a>
S
salus1 authorDevClub member 5/27/2013

Thanks for this info.
Unfortunately the thumbnail image is a BLOB generated by the PHPRunner image upload function. It is stored in a MySQL database and I don't think that it can be set to "Custom".
Also, the link needs to be dynamic, pointing to the list record's corresponding detail page.
Sorry if I'm missing something obvious here. Any other ideas?
Thanks!

C
cgphp 5/27/2013

What is the url of the image?

S
salus1 authorDevClub member 5/27/2013

Thanks again for looking at this.
The image is read in from the database and so it doesn't have a file type URL.
The detail view hyperlink is http://www.mysite.com/item_view.php?editid1=320.

C
cgphp 5/27/2013

The image is rendered with the tag "img" and this tag has a "src" attribute. That attribute is the link to the image. You can render an image calling a PHP script or with a direct URL to the image file. Your src attribute should have a link starting as mfhandler.php?filename=........ Hope to be clear.

S
salus1 authorDevClub member 5/27/2013
S
salus1 authorDevClub member 5/27/2013

The problem is that there is no way to configure the field as "Custom", only "Image" of "File" are available in the 'view As" tab.

C
cgphp 5/27/2013

Custom is grey out but you can use it anyway.

S
salus1 authorDevClub member 5/27/2013

OK, I tried every permutation I could in the Custom editor...
$value='<img width="160" height="120" border="0" src="mfhandler.php?filename=file.jpg&table=Consignments&field=Thumbnail&nodisp=1&pageType=list&key1='.$data["editid1"].'&rndVal=10129>';
...but no joy.
Any ideas?
Thanks!

Admin 5/27/2013

Instead of $data["editid1"] you need to use $data["KeyColumnName"]. Replace KeyColumnName with the actual key column name, case-sensitive.

S
salus1 authorDevClub member 5/27/2013

Hello,
I created a demo project to figure this out.
http://demo.asprunner.net/rsalusbury_msn_com/ImageLink/Table1_list.php
It has a list page with Description and Thumbnail and a detail/edit page with Description and Image.

I see that even though Custom is grayed out it is edit-able (thanks, did not know that!).

Can't figure out the syntax, though.

Any thoughts?

Thanks

S
salus1 authorDevClub member 5/28/2013

Theoretically the Custom code for the thumbnail in the example database to link to the detail page would look something like...
$value='<a href = "http://demo.asprunner.net/rsalusbury_msn_com/ImageLink/Table1_view.php?editid1='.$data["Serial"].'>;

<img border="0" src="mfhandler.php?filename=file.jpg&table=Table1&field=Thumbnail&nodisp=1&pageType=list&key1='.$data["Serial"].'&rndVal=20187"></a>';
...I think.
Any thoughts?

S
salus1 authorDevClub member 5/28/2013

After fooling with single and double quotes here is the working Custom code...

$value='<a href = "http://demo.asprunner.net/rsalusbury_msn_com/ImageLink/Table1_view.php?editid1='.$data["Serial"].'">;

<img border="0" src="mfhandler.php?filename=file.jpg&table=Table1&field=Thumbnail&nodisp=1&pageType=list&key1='.$data["Serial"].'&rndVal=20187"></a>"';


Thanks!