View more context

 

Neil Creagh

Thanks for that. Although having to add another separate Site Settings area seems a little off - wouldn’t moving those Access controls into Security be better? What do you think? I’ll add it an issue on Github and see what people think if you agree (or am I missing something here)

andante

i think those base-level controls are intended to be handled by admins - which is what the site-settings area is for - rather than people that might handle only users, which the security section can do. i think it probably makes sense to have an “admins-only” section of the Security ModelAdmin where those are handled

Joe

I've got a page with children, I want to display an element if a condition is true of any of the children. I cant figure out the best way to do this in the template. For example: <% loop $Children %><% if $SalePrice %> THERE ARE ITEMS IN THE SALE<% end_if %><% end_loop %> How can I make it so that the message only appears once, rather than for every time the if is true for every page?

Joe

I’d probably have a separate controller method that:

• gets children • filters for any children with your condition true • checks ->count() to make sure you have children with that condition • returns a boolean indicating children with your condition

so you’d end up with something like:

  1. <% if $showSalePrice %>
  2. THERE ARE ITEMS IN THE SALE
  3. <% end_if %>
  4. <% loop $Children %>
  5. ...
  6. <% end_loop %>
😁 (1)
Joe
  1. public function showSalePrice() {
  2. $children = $this->Children()
  3. // dummy filter since I don't know your actual logic
  4. ->filter('SalePrice', true);
  5.  
  6. return $children->count() > 0;
  7. }
markcl

kind of like php artisan tinker for Laravel?