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:

8498 Posts in 2212 Topics by 1195 members

General Questions

SilverStripe Forums » General Questions » 1 page with 2+ page types

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Page: 1
Go to End
Author Topic: 1 page with 2+ page types 485 Views
  • raamklaza
    avatar
    Community Member
    181 posts

    1 page with 2+ page types Link to this post

    Hello,

    how can i make more then one page type on one page?

    For example we have a normal Page page type.

    I would love to put a custom Form page type under the above mentioned Page page type.

    What's the easiest way to do this?

  • CrazyCoders
    avatar
    Community Member
    32 posts

    Re: 1 page with 2+ page types Link to this post

    Page types are intimately linked to the template. You can only have 1 template/page type per page. That said, you can do all kinds of tweaks to get to a solution.

    You could extend your page type to another page type such as CustomFormPage extends Page and put the code in there that creates the custom form. Then just copy and paste the page template to create the new associated template and then rebuild. That should do it.

    Was that too complex?

  • Sam
    avatar
    Administrator
    649 posts

    Re: 1 page with 2+ page types Link to this post

    Yes, page types are designed to inherit from each other.

    If you have CustomFormPage extends Page, it will first look for CustomFormPage.ss and then use Page.ss if that's not found.

    Combined with the Layout subfolder functionality, this can be quite powerful. If you have these 3 templates:

    templates/Page.ss - contains the template variable '$Layout' in it somewhere
    templates/Layout/Page.ss
    templates/Layout/CustomFormPage.ss

    Then the logic is this:

    * On a Page page, the page will be rendered using templates/Layout/Page.ss, and then that will be placed inside templates/Page.ss where the $Layout code is.
    * On a CustomFormPage page, the page will be rendered using templates/Layout/CustomFormPage.ss, and then that will be placed inside templates/Page.ss where the $Layout code is.

    In other words, you can have your "common skin" stuff in templates/Page.ss, and then have a region inside that that is customised on a per-pagetype basis.

    I hope that makes sense; it's a little tricky to describe!

  • raamklaza
    avatar
    Community Member
    181 posts

    Re: 1 page with 2+ page types Link to this post

    Thnx Sam.

    If i make CustomFormpage page it will use the Page.ss aswell or only when CustomFormpage isn't found?

    Is there a way to include exsisting Page templates?

    For example
    I make a formpage page and on top i include:page.ss

  • CDGIDev
    avatar
    Community Member
    9 posts

    Re: 1 page with 2+ page types Link to this post

    No it's only like this:

    Page extends SiteTree
    CustomFormPage extends Page

    For the templates:

    If CustomFormPage.ss then use it
    elseif Page.ss then use it

    Thats all

  • sicp
    avatar
    Community Member
    75 posts

    Re: 1 page with 2+ page types Link to this post

    Great, someone has asked this question already

    I'm trying to do this for UserDefinedForm, so ... Should I see templates/layout/UserDefinedForm.ss displayed from $Layout in templates/Page.ss ?

    The reason is: I'm not seeing this happen right now, UserDefinedForm extends Page so it should work right? Or would it be better to have CustomForm extends UserDefinedForm and expect templates/Pages.ss + templates/layout/CustomForm.ss to work?

    This is all because CalendarDateField.php adds Requirements::css which is overriding my theme's form.css GRRR and was hoping that <% require themedCSS(form) %> will work in there, but probably not.

    Cheers,

    Rich

    485 Views
Page: 1
Go to Top

Currently Online: mandrew, oldwrinkly

Welcome to our latest member: U

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

Comments on this website? Please give feedback.