Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

Separate link on top
https://www.tinywebgallery.com/forum/viewtopic.php?f=4&t=572
Page 1 of 2

Author:  Mini [ 18. Oct 2006, 11:51 ]
Post subject:  Separate link on top

When I'm building collages or flyers, folders etc. I want to publish the pictures I used in TWG. Besides the pictures I want to provide a link on top of the thumbview-page to a pdf or another file that was used for building the original (photoshop for example) I upload all files in one folder (pictures and specific file) and I want TWG to see if there's such a file, and if there is... show the link on top.

I tried:
if file_exists($basedir."/".$twg_album ."/test.pdf"){
echo "<a href='".$basedir."/".$twg_album."/test.pdf'>Download PDF</a>"
}

on line 278 below echo "<br/>";
but when I want to test it my gallery completely disapear.

Author:  TinyWebGallery [ 18. Oct 2006, 12:47 ]
Post subject: 

pretty close :)


if (file_exists($basedir."/".$twg_album ."/test.pdf")){
echo "<a href='".$basedir."/".$twg_album."/test.pdf'>Download PDF</a>";
}


you should check the php syntax :).

/Michael

Author:  Mini [ 18. Oct 2006, 13:53 ]
Post subject: 

Thanks, can I also detect the filename? Because not all pdf's are called "test"
Something like ($basedir."/".$twg_album."/".$filename.".pdf") ?

Author:  TinyWebGallery [ 18. Oct 2006, 14:12 ]
Post subject: 

you have to search for an pdf first and use this filename then.
or you use something like the folder name - because this is easier to extract.

/Michael

Author:  Mini [ 18. Oct 2006, 14:30 ]
Post subject: 

uhmmm. that's no good because
in first case all pdf's would have the same name and when I use ".$twg_album.".pdf") I'll get all foldernames in the pdf-filename. (folder1/subfolder2/subsub3.pdf)
and I don't have the freedom of naming my pdf's

Author:  TinyWebGallery [ 18. Oct 2006, 14:33 ]
Post subject: 

I haven't made any of your 2 solutions you say they are not good.

1. search !
2. the foldername - of yourse you have to extract the last part with basename().

/michael

Author:  Mini [ 19. Oct 2006, 10:59 ]
Post subject: 

okay, I went for the first option.
First I made this script in the actual folder and it worked.
Now I wanted to implement it into index.inc.php and changed the opendir(".") in opendir("$basedir."/".$twg_album.") but it doesn't work :cry:

//------------------------------------------- extra links on top -------------------------
echo "<table cellspacing='10'>";
echo "<tr><td valign='top'>";
function getPDF($filetype) // here I am searching for pdf's and show a link if there are
{
$dir_handle = opendir("$basedir."/".$twg_album.");
while(false !== ($entryname = readdir($dir_handle)))
{
$splitentryname = explode(".", $entryname);
$sizesplitentryname = count($splitentryname);
$fileext = $splitentryname[$sizesplitentryname-1];
$fileext = strtolower($fileext);

if($filetype == $fileext)
{
echo "<a href='$entryname'>Download $entryname</a><br>";
}
}
}
getPDF("pdf");
//---------------------------------
echo "</td><td valign='top'>";
function getQXD($filetype) // here I am searching for qxd's and show a link if there are
{
$dir_handle = opendir("$basedir."/".$twg_album.");
while(false !== ($entryname = readdir($dir_handle)))
{
$splitentryname = explode(".", $entryname);
$sizesplitentryname = count($splitentryname);
$fileext = $splitentryname[$sizesplitentryname-1];
$fileext = strtolower($fileext);

if($filetype == $fileext)
{
echo "<a href='$entryname'>Download $entryname</a><br>";
}
}
}
getQXD("qxd");
//--------------------------------
echo "</td><td valign='top'>";
function getINDD($filetype) // here I am searching for indd's and show a link if there are
{
$dir_handle = opendir("$basedir."/".$twg_album.");
while(false !== ($entryname = readdir($dir_handle)))
{
$splitentryname = explode(".", $entryname);
$sizesplitentryname = count($splitentryname);
$fileext = $splitentryname[$sizesplitentryname-1];
$fileext = strtolower($fileext);

if($filetype == $fileext)
{
echo "<a href='$entryname'>Download $entryname</a><br>";
}
}
}
getINDD("indd");
//--------------------------------
echo "</td></tr></table>";

//----------------------------------------end extra links on top -------------------------
Help... please

Author:  TinyWebGallery [ 19. Oct 2006, 11:10 ]
Post subject: 

because it's not valid php syntax:


$dir_handle = opendir("$basedir."/".$twg_album.");

should be

$dir_handle = opendir($basedir."/".$twg_album);

/Michael

Author:  Mini [ 19. Oct 2006, 11:44 ]
Post subject: 

Still doesn't work.
When I change it to opendir("pictures/folder1/subfolder/subsub")
it works fine.
Tried opendir($basedir.) and placed a pdf in folder pictures, but this also didn't work

Author:  TinyWebGallery [ 19. Oct 2006, 11:49 ]
Post subject: 

define not work!

because the code you write in the last line is not valid php!

Author:  Mini [ 19. Oct 2006, 11:58 ]
Post subject: 

when I enter the gallery and go to the folder with the pdf in it, it won't show the link
php code ->
$dir_handle = opendir($basedir."/".$twg_album);

when I use ->
$dir_handle = opendir("pictures/folder1/subfolder/subsub");
it does

Author:  TinyWebGallery [ 19. Oct 2006, 12:06 ]
Post subject: 

echo $basedir."/".$twg_album before the open - then you see whats in there

/Michael

Author:  Mini [ 19. Oct 2006, 12:21 ]
Post subject: 

When I add echo $basedir."/".$twg_album; outside the function it returns the complete path of the folder as it should, but inside the function (doesn't matter where) it returns nothing

Author:  TinyWebGallery [ 19. Oct 2006, 12:34 ]
Post subject: 

oh it's inside a function.

If you think a little bit then you will find out:). A parameter outside is not visible inside a function - pass it at the call (add parameters!).

/Michael

Author:  Mini [ 19. Oct 2006, 14:39 ]
Post subject: 

You're right. I've read it a few weeks ago in my first lessons php in the book.
Just forgot :oops:
Have inserted globals in the functions.
Thanks

Page 1 of 2 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/