SSbits - Home page
Site by Carbon Crayon
Submit a Post >
  • SnippetsGetting objects from multiple child pages

    1

    When you want to create a DataObjectSet encompasing objects from all the current pages children you can do something like this

    $pageIDs = $this->getDescendantIDList();
    $ObjectSet = DataObject::get(
                     "Object", 
                     "`ObjectPageID` IN (" . implode(",", $pageIDs) . ")"
                      );
    Continue reading...
  • TutorialsSorting on a related DataObject in ModelAdmin

    1

    Sometimes, in ModelAdmin, we want to be able to have a different default sort.

    Specifically, like in cases where a has_one is the preferred sorting. For example, we have a warehouse. In our DataObjects, we have the object "Lanes", has_many Products. And we have Products, has_one "Lanes". When we're browsing our Products in the admin, we want to have them default sorted by their Lane, not their name.

    Just saying default_sort = 'Lanes'; sadly does not do the job. It'll give you reddish-screens and stuff. Which is not what we like.

    Here's a (quite simple actually) solution.

    Continue reading...
  • SnippetsDisplaying Fields From a Set of Pages on Another Page

    0

    Although ultimately requiring very little code, displaying data from a set of pages on another page can seem confusing for those new to SilverStripe. This example will display all of the Images from all the staff pages on our current page. This works by first returning all the staff pages to our template and cycling through each of them, drawing the Image for each one.

    Continue reading...

Advertisement

Site of the Month

Find SSbits on

Top Contributers

Rank Avatar Name
1 article image Aram Balakjian
2 article image Daniel Hensby
3 article image Marcus Dalgren
4 article image Hamish Campbell
5 article image Ty Barho
6 article image Martijn van Nieuwenhoven
7 article image Darren-Lee
8 article image Roman Schmid
9 article image Matt Clegg
10 article image dalesaurus

View full leaderboard


Advertisement