<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; Customization</title>
	<atom:link href="http://www.g-loaded.eu/tag/customization/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>Drupal Tip: List a node&#8217;s taxonomy terms inside a Block</title>
		<link>http://www.g-loaded.eu/2009/05/07/drupal-tip-list-a-nodes-taxonomy-terms-inside-a-block/</link>
		<comments>http://www.g-loaded.eu/2009/05/07/drupal-tip-list-a-nodes-taxonomy-terms-inside-a-block/#comments</comments>
		<pubDate>Thu, 07 May 2009 01:38:48 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Taxonomy]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=1097</guid>
		<description><![CDATA[It&#8217;s been several months since the last time I had done any coding on Drupal. Although many people might find it trivial, here is a PHP snippet to enter in a custom block, so that the taxonomy terms of the currently displayed node are printed as an unordered list inside that block. Also, each list [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been several months since the last time I had done any coding on <a href="http://drupal.org">Drupal</a>. Although many people might find it trivial, here is a PHP snippet to enter in a custom block, so that the <strong>taxonomy terms</strong> of the currently displayed node are printed as an unordered <strong>list</strong> inside that block. Also, each list item will be a <strong>link</strong> pointing to the relevant term page.<br />
<span id="more-1097"></span><br />
First of all, in order to be able to include PHP code, which will be evaluated, inside your posts, it is required to activate the <strong>PHP Filter</strong> module. Double check at <code>admin/settings/filters</code> that only trusted roles can use the PHP filter, otherwise your web site could be at risk. By default, only the administrator can use this filter.</p>
<p>To create the custom block, go to <code>admin/build/block/add</code> and enter a <strong>description</strong> and a <strong>title</strong> for your custom block. Paste the following code on the <strong>body</strong> textarea:</p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Prints an unordered list of the terms (as links) that are
 * associated to the currently displayed node.
 */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'node'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> node_load<span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>module_exists<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'taxonomy'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$terms</span> <span style="color: #339933;">=</span> taxonomy_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'taxonomy terms'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">print</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'links'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$terms</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'node-terms'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'No associated categories.'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
<p>Make sure you select the <strong>PHP filter</strong> from the list of the <em>input filters</em>. Also, set the rest of the settings according to your needs and save the custom block.</p>
<p>Your new block should be available in the block list in <code>admin/build/block</code> and you should be able to use it straight away.</p>
<p>Now to some technical details about <strong>arg(0)</strong> and <strong>arg(1)</strong>, which probably seem a bit cryptic to a user that is not experienced with Drupal (like me). Assume we have the following <strong>URL</strong> to a node: <code>www.example.org/node/23</code>, which means that the <strong>path</strong> to the page is <code>/node/23</code>. Well, <em>arg(0)</em> is the <code>node</code> part and <em>arg(1)</em> is the second part; <code>23</code> that is. Read about the <a href="http://api.drupal.org/api/function/arg">arg()</a> function.</p>
<p>This should explain the following part of the snippet above:</p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'node'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> node_load<span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#91;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>
<p>I give some emphasis on this as it is a snippet you will use quite often in order to use any of the node object&#8217;s properties inside a block.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2009/05/07/drupal-tip-list-a-nodes-taxonomy-terms-inside-a-block/">Drupal Tip: List a node&#8217;s taxonomy terms inside a Block</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2009/01/04/always-use-a-block-device-label-or-its-uuid-in-fstab/" rel="bookmark">Always use a block device label or its UUID in fstab</a></li>
<li><a href="http://www.g-loaded.eu/2007/03/05/organizing-mailing-list-messages-with-evolution/" rel="bookmark">Organizing Mailing List messages with Evolution</a></li>
<li><a href="http://www.g-loaded.eu/2007/11/04/backslashes-inside-pre-html-tags-in-wordpress/" rel="bookmark">Backslashes inside pre HTML tags in WordPress</a></li>
<li><a href="http://www.g-loaded.eu/2008/11/27/getting-my-hands-on-drupal/" rel="bookmark">Getting my hands on Drupal</a></li>
<li><a href="http://www.g-loaded.eu/2007/08/20/mailing-list-manager/" rel="bookmark">Mailing List Manager</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2009/05/07/drupal-tip-list-a-nodes-taxonomy-terms-inside-a-block/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Use the Alternatives System to switch to a custom Firefox release</title>
		<link>http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/</link>
		<comments>http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 05:46:25 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=496</guid>
		<description><![CDATA[From a user&#8217;s perspective, having to use an old beta version of Firefox in my primary desktop, while, at the same time, a final stable release of the browser has been released, is a bit annoying. But, the fact that this happens due to technical issues makes it partially acceptable. The following article aims to [...]]]></description>
			<content:encoded><![CDATA[<p>From a user&#8217;s perspective, having to use an old beta version of <a href="http://www.mozilla.org/">Firefox</a> in <a href="http://www.g-loaded.eu/2008/05/16/desktop-now-uses-fedora-9/">my primary desktop</a>, while, at the same time, a final stable release of the browser has been released, is a bit annoying. But, the fact that this happens due to technical issues makes it partially acceptable. The following article aims to provide step-by-step instructions about how to use the <strong>alternatives system</strong> to set a custom Firefox release, downloaded from mozilla.org, to be the system&#8217;s default. Using this method the user is relieved from having to go through all the firefox launchers and menu entries in order to edit the paths to the firefox executable. Moreover, this post should also be a good example of how to use the alternatives system in the Linux distributions that support it.</p>
<p><strong><em>Update</em></strong>: Firefox 3.0 final has become available from the official fedora updates repository. It seems that the technical issues of the past do not exist any more! Kudos! This tutorial will still give you an idea though about how to <em>quickly</em> and <em>easily</em> switch between the default and custom versions of the same software in your system.<br />
<span id="more-496"></span><br />
Fedora 9 has been used as the desktop system for this article. The provided information will certainly work in CentOS and RHEL, but might also work for other linux distributions which use the alternatives system, such as Debian, Ubuntu, OpenSUSE etc. As far as I know, Gentoo and its derivatives use their own system.</p>
<p>In order to check if &#8220;alternatives&#8221; is available in your system, try one of the following commands:</p>
<pre class="console">
which alternatives
which update-alternatives
</pre>
<h4>Firefox Installation</h4>
<p>First of all, we install a <em>precompiled</em> (binary) Firefox distribution, downloaded from mozilla.org, in the <strong>/opt</strong> directory. All the following commands should be issued by &#8216;<code>root</code>&#8216; or by your regular user using &#8216;<code>sudo</code>&#8216;.</p>
<p><em>Change</em> to the <strong>/opt</strong> directory, <em>download</em> and <em>extract</em> the firefox package:</p>
<pre class="console">
cd /opt/
wget ftp://ftp.mozilla.org/pub/firefox/releases/3.0/linux-i686/en-US/firefox-3.0.tar.bz2
tar -xjf firefox-3.0.tar.bz2
</pre>
<p>Now <em>change</em> to the <strong>/opt/firefox/</strong> directory, <em>delete</em> the <strong>plugins/</strong> subdirectory and create a <em>symlink</em> to the system&#8217;s directory containing the firefox plugins (<code>/usr/lib/mozilla/plugins/</code> in Fedora).</p>
<pre class="console">
cd firefox/
rm -fr plugins
ln -s /usr/lib/mozilla/plugins/ plugins
</pre>
<p>The installation of the custom Firefox version is complete.</p>
<h4>Set the system-wide default Firefox version</h4>
<p>In this section we will use the <strong>alternatives system</strong> in order to provide us with two options:</p>
<ol>
<li>Use Fedora&#8217;s default Firefox release. This means that <strong>/usr/bin/firefox</strong> should be executed whenever we issue the &#8216;<code>firefox</code>&#8216; command.</li>
<li>Set our custom Firefox release as the system&#8217;s default. This means that <strong>/opt/firefox/firefox</strong> should be executed whenever we issue the &#8216;<code>firefox</code>&#8216; command.</li>
</ol>
<p><strong><em>Note</em></strong>: Describing the details of the alternatives system is out of the scope of this article, so it is highly recommended that you study the <em>alternatives manual page</em> (<code>man 8 alternatives</code>)</p>
<p>In the following steps we will add a <strong>group</strong>, named &#8220;<em>firefox</em>&#8220;, of alternative options for the location of the <strong>firefox executable</strong>. These options are actually <em>filesystem locations</em> which will be linked by the <strong>/usr/local/bin/firefox</strong> symlink. Note that we use the <strong>/usr/local/bin/&#8230;</strong> path for our symlink, because <strong>/usr/bin/firefox</strong> is occupied by fedora&#8217;s firefox executable. The latter will not be called directly any more, as the executables located in <strong>/usr/local/bin/</strong> override the ones located in <strong>/usr/bin/</strong>, so whenever the command &#8216;<code>firefox</code>&#8216; is invoked, <strong>/usr/local/bin/firefox</strong> will actually be used. The latter is a symlink, which links to either fedora&#8217;s firefox executable or our custom firefox executable.</p>
<p>So, we add the &#8216;<em>firefox</em>&#8216; group of options:</p>
<pre class="console">
/usr/sbin/alternatives --install /usr/local/bin/firefox firefox /usr/bin/firefox 10
/usr/sbin/alternatives --install /usr/local/bin/firefox firefox /opt/firefox/firefox 20
</pre>
<p>Now we can manually set which firefox executable to use as the system&#8217;s default. In other words, the following command links <strong>/usr/local/bin/firefox</strong> to the desired executable (<strong>/opt/firefox/firefox</strong> in our case):</p>
<pre class="console">
/usr/sbin/alternatives --set firefox /opt/firefox/firefox
</pre>
<p><strong>Instead of the <code>--set</code> option as shown above</strong>, we can use the <strong>&#8211;config</strong> option, so that a list of the available <em>alternatives</em> is displayed and we are prompted to make a selection:</p>
<pre class="console">
# /usr/sbin/alternatives --config firefox
There are 2 programs which provide 'firefox'.
  Selection    Command
-----------------------------------------------
   1           /usr/bin/firefox
*+ 2           /opt/firefox/firefox
Enter to keep the current selection[+], or type selection number: 2
</pre>
<p>Finally, we can issue the following command to get an overview of our current configuration for the group &#8216;<em>firefox</em>&#8216;:</p>
<pre class="console">
# /usr/sbin/alternatives --display firefox
firefox - status is manual.
 link currently points to /opt/firefox/firefox
/usr/bin/firefox - priority 10
/opt/firefox/firefox - priority 20
Current `best' version is /opt/firefox/firefox.
</pre>
<h4>Revert to the original state</h4>
<p>If for any reason you need to revert things back to the default state, all you have to do in order to remove all the &#8220;<em>alternatives</em>&#8221; we had configured in the previous section is the following:</p>
<pre class="console">
/usr/sbin/alternatives --remove firefox /opt/firefox/firefox
/usr/sbin/alternatives --remove firefox /usr/bin/firefox
</pre>
<p>No other configuration is required. From now on, whenever the &#8216;<code>firefox</code>&#8216; command is invoked, fedora&#8217;s old <strong>/usr/bin/firefox</strong> is executed.</p>
<h4>Final Thoughts</h4>
<p>Technical issues in the linux distribution preparation process might limit the user to certain software versions. The alternatives system provides users with the choice to configure the system in a way that it is extremely <strong>easy to switch</strong> between <strong>default</strong> and <strong>custom</strong> versions of the same software.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/">Use the Alternatives System to switch to a custom Firefox release</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2011/09/28/the-new-amateuristic-release-strategy-of-firefox/" rel="bookmark">The new amateuristic release strategy of Firefox</a></li>
<li><a href="http://www.g-loaded.eu/2009/10/30/selinux-setenforce-mode/" rel="bookmark">Using setenforce to switch SELinux mode wisely</a></li>
<li><a href="http://www.g-loaded.eu/2008/11/26/using-a-switch-to-prevent-system-shutdownrebootsuspend/" rel="bookmark">Using a switch to prevent system shutdown/reboot/suspend</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/11/local-yum-repository/" rel="bookmark">Local YUM Repository</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/08/the-use-of-the-uppercase-x-in-chmod/" rel="bookmark">The use of the uppercase X in chmod</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

