Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Showing GridField Content on other Pages (like LatestArticles)

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 751 Views
  • mimamo
    Avatar
    Community Member
    22 Posts

    Showing GridField Content on other Pages (like LatestArticles) Link to this post

    Hi Everyone,

    i'm trying to show the Content of a GridField on my HomePage PageType on all other Pages with a different PageType.
    A little bit like the LatestArticles on HomePage.
    I tried to do it like this.

    Page.php -> http://pastie.org/6036705
    SliderObject.php -> http://pastie.org/6036716
    HomePage.php -> http://pastie.org/6036721
    Slider.ss -> http://pastie.org/6036729

    The "getPageByClass" function worked fine for me on the Old SS Release and although when I want to display content form not gridfields on other pages in SS3.

    But now when i put in <% control getPageByClass(HomePage) %> the sldier displays nothing not on HomePage and not on any other Page.

    I althoug tried to put the getSlides function into Page.php but it doesn't work too, i think because the function can't find Slides on Page.php but how can i Link this function on the Page.php to Slides on HomePage.php

    Can someone please help me?

    Thx a lot!

    -hobenni

  • mimamo
    Avatar
    Community Member
    22 Posts

    Re: Showing GridField Content on other Pages (like LatestArticles) Link to this post

    push ;)
    i need it very urgent.

  • mi3ll
    Avatar
    Community Member
    23 Posts

    Re: Showing GridField Content on other Pages (like LatestArticles) Link to this post

    DataObject::get_one($class) instead of DataObject::get($class) in your Page.php method should fix it.

    I think DataObject::get always returns a DataList in SS3 even when there is only one matching, unlike previously.

  • mimamo
    Avatar
    Community Member
    22 Posts

    Re: Showing GridField Content on other Pages (like LatestArticles) Link to this post

    Hi,
    thank you very much for your answer. But it doesn't work :/
    Is there an other methode to get the content shown on other pages? Or is there a way to get the function working?

    EDIT:

    Ok i fixed it
    The First Mistake was the DataObject::get instead of DataObject::get_one (Thx a lot for that)
    And the second Mistake was that i tried to get the content with a function and not simply with <% loop Slides %>

    now everything works

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