<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0" xml:base="http://ivansotof.com/feed">
  <channel>
    <title>Ivan Soto weblog</title>
    <link>http://ivansotof.com/feed</link>
    <description />
    <language>en</language>
          <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ivansotof-weblog" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
    <title>Create your own node submission form</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/J2AGjYsIsaA/create-your-own-node-submission-form</link>
    <description>&lt;p&gt;A lot of times you have to make the node/add page look just the way you want, and you usually start complaining that it's technically impossible with Drupal. There are a lot of techniques for this but I will be talking about one in particular which is creating your own little module that does the job.&lt;/p&gt;
&lt;h3&gt;Creating a module? Isn't that really hard?&lt;/h3&gt;
&lt;p&gt;Not really, it's simpler that it sounds and in this case it won't have more than 60 lines of code.&lt;/p&gt;
&lt;p&gt;Our module will be called &lt;strong&gt;Apply&lt;/strong&gt;, and it will basically show a form so users can apply for something. It will create a node based on a custom node type we will create.&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Go to sites/all/modules&lt;/li&gt;
    &lt;li&gt;Create a folder called &lt;strong&gt;apply&lt;/strong&gt;&lt;/li&gt;
    &lt;li&gt;Create 2 files: &lt;strong&gt;apply.module&lt;/strong&gt; and &lt;strong&gt;apply.info&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;!--break--&gt;
&lt;p&gt;Now we have all the necessary files to create our module, so let's get our favorite text editor and open apply.info and fill some basic information so Drupal can recognize our module.&lt;/p&gt;
&lt;pre class="brush: php;" title="code"&gt;
name = Apply to something
description = Let users submit applications to something
package = Other
core = 6.x
dependencies[] = content
&lt;/pre&gt;
&lt;p&gt;That's it on this file. Basically we need a name, a description, which package the module will be under, the Drupal core version needed and the dependencies. For this case we will need the &lt;strong&gt;content&lt;/strong&gt; module (CCK).&lt;/p&gt;
&lt;p&gt;Now we open apply.module and the very first thing we add is the menu hook. This hook let us create an specific path on our site and use a callback function to display content on it.&amp;nbsp;&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
/**
 * Implementation of hook_menu().
 */
function apply_menu() {
  $items = array();
  $items['apply'] = array(
    'title' =&amp;gt; 'Submit application',
    'description' =&amp;gt; 'Does something',
    'page callback' =&amp;gt; 'drupal_get_form',
    'page arguments' =&amp;gt; array('apply_submit_form'),
    'access arguments' =&amp;gt; array('access content')
  );
  return $items;
}&lt;/pre&gt;
&lt;p&gt;On this case we create the path '&lt;strong&gt;apply&lt;/strong&gt;' and give it a tittle and description to it. We also specify which permission do you need in order to see this page ('&lt;strong&gt;access content&lt;/strong&gt;' is the most basic permission on Drupal).&lt;/p&gt;
&lt;p&gt;As you can see we are using the callback function &lt;strong&gt;drupal_get_form&lt;/strong&gt;. This tells Drupal that the page we will be rendering is a form, and the form we will use is the &lt;strong&gt;page argument&lt;/strong&gt; passed inside an array: &lt;strong&gt;array('apply_submit_form')&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;Building the form&lt;/h3&gt;
&lt;p&gt;Now it's time to build form we want to display, but first, lets enable our module.&lt;/p&gt;
&lt;p&gt;&lt;img width="522" height="140" alt="" src="/sites/default/files/Screen%20shot%202009-11-03%20at%2010_36_00%20PM.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;After we enable it we can see a new menu entry at our Navigation Menu:&lt;/p&gt;
&lt;p&gt;&lt;img width="213" height="146" alt="" src="/sites/default/files/Screen%20shot%202009-11-03%20at%2010_36_23%20PM.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Now comes the fun part, we need to build our form with Drupal and it's quite simple. Drupal has something called Form&amp;nbsp;API wich helps us to build forms as easy as building arrays. So, we create our form function (which is being called by the menu system):&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
function apply_submit_form() {
	$form = array();
	$form['name'] = array(
		'#type' =&amp;gt; 'textfield',
		'#title' =&amp;gt; 'Name'
	);
	$form['last_name'] = array(
		'#type' =&amp;gt; 'textfield',
		'#title' =&amp;gt; 'Last Name'
	);
	$form['address'] = array(
		'#type' =&amp;gt; 'textarea',
		'#title' =&amp;gt; 'Your full address',
		'#description' =&amp;gt; 'Please include aptartment number and postal code'
	);
	$form['submit'] = array(
		'#type' =&amp;gt; 'submit',
		'#value' =&amp;gt; 'Add yourself'
	);
	return $form;
}&lt;/pre&gt;
&lt;p&gt;As you can read, we have 4 elements in our form: Name, Last Name, Address and Submit. The Form API has a lot of more options and you can check them all at the &lt;a target="_blank" href="http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html"&gt;Forms API Reference&lt;/a&gt; page at Drupal.org&lt;/p&gt;
&lt;h3&gt;So, what happens when we press Submit?&lt;/h3&gt;
&lt;p&gt;Drupal will look for the same function name with a &lt;strong&gt;&lt;em&gt;_submit&lt;/em&gt;&lt;/strong&gt; appended, but before that it will try to validate it with another function with &lt;strong&gt;&lt;em&gt;_validate&lt;/em&gt;&lt;/strong&gt; appended.&lt;/p&gt;
&lt;p&gt;In our case we just want to validate the First name and if that goes well, then we can just let it pass.&lt;/p&gt;
&lt;pre class="brush: php;" title="code"&gt;
function apply_submit_form_validate($form, &amp;amp;$form_state) {
  if ($form_state['values']['name'] == '') {
    form_set_error('name', 'Please enter your first name.');
  }
}&lt;/pre&gt;
&lt;p&gt;Now that we have the form working and it actually submits, we need to build the submit function. This one will basically get the form variables and do whatever you want with them. In our case we will create a node with it.&lt;/p&gt;
&lt;p&gt;We will store the First name as the node title, the address as the body and for the Last Name we use a CCK field. I'm not so sure if this is the best idea but for demonstration purposes we will do it that way.&lt;/p&gt;
&lt;p&gt;First, we need to create a node type &amp;quot;apply&amp;quot; and create the necessary field for it. Here's a screenshot of the already created node type:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" style="width: 558px; height: 228px;" src="/sites/default/files/Screen%20shot%202009-11-04%20at%2011_39_53%20AM.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;As we can see the CCK field is called field_last. So now we can procced to create our submit function:&lt;/p&gt;
&lt;pre class="brush: php;" title="code"&gt;
function apply_submit_form_submit($form, &amp;amp;$form_state){
	$node = new StdClass();
	
	$node-&amp;gt;type = 'apply';	
	$node-&amp;gt;status = 1;
	
	// We are using the title as First Name
	$node-&amp;gt;title = $form_state['values']['name'];
	$node-&amp;gt;body = $form_state['values']['address'];
	$node-&amp;gt;field_last[0]['value'] = $form_state['values']['last_name'];
	
	node_save($node);
	drupal_set_message(t('Your application has been saved.'));
}&lt;/pre&gt;
&lt;p&gt;It's really self explanatory, first we create a node object and then we give it the corresponding values. The only different part can be the CCK field which is called in a different way (the [0] refers to the CCK option to have multiple values per field, which in our case we only allow 1).&lt;/p&gt;
&lt;p&gt;And there we have it. If everything goes well we will have a module with 4 functions: the HOOK_menu, apply_submit_form(), apply_submit_form&lt;strong&gt;_validate&lt;/strong&gt;() and apply_submit_form&lt;strong&gt;_submit&lt;/strong&gt;().&lt;/p&gt;
&lt;p&gt;Here's how our form will look like:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" style="width: 550px; height: 438px;" src="/sites/default/files/Screen%20shot%202009-11-04%20at%2011_43_50%20AM.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now in case you didn't read anything and you prefer to just copy and paste it:&lt;/p&gt;
&lt;pre class="brush: php;" title="code"&gt;
&amp;lt;?php 

/**
 * Implementation of hook_menu().
 */
function apply_menu() {
  $items = array();
  $items['apply'] = array(
    'title' =&amp;gt; 'Submit application',
    'description' =&amp;gt; 'Does something',
    'page callback' =&amp;gt; 'drupal_get_form',
    'page arguments' =&amp;gt; array('apply_submit_form'),
    'access arguments' =&amp;gt; array('access content')
  );
  return $items;
}

function apply_submit_form() {
	$form = array();
	$form['name'] = array(
		'#type' =&amp;gt; 'textfield',
		'#title' =&amp;gt; 'Name'
	);
	$form['last_name'] = array(
		'#type' =&amp;gt; 'textfield',
		'#title' =&amp;gt; 'Last Name'
	);
	$form['address'] = array(
		'#type' =&amp;gt; 'textarea',
		'#title' =&amp;gt; 'Your full address',
		'#description' =&amp;gt; 'Please include aptartment number and postal code'
	);
	$form['submit'] = array(
		'#type' =&amp;gt; 'submit',
		'#value' =&amp;gt; 'Add yourself'
	);
	return $form;
}

function apply_submit_form_validate($form, &amp;amp;$form_state) {
  if ($form_state['values']['name'] == '') {
    form_set_error('name', 'Please enter your first name.');
  }
}

function apply_submit_form_submit($form, &amp;amp;$form_state){
	$node = new StdClass();
	$node-&amp;gt;type = 'apply';	
	$node-&amp;gt;status = 1;
	// We are using the title as First Name
	$node-&amp;gt;title = $form_state['values']['name'];
	$node-&amp;gt;body = $form_state['values']['address'];
	$node-&amp;gt;field_last[0]['value'] = $form_state['values']['last_name'];
	
	node_save($node);
	drupal_set_message(t('Your application has been saved.'));
}
&lt;/pre&gt;
&lt;p&gt;I hope this short tutorial helps you get started with building modules for Drupal. Sometimes I find that creating a small module to take care of something specific is way better than dealing with our template.php file or some other solutions.&lt;/p&gt;
&lt;!--
&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"&gt;
&lt;rdf:Description rdf:about="http://ivansotof.com/2009/11/create-your-own-node-submission-form" dc:identifier="http://ivansotof.com/2009/11/create-your-own-node-submission-form" dc:title="Create your own node submission form" trackback:ping="http://ivansotof.com/trackback/53" /&gt;
&lt;/rdf:RDF&gt;
--&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/J2AGjYsIsaA" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/11/create-your-own-node-submission-form#comments</comments>
 <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/php">PHP</category>
 <pubDate>Wed, 04 Nov 2009 05:05:11 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">53 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/11/create-your-own-node-submission-form</feedburner:origLink></item>
  <item>
    <title>Drupal modules list</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/8qvrvV2KVcs/drupal-modules-list</link>
    <description>&lt;p&gt;This past monday I met a couple of Drupal developers and people who are actually interested in learning Drupal. The group was a nice mix of people sharing experiences and others trying to keep up and learn the most they can. It felt great, seeing what people expect from Drupal and what people have done with it, or what do they use Drupal for, but they all had one thing in common, &lt;strong&gt;it's always hard to find good modules or the one that you really need&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In Drupal you can take the same task in many different ways, the problem is when you get to the point where you realize that you should have chosen the other one. And&amp;nbsp;&lt;a href="http://drupal.org/node/614768"&gt;here's an example&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, this is my approach on reviewing some Drupal modules to let users know what kind of things you can do with them.&lt;/p&gt;
&lt;p&gt;Let's start:&lt;/p&gt;
&lt;p&gt;&amp;lt;!--break--&gt;&lt;/p&gt;
&lt;h3&gt;FeedAPI&lt;/h3&gt;
&lt;p&gt;This module let you create feed nodes that will be used to read feeds and process them. The usual task is create different nodes from the Feed one.&lt;/p&gt;
&lt;p&gt;It works this way: You create a Feed node and that node will be responsible for reading the feed and process it. You can do a lot with that feed (that's why its an API), but you will mostly use it to create nodes from the information it retrieves. The feed can be RSS/Atom but you can use extra modules to parse different kind of feeds like iCal, CSV, KML, etc.&lt;/p&gt;
&lt;p&gt;Also, with Feed Element Mapper you can map elements of the feed to CCK fields, taxonomies and locations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;When to use it?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The aggregator module from Drupal can also read and display feeds but doesn't offer the same flexibility than FeedAPI. If you need to do things with the data you are pulling, like using it for Views or CCK, or if you want to keep your database clean because FeedAPI can take care of removing older entries, then FeedAPI is your perfect choice.&lt;/p&gt;
&lt;p&gt;In other words, FeedAPI is &amp;quot;the way&amp;quot; to add content to your Drupal site from RSS/Atom/iCal/etc.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://drupal.org/project/feedapi"&gt;View the project&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Better Formats&lt;/h3&gt;
&lt;p&gt;This modules takes care of cleaning the site from some Drupal annoyances.&lt;/p&gt;
&lt;p&gt;You can remove the infamous &amp;quot;Formatting tips&amp;quot;, set a default text filter by role and hiding the rest, keep the formatting fieldset collapsed, etc. You set everything with permissions and the module is really lightweight and compatible. In general is a &amp;quot;must have&amp;quot; if you manage a blog or any site that wants to look clean.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://drupal.org/project/better_formats"&gt;View the project&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Views Node Feed&lt;/h3&gt;
&lt;p&gt;This is one of the examples where the module name doesn't help you know what it could be used for. It's not yet in stable version but it works pretty well.&lt;/p&gt;
&lt;p&gt;The idea with this module is being able to render Views as anything you want, RSS, XML, JSON, anything. It works very easily, when you create your Views you just need to set the style as &lt;strong&gt;Views Node Feed&lt;/strong&gt;, then select the template.&lt;/p&gt;
&lt;p&gt;The template creation is &lt;em&gt;_very_ &lt;/em&gt;simple, first you have the wrapper:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
&amp;lt;?php print &amp;quot;&amp;lt;?xml version=\&amp;quot;1.0\&amp;quot; encoding=\&amp;quot;ISO-8859-1\&amp;quot;?&amp;gt;&amp;quot;; ?&amp;gt;
&amp;lt;nodes&amp;gt;
***VIEWS_NODE_FEED_ITEMS***
&amp;lt;/nodes&amp;gt;
&amp;lt;?php drupal_set_header('Content-Type: text/xml; charset=utf-8'); ?&amp;gt;&lt;/pre&gt;&lt;p&gt;Then you add whatever you need. You can play with Devel here.&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
&amp;lt;node&amp;gt;
&amp;lt;nid&amp;gt;&amp;lt;?php print $node-&amp;gt;nid ?&amp;gt;&amp;lt;/nid&amp;gt;
&amp;lt;title&amp;gt;&amp;lt;?php print $node-&amp;gt;title ?&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;preview&amp;gt;&amp;lt;?php print $node-&amp;gt;field_image[0]['filepath'] ?&amp;gt;&amp;lt;/preview &amp;gt;
&amp;lt;votevalue&amp;gt;&amp;lt;?php print $node-&amp;gt;votevalue ?&amp;gt;&amp;lt;/votevalue&amp;gt;
&amp;lt;/node&amp;gt;&lt;/pre&gt;&lt;p&gt;That simple! And if you need arguments or anything like that, don't forget that you are using Views.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://drupal.org/project/views_node_feed"&gt;View project&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;
&lt;meta charset="utf-8" /&gt;&lt;/p&gt;
&lt;p&gt;That's for now, three modules that maybe you haven't used before, but remember that this is not a tutorial, just a short review of what to expect from these modules.&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"&gt;
&lt;rdf:Description rdf:about="http://ivansotof.com/2009/10/drupal-modules-list" dc:identifier="http://ivansotof.com/2009/10/drupal-modules-list" dc:title="Drupal modules list" trackback:ping="http://ivansotof.com/trackback/52" /&gt;
&lt;/rdf:RDF&gt;
--&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/8qvrvV2KVcs" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/10/drupal-modules-list#comments</comments>
 <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/php">PHP</category>
 <pubDate>Fri, 30 Oct 2009 03:46:23 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">52 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/10/drupal-modules-list</feedburner:origLink></item>
  <item>
    <title>Tieren Space Type</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/c_79CQMlcko/tieren-space-type</link>
    <description>&lt;table style="" width="auto" align="center"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://picasaweb.google.com/lh/photo/LkcR9FUOYrT_JmyRcAkpTQ?feat=embedwebsite"&gt;&lt;img alt="" src="http://lh4.ggpht.com/_uZOaEo7vESs/SuKUi1LqYGI/AAAAAAAACyY/w2F-I1IiR20/s400/DSC_0042.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="font-family:arial,sans-serif; font-size:11px; text-align:right"&gt;From &lt;a href="http://picasaweb.google.com/ivansotof/Models?feat=embedwebsite"&gt;Models&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table style="" width="auto" align="center"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://picasaweb.google.com/lh/photo/T_7SnnksEMY8yWqEeL0CtA?feat=embedwebsite"&gt;&lt;img alt="" src="http://lh6.ggpht.com/_uZOaEo7vESs/SuKUjb7yzjI/AAAAAAAACyc/t4yUdfiSTBE/s400/DSC_0043.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="font-family:arial,sans-serif; font-size:11px; text-align:right"&gt;From &lt;a href="http://picasaweb.google.com/ivansotof/Models?feat=embedwebsite"&gt;Models&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"&gt;
&lt;rdf:Description rdf:about="http://ivansotof.com/2009/10/tieren-space-type" dc:identifier="http://ivansotof.com/2009/10/tieren-space-type" dc:title="Tieren Space Type" trackback:ping="http://ivansotof.com/trackback/51" /&gt;
&lt;/rdf:RDF&gt;
--&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/c_79CQMlcko" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/10/tieren-space-type#comments</comments>
 <category domain="http://ivansotof.com/category/gundam">Gundam</category>
 <pubDate>Sat, 24 Oct 2009 05:49:23 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">51 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/10/tieren-space-type</feedburner:origLink></item>
  <item>
    <title>New blog, same content, now on Drupal</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/KLpk8l_SvHQ/new-blog-same-content-now-drupal</link>
    <description>&lt;p&gt;The old blog in Wordpress is now gone and I will be using Drupal from now on for my blog. The main reason of this is because I work with Drupal, it's also more flexible and overall I feel more comfortable working on it.&lt;/p&gt;
&lt;p&gt;So far, besides the change on the platform there are not so many changes, but let's list them:&lt;/p&gt;
&lt;h3&gt;Design&lt;/h3&gt;
&lt;p&gt;Even cleaner, brighter and more attractive. I like to keep it simple, I love blue tones and my personal blog is the perfect excuse to use them.&lt;/p&gt;
&lt;p&gt;The Work section also sports some nice selectors and some jQuery AJAX godness.&lt;/p&gt;
&lt;p&gt;&amp;lt;!--break--&gt;&lt;/p&gt;
&lt;h3&gt;Platform&lt;/h3&gt;
&lt;p&gt;I had enough with Wordpress. It's an excellent blogging platform but doing anything more than just a blog requires to &amp;quot;hack&amp;quot; a lot.&lt;/p&gt;
&lt;p&gt;Drupal on the other hand offers me more flexibility, more security and more control.&lt;/p&gt;
&lt;h3&gt;Work&lt;/h3&gt;
&lt;p&gt;My projects will now feature a full section and that is the most important change so far. Some projects will feature a full case study and others will just show a brief description plus the level of involvement I had on the project.&lt;/p&gt;
&lt;h3&gt;What's coming&lt;/h3&gt;
&lt;p&gt;Code. A new section I'm planning where I can show my OS projects. It's still just an idea and I will be elaborating it in the upcoming weeks.&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"&gt;
&lt;rdf:Description rdf:about="http://ivansotof.com/2009/10/new-blog-same-content-now-drupal" dc:identifier="http://ivansotof.com/2009/10/new-blog-same-content-now-drupal" dc:title="New blog, same content, now on Drupal" trackback:ping="http://ivansotof.com/trackback/48" /&gt;
&lt;/rdf:RDF&gt;
--&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/KLpk8l_SvHQ" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/10/new-blog-same-content-now-drupal#comments</comments>
 <category domain="http://ivansotof.com/category/design">Design</category>
 <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/web-development">Web Development</category>
 <pubDate>Tue, 20 Oct 2009 00:00:37 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">48 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/10/new-blog-same-content-now-drupal</feedburner:origLink></item>
  <item>
    <title>Plan, administrate and test your Drupal site</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/dbxO8bZ4-ms/plan-administrate-and-test-your-drupal-site</link>
    <description>&lt;img class="alignright size-medium wp-image-301" title="Drupal 6" src="http://ivansotof.com/wp-content/uploads/drupal6contentadministration-243x300.jpg" alt="Drupal 6" width="194" height="240" /&gt;We all know Drupal has some usability problems (or a lot). It's not friendly when you first install it and adding modules and themes can be confusing at the beginning. But wait! Adding stuff to Drupal is so easy, just download the zip file upload to the server and enable the module/theme. And here is exactly when we start having problems.

At one side, going module shopping is easy and &lt;span style="text-decoration: line-through;"&gt;repetitive&lt;/span&gt; fun but on the other side we often forget that downloading 20 extra modules can make our site run slow and even make it crash. Not to mention that some modules are &lt;strong&gt;not meant&lt;/strong&gt; to be compatible with others.

And first of all, don't be scared of buying a book that teaches you how to administrate Drupal, it's definitely worth if you are going to be in charge of the content.
&lt;h3&gt;Plan your site before start building it&lt;/h3&gt;
Even though this is important for any kind of project, because of Drupal ease of installation and setup users tend to "try" modules and forget that little tab called "Uninstall". Even so, some modules won't completely uninstall or can just break other parts. Not all modules are perfectly made.&lt;!--break--&gt;

By "plan" I really mean to plan your modules. Which modules you will be using and how do you want to use them.
&lt;h3&gt;Testing&lt;/h3&gt;
Consider having a "sandbox" site. A common rule on web development is not to work on a production site, but again because of Drupal being modular some users just install a module not even trying or testing it.

Another reason why you should do this is because even when you have experience working with a module in past projects, you are definitely working with different combination versions on the next one.
&lt;h3&gt;Benchmark your site&lt;/h3&gt;
So, you enabled 10 modules, you setup your views and panels and your site looks perfect but it's starting to feel slow. Let's test with no cache, normal cache and aggresive cache
&lt;pre lang="shell"&gt;ab -c1 -n100 http://ivansotof.com/&lt;/pre&gt;
Will give you a lot of information. Just google Apache Benchmark tool.
&lt;h3&gt;Configure your server&lt;/h3&gt;
Make sure you are running some kind of PHP accelerator (eAccelator is my favorite).

Make sure PHP has enough RAM to use or you can get the infamous "white screen of death"

Tune up MySQL, the performance can be greatly improved with this.
&lt;h3&gt;Finish your website, plan releases&lt;/h3&gt;
It's true that websites need to be improving all the time, but that doesn't mean you have to add new features everyday. Don't rush, have a testing site, install your new modules and see how things go, test a lot.
&lt;h3&gt;Further reading&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;span style="background-color: #ffffff; "&gt;&lt;a href="http://drupal.org/project/simpletest?no_cache=1254542677"&gt;SimpleTest for Drupal&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span style="background-color: #ffffff; "&gt;&lt;a href="http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html"&gt;Apache Benchmark&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
	&lt;li&gt;&lt;span style="background-color: #ffffff; "&gt;&lt;a href="http://drupal.org/node/85735"&gt;MySQL settings&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/dbxO8bZ4-ms" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/10/plan-administrate-and-test-your-drupal-site#comments</comments>
 <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/web-development">Web Development</category>
 <pubDate>Sat, 03 Oct 2009 02:20:36 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">36 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/10/plan-administrate-and-test-your-drupal-site</feedburner:origLink></item>
  <item>
    <title>Freelancing</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/IvW_5GD_3mw/freelancing</link>
    <description>&lt;p&gt;After working at &lt;a href="http://350designs.com"&gt;350 Designs&lt;/a&gt; for more than a year I decided to quit and go back to freelancing. I won't be explaining the reasons  on this post but I can say it will be a lot of fun.&lt;/p&gt;
&lt;p&gt;I already have some projects going on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One of them is taking care of the Drupal development for &lt;a href="http://thepuritea.com"&gt;http://thepuritea.com&lt;/a&gt;, which is looking really good so far.&lt;/li&gt;
&lt;li&gt;Continue improving my Android Twitter application Twit2go which is doing well.&lt;/li&gt;
&lt;li&gt;I will start working (hopefully soon) on the redesign (and Drupalization) of &lt;a href="http://www.voiceforisrael.com/"&gt;http://www.voiceforisrael.com/&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Continue improving &lt;a href="http://droidfeed.com" title="http://droidfeed.com"&gt;http://droidfeed.com&lt;/a&gt; which didn't have the acceptance I was expecting.&lt;/li&gt;
&lt;li&gt;Redesign and drupalization of my blog. (I keep talking how cool Drupal is and my blog is running Wordpress)&lt;/li&gt;
&lt;li&gt;Another ninja/secret project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, if you are interested in hiring me, you can email me at &lt;a href="mailto:ivansotof@gmail.com"&gt;ivansotof@gmail.com&lt;/a&gt;. I will be taking projects starting from mid-October.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/IvW_5GD_3mw" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/09/freelancing#comments</comments>
 <category domain="http://ivansotof.com/category/lifestyle">Lifestyle</category>
 <pubDate>Wed, 16 Sep 2009 06:35:06 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">35 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/09/freelancing</feedburner:origLink></item>
  <item>
    <title>Native User Interfaces and controls</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/YCVJhiA8DYo/native-interfaces-and-controls</link>
    <description>Today I was reading the comments on the article "&lt;a href="http://www.osnews.com/comments/21897"&gt;Opera: Apple, Ubuntu should include browser ballout screen too&lt;/a&gt;" and like always, everyone was commenting about how unsuccessful Opera is, hence the article. &lt;strong&gt;It really is&lt;/strong&gt; and anyone that works on web development will know how good Opera is, but at the same time knows why it's not their main browser.

&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/wrong.jpg" alt="wrong" title="wrong" width="400" height="258" class="aligncenter size-full wp-image-270" /&gt;&lt;/p&gt;

I don't want to find&lt;strong&gt; _the_&lt;/strong&gt; cause why Opera fails to get a piece of market share, I just want to give my personal opinion on why Opera and &lt;strong&gt;any other software&lt;/strong&gt; that doesn't use native controls fails to impress me.
&lt;!--break--&gt;
&lt;h2&gt;The lack of native controls&lt;/h2&gt;

Let's take Opera for Windows and Mac and we will see what I'm talking about:

&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/opera-windows7.jpg" alt="opera-windows7" title="opera-windows7" width="500" height="455" class="aligncenter size-full wp-image-267" /&gt;&lt;/p&gt;
&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/operamac.jpg" alt="operamac" title="operamac" width="500" height="379" class="aligncenter size-full wp-image-268" /&gt;&lt;/p&gt;

We can see that both the Windows and Mac version are not using native controls, interface or even colors. This is my main problem with Opera software and I know a lot of users have similar problems. Ok, maybe the Mac version looks a little better than the previous versions but it still doesn't feel right.

If we go further and take the Android browser that Opera built called Opera Mini you will find that it's completely different from the rest of the applications on your device. I know it's a port but I also know that they can do better that this. It just doesn't feel correct (and I'm not even talking about how you interact with it)

&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/android-opera.jpg" alt="android-opera" title="android-opera" width="510" height="383" class="aligncenter size-full wp-image-265" /&gt;&lt;/p&gt;

And I could continue on Opera but its not the only application that has this problem, Seesmic and Tweetie are both Twitter clients for Mac, but Tweetie feels nicer, faster and native. Seesmic feels like what it is, a flash application built for Desktop. That's something Adobe needs to change about Adobe AIR  if they want to succeed with that.

&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/tweetie-mac07.png" alt="tweetie-mac07" title="tweetie-mac07" width="456" height="388" class="aligncenter size-full wp-image-281" /&gt;&lt;/p&gt;

&lt;h2&gt;So, apps using a different UI or controls will fail?&lt;/h2&gt;

In my opinion, Yes. You can take Safari for example, it's a joy to use it on a Mac, it's nice, fast, looks great and feels native. The Windows version is another story, it's slow, ugly and feels like an emulated version. It even renders text like Macs on a Windows PC! That's what I call inconsistency. Leave the Mac font rendering for Mac, most Windows users like the way Windows render the text.

Now let's see another example: Why is Google Chrome being well received by the users? Well, it's fast! But it also looks good, simple, native, clean. They are doing an excellent job on adapting Chrome to OS X and Windows. It has tabs that don't look so native but they don't look bad on any OS. On Windows XP it renders the top part completely blue but on Vista and 7 it's transparent and looks really nice.

&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/picture-4.png" alt="picture-4" title="picture-4" width="500" height="78" class="aligncenter size-full wp-image-263" /&gt;
&lt;small&gt;Mac version&lt;/small&gt;&lt;/p&gt;

&lt;p align="center"&gt;&lt;img src="http://ivansotof.com/wp-content/uploads/picture-71.png" alt="picture-71" title="picture-71" width="500" height="89" class="aligncenter size-full wp-image-284" /&gt;
&lt;small&gt;Windows 7 version&lt;/small&gt;&lt;/p&gt;

&lt;h2&gt;The solution&lt;/h2&gt;

Use native controls and interfaces when you can, even if it's harder to achieve. Your users will be more comfortable using your application and it will be easier, and try not to mimic other applications/OSes. As an Android user I hate when I download an app just to see that they made it look like an iPhone. It's not an iPhone! We have a menu button, don't put the menu on the screen.

Although, there are exceptions, but in my opinion it's more that we are used to it than we like it. Photoshop for Windows looks like the Mac version, &lt;a href="http://img.brothersoft.com/screenshots/softimage/f/filezilla_for_mac-222057-1237435204.jpeg"&gt;Filezilla for Mac&lt;/a&gt; feels completely wrong even when the Windows version is so nice, etc.&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/YCVJhiA8DYo" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/07/native-interfaces-and-controls#comments</comments>
 <category domain="http://ivansotof.com/category/android">Android</category>
 <category domain="http://ivansotof.com/category/apple">Apple</category>
 <category domain="http://ivansotof.com/category/design">Design</category>
 <category domain="http://ivansotof.com/category/technology">Technology</category>
 <category domain="http://ivansotof.com/category/windows">Windows</category>
 <pubDate>Mon, 27 Jul 2009 18:32:46 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">34 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/07/native-interfaces-and-controls</feedburner:origLink></item>
  <item>
    <title>Visible Description on Drupal Primary Links</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/D9xKm38ye-k/visible-description-on-drupal-primary-links</link>
    <description>&lt;p&gt;Today I was working on a new site when I realized that the top navigation had descriptions under the links. I asked myself for a few seconds, how can I do that on Drupal? If you don't know what I'm talking about, have a look at this screenshot of another site.  &lt;img width="563" height="96" class="aligncenter size-full wp-image-250" title="digi" alt="digi" src="http://ivansotof.com/wp-content/uploads/digi.jpg" /&gt;  I'm doing this on a theme, so no need for a module here. What I need to do here is override (the &amp;quot;Drupal way&amp;quot;) the theme_links function and that's very easy on a theme, we just need to go to &lt;strong&gt;/includes/theme.inc&lt;/strong&gt; and copy the &lt;strong&gt;theme_links()&lt;/strong&gt; function. Then we can just paste it on our template.php file but we change the function name from &lt;strong&gt;theme_links&lt;/strong&gt; to &lt;strong&gt;MYTHEMENAME_links&lt;/strong&gt;.&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;I don't want to kill any other part on the site so let's add an extra parameter to the function, in this case &lt;strong&gt;$primarylinks = false&lt;/strong&gt;. By default the function will work like always does but If we pass $primarylinks as TRUE it will add the link description to the link title.  Let's see how the function will look like:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
function MYTHEMENAME_links($links, $attributes = array('class' =&amp;gt; 'links'), $primarylinks = false) {
  global $language;
  $output = '';
  if (count($links) &amp;gt; 0) {
    $output = '&amp;lt;ul '. drupal_attributes($attributes) .'&amp;gt;';
    $num_links = count($links);
    $i = 1;
 
    foreach ($links as $key =&amp;gt; $link) {
      $class = $key;
      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) &amp;amp;&amp;amp; ($link['href'] == $_GET['q'] || ($link['href'] == '&amp;lt;front&amp;gt;' &amp;amp;&amp;amp; drupal_is_front_page()))
          &amp;amp;&amp;amp; (empty($link['language']) || $link['language']-&amp;gt;language == $language-&amp;gt;language)) {
        $class .= ' active';
      }
      $output .= '&amp;lt;li '. drupal_attributes(array('class' =&amp;gt; $class)) .'&amp;gt;';
      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        if ($primarylinks) {
          $link['html'] = true;
          $output .= l($link['title'] . '&amp;lt;span&amp;gt;' . $link['attributes']['title'] . '&amp;lt;/span&amp;gt;', $link['href'], $link);
        } else {
          $output .= l($link['title'], $link['href'], $link);
        }
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in &amp;lt;span&amp;gt; for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '&amp;lt;span '. $span_attributes .'&amp;gt;'. $link['title'] .'&amp;lt;/span&amp;gt;';
      }
      $i++;
      $output .= &amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/li&amp;gt;\n&amp;quot;;
    }
    $output .= '&amp;lt;/front&amp;gt;&amp;lt;/ul&amp;gt;';
  }
  return $output;
}&lt;/pre&gt;
&lt;pre class="brush: php"&gt;

&lt;/pre&gt;
&lt;p&gt;If you didn't notice, this is the modified part:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
	if ($primarylinks) {
		$link['html'] = true;
		$output .= l($link['title'] . '&amp;lt;span&amp;gt;' . $link['attributes']['title'] . '&amp;lt;/span&amp;gt;', $link['href'], $link);
	} else {
		$output .= l($link['title'], $link['href'], $link);
	}&lt;/pre&gt;
&lt;pre class="brush: php"&gt;

&lt;/pre&gt;
&lt;p&gt;Pretty simple. If you wonder why I added $link['html'] = true, that's because the l() function needs to know it will render on HTML so you dont get the &lt;span&gt; displayed instead of used as HTML. You can do almost anything you want here, the rest is really up to you.  This is more like a trick than a tutorial, but I hope you find it useful.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/D9xKm38ye-k" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/07/visible-description-on-drupal-primary-links#comments</comments>
 <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/php">PHP</category>
 <category domain="http://ivansotof.com/category/web-development">Web Development</category>
 <pubDate>Fri, 03 Jul 2009 23:10:04 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">33 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/07/visible-description-on-drupal-primary-links</feedburner:origLink></item>
  <item>
    <title>Understanding the theme() function on Drupal</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/g44WvPj3qak/understanding-the-theme-function-on-drupal</link>
    <description>&lt;p&gt;One of the most complicated things to understand when templating or developing modules for drupal is the theme() function. But when you know how to deal with it is really useful even when there's no way to know how many we have available.  The way to use it fairly simple, let's see how the Garland theme builds the primary links:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
print theme('links', $primary_links,
array('class' =&amp;gt; 'links primary-links'));&lt;/pre&gt;
&lt;p&gt;The first argument is the actual hook we are calling, the second and third are the the arguments we are passing to that functions.  So basically the theme function will output plain HTML and it's actually way cleaner than defining a function or coding a lot of php on our template.&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;Let's see another example, we installed imagecache and created a preset, now we want to print and specific preset an image that is on a CCK image field. We can do it in the wrong way:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
print '/sites/default/files/imagecache/PRESET/'
.  $node-&amp;gt;field_imagecck[0]['filename'];
&lt;/pre&gt;
&lt;h3&gt;Why this is wrong?&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;It depends that the site location, so your site working on a subdirectory won't display this image.&lt;/li&gt;
    &lt;li&gt;You have to modify this code if you move your files folder.&lt;/li&gt;
    &lt;li&gt;The most important one is that when you upload a picture to drupal, if the picture filename exists the new picture keeps the same filename on the database, but the actual filename will be different. Let's see: file #1 filename: &lt;em&gt;image1.jpg&lt;/em&gt; fielpath: &lt;em&gt;sites/default/files/image1.jpg&lt;/em&gt;  file #2 filename: &lt;em&gt;image1.jpg&lt;/em&gt; fielpath: &lt;em&gt;sites/default/files/image1_0.jpg&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;The correct way to do this&lt;/h3&gt;
&lt;p&gt;Read the module README file. This is what the file says:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
print theme('imagecache', 'preset_namespace', $image_filepath, $alt, $title, $attributes);&lt;/pre&gt;
&lt;p&gt;Again, the first argument is the hook we are calling and the rest are the arguments we are passing to the hook.  Confused? When you build the first one you understand how it works.&lt;/p&gt;
&lt;h3&gt;Make your own&lt;/h3&gt;
&lt;p&gt;Now that you know how to use it let's see how to create one on your own custom module. Our module will be called &lt;strong&gt;mymod&lt;/strong&gt;  (I'm assuming that you already know how to create a module and where)&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
mymod_theme() {
  return array(
    'mymod_randomtext' =&amp;gt; array('arguments' =&amp;gt; array('element' =&amp;gt; NULL))
  );
}&lt;/pre&gt;
&lt;p&gt;And now we define the function that will be called:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
theme_mymod_randomtext($element) {
  $output = ' This is some very random text with'
                  . ' this text concatenated: '  . $element;
  return $output;
}&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And that's it. Now you can call it from your theme or other modules as simple as this:&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
print theme('mymod_randomtext', 'text we are passing');
&lt;/pre&gt;
&lt;p&gt;Hope this helped.  I do believe this function could be much more useful if there was a list of all the options we have. I hope something is implemented in the future, or wait!&lt;strong&gt; &amp;quot;there must be a module for that&amp;quot;&lt;/strong&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/g44WvPj3qak" height="1" width="1"/&gt;</description>
     <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/html">HTML</category>
 <category domain="http://ivansotof.com/category/tutorial">Tutorial</category>
 <category domain="http://ivansotof.com/category/web-development">Web Development</category>
 <pubDate>Mon, 25 May 2009 19:27:18 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">31 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/05/understanding-the-theme-function-on-drupal</feedburner:origLink></item>
  <item>
    <title>Drupal and GIT</title>
    <link>http://feedproxy.google.com/~r/ivansotof-weblog/~3/TXo-u3edcv0/drupal-and-git</link>
    <description>&lt;p&gt;During this year I've been moving my projects to GIT. While my private projects are on this server, my public ones are on &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt; as Open Source. Git is a really wonderful version control tool for any kind of project. It makes it easy for me to deploy, maintain and update my current sites. I just wish there could be a way to include the database on it.  In this post I will explain how &lt;strong&gt;I'm&lt;/strong&gt; using GIT to manage a Drupal site on both local and live environment. And since most people already have a site working, I will explain starting from an existing site.&lt;/p&gt;
&lt;h3&gt;Create the repository&lt;/h3&gt;
&lt;p&gt;The very first thing is going to the actual site, in my server this site is in: /var/www/sitename.com/public&lt;/p&gt;
&lt;pre title="code" class="brush: php;"&gt;
cd /var/www/sitename.com/public
git init
echo &amp;quot;sites/default/settings.php&amp;quot; &amp;gt;&amp;gt; .gitignore
&lt;/pre&gt;
&lt;p&gt;You can also run this if you want to ignore the files folder (that's really up to you)&lt;/p&gt;
&lt;pre lang="bash"&gt;
echo &amp;quot;sites/default/files&amp;quot; &amp;gt;&amp;gt; .gitignore&lt;/pre&gt;
&lt;p&gt;Then you have to add all files to the repository and make the first commit&lt;/p&gt;
&lt;pre lang="bash"&gt;
git add .
git commit -m &amp;quot;Initial commit for this site&amp;quot;&lt;/pre&gt;
&lt;!--break--&gt;
&lt;h3&gt;Making the site remotely available&lt;/h3&gt;
&lt;p&gt;Once you have your local repository working on your server it's time to push this to another place. This is asuming that you have a 'git' user somewhere else and you have access to SSH. I use my own server so I can actually change the address to localhost&lt;/p&gt;
&lt;pre lang="bash"&gt;
scp -rp .git git@yourreposerver.com:sitename.git&lt;/pre&gt;
&lt;p&gt;The last line is really dependent on your current config. In my case I use this:&lt;/p&gt;
&lt;pre lang="bash"&gt;
scp -rp .git git@ivansotof.com:sites/sitename.git&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;You can google a little about SCP command if you are not familiar with it.&lt;/em&gt; It will ask for a password since it's using SSH for copying the .git folder. It will take a while copying everything up to that server but when it's done you just need to add a remote entry to the local repo.&lt;/p&gt;
&lt;pre lang="bash"&gt;
git remote add origin git@yourreposerver.com/sitename.git&lt;/pre&gt;
&lt;p&gt;And you are done copying the site.&lt;/p&gt;
&lt;h3&gt;Cloning and working on  your local environment&lt;/h3&gt;
&lt;p&gt;Now that we have the live site under version control and the repository available for cloning you just need to clone it to your working environment.&lt;/p&gt;
&lt;pre lang="bash"&gt;
git clone git@yourreposerver.com:sitename.git&lt;/pre&gt;
&lt;p&gt;It will create a folder sitename/ that will be a perfect copy of what you have on your live site.  Now you can just go in and make changes to the site:&lt;/p&gt;
&lt;pre lang="bash"&gt;
cd sitename&lt;/pre&gt;
&lt;p&gt;If you are using TextMate on OSX or E-TextEditor on Windows you can open the working folders from here. If you are not, then you should :)  On OSX:&lt;/p&gt;
&lt;pre lang="bash"&gt;
mate sites/all/&lt;/pre&gt;
&lt;p&gt;On Windows&lt;/p&gt;
&lt;pre lang="bash"&gt;
e sites/all/&lt;/pre&gt;
&lt;p&gt;When you are done making changes:&lt;/p&gt;
&lt;pre lang="bash"&gt;
git commit -m &amp;quot;Making some random changes&amp;quot;&lt;/pre&gt;
&lt;p&gt;Now push all changes to the remote server&lt;/p&gt;
&lt;pre lang="bash"&gt;
git push origin master&lt;/pre&gt;
&lt;p&gt;Now go to the &amp;quot;live&amp;quot; site and just do:&lt;/p&gt;
&lt;pre lang="bash"&gt;
git pull origin master&lt;/pre&gt;
&lt;p&gt;You should now have all latest changes working on your remote server.  This is so far the setup I am using on most of my sites. I didn't include copying the database but I hope the readers already have some experience on that. Since I'm ignoring settings.php you should be able to have a configuration working on any copy of the site.  If you are using a different setup, please share it :)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ivansotof-weblog/~4/TXo-u3edcv0" height="1" width="1"/&gt;</description>
     <comments>http://ivansotof.com/2009/05/drupal-and-git#comments</comments>
 <category domain="http://ivansotof.com/category/drupal">Drupal</category>
 <category domain="http://ivansotof.com/category/tutorial">Tutorial</category>
 <pubDate>Sun, 10 May 2009 19:41:21 +0000</pubDate>
 <dc:creator>ivan</dc:creator>
 <guid isPermaLink="false">29 at http://ivansotof.com</guid>
  <feedburner:origLink>http://ivansotof.com/2009/05/drupal-and-git</feedburner:origLink></item>
  </channel>
</rss>
