I'm trying to add a search form in my jobs view. It's supposed to be a list of all the available jobs along with a search form that filters out the result. The searh form consists out of checkboxes that will need to be prepopulated with the database data.
So I have a number of questions.
Since "JModelList" in combination with getListQuery(). I tried a couple JForm etc and the inherited classes but then I get the following error: "Warning: Invalid argument supplied for foreach() in C:\\Users\\Nick\\Documents\\Dropbox\\yourstudent\\Development\\Live\\components\\com_jobs\\views\\jobs\\tmpl\\default.php on line 18"
I'm not having any troubles with creating a form, there are a couple of good examples for the crud operations needed on objects. But not when you either a) combine the list view with the form or b) need the form to act like a search form prepopulated with data.
I'm stuck at combining those 2 views essentially, I can't even test if my form fields etc are correct. Below is a snippet of the model jobs. Do you guys need any other code for helping me out here?
(This is my first question here, so bear with me and I'll try to adjust my question if needed.)
Code Snippet :
<?php
/* ------------------------------------------------------------------------
# jobs.php - jobs Component
# ------------------------------------------------------------------------
# author Breens Nick
# copyright Copyright (C) 2013. All Rights Reserved
# license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
# website www.nick.breens.be
------------------------------------------------------------------------- */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the Joomla modellist library
jimport('joomla.application.component.modellist');
/**
* Jobs Model
*/
class JobsModeljobs extends JModelList {
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery() {
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('*');
$query->from('#__yourstudent_jobs');
return $query;
}
}
?>
Thanks to a forum post on the Joomla Coding 3.0 subforum I got the answer.
Someone replied telling me that I should use filters in my case and base my component on the articles. I then searched for a good tutorial and then found this 2.5 based tutorial which still applies for 3.0
If anybody is interested I'll post my code below. (The model code remains the same.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.