A Very Simple Theme Switcher for Codeigniter

June 15, 2011

I am using this library for all of my Codeigniter projects and I was thinking how to dynamically change the theme of the website.

My first thought was to dynamically change the “views” of CI_Loader but it seems to be very hard to do without editing the Core.

Codeigniter doesn’t actually let you extend the Core by using hooks but extending the library ( which is confusing when you read the documentation).

/system/core/Loader.php

function __construct()
 {
 $this->_ci_view_path = APPPATH.'views/';
 $this->_ci_ob_level  = ob_get_level();
 $this->_ci_library_paths = array(APPPATH, BASEPATH);
 $this->_ci_helper_paths = array(APPPATH, BASEPATH);
 $this->_ci_model_paths = array(APPPATH);
 log_message('debug', "Loader Class Initialized");
 }

Note that the views folder is hard-coded. I would suggest to have ci_view_path to be on of the config items.

But anyway by using the library of Jerome (http://maestric.com/doc/php/codeigniter_template) , you can easily achieve a dynamic theme without changing it. Below is the code:

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

class Template {
 var $template_data = array();

 function set($name, $value)
 {
 $this->template_data[$name] = $value;
 }

 function load($template = '', $view = '' , $view_data = array(), $return = FALSE)
 {               
 $this->CI =& get_instance();
 $user_template = isset($_SESSION['template']) ? $_SESSION['template'] : 'default';             
 $this->set('contents', $this->CI->load->view($user_template.'/'.$view, $view_data, TRUE));            
 return $this->CI->load->view($user_template.'/'.$template, $this->template_data, $return);
 }
}

Now, you have a theme inside the views folder..

/application/views/default/
/application/views/theme1/
/application/views/theme2/

Simple right!

I am now loving Fotolia!!

March 22, 2011

After a few downloads of vectors and images from Fotolia for my web design and mobile development services, I can clearly say that they are way better than my previous stock photo company.

Compared to other stock agencies, Fotolia (www.fotolia) is rather young but it has gained popularity and good reviews both from contributors and customers.  Like other sites shelling the same type of business, this site is a good place to get images for creative purposes for a lesser cost. Since it was launched, there are almost 12 million photos, vectors and videos available. Fotolia also have 15 regional sites like Japan and Brazil. The site’s lay-out is uncomplicated – simple and clean. With this, the site is easy to navigate and user-friendly with less reported problems when it comes to uploading images and videos.

Collection

As mentioned, Fotolia has a large database. This is good for potential buyers to have more choices in terms of image selection. On the other side, this large number of images means stiff competition. Contributors have to exert extra effort to have their images stick out in the crowd. Image and video collections are also well-organized for easy and fast browsing. Images have specific categories like abstract, business, concept, emotion and architecture. Customers can excpet faster and more concise image selection. Site’s visitors can also check images taken in a specific country.

Contributors

One of the good things about Fotolia is it is open for beginners. As long as you want to have good exposure for your work or hobby, then you are free to set up an account. Photographers, designers and art directors make up of its contributor’s population. Unlike other stock agencies that only offer a public profile, Fotolia’s contributor’s have their own personal site with their “my Fotolia’s site”. This is a good venue for contributor’s to organize their submissions and even their rankings and earnings.

In order to earn money, Fotolia practices commission structuring as well as referral schemes. Like other commission-based agencies, your commission will increase as you sell more images. Same with referral, you earn each time your referral sells an image. One of the issues that contributors raise is how the site changes their policies. Many complain that Fotolia easily changes their guidelines specifically those in related to sales.

Costumers

Fotolia is a royalty –free sock agency which makes it very popular for its potential customers. When you buy an image, you can use it more than once without paying any royalty. This will make this site very cheap and good for small businesses. Customers can buy an image for less than $2. They also have many free images for customers to upload and use for free. This is a fair deal specifically for those who are on limited financial resources. Lastly, Fotolia offers subscription plans that can make one image upload as low as 14 cents.

With more than 2 million accounts and 9 million images and vidos, the future is bright for Fotolia. Cheaper fees make this site a great place to scout for images. Its easy features and over-all structure welcome more artists and designers to join their sturdy family. When looking for other reviews, Fotolia receives both fair and excellent assessments but for now, this site is one of the best stock agencies to choose especially if you are a beginner.

MYSQL Date/Time Range Query Example

November 14, 2010

1.       Get Date Range
SELECT * from tbl_events WHERE eventdate BETWEEN ‘2010-11-11’ AND ‘2010-11-30’

2.       Get year events

SELECT * FROM tbl_events WHERE YEAR(eventdate) = ‘2010’

3.       Get Month and Year Events

SELECT * from tbl_events WHERE eventdate BETWEEN ‘2010-11-1′ AND ‘2010-11-30′

4.       Get Events greater than Today or NOW

SELECT * from tbl_events HAVING eventdate >  CURDATE()

To get the number of days in a month use cal_days_in_month function.

Facebook Fake Email

September 19, 2010

Please be aware of this email!

Starcraft 2 : Wings of Liberty – Fireworks / PSD Template

July 28, 2010

Starcraft 2 : Wings of Liberty Fireworks Template for only 25.00 USD

- This template is based on Starcraft 2 Fan Site Kit.
- Made using Adobe Fireworks CS4+.
- High Quality and best for your Starcraft fan page.
- Can be saved as PSD.
- Payment via Paypal (webmaster@keithics.com)
- HTML is optional, just add 25USD for 1 homepage and 1 template.

Preview Below: Homepage at 90% from original (click to view)