I'm fairly new to Joomla and I'm developing my first component. I finished up the backend and I'm working on the frontend. I have most of the functionality figured out but I can't figure out how to get the Page heading to display from the Menu item params.
I looked all around but I can't get mine to display. I've looked at the Article component for guidance but it doesn't work.
I copied this directly from the Article component, but after debugging I noticed that params
is null:
<?php if ($this->params->get('show_page_heading',1)) : ?>
<h1><?php echo $this->params->get('page_heading') ? $this->params->get('page_heading') : JFactory::getApplication()->getMenu()->getActive()->title; ?></h1>
<?php endif; ?>
So then I figured I must add some code to the view.html.php
file. So I made some modifications to my display method to match what the Article component has. This time I get the following error message that points to when I'm trying to assign params
to $this
:
Fatal error: Call to a member function get() on null
I'm thinking maybe it's because I'm working on a list view and the Article code is for a single item view.
Any help would be appreciated.
Here's the code I have in my view.html.php file:
class LibraryViewItems extends JViewLegacy {
protected $items;
protected $params;
protected $state;
public function display($tpl = null) {
$this->items = $this->get('Items');
$state = $this->get('State');
$this->params = $this->state->get('params');
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
parent::display($tpl);
}
}