Get Sitemap order

Permalink
Hi Guys

Is there a way to get the sitemap order integer by collectionID or collectionLink?

Anybody ever do this?

I need to use Javascript to scroll horizontal and vertical, so i need the sitemap order of parent (eg. 4) and then get the child page you are targeting (eg.2)... so the page will jump to page 4, section 2.

Any help will be greatly appreciated!

 
siton replied on at Permalink Reply
siton
mmm its hard to understand what you trying to do. "Site map order" its very general term.
Mabye add some screenshot.

Mabye you can use the auto nav block array (Without any filtering + show all subpage + childs - its really like "site map" without hierarchy + you can know the "parent" and "childs" in the code) and/or pagelist array.

Pagelist object:
http://documentation.concrete5.org/developers/working-with-pages/se...

Getting Data about a Page
http://documentation.concrete5.org/developers/working-with-pages/ge...

Or search her: you find a lot of code snippets - "C5 Cheat Sheet":
http://www.webli.us/cheatsheet/doku.php...

Get the parent page name+link of page X :
$c = Page::getCurrentPage();
   // - get the parent page object using the ID
   $parentPageObject = Page::getByID($c->getCollectionParentID());
   // - using the parent page object, get the collection name (the page title)
   $parentPageName = $parentPageObject->getCollectionName();
   // get the URL of the parent page using the parent page object
   $parentPagelink = URL::to($parentPageObject);
Kitsu replied on at Permalink Reply
Hi siton

Thanks for the reply mate.


An example will be like this:

Sitemap: ( - is the Parent, = is the child)

+ Home:
- About Us:
= What we do
= Our mission
- Services:
= what we offer
- Contact Us:
= Map
= basic info


What i am trying to do is make a one-page template, so every "Parent" page i make will be a vertical section and every child of that parent will be a horizontal "Carousel".

So I want to make a JavaScript menu that when i click on a button that says basic info, I need the page to scroll down 3 times and 2 times across to the right.

at the moment if we manually navigate, the url looks like this:

http://localhost/golf/#Lifestyle/3...

That will scroll to the lifestyle section and the 3rd carousel page (which is a child page).

I hope this makes sense.

In the mean time I will go through the links that you have provided. :)

Thank you once again mate!

<section id="Lifestyle">
      <div class="page_1">
         //sample content here
      </div>
</section>
<section id="About">
      <div class="page_1">
         //sample content here
      </div>
      <div class="page_2">
         //sample content here
      </div>
      <div class="page_3">
         //sample content here
      </div>
Kitsu replied on at Permalink Reply
I think i managed to get it right.

by using the
$parent_children = $parent->getCollectionChildrenArray();

It basically gets the children in sitemap order.

So when i do a foreach loop i can just compare if the collectionID of the child that is being looped is equal to the child that im trying to target then set it as the url.... the problem is obviously that php arrays start at 0 so i just increment at the start of the loop which gives me 1, 2, 3 instead of 0, 1, 2.

$parent_children = $parent->getCollectionChildrenArray();
$pp_id = NULL;
foreach($parent_children as $ppc => $pc):
      $ppc ++;
      if($pc == $plink_id){
         $pp_id = $ppc;
      }else{
         continue;
      }
   endforeach;


I know the above code can be optimized.

So, basically... the end result is this:

http://localhost/golf/#Lifestyle/3...
where "#Lifestyle" is the parent page name, and "3" is the $pp_id or the php array number.

Thanks for your help in pointing me to the cheatsheet!

If something looks wrong in the above code, please do let me know.