Author Topic: show childpages and childpages of childs in the parentpage  (Read 1944 times)

Offline Craxx

  • Posts: 266
show childpages and childpages of childs in the parentpage
« on: February 20, 2010, 02:06:06 PM »
Hy WB-Gurus:),

i have the following problem. I have a page called "Handbuch" below this page there are several topics an subtopics.



To print the complette Handbook (Handbuch) at once, it should be shown under Handbuch with all Topics and subtopics. For this i need some Code. I have tested the following code from a Thread:

<?php
if ($page_id) {
    $db = new database();   
    $q = $db->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE root_parent = '$page_id' ORDER BY page_id");
    while ($d = $q->fetchRow()) {
        $wb->page_id = $d['page_id'];
        page_content();
    }
} else {
    page_content();
}
?>

With this code i get the topics and subtopics, but not really right. The it is not one after another like we can see the topics on left side, i think it is after the ID. I also tested the Aggregator Modul, but there is only the possibility for only Parent and Child no childs from the childs:)

Please help me?

best regards and THX a lot:)
Craxx
Craxx;)

Offline Monky

  • Posts: 47
  • Gender: Male
    • Segelclub Würmsee Starnberg e.V.
Re: show childpages and childpages of childs in the parentpage
« Reply #1 on: February 21, 2010, 08:50:00 PM »
Hi, I am trying to help a bit.

1. Your line
Code: [Select]
if ($page_id) { doesnt make sense. I guess you mean something like
Code: [Select]
if ($page_id == 42) {2. Your Query does
Code: [Select]
ORDER BY page_id so of course the result is ordered by page_id  :wink:
I threw a quick glance in the pages table of my page and I think the ordering you want is something like
Code: [Select]
ORDER BY parent, positionI'm not really sure though if this grants exactly the result you want. If might be easier (though uglier) to make several queries: one for each child of "Handbuch". You can then sort those queries by position.

Offline Craxx

  • Posts: 266
Re: show childpages and childpages of childs in the parentpage
« Reply #2 on: February 22, 2010, 11:10:35 AM »
Hy Monky,

thx for answer. I tested with following code, but i changed id from your 42 to 23 because handbuch is 23 and i sort by page_trail because parent and position doesn´t work. With this code it works :):

if ($page_id == 23) {
    $db = new database();  
    $q = $db->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE root_parent = '$page_id' ORDER BY page_trail");
    while ($d = $q->fetchRow()) {
        $wb->page_id = $d['page_id'];
        page_content();
    }
} else {
    page_content();
}


best regards
Craxx
« Last Edit: February 22, 2010, 08:27:03 PM by Craxx »
Craxx;)

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!