goFrendiAsgard / No-CMS

No-CMS, A CodeIgniter Based CMS Framework
299 stars 199 forks source link

View not loading correctly #52

Closed jadin closed 11 years ago

jadin commented 11 years ago

Hi,

This is an issue causing me some grief. I have the following view called gis_generate.php (note: I removed some of tags on purpose because it simply parses the html)



 if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 

GIS
Click below to generate your file: 
button type='submit' name='submit' id='submit' onclick="javascript:onClick()">Generate



I'm loading it in the index function as follows:


public function index (){
    $this->view('gis/gis_generate', 'gis_generate');
}

The module installer adds the navigation as follows:


$this->add_navigation("gis_generate", "GIS Generate KMZ", $cms_module_path."/gis/index", 3, 'gis_static');

But the end result is the attached file. Basically the view loads, but everything else disappears (menus, banners...etc.) I cannot tell if this due to an error in the above or some sort of bug.

GIS

goFrendiAsgard commented 11 years ago

Hi Jadin, are the other pages showed correctly? BTW, can you please check the "only content" option of "gis_generate" in navigation management? If it is checked, then un-check it.

jadin commented 11 years ago

Hi goFrendi,

The option "only content" is inactive. And yes, all other pages show correctly. GIS

goFrendiAsgard commented 11 years ago

Hi Jadin. This is quiet strange. In your controller, do you extend CMS_Controller or CMS_Priv_Strict_Controller?

Are you sure that your controller only contains this one?:

$this->view('gis/gis_generate', 'gis_generate');

I'm afraid there is something like "accidental" redirection which call $this->load->view instead of $this->view

But if it is not the case, don't you mind to send me the module? I still can't make sure, but this could be a bug.

Thanks

goFrendiAsgard commented 11 years ago

Hi Jadin, how is it? Have you solve the problem?

jadin commented 11 years ago

Hi Gofrendi,

No not solved unfortunately. I'm extending CMS_Controller. My controller contains two functions, the index function contains:


$this->view('gis/gis_generate', 'gis_generate');
while the another function contains:

$this->view($this->cms_module_path().'/gis_index_list', $data); 
The idea is that the module first loads the first view through index, and then when the user presses the generate button, I want to load another view (below is the full controller class) If you can let me know how I can send you the module to at least make sure it's not a bug? Thanks a lot.

view($this->cms_module_path().'/gis_generate');
     $this->view('gis/gis_generate', 'gis_generate');
}

public function generate (){

        $this->load->Model($this->cms_module_path().'/Map_Model');
        $latest_exists = $this->Map_Model->get_latest();
        if($latest_exists== false) {
            //$map = $this->Map_Model->get_data();
            $kml = $this->Map_Model->get_kml();
            $zip_name = 'Sites '.date('Y-m-d His').'.kmz';

            $zip = $this->Map_Model->zip_file($kml, $zip_name);
            if($zip == true){

                //Add Code

            } else {
                //Add code
            }

            $data = array("result"=> $zip_name);

        }
        else {
            $data = array("result"=> $latest_exists);

        }

        $this->view($this->cms_module_path().'/gis_index_list', $data); 
}

public function download($file_name){

    $this->load->helper('path');
    $directory = "modules/gis/assets/archive/";
    $path = set_realpath($directory);
    $this->load->helper('download');
    $data = file_get_contents($path.rawurldecode($file_name));
    force_download($file_name, $data );

}
```

}

?>
goFrendiAsgard commented 11 years ago

Seems nothing wrong. But, can you try to change this line:

$this->view('gis/gis_generate', 'gis_generate');

into this:

$this->view('gis/gis_generate', NULL, 'gis_generate');
jadin commented 11 years ago

Hi,

Thanks, that worked :) the first view is loading correctly. But the second view in the generate function is not (same issue, banner...etc. disappears.). there is no navigation associated with this view.


 $this->view($this->cms_module_path().'/gis_index_list', $data); 
The view is simply an anchor:


GIS

Your file has been generated:

goFrendiAsgard commented 11 years ago

Okay, I think I see what the problem really is. And surprisingly enough (I'm not aware of it :p)

$this->view() has at least 3 parameters. The first one is the view location, the second one is data, and the third one is navigation code. So, for the second case, it should be

 $this->view($this->cms_module_path().'/gis_index_list', $data, 'gis_generate'); 

This is not bug (at least not crucial one), But as long as I remember, the program can guess the navigation code automatically. I'll check it later though.

jadin commented 11 years ago

Thanks a lot GoFrendi, that worked as well :)

goFrendiAsgard commented 11 years ago

Automatic navigation_code guessing has been fixed in 0.6.2