Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 13. Dec 2017, 13:11

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Separate link on top
PostPosted: 18. Oct 2006, 11:51 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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.


Top
 Profile  
 
 Post subject:
PostPosted: 18. Oct 2006, 12:47 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
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


Top
 Profile  
 
 Post subject:
PostPosted: 18. Oct 2006, 13:53 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
Thanks, can I also detect the filename? Because not all pdf's are called "test"
Something like ($basedir."/".$twg_album."/".$filename.".pdf") ?


Top
 Profile  
 
 Post subject:
PostPosted: 18. Oct 2006, 14:12 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
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


Top
 Profile  
 
 Post subject:
PostPosted: 18. Oct 2006, 14:30 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: 18. Oct 2006, 14:33 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 10:59 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 11:10 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
because it's not valid php syntax:


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

should be

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

/Michael


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 11:44 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 11:49 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
define not work!

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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 11:58 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 12:06 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
echo $basedir."/".$twg_album before the open - then you see whats in there

/Michael


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 12:21 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 12:34 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 10571
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


Top
 Profile  
 
 Post subject:
PostPosted: 19. Oct 2006, 14:39 
Offline

Joined: 18. Oct 2006, 11:37
Posts: 9
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO