Skip to content

Commit

Permalink
Added getLayout to pagination class, so can put overrides in list tem…
Browse files Browse the repository at this point in the history
…plates, views/list/tmpl/whatever/layouts/pagination
  • Loading branch information
cheesegrits committed Feb 17, 2017
1 parent 9d1ac5d commit 17bd932
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions components/com_fabrik/helpers/pagination.php
Expand Up @@ -103,11 +103,12 @@ public function getListFooter($listRef = '', $tmpl = 'default')
{
$app = JFactory::getApplication();
$this->listRef = $listRef;
$this->tmpl = $tmpl;
$list = array();
$list['limit'] = $this->limit;
$list['limitstart'] = $this->limitstart;
$list['total'] = $this->total;
$list['limitfield'] = $this->showDisplayNum ? $this->getLimitBox() : '';
$list['limitfield'] = $this->showDisplayNum ? $this->getLimitBox($tmpl) : '';
$list['pagescounter'] = $this->getPagesCounter();

if ($this->showTotal)
Expand All @@ -134,9 +135,11 @@ public function getListFooter($listRef = '', $tmpl = 'default')
/**
* Creates a dropdown box for selecting how many records to show per page
*
* @param string $tmpl List template
*
* @return string The html for the limit # input box
*/
public function getLimitBox()
public function getLimitBox($tmpl = 'default')
{
$paths = array();
$displayData = new stdClass;
Expand All @@ -146,9 +149,7 @@ public function getLimitBox()
$displayData->viewAll = $this->viewAll;
$displayData->limit = $this->limit;

$paths[] = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/com_fabrik/list_' . $this->id;

$layout = FabrikHelperHTML::getLayout('pagination.fabrik-pagination-limitbox', $paths);
$layout = $this->getLayout('pagination.fabrik-pagination-limitbox');

return $layout->render($displayData);
}
Expand All @@ -164,9 +165,7 @@ protected function _item_active(JPaginationObject $item)
{
$displayData = new stdClass;
$displayData->item = $item;
$paths[] = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/com_fabrik/list_' . $this->id;

$layout = FabrikHelperHTML::getLayout('pagination.fabrik-pagination-item-active', $paths);
$layout = $this->getLayout('pagination.fabrik-pagination-item-active');

return $layout->render($displayData);
}
Expand All @@ -184,9 +183,7 @@ protected function _item_inactive(JPaginationObject $item)
{
$displayData = new stdClass;
$displayData->item = $item;
$paths[] = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/com_fabrik/list_' . $this->id;

$layout = FabrikHelperHTML::getLayout('pagination.fabrik-pagination-item-inactive', $paths);
$layout = $this->getLayout('pagination.fabrik-pagination-item-inactive');

return $layout->render($displayData);
}
Expand Down Expand Up @@ -323,9 +320,7 @@ protected function _list_render($list)
{
$displayData = new stdClass;
$displayData->list = $list;
$paths[] = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/com_fabrik/list_' . $this->id;

$layout = FabrikHelperHTML::getLayout('pagination.fabrik-pagination-links', $paths);
$layout = $this->getLayout('pagination.fabrik-pagination-links');

return $layout->render($displayData);
}
Expand Down Expand Up @@ -446,9 +441,7 @@ protected function _list_footer($list)
$displayData->showTotal = $this->showTotal;
$displayData->limit = $this->limit;

$paths[] = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/com_fabrik/list_' . $this->id;

$layout = FabrikHelperHTML::getLayout('pagination.fabrik-pagination-footer', $paths);
$layout = $this->getLayout('pagination.fabrik-pagination-footer');

return $layout->render($displayData);
}
Expand Down Expand Up @@ -494,4 +487,21 @@ public function get($property, $default = null)
return $default;
}
}

/**
* Get a pagination JLayout file
*
* @param string $type form/details/list
* @param array $paths Optional paths to add as includes
*
* @return FabrikLayoutFile
*/
public function getLayout($name, $paths = array(), $options = array())
{
$paths[] = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/com_fabrik/list_' . $this->id;
$paths[] = COM_FABRIK_FRONTEND . '/views/list/tmpl/' . $this->tmpl . '/layouts';
$layout = FabrikHelperHTML::getLayout($name, $paths, $options);

return $layout;
}
}

0 comments on commit 17bd932

Please sign in to comment.