Pagelist filtering
Permalink
Hello,
In a page type I have hardcoded a page list. When I activated the caching in Concrete5 the filtering I created is not working anymore. I wonder why this is the case and how it should have been done so it would work properly. The variables are still available in the url but the filter is not applied.
To clarify what I have done I will show some code snippets. In the "real versions" I have 3 filter drop downs.
Hardcoded pagelist
The page list makes use of filter that can be selected via a dropdown. When selected the variable of the location is available via de url. The variable is used to filter the pages on the page attribute.
Filtering
Filter example (html)
Thanks for the help,
Rge
In a page type I have hardcoded a page list. When I activated the caching in Concrete5 the filtering I created is not working anymore. I wonder why this is the case and how it should have been done so it would work properly. The variables are still available in the url but the filter is not applied.
To clarify what I have done I will show some code snippets. In the "real versions" I have 3 filter drop downs.
Hardcoded pagelist
$pl = new pageList(); //create a new instance $pl->filterByCollectionTypeHandle('news_item'); $pl->sortByPublicDateDescending(); $pl->setItemsPerPage(9); //total of items per page
The page list makes use of filter that can be selected via a dropdown. When selected the variable of the location is available via de url. The variable is used to filter the pages on the page attribute.
Filtering
/** * Filter by attribute * @orderBy get value via post or * example : /news?location=amstedam */ $location = $_REQUEST['location']; if( !empty($location) ){ if($location != 'all'){ $pl->filterBySelectAttribute('location', $location ); } } /** * Get pages * */
Viewing 15 lines of 16 lines. View entire code block.
Filter example (html)
/** * Get the location values */ $akLocation = CollectionAttributeKey::getByHandle('location'); $satcLocation = new SelectAttributeTypeController(AttributeType::getByHandle('select')); $satcLocation->setAttributeKey($akLocation); $valuesLocation = $satcLocation->getOptions(); /** * Create the dropdown */ <ul class="dropdown-menu vac-location-dropdown" role="menu" aria-labelledby="d-location"> <li><a href="<?php echo $uh->setVariable('location', 'all'); ?>">Toon alles</a></li> <?php foreach ($valuesLocation as $key => $v): $lv = str_replace(' ', '+', $v);
Viewing 15 lines of 19 lines. View entire code block.
Thanks for the help,
Rge
I guess I wil just have make a new block for this functionality. Any advice, examples and tips are welcome.
FYI
I have created a custom block based on the pagelist block in the core. The caching problem does not exist anymore.
Create page list (controller)
Filter the pagelist
In the view.php I have created the filter dropdown with the url helper
I have created a custom block based on the pagelist block in the core. The caching problem does not exist anymore.
Create page list (controller)
Loader::model('page_list'); $bID = $this->bID; $pl = new pageList(); $pl->setNameSpace('b' . $this->bID); $pl->filterByCollectionTypeHandle('blog_item'); $pl->sortByPublicDateDescending(); $pl->setItemsPerPage($this->num);
Filter the pagelist
/** * Filter by attribute * @orderBy get value via post or * example : /blog?categorie=php */ $categorie = $_REQUEST['categorie']; if( !empty($categorie) ){ if($categorie != 'all'){ $pl->filterBySelectAttribute('categorie', $categorie ); } }
In the view.php I have created the filter dropdown with the url helper