<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3112041083315533141</id><updated>2011-11-03T21:01:01.191-07:00</updated><category term='apache'/><category term='subdomain'/><category term='javascript'/><category term='modal window'/><category term='joomla'/><category term='tinymce'/><category term='extended valid elements'/><category term='squeezebox'/><category term='JHTML::_(&apos;behavior.modal&apos;)'/><category term='template override'/><category term='localhost'/><category term='preg_replace'/><category term='css'/><category term='dependent selects'/><category term='lightbox'/><category term='modal.js'/><category term='domain'/><category term='module class suffix'/><category term='htaccess'/><category term='pop up box'/><category term='module chrome'/><category term='changeDynaList'/><category term='behaviour.js'/><category term='JHTMLBehaviour'/><category term='joomla 1.5'/><title type='text'>Padmali's Joomla Notes</title><subtitle type='html'>joomla stuff i find useful to keep in one place</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://padmali.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://padmali.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>padmali</name><uri>http://www.blogger.com/profile/17561973047994672197</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_w8HhgOFc3bM/S6PFPiM7ZGI/AAAAAAAAAAo/IR-A7lYCiQI/S220/twitter.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3112041083315533141.post-1902566092409086693</id><published>2011-02-28T11:58:00.000-08:00</published><updated>2011-02-28T11:58:07.946-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JHTML::_(&apos;behavior.modal&apos;)'/><category scheme='http://www.blogger.com/atom/ns#' term='modal.js'/><category scheme='http://www.blogger.com/atom/ns#' term='modal window'/><category scheme='http://www.blogger.com/atom/ns#' term='JHTMLBehaviour'/><category scheme='http://www.blogger.com/atom/ns#' term='joomla 1.5'/><category scheme='http://www.blogger.com/atom/ns#' term='lightbox'/><category scheme='http://www.blogger.com/atom/ns#' term='behaviour.js'/><category scheme='http://www.blogger.com/atom/ns#' term='squeezebox'/><category scheme='http://www.blogger.com/atom/ns#' term='pop up box'/><title type='text'>modal window with lightbox - native joomla javascript</title><content type='html'>&lt;p&gt;Joomla's native modal.js ("squeezebox") is really easy to use to pop up a modal window with a lightbox overlay. You can popup images, hidden divs, internal and external urls.&lt;/p&gt;&lt;p&gt;It just takes one line of code in your component's template file, or in index.php if you want it site-wide.&lt;/p&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;JHTML::_('behavior.modal');&lt;/blockquote&gt;&lt;p&gt;This nifty one liner does all the heavy lifting - inserting links for media/system/js/modal.js and media/system/css/modal.css into the head of the document and adding a basic domready event as well. All you have to do is to put in the link(s) that triggers the modal behaviour.&lt;/p&gt;&lt;h3&gt;inserting the links&lt;/h3&gt;&lt;p&gt;Use an ordinary link specifying the default class (a.modal), and use the &lt;code&gt;rel&lt;/code&gt; attribute to specify a handler, and any of the available optional presets in the format:&lt;/p&gt;&lt;p&gt;&lt;code&gt;&amp;lt;a href="whatever" class="modal" rel="{handler:'specify', preset1:'value1', preset2:'value2'}"&gt;Link&amp;lt;/a&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;Handlers&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;image&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;adopt&lt;/code&gt; - great for hidden divs on the page&lt;/li&gt;&lt;li&gt;&lt;code&gt;url&lt;/code&gt; - use for internal urls&lt;/li&gt;&lt;li&gt;&lt;code&gt;iframe&lt;/code&gt; - use for external urls&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;Presets (optional)&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;size&lt;/code&gt;&lt;br /&gt;- width(x) and height(y) of the final window. Default is 600x450&lt;/li&gt;&lt;li&gt;&lt;code&gt;sizeLoading&lt;/code&gt;&lt;br /&gt;- width(x) and height(y) of the initial window. Default is 200x150&lt;/li&gt;&lt;li&gt;&lt;code&gt;fxOverlayDuration&lt;/code&gt;&lt;br /&gt;- the time it takes for the background to darken/lighten when the link is clicked, or the lightbox is shut. Default is 250ms&lt;/li&gt;&lt;li&gt;&lt;code&gt;fxResizeDuration&lt;/code&gt;&lt;br /&gt;- the time it takes for the lightbox to go from sizeLoading to size. Default is 750ms&lt;/li&gt;&lt;li&gt;&lt;code&gt;fxContentDuration&lt;/code&gt;&lt;br /&gt;- the time it takes for the content to fade in. Default is 250ms&lt;/li&gt;&lt;li&gt;&lt;code&gt;classOverlay&lt;/code&gt;&lt;br /&gt;- adds a class to style the overlay. Put it in your template's css file as &lt;code&gt;#sbox-overlay.your-class&lt;/code&gt;. Default is empty.&lt;/li&gt;&lt;li&gt;&lt;code&gt;classWindow&lt;/code&gt;&lt;br /&gt;- adds a class to style the modal window. Put it in your template's css file as &lt;code&gt;#sbox-window.your-class&lt;/code&gt;. Default is empty.&lt;/li&gt;&lt;li&gt;For the full list of presets see media/system/js/modal.js&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;examples of links&lt;/h3&gt;&lt;p&gt;&lt;u&gt;handler: image&lt;/u&gt;&lt;/p&gt;&lt;blockquote&gt;Click here for &amp;lt;a class="modal" href="path/to/bigimage.jpg" rel="{handler: 'image', sizeLoading: {x:200, y:150}, size: {x:400, y:300}}"&gt;&amp;lt;img src="path/to/thumbnail.jpg /&gt;&amp;lt;/a&gt;&lt;/blockquote&gt;&lt;p&gt;Note that &lt;code&gt;sizeLoading&lt;/code&gt; and &lt;code&gt;fxResizeDuration&lt;/code&gt; are not noticeable if the image loads quickly, or is cached.&lt;/p&gt;&lt;p&gt;&lt;u&gt;handler: adopt&lt;/u&gt;&lt;/p&gt;&lt;p&gt;Perfect for a hidden div that can be triggered to popup by clicking  a link. Use the adopt handler, and specify the div you are going to adopt.&lt;/p&gt;&lt;blockquote&gt;&amp;lt;div style="display:none;"&gt;&lt;br /&gt;&amp;lt;div id="spampolicy"&gt;&lt;br /&gt; &amp;lt;h4 class="purple"&gt;Spam Policy&amp;lt;/h4&gt;&lt;br /&gt; &amp;lt;p style="color:#ff3300;"&gt;&amp;lt;strong&gt;We hate spam too - that's why we use a double opt-in strategy and a reputable newsletter service that upholds the CAN SPAM Act. We will never disclose your personal details to anyone unless the law requires us to do so.&amp;lt;/strong&gt;&amp;lt;/p&gt;&lt;br /&gt; &amp;lt;/div&gt;&lt;br /&gt;&amp;lt;/div&gt;&lt;br /&gt;&amp;lt;p&gt;&amp;lt;a class="modal" rel="{handler: 'adopt', adopt:'spampolicy', size: {x:300, y:200}, classWindow: 'spamwindow'}" href="javascript:void(0);"&gt;Read our Spam Policy&amp;lt;/a&gt;&amp;lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Note that this is a cloned element, so the resizing effects are not available. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;handler: url&lt;/u&gt;&lt;/p&gt;&lt;p&gt;This means a relative url from your site. &lt;/p&gt;&lt;blockquote&gt;See our &amp;lt;a class="modal" href="index.php?Itemid=34" rel="{handler: 'url', sizeLoading: {x:150, y:100}, size: {x:640, y:480}, fxResizeDuration:1200, fxContentDuration:500"&gt;Privacy Statement&amp;lt;/a&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;u&gt;handler: iframe&lt;/u&gt;&lt;/p&gt;&lt;p&gt;Use this for external urls.&lt;/p&gt;&lt;blockquote&gt;&amp;lt;p&gt;Click here for &amp;lt;a class="modal" href="http://www.google.com" rel="{handler: 'iframe'}"&gt;Google&amp;lt;/a&gt;&amp;lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Note that this is an iframe, so the resizing effects are not available. &lt;/p&gt;&lt;br /&gt;&lt;h3&gt;adding universal settings to JHTMLBehaviour&lt;/h3&gt;&lt;p&gt;There are 2 params you can optionally add as universal settings if you need them (you probably won't):&lt;/p&gt;&lt;ol&gt;&lt;li&gt;The element and class you want to trigger the modal window &lt;br /&gt;(this is set to &lt;code&gt;a.modal&lt;/code&gt; by default so you wouldn't normally change it unless you had good reason)&lt;/li&gt;&lt;li&gt;&lt;code&gt;$params = array()&lt;/code&gt;&lt;br /&gt;(Note that these can also be added to each individual link that trigger the popup – so only add universal settings here.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Eg if you wanted to universally set the anchor element that triggers the lightbox to &lt;code&gt;a.lightbox&lt;/code&gt; (instead of the default &lt;code&gt;a.modal&lt;/code&gt;), you wanted all windows to open to 640x480 then you can also set your universal options:&lt;/p&gt;&lt;blockquote&gt;$options = array(&lt;br/&gt;&lt;br /&gt; 'size'=&gt;array('x'=&gt;640, 'y'=&gt;480)&lt;br/&gt;&lt;br /&gt; );&lt;br/&gt;&lt;br /&gt;JHTML::_('behavior.modal', 'a.popup', $options);&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;Note that the basic options you can use with &lt;code&gt;JHTML::_('behavior.modal');&lt;/code&gt; can be seen in libraries/joomla/html/html/behaviour.php. These are far fewer than in modal.js. This means the only useful preset you can use as a universal option is size.&lt;/p&gt;&lt;h3&gt;Roll Your Own Code&lt;/h3&gt;&lt;p&gt;If you want to roll your own code – eg to get more effects, then you have to hardcode links to modal.js and modal.css. In addition you need to write your own domready code.&lt;/p&gt;&lt;p&gt;&lt;u&gt;Sample code to include in the &amp;lt;head&gt; of your template's index.php:&lt;/u&gt;&lt;/p&gt;&lt;blockquote&gt;&amp;lt;script src="&amp;lt;?php echo JURI::base(); ?&gt;media/system/js/modal.js" type="text/javascript"&gt;&amp;lt;/script&gt;&lt;br /&gt;&amp;lt;link rel="stylesheet" href="&amp;lt;?php echo JURI::base(); ?&gt;media/system/css/modal.css" type="text/css" /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&gt;&lt;br /&gt;// &amp;lt;!--&lt;br /&gt;window.addEvent('domready', function() {&lt;br /&gt;SqueezeBox.initialize({&lt;br /&gt;size: { x:640,y:480 },&lt;br /&gt;sizeLoading: { x:250,y:250 },&lt;br /&gt;fxResizeDuration:1000,&lt;br /&gt;fxContentDuration:1000,&lt;br /&gt;classWindow: 'lightwin'&lt;br /&gt;});&lt;br /&gt;$$('a.modal').each(function(el) {&lt;br /&gt;el.addEvent('click', function(e) {&lt;br /&gt;new Event(e).stop();&lt;br /&gt;SqueezeBox.fromElement(el);&lt;br /&gt;});&lt;br /&gt;});&lt;br /&gt;});&lt;br /&gt;// --&gt;&lt;br /&gt;&amp;lt;/script&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;p&gt;Notice that I've put the universal presets into the initialise function. From here, it works just the same, presets in links overriding anything set universally. Not all the presets work for all the handlers – as already mentioned. &lt;/p&gt;&lt;p&gt;It's a simple class, so you'd need to write your own version of modal.js to get it to do more.&lt;/p&gt;&lt;br /&gt;References: Joomla 1.5 API JHTMLBehaviour class&lt;br /&gt;&lt;a href="http://api.joomla.org/Joomla-Framework/HTML/JHTMLBehavior.html"&gt;http://api.joomla.org/Joomla-Framework/HTML/JHTMLBehavior.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3112041083315533141-1902566092409086693?l=padmali.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://padmali.blogspot.com/feeds/1902566092409086693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://padmali.blogspot.com/2011/02/modal-window-with-lightbox-native.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/1902566092409086693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/1902566092409086693'/><link rel='alternate' type='text/html' href='http://padmali.blogspot.com/2011/02/modal-window-with-lightbox-native.html' title='modal window with lightbox - native joomla javascript'/><author><name>padmali</name><uri>http://www.blogger.com/profile/17561973047994672197</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_w8HhgOFc3bM/S6PFPiM7ZGI/AAAAAAAAAAo/IR-A7lYCiQI/S220/twitter.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3112041083315533141.post-5980225952578597207</id><published>2010-03-27T03:32:00.000-07:00</published><updated>2011-02-28T12:01:49.654-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='joomla'/><category scheme='http://www.blogger.com/atom/ns#' term='joomla 1.5'/><category scheme='http://www.blogger.com/atom/ns#' term='template override'/><category scheme='http://www.blogger.com/atom/ns#' term='module chrome'/><category scheme='http://www.blogger.com/atom/ns#' term='module class suffix'/><category scheme='http://www.blogger.com/atom/ns#' term='preg_replace'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>joomla module chrome - advanced styling</title><content type='html'>The normal way of styling Module Headers is to add a Module Class Suffix in &lt;br /&gt;Extensions &amp;gt; Modules &amp;gt; YourModule &lt;br /&gt;and then pick it up in the template css file using a selector like moduletable-moduleclasssuffix. But what if you want to do more? What if you want a module header where the H3 color is gray, but the first word is blue? Or the last word is blue?&lt;br /&gt;&lt;br /&gt;This article will show you how to modify h3 titles using Joomla's template overrides with module chrome and a bit help from the preg_replace function.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Step 1 – What's the Module Chrome?&lt;/h3&gt;&lt;br /&gt;Open the module you want to style up in Extensions &amp;gt; Module Manager and find out what position it's set to render in. In this example, the module is in the position: &lt;b&gt;footer&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Next open up index.php in your default template folder and find out if any module chrome has been applied to the position: footer. See the example below.&lt;br /&gt;&lt;br /&gt;index.php:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;div id="somediv"&amp;gt;&lt;br /&gt;&amp;lt;jdoc:include type="modules" name="&lt;b&gt;footer&lt;/b&gt;" style="&lt;b&gt;xhtml&lt;/b&gt;" /&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;Ok, the module chrome is &lt;b&gt;xhtml&lt;/b&gt;. That's great because we're going to use the xhtml chrome to create a template override. Only xhtml and rounded chrome have a h3 header built in, so any other style is useless for this particular example. Other styles you might see are outline, none, table, horz. But none of these have h3 headers so this example won't work with those styles. Default Joomla module chrome can be found in templates &amp;gt; system &amp;gt; html &amp;gt; modules.php and this is the file that Joomla consults if these styles are used.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Step 2 – is there a template override in your default template?&lt;/h3&gt;&lt;br /&gt;Open up your default template and check if there is a folder called &lt;b&gt;html&lt;/b&gt;. If there is, open it up and check for a file on the root of that folder – &lt;b&gt;modules.php&lt;/b&gt;. This is where the template overrides happen, and where we'll put the new module chrome style that'll do all the magic. &lt;br /&gt;&lt;br /&gt;If the html folder isn't present, then add it under your default template and put in a copy of modules.php from templates &amp;gt; system &amp;gt; html &amp;gt; modules.php. (Copy over the blank index.html while you're at it, for security sake).&lt;br /&gt;&lt;br /&gt;If you've just copied modules.php over from the systems template then open it and delete all the functions inside it except for the xhtml chrome function. So to begin with, your default template's html &amp;gt; modules.php file will look like this:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;?php&lt;br /&gt;// no direct access&lt;br /&gt;defined('_JEXEC') or die('Restricted access');&lt;br /&gt;function modChrome_xhtml ($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;{&lt;br /&gt;if (!empty ($module-&amp;gt;content)) : ?&amp;gt;&lt;br /&gt;&amp;lt;div class="moduletable&amp;lt;?php echo $params-&amp;gt;get('moduleclass_sfx'); ?&amp;gt;"&amp;gt;&lt;br /&gt;&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;&amp;lt;h3&amp;gt;&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;?php endif;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;Since you can't just overwrite the system's default chrome names, you'll need to change the name of the chrome, eg to fancyxhtml&lt;br /&gt;&lt;blockquote&gt;function modChrome_fancyxhtml ($module, &amp;amp;$params, &amp;amp;$attribs){&lt;/blockquote&gt;&lt;br /&gt;Now open up your default template's index.php and change the chrome name in the position you want it to show up in – &lt;br /&gt;&lt;blockquote&gt;&amp;lt;div id="somediv"&amp;gt;&lt;br /&gt;&amp;lt;jdoc:include type="modules" name="&lt;b&gt;footer&lt;/b&gt;" style="&lt;b&gt;fancyxhtml&lt;/b&gt;" /&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;h3&gt;Step 3 – Add a Module Class Suffix to the module(s) that you want fancy styling for&lt;/h3&gt;&lt;br /&gt;Go back to Extensions &amp;gt; Module Manager and open up any modules in the footer position (or whatever position you've chosen) that you're going to use the fancy styles for. In Advanced Parameters add the following in Module Class Suffix – &lt;br /&gt;&lt;blockquote&gt;-fancystyle&lt;/blockquote&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://1.bp.blogspot.com/_w8HhgOFc3bM/S63ePoE3t3I/AAAAAAAAABI/QbmS2_cZCDE/s1600/fancytitles1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="222" src="http://1.bp.blogspot.com/_w8HhgOFc3bM/S63ePoE3t3I/AAAAAAAAABI/QbmS2_cZCDE/s400/fancytitles1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The reason to add the module class suffix is so that when we rewrite the fancyxhtml chrome (in templates &amp;gt; yourdefaulttemplate &amp;gt; html &amp;gt; modules.php), it will be the exactly the same as xhtml chrome, UNLESS the module class suffix is –fancystyle, in which case the fancy titles will show up. Otherwise, it'll render the same as ordinary xhtml chrome.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Step 4 – Coding the fancyxhtml chrome&lt;/h3&gt;&lt;br /&gt;In the html &amp;gt; modules.php file in your default template change the fancyxhtml chrome function as follows:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;?php&lt;br /&gt;// no direct access&lt;br /&gt;defined('_JEXEC') or die('Restricted access');&lt;br /&gt;&lt;br /&gt;function modChrome_fancyxhtml ($module, &amp;amp;$params, &amp;amp;$attribs) {&lt;br /&gt;if (!empty ($module-&amp;gt;content)) : ?&amp;gt;&lt;br /&gt;&amp;lt;div class="moduletable&amp;lt;?php echo $params-&amp;gt;get('moduleclass_sfx'); ?&amp;gt;"&amp;gt;&lt;br /&gt;&amp;lt;?php &lt;br /&gt;if ($module-&amp;gt;showtitle != 0) :&lt;br /&gt;if ($params-&amp;gt;get('moduleclass_sfx')==='-fancystyle') :&lt;br /&gt;$pattern = '/([\S]+)$/'; //match the last word&lt;br /&gt;$title = preg_replace($pattern, "&amp;lt;span class="twotone"&amp;gt;$1&amp;lt;/span&amp;gt;",$module-&amp;gt;title);&lt;br /&gt;else :&lt;br /&gt;$title = $module-&amp;gt;title;&lt;br /&gt;endif;&lt;br /&gt;echo '&amp;lt;h3&amp;gt;' . $title . '&amp;lt;/h3&amp;gt;';&lt;br /&gt;endif;&lt;br /&gt;echo $module-&amp;gt;content;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;?php endif;&lt;br /&gt;} //end function&lt;br /&gt;?&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;If you want to apply the twotone style to the first word instead of the last word, just change the pattern to:&lt;br /&gt;&lt;blockquote&gt;$pattern = '/^([\S]+)/'; //match the first word instead&lt;/blockquote&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;Basic explanation of pattern matching:&lt;/span&gt;&lt;br /&gt;&lt;code&gt;\S&lt;/code&gt; - means match anything that is NOT a space.&lt;br /&gt;&lt;code&gt;[\S]+&lt;/code&gt; - match any char that is NOT a space, 1 or more times&lt;br /&gt;&lt;code&gt;([\S]+)&lt;/code&gt; - the bracket picks up the entire match as a variable&lt;br /&gt;&lt;code&gt;([\S]+)$&lt;/code&gt; - pick it up at the end of the string ($)&lt;br /&gt;&lt;code&gt;^([\S]+)&lt;/code&gt; - pick it up at the start of the string (^)&lt;br /&gt;&lt;code&gt;$n&lt;/code&gt; - substitute the variable from the nth bracket&lt;br /&gt;&lt;br /&gt;If you want to know more about the incredibly versatile preg_replace functions start with http://php.net/manual/en/function.preg-replace.php&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Step 5 – CSS for Styling&lt;/h3&gt;&lt;br /&gt;In the css file for your default template you could pick up the h3 styling as in:&lt;br /&gt;&lt;blockquote&gt;.moduletable-fancystyle {background-color: #eeeeee;}&lt;br /&gt;.moduletable-fancystyle h3 { color: #999999; }&lt;br /&gt;.moduletable-fancystyle h3 .twotone { color: #0000FF; }&lt;/blockquote&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://2.bp.blogspot.com/_w8HhgOFc3bM/S63eZ-NP_6I/AAAAAAAAABQ/602gXWaU7Jk/s1600/fancytitles2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_w8HhgOFc3bM/S63eZ-NP_6I/AAAAAAAAABQ/602gXWaU7Jk/s320/fancytitles2.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If you were to View &amp;gt; Source, you'd see:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;div class="moduletable-fancystyle"&amp;gt;&lt;br /&gt;&amp;lt;h3&amp;gt;Fancy &amp;lt;span class='twotone'&amp;gt;Module&amp;lt;/span&amp;gt;&amp;lt;/h3&amp;gt;&amp;lt;p&amp;gt;This is my fancy module with 2 tone colors in H3&amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3112041083315533141-5980225952578597207?l=padmali.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://padmali.blogspot.com/feeds/5980225952578597207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://padmali.blogspot.com/2010/03/joomla-module-chrome-advanced-styling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/5980225952578597207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/5980225952578597207'/><link rel='alternate' type='text/html' href='http://padmali.blogspot.com/2010/03/joomla-module-chrome-advanced-styling.html' title='joomla module chrome - advanced styling'/><author><name>padmali</name><uri>http://www.blogger.com/profile/17561973047994672197</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_w8HhgOFc3bM/S6PFPiM7ZGI/AAAAAAAAAAo/IR-A7lYCiQI/S220/twitter.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_w8HhgOFc3bM/S63ePoE3t3I/AAAAAAAAABI/QbmS2_cZCDE/s72-c/fancytitles1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3112041083315533141.post-2943569507914130928</id><published>2010-03-19T05:57:00.000-07:00</published><updated>2011-02-25T04:00:00.495-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='joomla'/><category scheme='http://www.blogger.com/atom/ns#' term='tinymce'/><category scheme='http://www.blogger.com/atom/ns#' term='extended valid elements'/><title type='text'>TinyMCE Strips Out Code in Joomla</title><content type='html'>I like the TinyMCE editor except for the fact that it strips out some code when you edit HTML. Like you go to the trouble of adding something like:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;div class="mystyle"&amp;gt;text&amp;lt;/div&amp;gt;&lt;/blockquote&gt;you save it, and return to find that TinyMCE has stripped out the class attribute leaving you with:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;div&amp;gt;text&amp;lt;/div&amp;gt;&lt;/blockquote&gt;The good news is that we can fix all that by using Extended Valid Elements.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;Extended Valid Elements to the Rescue&lt;/h3&gt;&lt;br /&gt;In the Joomla backend go to Extensions &amp;gt; Plugin Manager &amp;gt; Editor - TinyMCE. You can leave the editor functionality set to Advanced. Scroll down until you find the textarea for Extended Valid Elements, its should be empty as you can see below.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://4.bp.blogspot.com/_w8HhgOFc3bM/S6Nr2-TfjdI/AAAAAAAAAAU/UZHs_V3yl2k/s1600-h/extendedvalidelements1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_w8HhgOFc3bM/S6Nr2-TfjdI/AAAAAAAAAAU/UZHs_V3yl2k/s320/extendedvalidelements1.gif" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;/div&gt;&lt;br /&gt;The trick here is to put back the elements and attributes that TinyMCE is determined to strip out. So if you want to be able to use &lt;br /&gt;&amp;lt;div class="mystyle"&amp;gt;&lt;br /&gt;and also &amp;lt;img class="somestyle" /&amp;gt; and also &amp;lt;span&amp;gt; then you would use the following format separating the elements with a comma:&lt;br /&gt;&lt;blockquote&gt;div[attr1 | attr2 | attr3], img[attr1|attr2], span[attr]&lt;/blockquote&gt;What I mostly put into Extended Valid Elements takes care of any attributes I want to use with div, img and span, but of course you can add more. Notice no line breaks:&lt;br /&gt;&lt;blockquote&gt;div[id|name|style|class|onclick|onmouseover|onmouseout],span[id|class|style],img[&lt;br /&gt;class|src|border|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout&lt;br /&gt;|name]&lt;/blockquote&gt;&lt;br /&gt;&lt;h3&gt;Why all the Attributes?&lt;/h3&gt;&lt;br /&gt;The reason to use so many attributes is according to TinyMCE:&lt;br /&gt;&lt;i&gt;When adding a new attribute by specifying an existing element rule (e.g.  img), the entire rule for that element is over-ridden so be sure to  include all valid attributes not just the one you wish to add.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;If you want to find all the valid attributes, you can do so here:&amp;nbsp;&lt;a href="http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements"&gt;http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Warning: Watch out for Line Breaks when Pasting!&lt;/h3&gt;&lt;br /&gt;If you have any line breaks in what you paste into Extended Valid Elements, you'll end up with a heap of problems and it might even break TinyMCE. Be sure to paste with no line breaks! If you've done it wrong, you might see \n appearing in the Extended Valid Elements textarea. You can try to get rid of them, but the textarea is so small you usually end up creating even more problems.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://2.bp.blogspot.com/_w8HhgOFc3bM/S6NxHP5M8MI/AAAAAAAAAAc/EcYEZVejB2Y/s1600-h/extendedvalidelements2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_w8HhgOFc3bM/S6NxHP5M8MI/AAAAAAAAAAc/EcYEZVejB2Y/s320/extendedvalidelements2.gif" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;If things still don't work, close out of the plugin and use something like phpMyAdmin and locate the jos_plugins table. Click on Editor - TinyMCE and look at the params row. You can actually correct it from here. Scroll down the params until you reach extended_elements. Remove any \n (newlines) and/or duplicate elements. You can leave the pipe escapes (\|) alone, they're ok and won't do any harm. This is what it should look like when you're done:&lt;br /&gt;&lt;blockquote&gt;...other params above &lt;br /&gt;extended_elements=div[id\|style\|class\|onclick\|onmouseover\|onmouseout],span[id\|class\|style], img[class\|src\|border\|alt\|title\|hspace\|vspace\| width\|height\|align\|onmouseover\|onmouseout\|name]&lt;br /&gt;...more params below&lt;/blockquote&gt;&lt;br /&gt;Click Save, then try it again. TinyMCE is now ready to rock!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3112041083315533141-2943569507914130928?l=padmali.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://padmali.blogspot.com/feeds/2943569507914130928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://padmali.blogspot.com/2010/03/tinymce-strips-out-code-in-joomla.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/2943569507914130928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/2943569507914130928'/><link rel='alternate' type='text/html' href='http://padmali.blogspot.com/2010/03/tinymce-strips-out-code-in-joomla.html' title='TinyMCE Strips Out Code in Joomla'/><author><name>padmali</name><uri>http://www.blogger.com/profile/17561973047994672197</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_w8HhgOFc3bM/S6PFPiM7ZGI/AAAAAAAAAAo/IR-A7lYCiQI/S220/twitter.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_w8HhgOFc3bM/S6Nr2-TfjdI/AAAAAAAAAAU/UZHs_V3yl2k/s72-c/extendedvalidelements1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3112041083315533141.post-3062977205950992836</id><published>2010-03-07T10:40:00.000-08:00</published><updated>2011-02-25T04:05:18.550-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='joomla'/><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='dependent selects'/><category scheme='http://www.blogger.com/atom/ns#' term='changeDynaList'/><title type='text'>Dependent Selects using Joomla's javascript library – changeDynaList()</title><content type='html'>Dependent selects can be created using Joomla's built-in javascript library &lt;br /&gt;(see includes &amp;gt; js &amp;gt; joomla.javascript.js )&lt;br /&gt;using the changeDynaList() function.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://1.bp.blogspot.com/_w8HhgOFc3bM/S5OaBuLhEiI/AAAAAAAAAAM/yXWQyTBjsBw/s1600-h/selects.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_w8HhgOFc3bM/S5OaBuLhEiI/AAAAAAAAAAM/yXWQyTBjsBw/s320/selects.gif" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;/div&gt;So what I want to achieve here is that by selecting a Department, the Subdepartment dropdown gets dynamically populated.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;There are 2 scenarios – a new course being added and an existing course being edited. In a new course, I only have to list the Departments to begin with. The Subdepartment select would be empty until a Department is chosen. In the second scenario, an edit of an existing course, I want the values of the department and subdepartment to display in the selects.&lt;br /&gt;In this example, I'm working in the Admin section of the Model for the component I'm creating. I want to generate &lt;a href="http://api.joomla.org/Joomla-Framework/HTML/JHTMLSelect.html"&gt;JHTMLSelect genericLists&lt;/a&gt; which will be returned from the Model to the View for display in the template.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The basic method – in the Model&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;Use Joomlas generic list function to create the Department list (named 'didlist'),&lt;/li&gt;&lt;li&gt;Same for the Subdepartment (named 'sidlist')&lt;/li&gt;&lt;li&gt;Create a javascript array called subdeptarray in the form [key, text, value] which the javascript function changeDynaList can work with in the template.&lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;The Department List (in the Model)&lt;/h3&gt;Ok, lets suppose you've queried the database for all the Departments, something like this:&lt;br /&gt;&lt;blockquote&gt;$query = 'SELECT id AS did, department FROM #__departments';&lt;br /&gt;$this-&amp;gt;_db-&amp;gt;setQuery( $query );&lt;br /&gt;$departments = $this-&amp;gt;_db-&amp;gt;loadObjectList();&lt;/blockquote&gt;You now have the departments object, but we need to do a little work before we can stuff that into the JHTMLSelect genericList function:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I want to add an option at the top of the dropdown that says "Choose Department" with an option value of 0.&lt;/li&gt;&lt;li&gt;The Department select must contain a javascript attribute along the lines of:&lt;br /&gt;onchange=changeDynaList(param1, param2, etc)&lt;/li&gt;&lt;/ol&gt;&lt;u&gt;1. Add an option - Choose Department&lt;/u&gt;&lt;br /&gt;To add the Choose option I'll use the&lt;a href="http://api.joomla.org/Joomla-Framework/HTML/JHTMLSelect.html#option"&gt; JHTMLSelect option&lt;/a&gt; function to insert an extra option:&lt;br /&gt;&lt;blockquote&gt;object option (string $value, [string $text = ''], [string $value_name = 'value'], [string $text_name = 'text'], [ $disable = false])&lt;/blockquote&gt;as follows:&lt;br /&gt;&lt;blockquote&gt;$deps[] = JHTML::_('select.option', '0', JText::_(' - Choose Department - '), 'did', 'department');&lt;/blockquote&gt;Then I'll merge this with the $departments object I got from the DB query. This will work fine because the option only needs 2 values in the order of key – value and $departments provides both those values in the right order.&lt;br /&gt;&lt;blockquote&gt;$deps = array_merge($deps, $departments); //complete list of html options&lt;/blockquote&gt;&lt;u&gt;2. Add the javascript attribute&lt;/u&gt;&lt;br /&gt;Sort out the javascript which will trigger the changeDynaList function (this will be stuffed into the JHTMLSelect genericList function also)&lt;br /&gt;The changeDynaList function is in the format:&lt;br /&gt;&lt;blockquote&gt;function changeDynaList( listname, source, key, orig_key, orig_val ) &lt;/blockquote&gt;where:&lt;br /&gt;listname – name of list to change 'sidlist'&lt;br /&gt;source – a javascript array of list options in the form [key,value,text] which we will later program in as $subdeptarray&lt;br /&gt;key – the key to display&lt;br /&gt;orig_key – the original key that was selected&lt;br /&gt;orig_val – the original item value that was selected&lt;br /&gt;&lt;br /&gt;Since in this example the list will be shown in an admin template I'll use:&lt;br /&gt;&lt;blockquote&gt;$js = "onchange=\"changeDynaList( 'sidlist',  subdeptarray, document.adminForm.didlist.value, document.adminForm.didlist.options[document.adminForm.didlist.selectedIndex].value, &lt;br /&gt;document.adminForm.didlist.options[document.adminForm.didlist.selectedIndex].text);\"";&lt;/blockquote&gt;&lt;u&gt;3. Stuff the lot into Joomla's JHTMLSelect genericList&lt;/u&gt;&lt;br /&gt;Then finally stuff it all back into the JHTMLSelect genericList function, noting that the js is appended to the attributes param.&lt;br /&gt;&lt;blockquote&gt;string genericlist (array $arr, string $name, [string $attribs = null], [string $key = 'value'], [string $text = 'text'], [mixed $selected = NULL], [ $idtag = false], [ $translate = false])&lt;/blockquote&gt;as follows:&lt;br /&gt;&lt;blockquote&gt;$lists['departments'] = JHTML::_('select.genericlist',  $deps, 'didlist', 'class="inputbox" size="1" '.$js, 'did', 'department', intval($selecteddept));&lt;/blockquote&gt;The last value - $selecteddept – you would use if the user was editing an existing course rather than creating a new one where the value would just be 0. Obviously you could harvest this value in a number of ways in your model. If a department's value is greater than 0, then you're dealing with an edit and you'll also need a value from the subdepartments select. In this example those values are referred to as:&lt;br /&gt;&lt;blockquote&gt;$selecteddept;  //0 or id value from the database&lt;br /&gt;$selectedsubdept; //0, or id value from the database&lt;/blockquote&gt;So now $lists['departments'] is ready to be returned to the View.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The Subdepartment List (in the Model)&lt;/h3&gt;Again, we would get the complete list of subdepartments from the database in the Model using a query like:&lt;br /&gt;&lt;blockquote&gt;$query = 'SELECT id AS sid, did, subdepartment FROM #__ subdepartments';&lt;br /&gt;$this-&amp;gt;_db-&amp;gt;setQuery( $query );&lt;br /&gt;$subdepartments = $this-&amp;gt;_db-&amp;gt;loadObjectList();&lt;/blockquote&gt;Since a course can be added directly to a department (with or without subdepartment – like Joomla articles can be added directly to Sections without a Category), I need to program in 2 extra options. The first option is the usual 'Choose Subdepartment', value '0', and the second is 'None' value '-1' since courses can be added directly to department, without reference to a subdepartment.&lt;br /&gt;To get your head around it at this stage, what we're programming here is the initial state of the dependent subdepartment select when the form first opens. That's why we can't use array_merge here. What's seen in the Subdepartment select is entirely dependent on the state of the Department select.&lt;br /&gt;If no department has been selected (ie new course), then the value of  $selecteddept is also 0 and there won't be any other values in the select for the subdepartment.&lt;br /&gt;On the other hand, if a department has been selected (eg editing an existing course) then we not only have to add 'None' as an extra option, but also list only those subdepartments that come under the department chosen in the department select.&lt;br /&gt;&lt;u&gt;1. Program in the Choose Subdepartment option&lt;/u&gt;&lt;br /&gt;&lt;blockquote&gt;$subdeps[] = JHTML::_('select.option', '0', JText::_(' - Choose Subdepartment - '), 'sid', 'subdepartment'); &lt;/blockquote&gt;&lt;u&gt;2. Program in the None option&lt;/u&gt;&lt;br /&gt;&lt;blockquote&gt;if ((int) $selecteddept != 0) {&lt;br /&gt;$subdeps[] = JHTML::_('select.option', '-1', JText::_('None'), 'sid', 'subdepartment');&lt;br /&gt;}&lt;/blockquote&gt;&lt;u&gt;3. Program in the rest of the options for the subdepartment&lt;/u&gt;&lt;br /&gt;&lt;blockquote&gt;foreach ($subdepartments as $subdepartment) {&lt;br /&gt;if ($selecteddept == $subdepartment-&amp;gt;did) {&lt;br /&gt;$subdeps[] = JHTML::_('select.option', $subdepartment-&amp;gt;sid, $subdepartment-&amp;gt;subdepartment, 'sid', 'subdepartment');&lt;br /&gt;}&lt;br /&gt;}&lt;/blockquote&gt;Ok, now we're ready to stuff this into JHTMLSelect genericList as follows:&lt;br /&gt;&lt;blockquote&gt;$lists['subdepartments'] = JHTML::_('select.genericlist',  $subdeps, 'sidlist', 'class="inputbox" size="1" ', 'sid', 'subdepartment', intval($selectedsubdept));&lt;/blockquote&gt;And now the subdepartment list is ready to be returned to the View.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The subdeptarray (in the model)&lt;/h3&gt;The final requirement is to program an array mapping all the possible department keys to subdepartment text and values. We'll do this in PHP in the model and transfer it to the view for templating into its final form which will be javascript.&lt;br /&gt;In the final form (javascript in the template) it will show something like this:&lt;br /&gt;&lt;blockquote&gt;var subdeptarray = new Array();// [key,value,text]&lt;br /&gt;subdeptarray[0] = new Array( '6','0',' - Choose Subdepartment - ' );&lt;br /&gt;subdeptarray[1] = new Array( '6','-1','None' );&lt;br /&gt;subdeptarray[2] = new Array( '6','1','Ancient History' );&lt;br /&gt;subdeptarray[3] = new Array( '6','5','Medieval History' );&lt;br /&gt;subdeptarray[4] = new Array( '6','4','Modern History' );&lt;br /&gt;etc&lt;/blockquote&gt;Where, say, 6 is the History department id ('did'), the next value is the subdepartment id ('sid') and the final value is the name of the subdepartment).&lt;br /&gt;The changeDynaList javascript function requires that the var subdeptarray is written in the format [key,value,text]&lt;br /&gt;Back to the model, we'll pick up the 2 objects that we got from the original queries which contain the entire department list and the entire subdepartment list – ie $departments and $subdepartments and generate the php version of the subdeptarray to return the view. The first foreach just creates a '0' and '-1' option value for each of the subdepartments, in line with the lists generated to display the subdepartment select. The second foreach generates the list of subdepartments options present. &lt;br /&gt;&lt;blockquote&gt;foreach ($departments as $department) {&lt;br /&gt;$subdeptarray [$department-&amp;gt;did][] = JHTML::_('select.option', '0', JText::_(' - Choose Subdepartment - '), 'sid', 'subdepartment');&lt;br /&gt;$subdeptarray [$department-&amp;gt;did][] = JHTML::_('select.option', '-1', JText::_('None'), 'sid', 'subdepartment');&lt;br /&gt;}&lt;br /&gt;foreach ($subdepartments as $subdepartment) {&lt;br /&gt;$subdeptarray [$subdepartment-&amp;gt;did][] = JHTML::_('select.option', $subdepartment-&amp;gt;sid, $subdepartment-&amp;gt;subdepartment, 'sid', 'subdepartment');&lt;br /&gt;}&lt;br /&gt;return $subdeptarray;&lt;/blockquote&gt;&lt;h3&gt;Displaying $subdeptarray in the Template&lt;/h3&gt;Presuming your View has picked up the 2 lists (departments, subdepartments) and $subdeptarray, then all that's left is to display them in the template for the view (eg default.php)&lt;br /&gt;default.php:&lt;br /&gt;&lt;blockquote&gt;&amp;lt;?php &lt;br /&gt;defined('_JEXEC') or die('Restricted access'); ?&amp;gt;&lt;br /&gt;&amp;lt;script language="javascript" type="text/javascript"&amp;gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;var subdeptarray = new Array(); // array in the format [key,value,text]&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$i = 0;&lt;br /&gt;foreach ($this-&amp;gt;subdeptarray as $k=&amp;gt;$items) {&lt;br /&gt;foreach ($items as $v) &lt;br /&gt;echo "subdeptarray[".$i++."] = new Array( '$k','".addslashes( $v-&amp;gt;sid )."','".addslashes( $v-&amp;gt;subdepartment )."' );\n\t\t";&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;//--&amp;gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;form action="fill-this-in" method="post" name="adminForm" id="adminForm"&amp;gt;&lt;br /&gt;&amp;lt;table class="admintable"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td width="100" align="right" class="key"&amp;gt;&lt;br /&gt;&amp;lt;label for="department"&amp;gt;&lt;br /&gt;&amp;lt;?php echo JText::_( 'Department' ); ?&amp;gt;:&lt;br /&gt;&amp;lt;/label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;?php &lt;br /&gt;echo $this-&amp;gt;lists['departments']; &lt;br /&gt;?&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td width="100" align="right" class="key"&amp;gt;&lt;br /&gt;&amp;lt;label for="subdepartment"&amp;gt;&lt;br /&gt;&amp;lt;?php echo JText::_( 'Subdepartment' ); ?&amp;gt;:&lt;br /&gt;&amp;lt;/label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;?php &lt;br /&gt;echo $this-&amp;gt;lists['subdepartments']; &lt;br /&gt;?&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;etc&lt;/blockquote&gt;References: Joomla 1.5 API JHTMLSelect class&lt;br /&gt;&lt;a href="http://api.joomla.org/Joomla-Framework/HTML/JHTMLSelect.html"&gt;http://api.joomla.org/Joomla-Framework/HTML/JHTMLSelect.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3112041083315533141-3062977205950992836?l=padmali.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://padmali.blogspot.com/feeds/3062977205950992836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://padmali.blogspot.com/2010/03/dependent-selects-using-joomlas.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/3062977205950992836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/3062977205950992836'/><link rel='alternate' type='text/html' href='http://padmali.blogspot.com/2010/03/dependent-selects-using-joomlas.html' title='Dependent Selects using Joomla&apos;s javascript library – changeDynaList()'/><author><name>padmali</name><uri>http://www.blogger.com/profile/17561973047994672197</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_w8HhgOFc3bM/S6PFPiM7ZGI/AAAAAAAAAAo/IR-A7lYCiQI/S220/twitter.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_w8HhgOFc3bM/S5OaBuLhEiI/AAAAAAAAAAM/yXWQyTBjsBw/s72-c/selects.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3112041083315533141.post-7463255939003428370</id><published>2010-03-05T07:00:00.000-08:00</published><updated>2011-02-25T04:08:49.804-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='domain'/><category scheme='http://www.blogger.com/atom/ns#' term='localhost'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><category scheme='http://www.blogger.com/atom/ns#' term='htaccess'/><category scheme='http://www.blogger.com/atom/ns#' term='subdomain'/><title type='text'>domains and subdomains on apache localhost windows</title><content type='html'>Its frustrating when you need to test how htaccess is going to work against domains and subdomains on your windows localhost (apache-mysql-php), when all you have to work with is a uri like:&lt;br /&gt;&lt;blockquote&gt;http://127.0.0.1/etc or&lt;br /&gt;http://localhost/etc&lt;br /&gt;&lt;/blockquote&gt;On windows you can create domains and subdomains to show up instead. &lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;You need to alter 2 files:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;httpd.conf [under your apache install, in the conf folder] and&lt;/li&gt;&lt;li&gt;hosts [in windows go to windows &amp;gt; system32 &amp;gt; drivers &amp;gt; etc]&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;To begin with, stop the Apache service. Otherwise it won't pick up on the changes til ur next restart. When you've done all the changes, then turn it back on.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;httpd.conf&lt;/h3&gt;Open up httpd.conf in a decent text editor, or Notepad if you have nothing better. At the bottom of that file add the following:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;NameVirtualHost *:80&lt;br /&gt;&lt;br /&gt;&amp;lt;virtualhost *:80&amp;gt;&lt;br /&gt;DocumentRoot "C:/path/to/documentroot"&lt;br /&gt;ServerName localhost&lt;br /&gt;&amp;lt;/virtualhost&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;virtualhost *:80&amp;gt;&lt;br /&gt;DocumentRoot "C:/path/to/documentroot/subfolder"&lt;br /&gt;ServerName example.tld&lt;br /&gt;ServerAlias www.example.tld www subdomain.example.tld subdomain&lt;br /&gt;&amp;lt;/virtualhost&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;h3&gt;hosts file&lt;/h3&gt;&lt;br /&gt;Again, open this up in a decent text editor and type the following, being sure to keep each entry on a new line:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;127.0.0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; localhost&lt;br /&gt;127.0.0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; example.tld&lt;br /&gt;127.0.0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; www.example.tld&lt;br /&gt;127.0.0.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subdomain.example.tld&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So what we have now is that instead of http://127.0.0.1 you can use http://localhost. This will work for anything on the documentRoot. (If you're not sure where your documentRoot is, check it in httpd.conf, it'll tell you).&lt;br /&gt;&lt;br /&gt;You can now also use http://example.tld, http://www.example.tld and http://subdomain.example.tld in the subfolder that you specified here:&lt;br /&gt;&lt;i&gt;C:/path/to/documentroot/subfolder&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;It's handy when you have a lot of sites for testing in localhost under windows-apache-php-mysql and you need to see what's happening when testing .htaccess&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3112041083315533141-7463255939003428370?l=padmali.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://padmali.blogspot.com/feeds/7463255939003428370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://padmali.blogspot.com/2010/03/domains-and-subdomains-on-apache.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/7463255939003428370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3112041083315533141/posts/default/7463255939003428370'/><link rel='alternate' type='text/html' href='http://padmali.blogspot.com/2010/03/domains-and-subdomains-on-apache.html' title='domains and subdomains on apache localhost windows'/><author><name>padmali</name><uri>http://www.blogger.com/profile/17561973047994672197</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_w8HhgOFc3bM/S6PFPiM7ZGI/AAAAAAAAAAo/IR-A7lYCiQI/S220/twitter.png'/></author><thr:total>0</thr:total></entry></feed>
