Joe

it worked ok in SS3 using Translatable since it was easy to then get that page’s translations from each other

Joe

I haven’t used Fluent yet on a site, though, so I don’t know how that might come into play for that solution

Joe

i’ve solved this before by allowing the user to select which page is the Contact Us in the siteconfig

Joe

if you’re talking about a ton of pagetypes, then sure, having one function that can spit out the first page of any type might be useful

but for only 2 pagetypes, I think the probably-a-bit-more-verbose approach makes the code a little easier to read and a bit more maintainable

Joe

I usually will do utility functions (especially because we’re only talking 2 page types - Home and contact)

so I’d have in my project:

  1. public function getHomePage() {
  2. return HomePage::get()
  3. ->first();
  4. }
  5.  
  6. public function getContactUsPage() {
  7. return ContactPage::get()
  8. ->first();
  9. }

which means the template stays nice and clean and easy to read:

  1. <% if $HomePage %>
  2. <a href="{$HomePage.Link}">{$HomePage.MenuTitle.XML}</a>
  3. <% end_if %>
  4. <% if $ContactUsPage %>
  5. <a href="{$ContactUsPage.Link}">{$ContactUsPage.MenuTitle.XML}</a>
  6. <% end_if %>

but, ultimately probably just a matter of preference

Joe

those pages don’t use a specific page type?

Joe

ah - yeah, because you’re probably only selecting a single column

I didn’t see a method to turn a multi-column result set into an array, though

Joe

honestly, I’d probably try to replace the SQLSelect with an ORM query, because it’s super easy to end up with an array of IDs using the ORM

Joe

^ yep, was just gonna say that

it doesn’t appear that there’s any quick method for turning that result set into an array though

Joe

the github releases page will tell you the dates of release - https://github.com/silverstripe/silverstripe-framework/releases

Show 1 attachment(s)
GitHub  
silverstripe/silverstripe-framework

SilverStripe Framework, the MVC framework that powers SilverStripe CMS - silverstripe/silverstripe-framework

Hide attachment content