Skip to content

Commit

Permalink
make common layouts overridable (issue jemproject#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoffi1 committed Apr 2, 2014
1 parent da6315d commit b3c2752
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 14 deletions.
9 changes: 9 additions & 0 deletions site/classes/view.class.php
Expand Up @@ -34,6 +34,15 @@ public function getRows($rowname = "rows")
return $this->$rowname;
}

/**
* Add path for common templates.
*/
protected function addCommonTemplatePath() {
// additional path for list part + corresponding override path
$this->addTemplatePath(JPATH_COMPONENT.'/common/views/tmpl');
$this->addTemplatePath(JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/com_jem/common');
}

/**
* Prepares the document.
*/
Expand Down
9 changes: 7 additions & 2 deletions site/views/category/view.html.php
Expand Up @@ -15,6 +15,13 @@
*/
class JemViewCategory extends JEMView
{
function __construct($config = array()) {
parent::__construct($config);

// additional path for common templates + corresponding override path
$this->addCommonTemplatePath();
}

/**
* Creates the Category View
*/
Expand Down Expand Up @@ -108,8 +115,6 @@ function display($tpl=null)

} else {

$this->addTemplatePath(JPATH_COMPONENT.'/common/views/tmpl');

//initialize variables
$app = JFactory::getApplication();
$document = JFactory::getDocument();
Expand Down
7 changes: 7 additions & 0 deletions site/views/day/view.html.php
Expand Up @@ -16,6 +16,13 @@
*/
class JemViewDay extends JEMView
{
function __construct($config = array()) {
parent::__construct($config);

// additional path for common templates + corresponding override path
$this->addCommonTemplatePath();
}

/**
* Creates the Day View
*/
Expand Down
20 changes: 13 additions & 7 deletions site/views/event/view.html.php
Expand Up @@ -8,24 +8,31 @@
*/
defined('_JEXEC') or die;

require JPATH_COMPONENT_SITE.'/classes/view.class.php';

/**
* Event-View
*/
class JemViewEvent extends JViewLegacy
class JemViewEvent extends JEMView
{
protected $item;
protected $params;
protected $print;
protected $state;
protected $user;

function __construct($config = array()) {
parent::__construct($config);

// additional path for common templates + corresponding override path
$this->addCommonTemplatePath();
}

/**
* Creates the output for the Event view
*/
function display($tpl = null)
{
$this->addTemplatePath(JPATH_COMPONENT.'/common/views/tmpl');

$jemsettings = JemHelper::config();
$settings = JemHelper::globalattribs();
$app = JFactory::getApplication();
Expand Down Expand Up @@ -64,8 +71,8 @@ function display($tpl = null)

// Decide which parameters should take priority
$useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem'
&& $menuitem->query['view'] == 'event'
&& $menuitem->query['id'] == $item->id);
&& $menuitem->query['view'] == 'event'
&& $menuitem->query['id'] == $item->id);

// Add router helpers.
$item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id;
Expand Down Expand Up @@ -146,7 +153,6 @@ function display($tpl = null)

// Increment the hit counter of the event.
if (!$this->params->get('intro_only') && $offset == 0) {
$model = $this->getModel();
$model->hit();
}

Expand Down Expand Up @@ -270,7 +276,7 @@ function display($tpl = null)
$this->_prepareDocument();

parent::display($tpl);
}
}

/**
* structures the keywords
Expand Down
9 changes: 7 additions & 2 deletions site/views/eventslist/view.html.php
Expand Up @@ -15,13 +15,18 @@
*/
class JemViewEventslist extends JEMView
{
function __construct($config = array()) {
parent::__construct($config);

// additional path for common templates + corresponding override path
$this->addCommonTemplatePath();
}

/**
* Creates the Simple List View
*/
function display( $tpl = null )
{
$this->addTemplatePath(JPATH_COMPONENT.'/common/views/tmpl');

// initialize variables
$document = JFactory::getDocument();
$app = JFactory::getApplication();
Expand Down
10 changes: 7 additions & 3 deletions site/views/venue/view.html.php
Expand Up @@ -15,6 +15,13 @@
*/
class JemViewVenue extends JEMView {

function __construct($config = array()) {
parent::__construct($config);

// additional path for common templates + corresponding override path
$this->addCommonTemplatePath();
}

/**
* Creates the Venue View
*/
Expand Down Expand Up @@ -108,9 +115,6 @@ function display($tpl = null) {

} else {

// add templatepath
$this->addTemplatePath(JPATH_COMPONENT.'/common/views/tmpl' );

// initialize variables
$app = JFactory::getApplication();
$document = JFactory::getDocument();
Expand Down

0 comments on commit b3c2752

Please sign in to comment.