<![CDATA[ Sorting by pagetitle - My Forums]]> https://forums.modx.com/thread/?thread=101054 <![CDATA[Sorting by pagetitle]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545584
I cannot sort by pagetitle:

$resources[] = $res->get('pagetitle') . '==' .$res->get('pagetitle');
$resources->sortby('pagetitle', 'ASC'); 


2nd line doesnt work!
Any ideas?]]>
sspind Oct 11, 2016, 07:27 AM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545584
<![CDATA[Re: Sorting by pagetitle]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-553023 ]]> servicesatmumba Aug 05, 2017, 09:46 AM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-553023 <![CDATA[Re: Sorting by pagetitle]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545692 ]]> BobRay Oct 14, 2016, 06:29 AM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545692 <![CDATA[Re: Sorting by pagetitle]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545663 sspind Oct 13, 2016, 07:09 AM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545663 <![CDATA[Re: Sorting by pagetitle (Best Answer)]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545648
natcasesort($resources);


It would be faster if you refactored the whole operation so the resources you want could be pulled with a single query, using:

$c->sortby('pagetitle', 'ASC');


but your selection criteria are so complex that it would be a very difficult query.
]]>
BobRay Oct 12, 2016, 09:23 PM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545648
<![CDATA[Re: Sorting by pagetitle]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545629
<?php
//Spezielle Gruppe Fachtrainer
$superusergroups = $modx->getOption('superusergroups', $scriptProperties,'8,9,11');

//Kursinformationen von Parent Kursinformationen
$parent = $modx->getOption('parent', $scriptProperties, 47);

$superusergroups = explode(',', $superusergroups);

$groups = $modx->user->getUserGroups();

$has_permission = false;
$accepted = false; //see below

//Ist der User überhaupt in der Superusergroup?
foreach ($superusergroups as $group) {
    if (in_array($group, $groups)) {

	      $has_permission = true; //user is in one of the superusergroups

          $gruppe = $group;
/*	NEW: check which superuser group
			if ($group[0] != "")
			{
			$gruppe = "1";
			}
			else if ($group[1] != "")
			{
			$gruppe = "2";
			}
			else
			{
			$gruppe = "3";
			}


 $modx->log(modX::LOG_LEVEL_ERROR, $gruppe);
 $modx->trigger_error($gruppe, E_USER_WARNING);
 */
	}
	
}
$modx->log(modX::LOG_LEVEL_ERROR, $gruppe);
//Überprüfen welche Gruppe


$resources = array();
if ($parentObj = $modx->getObject('modResource', $parent)) 
{
 $c = $modx->newQuery('modResource');
 if ($resArray = $parentObj->getMany('Children', $c)) 
 {
    foreach ($resArray as $res) 
	{

       // if ($res instanceof modResource) 
	//	{
            if ($res->get('description') == 'Impuls Lehrtrainer 2') 
			{
                if ($has_permission AND $gruppe > "10")
				{
                    $accepted = true;
                }
            } 

			else if ($res->get('description') == 'Impuls Lehrtrainer') 
			{
                if ($has_permission AND $gruppe > "8")
				{
                    $accepted = true;
                }
            } 

				else if ($res->get('description') == 'Fachtrainer') 
			{
                if ($has_permission AND $gruppe >= "8")
				{
                    $accepted = true;
                }
            } 

			else 
			{
                $accepted = true;

            }
    //    }

        if ($accepted) 
			{
           // $resources[] = $res->get('pagetitle') . '==' .$res->get('id');
		   $resources[] = $res->get('pagetitle') . '==' .$res->get('pagetitle');
		   //$resources->sortby('pagetitle', 'ASC'); 
        	}
        $accepted = false; //reset accepted to false
      }
}

}
$out = implode("||", $resources);

return $out;
]]>
sspind Oct 12, 2016, 02:46 PM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545629
<![CDATA[Re: Sorting by pagetitle]]> https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545597
We need to see more of your code in order to help you.]]>
BobRay Oct 11, 2016, 06:42 PM https://forums.modx.com/thread/101054/sorting-by-pagetitle#dis-post-545597