Forum

Thread tagged as: Question

Sort Order on Multiple Filter

I have a list and detail setup which has a project page which contains all projects: I have a checkbox which allows me to switch the project on and off in the admin. I need to display all projects alphabetically by project name: The following code is used on the main project page and the ordering works perfectly.:

// List mode
          perch_content_custom('Projects', array(
        'page'=>'/projects/index.php',
        'template' => 'project_listing1.html',
     'filter'   => 'visibility',
       'match'    => 'eq',
         'value'    => 1,
    'sort' => 'projecttitle',
     'sort-order' => 'ASC',
    ));  

I then need to have category pages which use the shared regions of the main project page and filter by project type ie Education Projects page filters on the 'projecttype' id:

<?php
perch_content_custom('Projects', array(
        'page'=>'/projects/index.php',
        'template' => 'project_listing2.html',

        'filter'=>array(
        array(
           'filter'   => 'projecttype',
               'match'    => 'eq',
               'value'    => education,
               'sort' => 'projecttitle',
               'sort-order' => 'ASC',
        ),
        array(
           'filter'   => 'visibility',
               'match'    => 'eq',
               'value'    => 1,
               'sort' => 'projecttitle',
               'sort-order' => 'ASC',
        ),
    )
));
?>

All projects appear correctly on the relevant pages except that now, on the individual category pages which have 2 filters - ie 'Education Projects' page, the ordering doesn't work. Am I missing something with above code?

Richard Lowe

Richard Lowe 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Sorting isn't part of the filter.

<?php
perch_content_custom('Projects', array(
    'page'       => '/projects/index.php',
    'template'   => 'project_listing2.html',
    'sort'       => 'projecttitle',
    'sort-order' => 'ASC',
    'filter'     => array(
        array(
            'filter' => 'projecttype',
            'match'  => 'eq',
            'value'  => 'education',
        ),
        array(
            'filter' => 'visibility',
            'match'  => 'eq',
            'value'  => 1,
        ),
    )
));
?>
Richard Lowe

Richard Lowe 0 points
Registered Developer

of course, thanks again for great support!

Drew McLellan

Drew McLellan 2638 points
Perch Support

No problem!