Today I made my first Joomla component following their tutorial. Everything in my component was working as intended until I decided to add a second view to my component. I added a new folder in the /views/
directory of my component and added all the necessary files : view.html.php, index.html, tmpl/default.xml, tmpl/default.php, tmpl/index.html
.
Here is my view.html.php
class VacanciesViewSingle extends JViewLegacy
{
var $vacancy = null;
function display($tpl = null)
{
$this->vacancy = $this->get('Vacancy');
// // Check for errors.
if (count($errors = $this->get('Errors')))
{
JLog::add(implode('<br />', $errors), JLog::WARNING, 'jerror');
return false;
}
parent::display($tpl);
}
}
As long as I understood how components in Joomla work this should call the getVacancy()
method from my model class.
Inside my model class I have only 2 functions:
getVacancies()
which works perfectly with my other view and getVacancy()
which for debugging purposes return just a number:
public function getVacancy()
{
return "10";
}
So I'm expecting my view to output "10". This is my `tmpl/default.php' file:
defined('_JEXEC') or die('Restricted access');
?>
<?php echo $this->vacancy;?>
PS. Opening /index.php?option=com_vacancies&view=single
doesn't return any errors, just my page with blank space where the component output should be...
PS2. If I change $this->vacancy = $this->get('Vacancy');
to $this->vacancy = "10"
in my view class I get the expected output of '10' so I suppose getVacancy()
is not called for some reason.