⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Codeigniter Simplicity - A template library that it will make your code... simpler



web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 12 May 2013 - 00:22 AM

Have you ever noticed that Codeigniter although a powerful framework is lacking of a good template library? In the web they are plenty of template libraries for Codeigniter such as Phil Sturgeon template library and lot of more. But what about a different… simple approach? Well Codeigniter Simplicity is exactly that! A simple layout library that I've created and I wanted to share with you.

 

Visit Codeigniter Simplicity Website for more.

 

Enjoy :)


Mas Tiyo

Mas Tiyo
  • profile picture
  • Member

Posted 19 June 2013 - 03:16 AM

Nice, ok i'll try.


Chad Pry

Chad Pry
  • profile picture
  • Member

Posted 17 September 2013 - 18:24 PM

wanting to try out Simplicity, but i'm getting

 

Fatal error: Call to undefined method CI_Output::set_template() in C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\projects\dashboard\application\controllers\example.php on line 16


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 22 September 2013 - 21:27 PM

Can you please check at your config file at around line 136

$config['subclass_prefix'] = 'MY_';

This is how the MY_Output is extending CI_Output. Perhaps you did change that?

 

Also please check that you did copy the two files into the core folder of codeigniter.

application
├──core
│  ├──index.html
│  ├──MY_Loader.php
│  ├──MY_Output.php
├──errors
├── ...

If you still having issues please let me know.

 

Thanks

Johnny


raiethan

raiethan
  • profile picture
  • Member

Posted 07 November 2013 - 08:25 AM

thank you so much this template library i try to implement this with grocery grud with datatables theme

 

height size problem on my column search and text field on add and edit view...

 

i try to use $crud->unset_jquery_ui(); and $crud->unset_jquery();

 

but same result..

 

 

this is my code:

 private function _init()
	{
		$this->output->set_template('default');
                $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');

	}
        
        
      public function index()
      {
           $crud = new grocery_CRUD();
          $crud->set_theme('datatables');
          $crud->set_table('student_list');
          
          $crud->columns('studno','lname','fname','mi','schoolcollege');
          
          $crud->add_fields('studno','lname','fname','mi','schoolcollege');
          
          $crud->add_action('Hitory', '', 'main/submitted_com','ui-icon-plus');	
          
           $crud->add_action('Copy', '', 'main/send', 'ui-icon-plus');
           
           
          $crud->set_relation('schoolcollege', 'schoolcollege_table', 'name');
          
        //  $crud->set_relation($field_name, $related_table, $related_title_field);
          
          // $crud->unset_jquery_ui();
          
          $output = $crud->render();
          
          $this->load->view('example', $output);
          
      }

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 09 November 2013 - 15:18 PM

Hello there,

 

You actually need to install the jquery migrate in order to make it work. So in your example you need to do the following steps.

 

Step1. Download jquery migrate from: http://blog.jquery.com/2013/05/08/jquery-migrate-1-2-1-released/

Step2. Store the file at: assets/themes/default/js/

Step3. Add the line code JUST BELOW of the jquery load. In you case you will have:

private function _init()
	{
		$this->output->set_template('default');
		$this->load->js('assets/themes/default/js/jquery-1.9.1.min.js');
		$this->load->js('assets/themes/default/js/jquery-migrate-1.2.1.min.js');// <--Add this line code here
		$this->load->js('assets/themes/default/hero_files/bootstrap-transition.js');
		$this->load->js('assets/themes/default/hero_files/bootstrap-collapse.js');

	}
...

Grocery CRUD is using jquery library combine with the jquery migrate one. That's why you will actually need to have the jquery migrate in your template as well.

 

As in jquery page says:
 

The jQuery 1.x line had major changes as of jQuery 1.9.0. We strongly recommend that you also use the jQuery Migrate plugin if you are upgrading from pre-1.9 versions of jQuery or need to use plugins that haven't yet been updated.
Source: http://jquery.com/download/


raiethan

raiethan
  • profile picture
  • Member

Posted 11 November 2013 - 01:44 AM

thank you for reply, i follow your steps, but same result problem on textfield size... thank you so much


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 11 November 2013 - 08:17 AM



thank you for reply, i follow your steps, but same result problem on textfield size... thank you so much

 

Hello [member='raiethan'],

 

Can you please attach a screenshot so I can understand what do you mean? Please also remove the unset_jquery_ui line from your code.

 

Thanks

Johnny


raiethan

raiethan
  • profile picture
  • Member

Posted 19 November 2013 - 04:42 AM

sir...


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 19 November 2013 - 16:07 PM

Hello [member='aiethan'],

 

This seems to be only a CSS issue, really :-) . So you just need to change your CSS in order to make it work. That's it really. 

 

I think at the future I will create a full project with Codeigniter + Grocery CRUD + Image CRUD + Codeigniter Simplity so people will not need to install everything one by one :-)

 

But so far as I can see from your screen everything is working fine. You just need to change your CSS in order to make it work.

 

Hope it helps 

 

Cheers

Johnny


raiethan

raiethan
  • profile picture
  • Member

Posted 20 November 2013 - 01:02 AM

thnak you so much..

 

cheers..


jinbatsu

jinbatsu
  • profile picture
  • Member

Posted 12 December 2013 - 08:41 AM

Hello,

 

I have little question understanding this template engine - Codeigniter Simplicity.

How can I send normal variable into template, like default CI template engine?

Example:

in controller:

$data['date_time'] = date('Y-m-d H:i:s');
$this->load->view('default_view', $data);

in view:

echo $date_time;

In Codeigniter Simplicity, I just find variable only:

in controller $this->output->set_title will go output in views variable as $title.

$this->load->js/css will go output in views variable as: foreach and display the script js/style css

 

And the main display for grocery_crud:

$output = $crud->render();

$this->load->view('crud_view',$output);

will go output in view variable as $output

 

Now, how can I insert another variable, like example $date_time, from controller to view with Codeigniter Simplicity.

Thank You


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 12 December 2013 - 21:13 PM

Hello [member='jinbatsu'] and welcome to the forums,

 

That's a good question actually (It is my fault I didn't documented properly) . You can use the:

$this->load->section($section, $ci_view, $data);

So for example in your case you can have something like:

$data['date_time'] = date('Y-m-d H:i:s');
$this->load->section('datetime_section', 'default_view', $data);

in the view default_view.php you will have:

echo $date_time; //This is your view

and in your layout (e.g. application\views\themes\default.php) you will have this:

//This is your layout
...
$date_time = $this->load->get_section('datetime_section'); //Here you are loading the section at the variable
...
echo $date_time;

...

Hope it is now more clear. Actually if you try it like I've told you it will work like a magic :-)

 

Just to explain what is happening here is:
 

$this->load->section($section, $ci_view, $data);

The $section is any string you like for example 'my_section' , the $ci_view and the $data is the view name and the data (optional). Is like using the $this->load->view($ci_view, $data); with the only difference that this particular view will be loaded as a section. To actually call this section you just need to call it through your layout like this: $this->load->section($section_name); and that's it.

 

Please let me know if this worked for you.

 

Regards

Johnny


jinbatsu

jinbatsu
  • profile picture
  • Member

Posted 14 December 2013 - 06:39 AM

Thank You for the explain, I understand and it works well with grocerycrud.

But, it doesn't work with image CRUD, I have try with default output also I try with section, but doesn't show anything, it's blank and undefined variable output.

 

Can this template use for image crud?

Thank You

 

EDIT: SOLVED

 

I have forget to add extra segment, because my image_crud use category, and I should use category ID in my url browser.


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 14 December 2013 - 11:52 AM

I am very glad [member='jinbatsu'] that you've solved your issues :)

 

Cheers

Johnny


budi_seeker

budi_seeker
  • profile picture
  • Member

Posted 15 December 2014 - 15:40 PM

Can you please check at your config file at around line 136

$config['subclass_prefix'] = 'MY_';

This is how the MY_Output is extending CI_Output. Perhaps you did change that?

 

Also please check that you did copy the two files into the core folder of codeigniter.

application
├──core
│  ├──index.html
│  ├──MY_Loader.php
│  ├──MY_Output.php
├──errors
├── ...

If you still having issues please let me know.

 

Thanks

Johnny

 

Hello web-johnny,

Firstly, thank you for your simple-yet-cool template!

Problem is: I've got the similar error, followed your steps, then I got another error:

====================

An Error Was Encountered

Unable to load the requested file: themes/simple.php

====================

Do you have any idea how to solve it?

Any help would be very appreciated :)


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 28 December 2014 - 13:23 PM

 

Hello web-johnny,

Firstly, thank you for your simple-yet-cool template!

Problem is: I've got the similar error, followed your steps, then I got another error:

====================

An Error Was Encountered

Unable to load the requested file: themes/simple.php

====================

Do you have any idea how to solve it?

Any help would be very appreciated :)

 

 

Hello [member='budi_seeker'],

 

It seems that you need to create the file simple.php at the folder application/views/themes/ once you have this file that can be similar to the default.php file then you will solve your issue

 

Cheers

Johnny


otoyoto

otoyoto
  • profile picture
  • Member

Posted 07 April 2015 - 15:05 PM

Need help..please

 

 

 

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant EXT - assumed 'EXT'

Filename: core/MY_Loader.php

Line Number: 209

Backtrace:

File: D:\xampp\htdocs\ci_simplicity\application\core\MY_Loader.php
Line: 209
Function: _error_handler

File: D:\xampp\htdocs\ci_simplicity\application\controllers\example.php
Line: 7
Function: __construct

File: D:\xampp\htdocs\ci_simplicity\index.php
Line: 292
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\ci_simplicity\system\core\Exceptions.php:272)

Filename: core/Common.php

Line Number: 569

Backtrace:

File: D:\xampp\htdocs\ci_simplicity\application\controllers\example.php
Line: 25
Function: view

File: D:\xampp\htdocs\ci_simplicity\index.php
Line: 292
Function: require_once

An Error Was Encountered

Unable to load the requested file: ci_simplicity/welcome.php

 

 


egsolis

egsolis
  • profile picture
  • Member

Posted 09 June 2015 - 21:17 PM

Hi Otoyoto i got the same problem, i had to edit those lines to this:

function _ci_autoloader($basepath = NULL)
   {
          if($basepath !== NULL)
          {
          //$autoload_path = $basepath.'config/autoload'.EXT;
          $autoload_path = $basepath.'config/autoload.php';
    }
    else
    {
    //$autoload_path = APPPATH.'config/autoload'.EXT;
    $autoload_path = APPPATH.'config/autoload.php';
    }

it isn't the final solution but for the moment it makes it work


warlock

warlock
  • profile picture
  • Member

Posted 18 August 2015 - 16:08 PM

hello johny, 

 

I try to use "Codeigniter Simplicity" with CodeIgniter3 HMVC

 

All seems to work fine, except "section". Let me show you:

 

Controller Example

class Example extends MX_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
		$this->_init();
	}

	private function _init()
	{
		$this->output->set_template('default');
		$this->load->js('assets/themes/default/js/jquery-1.9.1.min.js');
	}

	public function index()
	{
		echo "welcome module EXAMPLE <br>";
		$this->output->set_title('this is a test example');
		$this->load->section('sidebar', 'ci_simplicity/sidebar');
		$this->load->view('ci_simplicity/example_3');
	}

The page is rendered ok, the title is set, the content is set, but the section is not available.

 

I did some debugging an I noticed that the section array has values in MY_Loader but when it comes to be used in template 

$this->load->get_section()

the section array is empty.

 

This seems to me that $this is not the same object.

 

 

When I extend class example with CI_Controller

class Example extends CI_Controller {
}

is all ok, the section array is available and the system is working.

 

 

I am aware of this:

https://github.com/scoumbourdis/codeigniter-simplicity/issues/2