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"

 
Steevb replied on at Permalink Reply
Steevb
You could try using the ’Page List’ block and sort ‘A-Z’. Also add some css to style the links:
.ccm-block-page-list-title::before{
   content:"\2022";margin-right: 5px}
jero replied on at Permalink Reply
jero
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:

$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();


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...