Source of file RenderablePortletsController.php
Size: 1,514 Bytes - Last Modified: 2021-12-23T10:59:01+00:00
/var/www/docs.ssmods.com/process/src/code/RenderablePortletsController.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | <?php namespace WebOfTalent\Portlets; use SilverStripe\ORM\DataList; use SilverStripe\View\ArrayData; use SilverStripe\Core\Extension; class RenderablePortletsController extends Extension { /* Render a portlet from a template call of the form <code> $RenderPortlet(NewsItem|Title|4|Carousel) </code> As Silverstripe can only deal with a single parameter string with no spaces, split the params by a pipe character. These parameters are as follows: * @param model The DataObject class that we wish to show * @param where The filter to use (i.e. the where clause, leave blank to ignore) * @param ordering The order (descending) to show items (normally the home page is for the most recent things) * @param amount The number of items maximum to show * @param template The template used to show it FIXME: Use a join to make image extraction more efficient */ public function RenderPortlet( $model, $where, $ordering, $amount, $template, $joinTable = '', $joinOn = '' ) { $result = null; $records = DataList::create($model)->where($where)->sort($ordering)->limit($amount); if ($joinTable) { $records->leftJoin($joinTable, $joinOn); } return $this->owner->customise( new ArrayData( array( 'Records' => $records, ) ) )->renderWith($template); } } |