GetSimple Support Forum
Cannot order subpages list, why? - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Cannot order subpages list, why? (/showthread.php?tid=10675)



Cannot order subpages list, why? - SalamandersPL - 2019-02-09

Hi. Relatively small problem.

I can not order the subpages i want to echo with the loop:
PHP Code:
   <?php
      $children
=getChildren('term-conditions');
 
     $ordered subval_sort($children'menuOrder');
    
?>
    <div class="parent">
      <?php foreach ($ordered as $child){?>
      <h2><?php getPageField($child'title'); ?></h2>
      <?php }; ?>
    </div> 

The $ordered variable do nothing. Why?


RE: Cannot order subpages list, why? - SalamandersPL - 2019-02-15

Hello?

Can anyone can help me to order this list?


RE: Cannot order subpages list, why? - smdp-1971 - 2019-02-15

(2019-02-15, 03:05:04)SalamandersPL Wrote: Hello?

Can anyone can help me to order this list?

In theme folder create functions.php and add this code:
PHP Code:
function getChildrenTitle($page)
{
    $children getChildren($page);
    foreach ($children as $subpage)
    {
        $title returnPageField($subpage,'title');
        echo '<div class="parent">';    
            echo 
'<h2>'.$title.'</h2>';
        echo '</div>';
    }    


Call the function in template:
PHP Code:
<?php getChildrenTitle('term-conditions');?>



RE: Cannot order subpages list, why? - SalamandersPL - 2019-02-18

Still, i have them ordered different way on the page than in GetSimple.

https://salamanders-studio.com/temp/getsimple.png
https://salamanders-studio.com/temp/result.png

(if you ask about my getsimple look: this is a css plugin, not modified core)


RE: Cannot order subpages list, why? - smdp-1971 - 2019-02-19

(2019-02-18, 19:27:07)SalamandersPL Wrote: Still, i have them ordered different way on the page than in GetSimple.

https://salamanders-studio.com/temp/getsimple.png
https://salamanders-studio.com/temp/result.png

(if you ask about my getsimple look: this is a css plugin, not modified core)

I see that you use numbers in the title (h2).

So try this code:
PHP Code:
function getChildrenTitle($page)
{
    
$children getChildren($page);
    
$pagesSorted subval_sort($childrenSORT_NUMERIC);
    
$pagesSorted array_reverse($pagesSortedtrue);
    
 
   foreach ($pagesSorted as $subpage)
 
   {
 
       $title returnPageField($subpage,'title');
 
       echo '<div class="parent">'   
            echo 
'<h2>'.$title.'</h2>';
 
       echo '</div>';
 
      




RE: Cannot order subpages list, why? - SalamandersPL - 2019-02-20

Your code gave me this:

https://www.salamanders-studio.com/temp/result2.png

Well, it would be great to have that option to sort it same as displayed in CMS.
And what is "menuOrder" for?

Smile


RE: Cannot order subpages list, why? - smdp-1971 - 2019-02-20

(2019-02-20, 09:43:03)SalamandersPL Wrote: Your code gave me this:

https://www.salamanders-studio.com/temp/result2.png

Well, it would be great to have that option to sort it same as displayed in CMS.
And what is "menuOrder" for?

Smile

Do you have install i18N plugin? If you have, create a new component (Theme->Edit Components) with this code:

Component name -> custom-nav
PHP Code:
<li class="<?php echo $item->classes; ?>">

 
 <a href="<?php echo htmlspecialchars($item->link); ?>">
 
   <?php echo htmlspecialchars($item->title); ?>
  </a>
 
  <?php if ($item->isOpen) { ?>
    <ul><?php $item->outputChildren(); ?></ul>
  <?php ?>
</li> 
In template add this:
PHP Code:
<?php if (return_page_slug()=='term-conditions') { ?>    
    <ul class="tree">    
    <?php get_i18n_navigation('term-conditions',1,100,I18N_SHOW_NORMAL'custom-nav'); ?>
    </ul>
<?php ?>



RE: Cannot order subpages list, why? - SalamandersPL - 2019-02-20

You are a great man. Thank you!


RE: Cannot order subpages list, why? - smdp-1971 - 2019-02-21

(2019-02-20, 22:34:40)SalamandersPL Wrote: You are a great man. Thank you!

You're welcome!