2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-sitetree-inheritance-helpers

A SilverStripe module that adds some helper methods to your site tree to aid with inherited values and relations

image

andrewhaine/silverstripe-sitetree-inheritance-helpers

A SilverStripe module that adds some helper methods to your site tree to aid with inherited values and relations

  • Monday, April 23, 2018
  • by andrewhaine
  • Repository
  • 2 Watchers
  • 1 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 188 % Grown

The README.md

SilverStripe SiteTree Inheritance Helpers

A module which adds some additional methods to SiteTree to make it easier to search "up" the page tree for values or relations to inherit. Please note this module is only compatible with SilverStripe 4.1+., (*1)

The problem

Are you tired of writing methods or template loops to retrieve database values or relations from parent pages? Well this is just the module for you!, (*2)

Introducing the helper methods

Currently this module adds two methods to help with inherited values. These can be used within your Page's php class or from within a template file., (*3)

Getting database field values

If you just need a database value you can use getInheritedDBValue, (*4)

Examples

CustomPage.php, (*5)

public function getMyDataBaseValue()
{
    return $this->getInheritedDBValue('FieldName');
}

CustomPage.ss, (*6)

<span>{$getInheritedDBValue('FieldName')}</span>

Getting relation values

If you need to get a relation from a parent page, for example a $has_one or a $many_many you can use getInheritedRelationValue. This method has an additional parameter which will need to be set to true when the relation is a list., (*7)

Examples

CustomPage.php, (*8)

public function getMyInheritedList()
{
    return $this->getInheritedRelationValue('SomeList', true);
}

CustomPage.ss, (*9)

<% loop $getInheritedRelationValue('SomeList', true) %>
    \\\
<% end_loop %>

Issues & Contributing

This was made quite quickly, any issue reports or enhancements are welcome :) - See you in the issues section, (*10)

The Versions

23/04 2018

dev-master

9999999-dev https://github.com/AndrewHaine/silverstripe-sitetree-inheritance-helpers

A SilverStripe module that adds some helper methods to your site tree to aid with inherited values and relations

  Sources   Download

BSD-3-Clause

The Requires

 

silverstripe methods inheritance sitetree