Можете помочь с MODX EVO?

Есть страница стран, в ней страны, необходимо сделать чтобы список формировался по алфавиту и по континентам.Что не так в этом сниппете?
Он взят в REVO на котором все работает.
<?php
$get = isset($_GET['type']) ? $_GET['type'] : '';//determine which type of output

if ($get=='cont') {$a='континентам';}
else {$a='алфавиту';}

echo '<div class="countryes">


  <form action="" class="form-body">
    <div class="sorting">
      <label for="">Сортировать по:</label><span class="select-carousel abc">
    <input type="hidden" id="hva" value="">
    <span class="current" style="">'.$a.'</span>
		<span class="open" style="display: none;">
			<span class="top">
				<span class="scroll_up"></span>
			</span>
			<span class="tile">
				<span class="value">алфавиту</span>
				<span class="value">континентам</span>
			</span>
			<span class="bottom">
				<span class="scroll_down"></span>
			</span>
		</span>
		</span>
    </div>
    
  </form>


  <div class="clr"></div>

  <div class="stats">';

$childs = $modx->getChildIds($id=5,$depth=1);



if ($get=='cont') {
///by continent
foreach ($childs as $child ){
$document = $modx->getObject('modResource',$child);
  echo '<dl class="countries-cont">
      <dt><strong>'.$document->get('pagetitle').'</strong></dt>
        <dd>
          ';
   $subchilds = $modx->getChildIds($id=$document->get('id'),$depth =1);
   $x=0;//hanoy counter
   $hanoy[1]='';//hanoy tower
   $hanoy[2]='';//hanoy tower
   $hanoy[3]='';//hanoy tower
   $hanoy[4]='';//hanoy tower
    foreach ($subchilds as $subchild) {
   $x++; if ($x>4) $x=1;

    $subdocument = $modx->getObject('modResource',$subchild);
    $hanoy[$x] .= '<li><a title="'.$subdocument->getTVValue('title-for-list').'" href="'.$modx->makeUrl($subchild,'','','full').'"><img border="0" src="/'.$subdocument->getTVValue('flag').'"><span>'.$subdocument->get('pagetitle').'</span></a></li>';
    }//foreach country

          echo '<ul>'.$hanoy[1].'</ul><ul>'.$hanoy[2].'</ul><ul>'.$hanoy[3].'</ul><ul>'.$hanoy[4].'</ul>
        </dd>
    </dl>';
  }//foreach continent
//by continent
}//if GET

else {
///alphabet
echo '<div class="stats">';
$bukvi=0;
$count=0;//how many countries total
$array=array();
foreach ($childs as $child ){
 $document = $modx->getObject('modResource',$child);
 $subchilds = $modx->getChildIds($id=$document->get('id'),$depth =1);
 foreach ($subchilds as $subchild) {
    $subdocument = $modx->getObject('modResource',$subchild);
    $tmp = $subdocument->get('pagetitle');
    $key = $tmp[0].$tmp[1];
    if (!in_array($key, $array)) {
    array_push($array,$key);
    $cou[$key]=array();

    }
    array_push($cou[$key],$subchild);
    $count++;
    //echo print($tmp);
 }//foreach subchilds
}//foreach childs
sort($array);//sort alphabetically



$x = ($count % 4);//how many countries must be in each tower
$y = ($count - $x)/4;


if ($x==0){$x = ($count-$x)/4;}
else {//$x = ($count-$x)/4+1;}
$x=$y;}


///output
echo '<dl class="countries-col">';
$y = 0; //how many countries in current tower
foreach ($array as $letter){
echo '<dt>'.$letter.'</dt>';
     foreach ($cou[$letter] as $elem){
  $tmp = $modx->getObject('modResource',$elem);
   $title = $tmp->get('pagetitle');
   $src = $tmp->getTVValue('flag');
   echo '<dd><a title="'.$tmp->getTVValue('title-for-list').'" href="'.$modx->makeUrl($elem,'','','full').'"><img src="/'.$src.'"><span>'.$title.'</span></a></dd>';

   $y++;//increment counter of element in current tower
  }//output current letter
  if ($y>=$x) { //we must make next tower
   $y=0;
  echo '</dl><dl class="countries-col">';
  }//if y>=x

}


echo '</dl>';
echo '</div><div class="clr"></div>';

/////alphabet
}//else


echo '
  </div>


</div>';
Николай Загумённов
17 октября 2013, 07:31
modx.pro
2 322
0
Поблагодарить автора Отправить деньги

Комментарии: 2

Василий Наумкин
17 октября 2013, 11:33
0
Коля, я Evolution не видел уже пару лет.

Но в коде сразу заметно, что идет работа с объектами, которых в Evo просто нет.
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
2