<?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>Acts Media &#187; joomla</title>
	<atom:link href="http://blog.actsmedia.com/tag/joomla/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.actsmedia.com</link>
	<description>Acts Media specializes in Wed Design, Web Development, and Flash/Flex Authoring</description>
	<lastBuildDate>Thu, 27 Jan 2011 16:15:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Joomla Component Ordering, Positioning Rows</title>
		<link>http://blog.actsmedia.com/2009/11/joomla-component-ordering-positioning-rows/</link>
		<comments>http://blog.actsmedia.com/2009/11/joomla-component-ordering-positioning-rows/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 03:44:44 +0000</pubDate>
		<dc:creator>Bryn Knatterud</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.actsmedia.com/?p=149</guid>
		<description><![CDATA[When creating a custom component in Joomla admin area it is somewhat frequent that one wants the ability to order items based on an order value associated with each row. Just like how articles have an order in the Joomla &#8220;Article Manager&#8221;. The following are the necessary code snippets that allow you to make this [...]]]></description>
			<content:encoded><![CDATA[<p>When creating a custom component in Joomla admin area it is somewhat frequent that one wants the ability to order items based on an order value associated with each row. Just like how articles have an order in the Joomla &#8220;Article Manager&#8221;.</p>
<p>The following are the necessary code snippets that allow you to make this possible.</p>
<p>I hope to add a little more explanation to these soon.</p>
<p><em>controller.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> saveorder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$option</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Initialize variables</span>
	<span style="color: #000088;">$db</span>	<span style="color: #339933;">=&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getDBO</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$cid</span>	<span style="color: #339933;">=</span> JRequest<span style="color: #339933;">::</span><span style="color: #004000;">getVar</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'cid'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'array'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$total</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cid</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$order</span><span style="color: #339933;">=</span> JRequest<span style="color: #339933;">::</span><span style="color: #004000;">getVar</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'order'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><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;">'post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'array'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	JArrayHelper<span style="color: #339933;">::</span><span style="color: #004000;">toInteger</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$row</span> <span style="color: #339933;">=&amp;</span> JTable<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'article'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Table'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// update ordering values</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$total</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$cid</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ordering</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$order</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ordering</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$order</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				JError<span style="color: #339933;">::</span><span style="color: #004000;">raiseError</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> 
                                     <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getErrorMsg</span><span style="color: #009900;">&#40;</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: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">reorder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$msg</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'New ordering saved'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setRedirect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index.php?option='</span><span style="color: #339933;">.</span><span style="color: #000088;">$option</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><em>views/all/tmp/default.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;th width=&quot;8%&quot;&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> JHTML<span style="color: #339933;">::</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'grid.sort'</span><span style="color: #339933;">,</span>   <span style="color: #0000ff;">'Position'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ordering</span><span style="color: #339933;">,</span> <span style="color: #339933;">@</span><span style="color: #000088;">$lists</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'order_Dir'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">@</span><span style="color: #000088;">$lists</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'order'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> JHTML<span style="color: #339933;">::</span>_<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'grid.order'</span><span style="color: #339933;">,</span>  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rows</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/th&gt;</pre></div></div>

<p><em>views/all/tmp/default.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;td class=&quot;order&quot;&gt;
        &lt;span&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderUpIcon</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'orderup'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Move Up'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt;
	&lt;span&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pagination</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orderDownIcon</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #000088;">$n</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'orderdown'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Move Down'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt;
	&lt;input type=&quot;text&quot; name=&quot;order[]&quot; size=&quot;5&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ordering</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; class=&quot;text_area&quot; style=&quot;text-align: center&quot; /&gt;
&lt;/td&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.actsmedia.com/2009/11/joomla-component-ordering-positioning-rows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla: Adding Meta Description &amp; Keywords</title>
		<link>http://blog.actsmedia.com/2009/09/joomla-adding-meta-description-keywords/</link>
		<comments>http://blog.actsmedia.com/2009/09/joomla-adding-meta-description-keywords/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:33:24 +0000</pubDate>
		<dc:creator>Bryn Knatterud</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[joomla]]></category>

		<guid isPermaLink="false">http://blog.actsmedia.com/?p=121</guid>
		<description><![CDATA[When using Joomla to run your website it is important to add Meta information to your articles. This information will be used by Search Engine Robots that index your site. The following is a quick guide to adding this information. Log into the Joomla back-end at http://&#60;yoursite&#62;.&#60;com/org/net&#62;/administrator Once logged in navigate using the upper navigation [...]]]></description>
			<content:encoded><![CDATA[<p>When using Joomla to run your website it is important to add Meta information to your articles. This information will be used by Search Engine Robots that index your site. The following is a quick guide to adding this information.</p>
<ol>
<li>Log into the Joomla back-end at http://&lt;yoursite&gt;.&lt;com/org/net&gt;/administrator</li>
<li>Once logged in navigate using the upper navigation bar to Content &gt; Article Manager</li>
<li>Click on any article in the manager to open the article</li>
<li>On the right column click on the bar that says &#8220;Meta Information&#8221;</li>
<li>The area will expand to show a few input areas. The ones we are concerned with are labeled &#8220;Description&#8221; and &#8220;Keywords&#8221; respectively.</li>
<li>In the &#8220;Description&#8221; input type a one sentence summary of the content in this article. You could to two sentences but one is really best.</li>
<li>Now in the &#8220;Keywords&#8221; box type in 2-3 keywords for the article. The words should be separated using semi-colons e.g. acts media; web design; web development; Also, notice that you can type key phrases not just words. You should try to keep the keywords at 3 or below.</li>
<li>When you are done inputting this information click on &#8220;Save&#8221; or &#8220;Apply&#8221; in the upper-right of the screen.</li>
<li>Great! Search Engines will now be able to better index this page of your site.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.actsmedia.com/2009/09/joomla-adding-meta-description-keywords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla Loading Plug-Ins in Custom Components</title>
		<link>http://blog.actsmedia.com/2009/08/joomla-loading-plug-ins-in-custom-components/</link>
		<comments>http://blog.actsmedia.com/2009/08/joomla-loading-plug-ins-in-custom-components/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 16:07:49 +0000</pubDate>
		<dc:creator>Bryn Knatterud</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.actsmedia.com/?p=98</guid>
		<description><![CDATA[I was having some trouble determining how to access and use a plugin in a custom component in Joomla. I finally figured it out and the rather simple code snippet is below&#8230; &#160; //Gives access to all plugins in the content folder JPluginHelper::importPlugin&#40;'content'&#41;; // This variable is passed by reference so we need it later [...]]]></description>
			<content:encoded><![CDATA[<p>I was having some trouble determining how to access and use a plugin in a custom component in Joomla.</p>
<p>I finally figured it out and the rather simple code snippet is below&hellip;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">//Gives access to all plugins in the content folder</span>
JPluginHelper<span style="color: #339933;">::</span><span style="color: #004000;">importPlugin</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// This variable is passed by reference so we need it later</span>
<span style="color: #000088;">$campinfo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//I created my own trigger below, but &quot;onContentPrepare&quot; would work fine here</span>
<span style="color: #000088;">$dispatcher</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'onCampPrepare'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$campinfo</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//assign are variable to be acessed in the template</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignRef</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'campinfo'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$campinfo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.actsmedia.com/2009/08/joomla-loading-plug-ins-in-custom-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla Component Global Models</title>
		<link>http://blog.actsmedia.com/2009/08/joomla-component-global-models/</link>
		<comments>http://blog.actsmedia.com/2009/08/joomla-component-global-models/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 03:29:35 +0000</pubDate>
		<dc:creator>Bryn Knatterud</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.actsmedia.com/?p=95</guid>
		<description><![CDATA[One thing that I often find necessary when creating a custom component in Joomla is the need to have a &#8220;Global&#8221; model that I can use in some or all of my views. It took me awhile to find documentation on this and what I did find was outdated documentation, so I think it is [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that I often find necessary when creating a custom component in Joomla is the need to have a &#8220;Global&#8221; model that I can use in some or all of my views. It took me awhile to find documentation on this and what I did find was <a href="http://forum.joomla.org/viewtopic.php?f=231&#038;t=173921" target="_blank">outdated documentation</a>, so I think it is worth providing some here&#8230;</p>
<p>I will use some simple code examples so you can get an idea of how it works.</p>
<h3>Prerequisite knowledge</h3>
<ul>
<li>Basic understanding of <a href="http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1" target="_blank">Joomla component MVC</a></li>
</ul>
<h3>1. Create your global model</h3>
<p>Create a file called &#8220;global.php&#8221; and place it in the &#8220;models&#8221; folder of you component.</p>
<p>Insert the following code&#8230;[global.php]</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: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_JEXEC'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Resctricted access'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jimport<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'joomla.application.component.model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
JModel<span style="color: #339933;">::</span><span style="color: #004000;">addIncludePath</span><span style="color: #009900;">&#40;</span>JPATH_COMPONENT<span style="color: #339933;">.</span>DS<span style="color: #339933;">.</span><span style="color: #0000ff;">'models'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> CustomComponentModelGlobal <span style="color: #000000; font-weight: bold;">extends</span> JModel
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">function</span> getData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;My Global Data&quot;</span><span style="color: #339933;">;</span>		
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>2. Modify Controller Code</h3>
<p>We will modify the code of the display method in the controller to make our global model available in all of the views.</p>
<p><em>controller.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> display<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$view</span> <span style="color: #339933;">=</span> JRequest<span style="color: #339933;">::</span><span style="color: #004000;">getVar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'view'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$view</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		JRequest<span style="color: #339933;">::</span><span style="color: #004000;">setVar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'view'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$model</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Global'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$document</span> <span style="color: #339933;">=&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getDocument</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$viewType</span>	<span style="color: #339933;">=</span> <span style="color: #000088;">$document</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$viewName</span>	<span style="color: #339933;">=</span> <span style="color: #000088;">$view</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$view</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getView</span><span style="color: #009900;">&#40;</span> 
                             <span style="color: #000088;">$viewName</span><span style="color: #339933;">,</span>
                             <span style="color: #000088;">$viewType</span><span style="color: #339933;">,</span> 
                             <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                             <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'base_path'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_basePath<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setModel</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	parent<span style="color: #339933;">::</span><span style="color: #004000;">display</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>3. Access the Global model in the view</h3>
<p><em>view.html.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> display<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/*
	 * The model can now be accessed in the view
	 * in either way below
	 */</span>
&nbsp;
	<span style="color: #000088;">$data</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'data'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Global'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$globalModel</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Global'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$globalModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//assign the data to a ref for output in the html</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignRef</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'myGobalData'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.actsmedia.com/2009/08/joomla-component-global-models/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

