Basic Question: Projects Module

edited April 2014 in Modules
Hi,

I am a beginner and have just installed the projects module as shown in the demo website. I have fuel 1.0 installed and am able to view a list of projects but when I click on 'view more' a 'page not found' shows. I am sure the url is correct and the project has been created. Has anyone had this issue with 1.0? I have posted my code from projects_model.php if that helps.

Any help much appreciated.

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Projects_model extends Base_module_model { public $filters = array('name'); public $required = array('name'); public $linked_fields = array('slug' => array('name' => 'url_title'), 'client' => array('name' => 'strtoupper')); //public $linked_fields = array('slug' => 'name', 'client' => 'name'); function __construct() { parent::__construct('projects'); // table name } function list_items($limit = null, $offset = null, $col = 'precedence', $order = 'desc') { $this->db->select('id, name, client, precedence, published', FALSE); $data = parent::list_items($limit, $offset, $col, $order); return $data; } 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/projects'; //$fields['description']['class'] = 'wysiwyg'; // put all project images into a projects subfolder $fields['image_upload']['upload_path'] = assets_server_path('projects', 'images'); // fix the preview by adding projects 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('projects/'.$values['image']).'" style="float: right;"/></div>'; } return $fields; } function on_after_post($values) { $CI =& get_instance(); $CI->load->library('image_lib'); // create the thumbnail if an image is uploaded if (!empty($CI->upload)) { $data = $CI->upload->data(); if (!empty($data['full_path'])) { $thumb_img = assets_server_path('projects/'.$this->thumb_name($data['file_name']), 'images'); // resize to proper dimensions $config = array(); $config['source_image'] = $data['full_path']; $config['create_thumb'] = FALSE; //$config['new_image'] = $thumb_img; $config['width'] = 240; $config['height'] = 140; $config['master_dim'] = 'auto'; $config['maintain_ratio'] = TRUE; $CI->image_lib->clear(); $CI->image_lib->initialize($config); if (!$CI->image_lib->resize()) { $this->add_error($CI->image_lib->display_errors()); } // create thumb $config = array(); $config['source_image'] = $data['full_path']; $config['create_thumb'] = FALSE; $config['new_image'] = $thumb_img; $config['width'] = 100; $config['height'] = 80; $config['master_dim'] = 'auto'; $config['maintain_ratio'] = TRUE; $CI->image_lib->clear(); $CI->image_lib->initialize($config); if (!$CI->image_lib->resize()) { $this->add_error($CI->image_lib->display_errors()); } } } return $values; } // delete the images as well function on_before_delete($where) { $id = $this->_determine_key_field_value($where); $data = $this->find_by_key($id); $files[] = assets_server_path('projects/'.$data->image, 'images'); $files[] = assets_server_path('projects/'.$this->thumb_name($data->image), 'images'); foreach($files as $file) { if (file_exists($file)) { @unlink($file); } } } function thumb_name($image) { return preg_replace('#(.+)(\.jpg|\.png)#U', '$1_thumb$2', $image); } } class Project_model extends Base_module_record { function get_url() { return site_url('showcase/project/'.$this->slug); } function get_image_path() { return img_path('projects/'.$this->image); } function get_thumb() { $thumb = $this->_parent_model->thumb_name($this->image); return img_path('projects/'.$thumb); } } ?>

Comments

  • edited April 2014
    What page are you trying to access?
    Are you trying to access the admin view of the module to add entries to the table?
  • edited 9:47AM
    Did you specify a "preview_path" for you module of 'showcase/project/'.$this->slug? And if so, is there a view file setup under fuel/application/views/showcase/project.php? If so, be sure to do ONE of the following:

    1. Add the following to your MY_fuel.php:
    $config['max_page_params'] = array('showcase/project' => 1);
    2. Or, add the following to your MY_fuel.php:
    $config['auto_search_views'] = TRUE;
    3. Or, create a variables filed called showcase (views/_varariables/showcase) and add the following:
    $pages['showcase/project/:any'] = array('view' => showcase/project');
    This ensures that it is looking for the proper view file.
  • edited April 2014
    Hi,

    Thanks for the quick response.

    I have:

    $config['modules']['projects'] = array('preview_path' => 'showcase/project/{slug}','sanitize_images' => FALSE in My_fuel_module.php and $config['auto_search_views'] = TRUE; enabled in MY_fuel.php

    Is that correct?
  • edited 9:47AM
    @kbjohnson90 I am trying to access the individual project view file. Admin side works fine - although if i click view project in the admin screen it takes me to a 'page not found'. Thanks
  • edited April 2014
    Update:

    The single project page is now working correctly.

    Only the header image is now not loading. The path is now retrieving from

    http://localhost:8888/showcase/assets/images/image.png

    rather than:

    http://localhost:8888/assets/images/image.png

    any ideas?
  • edited 9:47AM
    Are you using the img_path() function?
  • edited April 2014
    To load the image in the header I am using:

    <div class="logo"><img src="../assets/images/wycf_logo.png" </div>

    It works fine on other pages.
  • edited 9:47AM
    try using the img_path() function in one of the following methods depending on if the image code is in a field in the CMS or if it is in a static view file:

    View Code
    <div class="logo"><img src="<?=img_path('wycf_logo.png')?>"></div>

    Template Code Use for CMS:
    <div class="logo"><img src="{img_path('wycf_logo.png')}"></div>
  • edited 9:47AM
    This fixed it:

    <div class="logo"><img src="<?=img_path('wycf_logo.png')?>"></div>

    Thanks for your help.
Sign In or Register to comment.