Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Content from superclass

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

Page: 1
Go to End
Author Topic: 508 Views
  • me.yay
    Avatar
    Community Member
    14 Posts

    Content from superclass Link to this post

    Hi SilverStripers,

    guess i need to describe my site-structur first to make things clear:

    control: i have 3 classes called packageA, packageB, packageC which sublass von Package. Package subclasses Page.

    view: PackagePage.ss has the template element $Content while packageAPage.ss is in layout folder and just inherits from PackagePage making some style changes without using template vars.

    In the backend i create one content page for every package (A,B,C) which should be used as content for other pages.

    Now i have 6 items which should use packageA, packageB, packageC but need to have different meta-data/different url and different headlines and prices.This makes a total of 18 pages. The different headlines/prices are shown by images inside the template using $URLSegment.

    I made a class ItemA which sublusses from PackageA (same for B/C) to re-use it's template code.

    ItemAPage_Controller has this method:

       public function PackageAPage(){
        return DataObject::get_one('PackageAPage');
       }

    PackagePage.ss uses this template:

    $PackageAPage.Content

    Instead of the content for PackageA i get the content of itemA. How can i get the content of PackageA instead?

    <EDIT> when i use return DatObject::get_one('Page') i am able to see it's content using the template code from above... This seems like an inherit problem.</EDIT>

    <EDIT>ItemA/B/C inherit now from Page. ItemA.SS has now full template of PackageA.SS with minor changes ($ItemA.Content instead of $Content)</EDIT>

    But i am still wondering about what caused my problem...

    kind Regards
    Metin

    508 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.