We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29003
    • 5 Posts
    Просьба помочь разобраться с этой ситуацией.
    Выводится основной товар на страницу. Слева и справа должен выводиться предыдущий и следующий товар и была возможность перехода между ними.
    Для наглядности можно глянуть Чайники
    т.е. нужно не только ссылки "назад" и "вперед", но и вывести товар.
    Спасибо!
      • 23027
      • 7 Posts
      Была схожая задача. У меня просто выводились ссылки на соседние элементы. типа:
      ← Кухня «Виола» | Кухня «Волна 2» →
      Картинки, думаю, сам доделаешь.
      Для Evo использовал сниппет:
      [[PrevNext]]
      <?php
      $ID = $modx->documentIdentifier;
      $parentId = array_pop($modx->getParentIds($modx->documentIdentifier,1));
      
      $children = $modx->getActiveChildren($parentId,'menuindex','ASC');
      
      $i=0;
      $key = false;
      while(!$key && $i<count($children)){
        $key = array_search($ID,$children[$i]);
        $i++;
      }
      
      if(!empty($key) && count($children)>1) 
      {
      if ($i-2>=0) { $pprev = $modx->getDocument($children[$i-2]['id'], "pagetitle"); }
      if ($i<count($children)) { $pnext = $modx->getDocument($children[$i]['id'], "pagetitle");  }
      
          $placeholders = array(
          'prev'=>( $i-2>=0 ? '<a href="'.$modx->makeUrl($children[$i-2]['id']).'">← '.$pprev['pagetitle'].'</a>':''),
          'next'=>($i<count($children)?'<a href="'.$modx->makeUrl($children[$i]['id']).'">'.$pnext['pagetitle'].' →</a>':'')
      );
      $output = $modx->parseChunk('prevnext',$placeholders,'[+', '+]');
      
      }
      return $output;
      ?>


      Чанк prevnext:
      [+prev+] | [+next+]


      Чанк next
      <a href="[~[+id+]~]">[+pagetitle+] →</a>


      Чанк prev
      <a href="[~[+id+]~]">← [+pagetitle+]</a>