Automatic config Base_url in CodeIgniter
Posted on Friday 17 July 2009

If you don‘t like to change the base_url in your Codeigniter config file every time you move your application. Just replace it with the following:
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
It also works with https.
How to resize youtube or vimeo movies with PHP
Posted on Wednesday 27 May 2009

You have to use the preg_replace php function here. The $video variable holds the embed code fromyoutube, vimeo or other similar website that use these parameters in their embed codes in the example. You can change the width and height in the second parameter. This will replace the width and height parameters in you embed code with you desired width. That way inserted video‘s by users won‘t mess up your layout.
$video = preg_replace('/(width)=("[^"]*")/i', 'width="270"', $video);
$video = preg_replace('/(height)=("[^"]*")/i', 'height="270"', $video);
Add www to your domain or remove the www from your domain
Posted on Tuesday 26 May 2009

This is important not only for aesthetic reasons, but for SEO (Search Engine Optimization). Forcing www before your domain or removing it prevents search engines from ending up with duplicate results and different page ranks per page. Some websites don‘t even return a page when you leave out the www. This depends on how your webserver is set up.
Multi-language support with Smarty
Posted on Wednesday 13 May 2009
Languages have always been a stumbling block for developers. With smarty you can make language files containing all the words that need to be translated and smarty will replace the language variables with the correct language. Smarty is also able to automatically check the browser language. I found this language class on the http://smarty.incutio.com/ website.
How to force plaintext insertion on paste in tiny_mce
Posted on Sunday 10 May 2009
Several clients of ours seem to type the text for their websites in a Word document fires and copy them afterwards in tiny_mce. Apparently tiny_mce copies the layout from word or any other program so the layout in your website gets messed up. I found a solution for this. You have to enforce pasting as plaintext which removes all markup when you paste something within tiny_mce.
copy these lines within your init function:
//force text to be pasted as plaintext
setup: function(ed) {
ed.onPaste.add( function(ed, e, o) {
ed.execCommand('mcePasteText', true);
return tinymce.dom.Event.cancel(e);
});
},
Getting started with Smarty templating
Posted on Thursday 7 May 2009

A few days ago I started using smarty. I was amazed by what you can do with this templating engine. Smarty is a templating engine written in php which allows you to easily split the PHP code from your html code. The smarty developers call it a "Template/Presentation Framework” because it‘s not just a tag replacing template engine. Templating is especially useful when you work with web designers who have little or no knowledge of PHP. They can easily change the html code in the tpl files without being bombarded with PHP code. I am a web developer and I started using a templating class which just enabled me to assign variables and blocks. I now use smarty for my CMS. It took me about 2,5 days to implement it because the templating class I used, worked completely different from Smarty. Smarty enables me to loop through arrays, use modifiers (which are basically custom PHP functions that work within smarty), cache files, debugging and so much more.