<?xml version="1.0" encoding="utf-8"?>	
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>CodeIgniter Wiki</title>
    <link>http://codeigniter.com/wiki</link>
    <description>CodeIgniter Wiki</description>
    <dc:language>en</dc:language>
    <dc:creator>support@ellislab.com</dc:creator>
    <dc:rights>Copyright 2007</dc:rights>
    <dc:date>2012-05-22T00:10:53+00:00</dc:date>
    <admin:generatorAgent rdf:resource="http://www.pmachine.com/" />
    

    <item>
      <title>Applications Using Code Igniter</title>
      <link>http://codeigniter.com/wiki/Applications_Using_Code_Igniter</link>
      <guid>http://codeigniter.com/wiki/Applications_Using_Code_Igniter</guid>
      <description><![CDATA[<p><a href="http://codeigniter.com/wiki/Category:Applications" title="Category:Applications">Category:Applications</a></p>

<h3>Projects using CodeIgniter (source code available)</h3>

<p><b><a href="http://www.pyrocms.com/">PyroCMS</a></b><br />
PyroCMS is the CMS built for everyone: your clients, your designer and you - the developer. Built by some of the same people who maintain CodeIgniter, PyroCMS is always using the latest and greatest CodeIgniter features - even ones you don&#8217;t know about yet.</p>

<p><b><a href="http://cibonfire.com">Bonfire</a></b><br />
Kickstart your web apps with this powerful, flexible app framework built on top of CI 2. Provides auth, user management, admin area, email queue, system events, modules, HMVC, database backup, mirations, and more.</p>

<p><b><a href="http://blazeeboy.github.com/Codeigniter-Egypt/">Egypt CMS</a></b><br />
An easy to use base for designers with a default auth system, database and more.</p>

<p><b><a href="http://www.bambooinvoice.org/">BambooInvoice</a></b></p>

<p><b><a href="http://classroombookings.com/">Classroombookings</a></b><br />
Room booking system for schools.</p>

<p><b><a href="http://myfina.ridinglinux.org/">MyFina</a></b><br />
Web-based personal financial management system.</p>

<p><b><a href="http://www.ionizecms.com">Ionize CMS</a></b><br />
Ionize is a Content Management System base on CodeIgniter. Easy, powerful and modular, Ionize is build by webdesigners for webdesigners. url=&#8220;http://demo.ionizecms.com&#8221;]Demo of Ionize[/url]</p>

<p><b><a href="http://68kb.com">68 Knowledge Base</a></b><br />
68KB is a knowledge base script.&nbsp; It was built with the site owner in mind and to be as simple to work with as possible.</p>

<p><b><a href="http://www.assembla.com/wiki/show/linkster">Linkster, PHP Link Directory</a></b><br />
Growing out of a need for simple categorical organization, Linkster aims to be the simple solution. Specifically built for link directories, such as a collection of your business partners. <a href="http://demo.codeigniterdirectory.com/">Demo available here</a>. </p>

<p><b><a href="http://max-3000.com/">MaxSite CMS</a></b><br />
WordPress-like blog CMS. In heavy development. Documentation is in Russian only for now.<br />
<b><a href="http://code.google.com/p/planet-ci/">Planet CI</a></b><br />
Planet CI is a Feed/RSS agregator reader using PHP. Its similar to <a href="http://www.planetplanet.org/">planetplanet</a> but its on perl langguage. Planet CI using codeigniter and simple pie. you can se the demo at <a href="http://planet.ilkom.org/">planet.ilkom.org</a>.</p>

<p><b><a href="http://myclientbase.com/">MyClientBase</a></b><br />
Invoice management.</p>

<p><b><a href="http://www.getfuelcms.com">FUEL CMS</a></b><br />
An easy, flexible, empowering Content Management System for rapid development that transforms your CodeIgniter projects into client manageable brilliance.</p>

<p><b><a href="http://codefight.org">CODEFIGHT CMS</a></b><br />
Simple multiple website manager.</p>

<h3>Projects using Code Igniter</h3>

<p><b><a href="http://www.thephpcode.com/">PHP Code Generator</a></b><br />
The PHP Code generator generates PHP code for using with Codeigniter framework. The generator itself powered by Codeigniter.</p>

<p><b><a href="http://www.pliantcms.com/">PliantCMS</a></b><br />
Themeable, dynamic, seo optimized CMS for codeigniter designers, content manager and seo specialist.</p>

<p><b><a href="http://osmek.com">Osmek</a></b> A new kind of CMS, built in the cloud so your content is available where and how you need it. It&#8217;s a beautiful interface for creating content, and a powerful set of APIs for retrieving it.</p>

<p><b><a href="http://www.escrowizard.com">EscroWizard</a></b> Escrow and Title Insurance quote issuing system, intended for small to medium sized escrow companies and title companies.</p>

<p><b><a href="http://www.timecamp.com">TimeCamp</a></b> Automatic time-tracking software, that tracks projects, websites and applications usage, users&#8217; productivity and helps understand how the time is spend.</p>

<p><b><a href="http://www.visikid.com">Visikid</a></b> Parental control application. Visikid is taking the educative role in regards to your child’s safety on the internet.</p>

<p><b><a href="http://narien.com">Narien Teas</a></b> Online Tea Store built with CI. Site features shopping cart, blog, reward points, coupon system, affiliate and referrals, ebay integration, keyword tracking, mailing list, pdf invoices, product label creation, etc.</p>

<p><b><a href="http://linkfuu.com/">LinkFuu</a></b> is a URL management tool for webmasters. CI is used along side JQuery with great effect. </p>

<p><b><a href="http://www.wittygraphy.com">Wittygraphy</a></b> is a social network dedicated to caricaturists and caricature lovers. It&#8217;s a place to share, discuss, and promote the art of caricature. Caricaturists get free webspace to build their homepage, get listed in our directory, publish their portfolios to promote their artwork. In addition Wittygraphy is also a marketplace helping artists to sell their services.</p>

<p><b><a href="http://blogfrog.pl/">BlogFrog</a></b> blog aggegate service</p>

<p><b><a href="https://www.mindzinger.com/">MindZinger</a></b> is mainly a question-answer site for students and tutors. Also it has a section that is pretty similar to hotornot.com, and a forum (based on phpbb2), etc. Registration is free. All created on top of a plain code igniter installation by <a href="http://www.pengekcs.com">www.pengekcs.com</a> - you can reach me on yahoo at pengekcs [at] yahoo [dot] com</p>

<p><b><a href="http://www.bambooinvoice.org/">BambooInvoice</a></b> is free open-source invoicing software intended for small businesses and independent contractors. <i>code is available</i> Also see this <a href="http://www.codeigniter.com/forums/viewthread/705/">forum thread</a>.</p>

<p><b><a href="http://www.motortopia.com/">Motortopia</a></b>. A motor enthusiast social networking site focused on peoples passion for motor vehicles. Site features Web 2.0 interface, cross-browser compatability, degradability, accessability and web standards compliance.</p>

<p><b><a href="http://www.todlaciebie.pl/">ToDlaCiebie.pl</a></b> - website built entirely with CI, collects best gift ideas from Polish e-shops (&#8216;to dla ciebie&#8217; means &#8216;this is for you&#8217;).</p>

<p><b><a href="http://www.nuherbs.com/">Nuherbs.com</a></b> - Chinese herbs and medicine site built in CI. Has product ordering and full account access.</p>

<p><b><a href="http://peterbaker.net/">PeterBaker.net</a></b> - Portfolio for the photographer, built in CI and using jquery for some effects.</p>

<p><b><a href="http://freestuffwave.com">FreeStuffWave</a></b> A community freebie site built using the latest released CI version.</p>

<p><b><a href="http://www.snowshoeconditions.com/">Snowshoe Conditions</a></b> - A site for people to check back-country snow conditions before heading out for the day, everything is user-submitted.</p>

<p><b><a href="http://www.creatieve-cursussen.nl">Creatieve-Cursussen.nl</a></b> - Dutch website listing creative courses. Also uses Jquery and a google maps api class.</p>

<p><b><a href="http://britcaster.com">BritCaster.com</a></b> - An aggregator and hub for podcasts - UK focused. Generates aggregated RSS feeds for serialised content and a unique custom keyword RSS creator (FeedMe!).</p>

<p><b><a href="http://www.sign-up-sheet.com">Sign-Up-Sheet</a></b> - Super simple web based sign-up-sheet program.</p>

<p><b><a href="http://www.badgetracker.com">BadgeTracker</a></b> - A web app, built using CI, that handles activity registration and camp management for summer camps.</p>

<p><b><a href="http://classroombookings.com/">Classroombookings</a></b>. An open-source easy to use web-based room booking system for schools.</p>

<p><b><a href="http://www.zoekipedia.nl/">Zoekipedia</a></b>. Dutch Wikipedia searchengine. build in CI 1.5.2 Project from Auke Jongbloed and under constant development.</p>

<p><b><a href="http://www.webacana.com.br/">Webacana</a></b>. Brazilian movie rental service (like Netflix). build in CI 1.5.1 Project from Jesse Jr and under constant development too.</p>

<p><b><a href="http://www.morechevrolet.com/">More Chevrolet</a></b>. Auto dealer site build completely with Code Igniter, with full administrative and CMS.</p>

<p><b><a href="http://www.reggaeplanet.pl/">Reggae Planet</a></b>, <b><a href="http://www.metaltown.pl/">Metal Town</a></b>, <b><a href="http://www.punkspace.pl/">Punk Space</a></b>. Polish e-shops for reggae, metal and punk music fans.</p>

<p><b><a href="http://www.gayticketshop.nl/">Gayticketshop.nl</a></b> - Dutch webshop for ordering tickets for (gay) parties and events. Built and maintained in latest CI version.</p>

<p><b><a href="http://www.solid.lt/">Solid.lt</a></b>. Lithuanian hosting provider.</p>

<p><b><a href="http://www.webhostninja.com/">WebHostNinja.com</a></b>. Price and feature comparison for web hosting.</p>

<p><b><a href="http://d.sumy.ua/mng/">Music News Generator</a></b> - lets you generate music release news code (BB-Code, XHTML code and any other) for blogs, forums etc. using data recieved from <a href="http://www.discogs.com/">Discogs</a> and <a href="http://www.last.fm/">Last.fm</a> music community sites.</p>

<p><b><a href="http://randomtextgenerator.com/">Random Text Generator</a></b> An online tool for generating random text to use in web pages designs, site templates and typography demos. Plain text or HTML output.</p>

<p><b><a href="http://www.mediaroost.com/">TweetRoost</a></b><br />
TweetRoost helps individuals and groups efficiently monitor, assign, categorize, save and analyze tweets from one or multiple Twitter accounts.</p>

<p><b><a href="http://www.lankamatters.com/">Lanka Matters</a></b><br />
Lanka matters is a real estate completely free website offers to deal with property dealings in Sri Lanka.</p>

<p><b><a href="http://www.athensmenu.gr/">AthensMenu</a></b><br />
A website with reviews about restaurants in Athens, Greece.</p>

<h3>Work-in-progress projects using Code Igniter</h3>

<p><b><a href="http://lumberjackapp.com/">Lumberjack App</a></b> - A remote logging server which allows web apps to transmit logs for tracking and analyzing.</p>

<p><b><a href="http://cornnery.kelio.org/">morel cornnery</a></b>. a project Meeting site based on CI  1.5.4 from dakar senegal  .</p>

<p><b><a href="http://franchisebean.com/">Franchise Bean</a></b>. An online resource for franchise companies that allows to set up profiles and generate leads.</p>

<p><b><a href="http://www.digital-design.it/">Digital Design</a></b> a website built on CI 1.4.1, jquery js/ajax library and some google api flavour. Still under construction. They plan to release the source when they are done.</p>

<p><b><a href="http://www.interlinkairlines.com/">Interlink Airlines</a></b> Still under construction, due for release soon. Complete rewrite of Airline booking system + admin facility + major features upgrade.</p>

<p><b><a href="http://www.granitiworld.com/">GranitiWorld</a></b> - Just a personal site about Graniti, Italy.</p>

<p><b><a href="http://www.lovetech.net/">Lovetech</a></b>&nbsp; - Personal website. Started Dec 06. Heading for commerical cms. Or for charity. Or both. Still practicing, Finland.</p>

<p><b><a href="http://3m2.net/sl/vouge/"> SLVouge </a> </b> - Web Site for an already active Second Life Fashion Magazine. Not yet finished and still in development.</p>

<p><b><a href="http://www.overfood.com/"> overfood.com </a> </b> - The site currently features a restaurant search of the Chefmoz database with restaurants mapped using Google Maps. The search uses xajax for an autocomplete when searching by city. It also uses the mootools accordion effect to switch between search types. </p>

<p><b><a href="http://www.mobilu.lt/">Mobilu.lt</a></b>. Lithuanian site. It&#8217;s cell phones classifieds system. Built on CI 1.5.3. Uses a little bit of XAJAX library.</p>

<p><b><a href="http://www.dwi.web.id/">Blog System</a></b>. An Indonesian CMS Blog, will release the source when it have done.</p>

<p><b><a href="http://www.beezwaxx.com/">Beezwaxx!</a></b>. Safe, secure, online email app for kids. Currently in closed beta.</p>

<p><b><a href="http://itemio.de/">itemio</a></b>. Social Bookmarking site for products based on CI</p>

<p><b><a href="http://ufashion.de/">ufashion</a></b>. German Fashion Community using CodeIgniter and JQuery</p>

<p><b><a href="http://gravial.com/">Gravial</a></b> - Community oriented content publishing platform. Under development.</p>

<p><b><a href="http://www.buildtracks.com/">Tracks</a></b> - An add-on for Highrise CRM (37signals) that allows users to manage and forecast their sales pipeline. Currently in Alpha. Built and styled with JQuery Mobile for primary use on tablets and smart phones. Works on desktops too. CI version 2.1.0.</p>

<h3>Websites using Code Igniter</h3>

<p><b><a href="http://www.portaimprese.it">Portaimprese</a></b>. Directory site for companies in and around Rome based on CodeIgniter 2.0.</p>

<p><b><a href="http://edgetube.com">EdgeTube Cellular</a></b>. Online cell phone store based on CodeIgniter 2.0.</p>

<p><b><a href="http://ratemymechanic.us">Rate My Mechanic</a></b>. Rate My Mechanic is a website based on helping people find mechanics they can trust based on user ratings and reviews.</p>

<p><b><a href="http://appliedcodingtech.com">Applied Coding Technologies</a></b>. Applied Coding Technologies is a company that specializes in printing and coding machinery for industrial use.</p>

<p><b><a href="http://kanji.ligona.org/">Mainichi Kanji</a></b> Is a Kanji dictionary based on CI 1.7.2.</p>

<p><b><a href="http://www.bientek.com/">BienTek</a></b> is a computer repair business with a contractor job dispatch system written from the ground-up in CI 1.7.2.</p>

<p><b><a href="http://resipiscent.com/">Resipiscent</a></b>.&nbsp; San Francisco experimental record label and the record label CMS that powers it, built on CodeIgniter 1.7.2.</p>

<p><b><a href="http://www.blueice.com/">blueice.com</a></b>.&nbsp; High-quality mountaneering equipment, ecommerce built on CodeIgniter 1.7.2.</p>

<p><b><a href="http://allegiancelaw.com/">Allegiance Law</a></b>.&nbsp; San Francisco Bay Area personal injury and employment attoryneys, built on CodeIgniter 1.7.2.</p>

<p><b><a href="http://kazoosoft.eu">KazooSoft.eu</a></b>. Website &amp; Software development, Marketing and Twitter promotions</p>

<p><b><a href="http://pulsarcap.com/">Pulsar Capital Limited</a></b>. An International Proprietary Trading Firm.</p>

<p><b><a href="http://unggulnews.com/">News Update and Bussines Center - UnggulNews</a></b>. An online News website.</p>

<p><b><a href="http://site2text.com/">Site2Text.com - 2-Way Site to Text</a></b>. A service allowing customers to send you a SMS text message via your site and allowing you to respond like any normal SMS text back to the customer on your site. Chat using just a SMS text message. No gateways fees. </p>

<p><b><a href="http://tctransit.mobi/">TCTransit.mobi - Twin Cities Transit: Mobile</a></b>. Provide transit data to Twin Cities (Minnesota, USA) commuters in a manner friendly to iPhone and Android devices. Based on CI 1.7.2.</p>

<p><b><a href="http://panturanews.com/">News Online - PanturaNews</a></b>. An online News website.</p>

<p><b><a href="http://ponpesassalafiyah.com/">The Islamic Boarding Schools</a></b>.Pondok Pesantren Assalafiyah</p>

<p><b><a href="http://www.unggulresearch.com/">The IT Solution</a></b>.Unggul Research</p>

<p><b><a href="http://www.operamage.com">Prodotti Tipici</a></b> - Vendita online di prodotti tipici | Italian special alimentar products e-Commerce</p>

<p><b><a href="http://bestpartyever.com">Party Ideas and Party Planning</a></b> - at bestpartyever.com - CI,1.6.1</p>

<p><b><a href="http://www.rsciranjang.com">Rumah Sakit Ciranjang</a></b> - Ciranjang Hospital Website. Based on CI 1.6</p>

<p><b><a href="http://www.diksphoto.com">Dik&#8217;s Photography</a></b> - Indonesian Photographer Website. Based on CI 1.5</p>

<p><b><a href="http://www.spiceit.co.uk/">SpicY Web+Design</a></b> - Website based on CI 1.5</p>

<p><b><a href="http://www.networkartisan.co.uk/">Network Artisan</a></b> - UK catering supplier based on CI 1.5.</p>

<p><b><a href="http://www.422south.com/">422 South</a></b> - VFX House website based on CI 1.5</p>

<p><b><a href="http://www.michel-ange.fr/">Michel-Ange Kuntz - Photo blog</a></b> - Built using CI 1.5. Back-office : &#8220;Partikule CMS&#8221; based on CI 1.5.</p>

<p><b><a href="http://www.wissamjoubran.com/">Wissam Joubran website</a></b> - Wissam Joubran luthier web site. Front-end based on Code Igniter. Back-office : &#8220;Partikule CMS&#8221; based on Code Igniter.</p>

<p><b><a href="http://www.sheybal.waw.pl/">Aleksandra Sheybal &amp; Family</a></b> - first version of private family website (it&#8217;s still growing with features - if it&#8217;s too small - please remove it from list ;-))</p>

<p><b><a href="http://www.tomwelshbuilder.com/">Thomas Welsh Builders, LLC</a></b> Built using CI 1.5, has property management backend and more - 100% CI!</p>

<p><b><a href="http://c7.se/">c7 mobile blog</a></b> - Personal moblog, updated to Code Igniter over one evening.</p>

<p><b><a href="http://browniethecow.org/">BrownieTheCow.org</a></b> - School testing activist web site. All Code Igniter (front and backend) and a bit of jQuery.<br />
<b><a href="http://wissahickon.patrails.org/">Wissahickon Restoration Volunteers</a></b> - Environmental group / member-supported, volunteer-driven nonprofit. All CI.<br />
<b><a href="http://www.theclientele.co.uk/">www.theclientele.co.uk</a></b> - web site for the band &#8216;the clientele&#8217; (merge records). </p>

<p><b><a href="http://pipasforthepeople.com/">pipasforthepeople.com</a></b> - band web site. tour dates, blog stuff and the rest of the site all done with CI.</p>

<p><b><a href="http://www.pixelsandcode.net/">Pixels and Code, LLC</a></b> - Forward-thinking web design and development</p>

<p><b><a href="http://www.systematix.co.uk/">Systematix Computer Training</a></b> - UK commercial training website rewritten in CI 1.5.1</p>

<p><b><a href="http://www.jomm.nl/">Jongbloed MultiMedia</a></b>. Home of Dutch Freelance webdeveloper Auke Jongbloed. Front and back-end build in CI 1.5.2 using mootools for effects.</p>

<p><b><a href="http://www.club-3d.com/">Club 3D </a></b>. Graphics and Multimedia card company. Front and back-end build in CI 1.5.2 extended with Xajax library.</p>

<p><b><a href="http://www.monpatelin.fr/">MonPatelin.fr</a></b>. French website of local classifieds.</p>

<p><b><a href="http://rmcreative.ru/">RMCreative</a></b>. Sam Dark&#8217;s custom blog written from scratch with CI.</p>

<p><b><a href="http://www.lirikita.com/">Lirikita</a></b>. Lyric and  video download written from scratch with CI.</p>

<p><b><a href="http://www.scholl.com.pl/">Scholl</a></b>. Shoes and foot care company - polish version written from scratch with CI.</p>

<p><b><a href="http://www.moyvkus.ru/">MoyVkus.ru</a></b>. Food Social Network.</p>

<p><b><a href="http://www.drimr.com/">DrimR.com</a></b>. Music Social Network</p>

<p><b><a href="http://www.thebuzz.co.il/">thebuzz.co.il</a></b>. Real-time news aggregation of financial and business news in Israeli media (in Hebrew).</p>

<p><b><a href="http://www.backabuddy.co.za/">Backabuddy</a></b>. Online fundraising -&nbsp; speedy solution to donating and raising money for charity!, .</p>

<p><b><a href="http://www.openopp.ca">OpenOpp</a></b> - Specializing in Job Marketing and Perpetual Sourcing of top talent, our careers microsites can fully integrate with your existing corporate website, they are available instantly, and they enable millions of active, passive, and future job seekers to find your jobs first.</p>

<p><b><a href="http://www.dennismonsewicz.com">dennismonsewicz.com</a></b> - Personal blog about PHP, terminal and weight loss</p>

<p><b>Autolink Media</b> - Large group of <a href="http://www.autolinkmedia.com">Used Car</a> websites / Marque dedicated car portals.</p>

<p><b><a href="http://faveone.com">Faveone</a></b> - A fun site to vote on this vs thats and learn more about your friends.</p>

<p><b><a href="http://www.onlinemachinist.com">Online Machinist</a></b> - Create custom parts online.</p>

<p><b><a href="http://www.vinos.com">Vinos.com</a></b> - The site for wine enthusiasts and professionals.</p>

<p><b><a href="http://www.goingclubing.com/">New York Nightlife</a></b>. An event listing site.&nbsp; Featuring nightlife events in the NY area.</p>

<p><b><a href="http://www.southsidesalesandrental.com/">Southside Sales and Rental</a></b> - Manages the online inventory for the car dealership.</p>

<p><b><a href="http://www.nyfreelancers.com/">New York Job Board</a></b>. Basic Job Board built on CI 2.0</p>

<h3>Other Helpful Links</h3>

<p><b><a href="http://en.wikipedia.org/wiki/Social_media">Social Media</a></b> - media designed to be disseminated through social interaction</p>

<p><b><a href="http://www.seop.com/social-media-marketing/">Social Media Marketing</a></b> -&nbsp; help your site gain more visibility, popularity, solidify your brand and promote your products and services</p>

<p><b><a href="http://deskhot.com/">Deskhot.com</a></b>- Deskhot is a free bookmark manager with a focus on speed.</p>]]></description>
      <dc:subject>Applications Using Code Igniter</dc:subject>
      <dc:date>2012-05-22T00:10:53+00:00</dc:date>
    </item>

    <item>
      <title>mod rewrite</title>
      <link>http://codeigniter.com/wiki/mod_rewrite</link>
      <guid>http://codeigniter.com/wiki/mod_rewrite</guid>
      <description><![CDATA[<p><a href="http://codeigniter.com/wiki/Category:Help::ApacheConfig" title="Category:Help::ApacheConfig">Category:Help -&gt; ApacheConfig</a></p>

<p>This article explains how to take away &#8220;index.php&#8221; from your CI application URLs. However, it does NOT remove the need for Index.php, which is the CI front controller i.e. even though Index.php will not appear in the URL, it still needs to be present at the top level of your site (above the /system/ directory).&nbsp; To quote the User Guide,</p>

<blockquote><p>You can easily remove this file by using a .htaccess file with some simple rules.</p>
</blockquote>

<p>You need to perform the following steps to get this working:</p>

<p><b>1. Create a .htaccess file to configure the rewrite engine</b></p>

<p><b>2. Set $config[&#8216;index_page&#8217;] to an empty string</b></p>

<p><b>3. Make sure your apache uses the mod_rewrite module</b></p>

<p><b>4. Make sure apache is configured to accept needed .htaccess directives</b></p>

<p><b>5. Restart apache and test</b></p>

<h3>1. Create your .htaccess file</h3>

<p>Create a new file named .htaccess and put it in your web directory</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">IfModule&nbsp;mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">c</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteEngine&nbsp;On<br />&nbsp;&nbsp;&nbsp;&nbsp;RewriteBase&nbsp;</span><span style="color: #007700">/<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Removes&nbsp;access&nbsp;to&nbsp;the&nbsp;system&nbsp;folder&nbsp;by&nbsp;users.<br />&nbsp;&nbsp;&nbsp;&nbsp;#Additionally&nbsp;this&nbsp;will&nbsp;allow&nbsp;you&nbsp;to&nbsp;create&nbsp;a&nbsp;System.php&nbsp;controller,<br />&nbsp;&nbsp;&nbsp;&nbsp;#previously&nbsp;this&nbsp;would&nbsp;not&nbsp;have&nbsp;been&nbsp;possible.<br />&nbsp;&nbsp;&nbsp;&nbsp;#'system'&nbsp;can&nbsp;be&nbsp;replaced&nbsp;if&nbsp;you&nbsp;have&nbsp;renamed&nbsp;your&nbsp;system&nbsp;folder.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_URI&#125;&nbsp;</span><span style="color: #007700">^</span><span style="color: #0000BB">system</span><span style="color: #007700">.*<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;/</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#When&nbsp;your&nbsp;application&nbsp;folder&nbsp;isn't&nbsp;in&nbsp;the&nbsp;system&nbsp;folder<br />&nbsp;&nbsp;&nbsp;&nbsp;#This&nbsp;snippet&nbsp;prevents&nbsp;user&nbsp;access&nbsp;to&nbsp;the&nbsp;application&nbsp;folder<br />&nbsp;&nbsp;&nbsp;&nbsp;#Submitted&nbsp;by:&nbsp;Fabdrol<br />&nbsp;&nbsp;&nbsp;&nbsp;#Rename&nbsp;'application'&nbsp;to&nbsp;your&nbsp;applications&nbsp;folder&nbsp;name.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_URI&#125;&nbsp;</span><span style="color: #007700">^</span><span style="color: #0000BB">application</span><span style="color: #007700">.*<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;/</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Checks&nbsp;to&nbsp;see&nbsp;if&nbsp;the&nbsp;user&nbsp;is&nbsp;attempting&nbsp;to&nbsp;access&nbsp;a&nbsp;valid&nbsp;file,<br />&nbsp;&nbsp;&nbsp;&nbsp;#such&nbsp;as&nbsp;an&nbsp;image&nbsp;or&nbsp;css&nbsp;document,&nbsp;if&nbsp;this&nbsp;isn't&nbsp;true&nbsp;it&nbsp;sends&nbsp;the<br />&nbsp;&nbsp;&nbsp;&nbsp;#request&nbsp;to&nbsp;index.php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">f<br />&nbsp;&nbsp;&nbsp;&nbsp;RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">d<br />&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">IfModule</span><span style="color: #007700">&gt;<br /><br />&lt;</span><span style="color: #0000BB">IfModule&nbsp;</span><span style="color: #007700">!</span><span style="color: #0000BB">mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">c</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#&nbsp;If&nbsp;we&nbsp;don't&nbsp;have&nbsp;mod_rewrite&nbsp;installed,&nbsp;all&nbsp;404's<br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;can&nbsp;be&nbsp;sent&nbsp;to&nbsp;index.php,&nbsp;and&nbsp;everything&nbsp;works&nbsp;as&nbsp;normal.<br />&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Submitted&nbsp;by:&nbsp;ElliotHaughin<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ErrorDocument&nbsp;404&nbsp;</span><span style="color: #007700">/</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">IfModule</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>The above configuration behaves as follows:</p>

<p>1. If your installation is not in the server root you will need to amend the RewriteBase line from &#8220;RewriteBase /&#8221; to &#8220;RewriteBase /folder/&#8221;</p>

<p>2. Checks to see if someone has entered a URL starting with &#8220;system&#8221;, all requests like this get routed to index.php, this is a security feature that removes the possibility of anyone directly accessing your system folder. You can use the same syntax to hide other folders inside your root if you want.</p>

<p>3. If the URL doesn&#8217;t start with &#8220;system&#8221;, the web server will check to see if there is a corresponding physical resource matching the URL, such as an image, script file, or directory.</p>

<p>4. If such a resource exists, that resource is returned by the webserver with no rewriting performed. If no such resource exists the url is rewritten to index.php (passed to codeigniter)</p>

<p>Notes for Windows users:<br />
To create this file you must open Command Prompt and type:<br />
copy con .htaccess [Enter]<br />
[Press CTRL + Z]<br />
A blank .htaccess file will be created. Now you can edit it using Notepad or your favorite text editor and copy the script above.</p>

<p>Note: Most Windows editors will assume that you are attempting to save an .htaccess file as a file with an extension and no filename. The Crimson Editor can be used to create and save .htaccess files and other files that have no filename. </p>

<p>Note: If your site is placed in subfolder specify the path in the &#8220;RewriteBase /subfolder/&#8221; line.</p>

<p>Note: When using the above example on some systems it may be necessary to specify the uri_protocol configuration value to achieve reliable results. (Otherwise values with periods that are passed via URI will be converted to underscores in CodeIgniter 1.7.1 eg: some.value becomes some_value)</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'uri_protocol'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'QUERY_STRING'</span><span style="color: #007700">;&nbsp;</span>
</span>
</code></div>

<h3>2. Set $config[&#8216;index_page&#8217;]&nbsp; to an empty string</h3>
<p>Open your</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">system</span><span style="color: #007700">/</span><span style="color: #0000BB">application</span><span style="color: #007700">/</span><span style="color: #0000BB">config</span><span style="color: #007700">/</span><span style="color: #0000BB">config</span><span style="color: #007700">.</span><span style="color: #0000BB">php&nbsp;</span>
</span>
</code></div><p> and find the line that assigns $config[&#8216;index_page&#8217;] a value, usually:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'index_page'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"index.php"</span><span style="color: #007700">;&nbsp;</span>
</span>
</code></div>

<p>and change it to:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'index_page'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;&nbsp;</span>
</span>
</code></div>

<p>Save the file.</p>

<h3>3. Make sure your apache has mod_rewrite activated</h3>
<p>This means that the apache must be configured to load the mod_rewrite module (or it might have it compiled-in). For module inclusion, usually you have to look for a line like this in httpd.conf or a file loaded by it (hint: use some quick file search utility to grep files with lines containing &#8216;rewrite&#8217; string):</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">LoadModule&nbsp;rewrite_module&nbsp;</span><span style="color: #007700">/</span><span style="color: #0000BB">usr</span><span style="color: #007700">/</span><span style="color: #0000BB">lib</span><span style="color: #007700">/</span><span style="color: #0000BB">apache2</span><span style="color: #007700">/</span><span style="color: #0000BB">modules</span><span style="color: #007700">/</span><span style="color: #0000BB">mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">so&nbsp;</span>
</span>
</code></div>

<p>If you&#8217;re running Apache2 type</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">a2enmod&nbsp;</span>
</span>
</code></div> in the console and when prompted <div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">rewrite&nbsp;</span>
</span>
</code></div><p> to enable mod_rewrite.</p>

<p>On a Windows machine this line might look this way:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">LoadModule&nbsp;rewrite_module&nbsp;modules</span><span style="color: #007700">/</span><span style="color: #0000BB">mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">so&nbsp;</span>
</span>
</code></div>

<p>If it is commented out (# in front), make sure to uncomment it and save the file. Checking if the corresponding module exists may be a good idea as well (but it usually does).</p>

<h3>4. Make sure apache accepts needed .htaccess directives</h3>
<p>This means that apache is explicitly configured to allow .htaccess files to override those directives that you use in your .htaccess file from step 1. above.</p>

<p>It seems to be sufficient if you add these two lines to your &lt;Directory&gt; section where you configure the document root for your CI application:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">Directory&nbsp;</span><span style="color: #DD0000">"/some/absolute/path/htdocs"</span><span style="color: #007700">&gt;<br />...<br /></span><span style="color: #0000BB">Options&nbsp;FollowSymLinks<br />AllowOverride&nbsp;FileInfo<br /></span><span style="color: #007700">...&nbsp;&nbsp;<br />&lt;/</span><span style="color: #0000BB">Directory</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>There might be other Options listed, just make sure you have <b>FollowSymLinks</b> as well.</p>

<p>Should you get a 500 Internal Server Error, try the following syntax:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">Directory&nbsp;</span><span style="color: #DD0000">"/some/absolute/path/htdocs"</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">Options&nbsp;Indexes&nbsp;Includes&nbsp;FollowSymLinks&nbsp;MultiViews<br />AllowOverride&nbsp;AuthConfig&nbsp;FileInfo<br />Order&nbsp;allow</span><span style="color: #007700">,</span><span style="color: #0000BB">deny<br />Allow&nbsp;from&nbsp;all<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">Directory</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<h3>5. Restart apache and test your application</h3>

<p><b>Works? Congratulations!</b></p>

<p>Doesn&#8217;t work? Ehrrr&#8230; well, do not give up; equip yourself with patience, double check all steps above and if it still does not work, post on the forum giving all details of your setup.</p>

<h3>How does URL rewriting work?</h3>
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">IfModule&nbsp;mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">c</span><span style="color: #007700">&gt;<br />...<br />&lt;/</span><span style="color: #0000BB">IfModule</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>
<p>Do what is inside only if Apache has the mod_rewrite feature (by in place compilation, or loaded module).</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">RewriteEngine&nbsp;On&nbsp;</span>
</span>
</code></div>
<p>Activate the URL rewriting engine, if not already done (in main Apache configuration file.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">RewriteBase&nbsp;</span><span style="color: #007700">/&nbsp;</span>
</span>
</code></div>
<p>Define the part of the URL that won&#8217;t change nor be used for rewriting. In fact, this part will be removed before processing, and prepended after processing. This&#8217;s a good way to use subfolder-independent rewrite rules. For example, if your CodeIgniter index.php is placed in a virtual host directory, like /tests/, set RewriteBase to /tests/.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">f&nbsp;</span>
</span>
</code></div>
<p>Condition to meet for RewriteRule activation. Here, we test if the requested filename does not exist.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">d&nbsp;</span>
</span>
</code></div>
<p>Same as above, but we test for directory existence.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;&nbsp;</span>
</span>
</code></div>
<p>If RewriteCond conditions are met, this rule will be applied. It inserts index.php before the requested URI. The $1 represents the part of string enclosed by parentheses in left expression. The [L] means that this rule is the last one if rule is applied (thus stopping rewriting).</p>

<h2>Configuring mod_rewrite in the httpd.conf file</h2>

<p>The Apache mod_rewrite docs say</p><blockquote><p>While URL manipulations in per-server context are really fast and efficient, per-directory rewrites are slow and inefficient&#8230;</p>
</blockquote><p>. If you have access to your httpd.conf file, you&#8217;ll have better performance if you configure the rewrite rules in there.</p>

<p>You can add something like this to your httpd.conf:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">IfModule&nbsp;mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">c</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">RewriteEngine&nbsp;On<br />RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_URI&#125;&nbsp;</span><span style="color: #007700">!^(/</span><span style="color: #0000BB">index\</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">|/</span><span style="color: #0000BB">img</span><span style="color: #007700">|/</span><span style="color: #0000BB">js</span><span style="color: #007700">|/</span><span style="color: #0000BB">css</span><span style="color: #007700">|/</span><span style="color: #0000BB">robots\</span><span style="color: #007700">.</span><span style="color: #0000BB">txt</span><span style="color: #007700">|/</span><span style="color: #0000BB">favicon\</span><span style="color: #007700">.</span><span style="color: #0000BB">ico</span><span style="color: #007700">)<br /></span><span style="color: #0000BB">RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;/</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">IfModule</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<h2>Configuring mod_rewrite and virtual hosting with Apache 2.2</h2>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">VirtualHost&nbsp;</span><span style="color: #007700">*&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ServerName&nbsp;www</span><span style="color: #007700">.</span><span style="color: #0000BB">mydomain</span><span style="color: #007700">.</span><span style="color: #0000BB">com<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot&nbsp;</span><span style="color: #007700">/</span><span style="color: #0000BB">path</span><span style="color: #007700">/</span><span style="color: #0000BB">to</span><span style="color: #007700">/</span><span style="color: #0000BB">ci</span><span style="color: #007700">/</span><span style="color: #0000BB">directory<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">Directory&nbsp;</span><span style="color: #007700">/</span><span style="color: #0000BB">path</span><span style="color: #007700">/</span><span style="color: #0000BB">to</span><span style="color: #007700">/</span><span style="color: #0000BB">ci</span><span style="color: #007700">/</span><span style="color: #0000BB">directory</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteEngine&nbsp;On<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RewriteBase&nbsp;</span><span style="color: #007700">/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">f<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">d<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">Directory</span><span style="color: #007700">&gt;<br />&lt;/</span><span style="color: #0000BB">VirtualHost</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<h2>Apache 2.2 Shared Host .htaccess to protect application and system folders</h2>

<p>First, you will need to remove all .htaccess files from the system and application directories ( back them up just in case your hosting solution doesn&#8217;t accept this method )</p>

<p>Second, place an .htaccess file with the following code in it.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">IfModule&nbsp;mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">c</span><span style="color: #007700">&gt;<br />&nbsp;<br />&nbsp;</span><span style="color: #FF8000">#&nbsp;Enable&nbsp;URI&nbsp;Rewriting<br />&nbsp;</span><span style="color: #0000BB">RewriteEngine&nbsp;On<br />&nbsp;RewriteBase&nbsp;</span><span style="color: #007700">/<br /><br />&nbsp;</span><span style="color: #FF8000">#&nbsp;Protect&nbsp;special&nbsp;folders&nbsp;from&nbsp;access<br />&nbsp;</span><span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_URI&#125;&nbsp;</span><span style="color: #007700">^/(</span><span style="color: #0000BB">application</span><span style="color: #007700">|</span><span style="color: #0000BB">system</span><span style="color: #007700">)/(.*)$<br />&nbsp;</span><span style="color: #0000BB">RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;<br /><br />&nbsp;</span><span style="color: #FF8000">#&nbsp;If&nbsp;object&nbsp;does&nbsp;not&nbsp;exist,&nbsp;process&nbsp;through&nbsp;index.php<br />&nbsp;</span><span style="color: #0000BB">RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">f<br />&nbsp;RewriteCond&nbsp;</span><span style="color: #007700">%</span><span style="color: #0000BB">&#123;REQUEST_FILENAME&#125;&nbsp;</span><span style="color: #007700">!-</span><span style="color: #0000BB">d<br />&nbsp;RewriteRule&nbsp;</span><span style="color: #007700">^(.*)$&nbsp;</span><span style="color: #0000BB">index</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">/$</span><span style="color: #0000BB">1&nbsp;&#91;L&#93;&nbsp;<br /><br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">IfModule</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>If all is well, requests to the server should treat the application and system directories as if they don&#8217;t exist and process all requests through index.php.<br />
Use this method only if you can not edit your virtual host settings directly.</p>]]></description>
      <dc:subject>mod rewrite</dc:subject>
      <dc:date>2012-05-21T00:16:37+00:00</dc:date>
    </item>

    <item>
      <title>Ajax Framework For CodeIgniter</title>
      <link>http://codeigniter.com/wiki/Ajax_Framework_For_CodeIgniter</link>
      <guid>http://codeigniter.com/wiki/Ajax_Framework_For_CodeIgniter</guid>
      <description><![CDATA[<p><a href="http://codeigniter.com/wiki/Category:Ajax_Frameworks" title="Category:Ajax_Frameworks">Category:Ajax Frameworks</a><br />
<a href="http://codeigniter.com/wiki/Category:Library::AJAX" title="Category:Library::AJAX">Category:Library -&gt; AJAX</a><br />
<a href="http://codeigniter.com/wiki/Category:Ajax_applications" title="Category:Ajax_applications">Category:Ajax applications</a></p>

<p>A very basic but powerful implementation of Ajax Framework that complements Codeigniter.</p>

<h3>Download here:</h3>
<blockquote>
<p><a href="http://code.google.com/p/ajax-framework-for-codeigniter/downloads/list">http://code.google.com/p/ajax-framework-for-codeigniter/downloads/list</a></p>
</blockquote>

<p>Cjax Framework separates your ajax controllers from your regular controllers. While your normal controllers reside in application/controllers, your ajax controllers will reside in application/response.</p>

<h2>Install</h2><p>Download and unzip the Ajax Framework package, then just overwrite everything  from the zip into your CodeIgniter base installation (will not replace any of your files)</p>

<h2>Test</h2><p> just go to: <br />
http://yoursite.com/ajax.php?test/test</p>

<p>(replace http://yoursite.com with the base directory where your CodeIgniter installation resides)</p>

<p>To this point you are done, successfully installing and using Cjax, if the test above prints &#8220;Ajax View..&#8221;. You can find this text inside file application/views/test.php, and its controller in application/response/test.php.</p>

<p><i><b>20+ </b> </i><b>Demos:</b></p><blockquote><p><a href="http://code.google.com/p/ajax-framework-for-codeigniter/downloads/list">http://code.google.com/p/ajax-framework-for-codeigniter/downloads/list</a> (AJAXFW_EXAMPLES_1x.zip)</p>
</blockquote><p> </p>

<p><i>Usage of demos: </i>just place the “Examples” directory that comes in the zip, into your CI installation, and go to the URL:&nbsp; /examples in your CI Installation, make sure to install the AJAX Framework first..</p>

<p><b>ChangeLog:</b></p><blockquote><p><a href="http://code.google.com/p/ajax-framework-for-codeigniter/source/browse/trunk/CHANGELOG.txt">http://code.google.com/p/ajax-framework-for-codeigniter/source/browse/trunk/CHANGELOG.txt</a></p>
</blockquote>

<h3>Friendly URLS</h3>

<p>Full support for friendly URLS.</p>

<p>Friendly URLS are supported, but not required to use Cjax. <br />
You may access your controllers in any of the following ways; these examples make use of controller file application/response/test.php.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #FF8000">//ajax.php?controller=$controller&amp;function;=$function<br /></span><span style="color: #0000BB">ajax</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?</span><span style="color: #0000BB">controller</span><span style="color: #007700">=</span><span style="color: #0000BB">test</span><span style="color: #007700">&amp;function=</span><span style="color: #0000BB">test<br /></span><span style="color: #FF8000">//ajax.php?$controller/$function<br /></span><span style="color: #0000BB">ajax</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?</span><span style="color: #0000BB">test</span><span style="color: #007700">/</span><span style="color: #0000BB">test<br /></span><span style="color: #FF8000">//ajax/$controller/$function<br />#This&nbsp;one&nbsp;requires&nbsp;mod_rewrite<br /></span><span style="color: #0000BB">ajax</span><span style="color: #007700">/</span><span style="color: #0000BB">test</span><span style="color: #007700">/</span><span style="color: #0000BB">test&nbsp;</span>
</span>
</code></div>

<p>The last url above, will require you to enable mod_rewrite in your server and rename the accompanied file htaccess.txt  <a href="http://codeigniter.com/wiki/File:htaccess.txt" title="File:htaccess.txt" class="noArticle">File:htaccess.txt</a> to .htacccess</p>

<h2>Creating Controllers</h2>

<p>Creating controllers works the same way as your regular controllers,&nbsp; except the class name of ajax controller start with the keyword &#8220;controller_&#8221;. For example, if you want to create a controller named test,&nbsp; then your class name would be &#8220;controller_test&#8221;.</p>

<h3>Example</h3>
<p>application/response/test.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br /><br />&#125;&nbsp;</span>
</span>
</code></div>
<p>You may use your ajax controller the same way you would use any other CI controller including the creation of any dependencies.</p>

<h2>Passing Parameters</h2>

<p>Cjax uses URL query string to pass parameters into the controller by using function parameters. You can pass alphabetic letters as parameter order to your methods inside the controllers. There is more than one way to pass parameters, depending on the way you are using the URL.</p>

<p>Example of passing parameters in followed order.</p>

<p>URL:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">ajax</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?</span><span style="color: #0000BB">test</span><span style="color: #007700">/</span><span style="color: #0000BB">test</span><span style="color: #007700">/</span><span style="color: #0000BB">arg1</span><span style="color: #007700">/</span><span style="color: #0000BB">someID<br /></span><span style="color: #FF8000">//&nbsp;this&nbsp;also&nbsp;applies&nbsp;to&nbsp;mod_rewrite&nbsp;urls&nbsp;such&nbsp;as:&nbsp;ajax/test/test/arg1/someID&nbsp;</span>
</span>
</code></div>
<p>The  above URL is passing two parameters arg2 and someID, test/test indicates the controller and the method.&nbsp; To access these parameters use function arguments:</p>

<h3>Example</h3>
<p>application/response/test.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$arg1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arg2</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$arg1</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$arg2</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//prints&nbsp;&nbsp;arg1<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;someID<br /></span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>You can pass unlimited number of parameters, and access them through function parameters in the same order they are passed.&nbsp; </p>

<p>&nbsp;</p>

<h4>Alphabetic order Parameters</h4>
<p>A less Organized way to pass parameters that may accept any order within the URL: </p>

<p>URL:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">ajax</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?</span><span style="color: #0000BB">controller</span><span style="color: #007700">=</span><span style="color: #0000BB">test</span><span style="color: #007700">&amp;function=</span><span style="color: #0000BB">test</span><span style="color: #007700">&amp;</span><span style="color: #0000BB">a</span><span style="color: #007700">=</span><span style="color: #0000BB">Hello</span><span style="color: #007700">&amp;</span><span style="color: #0000BB">b</span><span style="color: #007700">=</span><span style="color: #0000BB">World</span><span style="color: #007700">&amp;</span><span style="color: #0000BB">c</span><span style="color: #007700">=</span><span style="color: #0000BB">Hello&nbsp;World&nbsp;</span>
</span>
</code></div>

<p>The previous URL, makes use of common URL, and passes three parameters to the controller.</p>

<p>This methods accepts any alphabetic letter in respective order to pass parameters. You may pass: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, which will be accessible through function parameter. Using this method also allows you to pass any other parameters through outside of the function parameter scope.</p>

<h3>Example</h3>
<p>application/response/test.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//prints&nbsp;&nbsp;Hello<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;World<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hello&nbsp;World<br /></span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<h2>Advanced Usage</h2>

<p><br />
Bellow are some more advanced ways to use this ajax framework. The level of expertize required is advanced intermediate, if you feel confident, do read through it. Not all the APIs will be covered here, however some of the most used ones will.</p>

<h2>Using Ajax Framework JavaScript Library</h2>
<p>So far you have experienced the basic power of this framework through a php environment, but this framework also offers a taste of JavaScript.</p>

<p><br />
To initialize the JavaScript library included with Cjax, include file in the head of your HTML document:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">cjax</span><span style="color: #007700">/</span><span style="color: #0000BB">core</span><span style="color: #007700">/</span><span style="color: #0000BB">js</span><span style="color: #007700">/</span><span style="color: #0000BB">cjax</span><span style="color: #007700">.</span><span style="color: #0000BB">min</span><span style="color: #007700">.</span><span style="color: #0000BB">js&nbsp;</span>
</span>
</code></div>

<h3>Event Request</h3>

<p>The purpose of this section is to illustrate how to use utilities included within the framework, and how they are executed, not necessarily how to use ajax.</p>

<p>The js Lib, offers two event request types, which are executed when page first loads  and each time you make an ajax request.</p>

<p>You may use this Framework to create ajax requests or you may use any other method, but we recommend either using this framework or using Jquery. See at the  bottom of this page how to integrate this framework with any other ajax request application or method. </p>

<h3>Framework Usage of JavaScript</h3>

<p>This framework does not make use of JavaScript directly. It does however uses the js lib indirectly, by creating XML or Json commands that are later passes to the interpreter which executes the XML commands which fires functions included in the js library (cjax.min.js).</p>

<p>This allows you to create all your ajax framework code in a php environment, rather than a JavaScript one.</p>

<h3>Create ajax request</h3>

<p>Within your main controller, include file ajaxfw.php</p>

<p>in your main controller:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">file&#40;FCPATH</span><span style="color: #007700">.</span><span style="color: #DD0000">'ajaxfw.php'</span><span style="color: #0000BB">&#41;</span><span style="color: #007700">;&nbsp;</span>
</span>
</code></div>

<p>Then you can make full use of the ajax framework in a local scope within your controller. </p>

<p>You may instantiate ajax by using the following method:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();&nbsp;</span>
</span>
</code></div>

<p>&nbsp;</p>

<p><b>Important:</b> <br />
As of Cjax version 4.1RC1 you may instantiate Cjax as Follows:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();&nbsp;</span>
</span>
</code></div>

<p>If you are using a previous version, you will need to do it this way:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">CJAX</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">();&nbsp;</span>
</span>
</code></div>

<p>&nbsp;</p>

<h3>Hello Application</h3>

<p>Now lets make some anchors fire an ajax request, and handle the hello request with the server.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Exec&#40;</span><span style="color: #DD0000">'achor1'</span><span style="color: #007700">,</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">call</span><span style="color: #007700">(</span><span style="color: #DD0000">'ajax.php?test/test/Hello'</span><span style="color: #0000BB">&#41;</span><span style="color: #007700">);&nbsp;</span>
</span>
</code></div>

<p>The above line will create an event listener ajax request attached to  click event to a DOM element with id &#8216;anchor1&#8217;.</p>

<p>Same result using Jquery:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">$(</span><span style="color: #0000BB">document</span><span style="color: #007700">).</span><span style="color: #0000BB">ready</span><span style="color: #007700">(function()</span><span style="color: #0000BB">&#123;<br />&nbsp;</span><span style="color: #007700">$(</span><span style="color: #DD0000">'#achor1'</span><span style="color: #007700">).</span><span style="color: #0000BB">click</span><span style="color: #007700">(function()</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;</span><span style="color: #007700">$.</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'ajax.php?test/test/Hello'</span><span style="color: #007700">,&nbsp;function(</span><span style="color: #0000BB">response</span><span style="color: #007700">)&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;<br />&nbsp;&nbsp;&#125;</span><span style="color: #007700">)<br />&nbsp;</span><span style="color: #0000BB">&#125;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">&#125;</span><span style="color: #007700">);&nbsp;</span>
</span>
</code></div>

<p><br />
In your view file.. lets add that anchor:</p><h3>Note</h3><p>You may add event listeners the same way to about any DOM element such as buttons, images, and of course anchors etc.</p>

<p><br />
views/test.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">body</span><span style="color: #007700">&gt;<br />&lt;</span><span style="color: #0000BB">a&nbsp;id</span><span style="color: #007700">=</span><span style="color: #DD0000">'anchor1'&nbsp;</span><span style="color: #0000BB">href</span><span style="color: #007700">=</span><span style="color: #DD0000">'#'</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">Anchor&nbsp;1</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">a</span><span style="color: #007700">&gt;<br />&lt;/</span><span style="color: #0000BB">body</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>When you click on the link, it will fire the ajax request directed to: ajax.php?test/test/Hello.</p>

<h3>Server Side</h3>

<p>Now that the ajax request has fired,&nbsp; it will trigger method test() inside class controller_test in application/response/test.php.</p>

<p>We&#8217;ll show a message in the screen, see below a list of messaging types.</p>

<p><b>Messaging API:</b><br />
 * success<br />
 * error<br />
 * info<br />
 * warning</p>

<p>At this point we are within the  ajax server side scope, so we do not need to include any files, we just need to instantiate the ajax class.</p>

<p>&nbsp;</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">success</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&#125;&nbsp;</span>
</span>
</code></div>

<p>The word <b>Hello</b> is passed through the ajax call parameter, and we make use of the ajax messaging api to display a success message in the middle screen. </p>

<p>Each message function is pre-configured to stay on the screen for three seconds, but you may change that with a second parameter, lets try 10 seconds:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">success</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">);&nbsp;</span>
</span>
</code></div>

<p><br />
You may  use any of these messaging API functions:</p>

<p><br />
Try them.. one at a time.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">success</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">error</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">info</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">warning</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);&nbsp;</span>
</span>
</code></div>

<p>You cannot use more than one message API at the same time because the next message will remove the previous, and you will not be able to see them, except the last one.</p>

<p>Cjax has a handy function that allows you to by pass this behavior, tha wait() function. You may call wait() each time one of them is fired as follow:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">success</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">wait</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">error</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">wait</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">info</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">wait</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">warning</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);&nbsp;</span>
</span>
</code></div>

<p>You will be able to see each one of the message for three seconds. There is no real world use for this, but it is a demonstration of the usage of timeouts. You may use timeouts for most API functions within the framework.</p>

<p>&nbsp;</p>

<h2>Recursive Ajax Requests</h2>

<p>Using the same <b>Hello</b> Application, we&#8217;ll create recursive ajax requests, each 5 seconds.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">wait</span><span style="color: #007700">(</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">call</span><span style="color: #007700">(</span><span style="color: #DD0000">"ajax.php?test/test/hello"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&#125;&nbsp;</span>
</span>
</code></div>

<p>The above example will trigger ajax requests to the same method, recursively every 5 seconds. </p>

<h2>Update Containers</h2>

<p>You can update any div, span containers or text/HTML elements on the page using the update(); function.</p>

<h3>Example</h3>
<p>application/response/test.php</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">update</span><span style="color: #007700">(</span><span style="color: #DD0000">"Div_id"</span><span style="color: #007700">,</span><span style="color: #DD0000">"html&nbsp;here"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&#125;&nbsp;</span>
</span>
</code></div>

<h2>Overlays Lightbox</h2>

<p><b>Watch Video Demonstration</b></p><blockquote>
<p><a href="http://www.youtube.com/watch?v=KCJkcLEK-X4">http://www.youtube.com/watch?v=KCJkcLEK-X4</a></p>
</blockquote>

<p>One of the fancy features of Cjax is how  easy is to create overlays without much code foot print. Lets  take our <b>Hello</b> Application and use it instead of the messaging.</p>

<h3>Basic use of OverlayCotent()</h3>
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">overlayContent</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&#125;&nbsp;</span>
</span>
</code></div>

<p>Above is the raw basic use of an overlay, you may pass any html or template in the first parameter, and it will show it in  the overlay.</p>

<p>Now lets show some configuration  and customization:</p>

<p>You may control, how transparent the overlay is, color, and position within the screen, top and left positioning.</p>

<h3>Overlay using Options</h3>
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$options&#91;</span><span style="color: #DD0000">'transparent'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$options&#91;</span><span style="color: #DD0000">'color'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'#425769'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$options&#91;</span><span style="color: #DD0000">'top'</span><span style="color: #0000BB">&#93;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;&nbsp;</span><span style="color: #0000BB">200</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$options&#91;</span><span style="color: #DD0000">'left'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"50%"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">overlayContent</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&#125;&nbsp;</span>
</span>
</code></div>

<p>You may  also format the dialog message within the overlay as follows (you maybe still pass the options if desired.):</p>

<h3>Overlay using formatting</h3>
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$html&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dialog</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">,</span><span style="color: #DD0000">"Hello&nbsp;Application"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">overlayContent</span><span style="color: #007700">(</span><span style="color: #0000BB">$html</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&#125;&nbsp;</span>
</span>
</code></div>

<h3>Fetching a URL</h3>

<p>The overLay() function fetches a URL and places the response html inside the overlay.</p>

<p>The next example will fire an ajax request and get the html, and set it within the overlay.</p>

<h3>Overlay URL</h3>
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">controller_test&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">CI_Controller&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$hello</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ajax&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">overlay</span><span style="color: #007700">(</span><span style="color: #DD0000">"ajax.php?test/html"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">html</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"some&nbsp;html&nbsp;fetched&nbsp;through&nbsp;ajax"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&#125;&nbsp;</span>
</span>
</code></div>

<h2>Configuring the framework with other ajax requests</h2>
<p>If you use your custom code to create ajax request or use some other framework or library, you may also be able to allow it to execute all these commands, here is how:</p>

<p>Each time an ajax request is created, it returns a response text, the framework processes this text to find possible commands to execute, all commands are parsed from an XML format.</p>

<p>This is the generic code needed to allow any ajax request to process the commands:</p>

<p>after you have created the request, use the response text as such:</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">if(</span><span style="color: #0000BB">typeof&nbsp;CJAX&nbsp;</span><span style="color: #007700">!=&nbsp;</span><span style="color: #DD0000">'undefined'</span><span style="color: #007700">)&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;CJAX</span><span style="color: #007700">.</span><span style="color: #0000BB">process_all</span><span style="color: #007700">(</span><span style="color: #0000BB">response</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;your&nbsp;response&nbsp;text&nbsp;goes&nbsp;here<br /></span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<h3>Jquery</h3>
<p>The Ajax Framework is  already configured to automatically detect any Jquery request through the complete() function callback in Jquery Ajax. So you do not need to do any extra steps if your request originated from the framework or from Jquery.</p>

<h2>Creating AJAX Framework (4.2+) Plugins</h2>

<p>Put bluntly, with the Ajax Framework you can literally execute JavaScript from PHP, and with Cjax Plugins you can execute your own custom JavaScript Code through $ajax object from PHP anywhere in your application. This makes it handy dandy, for you to consolidate solid functionality through your application, and easily execute without having to get your hands dirty with chunks of JavaScript everywhere. You maybe be able to create widgets if you let your imagination fly.</p>

<h4>Scope</h4>
<p>Plugins can be executed on page load, or within every ajax request.</p>

<h4>Steps for creating a plugin</h4>

<p>&nbsp;   1. Create a Javascript file under cjax/plugins/YourPlugin.js<br />
&nbsp;  &nbsp;  &nbsp; <br />
&nbsp;  &nbsp;  &nbsp; Or you may also create a directory inside plugins directory like so:&nbsp; <br />
&nbsp;  &nbsp;  &nbsp; cjax/plugins/YourPlugin/YourPlugin.js,&nbsp; In case you want to add additional css,&nbsp;  &nbsp;  &nbsp;  images, or other media, etc.</p>

<p>&nbsp;   2. Add a function YourPlugin in YourPlugin.js</p>

<p>&nbsp;  &nbsp;  &nbsp; <br /></p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">YourPlugin</span><span style="color: #007700">()&nbsp;</span><span style="color: #0000BB">&#123;&#125;&nbsp;</span>
</span>
</code></div>

<p><br />
<b>Call your plugin</b></p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">YourPlugin</span><span style="color: #007700">()&nbsp;</span>
</span>
</code></div>

<p><br />
&nbsp;   3. Replace &#8220;YourPlugin&#8221; with the name of your plugin<br />
&nbsp;   4. Pass parameters<br />
&nbsp;  &nbsp;  &nbsp; You may pass strings or arrays through function parameters through your php plugin call.</p>

<p><br /></p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$ajax</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">YourPlugin</span><span style="color: #007700">(</span><span style="color: #DD0000">'pass&nbsp;strings'</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'pass'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'arrays'</span><span style="color: #007700">))&nbsp;</span>
</span>
</code></div>

<p><br />
<b>&nbsp;  &nbsp;  &nbsp; Acess parameters in your JavaScript Plugin</b></p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #FF8000">//cjax/plugins/YourPlugin.js<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">YourPlugin</span><span style="color: #007700">(</span><span style="color: #0000BB">str</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">arr</span><span style="color: #007700">)&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//YOUR&nbsp;CUSTOM&nbsp;CODE&nbsp;HERE<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">alert</span><span style="color: #007700">(</span><span style="color: #0000BB">str&#41;</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//alerts&nbsp;all&nbsp;the&nbsp;items&nbsp;in&nbsp;your&nbsp;array.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">for(</span><span style="color: #0000BB">item&nbsp;in&nbsp;arr&#41;&nbsp;&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert</span><span style="color: #007700">(</span><span style="color: #0000BB">item</span><span style="color: #007700">+&nbsp;</span><span style="color: #DD0000">'&nbsp;'</span><span style="color: #007700">+</span><span style="color: #0000BB">arr&#91;item&#93;&#41;</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;</span>
</span>
</code></div>
<p>&nbsp;  &nbsp;  &nbsp;   Arrays are converted to Json objects, that is how you would access them.</p>

<p>Creating a plugin, couldn&#8217;t be easier&#8230;</p>]]></description>
      <dc:subject>Ajax Framework For CodeIgniter</dc:subject>
      <dc:date>2012-05-17T12:03:49+00:00</dc:date>
    </item>

    <item>
      <title>Multiple File Import By Zip File</title>
      <link>http://codeigniter.com/wiki/Multiple_File_Import_By_Zip_File</link>
      <guid>http://codeigniter.com/wiki/Multiple_File_Import_By_Zip_File</guid>
      <description><![CDATA[<p>I got a bit sick of seeing multiform inputs in many different cms&#8217;s where you have to select each file 1 at a time. To me this is completely useless. So I wrote a little function to import a zip file archive extract all the files, and import them into a specific folder (category named folder that&#8217;s database driven) This is more designed for images with say a gallery in mind, but it can easily be adopted to be used with almost any file type. So this not only extracts the zip files but it also creates thumbnails, than moves all the files into the correct place, and then deletes all the source files and zip archive after it&#8217;s done leaving no trace of the oringal filesm, so it doesn&#8217;t waste space.</p>

<p>So first we have a the primary function.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">import_zip</span><span style="color: #007700">()<br />&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">form_validation</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set_message</span><span style="color: #007700">(</span><span style="color: #DD0000">'required'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'The&nbsp;Field&nbsp;%s&nbsp;is&nbsp;Required'</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">form_validation</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set_rules</span><span style="color: #007700">(</span><span style="color: #DD0000">'userfile'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'userfile'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'xss_clean'</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">form_validation</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set_error_delimiters</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;h5&gt;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'&lt;/h5&gt;'</span><span style="color: #007700">);<br />&nbsp;if(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">form_validation</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">run</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;$data&#91;</span><span style="color: #DD0000">'error'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$data&#91;</span><span style="color: #DD0000">'heading'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Import&nbsp;Zip&nbsp;File'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$data&#91;</span><span style="color: #DD0000">'page'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'import_zip'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$data&#91;</span><span style="color: #DD0000">'vcate'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_categories'</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(</span><span style="color: #DD0000">'import_zip'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;</span><span style="color: #007700">else<br />&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//Upload&nbsp;file&nbsp;-&nbsp;Be&nbsp;Sure&nbsp;to&nbsp;change&nbsp;your&nbsp;upload&nbsp;path.<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'upload_path'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'./assets/gallery/photos/import_zip'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'allowed_types'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'zip'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'max_size'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'20000'</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">library</span><span style="color: #007700">(</span><span style="color: #DD0000">'upload'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br />&nbsp;&nbsp;if(!</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">upload</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">do_upload</span><span style="color: #007700">())<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;$data&#91;</span><span style="color: #DD0000">'error'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'error'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">upload</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display_errors</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&#91;</span><span style="color: #DD0000">'heading'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Import&nbsp;Zip&nbsp;File'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$data&#91;</span><span style="color: #DD0000">'vcate'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_categories'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(</span><span style="color: #DD0000">'import_zip'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;</span><span style="color: #007700">else<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Get&nbsp;the&nbsp;Category&nbsp;Name<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$cat_name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">gallery_model</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get_cat_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">input</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">post</span><span style="color: #007700">(</span><span style="color: #DD0000">'cat_id'</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: #0000BB">$cat_name&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$ca</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;$get_cat_name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$ca</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Get&nbsp;the&nbsp;uploaded&nbsp;zip&nbsp;file<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip_array&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'upload_data'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">upload</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">data</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip_file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$zip_array&#91;</span><span style="color: #DD0000">'upload_data'</span><span style="color: #0000BB">&#93;&#91;</span><span style="color: #DD0000">'full_path'</span><span style="color: #0000BB">&#93;</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Make&nbsp;a&nbsp;temp&nbsp;folder&nbsp;to&nbsp;store&nbsp;source&nbsp;zip&nbsp;files<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">@</span><span style="color: #0000BB">mkdir</span><span style="color: #007700">(</span><span style="color: #0000BB">$_SERVER&#91;</span><span style="color: #DD0000">'DOCUMENT_ROOT'</span><span style="color: #0000BB">&#93;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'/assets/gallery/photos/import_zip/'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Open&nbsp;the&nbsp;Zip&nbsp;File,&nbsp;and&nbsp;extract&nbsp;it's&nbsp;contents.<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #0000BB">$zip_file</span><span style="color: #007700">)&nbsp;===&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'./assets/gallery/photos/import_zip/'</span><span style="color: #007700">.</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">else<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Failed&nbsp;to&nbsp;extract&nbsp;files&nbsp;from&nbsp;zip&nbsp;archive."</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Get&nbsp;an&nbsp;array&nbsp;of&nbsp;extracted&nbsp;files&nbsp;from&nbsp;the&nbsp;temp&nbsp;import&nbsp;folder.<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$extracted_files&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">directory_map</span><span style="color: #007700">(</span><span style="color: #DD0000">'assets/gallery/photos/import_zip/'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#loop&nbsp;through&nbsp;the&nbsp;results.<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">foreach(</span><span style="color: #0000BB">$extracted_files&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Create&nbsp;Thumbnail&nbsp;Images.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'image_library'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'GD2'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'source_image'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'assets/gallery/photos/import_zip/'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">).</span><span style="color: #DD0000">'/'</span><span style="color: #007700">.</span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'new_image'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'assets/gallery/photos/'</span><span style="color: #007700">.</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">).</span><span style="color: #DD0000">'/thumbs/'</span><span style="color: #007700">.</span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'create_thumb'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'maintain_ratio'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'quality'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #DD0000">'thumbnail_quality'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'width'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #DD0000">'thumbnail_maxwidth'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'height'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #DD0000">'thumbnail_maxheight'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">'thumb_marker'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">image_lib</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">initialize</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">image_lib</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">resize</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#config2<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'image_library'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'GD2'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'source_image'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'assets/gallery/photos/import_zip/'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">).</span><span style="color: #DD0000">'/'</span><span style="color: #007700">.</span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'new_image'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'assets/gallery/photos/'</span><span style="color: #007700">.</span><span style="color: #0000BB">url_title</span><span style="color: #007700">(</span><span style="color: #0000BB">$get_cat_name</span><span style="color: #007700">).</span><span style="color: #DD0000">'/normal/'</span><span style="color: #007700">.</span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'create_thumb'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'maintain_ratio'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'quality'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #DD0000">'normal_quality'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'width'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #DD0000">'normal_maxwidth'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'height'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">config</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #DD0000">'normal_maxheight'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$config2&#91;</span><span style="color: #DD0000">'thumb_marker'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">image_lib</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">initialize</span><span style="color: #007700">(</span><span style="color: #0000BB">$config2</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">image_lib</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">resize</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Insert&nbsp;file&nbsp;info&nbsp;into&nbsp;database<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$userfile&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$value</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">gallery_model</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert_image_by_zip</span><span style="color: #007700">(</span><span style="color: #0000BB">$userfile</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Optimize&nbsp;the&nbsp;Database&nbsp;Table<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dbutil</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dbutil</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">optimize_table</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_photos'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#We&nbsp;will&nbsp;now&nbsp;do&nbsp;garbage&nbsp;collection&nbsp;and&nbsp;delete&nbsp;all&nbsp;the&nbsp;extra&nbsp;junk&nbsp;created&nbsp;during&nbsp;this&nbsp;import.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">delete_files</span><span style="color: #007700">(</span><span style="color: #DD0000">'assets/gallery/photos/import_zip/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#Okay&nbsp;everything&nbsp;is&nbsp;done&nbsp;lets&nbsp;re-direct&nbsp;back&nbsp;to&nbsp;the&nbsp;category&nbsp;these&nbsp;files&nbsp;were&nbsp;uploaded&nbsp;to.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">redirect</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_admin/images/'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">input</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">post</span><span style="color: #007700">(</span><span style="color: #DD0000">'cat_id'</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br />&nbsp;&nbsp;&#125;<br />&nbsp;&#125;&nbsp;</span>
</span>
</code></div>

<p>Okay So you may notice we have configured gallery thumbnail sizes which are loaded from the config file. So that file is below</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(!</span><span style="color: #0000BB">defined</span><span style="color: #007700">(</span><span style="color: #DD0000">"BASEPATH"</span><span style="color: #007700">))&nbsp;exit(</span><span style="color: #DD0000">"No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">"normal_maxwidth"</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'1024'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">"normal_maxheight"</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'768'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">"normal_quality"</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'90'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">"thumbnail_maxwidth"</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'100'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">"thumbnail_maxheight"</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'75'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$config&#91;</span><span style="color: #DD0000">"thumbnail_quality"</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'70'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;&nbsp;</span>
</span>
</code></div>

<p>That way you can customize these settings for whatever projects you use this for. You can also easily extend this to create different sized thumbnails. So if you want to make a 3rd group of sizes you can pretty easy.</p>

<p>The relevant model functions are below. These can be customized for your database of course.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">get_categories</span><span style="color: #007700">()<br /></span><span style="color: #0000BB">&#123;<br />$cat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_categories'</span><span style="color: #007700">);<br />return&nbsp;</span><span style="color: #0000BB">$cat</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">&#125;<br /><br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">get_cat_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$catid</span><span style="color: #007700">)<br /></span><span style="color: #0000BB">&#123;<br />$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">where</span><span style="color: #007700">(</span><span style="color: #DD0000">'id'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$catid</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cat_name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_categories'</span><span style="color: #007700">);<br />return&nbsp;</span><span style="color: #0000BB">$cat_name</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">result</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">&#125;<br /><br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">insert_image_by_zip</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">)<br /></span><span style="color: #0000BB">&#123;<br />$array&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;</span><span style="color: #DD0000">'cat_id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">input</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">post</span><span style="color: #007700">(</span><span style="color: #DD0000">'cat_id'</span><span style="color: #007700">),<br />&nbsp;</span><span style="color: #DD0000">'userfile'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">,<br />&nbsp;</span><span style="color: #DD0000">'desc_one'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,<br />&nbsp;</span><span style="color: #DD0000">'desc_two'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,<br />&nbsp;</span><span style="color: #DD0000">'sort_id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'0'<br />&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_photos'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>And lastly the view file below.</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">div&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"form-horizontal"</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$error?&gt;<br />&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">form_open_multipart</span><span style="color: #007700">(</span><span style="color: #DD0000">'gallery_admin/import_zip/'</span><span style="color: #007700">);</span><span style="color: #0000BB">?&gt;<br />&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">fieldset</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">legend</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lang</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">line</span><span style="color: #007700">(</span><span style="color: #DD0000">'label_import_zip'</span><span style="color: #007700">);</span><span style="color: #0000BB">?&gt;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">legend</span><span style="color: #007700">&gt;<br /><br />&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">div&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"control-group"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">label&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"control-label"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lang</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">line</span><span style="color: #007700">(</span><span style="color: #DD0000">'label_zip_file'</span><span style="color: #007700">);</span><span style="color: #0000BB">?&gt;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">label</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">div&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"controls"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">input&nbsp;type</span><span style="color: #007700">=</span><span style="color: #DD0000">"file"&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"field"&nbsp;</span><span style="color: #0000BB">name</span><span style="color: #007700">=</span><span style="color: #DD0000">"userfile"&nbsp;</span><span style="color: #0000BB">value</span><span style="color: #007700">=</span><span style="color: #DD0000">""&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">div</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">div</span><span style="color: #007700">&gt;<br /><br />&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">div&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"control-group"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">label&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"control-label"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lang</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">line</span><span style="color: #007700">(</span><span style="color: #DD0000">'label_gallery_category'</span><span style="color: #007700">);</span><span style="color: #0000BB">?&gt;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">label</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">div&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"controls"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">select&nbsp;name</span><span style="color: #007700">=</span><span style="color: #DD0000">"cat_id"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">foreach(</span><span style="color: #0000BB">$vcate</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">result</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$catname</span><span style="color: #007700">)&nbsp;:&nbsp;</span><span style="color: #0000BB">?&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">option&nbsp;value</span><span style="color: #007700">=</span><span style="color: #DD0000">"&lt;?php&nbsp;echo&nbsp;</span><span style="color: #0000BB">$catname</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">id?&gt;</span><span style="color: #DD0000">"</span><span style="color: #007700">&gt;</span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$catname</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name?&gt;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">option</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">endforeach;&nbsp;</span><span style="color: #0000BB">?&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">select</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">div</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">div</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">div&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"form-actions"</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;&nbsp;&lt;</span><span style="color: #0000BB">input&nbsp;</span><span style="color: #007700">class=</span><span style="color: #DD0000">"btn&nbsp;btn-primary"&nbsp;</span><span style="color: #0000BB">type</span><span style="color: #007700">=</span><span style="color: #DD0000">"submit"&nbsp;</span><span style="color: #0000BB">value</span><span style="color: #007700">=</span><span style="color: #DD0000">"Submit"&nbsp;</span><span style="color: #007700">/&gt;<br />&nbsp;&nbsp;&nbsp;&lt;/</span><span style="color: #0000BB">div</span><span style="color: #007700">&gt;<br />&nbsp;&nbsp;<br />&nbsp;&lt;/</span><span style="color: #0000BB">fieldset</span><span style="color: #007700">&gt;<br /></span><span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">form_close</span><span style="color: #007700">();</span><span style="color: #0000BB">?&gt;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">div</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>

<p>Hopefully someone finds this handy. :)</p>]]></description>
      <dc:subject>Multiple File Import By Zip File</dc:subject>
      <dc:date>2012-05-15T05:41:50+00:00</dc:date>
    </item>

    <item>
      <title>Persistent Content Across Views</title>
      <link>http://codeigniter.com/wiki/Persistent_Content_Across_Views</link>
      <guid>http://codeigniter.com/wiki/Persistent_Content_Across_Views</guid>
      <description><![CDATA[<p><a href="http://codeigniter.com/wiki/Category:Approaches::Header_and_Footer_and_Menu_on_every_page" title="Category:Approaches::Header_and_Footer_and_Menu_on_every_page">Category:Approaches -&gt; Header and Footer and Menu on every page</a></p>

<p><b>Overview</b><br />
A very simple but neat way to add some &#8220;constant&#8221; content to every page by<br />
overriding the &#8220;view&#8221; function in CI&#8217;s &#8220;Loader&#8221; class. This enables content<br />
such as headers / footers to be added to some or all pages without hacking<br />
any of CI&#8217;s system files or changing all your existing controllers.</p>

<p><b>Approach (brief)</b><br />
The ubiquitous $this-&gt;load-&gt;view() function is overridden using CI&#8217;s inbuilt<br />
mechanism for dynamically replacing it&#8217;s code (i.e.<br />
[url=&#8220;http://codeigniter.com/user_guide/general/core_classes.html&#8221;]extending<br />
core classes[/url]).</p>

<p>The basic method is very easy (just a few lines of code) and is ripe for<br />
customising further. For example, code could be added to alter the static<br />
pages that are provided (instead of turning the function on or off as is<br />
presently the case).</p>

<p><b>Approach (in detail)</b><br />
The code below is valid when the following assumptions are made:<br />
+ A complete page can be constructed from three views, &#8220;header&#8221;, &#8220;content&#8221;<br />
and &#8220;footer&#8221;<br />
+ You haven&#8217;t changed the config variable &#8216;subclass_prefix&#8217; from &#8216;MY_&#8217;</p>

<p>Simply create a new file in &#8216;application/core&#8217; named &#8216;MY_Loader.php&#8217; and add<br />
the following content:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&nbsp;</span>
</span>
</code></div>
<p>You can embellish with more comprehensive comments (you might want to copy<br />
those from the original function as a starting point), but I&#8217;ve kept it<br />
brief here on purpose.</p>

<p>Then simply call &#8220;view()&#8221; in your controller as you normally would for your<br />
content:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view</span><span style="color: #007700">(</span><span style="color: #DD0000">'content'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">);&nbsp;</span>
</span>
</code></div>

<p><b>What&#8217;s Going On</b><br />
As seasoned coders will easily see, we&#8217;ve derived a new class from<br />
&#8220;CI_Loader&#8221; in which we&#8217;ve overridden the existing function, &#8220;view()&#8221;. A<br />
feature of CI is that you can replace any of the existing core classes by<br />
creating a class called &#8220;MY_xxx&#8221; in the &#8216;application/core&#8217; folder (where<br />
&#8220;xxx&#8221; is the name of an existing CI class, but without the &#8220;CI_&#8221; prefix).<br />
Dropping this derived and appropriately named class in this folder is<br />
therefore all we need to do for it to be used every time CodeIgniter is<br />
started instead of the original. The only function that has been redefined<br />
is &#8220;view()&#8221;, so all others work as before.</p>

<p>When it executes, the original function in the parent class is called three<br />
times (in this case) with the header, whatever main content you want and<br />
then the footer. Concatenation of the results is done because view can be<br />
requested to return the page as a string instead of being sent to the user&#8217;s<br />
browser. The added fourth parameter ($include_static) is used as an<br />
indicator for situations where static content is not desired. You will see<br />
that the additional calls are conditional upon this being TRUE.</p>

<p>I developed this against the 2.1.0 version of CodeIgniter. It may need<br />
changing (or may not work at all) for versions prior to 2.0.0 and, of<br />
course, future versions are also subject to change (although I&#8217;d expect the<br />
approach to be reasonably robust).</p>

<p><b>Downsides</b><br />
The main problem with this technique is that things become more complicated<br />
if you need to construct pages from more than one view: every call to view()<br />
will add all the static content or none of it to the output page (depending<br />
on the value of $include_static). It would be relatively easy to swap<br />
$include_static for a variable used to identify which of several additional<br />
code snippets should be introduced (so the first call could include the<br />
header and the last the footer), but as it becomes more and more<br />
complicated, the advantages of using a technique such as this over and above<br />
simply calling view() in your code separately for each snippet become less<br />
and less clear.</p>

<p>From a stylistic point of view, some people may have an opinion on creating<br />
a very specific version of one of CI&#8217;s core classes (i.e. one with hardwired<br />
views). A more generic approach, using a config file to wire up the static<br />
content and a more sophisticated selection process might be an interesting<br />
project, but it would be easy to get away from the fact that this is a<br />
simple solution for a not very onerous problem.</p>]]></description>
      <dc:subject>Persistent Content Across Views</dc:subject>
      <dc:date>2012-05-07T21:03:46+00:00</dc:date>
    </item>

    <item>
      <title>htaccess.txt</title>
      <link>http://codeigniter.com/wiki/htaccess.txt</link>
      <guid>http://codeigniter.com/wiki/htaccess.txt</guid>
      <description><![CDATA[<div class="codeblock"><code><span style="color: #000000">
<span style="color: #007700">&lt;</span><span style="color: #0000BB">IfModule&nbsp;mod_rewrite</span><span style="color: #007700">.</span><span style="color: #0000BB">c</span><span style="color: #007700">&gt;<br />&nbsp;</span><span style="color: #0000BB">RewriteEngine&nbsp;On<br /><br />&nbsp;</span><span style="color: #FF8000">#If&nbsp;you&nbsp;are&nbsp;having&nbsp;problems&nbsp;with&nbsp;the&nbsp;rewrite&nbsp;rules,&nbsp;remove&nbsp;the&nbsp;"#"&nbsp;from&nbsp;the<br />&nbsp;#line&nbsp;that&nbsp;begins&nbsp;"RewriteBase"&nbsp;below.&nbsp;You&nbsp;will&nbsp;also&nbsp;have&nbsp;to&nbsp;change&nbsp;the&nbsp;path<br />&nbsp;#of&nbsp;the&nbsp;rewrite&nbsp;to&nbsp;reflect&nbsp;the&nbsp;path&nbsp;to&nbsp;your&nbsp;base&nbsp;path.<br />&nbsp;#RewriteBase&nbsp;/<br /><br /></span><span style="color: #0000BB">RewriteRule&nbsp;&nbsp;</span><span style="color: #007700">^/?</span><span style="color: #0000BB">ajax</span><span style="color: #007700">/(.*)$&nbsp;</span><span style="color: #0000BB">ajax</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">?$</span><span style="color: #0000BB">1&nbsp;&#91;NC</span><span style="color: #007700">,</span><span style="color: #0000BB">QSA</span><span style="color: #007700">,</span><span style="color: #0000BB">L&#93;<br /></span><span style="color: #007700">&lt;/</span><span style="color: #0000BB">IfModule</span><span style="color: #007700">&gt;&nbsp;</span>
</span>
</code></div>]]></description>
      <dc:subject>htaccess.txt</dc:subject>
      <dc:date>2012-05-03T23:23:43+00:00</dc:date>
    </item>

    <item>
      <title>RB Menu</title>
      <link>http://codeigniter.com/wiki/RB_Menu</link>
      <guid>http://codeigniter.com/wiki/RB_Menu</guid>
      <description><![CDATA[<p><b>Overview</b></p>

<p>The RB-Menu handles one or more menu bars on your web pages. It supports <i>horizontally</i> or <i>vertically</i> oriented menus optionally showing <i>one level of sub menu items</i>. RB-Menu selects one menu item according to the current request URI. The selected menu item can be highlighted.</p>

<p>The RB-Menu package allows you to setup the menu items and sub items independently from the visual appearance attributes. The loaded instance of the Rb_menu library class stores all these setup data and uses them as soon as menu rendering is requested - usually within a view class.</p>

<p>During rendering RB-Menu checks for each menu item whether it is allowed to be rendered by calling a method of an acl (access control list) library class if such a class is available. Thus the acl library class can control at runtime the visibility of menu items - for example according to a logged-in status of the user.</p>

<p><a href="http://roland.blochberger.us/index.php/pages/packdesc/rb_menu">Further information</a></p>

<p><br />
<b>Requirements</b><br />
&nbsp; * CodeIgniter  - I have tested it on 1.7.0 and now 2.1.0 but other versions should work fine too.<br />
&nbsp; * PHP of course - I have tested it on PHP 4.4.9, 5.2.1, and now 5.3.8 (XAMPP).</p>

<p><b>See It Run</b><br />
<a href="http://rb_menu.blochberger.us/">Here you can find a demo site (not yet updated)</a>.</p>

<p><b>Download</b><br />
All files necessary for the RB Menu are here:</p>

<p>- <a href="http://codeigniter.com/wiki/File:rb_menu_20120417.zip" title="File:rb_menu_20120417.zip" class="noArticle">File:rb menu 20120417.zip</a> Release 2, 2012-04-17,<br />
&nbsp;  &nbsp; adapted to CodeIgniter 2.1.0 and PHP 5.3.<br />
- <a href="http://codeigniter.com/wiki/File:rb_menu_20090121.zip" title="File:rb_menu_20090121.zip" class="noArticle">File:rb menu 20090121.zip</a> Release 1, 2009-01-21,<br />
&nbsp;  &nbsp; original release.</p>

<p>- <a href="http://codeigniter.com/wiki/File:rb_menu_demo_20120417.zip" title="File:rb_menu_demo_20120417.zip" class="noArticle">File:rb menu demo 20120417.zip</a> Demo application for Release 2, 2012-04-17.</p>

<p><br />
<b>Installation and Configuration</b></p>

<p>&nbsp; * Unzip the downloaded archive into your CodeIgniter installation. The archive contains sub directories that show where the files have to go.</p>

<p>&nbsp; * The archive contains example files that show how to implement: </p>

<p>&nbsp;   - an <b>access control library</b> class (libraries/acl.php) that - in this example - distinguishes menu items for users or administrators. Please adapt this for your application.</p>

<p>&nbsp;   - a <b>helper</b> (helpers/menu_helper.php) that configures the menu items for your web site. Please adapt this for your application.</p>

<p>&nbsp;   - a <b>controller</b> (controllers/welcome.php) with RB-Menu support - its constructor loads the <i>url_helper</i>, the <i>menu_helper</i>, the <i>acl library</i>, and defines the <i>menu items</i>. This file shows how to integrate RB Menu.</p>

<p>&nbsp;   - a page header <b>view</b> (views/pageheader.php) that renders the menu.&nbsp; This file shows how to integrate RB Menu.</p>

<p>&nbsp; * For a detailed description of the methods of the <i>Rb_menu</i> library class please refer to the inline documentation inside the file <b>libraries/Rb_menu.php</b>.</p>

<p>&nbsp; * The archive also contains an example <i>RB-Menu configuration file</i> (config/Rb_menu.php) that shows which values you can modify to adapt RB-Menu to your web application&#8217;s visual appearance.</p>

<p>&nbsp; * If you plan to use sub menu items, you need to load a <b>CodeIgniter Session</b> class since the name of the open parent menu item is stored in the session&#8217;s user data. Please note, that the standard CodeIgniter Session needs a non-empty &#8216;encryption_key&#8217; value (in config/config.php).</p>

<p>&nbsp; * Parent menu items are marked with a <i>small arrow icon</i>. The associated image files are located in the <i>img</i> directory of the archive. Feel free to choose other icons appropriate to your web design. The names of both icons for the selected and the unselected parent menu item can be configured in <i>config/Rb_menu.php</i>.</p>]]></description>
      <dc:subject>RB Menu</dc:subject>
      <dc:date>2012-04-17T09:05:53+00:00</dc:date>
    </item>

    <item>
      <title>ORM</title>
      <link>http://codeigniter.com/wiki/ORM</link>
      <guid>http://codeigniter.com/wiki/ORM</guid>
      <description><![CDATA[<h3>Under Active Development</h3>
<p><a href="http://codeigniter.com/wiki/ActiveRecord_Class/">ActiveRecord</a><br />
<a href="http://codeigniter.com/wiki/ActiveRecord_Class_Mod/">ActiveRecord Mod</a><br />
<a href="http://codeigniter.com/wiki/DataMapper/">DataMapper</a><br />
<a href="http://codeigniter.com/wiki/Using_Doctrine_with_Code_Igniter/">Doctrine</a><br />
<a href="http://codeigniter.com/wiki/GasORM/">Gas ORM</a><br />
<a href="http://codeigniter.com/wiki/IgnitedRecord/">IgnitedRecord</a><br />
<a href="http://codeigniter.com/forums/viewthread/95565/">Outlet</a><br />
<a href="http://codeigniter.com/wiki/Using_Propel_as_Model/">Propel</a></p>

<h3>Deceased</h3>

<p><a href="http://codeigniter.com/forums/viewthread/51495/">ORM</a></p>

<h3>Categories</h3>
<p><a href="http://codeigniter.com/wiki/Category:Libraries::Database" title="Category:Libraries::Database">Category:Libraries -&gt; Database</a><br />
<a href="http://codeigniter.com/wiki/Category:Database" title="Category:Database">Category:Database</a></p>]]></description>
      <dc:subject>ORM</dc:subject>
      <dc:date>2012-04-14T10:51:32+00:00</dc:date>
    </item>

    <item>
      <title>Category:Help &#45;&gt; Tutorials</title>
      <link>http://codeigniter.com/wiki/Category:Help::Tutorials</link>
      <guid>http://codeigniter.com/wiki/Category:Help::Tutorials</guid>
      <description><![CDATA[<h3>Official tutorials</h3>
<h4>Version &gt;= 2.0.0</h4>
<p>* <a href="http://ie.mirror.twsweb-int.com/codeigniter/user_guide/tutorial/introduction.html">Introduction to Code Igniter</a> <b>Mirror</b></p>

<h3>Official video tutorials</h3>

<h4>Version &lt;= 1.7.2</h4>
<p>* <a href="http://codeigniter.com/tutorials/watch/intro/">Hello World! Introduction to Code Igniter</a><br />
* <a href="http://codeigniter.com/tutorials/watch/blog/">Create a Blog in 20 Minutes</a></p>

<h3>Video tutorials on external sites</h3>

<h4>Version &gt;= 2.0.0</h4>
<p>* <a href="http://heybigname.com/2011/07/28/codeigniter-2-sparks-php-activerecord-part-1-installation/">CodeIgniter 2 + Sparks + PHP ActiveRecord Part 1: Installation</a><br />
* <a href="http://heybigname.com/2011/08/03/codeigniter-2-sparks-php-activerecord-part-2-the-user-model/">CodeIgniter 2 + Sparks + PHP ActiveRecord Part 2: The User Model</a><br />
* <a href="http://heybigname.com/2011/08/17/codeigniter-2-sparks-php-activerecord-part-3-login/">CodeIgniter 2 + Sparks + PHP ActiveRecord Part 3: Login</a></p>

<p>* <a href="http://www.hectorcyc.com.mx/2012/04/06/codeigniter-crud/">Codeigniter + CRUD Easy datagrids!</a><br />
* <a href="http://codeigniter.tv/a-4/An-introduction-to-Codeigniter-MVC">Codeigniter.tv - An introduction to Codeigniter MVC</a><br />
* <a href="http://codeigniter.tv/a-6/Create-a-Codeigniter-Wordpress-like-shortcode-parser">Codeigniter.tv - Create a Codeigniter Wordpress-like shortcode parser</a><br />
* <a href="http://codeigniter.tv/a-8/Create-multiple-aspect-ratio-thumbnails">Codeigniter.tv - Create multiple aspect ratio thumbnails</a><br />
* <a href="http://codeigniter.tv/a-9/Dynamically-distinguish-between-development-staging-and-production-servers">Codeigniter.tv - Dynamically distinguish between development, staging and production servers</a><br />
* <a href="http://codeigniter.tv/a-10/Extending-the-core-MY_Controller-and-beyond">Codeigniter.tv - Extending the core: MY_Controller and beyond</a><br />
* <a href="http://codeigniter.tv/a-11/Extending-the-Codeigniter-core-MY_Model-part-1">Codeigniter.tv - MY_Model: What is a MY_Model and why is it such a good tool?</a><br />
* <a href="http://codeigniter.tv/a-12/Extending-the-Codeigniter-core-MY_Model-part-2">Codeigniter.tv - MY_Model: Creating all the get methods</a></p>

<h4>Version &lt;= 1.7.2</h4>
<p>* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-1/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 1, Nettuts.com - Getting Started With the Framework</a><br />
* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-2/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 2, Nettuts.com - Database Selecting Methods</a><br />
* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-3/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 3, Nettuts.com - Sending Emails</a><br />
* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-4/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 4, Nettuts.com - Newsletter Signup</a><br />
* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-5/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 5, Nettuts.com - CRUD</a><br />
* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-6/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 6, Nettuts.com - Login</a><br />
* <a href="http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-7-pagination/">Jeffrey Way&#8217;s CodeIgniter From Scratch: Day 7, Nettuts.com - Pagination</a><br />
* <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-day-8-ajax/">Burak Guzel&#8217;s CodeIgniter From Scratch: Day 8, Nettuts.com – AJAX</a> (Burak will be continuing the series!) </p>

<p><br />
* <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-file-uploading-and-image-manipulation/">Burak Guzel&#8217;s CodeIgniter from Scratch, Nettuts.com – File Uploading and Image Manipulation</a><br />
* <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-the-calendar-library/">Burak Guzel&#8217;s CodeIgniter from Scratch, Nettuts.com – The Calendar Library</a><br />
* <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-file-operations/">Burak Guzel&#8217;s CodeIgniter from Scratch, Nettuts.com – File Operations</a><br />
* <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-shopping-cart/">Burak Guzel&#8217;s CodeIgniter from Scratch, Nettuts.com – Shopping Cart</a><br />
* <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-extending-the-framework/">Burak Guzel&#8217;s CodeIgniter from Scratch, Nettuts.com - Extending the Framework </a></p>

<p>* <a href="http://www.youtube.com/watch?v=wRGb7VuIbe4">Usage of CodeIgniter plug-in for free PHP IDE - Codelobster PHP Edition</a></p>

<p>* <a href="http://learn-codeigniter.com/episode/introduction_to_codeigniter">Cody P. Christian&#8217;s - LearnCI - Introduction To CodeIgniter - Episode 1, learn-codeignter.com</a><br />
* <a href="http://learn-codeigniter.com/episode/codeigniter_basics">Cody P. Christian&#8217;s - LearnCI - CodeIgniter Basics - Episode 2, learn-codeignter.com</a> (More episodes coming soon!) </p>

<p><br />
* <a href="http://video.derekallard.com/">Derek Allard&#8217;s Tutorial using AJAX, Scriptaculous, and Models</a><br />
* <a href="http://www.viddler.com/explore/lszanto/videos/1/">Image Uploader Tutorial</a> hosted at Viddler.com, created by <a href="http://codeigniter.com/forums/member/52992/">Iszanto</a> (2007-10-31)<br />
*<a href="http://jedidiahreeser.com/blog/2009/07/accessing-multiple-databases-codeigniter/">Jedidiah Reeser&#8217;s - Accessing Multiple Databases</a> (2009-07)<br />
*<a href="http://designerfoo.com/codeigniter-tutorial-tellafriend-email-form-validation-codeignter.html#contentstartshere">Designerfoo.com: CI TellAFriend Video Tutorial</a>&nbsp; - By Manoj Sachwani (2010-01-03)<br />
*<a href="http://designerfoo.com/howto-codeigniter-uploadify.html">Designerfoo.com: CI+Uploadify Video Tutorial</a> - By Manoj Sachwani<br />
* <a href="http://www.youtube.com/verbloten">Alasdair Boyd&#8217;s Series of CodeIgniter Video Tutorials</a><br />
*<a href="http://shawnmccool.com/2009/08/29/understand-the-structure-of-code-igniter/">Shawn McCool&#8217;s Blog - Code Igniter: An Incredibly Brief Introduction</a><br />
*<a href="http://shawnmccool.com/2009/09/04/developing-a-website-with-code-igniter-part-1-configuration/">Shawn McCool&#8217;s Blog - Developing a website with Code Igniter Part 1: Configuration</a><br />
*<a href="http://shawnmccool.com/2009/09/06/developing-a-website-with-code-igniter-part-2-users-database-table-and-the-user-model/">Shawn McCool&#8217;s Blog - Developing a website with Code Igniter Part 2: Users database table and users model</a><br />
*<a href="http://shawnmccool.com/2009/11/09/developing-a-website-with-code-igniter-part-3-the-login-process/">Shawn McCool&#8217;s Blog - Developing a website with Code Igniter Part 3: The Login Process</a><br />
*<a href="http://shawnmccool.com/2010/01/30/developing-a-website-with-codeigniter-part-4-admin-site-crud/">Shawn McCool&#8217;s Blog - Developing a website with Code Igniter Part 4: Admin Site Crud</a></p>

<h3>Video tutorials in Portuguese (Tutorial CodeIgniter em Português)</h3>
<p>* <a href="http://www.ademargomes.com/index.php/artigos/100-code-igniter-video-tutoriais-em-portugues-.html">Ademar Gomes - Tutorial CodeIgniter - Parte 1 - Introdução</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/102-codeigniter-video-tutoriais-parte-2.html">Ademar Gomes - Tutorial CodeIgniter - Parte 2 - Conhecendo Controllers</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/104-codeigniter-video-tutoriais-parte-3.html">Ademar Gomes - Tutorial CodeIgniter - Parte 3 - Conhecendo Views</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/105-codeigniter-video-tutoriais-parte-4.html">Ademar Gomes - Tutorial CodeIgniter - Parte 4 - Conhecendo Helpers e criando formulários</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/106-codeigniter-video-tutoriais-parte-5.html">Ademar Gomes - Tutorial CodeIgniter - Parte 5 - CRUD - recuperando dados do banco</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/107-codeigniter-video-tutoriais-parte-6.html">Ademar Gomes - Tutorial CodeIgniter - Parte 6 - CRUD - Active Records</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/108-codeigniter-video-tutoriais-parte-7.html">Ademar Gomes - Tutorial CodeIgniter - Parte 7 - CRUD - Inclusão</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/109-codeigniter-video-tutoriais-parte-8.html">Ademar Gomes - Tutorial CodeIgniter - Parte 8 - CRUD - Deleção e session</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/111-codeigniter-video-tutoriais-parte-9.html">Ademar Gomes - Tutorial CodeIgniter - Parte 9 - CRUD - Alteração e validação de formulários</a><br />
* <a href="http://www.ademargomes.com/index.php/artigos/112-codeigniter-video-tutoriais-parte-10.html">Ademar Gomes - Tutorial CodeIgniter - Parte 10 - Login</a></p>

<h3>Written tutorials on external sites</h3>
<p>* <a href="http://4moki.com/ajax-login-with-jquery-and-codeigniter/">Ajax login with Jquery and Codeigniter</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-from-scratch-day-1-install-and-setup">CodeIgniter and Doctrine from scratch. Day 1 – Install and Setup.</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-and-doctrine-from-scratch-day-2-the-basics">CodeIgniter and Doctrine from scratch. Day 2 – The Basics.</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-3-user-signup-form">CodeIgniter and Doctrine from scratch. Day 3 – User Signup Form.</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-4-user-login">CodeIgniter and Doctrine from scratch. Day 4 – User Login.</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-day-5-database-crud">CodeIgniter and Doctrine from scratch. Day 5 – Database CRUD.</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-day-6-models-relationships">CodeIgniter and Doctrine from scratch. Day 6 - Models with Relationships</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-7-fixtures-forum-list">CodeIgniter and Doctrine from scratch. Day 7 - Fixtures &amp; Forum List</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-8-hooks-profiling-dql">CodeIgniter and Doctrine from scratch. Day 8 - Hooks, Profiling and DQL</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-9-templates-data-hydrators">CodeIgniter and Doctrine from scratch. Day 9 - Templates &amp; Data Hydrators</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-10-pagination">CodeIgniter and Doctrine from scratch. Day 10 - Pagination</a><br />
* <a href="http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-11-record-hooks">CodeIgniter and Doctrine from scratch. Day 11 - Record Hooks</a></p>

<p>* <a href="http://henrihnr.wordpress.com/2009/04/26/simple-crud-application/">Henri Blog - Simple CRUD – CodeIgniter</a></p>

<p>* <a href="http://www.devshed.com/c/a/PHP/Introduction-to-the-CodeIgniter-PHP-Framework/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 1</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Building-a-DatabaseDriven-Application-with-the-Code-Igniter-PHP-Framework/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 2 - Databases</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Paginating-Database-Records-with-the-Code-Igniter-PHP-Framework/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 3 - Paginating</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Validating-Web-Forms-with-the-Code-Igniter-PHP-Framework/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 4 - Validating</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Performing-Strict-Validation-with-the-Code-Igniter-PHP-Framework/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 5 - Strict Validating</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Working-with-the-Active-Record-Class-in-Code-Igniter/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 6 - Active Record</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Inserting-Updating-and-Deleting-Database-Rows-with-Code-Igniter/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 7 - Insert/Update/Delete Database Rows</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Working-with-the-Email-Class-in-Code-Igniter/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 8 - Emailing</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Building-a-Content-Management-System-with-Code-Igniter/">Devshed: Introduction-to-the-CodeIgniter-PHP-Framework - Part 9 - Build a CMS</a></p>

<p>* <a href="http://www.devshed.com/c/a/PHP/Handling-Views-with-CodeIgniter/">Devshed: Handling-Views-with-CodeIgniter - Part 1</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Adding-CSS-to-Handling-Views-with-CodeIgniter/">Devshed: Handling-Views-with-CodeIgniter - Part 2 - Adding CSS</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Using-Nested-Views-with-CodeIgniter/">Devshed: Handling-Views-with-CodeIgniter - Part 3 - Using nested views</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Returning-Strings-from-Views-with-Code-Igniter/">Devshed: Handling-Views-with-CodeIgniter - Part 4 - Returning Strings from Views</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Moving-Presentation-Logic-Out-of-Views-with-Code-Igniter/">Devshed: Handling-Views-with-CodeIgniter - Part 5 - Moving Presentation Logic out of Views</a><br />
* <a href="http://www.devshed.com/c/a/PHP/Defining-a-Model-Class-for-Handling-Views-with-CodeIgniter/">Devshed: Handling-Views-with-CodeIgniter - Part 6 - Models and Views </a><br />
* <a href="http://www.devshed.com/c/a/PHP/Embedding-Model-Data-in-Views-with-Code-Igniter/">Devshed: Handling-Views-with-CodeIgniter - Part 7 - Model Data and Views</a></p>

<p>* <a href="http://pinoytech.org/blog/post/AJAX-with-CodeIgniter">PinoyTech - AJAX with CodeIgniter</a><br />
* <a href="http://pinoytech.org/blog/post/pagination-with-codeigniter">PinoyTech - Pagination with CodeIgniter</a><br />
* <a href="http://pinoytech.org/blog/post/CodeIgniter-Image-Manipulation-Class-How-to-Resize">PinoyTech - CodeIgniter Image Manipulation Class: How to Resize</a></p>

<p>* <a href="http://godbit.com/article/introduction-to-code-igniter">Godbit Project - Introduction to Code Igniter: Part 1</a><br />
* <a href="http://godbit.com/article/introduction-to-code-igniter-part-2">Godbit Project - Introduction to Code Igniter: Part 2</a><br />
* <a href="http://godbit.com/article/introduction-to-code-igniter-part-3">Godbit Project - Introduction to Code Igniter: Part 3</a><br />
* <a href="http://godbit.com/article/pagination-with-code-igniter">Godbit Project - Pagination with Code Igniter</a></p>

<p>* <a href="http://www.4webby.com/freakauth/tutorials/ci-swift-mailer">4webby.com - Using SWIFT MAILER with Code Igniter</a><br />
* <a href="http://www.4webby.com/freakauth/tutorials/using-zend-framework-components-in-code-igniter">4webby.com - Using Zend Framework components in Code Igniter</a><br />
* <a href="http://www.derekallard.com/blog/post/building-an-rss-feed-in-code-igniter/">Building an RSS Feed in Code Igniter</a></p>

<p>* <a href="http://pr0digy.com/codeigniter/unobtrusive-ajax-with-codeigniter-and-mootools/">pr0digy.com - Unobtrusive AJAX with CodeIgniter and Mootools</a><br />
* <a href="http://pr0digy.com/codeigniter/live-search-with-codeigniter-and-mootools/">pr0digy.com - Live search with CodeIgniter and Mootools (JSON)</a></p>

<p>* <a href="http://www.zenperfect.com/2007/07/12/model-view-controller-and-codeigniter/"> zenperfect - Introduction to MVC Approach</a><br />
* <a href="http://www.zenperfect.com/2007/07/27/sample-codeigniter-application/"> zenperfect - Sample Application with Source Code</a><br />
shows Ajax with Prototype and script.aculo.us, models, sessions</p>

<p>* <a href="http://www.devshed.com/c/a/PHP/Introduction-to-the-CodeIgniter-PHP-Framework/">devshed - Introduction to the CodeIgniter Framework Part 1</a></p>

<p>* <a href="http://www.ibm.com/developerworks/web/library/wa-codeigniter/index.html">IBM developerWorks - Getting started with CodeIgniter</a></p>

<p>* <a href="http://lazarevskizoran.com/blog"> Helpful tutorials for CodeIgniter beginners and some helpful techniques </a></p>

<p>* <a href="http://www.kromack.com/codeigniter/tutorial-codeigniter-flashdata-highlighting-with-jquery-and-jgrowl/">CodeIgniter Flashdata Highlighting with jQuery and jGrowl</a></p>

<h3>Portuguese</h3>

<p>* <a href="http://programadoranonimo.blogspot.com/2008/10/tutorial-mvc-1-introduo.html">Programador Anónimo(PT)-Tutorial MVC - 1 Introdução</a><br />
* <a href="http://programadoranonimo.blogspot.com/2008/10/tutorial-mvc-2-codeigniter-primeiros.html">Programador Anónimo(PT)-Tutorial MVC - 2 CodeIgniter, Primeiros Passos</a><br />
* <a href="http://programadoranonimo.blogspot.com/2008/10/tutorial-mvc-3-acesso-dados.html">Programador Anónimo(PT)-Tutorial MVC - 3 Acesso a dados</a><br />
* <a href="http://programadoranonimo.blogspot.com/2008/10/tutorial-mvc-4-inserir-de-dados.html">Programador Anónimo(PT)-Tutorial MVC - 4 Inserir dados, Formulários e Validação</a><br />
* <a href="http://brayanrastelli.com/index.php/2010/08/configurando-uma-aplicacao-no-codeigniter/">Configurando Templates no Codeigniter - Brayan L. Rastelli</a></p>

<h3>French</h3>

<p>* <a href="http://www.kromack.com/codeigniter/tutoriel-codeigniter-creer-ses-propres-fichiers-de-configuration/">Créer et gérer ses propres fichiers de configuration</a></p>

<p>* <a href="http://www.kromack.com/codeigniter/bonnes-pratiques-sur-la-gestion-de-base-de-donnees-sous-codeigniter/">Bonnes pratiques sur la gestion de bases de données sous CodeIgniter</a></p>

<h3>Spanish</h3>

<p>* <a href="http://www.davidrojas.net/index.php/desarrollo-web/screencast-introduccion-al-framework-php-codeigniter/">David Rojas&#8217; Videotutorial: Introducción a Codeigniter</a><br />
* <a href="http://www.davidrojas.net/index.php/desarrollo-web/screencast-tutorial-creacion-y-validacion-de-formularios-con-codeigniter/">David Rojas&#8217; Videotutorial: Creación y validación de formularios con Codeigniter</a><br />
* <a href="http://www.davidrojas.net/index.php/desarrollo-web/screencast-tutorial-ajax-con-jquery-en-codeigniter/">David Rojas&#8217; Videotutorial: Ajax con Jquery en Codeigniter</a><br />
* <a href="http://www.davidrojas.net/index.php/desarrollo-web/screencast-crud-con-scaffolding-rendimiento-y-unit-testing-en-codeigniter/">David Rojas&#8217; Videotutorial: CRUD con scaffolding, rendimiento y unit testing en Codeigniter</a><br />
* <a href="http://www.davidrojas.net/index.php/desarrollo-web/screencast-tutorial-hooks-y-creacion-de-librerias-con-codeigniter/">David Rojas&#8217; Videotutorial: Hooks y creación de librerías con Codeigniter</a></p>

<h3> Chinese </h3>

<p><a href="http://www.youku.com/playlist_show/id_6175330.html"> Learn CodeIgniter Follow Me Series (1-5) </a></p>

<h3>Other</h3>

<p>* Norwegian: <a href="http://www.skitx.com/artikkel/kom_igang_med_codeigniter/">Kom igang med CodeIgniter</a></p>

<h3>All CodeIgniter resources in 1 place:</h3>
<p>* <a href="http://www.codeigniterdirectory.com/">www.codeigniterdirectory.com</a></p>]]></description>
      <dc:subject>Category:Help &#45;&gt; Tutorials</dc:subject>
      <dc:date>2012-04-12T20:45:59+00:00</dc:date>
    </item>

    <item>
      <title>MY Controller</title>
      <link>http://codeigniter.com/wiki/MY_Controller</link>
      <guid>http://codeigniter.com/wiki/MY_Controller</guid>
      <description><![CDATA[<p><span style="color:green;">This page describes a standard feature of the CodeIgniter framework - the ability to extend core libraries.&nbsp; It concerns itself with extending <b>Controller</b> only - as this is the most common application of this feature - but the concepts shown here also apply to the other core libraries.</span></p>

<p><span style="color:green;">Take care - these instructions are for CodeIgniter <b>1.7.x</b> - the <b>2.x</b> release sees MY_ class extenders relocated to app/core - see the relevant documentation for 2.x.&nbsp; CI 2.x controllers also extend CI_Controller instead of just Controller.</span></p>

<h2>
Overview
</h2>
<p>We assume here that you have an understanding of CI and MVC fundamentals.&nbsp; You will have read through the <a href="/user_guide">User Guide</a>, especially the sections on <a href="/user_guide/general/controllers.html">Controllers</a> and <a href="/user_guide/general/models.html">Models</a>.</p>

<p>The subject of extending core controllers is discussed briefly in a few places in the manual - specifically in the <a href="http://user_guide/general/core_classes.html">Core Classes</a> and <a href="http://user_guide/general/creating_libraries.html">Creating Libraries</a> pages.</p>

<p>The <b>intent</b> of extending the core Controller is to provide methods and attributes to all your normal Controllers.&nbsp; There are other ways of providing this kind of pervasive functionality - including <a href="/user_guide/general/hooks.html">Hooks</a>, <a href="/user_guide/general/creating_libraries.html">Libraries</a> and <a href="/user_guide/general/helpers.html">Helpers</a>.&nbsp; You should familiarise yourself with the methods and benefits of those alternatives before assuming the following is <i>the</i> answer to your question.</p>

<p>Finally, it&#8217;s assumed that you have an application that does <i>something</i> - it doesn&#8217;t matter what, merely that you have an existing Controller that we can work with here.</p>



<h2>
Creating the MY_Controller file
</h2>
<p>Extensions to the core libraries are placed in <b>application/libraries</b> and the file name is determined by adding the <b>$config[&#8216;subclass_prefix&#8217;]</b> to the core library name.</p>

<p>The $config[&#8216;subclass_prefix&#8217;] variable is set in <b>application/config/config.php</b> and by default it is set to &#8216;<b>MY_</b>&#8217;.&nbsp; You probably don&#8217;t want to change this unless you know what you&#8217;re doing (and if you know what you&#8217;re doing you&#8217;re probably not reading this guide).</p>

<p>In any case, this explains why it&#8217;s usually called the <b>MY_Controller</b> approach.</p>

<p>So, create your file - <b>application/libraries/MY_Controller.php</b> - and fill it with this code:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;&nbsp;</span><span style="color: #007700">extends&nbsp;&nbsp;</span><span style="color: #0000BB">Controller&nbsp;&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;</span><span style="color: #007700">()&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">Controller</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;</span>
</span>
</code></div>

<p>Save and quit.&nbsp; Obviously this file doesn&#8217;t actually <i>do anything useful</i> but we&#8217;ll get back to that in a minute.</p>

<p>&nbsp;</p>

<h2>
Modifying your existing Controller
</h2>

<p>We&#8217;ll now modify one of your Controllers to work via the MY_Controller.&nbsp; The following code partial is obviously not a fully functional Controller - I&#8217;m just showing enough so you know what you have to change.&nbsp; Here we&#8217;re using the Controller <b>Forum</b>.&nbsp; CodeIgniter encourages users to stick with the PHP4 (constructor name is the same as class name) syntax, but both formats are shown here.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #FF8000">//&nbsp;Consider&nbsp;these&nbsp;lines&nbsp;in&nbsp;a&nbsp;normal&nbsp;PHP5&nbsp;Controller:<br /></span><span style="color: #007700">class&nbsp;&nbsp;</span><span style="color: #0000BB">Forum&nbsp;&nbsp;</span><span style="color: #007700">extends&nbsp;&nbsp;</span><span style="color: #0000BB">Controller&nbsp;&nbsp;&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;&nbsp;</span><span style="color: #0000BB">__construct</span><span style="color: #007700">()&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">Controller</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br /></span><span style="color: #FF8000">//&nbsp;If&nbsp;you&nbsp;are&nbsp;using&nbsp;PHP4&nbsp;constructs,&nbsp;it&nbsp;will&nbsp;look&nbsp;like:<br /></span><span style="color: #007700">class&nbsp;&nbsp;</span><span style="color: #0000BB">Forum&nbsp;&nbsp;</span><span style="color: #007700">extends&nbsp;&nbsp;</span><span style="color: #0000BB">Controller&nbsp;&nbsp;&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;&nbsp;</span><span style="color: #0000BB">Forum</span><span style="color: #007700">()&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">Controller</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>Now, change the relevant lines to look like this:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #FF8000">//&nbsp;Modify&nbsp;them&nbsp;to&nbsp;look&nbsp;like&nbsp;this&nbsp;instead&nbsp;(for&nbsp;PHP5):<br /></span><span style="color: #007700">class&nbsp;&nbsp;</span><span style="color: #0000BB">Forum&nbsp;&nbsp;</span><span style="color: #007700">extends&nbsp;&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;&nbsp;&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;&nbsp;</span><span style="color: #0000BB">__construct</span><span style="color: #007700">()&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">MY_Controller</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br /></span><span style="color: #FF8000">//&nbsp;Or,&nbsp;for&nbsp;PHP4&nbsp;format:<br /></span><span style="color: #007700">class&nbsp;&nbsp;</span><span style="color: #0000BB">Forum&nbsp;&nbsp;</span><span style="color: #007700">extends&nbsp;&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;&nbsp;&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;&nbsp;</span><span style="color: #0000BB">Forum</span><span style="color: #007700">()&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">MY_Controller</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;&nbsp;</span>
</span>
</code></div>

<p>Now test your application - it will work exactly the same as it did previously.&nbsp; MY_Controller <i>is</i> being loaded - the extra processing time would be difficult to detect, so you&#8217;ll just have to trust me here.</p>

<p><i>If you don&#8217;t trust me - and good for you if so - you can edit the MY_Controller briefly and introduce an obvious syntax error, such as changing <b>parent</b> to <b>patent</b> for example, and then try reloading your page.&nbsp; Revert your error before continuing.</i></p>

<h3>Theory side note</h3>
<p>All we&#8217;ve done here is inserted this <b>MY_Controller</b> class in between your normal Controller and the CI Controller class.&nbsp; Previously your Controller was descended directly from the CI core.&nbsp; This is basic OO theory, but if you&#8217;re not familiar with that then a ludicrous analogy might be that we&#8217;ve just inserted a new generation between you and your dad - with your dad suddenly becoming your grand-dad.&nbsp; You have still inherited the blue eyes and sparkling wit, but it means you can also now inherit (once you create them!) things from this new intermediate ancestor - such as curly hair or date formatters.</p>



<h2>
Putting useful stuff in MY_Controller
</h2>

<p>Usually people are looking for a way of making functions accessible across all their Controllers - and so we&#8217;ll make a very simple function in your <b>MY_Controller</b> to demonstrate how this can work.</p>

<p>Edit your <b>application/libraries/MY_Controller.php</b> file again, and modify it to look like this:</p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;&nbsp;</span><span style="color: #007700">extends&nbsp;&nbsp;</span><span style="color: #0000BB">Controller&nbsp;&nbsp;&#123;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">MY_Controller&nbsp;</span><span style="color: #007700">()&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent</span><span style="color: #007700">::</span><span style="color: #0000BB">Controller</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Pretty&nbsp;date<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Takes&nbsp;an&nbsp;ISO8601&nbsp;formatted&nbsp;date&nbsp;and&nbsp;returns&nbsp;a&nbsp;human-friendly&nbsp;form,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;by&nbsp;rounding&nbsp;the&nbsp;time&nbsp;to&nbsp;the&nbsp;nearest&nbsp;hour.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;eg.&nbsp;2009-05-31T15:42:07&nbsp;&nbsp;==&gt;&nbsp;&nbsp;"2009-05-31&nbsp;~&nbsp;4pm"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;&nbsp;&nbsp;&nbsp;$date_in&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;(iso8601&nbsp;date)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;&nbsp;&nbsp;&nbsp;string<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;&nbsp;</span><span style="color: #0000BB">pretty_date&nbsp;</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$date_in&nbsp;</span><span style="color: #007700">)&nbsp;&nbsp;</span><span style="color: #0000BB">&#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">strlen&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$date_in</span><span style="color: #007700">)&nbsp;!=&nbsp;</span><span style="color: #0000BB">19</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$date_in</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;return&nbsp;in&nbsp;confusion!<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$date_in</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$mm&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$date_in</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">14</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$mm&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hh</span><span style="color: #007700">++;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;(</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">23</span><span style="color: #007700">)&nbsp;OR&nbsp;(</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">'00'</span><span style="color: #007700">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hh_string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"midnight"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hh_string&nbsp;</span><span style="color: #007700">=&nbsp;(</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">)&nbsp;.</span><span style="color: #DD0000">"pm"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hh_string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"midday"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$hh_string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$hh&nbsp;</span><span style="color: #007700">.</span><span style="color: #DD0000">"am"</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$output&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">substr&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$date_in</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">)&nbsp;.</span><span style="color: #DD0000">"&nbsp;~&nbsp;"</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$hh_string</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$output</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;end-function&nbsp;&nbsp;pretty_date&nbsp;()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">&#125;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;end-class&nbsp;MY_Controller&nbsp;</span>
</span>
</code></div>

<h2>
Using a MY_Controller method from your Controller
</h2>

<p>The pretty_date() function above is particularly useful for ISO8601 timestamps that come in from EXIF information, for example.&nbsp; We&#8217;ll just use a hard-coded input string here.</p>

<p>Edit your functioning Controller and add in a reference to this function.&nbsp; I&#8217;ll assume you&#8217;re using $this-&gt;data for your view data, and that you have a view file you can use this in.&nbsp; You&#8217;ll see that we simply use the <b>$this-&gt;</b> prefix, which will look in the parent controller (in this case MY_Controller) for a matching method or attribute.</p>

<div class="codeblock"><code><span style="color: #000000">
<span style="color: #FF8000">//&nbsp;somewhere&nbsp;in&nbsp;one&nbsp;of&nbsp;your&nbsp;application's&nbsp;Controller&nbsp;files<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">...<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">data&#91;</span><span style="color: #DD0000">'friendly_date'</span><span style="color: #0000BB">&#93;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">pretty_date&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">"2009-05-31T16:42:07"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;...<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">view&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">'your_view'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">data</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;</span>
</span>
</code></div>

<p>In your view you can now <b>echo $friendly_date</b> - so go and make that change to your view file and then reload your web page to confirm that it&#8217;s all tickety-boo.</p>

<p>Impressive, eh?</p>

<p>&nbsp;</p>

<h2>
Final notes on this method
</h2>

<p>This is a fairly trivial example of what you can do with MY_Controller - most people would put a function like pretty_date() into a helper, as it requires no database access, and is only needed for views that have to generate a pretty date from an ISO8601 one.</p>

<p>More often you would use a MY_Controller for &#8216;on-every-page-load&#8217; activities like:<br />
 <b>o</b> calling models to retrieve database information,<br />
 <b>o</b> setting / retrieving Session data,<br />
 <b>o</b> applying an authentication layer - often tied in with Session data,<br />
 <b>o</b> generating common view partials (headers, footers, menus).</p>

<p>As an example of the last one there, have a read of Jedd&#8217;s <a href="/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/">header, footer and menu on every page</a> article.</p>]]></description>
      <dc:subject>MY Controller</dc:subject>
      <dc:date>2012-03-20T04:31:56+00:00</dc:date>
    </item>

    
    </channel>
</rss>
