Jump to content

Display List Of Folders And Link To Individual Pages


mallen

Recommended Posts

Can anyone else help? I have been struggling with this for 3 days. The more I look at it not sure (how is currently written) how it knows I want only pdf files to be listed in the second function.

 

My folder struccture is products/category1/product1/product2....category2/product1/product2 and so on. I already can get it to list the category folders as links.

Edited by mallen
Link to comment
Share on other sites

I tried this function and it outputs it if I do a var_dump($dir) but can't get it to echo the values.

function list_directories () {
if (!empty ($_GET['folder'])) {
 $dir = 'products/' . $_GET['folder'];

} else {
 $dir = 'somevalue';

}
$images= glob($dir . "*.jpg");

foreach($images as $image)
{
echo $image;
}
var_dump($dir);
}

Edited by mallen
Link to comment
Share on other sites

Ok got it to work. :happy-04: (somewhat) I left off that slash/ on line 6. It now displays the image according to the link I click. Now I need to work on passing the variable for the pdf file. Because all it checks is value of 'folder'

function list_directories () {
if (!empty ($_GET['folder'])) {
    $dir = 'products/' . $_GET['folder'];

} else {
    $dir = 'somevalue';

}
$images = glob($dir . "/*.jpg");

foreach($images as $image)
{
echo basename($image);
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.