Page 1 of 1
Docs X - Re-ordering the pages in sidebar
Posted: Sun May 09, 2021 7:57 pm
by kaaleth
Hi,
how can I reorder the page positions inside of sidebar? I have changed the position of the content but the pages are still messy. I would like to sort them somehow.
Re: Docs X - Re-ordering the pages in sidebar
Posted: Mon May 10, 2021 3:08 pm
by Edi
Please see the following post:
viewtopic.php?p=7612#p7612
This works with default content.
Re: Docs X - Re-ordering the pages in sidebar
Posted: Mon May 10, 2021 9:02 pm
by kaaleth
Hi Edit,
I was not able to find a solution for my problem.
I have something like this:
- menu.png (2.33 KiB) Viewed 4826 times
So as you can see, Home is a parent category that has a child: Team and Welcome.
The Welcome page has order set by 1 and Team set by 2 but somehow the website shows the Team as 1st and Welcome as 2nd. How can I change it?
I have also found a bug. I thought I should create a websites as static, but it allows me to create only the link to horizontal navbar, not sidebar. After I moved the parent with some child from static to default (pages), I was able to see parent only. The child are disappeared
Edit:
Ok I found the solutions. In the settings of Bludit there is a need to change the order of displaying post from date to position.
Greetings
Re: Docs X - Re-ordering the pages in sidebar
Posted: Mon May 10, 2021 9:41 pm
by Edi
kaaleth wrote: ↑Mon May 10, 2021 9:02 pm
In the settings of Bludit there is a need to change the order of displaying post from date to position.
Sorry, I should have mentioned that.
Re: Docs X - Re-ordering the pages in sidebar
Posted: Thu Aug 04, 2022 1:45 pm
by miloslav
Hi I made a simple function for ordering subpages by "position" number:
Code: Select all
function renderChildrenListSorted($parentPage) {
$out = '';
$childrenSorted = [];
if ($parentPage->hasChildren()) {
$out .= '<ul>';
$children = $parentPage->children();
foreach ($children as $ch) {
$position = $ch->getValue('position');
$childrenSorted[$position] = $ch;
}
ksort($childrenSorted);
foreach ($childrenSorted as $child) {
$out .= '<li>';
$out .= ' <a href="'.$child->permalink().'">'.$child->title().'</a>';
$out .= '</li>';
}
$out .= '</ul>';
}
return $out;
}
add this function to init.php in Your theme and call simple like that in template php file:
Code: Select all
echo renderChildrenListSorted($page);