It looks like you're new here. If you want to get involved, click one of these buttons!
recent_project table
project_id details published slug
recent_project_images table
id project_id (which is a fk to recent_project.project_id) image
class RecentProjects_model extends Base_module_model {
function __construct()
{
parent::__construct('recent_project');
}
// method used to list the data in the admin panel
function list_items($limit = NULL, $offset = NULL, $col = 'project_id', $order = 'asc')
{
// the data to list
$this->db->select('recent_project.project_id, recent_project_images.id, recent_project.details, recent_project_images.image, recent_project.slug, recent_project.published', FALSE);
$this->db->join('recent_project_images', 'recent_project_images.project_id = recent_project.project_id');
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}
// used to return form information to the form builder class to render the create/edit screens in the admin panel
function form_fields($values = array())
{
$fields = parent::form_fields($values);
// to limit the image folder to just the projects folder for selection
$fields['image']['class'] = 'asset_select images/recentProjectImages';
$upload_path = assets_server_path('recentProjectImages', 'images');
$fields['image_upload'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE, 'required' => TRUE);
// fix the preview by adding galleryImages in front of the image path since we are saving it in a subfolder
if (!empty($values['image']))
{
$fields['image_upload']['before_html'] = '<div class="img_display"><img src="'.img_path('recentProjectImages/thumbs/'.$values['image']).'_thumb'.'" style="float: right;"/></div>';
}
//$fields['published']['order'] = 1000;
return $fields;
}
Error Number: 1054
Unknown column 'id' in 'field list'
SELECT id, details FROM (recent_project) ORDER BY `details` asc
Filename: core/MY_Model.php
Line Number: 646
Comments
With regards to the multiple images, try adding the class "multifile" to the $fields['image_upload'] field which should allow you to upload more then one file at a time. You may want to upload the files into there own specific project folder to help with organization. You can accomplish that by adding a "folder" field to your model and then in your 'upload_path' value you can use the {folder} placeholder which will substitute in the value:
$upload_path = assets_server_path('recentProjectImages/{folder}/', 'images');
Then, I would create an additional module for the recent_project_images table (you can set it as "hidden" in it's configuration so it won't appear in the navigation). You can then manipulate the the form_fields() method to display the selected images by scanning the recentProjectImages/{folder}/ folder to pull the image names and then display them by using the 'before_html' attribute. You can display it as a linked image that when clicked will take you to the recent_project_images module to edit.