<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nabil Kadimi &#187; English</title>
	<atom:link href="http://www.kadimi.com/en/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kadimi.com</link>
	<description>Freelance Web Developer - Morocco</description>
	<lastBuildDate>Mon, 20 May 2013 13:22:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Drupal Commerce: Redirect to cart after adding a product</title>
		<link>http://www.kadimi.com/en/drupal-commerce-redirect-to-cart</link>
		<comments>http://www.kadimi.com/en/drupal-commerce-redirect-to-cart#comments</comments>
		<pubDate>Sat, 18 May 2013 19:45:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://www.kadimi.org/k/?p=1300</guid>
		<description><![CDATA[Sometimes, you want the visitor to go directly to the cart, instead of staying in the same page and having a success message telling him that his product has been added to the cart. In order to go directly to &#8230; <a href="http://www.kadimi.com/en/drupal-commerce-redirect-to-cart">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Sometimes, you want the visitor to go directly to the cart, instead of staying in the same page and having a success message telling him that his product has been added to the cart.</p>
<p>In order to go directly to the cart, add (import) this Rule from <strong>Admin</strong> &gt;<strong> Configuration &gt; Workflow &gt; Rules &gt; Import rule</strong>, Or <code>http://www.example.com/?q=admin/config/workflow/rules/reaction/import</code></p>
<pre>{ "rules_redirect_to_cart" : {
    "LABEL" : "Redirect to cart",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules_conditional", "rules", "commerce_cart" ],
    "ON" : [ "commerce_cart_product_add" ],
    "DO" : [ { "CONDITIONAL" : [  ] }, { "redirect" : { "url" : "cart" } } ]
  }
}</pre>
<p>Very usefull for single product websites, subcriptions based services and deals websites.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/drupal-commerce-redirect-to-cart/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress and dashes (m-dash &amp; n-dash)</title>
		<link>http://www.kadimi.com/en/wordpress-dashes</link>
		<comments>http://www.kadimi.com/en/wordpress-dashes#comments</comments>
		<pubDate>Wed, 24 Apr 2013 02:04:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.kadimi.org/k/?p=1217</guid>
		<description><![CDATA[I got you there, I too didn&#8217;t know there were n and m dashes &#8220;&#8211;&#8221; and &#8220;&#8212;&#8221;. Anyways, the process of using one of these in my life was something like this: Search Google for &#8220;mdash&#8221; Use my eye scanning &#8230; <a href="http://www.kadimi.com/en/wordpress-dashes">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.kadimi.com/files/2013/04/dash.png"><img class="size-full wp-image-1224 alignright" alt="Dashes and Hyphens" src="http://www.kadimi.com/files/2013/04/dash.png" width="282" height="214" /></a>I got you there, I too didn&#8217;t know there were n and m dashes &#8220;&#8211;&#8221; and &#8220;&#8212;&#8221;.</p>
<p>Anyways, the process of using one of these in my life was something like this:</p>
<ol>
<li>Search Google for &#8220;mdash&#8221;</li>
<li>Use my eye scanning techinque to find any dash which looks longer than usual</li>
<li>CTRL-C, CTRL-V</li>
<li>life goes on</li>
</ol>
<p>Tired of this repetitive process, I decided to replace n/m dashe with hyphen (-), those looked unfamiliar and rather creepy ( -example-), so I changed my mind again and decided to use double hyphens (- -).</p>
<p>Surprise! WordPress turns automatically any 2 consecutive and uspaced hyphens into n-dashs and any 3 hyphens into m-dashs, like this see:</p>
<ul>
<li>2 dashes: &#8211;</li>
<li>3 dashes: &#8212;</li>
</ul>
<p>Well, it&#8217;s not that simple, so for those of you who really want to know the origin of things, check the <a href="http://core.trac.wordpress.org/browser/trunk/wp-includes/formatting.php#L29">wptexturize() function</a>, specially <a href="http://core.trac.wordpress.org/browser/trunk/wp-includes/formatting.php#L73">around thoses lines</a>.</p>
<p>If you don&#8217;t like this behaviour, and your life depends on the hyphens remaining hyphens, you can use this <a href="http://wordpress.org/support/topic/issue-with-double-dash#post-2643315">small plugin</a>:</p>
<pre>&lt;?php
/*
Plugin Name: Remove the wptexturize filter
*/
remove_filter( 'the_title' , 'wptexturize'  );
remove_filter( 'the_content' , 'wptexturize' );
remove_filter( 'the_excerpt' , 'wptexturize' );
remove_filter( 'comment_text' , 'wptexturize' );
remove_filter( 'list_cats' , 'wptexturize' );</pre>
<p>Name the file as you want but make sure you <strong>place it under the wp-content/plugins</strong> directory and you <strong>enable the plugin</strong> in your awesome website dashboard.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/wordpress-dashes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla 3.0 &#8211; Fix Application Instantiation Error</title>
		<link>http://www.kadimi.com/en/joomla-3-0-fix-application-instantiation-error</link>
		<comments>http://www.kadimi.com/en/joomla-3-0-fix-application-instantiation-error#comments</comments>
		<pubDate>Wed, 24 Apr 2013 01:48:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Joomla]]></category>

		<guid isPermaLink="false">http://www.kadimi.org/k/?p=1212</guid>
		<description><![CDATA[Everything went smoothly as usual in my local machine, but as soon as I moved the website to the client server, it wouldn&#8217;t run normally, instead it gives me the dreaded error message: Error displaying the error page: Application Instantiation &#8230; <a href="http://www.kadimi.com/en/joomla-3-0-fix-application-instantiation-error">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Everything went smoothly as usual in my local machine, but as soon as I moved the website to the client server, it wouldn&#8217;t run normally, instead it gives me the dreaded error message:</p>
<pre>Error displaying the error page: Application Instantiation Error</pre>
<p>After a small search on Google, I found that all people were saying to check that the database connection credentials were correct in <strong>configuration.php</strong>, in fact, I&#8217;m not new to this thing but I checked again&#8230;</p>
<pre>
	public $host = 'localhost';
	public $user = 'me';
	public $password = 'P0L1C3';
	public $db = 'my_db';
</pre>
<p>To my big surprise, the error was with the server not having the mysqli extension, this is rather inconvenient in 2013, and to add insult to irony, magic quotes were turned on, anyways, I got things to work &#8220;normally&#8221; after changing the $dbtype from mysqli to mysql:</p>
<pre>
	public $dbtype = 'mysql';
</pre>
<p>Sad but true&#8230;</p>
<p>PS.<br />
If &#8211;like me&#8211; you were migrating a website, don&#8217;t forget to change the $log_path and $tmp_path near the end of the configuration file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/joomla-3-0-fix-application-instantiation-error/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal certification &#8211; How much time to be an 11</title>
		<link>http://www.kadimi.com/en/drupal-certification-how-much-time-to-be-an-11</link>
		<comments>http://www.kadimi.com/en/drupal-certification-how-much-time-to-be-an-11#comments</comments>
		<pubDate>Sat, 16 Feb 2013 03:12:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=1166</guid>
		<description><![CDATA[There is no official Drupal certification, but there is better. Today, at 2am, I decided to track my improvements in Drupal with Certified to Rock, my goal for now is not to be an 11, a tiny 3 will suffice, &#8230; <a href="http://www.kadimi.com/en/drupal-certification-how-much-time-to-be-an-11">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><img class="alignleft  wp-image-1168" alt="i-m-a-2" src="http://www.kadimi.com/files/2013/02/i-m-a-2.png" width="934" height="296" />There is no official Drupal certification, but there is <a title="Certified to Rock" href="http://certifiedtorock.com/">better</a>.</p>
<p>Today, at 2am, I decided to track my improvements in Drupal with <a href="http://certifiedtorock.com/">Certified to Rock</a>, my goal for now is not to be an 11, a tiny 3 will suffice, well&#8230; I&#8217;m a 2&#8230; that&#8217;s why.</p>
<p>How I will do it inshaallah, simple, 2-&gt;3-&gt;[...]-&gt;11, better yet, I will:</p>
<ul>
<li>Participate in the Drupal forum</li>
<li>and in Drupal Answers (Stack Exchange), it&#8217;s not monitored by the CTR meter but it&#8217;s funny and extremely educational,</li>
<li>Convince my next client to allow me to use Drupal using the killer argument &#8220;it&#8217;s used by the White House and Le Louvre&#8221;&#8230; who knows what those are!</li>
<li>Investigate more time in core APIs (menus, forms, fields) and other interesting APIs (Drupal Commerce)</li>
<li>Use useful modules (views, panels, Drupal Commerce)</li>
<li>Find some modules that needs co-maintainers</li>
<li>Suggest patches</li>
<li>Follow Drupal 8 discussions</li>
<li>Follow Dries, merlinofchaos, webchick, sun and some others I don&#8217;t remember now.</li>
</ul>
<p>Please excuse any mistakes, I&#8217;m a 2.</p>
<p>If you&#8217;re with me in this, please use the comments to track <a href="http://certifiedtorock.com/">your score</a>, the score is calculated every quarter using some complex math based on your Drupal presence.</p>
<p>Let&#8217;s do it, it won&#8217;t hurt (اللي ما قتلات تسمن = what doesn&#8217;t kill makes fatter).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/drupal-certification-how-much-time-to-be-an-11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: empty() is your friend</title>
		<link>http://www.kadimi.com/en/php-empty-usage</link>
		<comments>http://www.kadimi.com/en/php-empty-usage#comments</comments>
		<pubDate>Mon, 12 Nov 2012 11:37:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=1147</guid>
		<description><![CDATA[It&#8217;s easy to miss things that are very obvious, this is the proper way to check that a variable has a value that is not nothing (null, 0, FALSE, &#8220;false&#8221;, array(), etc) without getting PHP E_NOTICE messages (that I encourage &#8230; <a href="http://www.kadimi.com/en/php-empty-usage">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="attachment_1154" class="wp-caption alignright" style="width: 167px"><img class=" wp-image-1154 " title="Box" alt="" src="http://www.kadimi.com/files/2012/11/box.gif" width="157" height="139" /><p class="wp-caption-text">The right question is: Is it empty?</p></div>
<p>It&#8217;s easy to miss things that are very obvious, this is the proper way to check that a variable has a value that is not nothing (null, 0, FALSE, &#8220;false&#8221;, array(), etc) without getting PHP E_NOTICE messages (that I encourage you to show when developing):</p>
<pre>// Check that $var is set and is not empty:

// 1. The WRONG way
if($var){
  // ... 
}

// 2. The LONG way
if(isset($var) &amp;&amp; $var){
  // ...
}

// 3. The I ROCK way
if(!empty($var)){
  // ...
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/php-empty-usage/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tiny Checker: probably the best Pagerank, Alexa and domain name lookup tool</title>
		<link>http://www.kadimi.com/en/tinychecker</link>
		<comments>http://www.kadimi.com/en/tinychecker#comments</comments>
		<pubDate>Sat, 15 Sep 2012 22:11:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=1123</guid>
		<description><![CDATA[Today I want to show you Tiny Checker and explain why it&#8217;s probably the best tool that exists so far for: Checking domain name availability Checking Alexa ranking Checking PageRank User friendly (secure, intuitive, fast&#8230;) It&#8217;s secure, it doesn&#8217;t monitor &#8230; <a href="http://www.kadimi.com/en/tinychecker">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Today I want to show you <a title="Instant Pagerank, Alexa and domain nome lookup" href="http://tinychecker.com/">Tiny Checker</a> and explain why it&#8217;s probably the best tool that exists so far for:</p>
<ul>
<li>Checking domain name availability</li>
<li>Checking Alexa ranking</li>
<li>Checking PageRank</li>
</ul>
<div id="attachment_1126" class="wp-caption alignright" style="width: 690px"><a href="http://www.tinychecker.com/"><img class=" wp-image-1126 " title="Tiny Checker preview" alt="Tiny Checker preview" src="http://www.kadimi.com/files/2012/09/tinychecker.png" width="680" height="301" /></a><p class="wp-caption-text">Tiny Checker preview &#8211; Tiny Checker is the perfect tool for finding the perfect domain</p></div>
<h2>User friendly (secure, intuitive, fast&#8230;)</h2>
<p>It&#8217;s<strong> secure</strong>, it doesn&#8217;t monitor your searches, ever happened to you on other tools? You find a great domain name and a few hours later it&#8217;s registered by someone else&#8230; It happened to me and I don&#8217;t want it to happen to you.</p>
<p>It&#8217;s<strong> intuitive</strong> and<strong> lightning fast</strong>, I don&#8217;t want you to spend hours waiting for pages to load or typing captchas, I did my best to make it as user friendly as possible, I want you to feel at home</p>
<p>It&#8217;s <strong>free</strong>, now and forever.</p>
<h2>But&#8230; It could be better</h2>
<p>I had a lot of positive reviews, people like it,  but nothing is still perfect, I need your help to make it better, so what can you do?</p>
<ul>
<li>Give it a try (in other words &#8220;abuse it&#8221;) &#8211; here&#8217;s the link again: <a href="http://www.tinychecker.com">http://www.tinychecker.com</a></li>
<li>Write your critics in the comments section below</li>
<li>Get more people to use (share on Facebook, Twitter, etc)</li>
</ul>
<p>I will do my best to respond to all your requests in a timely manner.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/tinychecker/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Are you missing opportunities? I bet you do!</title>
		<link>http://www.kadimi.com/en/opportunities</link>
		<comments>http://www.kadimi.com/en/opportunities#comments</comments>
		<pubDate>Wed, 30 May 2012 21:54:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Quotes I like]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=1057</guid>
		<description><![CDATA[Probably not the next internet meme, I don&#8217;t think you are interested in seeing it, yes it&#8217;s funny but rather mediocre humor compared to what you can find online. But when deciding to post it or not, I remembered how &#8230; <a href="http://www.kadimi.com/en/opportunities">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Probably not the next internet meme, I don&#8217;t think you are interested in seeing it, yes it&#8217;s funny but rather mediocre humor compared to what you can find online.</p>
<div id="attachment_1062" class="wp-caption aligncenter" style="width: 266px"><img class="size-full wp-image-1062" title="Funny captcha" alt="Funny captcha" src="http://www.kadimi.com/files/2012/05/recaptcha.png" width="256" height="156" /><p class="wp-caption-text">Funny captcha</p></div>
<p>But when deciding to post it or not, I remembered how many times I missed a very good opportunity because I didn&#8217;t feel it or I didn&#8217;t want to invest $10 on that domain name only to see it on sale at thousands of dollars a week later, or  &#8211; ever worse &#8211; by pure laziness to try.</p>
<blockquote><p>Opportunities? They are all around us&#8230; there is power lying latent everywhere waiting for the observant eye to discover it.</p>
<p style="text-align: right;">Orison Swett Marden</p>
</blockquote>
<p>What&#8217;s the biggest opportunity you have missed? Why did you let it by? Do you regret it? why?&#8230; Write a comment about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/opportunities/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL tip: Update a column with random values</title>
		<link>http://www.kadimi.com/en/mysql-random-column-values</link>
		<comments>http://www.kadimi.com/en/mysql-random-column-values#comments</comments>
		<pubDate>Mon, 28 May 2012 23:18:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=1033</guid>
		<description><![CDATA[I&#8217;m always impressed with what you can do with MySQL (my favorite RDBMS), not long ago I needed to add a column in a table and fill it with some random values. Instead of using a PHP (could be C, &#8230; <a href="http://www.kadimi.com/en/mysql-random-column-values">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="attachment_1048" class="wp-caption alignright" style="width: 260px"><img class="size-full wp-image-1048" title="Random string in MySQL" alt="Random string in MySQL" src="http://www.kadimi.com/files/2012/05/mysql_string_random.jpg" width="250" height="250" /><p class="wp-caption-text">Random string in MySQL</p></div>
<p>I&#8217;m always impressed with what you can do with MySQL (my favorite RDBMS), not long ago I needed to add a column in a table and fill it with some random values. Instead of using a PHP (could be C, Java, perl&#8230;) script that goes row by row and calculates a random value, I thought it would be challenging to do it with a single SQL query.</p>
<h2>Generate a random character</h2>
<pre>-- This query returns a random character from the string chars_str
-- Replace chars_str with a string containing the acceptabe characters
SELECT SUBSTRING(chars_str , 1+ FLOOR(RAND()*LENGTH(chars_str)) ,1);

-- Example
SELECT SUBSTRING('01234567' , 1+ FLOOR(RAND()*LENGTH('01234567')) ,1) AS random_octal;
+--------------+
| random_octal |
+--------------+
| 6            |
+--------------+</pre>
<h2>Generate a random string of characters</h2>
<p>In order to generate a random string we need to generate many random characters, thus we need to repeat the previous query, or we can simply create a table and have the query executed on each rows of that table, MySQL will generate for us one random character per table row and we&#8217;ll concatenate them (with GROUP_CONCAT [...] SEPARATOR &#8221; )to produce our final random string:</p>
<pre>-- This query returns a random string constitud of characters from the string chars_str
-- Replace chars_str with a string containing the acceptabe characters
-- The string length is the length of dummy_tbl which corresponds to the number of SELECT you have in the FROM
SELECT GROUP_CONCAT(SUBSTRING(chars_str , 1+ FLOOR(RAND()*LENGTH(chars_str)) ,1) SEPARATOR '') 
FROM (SELECT 1 /* UNION SELECT 2 ... UNION SELECT n */) as dummy_tbl;

-- Example
SELECT GROUP_CONCAT(SUBSTRING('01' , 1+ FLOOR(RAND()*LENGTH('01')) ,1) SEPARATOR '') as random_binary
FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) as dummy_tbl;
+---------------+
| random_binary |
+---------------+
| 0111          |
+---------------+</pre>
<h2>Update a column with random values</h2>
<p>Now need to update the column of our database with random values, we will do so by nesting the query that generates random values into a normal UPDATE statement</p>
<pre>-- column_name.tbl_name is the column we want to update
UPDATE tbl_name SET column_name = (
  SELECT GROUP_CONCAT(SUBSTRING(chars_str , 1+ FLOOR(RAND()*LENGTH(chars_str)) ,1) SEPARATOR '')
  FROM (SELECT 1 /* UNION SELECT 2 ... UNION SELECT n */) as dummy_tbl
);

-- Example
UPDATE tickets SET code = (
  SELECT GROUP_CONCAT(SUBSTRING('123abcABC-_$@' , 1+ FLOOR(RAND()*LENGTH('123abcABC-_$@')) ,1) SEPARATOR '')
  FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) as dummy_tbl
);</pre>
<p>There you have it, there is probably a better &#8211; and more of less complicated &#8211; way to do it, you may want to try doing the same thing with procedure, if you do please share your results on the comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/mysql-random-column-values/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP MVC tutorial for beginners &#8211; Part 1: What is MVC?</title>
		<link>http://www.kadimi.com/en/php-mvc-for-beginners-part-1</link>
		<comments>http://www.kadimi.com/en/php-mvc-for-beginners-part-1#comments</comments>
		<pubDate>Sat, 26 May 2012 19:17:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=1016</guid>
		<description><![CDATA[The MVC design pattern separates business logic from user interface Model–View–Controller is a design pattern or a software engineering concept that separates the model, the view and the controller from each others, thus dividing the labour in your application in &#8230; <a href="http://www.kadimi.com/en/php-mvc-for-beginners-part-1">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>The MVC design pattern separates business logic from user interface</h2>
<p>Model–View–Controller is a design pattern or a software engineering concept that separates the model, the view and the controller from each others, thus dividing the labour in your application in such a way that:</p>
<p><strong>The model</strong> is the brain, the knowledge, or simply data and means to using it:</p>
<ul>
<li>it knows where data is, how to access it and how to change it</li>
<li>it responds to requests about data state</li>
<li>it responds to instructions to change data state</li>
</ul>
<p><strong>The view</strong> holds the presentation logic like templating and caching, in a PHP MVC application it may range from a few  html templates with PHP tags for inserting request specific data to a bunch of templates using a templating engine such as Smarty.</p>
<p><strong>The controller</strong> acts as the mediator, like a  front desk agent or the guy that takes your order and serves your dish at a McDonald&#8217;s:</p>
<ul>
<li>it receives the client (visitor&#8217;s browser) input in the form of GET or POST requests</li>
<li>it could possibly verify and validate user input</li>
<li>it instructs a the model to execute a specific action depending on the input it received</li>
</ul>
<hr />
<h2>The Key benefits of using MVC</h2>
<h3>Separation of concerns</h3>
<p title="Separation of concerns">By separating the data logic (the model), the presentation logic (the view) and the application logic (the controller) you make sure that there is no interference between the three allowing you to work on and optimize each one dependently from the other two.</p>
<p title="Separation of concerns">Let&#8217;s assume a scenario where we have a data driven website that we made with MVC in mind, this website needs a graphical redesign, we&#8217;ll simply hire an excellent web designer, which happens to be not so good at programming but we don&#8217;t care, all he will see is the website template files (our views).</p>
<p title="Separation of concerns">Now we heard that PostgreSQL offers better performance and we want to switch from X to PostgreSQL, fine, all we have to do is migrate our database and modify our model, of course we will not modify a single line on the controller or view logic.</p>
<h3>Code reuse</h3>
<p>Data returned by the model  is &#8220;pure&#8221; data, free from any formatting or presentation, when you need to present data to the user you write a view or more if you are offering the same data in many formats (HTML, XML, file for download&#8230;). The model is written only once and is reused by the views, there is no code duplication and you don&#8217;t waste your time rewriting code that does the same or almost the same thing.</p>
<p>By using MVC, you will end up having a library of well organized components that you can reuse on the same application and in other applications as well, this will drastically increase your productivity.</p>
<p><strong>Part 2 : Writing a small PHP application with MVC (coming soon)&#8230;</strong></p>
<p>In part 2 you will <strong>write your first MVC application</strong>, yes you will write models,  views and controllers, it&#8217;s gonna be fun, so don&#8217;t miss it, subscribe to my RSS or follow me on the social network of your choice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/php-mvc-for-beginners-part-1/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP code to remove breadcrumbs in a Drupal page</title>
		<link>http://www.kadimi.com/en/drupal-disable-breadcrumbs</link>
		<comments>http://www.kadimi.com/en/drupal-disable-breadcrumbs#comments</comments>
		<pubDate>Mon, 19 Mar 2012 11:18:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://www.kadimi.com/en/?p=982</guid>
		<description><![CDATA[Sometimes you want to hide the breadcrumbs in a single page an keep it in the others, either using a module or inside a node. You can remove the breadcrumb from a Drupal page with this line of code: This &#8230; <a href="http://www.kadimi.com/en/drupal-disable-breadcrumbs">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Sometimes you want to hide the breadcrumbs in a single page an keep it in the others, either using a module or inside a node.</p>
<p>You can remove the breadcrumb from a Drupal page with this line of code:</p>
<p>This is how I do it:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">drupal_set_breadcrumb<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kadimi.com/en/drupal-disable-breadcrumbs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
