WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: Craxx on February 20, 2010, 02:06:06 PM

Title: show childpages and childpages of childs in the parentpage
Post by: Craxx 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.
(http://www.messlers.com/unterseiten.jpg)


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
Title: Re: show childpages and childpages of childs in the parentpage
Post by: Monky 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.
Title: Re: show childpages and childpages of childs in the parentpage
Post by: Craxx 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
Title: Re: show childpages and childpages of childs in the parentpage
Post by: Argos on March 22, 2010, 09:56:38 AM
Sounds like a regular sitemap to me, starting at a certain page.

As a droplet:
http://www.websitebakers.com/pages/droplets/official-library/navigation/sitemapchild.php

As module:
http://www.websitebakers.com/pages/modules/listings/section-pages/sitemap.php