<?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>Toolbox Digital Services &#187; CSS</title>
	<atom:link href="http://toolboxdigital.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://toolboxdigital.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 05 Aug 2010 09:15:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Advanced Techniques: The Joomla Parent Menu ItemID</title>
		<link>http://toolboxdigital.com/2010/03/advanced-techniques-the-joomla-parent-menu-itemid/</link>
		<comments>http://toolboxdigital.com/2010/03/advanced-techniques-the-joomla-parent-menu-itemid/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 22:50:56 +0000</pubDate>
		<dc:creator>Dan Luton</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://toolboxdigital.com/?p=411</guid>
		<description><![CDATA[Joomla&#8217;s ItemID system offers a great way of customizing sites by giving the opportunity to style major parts of a template or page based on the menu links ItemID.  ...]]></description>
			<content:encoded><![CDATA[<p>Joomla&#8217;s ItemID system offers a great way of customizing sites by giving the opportunity to style major parts of a template or page based on the menu links ItemID.  Every menu link in a Joomla website has one; and they are unique to each and every link on your site.</p>
<p>But what if you need to style entire sections of a site based on a handful of top-level (parent) menu items?</p>
<p>This article explores the methodology of styling sub-level pages respective of their common parent menu links.</p>
<span id="more-411"></span>
<p><img src="http://toolboxdigital.com/wp-content/uploads/2010/01/menusystem.jpg" alt="menusystem" title="menusystem" width="774" height="283" class="alignnone size-full wp-image-487" /></p>
<h3>Method 1: Modifying the mod_breadcrumb Module Code</h3>
<p>The mod_breadcrumb module is native to Joomla, and by it&#8217;s core function maintains a trail of menu link hierarchy leading to the current page.  This code can be utilized in order to obtain the top-level menu&#8217;s textual name (rather than an itemID number).  This method expands the code further to reformat this text into a usable, readable format which can be used to style a page in an understandable way.  It&#8217;s more code-heavy than method 2, but provides an easier-to-understand output that works in exactly the same way.</p>
<p>Let&#8217;s first examine the original code:</p>
<pre class="brush:php">
defined('_JEXEC') or die('Restricted access');

class modBreadCrumbsHelper
{
	function getList(&#038;$params)
	{
		global $mainframe;

		// Get the PathWay object from the application
		$pathway =&#038; $mainframe->getPathway();
		$items   = $pathway->getPathWay();

		$count = count($items);
		for ($i = 0; $i &lt; $count; $i ++)
		{
			$items[$i]->name = stripslashes(htmlspecialchars($items[$i]->name));
			$items[$i]->link = JRoute::_($items[$i]->link);
		}

		if ($params->get('showHome', 1))
		{
			$item = new stdClass();
			$item->name = $params->get('homeText', JText::_('Home'));
			$item->link = JURI::base();
			array_unshift($items, $item);
		}

		return $items;
	}
	
	function setSeparator($custom = null)
	{
		global $mainframe;

		$lang =&#038; JFactory::getLanguage();

		if ($custom == null) {
			if($lang->isRTL()){
				$_separator = JHTML::_('image.site', 'arrow_rtl.png');
			}
			else{
				$_separator = JHTML::_('image.site', 'arrow.png');
			}
		} else {
			$_separator = $custom;
		}
		return $_separator;
	}
}
</pre>
<p>We can immediately remove the second part of the code that sets the separator, since we don&#8217;t need that.  Also, since we only need to return the parent item&#8217;s text, we don&#8217;t need the loop in place.  We shall also use the <em>Application Object</em> since <strong><br />$global mainframe</strong> will be removed in Joomla 1.6, so:</p>
<pre class="brush:php">
$global mainframe; 
</pre>
<p>Becomes:</p>
<pre class="brush:php">
$app = &#038;JFactory::getApplication();
</pre>
<p>Which gives us the completed code below:</p>
<pre class="brush:php">
class getParentMenuTitle {
	function getList() {
		$getParent = &#038;JFactory::getApplication();
		// Get the PathWay object
		$pathway =&#038; $getParent->getPathway();
		$items = $pathway->getPathWay();
	return $items;
	}
}
$list = getParentMenuTitle::getList();
$count = count($list);
if ($count !== 0) :
	$parentmenu = $list[0]->name;
	$parentmenu = ereg_replace(" ", "-", $parentmenu); // replace spaces with a dash
	$parentmenu = ereg_replace("[^+A-Za-z0-9-]", "", $parentmenu); // strip special characters
	$parentmenu = strtolower($parentmenu); //set name to lowercase
else :
	$parentmenu = "home"; // Set parentmenu to "home" if there are no items
endif;
</pre>
<h3>How To Use The Code</h3>
<p>This block of code can be inserted directly into your active template&#8217;s <strong>index.php</strong> file before the HTML is started.  Remember to enclose the code block in PHP tags.  Alternatively you can include it from an external file.</p>
<p>Once working in the template, you can apply the variable <strong>$parentmenu</strong> to a top-level container to initiate a CSS hook.  Where you add this will depend on what you need to influence in the design, but the further up the hierarchy the more things you will be able to affect in the design &#8211; for example:</p>
<pre class="brush:php">
&lt;body id="&lt;?php echo $parentmenu; ?>">
</pre>
<p>&#8230;will allow you to influence the design across the whole template, such as:</p>
<pre class="brush:css">
body#menu-link-name a {color:red;}
</pre>
<p>&#8230;which will change all links on the page to red for that particular top-level menu link.</p>
<h3>Method 2: Using the Jsite Object</h3>
<p>This method is by far the simplist of the two methods, and unless you need a more human-readable format for the menu class/ids then it&#8217;s by far the recommended method of the two.  It uses the Jsite object to obtain the parent menu&#8217;s ItemID and stores it in a variable which can then be applied to any class/id in the template:</p>
<pre class="brush:php">
$parentmenu = JSite::getMenu()->getActive()->tree[0];
</pre>
<p>You can obtain the ItemID of any menu links in the pathway by altering the value of <strong>tree[0]</strong>.</p>
<h3>How To Use The Code</h3>
<p>Again, this code needs to be inserted into the template.  The ItemID is stored in the <strong>$parentmenu</strong> variable, just as it was before, so you can use a similar method to above &#8211; but prefix the class/id with something or else you may have problems, for example:</p>
<pre class="brush:php">
&lt;body id="menuID-&lt;?php echo $parentmenu; ?>">
</pre>
<h3>Why Would You Need To Use Method 1?</h3>
<p>The first method could be useful in instances where you (as the developer) might want to pass more control onto someone who is less technically-minded &#8211; the class/id names which are generated using this method are very easy to predict, whereas method 2 requires the administrator to lookup the itemID for each menu item that requires styling.</p>
<h3>Something to Share?</h3>
<p>Have an alternative technique, or have you used this (or something similar) on a site before?  Please do share it in the comments.</p>
<span class="small">Many thanks to <a href="http://joomline.org/">Gergő Erdősi</a> and <a href="http://www.alltogetherasawhole.org">Amy Stephen</a> for the code presented in method 2 above. 
]]></content:encoded>
			<wfw:commentRss>http://toolboxdigital.com/2010/03/advanced-techniques-the-joomla-parent-menu-itemid/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Anatomy of a Newsletter</title>
		<link>http://toolboxdigital.com/2010/01/anatomy-of-a-newsletter/</link>
		<comments>http://toolboxdigital.com/2010/01/anatomy-of-a-newsletter/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 11:12:59 +0000</pubDate>
		<dc:creator>Dan Luton</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Newsletters]]></category>

		<guid isPermaLink="false">http://toolboxdigital.com/?p=418</guid>
		<description><![CDATA[We&#8217;ve recently been tasked with designing and building a bunch of newsletters for different sites.  Newsletter crafting can be pretty straightforward but cumbersome at times due to the way ...]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve recently been tasked with designing and building a bunch of newsletters for different sites.  Newsletter crafting can be pretty straightforward but cumbersome at times due to the way they must be constructed in order to retain the original designs &#8211; even more so if the designs are quite complex and laden with images.</p>
<p>This article describes the basics for turning your newsletter designs into functional newsletters.</p>
<span id="more-418"></span>
<h3>Getting Started</h3>
<p>First off, work from a design so you know how the final construction will look.  This can be a full-blown Photoshop mock-up, or a wireframe&#8230;however you make it, just make sure it&#8217;s designed as you&#8217;d like the final newsletter to appear.</p>
<p>Once your design is ready, you will need to create the framework of the newsletter, using HTML tables and a combination of carefully defined table-cells. You can save some time here by using a visual (WYSIWYG) editor such as Dreamweaver to visually create the layout; this will save a significant amount of time over hand-coding the table layout.  In fact, you can use a visual editor to create the whole thing &#8211; but I personally prefer to see exactly what&#8217;s going on, so tend to hand-code once the basic structure is defined.</p>
<img src="http://toolboxdigital.com/wp-content/uploads/2010/01/table-layout.jpg" alt="table-layout" title="table-layout" width="774" height="619" class="noborder" />
<p>Note that the table I&#8217;ve used here is quite narrow (600px) and centered &#8211; you can use your own dimensions and alignment here, but this arrangement seems to work best for most email clients and display resolutions.</p>
<p>I&#8217;ve also left the border active (<strong>border=&quot;1&quot;</strong>) which will help when I add content to the layout.  You can disable this later if you do not wish the borders to be displayed in the final newsletter.</p>
<h3>Adding Content</h3>
<p>Once you have your basic structure in place, you&#8217;re ready to start adding content (text and images) to the newsletter.  For now, don&#8217;t worry about the styling; just add the bulk of the text and any images you have to the layout.</p>
<p>If you don&#8217;t have final images, use exact-sized placeholders until the graphics are ready.  This will help to get the layout exactly right, and show where any fine adjustments to the table layout is needed.</p>
<p>Images should be added using the absolute path to the server where they are stored:</p>
<pre class="brush:html">
&lt;img src="http://mydomain.com/images/header.jpg" alt="" />
</pre>
<p>&#8230;this will ensure the images load correctly into the document.  Note that many email clients will require user approval before they fully display embedded images &#8211; it is not possible to override this.</p>
<h3>Adding the Style</h3>
<p>This is where most of the time is consumed &#8211; actually adding the inline CSS to the layout in order to get the look to match the design you&#8217;ve made.  Inline styling offers the best and most widely compatible method to add styling to the newsletter.  If you&#8217;re comfortable with hand-coding the styles, this is the best way &#8211; but of course you can always use a visual editor&#8230;just keep an eye on the way the styling is added to the document &#8211; some editors (such as Dreamweaver) may define styles in a stylesheet format which won&#8217;t work for the newsletter.</p>
<p>The styles must be applied to each and every element that needs to be altered from the default.  You can of course apply a global style to the whole container (the main table definition) to set a standard font size/colour/style to start you off:</p>
<pre class="brush:html">
&lt;table width='600px' border='1' cellspacing='0' cellpadding='5' align='center' style='font-family: Georgia, 'Times New Roman', Serif; color: #222222; font-size: 13px>
</pre>
<p>This will give you your text style for any text that does not have it&#8217;s own definition.  Much of the styling information will be applied to things like headers and links:</p>
<pre class="brush:html">
&lt;h2 style="font-size:18px; font-weight:bold; color:#FF3300">Here's My Title&lt;/h3>
&lt;p>Check out the following link:&lt;/p>
&lt;a href="http://www.mylink.com" style="color:#3F84BA; text-decoration:underline">My Link&lt;/a>
</pre>
<p>It is necessary to add all styling information in this way.  You should also refrain from using shorthand CSS as some email clients will ignore this method of styling, such as:</p>
<pre class="brush:html">
&lt;p style="font: bold 14px/120% Arial,Sans-Serif">This is my paragraph.&lt;/p>
</pre>
<h3>Viewing the Newsletter in Other Formats</h3>
<p>If your mass-mail system supports a plain-text version of the newsletter, you should take the time to create this alongside your HTML version so that users who cannot view mail in HTML format can still read the email.</p>
<p>If this is not practical or possible, provide a link to the HTML document on your server at the top of the email, this way readers who cannot properly view the newsletter will at least have the option to view the newsletter in their browser, which has a good chance of being rendered as you intended it.</p>
<a href="http://www.wickwarbrewing.co.uk/eflyer/december09e60a95f3f443e37f5a47210d9b340a05.html" target="_blank"><img src="http://toolboxdigital.com/wp-content/uploads/2010/01/newsletter-example.jpg" alt="newsletter-example" title="newsletter-example" width="774" height="619" class="alignnone size-full wp-image-441" /></a>
<span class="caption">The finished example (click to view the actual document in your browser)</span>]]></content:encoded>
			<wfw:commentRss>http://toolboxdigital.com/2010/01/anatomy-of-a-newsletter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
