Welcome Guest, Not a member yet? Register   Sign In
  Template Library Version 1.3
Posted by: El Forum - 08-16-2008, 05:28 PM - Replies (16)

[eluser]Colin Williams[/eluser]
Template Library Version 1.3 has been released. Version 1.3 adds new features for working with template parsers like Smarty.

-------------------------------------------------------------------------------------

Visit the Template Library Homepage

View the Change Log

Still using Template 1.2.1? See the Ignited Code thread covering Template 1.2.1

-------------------------------------------------------------------------------------

What's New in Version 1.3?

Since Version 1.1, Template provided the parse_view() method, allowing programmers to utilize CI's Template Parser class when writing to regions instead of just using standard PHP-coded Views. Version 1.3 expands this functionality, allowing the use of any additional template parser, like the popular Smarty Template Engine. Along these same lines, Version 1.3 allows the master template file to be parsed by any parser class instead of always being loaded as a View.

-------------------------------------------------------------------------------------

The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML.

Using Template looks like this:

Code:
$this->template->write('title', 'Introduction to Template');
$this->template->write_view('content', 'blog/posts', $this->blog->get_posts());
$this->template->render();

Look interesting? Head over to the Template Library Homepage to begin using Template in your next CodeIgniter application.


  Library playing me up!
Posted by: El Forum - 08-16-2008, 04:27 PM - Replies (15)

[eluser]Adam Griffiths[/eluser]
Hey!

I am writing an authentication library, firstly, here is my constructor.

Code:
function Auth($config)
    {
        $CI =& get_instance();
        $CI->load->library('session');
    }

I get this error, whenever I use $CI->function->parameter('value'); from any other function in the auth class.

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: CI

Filename: libraries/Auth.php

Line Number: 53


A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: libraries/Auth.php

Line Number: 53

Line 53 is...

Code:
$CI->load->library('session');

I am running PHP 5.2.5 The user guide only says that PHP 4 has problems returning the codeigniter instance from a constructor...I have also tried using __construct as my constructor name but it has the same end result.

All comments welcome.

Thanks Smile


  Bake in Codeignitor?
Posted by: El Forum - 08-16-2008, 02:37 PM - Replies (3)

[eluser]Unknown[/eluser]
I already have a database made and I want to quickly spread everything out. In CakePHP, you could use the bake command in the console/command line and it would ready everything for you.

Is there any way I can do this in Codeignitor?
Thanks, reply soon! Smile


  autoload performance
Posted by: El Forum - 08-16-2008, 12:02 PM - Replies (2)

[eluser]Xavier D.[/eluser]
Hi,

I'm working on a big site with CI, the models, helpers en library are becoming big.

Loading all the those things everytime in a class looks like overkill, now I see the autoload can help me with that, but what about performance, is there a difference in performance using the autoload?

thx


  best approach for multi controllers with little difference.
Posted by: El Forum - 08-16-2008, 08:19 AM - Replies (6)

[eluser]RpR[/eluser]
Hi,

I am trying to convert my old php to codeigniter to learn some more about codeigniter.
Now I am facing this.

I have some controllers
contact,projects,introduction they all contain the same except some vars which are different. What would be the best approach to code without copy past. I was thinking using a model but that is more for db access.

Example.
contact:

Code:
<?php

class Contact extends Controller {

    function Contact()
    {
        parent::Controller();
    }
    
    function index()
    {
        $data_top['title1'] = "Contact";
        $data_top['url1'] = "";
        $this->load->view('top',$data_top);
        $this->load->view('content');
        $this->load->view('bottom');
    }
}

/* End of file contact.php */
/* Location: ./system/application/controllers/contact.php */

Introduction which is voorstelling in Dutch Smile
Code:
<?php

class Voorstelling extends Controller {

    function Voorstelling()
    {
        parent::Controller();
    }
    
    function index()
    {
        $data_top['title1'] = "Voorstelling";
        $data_top['url1'] = "";
        $this->load->view('top',$data_top);
        $this->load->view('content');
        $this->load->view('bottom');
    }
}

/* End of file voorstelling.php */
/* Location: ./system/application/controllers/voorstelling.php */

As you can see only the $data_top parameters are different and the content will be replaced by a different page but for the rest it stays the same.

Thanks for any input.


  A better menu/breadcrumb model
Posted by: El Forum - 08-16-2008, 04:00 AM - Replies (1)

[eluser]neen[/eluser]
Hi there, below you'll find the menu class I am using for my custom CMS built on CI...

This has only been tested with PHP5. It will probably work with PHP4, with some major edits.

Just drop the model in your models directory and drop the below code in the __construct() function of your controller. This can be used to generate and display several menus at once such as here: http://mjohn.krob.ath.cx/menu.php, or just one menu.

This model handles side menus (ie just one menu at a time, instead of several). If you specify more than one menu in your controller, pass the $id of the menu you want to render to $this->menu->generateSidemenu() .

It also handles breadcrumbs, and lets you specify custom names for any of the URIs you may have. This is primarily meant for the backend/admin area.

Each controller can have it's own separate menu/breadcrumb initialization, or you can dump them all in one file and use a foreach() on $this->menu->menuList().

This also has a little bit of HTML hard coded into it, but it shouldn't be too hard to change it to suit your needs. This model also doesn't handle any sort of display, either, so that will be up to you to take care of.

The model is in my second post (since I hit the character limit). If you have any questions or suggestions, let me know!
Implementation:

Code:
$this->load->model('display_model', 'display');
            // setup the menu and breadcrumbs
            $this->menu->item("Content","Manage Content")->
                create("Add Content")->
                listitems("List Content")->
                delete("Delete Content")->
                registerBreadcrumb('manage', 'Manage Content')->
                registerBreadcrumb('create', 'Add Content')->
                registerBreadcrumb('list', 'List Content')->
                registerBreadcrumb('edit', 'Edit Content')->
                registerBreadcrumb('delete', 'Delete Content');


  Include .xml view
Posted by: El Forum - 08-15-2008, 11:03 PM - Replies (1)

[eluser]spheroid[/eluser]
I need to create an .xml file as a view....then display the content. However, in my controller I have

Code:
$this->load->view('sample/samplexmldoc', $data);

The file does not have a .php extension but .xml (i.e. views/sample/samplexmldoc.xml).

How can I do this?


  strange issues with get_where..
Posted by: El Forum - 08-15-2008, 10:33 PM - Replies (8)

[eluser]awpti[/eluser]
mysql> SELECT * FROM (`jobs`) WHERE `times_reported` > 0;
Empty set (0.00 sec)

But..

Code:
function fetch_reported_jobs()
{
   $this->db->get_where('jobs', 'times_reported > 0');
   return $this->db->count_all_results();
}

Returns a result of 1

Result of db->last_query: SELECT * FROM (`jobs`) WHERE `times_reported` > 0

For some reason, count_all_results() is returning 1 even though it should return 0. I can't see any issue with the code in DB_active_rec.php

Thoughts?


  Number of queries per page, what is considered the limit?
Posted by: El Forum - 08-15-2008, 05:48 PM - Replies (4)

[eluser]codex[/eluser]
I know, the less queries you have the better, but how many is considered 'a lot'? 50? 100?

Just curious.


  Database Caching
Posted by: El Forum - 08-15-2008, 03:43 PM - Replies (3)

[eluser]BeingDefined[/eluser]
I'm looking at database caching documentation and I'm trying to wonder why there's no expire time feature for the database caching like in the general page caching. Would creating such a feature put some limitations or was it just not programmed(probably not this one tho :p)

Thanks all!


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
CodeIgniter v4.5.0 Releas...
by eelisland
7 minutes ago
Cache best practice?
by BhambriRohunu
1 hour ago
CI 4.5.1 CSRF - The actio...
by BhambriRohunu
1 hour ago
Bug with sessions CI 4.5....
by InsiteFX
1 hour ago
Codeigniter Shield Bannin...
by kenjis
6 hours ago
SQL server connection not...
by kenjis
6 hours ago
Best way to create micros...
by kenjis
8 hours ago
How to use Codeigniter wi...
by kenjis
8 hours ago
Getting supportedLocales ...
by kcs
Yesterday, 09:30 AM
Component help
by FlashMaster
Yesterday, 01:41 AM

Forum Statistics
» Members: 85,280
» Latest member: buy-oxycodone-online-quickly
» Forum threads: 77,577
» Forum posts: 375,981

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB