Print page name at Third Level

Permalink
Hi all,
I've searched the forums and tried several different snippets of code to get this working, but can't get it working.

My sitemap is setup like so:

Home
   - English
      -Category Name One
         - 2015-08-17
            - blog post 1
            - blog post 2
            - blog post 3
      -Category Name Two
         - 2015-08-16
            - blog post 1
            - blog post 2
            - blog post 3


Is there a way to display the name of the page at LEVEL 3 (Category Name) in my view.php file in my custom block?

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi stangn99,

Can you be more specific about what you are trying to do.

What pages are you going to use the block on?

You can use the Auto-Nav block to display the "Category Name" on pages.

Are you trying to get the page name "Category Name" or the page and a link?
stangn99 replied on at Permalink Reply
Hi MrKDilkington,
Thanks for the reply.

I've created a custom PageList template which displays 6 "front page" pages on the landing page of the website (with thumbnails)

I've setup the template so that there is a DIV box positioned on top of the thumbnail image of each page that is loaded with the Page List block.

The purpose of this DIV is to display the Page Name of category page as seen below. In the example below, the DIV box should display "Sports" or "News" depending on the ParentParent (grandparent) page name as seen in the sitemap example.

Home 
   - English 
      -Sports 
           - 2015-08-17 
                - Hockey is cool 
                - So is Baseball 
                - And Soccer 
       -News 
           - 2015-08-17  
                - Concrete is cool 
                - And easy to use


Please let me know I've made any sense and if more clarification is needed.

Thanks again!
MrKDilkington replied on at Permalink Reply
MrKDilkington
I am still not sure what you are trying to accomplish.

Do you have a website link where you are using this template?

Do you also have a design mockup of how you want the information displayed?
stangn99 replied on at Permalink Reply 1 Attachment
Hi again.
Thanks for the reply.

Does the attached image show what I'm trying to do?

I'm building this locally, so I unfortunately do not have a link to share.

I really appreciate the help!
stangn99 replied on at Permalink Reply
Hi again,
I believe I finally got it working. I don't know why I didn't think of this sooner, and I'm not sure if there is a better way to do this.


To get the page name of page 2 levels above current page I did the following:

<?php 
foreach ($pages as $page) {
     // Get parent page ID
     $parentID = Page::getByID($page->getCollectionParentID()); 
     // Use $parentID from above to get it's parent ID
    $grandparentID = Page::getByID($parentID->getCollectionParentID()); 
     // Print the page name of grandparent page
    print $grandparentID->getCollectionName();
}
?>



Is there a better (one-step) way of doing this? Rather than getting the ID's twice?
MrKDilkington replied on at Permalink Reply
MrKDilkington
After looking through the Page class methods, there appear to be a couple ways to do this.
http://www.concrete5.org/api/class-Concrete.Core.Page.Page.html...

For what you are trying to do, I am not aware of a one step way to do this.
stangn99 replied on at Permalink Reply
MrKDilkington,

I guess I'll leave it as-is, since it seems to be working okay.

Thanks once again for all your help!