Markie
Posts: 251
|
| Posted: 02/11/2009, 1:14 AM |
|
I have a grid which shows images from my database. Each image has a link to a popup page. In html code:
<img src="{Photo}" title="Photo: {Photo}"> <br>
<a href="showpopup.php?Photo={Photo}">popup</a>
My database contains all kinds of images, like jpg, gif, ico, psd, tiff, bmp, eps, png etc. and I want to show the link to the popup window ONLY when the image is a jpg, gif, png or bmp image. The reason for this is that the other kinds of images simply won't show up in the browser (tiff, psd, eps etc.)
Is it possible to show the popup link only when the extension of the image is jpg, gif, png or bmp ?
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
Gena
Posts: 591
|
| Posted: 02/11/2009, 1:30 AM |
|
as usual, put Panel around your link html code. In Before Row Show event check your image/file extention or whatever you need and Show/Hide Panel.
_________________
Gena |
 |
 |
Markie
Posts: 251
|
| Posted: 02/11/2009, 2:01 AM |
|
Hi Gena, I understand how to use the panel and show / hide event. I don't understand how to tell the event that I only want to show the link when the file extension is jpg for example. I have to fill this fields:
Condition Type:
Compare as:
Condition:
Parameter 1:
Name:
Source Type:
Format:
Parameter 2:
Name:
Source Type:
Format:
Can you help me with filling this details ?
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
Gena
Posts: 591
|
| Posted: 02/11/2009, 2:14 AM |
|
don't use Show/Hide Panel action for this - there is an error in code (it produces just one IF operator so if you have many Rows it will not works...). Just use code like following:
//BeforeShowRow event
$ext = $Container->ext->GetValue(); /if you have some extention field in your table,
if NO - you need just get ext from your filename
if ($ext='gif' or $ext='jpg' or .....) {
$showpanel = 1;
}else{
$showpanel = 0;
}
if ($showpanel ) {
$Container->PanelXXX->Visible = true;
} else {
$Container->PanelXXX->Visible = false;
}
_________________
Gena |
 |
 |
Markie
Posts: 251
|
| Posted: 02/11/2009, 3:11 AM |
|
hm, it must be me, but it doesn't work:
I have a label in my grid with the file extension. The name of this label is Label6.
I have a link in a panel, the name of this panel is Panel1, Visible = No
I have this BeforeShowRow event in my grid:
$ext = $Container->Label6->GetValue();
if ($ext='jpg') {
$showpanel = 1;
}else{
$showpanel = 0;
}
if ($showpanel ) {
$Container->Panel1->Visible = true;
} else {
$Container->Panel1->Visible = false;
}
but whatever file my page shows (tiff, eps, psd etc.) the link is always visible. Can you see what I'm doing wrong here ?
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
Gena
Posts: 591
|
| Posted: 02/11/2009, 3:25 AM |
|
sorry, I was wrong >:
if ($ext=='jpg') {
_________________
Gena |
 |
 |
Markie
Posts: 251
|
| Posted: 02/11/2009, 4:22 AM |
|
Thanks mate, you've solved my probs !
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
damian
Posts: 838
|
| Posted: 02/11/2009, 4:35 AM |
|
dammit!
i just spent the last 3 hours trying to solve this one and i just got it!
this one is based on an old solution started by donp and finished by walter
the really nice thing about this is its all done in the db no panels required....
fast, minimal coding, no panels, just a show/hide of the image if my_image is empty....
select *,
case locate('.gif',image) when false then
case locate('.png',image) when false then
case locate('.jpg',image) when false then
'' else 'jpg.png' end
else 'png.png' end
else 'gif.png' end
as my_image
from tablename
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
Markie
Posts: 251
|
| Posted: 02/11/2009, 6:05 AM |
|
yep, that's a nice minimalistic solution ! However, with panels it's possible to show a message (for example "I'm sorry, no thumbnail for this kind of images").
My final solution (with thanks to Gena) in a Before Show Row event of the grid:
$album = $Container->album->GetValue();
$photo = $Container->photo->GetValue();
$path="$album/$photo";
if (!function_exists('getFileExtension')) {
function getFileExtension($fileName)
{
$parts=explode(".",$fileName);
return $parts[count($parts)-1];
}
//function to return file extension from a path or file name
if (!function_exists('getFileExtension')) {
function getFileExtension($path)
{
$parts=pathinfo($path);
return $parts['extension'];
}//function to return file name from a path
function getFileName($path)
{
$parts=pathinfo($path);
return $parts['photo'];
}
}
}
if (getFileExtension($path)=='jpg' or getFileExtension($path)=='JPG' or getFileExtension($path)=='jpeg' or getFileExtension($path)=='JPEG' or getFileExtension($path)=='gif' or getFileExtension($path)=='GIF' or getFileExtension($path)=='png' or getFileExtension($path)=='PNG' or getFileExtension($path)=='bmp' or getFileExtension($path)=='BMP') {
$Container->Panel1->Visible = true;
} else {
$Container->Panel1->Visible = false;
}
if (getFileExtension($path)=='jpg' or getFileExtension($path)=='JPG' or getFileExtension($path)=='jpeg' or getFileExtension($path)=='JPEG' or getFileExtension($path)=='gif' or getFileExtension($path)=='GIF' or getFileExtension($path)=='png' or getFileExtension($path)=='PNG' or getFileExtension($path)=='bmp' or getFileExtension($path)=='BMP') {
$Container->Panel2->Visible = false;
} else {
$Container->Panel2->Visible = true;
}
Panel1 contains a link to the popup window and Panel2 contains a short text.
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
damian
Posts: 838
|
| Posted: 02/11/2009, 1:14 PM |
|
select *,
case locate('.gif',image) when false then
case locate('.png',image) when false then
case locate('.jpg',image) when false then
'nothumb.png' else 'jpg.png' end
else 'png.png' end
else 'gif.png' end
as my_image
from tablename
easy - insert a default image name eg nothumb.png for the false, false, false result....
_________________
if you found this post useful take the time to help someone else.... :)
|
 |
 |
|