Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2014-08-10 23:31:40

fabian.trees
Member
Registered: 2012-09-26
Posts: 34

Nested galleries

As with every update, I get stucked with nested galleries and navigation....
I adapted the php but it does not work:

$indexPath = '/galleries/'; // set folder location to scan for galleries
    $theroot = $_SERVER['DOCUMENT_ROOT'];

    require_once($theroot.'/lib/autoindex/autoindex.php');
    if (trim($_SERVER["QUERY_STRING"]) == 'debug')
        define ('AUTOINDEX_DEBUG', true); // enable statement to output debugging info from autoindex()
    $albums = autoindex($theroot.$indexPath);
    // $albums = array_reverse($albums); // Reverses album order
    // shuffle($albums); // Shuffles albums
    $j = min(count($albums), 8); // build <li>s from first 8 in gallery list   
    for($i=0; $i < $j; $i++) {
   
    $childalbum= $albums[$i]['url'];
        echo '<li><a href="'.$albums[$i]['url'].'"title="'.$albums[$i]['description'].'">'.$albums[$i]['title'].'</a>';
                if (file_exists($theroot.$childalbum.'/lib/autoindex/autoindex.php'))
                    {
                    require_once($theroot.$childalbum.'/lib/autoindex/autoindex.php');
                    $albumsc = autoindex($theroot.$childalbum);
                    //    $albumsc = array_reverse($albums); // Reverses album order
                    // build childs from first 8 in gallery list
                    $jc = min(count($albumsc), 8);
                    echo '<ul>'; // create child
                        for($ic=0; $ic < $jc; $ic++)
                        {
                        echo '<li><a href="'.$albumsc[$ic]['url'].'"title="'.$albumsc[$ic]['description'].'">'.$albumsc[$ic]['title'].'</a></li>';
                        }
                    echo '</ul>' ;
                    } // close child

                else
                    {
                    '</li>'; // close liste when there is no autoindex
                     };
                };
            if (count($albums) > 8)
            {
            echo '<li><a href="/galleries.php" title="Mehr Fotos" >mehr ...</a></li>';
            };
    echo '

Can anybody help me?

By the way at www.imagepower.ch it works well...

Thanks a lot
Fabian

Offline

#2 2014-08-23 20:26:03

fabian.trees
Member
Registered: 2012-09-26
Posts: 34

Re: Nested galleries

OK, spending a little bit more of time and analyzing the new structure of CE4, I figured out a code that works:

<!-- EDIT ONLY BELOW THIS LINE : -->
            <li><a href="/">Home</a></li>
            <li><a href="/galleries.php">galleries</a>
                <ul>
';
    $indexPath = '/galleries/'; // set folder location to scan for galleries
    $theroot = $_SERVER['DOCUMENT_ROOT'];

    require_once($theroot.'/lib/autoindex/autoindex.php');
    if (trim($_SERVER["QUERY_STRING"]) == 'debug')
        define ('AUTOINDEX_DEBUG', false); // enable statement to output debugging info from autoindex()
    $albums = autoindex($theroot.$indexPath);
    // $albums = array_reverse($albums); // Reverses album order
    // shuffle($albums); // Shuffles albums
    $j = min(count($albums), 8); // build <li>s from first 8 in gallery list   
    for($i=0; $i < $j; $i++) {
        $childalbum= $albums[$i]['url'];
        echo '<li><a href="'.$albums[$i]['url'].'"title="'.$albums[$i]['description'].'">'.$albums[$i]['title'].'</a>';
                if (file_exists($theroot.$childalbum.'/index.php'))
                    {
                    require_once($theroot.'/lib/autoindex/autoindex.php');
                    $albumsc = autoindex($theroot.$childalbum);
                    // $albums = array_reverse($albums); // Reverses album order
                    // shuffle($albums); // Shuffles albums
                    $jc = min(count($albumsc), 8);// build childs from first 8 in gallery list
                    echo '<ul>'; // create child
                        for($ic=0; $ic < $jc; $ic++)
                        {
                        echo '<li><a href="'.$albumsc[$ic]['url'].'"title="'.$albumsc[$ic]['description'].'">'.$albumsc[$ic]['title'].'</a></li>';
                        }
                    echo '</ul>' ;
                    } // close child
                else
                    {
                    '</li>'; // close liste when there is no autoindex
                     };
                };
            if (count($albums) > 8)
            {
            echo '<li><a href="/galleries.php" title="Mehr Fotos" >mehr ...</a></li>';
            };
    echo '
                </ul>
            </li>
            <li><a href="/blog/">News</a></li>
            <li><a href="/services.php">services</a></li>
            <li><a href="/about.php">about</a></li>
            <li><a href="/contact.php">contact</a></li>
            <li><a href="/search/"><i class="fa fa-search"></i></a></li>
           
        <!-- EDIT ONLY ABOVE THIS LINE -->

Offline

#3 2014-09-21 15:05:02

dougc
Member
Registered: 2013-03-11
Posts: 119

Re: Nested galleries

Fabian,
Thank you so much for posting this solution to Nested Galleries.  I struggled most of the day trying to adapt what I had used successfully in CE3 and was getting nowhere.  When I found your post, I copied and pasted your code into my phplugins.php and it is working like a charm.
Doug

Offline

#4 2015-03-25 19:28:57

fabian.trees
Member
Registered: 2012-09-26
Posts: 34

Re: Nested galleries

Hello Folks

before updating the my website I am testing a lot: Some strange behaviour here:

The nested dropdown menu does not work like expected:
test.imagepower .ch (remove the space... google should not trace...) (you can also login as ttg admin ttg8888)
TTG BE Admin version: 2.0.3
TTG CE4 Publisher version: 2.2.1

instead here, it worked without problems:
ww2.imagepower .ch (remove the space...)
TTG BE Admin version: 2.0.2
TTG CE4 Publisher version: 2.1.3

It seems to find for every time a nested gallery which should not to be

Any idea where to search the error?

The phplugin is the same:

<ul>
';
    $indexPath = '/galleries/'; // set folder location to scan for galleries
    $theroot = $_SERVER['DOCUMENT_ROOT'];

    require_once($theroot.'/lib/autoindex/autoindex.php');
    if (trim($_SERVER["QUERY_STRING"]) == 'debug')
        define ('AUTOINDEX_DEBUG', false); // enable statement to output debugging info from autoindex()
    $albums = autoindex($theroot.$indexPath);
    $albums = array_reverse($albums); // Reverses album order
    // shuffle($albums); // Shuffles albums
    $j = min(count($albums), 8); // build <li>s from first 8 in gallery list   
    for($i=0; $i < $j; $i++) {
        $childalbum= $albums[$i]['url'];
        echo '<li><a href="'.$albums[$i]['url'].'"title="'.$albums[$i]['description'].'">'.$albums[$i]['title'].'</a>';
                if (file_exists($theroot.$childalbum.'/index.php'))
                    {
                    require_once($theroot.'/lib/autoindex/autoindex.php');
                    $albumsc = autoindex($theroot.$childalbum);
                    // $albums = array_reverse($albums); // Reverses album order
                    // shuffle($albums); // Shuffles albums
                    $jc = min(count($albumsc), 8);// build childs from first 8 in gallery list
                    echo '<ul>'; // create child
                        for($ic=0; $ic < $jc; $ic++)
                        {
                        echo '<li><a href="'.$albumsc[$ic]['url'].'"title="'.$albumsc[$ic]['description'].'">'.$albumsc[$ic]['title'].'</a></li>';
                        }
                    echo '</ul>' ;
                    } // close child
                else
                    {
                    '</li>'; // close liste when there is no autoindex
                     };
                };
            if (count($albums) > 8)
            {
            echo '<li><a href="/galleries.php" title="Mehr Fotos" >mehr ...</a></li>';
            };
    echo '
                </ul>

thanks for helping!
Fabian

Offline

#5 2015-03-26 09:13:54

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Nested galleries

You've got a bunch of empty lists -- <ul></ul> -- showing up in your source code.


Matt

The Turning Gate, http://theturninggate.net

Offline

#6 2015-03-27 06:34:48

fabian.trees
Member
Registered: 2012-09-26
Posts: 34

Re: Nested galleries

Not sure what you mean...
once the code works, once not...
the <ul> </ul> is part of the phplugin script provided from ttg pages etc.

function ttg_header_navigation( $style, $path ) {
    echo '
    <div id="navigation-container" class="navigation-container clearfix">
    <div id="navigation" class="block-id navigation clearfix">
    <div class="mantle clearfix">
        <div class="core clearfix">
        <div id="navigation-background">

        <div id="r2d2-menu" class="clearfix">
        <ul id="pull">
            <li><span>&nbsp;</span></li>
            <li><span>&nbsp;</span></li>
            <li><span>&nbsp;</span></li>
            <li><span>&nbsp;</span></li>
            <li id="open-nav" class="toggle-nav"><a href="#r2d2-menu"><i class="fa fa-reorder"></i></a></li>
            <li id="close-nav" class="toggle-nav"><a href="#"><i class="fa fa-remove"></i></a></li>
        </ul>

        <ul id="nav">
        <!-- EDIT ONLY BELOW THIS LINE : -->
            <li><a href="/">Home</a></li>
            <li><a href="/galleries.php">Fotos</a>
                <ul>
';
    $indexPath = '/galleries/'; // set folder location to scan for galleries
    $theroot = $_SERVER['DOCUMENT_ROOT'];

    require_once($theroot.'/lib/autoindex/autoindex.php');
    if (trim($_SERVER["QUERY_STRING"]) == 'debug')
        define ('AUTOINDEX_DEBUG', false); // enable statement to output debugging info from autoindex()
    $albums = autoindex($theroot.$indexPath);
    // $albums = array_reverse($albums); // Reverses album order
    // shuffle($albums); // Shuffles albums
    $j = min(count($albums), 8); // build <li>s from first 8 in gallery list   
    for($i=0; $i < $j; $i++) {
        $childalbum= $albums[$i]['url'];
        echo '<li><a href="'.$albums[$i]['url'].'"title="'.$albums[$i]['description'].'">'.$albums[$i]['title'].'</a>';
                if (file_exists($theroot.$childalbum.'/index.php'))
                    {
                    require_once($theroot.'/lib/autoindex/autoindex.php');
                    $albumsc = autoindex($theroot.$childalbum);
                    // $albums = array_reverse($albums); // Reverses album order
                    // shuffle($albums); // Shuffles albums
                    $jc = min(count($albumsc), 8);// build childs from first 8 in gallery list
                    echo '<ul>'; // create child
                        for($ic=0; $ic < $jc; $ic++)
                        {
                        echo '<li><a href="'.$albumsc[$ic]['url'].'"title="'.$albumsc[$ic]['description'].'">'.$albumsc[$ic]['title'].'</a></li>';
                        }
                    echo '</ul>' ;
                    } // close child
                else
                    {
                    '</li>'; // close liste when there is no autoindex
                     };
                };
            if (count($albums) > 8)
            {
            echo '<li><a href="/galleries.php" title="Mehr Fotos" >mehr ...</a></li>';
            };
    echo '
                </ul>
            </li>
            <li><a href="/blog/">News</a></li>
            <li><a href="/services.php">Referenzen</a></li>
            <li><a href="/about.php">Shop</a></li>
            <li><a href="/contact.php">Kontakt</a></li>
            <li><a href="/search/"><i class="fa fa-search"></i></a></li>
           
        <!-- EDIT ONLY ABOVE THIS LINE -->
        </ul>


        </div><!-- #r2d2-menu -->

        </div><!-- #navigation-background -->
        </div>
    </div>
    </div> <!-- #navigation -->

</div> <!-- #navigation-container -->
    ';
    return false;        // Replaces normal menu
} // END


I am still searching... :-)

Offline

#7 2015-03-27 16:47:57

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Nested galleries

fabian.trees wrote:

Not sure what you mean...

Well it could mean a couple of things. It might mean something is wrong with your code. Or the code might be find, and you might have a bunch of weird, empty folders sitting on your server getting scanned.


Matt

The Turning Gate, http://theturninggate.net

Offline

#8 2015-03-29 07:16:40

fabian.trees
Member
Registered: 2012-09-26
Posts: 34

Re: Nested galleries

Hello Matthew
I did some research...
If in the autoindex.xml the <url></url> is not empty, the phplugin do the right thing, if <url> is empty, there is something, that makes that there are empty lists...

I think I can manage that with my structure!

Thanks
Fabian

Offline

#9 2015-05-18 23:18:59

fabian.trees
Member
Registered: 2012-09-26
Posts: 34

Re: Nested galleries

Hello community

finally here is the code that works for CE4...

$indexPath = '/galleries/'; // set folder location to scan for galleries
    $theroot = $_SERVER['DOCUMENT_ROOT'];

    require_once($theroot.'/lib/autoindex/autoindex.php');
    if (trim($_SERVER["QUERY_STRING"]) == 'debug')
        define ('AUTOINDEX_DEBUG', false); // enable statement to output debugging info from autoindex()
    $albums = autoindex($theroot.$indexPath);
    $albums = array_reverse($albums); // Reverses album order
    // shuffle($albums); // Shuffles albums
    $j = min(count($albums), 8); // build <li>s from first 8 in gallery list   
    for($i=0; $i < $j; $i++)
    {
        $childalbum= $albums[$i]['url'];
        echo '<li><a href="'.$albums[$i]['url'].'"title="'.$albums[$i]['description'].'">'.$albums[$i]['title'].'</a>';
        $albumsc = autoindex($theroot.$childalbum);
        // $albums = array_reverse($albums); // Reverses album order
        // shuffle($albums); // Shuffles albums
        $jc = min(count($albumsc), 8);// build childs from first 8 in gallery list
        if ($jc > 0)
        {
            echo '<ul>'; // create child
            for($ic=0; $ic < $jc; $ic++)
            {
                echo '<li><a href="'.$albumsc[$ic]['url'].'"title="'.$albumsc[$ic]['description'].'">'.$albumsc[$ic]['title'].'</a></li>';
            }
            echo '</ul>' ;
        } // close child
       
        else
        {
            '</li>'; // close liste when there is no autoindex
        };
    };
   
   
    if (count($albums) > 8)
    {
        echo '<li><a href="/galleries.php" title="Mehr Fotos" >mehr ...</a></li>';
    };
    echo '

Perhaps it helps to someone!

Cheers
Fabian

Offline

Board footer

Powered by FluxBB