Forum

Thread tagged as: Gallery

Album listing order

I have a list of albums on my gallery page. I would like to switch the order (so that the most recent is first) - ie sort by album date.

Please can you tell me what the album date id is so I can add it to the SORT.

Thanks


On my gallery/index.php i have :

<div class="box gallery upcoming">
  <h2>List of Albums</h2>
  <ul class="glist albums">

         <?php perch_gallery_albums(array(
            'template' => 'list_of_albums.html',
        )); ?>

      </ul>              </div><!--end box-->

In my list_of_albums.html template I have :

 <li class="event">
  <a href="album.php?s=<perch:gallery id="albumSlug" />"><perch:gallery id="albumTitle" /></a>
  </li>

https://www.chiddingfoldfarmers.com/gallery/cfpc/index.php

cow shed

cow shed 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us your album template?

This is my album.html template :

<?php include('../../perch/runtime.php'); ?>

<!DOCTYPE html> <html lang="en">

<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content="">

<title>CF</title>

<meta name="description" content="" />

<meta name="keywords" content=""/>

<!--  DMOZ or Yahoo! Directory page title and meta description -->
<meta name="robots" content="noodp, noydir" />

<!-- Bootstrap core CSS -->
<link href="../../bootstrap/css/bootstrap.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="../../styles-cfpc/cfpc.css" rel="stylesheet">
<link href="../../styles-cfpc/nest-short.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->


<!-- Fancybox -->
<!-- Add jQuery library -->
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
<!-- Add mousewheel plugin (this is optional) -->
<script type="text/javascript" src="../jquery.mousewheel.pack.js"></script>
<!-- Add fancyBox main JS and CSS files -->
<script type="text/javascript" src="../jquery.fancybox.js"></script>
<script type="text/javascript" src="../jquery.fancybox.pack.js"></script>
<link rel="stylesheet" type="text/css" href="../jquery.fancybox.css" media="screen" />

</head>

<body> <script type="text/javascript"> $(document).ready(function() { $(".fancybox").fancybox(); }); </script> <div class="container masthead"> <img src="../../images-cfpc/pony-club-masthead.png" class="img-responsive" alt=""> </div> <?php require_once('cfpc-menu.php'); ?>

<div class="container main">


 <div class="row">
 <div class="col-md-8">
        <div class="page-header" >  
    <h1>  <?php perch_gallery_album_details(perch_get('s'), array(
'template' => 'album-title.html',
           )); ?>      
     </h1>
</div>

<ul> <?php if(perch_get('s')) { perch_gallery_album_images(perch_get('s'), array( 'template'=>'album-image.html')) ; } ?> </ul> <div style="clear: both;"></div>

  </div>   <!-- end col 8 -->

    <div class="col-md-4">

        <div class="box gallery upcoming">
        <h2>List of Albums</h2>
          <ul class="glist albums">
              <?php perch_gallery_albums(array(
                'template' => 'list_of_albums.html',
                )); ?>
          </ul>  
        </div><!--end box-->

    </div> <!--end col-8-->



</div><!-- end row -->


</div>    <!-- end container main-->

<div style="clear: both;"></div>

<footer> <?php require_once('../../includes/footer.php'); ?> </footer>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../../bootstrap/js/bootstrap.min.js"></script>

</body>

</html>

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think that's your page rather than the album.html template.

Ok. What's the ID of the date field you want to sort by?

whoops I think you wanted this <h1 class="text-center welcome"><perch:gallery id="albumTitle" type="text" label="Title" size="l" /></h1>

<span class="text-center welcome"><perch:gallery id="description" type="textarea" label="Description" editor="markitup" textile="true" order="1" size="m" /> </span>

I can see a album date when I look at the albums that have been added though the perch user interface. But I can t see a date here!

I have this on my album_listing.html template which looks more useful. Its from the nest example. It sets a date using timestamp - so I'm not too sure what the field is called...

<div class="col-sm-6">

     <div class="album boxer">

        <a href="album.php?s=<perch:gallery id="albumSlug" />">

        <img src="<perch:gallery id="square" />" alt="" />

        <span class="image-count"><perch:gallery id="imageCount" /> <span class="lang-photos">photos in this album</span></span>

        </a>

    <div class="box gallery minor boxed">

    <h2><a href="album.php?s=<perch:gallery id="albumSlug" />"><perch:gallery id="albumTitle" /></a></h2>

    <time datetime="<perch:gallery id="date" type="date" format="Y-m-d" />" pubdate="pubdate"><span class="day"><perch:gallery id="date" type="date" format="jS" /></span> <perch:gallery id="date" type="date" format="F Y" /></time>

    <perch:gallery id="description" type="textarea" textile="true" />


    </div> <!-- end box gallery minor boxed --> 
    </div> <!-- end album boxer --> 

</div> <!-- end column-6 -->

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, it looks like it's just called date. So

'sort' => 'date',
'sort-order' => 'DESC',

Thank you! Thats worked