Welcome Guest, Not a member yet? Register   Sign In
HMVC, Cant Load Libraries
#1

[eluser]seminalJim[/eluser]
Im having trouble loading libraries in codeigniter (2.1.2), with HMVC installed...

Ive tried setting the autoload (/config/autoload.php) and can use the db class in (controllers/articles.php)...
Code:
$this->db->get('articles');
.. works fine!

However, I cant use the db class from a module controller, eg.
modules/MOD_Content/controllers/Content.php/fetch($id)
Code:
$this->load->model('MOD_Content/content_model');
$object = $this->content_model->getRowOf('articles', $id);
modules/MOD_Content/models/Content_model.php/getRowOf($db_name, $id)
Code:
class Content_Model extends CI_Model
{
function getRowOf($db_name, $id)
{
  $this->db->where('id', $id);
  $query = $this->db->get($db_name);
  return $query->row();
}
}

I get this message...

Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Snapsemenu::$db
Filename: core/Model.php
Line Number: 51

I traced the snapsemenu bit to my controller (controllers/articles.php)

Code:
class Articles extends MX_Controller
{
public function article($id)
{
  $css  = array();
  $script  = array();
  echo html_open_new(@$page_title, $css, $script);
  echo container_open();
//  echo Modules::run('MOD_Header/Header/render');
  echo Modules::run('MOD_SnapseMenu/SnapseMenu/render');
  $modules = array
  (
//   1 => array
//   (
//    'path' => 'MOD_Sidemenu/sidemenu/render',
//    'config' => array
//    (
//     'widgets' => array
//     (
//      'search'=>'WID_Sidemenu/search/render',
//      'topten'=>'WID_Sidemenu/topten/render',
//     ),
//    )
//   ),
   2 => array
   (
    'path' => 'MOD_Content/content/render',
    'config' => array
    (
     'layout' => 'single',
     'content_type' => 'article',
     'ref_id' => $id
    )
   )
  );
  echo Modules::run('MOD_Flatland/flatland/render', $modules);
  echo container_close();
  echo html_close();
}
}

If i comment-out the line
Code:
echo Modules::run('MOD_SnapseMenu/SnapseMenu/render');

It seems to work for some reason? I am totally mystified?

Please somebody help?

#2

[eluser]Aken[/eluser]
Well that should tell you that the problem is not with the code you've posted, but with something to do with the SnapseMenu module.
#3

[eluser]seminalJim[/eluser]
Snapsemenu doesnt do anything really...?

Controller: snapsemenu.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Snapsemenu extends CI_Controller
{

public function render()
{
  $this->load->view('output');
}

}

/* End of file snapsemenu.php */

View: output.php
Code:
<style>
.snapsemenu
{
display: block;
margin: 0px auto;
width: 1200px; height: 40px;
background-color: #900; color: white;
}
</style>
<div class='snapsemenu'>
SNAPSE Menu
</div>

And it doesnt use the DB class?
#4

[eluser]seminalJim[/eluser]
Shit, sorry... lol. you were right. I had to change the CI_ to MX_

Thanks for your help!




Theme © iAndrew 2016 - Forum software by © MyBB