Site map order.
Permalink
I am doing some work on a site built by another company.www.www.keystonelaw.co.uk/sitemap... they wish for all the pages under Lawyers to be alphabetical in the sitemap so that whenever someone is added it will slot in where it should. Surely this is possible without some custom coding but I cant find anything useful. e.g "Order pages A-Z"
You could try using the ’Page List’ block and sort ‘A-Z’. Also add some css to style the links:
If you're using a page list block, then there are numerous ways to sort the pages, including alphabetically.
If however you're referring the the dashboard site map, then you are going to need some custom code. I've used code like this in the past to do this sort of thing:
Perhaps the easiest place to put this is in a custom package and hook into one of concrete5's events. For example something like this:
You might want to experiment with the most appropriate event - on_page_version_approve may not be what you want. Checkouthttps://documentation.concrete5.org/developers/appendix/full-event-l...
If however you're referring the the dashboard site map, then you are going to need some custom code. I've used code like this in the past to do this sort of thing:
$pl = new PageList(); $pl->filterByPath('/my-parent-page'); $pl->sortByName(); $pages = $pl ->get(); if ($pages && is_array($pages)){ foreach ($pages as $displayOrder => $page) { $page->updateDisplayOrder($displayOrder, $page->cID); } }
Perhaps the easiest place to put this is in a custom package and hook into one of concrete5's events. For example something like this:
<?php namespace Concrete\Package\Mypackage; class Controller extends Package { protected $pkgHandle = 'mypackage'; protected $appVersionRequired = '5.7.5'; protected $pkgVersion = '0.1'; public function getPackageName () { return t("My Package"); } public function getPackageDescription () { return t("My Package"); } public function on_start () { Events::addListener('on_page_version_approve', function ($event { $page = $event->getPageObject();
Viewing 15 lines of 30 lines. View entire code block.
You might want to experiment with the most appropriate event - on_page_version_approve may not be what you want. Checkouthttps://documentation.concrete5.org/developers/appendix/full-event-l...