Welcome Guest, Not a member yet? Register   Sign In
Help me for this library
#1

(This post was last modified: 03-12-2015, 12:00 AM by Vimal.)

I am using HMVC extension with COdeigniter 3 rc3

And also this lib.
http://www.grocerycrud.com/codeigniter-simplicity

I know this is for old version but its working fine in ci3.
My problem is.
When I use its default given controllers and view in modules with its working fine. And when i use my own controllers and views its working but css and js file not loaded with it. Its show nothing..
PHP Code:
class Test extends MX_Controller {
 
   //put your code here
 
   public function __construct()
 
   {
 
       parent::__construct();
 
   
        $this
->_init();
 
       
    
}
 
   
    private 
function _init(){
 
       
    $this
->output->set_template('test');
 
    $this->load->js('assets/themes/default/js/jquery-1.9.1.min.js');
 
       $this->load->js('assets/themes/default/hero_files/bootstrap-transition.js');
 
       $this->load->js('assets/themes/default/hero_files/bootstrap-collapse.js');
 
       $this->load->css('assets/admin/bower_components/bootstrap/dist/css/bootstrap.min.css');
 
   
    
}
 
   
    public 
function index()
 
   {
 
       $this->load->view('testview');
 
       
    
}
 
   



Folder location
..
application/
---modules/
         test/
            --controllers/
                        --Test.php
            --views/
                       --testview.php
                          -themes/
                                   --test.php

themes/test.php
PHP Code:
This is test's

<?=$output?>
<?php
    /** -- Copy from here -- */
    if(!empty($meta))
    foreach($meta as $name=>$content){
        echo "\n\t\t";
        ?><meta name="<?php echo $name; ?>" content="<?php echo $content; ?>" /><?php
             }
    echo "\n";

    if(!empty($canonical))
    {
        echo "\n\t\t";
        ?><link rel="canonical" href="<?php echo $canonical?>" /><?php

    }
    echo "\n\t";

    foreach($css as $file){
         echo "\n\t\t";
        ?><link rel="stylesheet" href="<?php echo $file; ?>" type="text/css" /><?php
    } echo "\n\t";

    foreach($js as $file){
            echo "\n\t\t";
            ?><script src="<?php echo $file; ?>"></script><?php
    } echo "\n\t";

    /** -- to here -- */
?>


testview.php
PHP Code:
<hr/>
This is from test view file<br


OutputSource is
PHP Code:
This is test's


<hr/>
This is from test view file<br/>
        <meta name="keywords" content="" />
        <meta name="description" content="" /> 
Reply
#2

The CodeIgniter-simplicity code is overloading the loader to handle assets ($this->load->js()/$this->load->css()). HMVC is also overloading the loader to support HMVC (and the MX_Controller kicks off loading a lot of the other HMVC code).

More than likely, the MX_Loader and codeigniter-simplicity's MY_Loader are not playing nice together, so you would have to modify one or the other to work together.

The first thing I would try would be to modify MY_Loader.php to extend MX_Loader instead of CI_Loader.
Reply
#3

I forgot to say i already done this.

PHP Code:
(defined('BASEPATH')) OR exit('No direct script access allowed');

/* load the MX_Loader class */
require APPPATH."third_party/MX/Loader.php";

//class MY_Loader extends MX_Loader {}


class MY_Loader extends MX_Loader {

//simplicity codes


But still not loading js, meta css file only. Other things running perfactly SmilePlease
Reply
#4

Please any one help me. Its emergency condition for me..Please. I am stuck on this point. Curruntly I am including it with manually please..
Reply
#5

We are also using HMVC extension with COdeigniter 3

Our approach to use js and css files for our project is little bit different.

We first define few constants in application/config/constants.php as below

$server_name=$_SERVER['HTTP_HOST'];

define( 'BASE_URL',"http://".$server_name."/demo/" );

// User directory path
define( 'BASE_CSS', BASE_URL . 'media/user/css/' );
define( 'BASE_JS', BASE_URL . 'media/user/js/'  );


Then in template header file we use these constants to load js and css files

File : application/modules/test/views/themes/test.php

<link href="<?php echo BASE_CSS; ?>bootstrap.min.css" rel="stylesheet">

<script type='text/javascript' src='<?php echo BASE_JS; ?>jquery-1.9.1.min.js'></script>

I hope this will help you.
Reply
#6

No its Not..
Common files already included in my layout.But sometime we need to include specific file for specific page.In that condition we should use this load js function.
Reply
#7

(03-13-2015, 09:56 PM)Vimal Wrote: No its Not..
Common files already included in my layout.But sometime we need to include specific file for specific page.In that condition we should use this load js function.


In that case one solution is :

add js file path inside the specific function in controller as :

$this->data['javascript'][] = BASE_JS. "jquery.validate.min.js";

and then in your header file or footer file use the below code :

<?php

if(!empty($javascript))
{
if(is_array($javascript) && sizeof($javascript) > 0){
foreach($javascript as $k => $v){
echo '<script src="'.$v.'"></script>';
}
}
}
?>

In this way page specific js files will be included.

Same logic can be used for css files.

I hope now your problem will be solved.
Reply
#8

(03-13-2015, 09:56 PM)Vimal Wrote: No its Not..
Common files already included in my layout.But sometime we need to include specific file for specific page.In that condition we should use this load js function.

I had the same problem. A compromise for this problem is extending your controller with CI_Controller instead of MX_Controller . Extending the controllers with MX_Controller seems required only if you want call other controller functions from within a controller .
Reply




Theme © iAndrew 2016 - Forum software by © MyBB