Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17480 Posts in 4474 Topics by 1973 members

Archive

SilverStripe Forums » Archive » How do I get the Page Type of the Parent.

Our old forums are still available as a read-only archive.

Page: 1
Go to End
Author Topic: How do I get the Page Type of the Parent. 562 Views
  • micahsheets
    avatar
    Community Member
    106 posts

    How do I get the Page Type of the Parent. Link to this post

    I would like to know how to get the Page Type of the Parent of the current page. All my level(2) pages are of the same page type, however the parent pages are of various types. I need to make changes in the child pages based on what the parent page's page type is.

    I want to do this in the Class php file not in the template so <% control Parent %> won't work for me.

  • Sam
    avatar
    Administrator
    636 posts

    Re: How do I get the Page Type of the Parent. Link to this post

    <% control Parent %> just calls $this->Parent() if that method exists, or $this->Parent if the method doesn't.

    So, to do what you want, use:

    $this->Parent()->ClassName

  • micahsheets
    avatar
    Community Member
    106 posts

    Re: How do I get the Page Type of the Parent. Link to this post

    Thank you for your answer. I am still trying to get a handle on PHP classes and how inheritance works. I assume that $this is a reference to the current page being displayed. However it seems that if I get the value of $this in the page, it is different than if I get the value in the page_controller. In the case of

    $this->Parent()->ClassName

    ,

    do I call it in the page or controller and why?

    562 Views
Page: 1
Go to Top

Currently Online: JoshuaLewis, NickJacobs

Welcome to our latest member: marcusl

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.