![]() |
Using custom library - best practice? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Using custom library - best practice? (/showthread.php?tid=21898) Pages:
1
2
|
Using custom library - best practice? - El Forum - 08-24-2009 [eluser]Flak[/eluser] Well, I have a Slider library and a method to check what slide is loading, is it img or swf. Code: class Slider { I have load library on controller, And I was trying to call this on View: Code: <div id="promobox"> Which won't work. I know that maybe this don't work, but any idea how to achieve this. Thanks. Using custom library - best practice? - El Forum - 08-24-2009 [eluser]pistolPete[/eluser] You need to add an echo statement: Code: <?php echo $this->Slider->loadTypes($item->type,$item->path,$item->name); ?> Using custom library - best practice? - El Forum - 08-24-2009 [eluser]Flak[/eluser] tried already but still same: Code: A PHP Error was encountered Fatal error: Call to a member function loadTypes() on a non-object in D:\AppServ\www\ninja\system\application\views\home.php on line 94 Using custom library - best practice? - El Forum - 08-24-2009 [eluser]davidbehler[/eluser] Have you actually loaded the library? Code: $this->load->library('Slider'); Using custom library - best practice? - El Forum - 08-24-2009 [eluser]Flak[/eluser] Damn, why this don't work: $this->Slider->loadTypes and this does $this->slider->loadTypes while I have class Slider. Looks like I have to make all lower to not have such a problems in future. Using custom library - best practice? - El Forum - 08-24-2009 [eluser]jedd[/eluser] You didn't mention in the first post, or answered the most recent, on how you load the library. Using custom library - best practice? - El Forum - 08-24-2009 [eluser]Flak[/eluser] [quote author="jedd" date="1251137528"]You didn't mention in the first post, or answered the most recent, on how you load the library.[/quote] FLAK Quote:I have load library on controller, Code: $this->load->library('slider'); but even if I do Code: $this->load->library('Slider'); I still need to user $this->slider->func. Why is this CaseSensitive, doesn't make sense to me. Using custom library - best practice? - El Forum - 08-24-2009 [eluser]jedd[/eluser] [quote author="Flak" date="1251137781"] but even if I do Code: $this->load->library('Slider'); I still need to user $this->slider->func. [/quote] You're loading it with $this->load->library('Slider'), the class name is Slider - I can see those two things from the code you've provided - and it still doesn't work when you talk to ->Slider-> ...? Yes, that is very odd. Can you confirm the file is called Slider.php in your library directory? Using custom library - best practice? - El Forum - 08-24-2009 [eluser]Flak[/eluser] Nope its slider.php . I don't understand which one is right. ->Slider-> is filename or class name. Using custom library - best practice? - El Forum - 08-24-2009 [eluser]jedd[/eluser] [quote author="Flak" date="1251142824"]Nope its slider.php . [/quote] Ahhh. Quote:I don't understand which one is right. Happily, we have a [url="http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html"]resource[/url] that answers such question. Yes, some consistency appears to be missing, and that'd be a valid complaint - but the documentation is complete and concise (taken from the above link) Naming Conventions File names must be capitalized. For example: Myclass.php Class declarations must be capitalized. For example: class Myclass Class names and file names must match. |