Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [solved] Page.php: same code renders differently, when renamed

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

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 968 Views
  • silberfischer
    Avatar
    Community Member
    6 Posts

    [solved] Page.php: same code renders differently, when renamed Link to this post

    fresh Silverstripe install:

    * I copy the /tutorial/codePage.php to /mysite/code/HWPage.php
    * edit the file to have HWPage and HWPage_Controller instead of Page etc.
    * I copy /tutorial/templates/Page.ss to /mysite/templates/HWPage.php
    * flush, rebuild, flush

    * i log into the CMS
    * create a new page of type Page
    * type "Hello World" in the content-field; name of page is Helloworld1; save & publish
    * create a new page of type HWPage
    * type "Hello World" in the content-field; name of page is Helloworld2; save & publish

    * i go to the site and see links to both pages in the menu (top level, both)

    from what i did i expect both pages to be rendered identically

    Helloworld1 (type: Page) looks like expected: default menu on it, default theme etc.
    Helloworld2 (type: HWPage) has no menu on it, the layout is distorted (margins in top, middle and bottom do not align) and only roughly resembles the theme

    since i copied the code of Page[.php .ss] to HWPage, I expected it to look alike.

    I also tried to inherit HWPage from Page, instead of from SiteTree; no difference.
    I did try it on two different installs/machines; result is the same.

    I attached an img which displays the two pages as rendered.

    Am I not getting part of the concept? What is going wrong here?
    Any help welcome...

    Chris

    Attached Files
  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: [solved] Page.php: same code renders differently, when renamed Link to this post

    HWPage should extend from Page. and HWPage_Controller from Page_Controller.

    All your template stuff (ss files, css, images) should go in the theme. (eg themes/yourcustomtheme/). It looks like from that screenshot you are running BlackCandy and not the tutorial theme at all so if you want to copy code / templates you should be doing it from mysite/code/ and template files from themes/blackcandy/ as the mixing the tutorial templates with the blackcandy css could have odd results.

  • silberfischer
    Avatar
    Community Member
    6 Posts

    Re: [solved] Page.php: same code renders differently, when renamed Link to this post

    Ok, I get the point.
    I *do* find a Page.php in mysite/code/, yet I don't find a Page.ss in mysite/templates/.
    Where do I get the default Page template from, if not from tutorial/templates/?

  • Phill
    Avatar
    Community Member
    75 Posts

    Re: [solved] Page.php: same code renders differently, when renamed Link to this post

    Hey the .ss files should be located in

    /themes/blackcandy/templates/

  • silberfischer
    Avatar
    Community Member
    6 Posts

    Re: [solved] Page.php: same code renders differently, when renamed Link to this post

    Booyah!

    Now *that* looks different
    Thanks! And it was definitely a missing piece.

    Best regards,
    Chris

    968 Views
Page: 1
Go to Top

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

Comments on this website? Please give feedback.