Welcome Guest, Not a member yet? Register   Sign In
couldn't create own library
#1

(This post was last modified: 01-21-2015, 12:42 AM by kavy.)

I created my own library  . how could customized template in library ... iam so new with codeigniter .
Reply
#2
Tongue 

You are new to english too Tongue. What was the question again? (Usually is good to put a question mark if you want something to be answered...)
Reply
#3

(This post was last modified: 01-21-2015, 05:30 AM by InsiteFX.)

If you access CI in a CI User Library then you need to use the CI Super Object.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(01-20-2015, 10:25 PM)kavy Wrote: I created my own library  . how could customized template in library  ... iam so new with codeigniter .

kavy, I can't really tell what you're asking, but welcome to CodeIgniter, and don't give up. It will take some time to learn.

Here's a link to a PDF of the documentation for Code Igniter 2.1.2
http://notes.hipopotam.org/file_download..._Guide.pdf

If you're just starting with Code Igniter, I advise you not to create libraries yet. Create a few simple applications, like a blog, or product registration, or something like that. When you get more familiar with Code Igniter, you will probably find it easy to add your own libraries.

To avenirer and InsiteFx, come on, folks, don't be mean. Not everyone in the world speaks the Queen's English, and don't throw terms like CI Super Object to a newbie lost on page one. They'll just get loster.  Smile
Reply
#5

To create a library is very simple with CI. First you have to create a File with your Classname in your /application/library folder like

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

class 
Rufnex {

    function 
__construct($params)
    {
        
$this->param $params['test'];
        
$this->ci =& get_instance();
    }

    public function 
hello()
    {
        echo 
"hello world";
    }

    public function 
load()
    {
        
$this->ci->load->library('calendar');
        echo 
$this->ci->calendar->generate();
    }

    public function 
param($param)
    {
        echo 
"content of my param: ".$param;
        echo 
"<br />";
        echo 
"content of my class param: ".$this->param;
    }
    


Then you can call your Class in you controller like this

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

class 
Welcome extends MY_Controller {

    function 
__construct()
    {
        
parent::__construct();
    }

    public function 
index()
    {
        
$this->load->library('rufnex', array('test' => 123));
        
$this->rufnex->hello();
        
$this->rufnex->load();
        
$this->rufnex->param('test');
    }


As you see, there is no magic ;o) For further details please refer to the documentaion at http://www.codeigniter.com/user_guide/ge...aries.html

Reply




Theme © iAndrew 2016 - Forum software by © MyBB