Page library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Page library (/showthread.php?tid=2158) |
Page library - El Forum - 07-19-2007 [eluser]Al James[/eluser] Hi there... As discussed here: http://ellislab.com/forums/viewthread/49910/P45/#279320 I think that functions for linking css and js files should be broken out of the view library and put into a separate 'page' library. I have written a basic page library. Features: * Automatic linking of CSS and JS files (as per coolfactors idea in his view library) * Ability to set title, description and keywords meta tags. * Ability to pass values directly into the javascript environment (uses json_encode, so its PHP 5 or PHP 4 + the json extension) * Ability to set javascript code to be executed in the window.onload function. I will post the code in the next reply as its too long to include here! Example usage: Controller: Code: $this->page->set_title('My page'); In the view file: Code: <html> Outputs: Code: <html> Page library - El Forum - 07-19-2007 [eluser]Al James[/eluser] Arg! Code too long to put here... Here is a link: http://codeigniter.com/wiki/File:Page.zip/ Aside note: Why cant we attach PHP files to posts in this forum? That would be super useful! Page library - El Forum - 12-10-2007 [eluser]NBrepresent[/eluser] This is the best!! Reeeaallly cleans up the header.php . Thanks, Al. One possible improvement would be if you added a parameter in the css_link method for media. Page library - El Forum - 12-10-2007 [eluser]sophistry[/eluser] Al James! Nice to see you. Welcome back from Zend-land. ¿Qué Pasó allá? A month ago you posted a farewell notice here in the sparks thread: http://ellislab.com/forums/viewthread/56456/P20/ Does this mean you'll be picking up the "Sparks Library - Object Caching" project again? Page library - El Forum - 12-10-2007 [eluser]NBrepresent[/eluser] Oh, I seem to have resurrected a thread that's been dead for a while. Page library - El Forum - 12-10-2007 [eluser]sophistry[/eluser] Yep. No Problem. Al was a generous contributor. I got all fuddled up and forgot to read the dates too! :-) Welcome to CI, BTW! Page library - El Forum - 12-10-2007 [eluser]NBrepresent[/eluser] Has anyone gotten the page library working? I just sent this email to Al to see whether he can shed some light on the config file issue: Hi Al, First, let me say thanks for your Page library. It looks really useful, and I'm excited about using it. The problem is that once I've added the library to /application/libraries/, I get the following error message when I try to autoload the library: "The configuration file page.php does not exist." So, I tried adding an empty file called page.php in the config directory, producing this error: "Your page.php file does not appear to contain a valid configuration array." So the big question would be, what should the config array contain? I notice in the comments of the library, you mention the config once: "Set to 0 (can also be set from this libraries config file) to disable." If this is an annoyance, I apologize, but based on the tone of some posts on the CI board that I've read, I decided that you were a pretty affable guy. Hope to talk to you soon, Perry Page library - El Forum - 12-10-2007 [eluser]NBrepresent[/eluser] If anyone else is ever looking for a solution to this problem, commenting lines 36 + 38 of the library got things working for me. On to the next adventure... Page library - El Forum - 12-13-2007 [eluser]anthrotech[/eluser] What is the difference of this approach versus putting vars in a language file? I've put all my metadata variables in a custom language file and called the objects via: $this->lang->line('some_var') <?=$this->lang->line('some_var')?> in my header.php file Just curious...I am sure it's "Six One Way, Half a Dozen Another" type of thing. But I've only begun using CI, so I am curious to find out "best practices." Page library - El Forum - 12-13-2007 [eluser]NBrepresent[/eluser] I guess that it's just more intuitive/readable to use the page library (really only because of the method names), but they both accomplish the same really. |