Innovating Tomorrow - How To&#039;s http://www.innovatingtomorrow.net/taxonomy/term/3/0 en Drupal 6 Development Can Be A Caching Pain http://www.innovatingtomorrow.net/blog/2008/07/drupal-6-development-can-be-a-caching-pain <p><img src="/sites/innovatingtomorrow.net/files/u2/druplicon_small.png" width="175" height="200" alt="druplicon_small.png" alt="drupal logo" class="float-left" align="left" style="margin: 0 10px 10px 0;"/><a href="http://drupal.org" title="drupal">Drupal</a> provides some great <a href="http://en.wikipedia.org/wiki/Cache" title="Caching">caching</a> tools to improve page loading performance. Production sites see huge speed increases because of caching. But, when a site is being developed caching can quickly turn into a nightmare. For example, when you add a new theme override function your to template.php file it isn't picked up right away and you may end up banging your head wondering what's going on. Or, when your developing filter code your filtered content may be cached. Going to the performance setting page and clearing the cache is annoying and a work flow problem. So, let's look at a couple simple solutions that can make development a little easier and less painful.<!--break--></p> <h3>Cache Disable Module</h3> <p>Drupal wiz kid <a href="http://drupal.org/user/47566" title="dmitrig01">Dmitri Gaskin</a> created the <a href="http://drupal.org/project/cache_disable" title="Cache Disable Module">Cache Disable module</a> which does just as it's name suggests. While some solutions clear the cache on every page load this module disables it. During development this is a great tool to use.</p> <h3>Clearing The Cache In Your Code</h3> <p>If you just want to clear part of the cache during development you can use some code snippets to do just that. For example, if you are developing a theme and just don't want the theme information to stay in the cache you could call <a href="http://api.drupal.org/api/function/drupal_rebuild_theme_registry/6" title="drupal_rebuild_theme_registry()">drupal_rebuild_theme_registry()</a> in your theme to rebuild the theme cache on every page load. A simple way to do this would be to add the following code snippet to the bottom of your page.tpl.php file.<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; drupal_rebuild_theme_registry</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div> </p> <p>Other cache clearing functions you can use are <a href="http://api.drupal.org/api/function/cache_clear_all/6" title="cache_clear_all()">cache_clear_all()</a>, <a href="http://api.drupal.org/api/function/menu_rebuild/6" title="menu_rebuild()">menu_rebuild()</a>, and <a href="http://api.drupal.org/api/function/drupal_flush_all_caches/6" title="drupal_flush_all_caches()">drupal_flush_all_caches()</a>, which clears all possible caches including those that contributed modules use with the caching system.</p> <p>Once the sites are ready for production these functions or modules we added should be removed so we can get all the caching benefits.</p> http://www.innovatingtomorrow.net/blog/2008/07/drupal-6-development-can-be-a-caching-pain#comments Cache Disable module caches caching Dmitri Gaskin drupal drupal-planet How To&#039;s performance snippet Software theme Wed, 30 Jul 2008 22:00:00 +0000 Matt Farina 146 at http://www.innovatingtomorrow.net Follow Project Issues with Yahoo Pipes http://www.innovatingtomorrow.net/blog/2008/07/follow-project-issues-with-yahoo-pipes <p><a href="http://drupal.org" title="drupal">Drupal</a> provides project owners with the ability to follow issues on their projects. Simply go to your <a href="http://drupal.org/project/user" title="My Projects">My Projects</a> page and you can see an overview of your projects and even grab a RSS feed of the latest issues. But, if you are just a project co-maintainer or a contributor who doesn't actually have access to a project there is no nice and easy place to follow the issues on that project. I used <a href="http://pipes.yahoo.com" title="Yahoo Pipes">Yahoo Pipes</a> to solve this problem because it outputs RSS, has quick add buttons for sites like My Yahoo and Netvibes, can be added to a page as a badge, and it provides JSON and PHP access.<!--break--></p> <p><img src="/sites/innovatingtomorrow.net/files/u2/drupal-pipes.png" width="323" height="397" alt="drupal-pipes.png" title="drupal in Yahoo Pipes"/></p> <p>The image above shows the simple pipe I created. I went to each of the issues pages, grabbed the RSS feed for that issue list, and inserted it to Feed Fetch. I followed that up by using sort to bring the newest issues to the top (you can sort this is any way you like). And, then I output that. I can now view this in a number of different ways and places.</p> <p>If you want to get fancy you only need to pull in one RSS feed. The variable called projects in the feed URL can be a comma separated list of project nodes.</p> http://www.innovatingtomorrow.net/blog/2008/07/follow-project-issues-with-yahoo-pipes#comments badge contributor different ways drupal drupal-planet google How To&#039;s Internet maintainer modules my yahoo netvibes project co RSS yahoo yahoo pipes Tue, 08 Jul 2008 10:00:00 +0000 Matt Farina 138 at http://www.innovatingtomorrow.net Evaluating Content Management Systems http://www.innovatingtomorrow.net/blog/2008/06/evaluating-content-management-systems <p><img src="/sites/innovatingtomorrow.net/files/u2/joomla-logo.jpg" width="150" height="103" alt="joomla-logo.jpg" title="Joomla" align="left" class="float-left" style="margin: 0 10px 10px 0;" />Content Management Systems are always being evaluated. Sometimes it's an organization looking for the next system to host their website. Sometimes it's someone writing a review about a system. And, still other times it's the competition taking a peak at the products they are up against. Let's take a look at some common areas we need to evaluate whether the system is open source or proprietary.<!--break--></p> <h3>The Developers</h3> <p>One of the first areas to look at is the developers behind a product. Are they engineering a system or throwing something together ad hoc? Are they knowledgeable about content management and social publishing? Are they good developers who attempt to use good <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)" title="Design Patterns on Wikipedia">design patterns</a> and practices?</p> <p>In not talking about the developers who use a CMS to create a website. That's something separate unless you have the same people doing both which happens with some proprietary systems.</p> <h3>Support</h3> <p>No quality support options can be a deal breaker for many. Many companies in the enterprise world have policies that stop software purchase where no support contracts are available unless someone with leverage gets this overridden. This same thing happens within many churches, ministries, and other non-profits.</p> <p>What are the support options available for a product? Sometimes this will be a regular monthly fee for ongoing support and other times you can get it on a case by case basis.</p> <p>Do the support options fit your needs and environment?</p> <h3>Usability</h3> <p>The more web based tools I try the more I find usability is not an up front factor where it should be. When we think about the people using a CMS we need to think about the lower common denominators. That is, the people who aren't super tech savvy. Think of a church secretary or someone in the age bracket over 55 (where they spent most of their life without a computer). Think of people who aren't using technology everyday and aren't going to learn loads of new terms and concepts. How intuitive is a CMS for them to use?</p> <h3>Innovation</h3> <p>The Internet, the way we use it, and the way we connect with others is changing at a fairly high rate. Technology is giving us the ability to redefine our processes as things become simpler and more widely distributed. At the same time, web based technologies are becoming more integrated with each other and our lives. How is a CMS moving with this trend? How is a CMS at adopting new processes and technologies to help your organization do what it does better?</p> <h3>Features</h3> <p>This one seems simple and it usually is. Does the CMS have the features to implement the things you need it to do? This means that you need to know what to look for before you dive into picking a CMS. It's the requirements of a product before you pick a solution mentality rather than picking a solution and using what it has mentality.</p> <p>Over the next few weeks I'll be blogging about each of these areas and what they mean in more detail.</p> http://www.innovatingtomorrow.net/blog/2008/06/evaluating-content-management-systems#comments age bracket case basis church secretary churches ministries CMS common denominators design patterns How To&#039;s Internet leverage ongoing support proprietary systems quality support Software software purchase stop software support options tech savvy usability using technology Wed, 25 Jun 2008 10:00:00 +0000 Matt Farina 135 at http://www.innovatingtomorrow.net How To Measure Church Effectiveness http://www.innovatingtomorrow.net/2008/05/21/how-to-measure-church-effectiveness <p><img src="/sites/innovatingtomorrow.net/files/u2/flot-small.png" width="250" height="123" alt="flot-small.png" title="graph" class="float-right" align="right" style="0 0 10px 10px;" />When I first started looking into church statistics and measurements I found measurements like the the number of members at a church, the number of weekend attenders, and income for a church on any given week. These numbers give a little detail about the church but they don't provide much insight into how church is doing towards meeting it's goals. They provide some numbers that allow a church to be compared to other churches but they don't provide much detail about an individual church. Let's look at some measurements that can be taken in a church providing insight into how a church is doing at its, God given, mission.<!--break--></p> <h3>Growth</h3> <p>The bible tells us to go and make disciples of all nations in Matthew 28. This is a mission of growth and something measurements can tell us how we're doing. The mission is to make disciples, that is people going from not having faith and belief to disciples. This measurement doesn't directly relate to the number of new people who come to a church. It's independent of total church growth.</p> <p>Recent statistics released by a number of church bodies have said this number is about 3% of their growth. Measuring this has caused them to change their outreach model.</p> <h3>Teaching</h3> <p>Another part of the mission supplied to us in Matthew 28 is that we are to make disciples by teaching. This doesn't mean it has to be formal classroom teaching but there is some form of mentoring or teaching going on. This is something we can measure. If you have a class for people who don't know about church you can measure the attendance of the people who are genuinely new to the idea of church. Do you have a bible study? What is the attendance at that?</p> <p>Another part of this is people being prepared to teach others. It could be parents teaching their children, people leading a book club for Christian books, someone mentoring a friend in their spiritual journey, or someone teaching a formal class. Something to measure is how many people in your congregation have the resources to do that? How many people have the experience to be in one or more of these roles?</p> <h3>Money</h3> <p>Money seems to be a big deal in the church for a lot of people. Money is a personal issue for a lot of people. It's something people tend to want to keep for themselves and keep God out. Measurements here can be very effective. But, all measurements here need to be put in context. What is the income from a group compared to their demographics? Are they giving a tithe or not? This can provide some insight into the members of a church. Not from a money angle but a heart angle. It can show us if people are joyfully giving or not.</p> <h3>Bringing These Things Together</h3> <p>When we start to bring these different measurements together we can get a more well rounded picture of the spiritual model of a local church.</p> <p>For example, you may have a church full of people who give a tithe but they don't know much about the bible and they don't outreach. Or, you may have a church that is growing at a great rate but there are few, if any, new people becoming disciples.</p> <p>When we start mashing together these measurements in calculated ways we can start to get a model for our local church. We can start to see what's going on. This is an important step. As we drill down in identifying what's going wrong we can see where we need to work, as a church, to communally grow in our faiths.</p> http://www.innovatingtomorrow.net/2008/05/21/how-to-measure-church-effectiveness#comments attendance bible study christian books church bodies church statistics churches disciples formal classroom god having faith How To&#039;s insight measurement measurements mentoring Outreach parents spiritual journey Wed, 21 May 2008 10:00:00 +0000 Matt Farina 117 at http://www.innovatingtomorrow.net Rotating Banner Images with Views and jQuery http://www.innovatingtomorrow.net/2008/05/12/rotating-banner-images-with-views-and-jquery <p>Rotating banner images is a simple way to spice up most sites. It adds something shiny that can hook people in. If you use jQuery, like I often do, then a simple way to do the rotating banner images is using the <a href="http://www.malsup.com/jquery/cycle/" title="jQuery cycle">jQuery cycle</a> plugin. This plugin can even be used along with <a href="http://drupal.org" title="drupal">drupals</a> <a href="http://drupal.org/project/views" title="views module">views module</a> to create dynamic lists of rotating images. </p> <p>But, there are some downfalls with this approach. For example, if you create a list of images for the jQuery cycle plugin to rotate through you need to set all but one of them not to display with css. Even though most of the images are not initially displaying they are still downloaded in many browsers. If you have a bunch of images loading that have any size this has a potential to waste a lot of bandwidth if those images aren't viewed.</p> <p>This was a problem that I ran into working on a few sites. Here's a solution I use that solves this problem while working well with Views, jQuery, and any content Views can create.<!--break--></p> <p><em>Note: This explanation applies to drupal 5.</em></p> <h3>The Views</h3> <p>The first thing I do is create 2 views. One that contains only one image, to be used for the initial display, and a second that loads all of the images to rotate through. The view that loads only one image gets <a href="/2007/12/09/how-embed-view" title="How To: Embed A View">embedded into a template file</a>, like my page-front.tpl.php file.</p> <p>The second view I'll setup to return as an <a href="/2008/05/05/how-to-views-javascript" title="How To: Views to Javascript">array in JavaScript</a>. The return method to use in this example is "return drupal_to_js($items);", but that's not the only way that will work.</p> <p>In both cases I'll use template files that are called from custom theme functions that are called by template.php. The Views Theme Wizard modules, that comes with views, can help you create those functions. In the theme file for the single image I'll put in something like:<br /> <div class="codeblock"><code>&lt;div id=&quot;some-unique-id&quot;&gt;<br />&lt;!-- Insert my content here --&gt;<br />&lt;/div&gt;</code></div></p> <p>While the template file for the view containing the content to rotate through would look like:<br /> <div class="codeblock"><code>&lt;!-- Insert my content here --&gt;</code></div></p> <p>In both cases the "Insert my content here" should be the same.</p> <p><em>Note: If you are a theming ninja you can accomplish this with just one view and one template file.</em></p> <h3>The JavaScript</h3> <p>Here is a bit of JavaScript containing an example of an external file that does the heavy lifting. You'll notice that it contains a <a href="/2008/04/30/preloading-content-jquery" title="Preloading Content With jQuery">jQuery preloader</a> function that I've previously written about. The different parts of the javascript file are explained with comments.<br /> <div class="codeblock"><code>// Create the namespace for the functions to work out of.<br />Drupal.themename = {};<br /><br />// The function that gets called to do the replacement<br />Drupal.themename.replaceimage = function () {<br />&nbsp; <br />&nbsp; // Replace the content inside #some-unique-id<br />&nbsp; $(&#039;#some-unique-id&#039;).html(themename_rotating_images[themename_rotating_pointer]);;<br />&nbsp; <br />&nbsp; // Increase the pointer<br />&nbsp; themename_rotating_pointer++;<br /><br />&nbsp; // Reset the pointer and turn off image preloading.<br />&nbsp; // Note the number 10. This needs to be set the total number of items<br />&nbsp; // in your view minus 1. This can be stored in a setting and passed in.<br />&nbsp; if (themename_rotating_pointer == 10) {<br />&nbsp;&nbsp;&nbsp; themename_rotating_pointer = 0;<br />&nbsp;&nbsp;&nbsp; themename_rotating_switch = 0;<br />&nbsp; }<br />&nbsp; <br />&nbsp; // Preload the content item after the next one. I load 2 ahead to<br />&nbsp; // give the preloading more time for bigger files<br />&nbsp; if (themename_rotating_switch == 1) {<br />&nbsp;&nbsp;&nbsp; $.preloaddivs(themename_rotating_images[themename_rotating_pointer + 1]);<br />&nbsp; }<br />}<br /><br />// This is a content preloader function.<br />jQuery.preloaddivs = function(){<br />&nbsp; for(var i = 0; i&lt;arguments.length; i++)<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp; jQuery(&quot;&lt;div&gt;&quot;).html(arguments[i]);<br />&nbsp; }<br />}<br /><br />$(document).ready(function() {<br />&nbsp; // Preload the first 2 pieces of content.<br />&nbsp; jQuery.preloaddivs(themename_rotating_images[themename_rotating_pointer], themename_rotating_images[themename_rotating_pointer + 1]);<br />&nbsp; <br />&nbsp; // Setup the content replacer to run every 7 seconds. This number can<br />&nbsp; // be changed and even setup via a setting.<br />&nbsp; setInterval(&quot;Drupal.themename.replaceimage()&quot;, 7000);<br />});</code></div></p> <p>This is just a basic example of how to do this. On sites I build, like <a href="http://www.muddyrivermedia.org" title="Muddy River Media">MuddyRivermedia.org</a>, I've put in fade in and fade out effects. All of the hard set variables in this example can be passed in with settings and variables so they can be made entirely dynamic and this can be made to be more flexible. I've hard coded them for simplicity.</p> <h3>The Theme</h3> <p>The final step is to include all of this stuff into the theme so that it all comes together. The views theming functions should already be included in the template.php file so I won't include them here. Here are the other things to put in the template.php file:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">_phptemplate_variables</span><span style="color: #007700">(</span><span style="color: #0000BB">$hook</span><span style="color: #007700">, </span><span style="color: #0000BB">$variables </span><span style="color: #007700">= array()) {<br />&nbsp; <br />&nbsp; </span><span style="color: #FF8000">// Add out stuff to the page<br />&nbsp; </span><span style="color: #007700">if (</span><span style="color: #0000BB">$hook </span><span style="color: #007700">== </span><span style="color: #DD0000">'page'</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; </span><span style="color: #FF8000">// This logic will do our work on just the site homepage.<br />&nbsp;&nbsp;&nbsp; // This logic can be changed to occur on other pages<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #007700">if (</span><span style="color: #0000BB">request_uri</span><span style="color: #007700">() == </span><span style="color: #DD0000">'/' </span><span style="color: #007700">|| </span><span style="color: #0000BB">request_uri</span><span style="color: #007700">() == </span><span style="color: #DD0000">'/'</span><span style="color: #007700">. </span><span style="color: #0000BB">variable_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'site_frontpage'</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #FF8000">// Load the scripts.js file described above.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">drupal_add_js</span><span style="color: #007700">(</span><span style="color: #0000BB">path_to_theme</span><span style="color: #007700">() .</span><span style="color: #DD0000">'/scripts.js'</span><span style="color: #007700">, </span><span style="color: #DD0000">'theme'</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #FF8000">// Load the variable with the rotating images. Notice the<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // str_replace and substr functions used to remove the wrapper<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // divs placed in by views. Change the class names to the ones<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // from your view.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">drupal_add_js</span><span style="color: #007700">(</span><span style="color: #DD0000">'var themename_rotating_images = '</span><span style="color: #007700">. </span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">"&lt;div class='view view-my-example'&gt;&lt;div class='view-content view-content-my-example'&gt;"</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #0000BB">theme</span><span style="color: #007700">(</span><span style="color: #DD0000">'view'</span><span style="color: #007700">, </span><span style="color: #DD0000">'home_image_random'</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">, </span><span style="color: #DD0000">'block'</span><span style="color: #007700">)), </span><span style="color: #0000BB">0</span><span style="color: #007700">, -</span><span style="color: #0000BB">13</span><span style="color: #007700">) .</span><span style="color: #DD0000">';'</span><span style="color: #007700">, </span><span style="color: #DD0000">'inline'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">drupal_add_js</span><span style="color: #007700">(</span><span style="color: #DD0000">"var themename_rotating_pointer = 0;"</span><span style="color: #007700">, </span><span style="color: #DD0000">'inline'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">drupal_add_js</span><span style="color: #007700">(</span><span style="color: #DD0000">"var themename_rotating_switch = 1;"</span><span style="color: #007700">, </span><span style="color: #DD0000">'inline'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; </span><span style="color: #FF8000">// Rebuild the phptemplate page variable $scripts with new content<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$variables</span><span style="color: #007700">[</span><span style="color: #DD0000">'scripts'</span><span style="color: #007700">] = </span><span style="color: #0000BB">drupal_get_js</span><span style="color: #007700">();<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>This example shows the basic idea for using Views, image preloading, and jQuery to create a dynamic content rotation on a site with drupal.</p> <p>There is a bit of room for optimization and quite a bit of flexibility and eye candy (like fading and other animations) that can be built in and on top of what is included here.</p> http://www.innovatingtomorrow.net/2008/05/12/rotating-banner-images-with-views-and-jquery#comments array in javascript bandwidth How To&#039;s Internet jquery ninja Software template files theming tpl wizard Mon, 12 May 2008 09:00:00 +0000 Matt Farina 110 at http://www.innovatingtomorrow.net How To: Views to Javascript http://www.innovatingtomorrow.net/2008/05/05/how-to-views-javascript <p>The views module for <a href="http://drupal.org" title="drupal">drupal</a> provides a powerful way to create queries of content and then present it in a number of different ways. One of the ways I've seen seldom used is views generating lists and variables for javascript and <a href="http://www.jquery.com" title="jQuery">jQuery</a>. Let's take a look at how we can accomplish this fairly easily.<!--break--></p> <p>At the heart of making this happens is theme override functions and <a href="http://api.drupal.org/api/function/drupal_to_js/5" title="drupal_to_js">drupal_to_js</a>, a function that converts php variables into javascript variables.</p> <p>To find your views theme override function you can install the Views Theme Wizard module that comes with views. Using the views theme wizard you should be able to get a function like:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">phptemplate_views_view_list_My_Example</span><span style="color: #007700">(</span><span style="color: #0000BB">$view</span><span style="color: #007700">, </span><span style="color: #0000BB">$nodes</span><span style="color: #007700">, </span><span style="color: #0000BB">$type</span><span style="color: #007700">) {<br />&nbsp; </span><span style="color: #0000BB">$fields </span><span style="color: #007700">= </span><span style="color: #0000BB">_views_get_fields</span><span style="color: #007700">();<br /><br />&nbsp; </span><span style="color: #0000BB">$taken </span><span style="color: #007700">= array();<br /><br />&nbsp; </span><span style="color: #FF8000">// Set up the fields in nicely named chunks.<br />&nbsp; </span><span style="color: #007700">foreach (</span><span style="color: #0000BB">$view</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">field </span><span style="color: #007700">as </span><span style="color: #0000BB">$id </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$field</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$field_name </span><span style="color: #007700">= </span><span style="color: #0000BB">$field</span><span style="color: #007700">[</span><span style="color: #DD0000">'field'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp; if (isset(</span><span style="color: #0000BB">$taken</span><span style="color: #007700">[</span><span style="color: #0000BB">$field_name</span><span style="color: #007700">])) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$field_name </span><span style="color: #007700">= </span><span style="color: #0000BB">$field</span><span style="color: #007700">[</span><span style="color: #DD0000">'queryname'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$taken</span><span style="color: #007700">[</span><span style="color: #0000BB">$field_name</span><span style="color: #007700">] = </span><span style="color: #0000BB">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$field_names</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">] = </span><span style="color: #0000BB">$field_name</span><span style="color: #007700">;<br />&nbsp; }<br /><br />&nbsp; </span><span style="color: #FF8000">// Set up some variables that won't change.<br />&nbsp; </span><span style="color: #0000BB">$base_vars </span><span style="color: #007700">= array(<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #DD0000">'view' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$view</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #DD0000">'view_type' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$type</span><span style="color: #007700">,<br />&nbsp; );<br /><br />&nbsp; foreach (</span><span style="color: #0000BB">$nodes </span><span style="color: #007700">as </span><span style="color: #0000BB">$i </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$node</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars </span><span style="color: #007700">= </span><span style="color: #0000BB">$base_vars</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'node'</span><span style="color: #007700">] = </span><span style="color: #0000BB">$node</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'count'</span><span style="color: #007700">] = </span><span style="color: #0000BB">$i</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'stripe'</span><span style="color: #007700">] = </span><span style="color: #0000BB">$i </span><span style="color: #007700">% </span><span style="color: #0000BB">2 </span><span style="color: #007700">? </span><span style="color: #DD0000">'even' </span><span style="color: #007700">: </span><span style="color: #DD0000">'odd'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; foreach (</span><span style="color: #0000BB">$view</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">field </span><span style="color: #007700">as </span><span style="color: #0000BB">$id </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$field</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$name </span><span style="color: #007700">= </span><span style="color: #0000BB">$field_names</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #0000BB">$name</span><span style="color: #007700">] = </span><span style="color: #0000BB">views_theme_field</span><span style="color: #007700">(</span><span style="color: #DD0000">'views_handle_field'</span><span style="color: #007700">, </span><span style="color: #0000BB">$field</span><span style="color: #007700">[</span><span style="color: #DD0000">'queryname'</span><span style="color: #007700">], </span><span style="color: #0000BB">$fields</span><span style="color: #007700">, </span><span style="color: #0000BB">$field</span><span style="color: #007700">, </span><span style="color: #0000BB">$node</span><span style="color: #007700">, </span><span style="color: #0000BB">$view</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isset(</span><span style="color: #0000BB">$field</span><span style="color: #007700">[</span><span style="color: #DD0000">'label'</span><span style="color: #007700">])) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #0000BB">$name </span><span style="color: #007700">. </span><span style="color: #DD0000">'_label'</span><span style="color: #007700">] = </span><span style="color: #0000BB">$field</span><span style="color: #007700">[</span><span style="color: #DD0000">'label'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$items</span><span style="color: #007700">[] = </span><span style="color: #0000BB">_phptemplate_callback</span><span style="color: #007700">(</span><span style="color: #DD0000">'views-list-My_Example'</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars</span><span style="color: #007700">);<br />&nbsp; }<br />&nbsp; if (</span><span style="color: #0000BB">$items</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; return </span><span style="color: #0000BB">theme</span><span style="color: #007700">(</span><span style="color: #DD0000">'item_list'</span><span style="color: #007700">, </span><span style="color: #0000BB">$items</span><span style="color: #007700">);<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>This function goes in your template.php file, as the wizard will tell you, and is the place where we start.</p> <p>There are a few things we can change here to manipulate our information for javascript. The first is the line:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; $items</span><span style="color: #007700">[] = </span><span style="color: #0000BB">_phptemplate_callback</span><span style="color: #007700">(</span><span style="color: #DD0000">'views-list-My_Example'</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>This line is taking each node found by views with the accompanying fields, as selected in the view, and passing it to a template file to style the content. In this case the fields on the view are passed to the file views-list-My_Example.tpl.php in your themes folder where you can style it.</p> <p>You can keep this line the way it is and style the content to pass to your javascript, as I did for the image rotator on <a href="http://www.MuddyRiverMedia.org" title="MuddyRiverMedia.org">MuddyRiverMedia.org</a>, or you can turn the fields into variables in an array to pass to javascript. To turn them into variables to pass to the javascript as an array change the line to read:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; $items</span><span style="color: #007700">[] = </span><span style="color: #0000BB">$vars</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>The next part of the equation is to supply the view to javascript in a way the javascript can use it. To do this we alter the line:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; </span><span style="color: #007700">return </span><span style="color: #0000BB">theme</span><span style="color: #007700">(</span><span style="color: #DD0000">'item_list'</span><span style="color: #007700">, </span><span style="color: #0000BB">$items</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>There are 2 ways to do this. The first is to create a javascript variable in our theme and the second is to pass it in as a drupal setting for javascript. To create a javascript variable change the line above to:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; </span><span style="color: #007700">return </span><span style="color: #0000BB">drupal_to_js</span><span style="color: #007700">(</span><span style="color: #0000BB">$items</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>Then, in the javascript part of your theme you can do something like this:<br /> <div class="codeblock"><code>var myvarname = <span style="color: #000000"><span style="color: #0000BB">&lt;?php </span><span style="color: #007700">print </span><span style="color: #0000BB">theme</span><span style="color: #007700">(</span><span style="color: #DD0000">'views'</span><span style="color: #007700">, </span><span style="color: #DD0000">'My_Example'</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #DD0000">'embed'</span><span style="color: #007700">); </span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p><em>Note: This has to be a file generated by PHP and can't be an external javascript file</em></p> <p>Another way to add this views generated information is to pass it in as a drupal setting for your javascript. To do this change:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; </span><span style="color: #007700">return </span><span style="color: #0000BB">theme</span><span style="color: #007700">(</span><span style="color: #DD0000">'item_list'</span><span style="color: #007700">, </span><span style="color: #0000BB">$items</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>To:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; </span><span style="color: #007700">return </span><span style="color: #0000BB">$items</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>Then, in your theme or a module use something like:<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp; drupal_add_js</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'myvarname' </span><span style="color: #007700">= &gt; </span><span style="color: #0000BB">theme</span><span style="color: #007700">(</span><span style="color: #DD0000">'views'</span><span style="color: #007700">, </span><span style="color: #DD0000">'My_Example'</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #DD0000">'embed'</span><span style="color: #007700">)), </span><span style="color: #DD0000">'setting'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>In your javascript this variable would then be accessible at Drupal.settings.myvarname. You'll notice that we didn't use drupal_to_js in this case. That's because drupal does this for us when we use a setting in drupal_add_js.</p> <p>Views can be a very useful way to pass information to javascript to make our sites even more useful and fun.</p> http://www.innovatingtomorrow.net/2008/05/05/how-to-views-javascript#comments array chunks different ways drupal drupal-planet field names fir heart How To&#039;s override queries true field wizard Mon, 05 May 2008 10:00:00 +0000 Matt Farina 108 at http://www.innovatingtomorrow.net How To: Clear Floats in CSS http://www.innovatingtomorrow.net/2008/03/24/how-clear-floats-css <p>Have you ever had the situation where you tried to clear a floating element in your web design only to have something not line up right? Maybe the box model in your design didn't line up right. Maybe a column was too long and ran over something it shouldn't. You look at your CSS and see <em>clear: both;</em> in the right place and can't find the problem. There are better ways to clear floats. They deal with cross browser issues and do so without adding extra elements to a page.</p> <p>A common way to fix the float problem is to stick <em><code>&lt;br style=&quot;clear:both&quot;/&gt;</code></em> after your floated items to clear the float. This works and it keeps columns aligned. But, it adds extra elements to the page and you may have spacing issues from this tag.</p> <p>Instead of doing this I'd suggest two different methods.</p> <h3>Position Everything Method</h3> <p>Over at <a href="http://www.positioniseverything.net/easyclearing.html" title="How To Clear Floats Without Structural Markup">position everything</a> there is an article on how to clear floats without adding any structured markup to a page. To do this you first add the following to your css:<br /> <div class="codeblock"><code>.clear-block:after {<br />&nbsp; content: &quot;.&quot;;<br />&nbsp; display: block;<br />&nbsp; height: 0;<br />&nbsp; clear: both;<br />&nbsp; visibility: hidden;<br />}<br /><br />.clear-block {<br />&nbsp; display: inline-block;<br />}<br /><br />/* Hides from IE-mac \*/<br />* html .clear-block {<br />&nbsp; height: 1%;<br />}<br />.clear-block {<br />&nbsp; display: block;<br />}<br />/* End hide from IE-mac */</code></div></p> <p>Then, in your page have something like the following:<br /> <div class="codeblock"><code>&lt;div id=&quot;wrapper&quot; class=&quot;clear-block&quot;&gt;<br />&nbsp; &lt;div style=&quot;float:right&quot;&gt;<br />&nbsp;&nbsp;&nbsp; // Your content here<br />&nbsp; &lt;/div&gt;<br />&nbsp; &lt;div style=&quot;float:left&quot;&gt;<br />&nbsp;&nbsp;&nbsp; // More content here<br />&nbsp; &lt;/div&gt;<br />&lt;/div&gt;</code></div></p> <p>This is the method built into <a href="http://drupal.org" title="drupal">drupal</a> and one that works well. It takes advantage of the rarely used :after method in css. It, also, works in all the major browsers including the now dead IE for Mac.</p> <h3>Paul O’Brien Method</h3> <p><a href="http://pmob.co.uk/" title="raw CSS examples">Paul O'Brien</a> suggested adding <em>overflow:auto</em> to the outer div.</p> <p>An example of this would look like:<br /> <div class="codeblock"><code>&lt;div id=&quot;outer&quot; style=&quot;overflow: auto;&quot;&gt;<br />&nbsp; &lt;div style=&quot;float:right&quot;&gt;<br />&nbsp;&nbsp;&nbsp; // Your content here<br />&nbsp; &lt;/div&gt;<br />&nbsp; &lt;div style=&quot;float:left&quot;&gt;<br />&nbsp;&nbsp;&nbsp; // More content here<br />&nbsp; &lt;/div&gt;<br />&lt;/div&gt;<br />&lt;div id=&quot;footer&quot; style=&quot;clear:both;&quot;&gt;<br />&nbsp; // Some footer content<br />&lt;/div&gt;</code></div></p> <p>Adding <em>overflow:auto</em> seems to be a gentle enough reminder to browsers that the content in them is in them and to enclose the whole thing in them.</p> <p>While, I used the CSS in style tags here I'd suggest putting all the CSS in style sheets in a production site. Happy Positioning.</p> http://www.innovatingtomorrow.net/2008/03/24/how-clear-floats-css#comments box model div drupal element elements footer How To&#039;s Internet markup overflow reminder t line visibility web design Mon, 24 Mar 2008 10:00:00 +0000 Matt Farina 86 at http://www.innovatingtomorrow.net Rename Tabs In Drupal 5 http://www.innovatingtomorrow.net/2008/02/21/rename-tabs-drupal-5 <p>Renaming tabs in <a href="http://drupal.org" title="drupal">drupal</a> 6 is easy thanks to <a href="http://api.drupal.org/api/function/hook_menu_alter/6" title="hook_menu_alter">hook_menu_alter</a>. In drupal 5 it's not so easy and there is no place to rename them outside of the theme system. So, let's take a look at how to rename tabs in the theme system. This method is similar to the method I outlined for <a href="/2008/02/18/removing-and-altering-tab-names-drupal-5" title="Removing Tab Names In Drupal 5">removing tabs via the theme system</a>.<!--break--></p> <p>First, put the following function in your template.php file.<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**<br /> * Function renames tabs in drupal<br /> *<br /> * @param&nbsp; $label_old<br /> * Name of old label to replace<br /> * <br /> * @param&nbsp; $label_new<br /> * Name of new label to replace with<br /> * <br /> * @param&nbsp; $vars<br /> * $vars from _phptemplate_variables<br /> * <br /> */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">phptemplate_change_tab_label</span><span style="color: #007700">(</span><span style="color: #0000BB">$label_old</span><span style="color: #007700">, </span><span style="color: #0000BB">$label_new</span><span style="color: #007700">, &amp;</span><span style="color: #0000BB">$vars</span><span style="color: #007700">) {<br />&nbsp; </span><span style="color: #0000BB">$tabs </span><span style="color: #007700">= </span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">]);<br />&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">] = </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br /><br />&nbsp; foreach(</span><span style="color: #0000BB">$tabs </span><span style="color: #007700">as </span><span style="color: #0000BB">$tab</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; if(</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$tab</span><span style="color: #007700">, </span><span style="color: #DD0000">'&gt;'</span><span style="color: #007700">. </span><span style="color: #0000BB">$label_old </span><span style="color: #007700">.</span><span style="color: #DD0000">'&lt;'</span><span style="color: #007700">) === </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">] .= </span><span style="color: #0000BB">$tab </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">] .= </span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'&gt;'</span><span style="color: #007700">. </span><span style="color: #0000BB">$label_old </span><span style="color: #007700">.</span><span style="color: #DD0000">'&lt;'</span><span style="color: #007700">, </span><span style="color: #DD0000">'&gt;'</span><span style="color: #007700">. </span><span style="color: #0000BB">$label_new </span><span style="color: #007700">.</span><span style="color: #DD0000">'&lt;'</span><span style="color: #007700">, </span><span style="color: #0000BB">$tab</span><span style="color: #007700">) .<br /></span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>Then, in the function _phptemplate_variables in your template.php put something like:</p> <p><div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">_phptemplate_variables</span><span style="color: #007700">(</span><span style="color: #0000BB">$hook</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars </span><span style="color: #007700">= array()) {<br />&nbsp; if (</span><span style="color: #0000BB">$hook </span><span style="color: #007700">== </span><span style="color: #DD0000">'page'</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; if (</span><span style="color: #0000BB">arg</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">) == </span><span style="color: #DD0000">'user' </span><span style="color: #007700">&amp;&amp; </span><span style="color: #0000BB">is_numeric</span><span style="color: #007700">(</span><span style="color: #0000BB">arg</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">))) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">phptemplate_change_tab_label</span><span style="color: #007700">(</span><span style="color: #DD0000">'Edit'</span><span style="color: #007700">, </span><span style="color: #DD0000">'Edit account settings'</span><span style="color: #007700">, &amp;</span><span style="color: #0000BB">$vars</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>In this example we change the 'Edit' tab to read 'Edit account settings' and we do this only on user pages. This allows us to customize the interface and make our drupal site more usable.</p> http://www.innovatingtomorrow.net/2008/02/21/rename-tabs-drupal-5#comments array drupal-planet How To&#039;s interface Internet new label Software theme system variables Thu, 21 Feb 2008 11:00:00 +0000 Matt Farina 71 at http://www.innovatingtomorrow.net Removing and Altering Tab Names In Drupal 5 http://www.innovatingtomorrow.net/2008/02/18/removing-and-altering-tab-names-drupal-5 <p>Altering menu items in drupal 6 is fairly easy thanks to <a href="http://api.drupal.org/api/function/hook_menu_alter/6" title="hook_menu_alter">hook_menu_alter</a>. But, in drupal 5 it's not so easy. While we can't achieve all the power of hook_menu_alter we can remove tabs, among other things. Let's take a look at how to do this.<!--break--></p> <p>To remove tabs put the following function in your template.php file.<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**<br /> * Remove a tab<br /> *<br /> * @param&nbsp; $label<br /> * The label to remove<br /> * <br /> * @param&nbsp; $vars<br /> * $vars from _phptemplate_variables<br /> */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">phptemplate_remove_tab</span><span style="color: #007700">(</span><span style="color: #0000BB">$label</span><span style="color: #007700">, &amp;</span><span style="color: #0000BB">$vars</span><span style="color: #007700">) {<br />&nbsp; </span><span style="color: #0000BB">$tabs </span><span style="color: #007700">= </span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">]);<br />&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">] = </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br /><br />&nbsp; foreach(</span><span style="color: #0000BB">$tabs </span><span style="color: #007700">as </span><span style="color: #0000BB">$tab</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; if(</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$tab</span><span style="color: #007700">, </span><span style="color: #DD0000">'&gt;'</span><span style="color: #007700">. </span><span style="color: #0000BB">$label </span><span style="color: #007700">.</span><span style="color: #DD0000">'&lt;'</span><span style="color: #007700">) === </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$vars</span><span style="color: #007700">[</span><span style="color: #DD0000">'tabs'</span><span style="color: #007700">] .= </span><span style="color: #0000BB">$tab </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div></p> <p>Then, in the function _phptemplate_variables use this new function like the following example.<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">_phptemplate_variables</span><span style="color: #007700">(</span><span style="color: #0000BB">$hook</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars </span><span style="color: #007700">= array()) {<br />&nbsp; if (</span><span style="color: #0000BB">$hook </span><span style="color: #007700">== </span><span style="color: #DD0000">'page'</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">phptemplate_remove_tab</span><span style="color: #007700">(</span><span style="color: #DD0000">'View'</span><span style="color: #007700">, &amp;</span><span style="color: #0000BB">$vars</span><span style="color: #007700">);<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div><br /> This would remove all tabs with the name View. If we wanted to get more complicated we can use some arguments. This example only removes the View tab on user pages.<br /> <div class="codeblock"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">_phptemplate_variables</span><span style="color: #007700">(</span><span style="color: #0000BB">$hook</span><span style="color: #007700">, </span><span style="color: #0000BB">$vars </span><span style="color: #007700">= array()) {<br />&nbsp; if (</span><span style="color: #0000BB">$hook </span><span style="color: #007700">== </span><span style="color: #DD0000">'page'</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp; if (</span><span style="color: #0000BB">arg</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">) == </span><span style="color: #DD0000">'user' </span><span style="color: #007700">&amp;&amp; </span><span style="color: #0000BB">is_numeric</span><span style="color: #007700">(</span><span style="color: #0000BB">arg</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">)) &amp;&amp; </span><span style="color: #0000BB">arg</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">) == </span><span style="color: #DD0000">''</span><span style="color: #007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">phptemplate_remove_tab</span><span style="color: #007700">(</span><span style="color: #DD0000">'View'</span><span style="color: #007700">, &amp;</span><span style="color: #0000BB">$vars</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp; }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div><br /> This is just one of the menu related alterations we can do from the template.php file. But, it is one I put to good use regularly.</p> http://www.innovatingtomorrow.net/2008/02/18/removing-and-altering-tab-names-drupal-5#comments array drupal-planet hook_menu_alter How To&#039;s Internet phptemplate Software tabs variables Mon, 18 Feb 2008 11:00:00 +0000 Matt Farina 67 at http://www.innovatingtomorrow.net 5 Tips To Become A Better Podcaster http://www.innovatingtomorrow.net/2008/02/05/5-tips-become-better-podcaster <p><img src="/sites/innovatingtomorrow.net/files/u2/podcast-icon.jpg" width="169" height="169" alt="podcast icon" title="podcast icon" align="right" class="float-right" style="margin: 0 0 10px 10px" /><strong>Every podcaster has room for improvement.</strong> Whether that podcaster is someone who has just started their first podcast or someone who is a seasoned veteran, there is always room to improve. When <a href="http://www.bobchristenson.com" title="Bob Christenson">Bob</a> and I first started podcasting with the <a href="http://geeksandgod.com" title="Geeks and God Podcast">Geeks and God podcast</a> we were not nearly as good as we are today (though there is still much room to improve). We've worked to improve, not only the technology behind the show, but how we present ourselves as podcasters. Here are a few of the methods I've learned to help me improve at being a podcaster.<!--break--></p> <h3>Pay Attention To Other Podcasters</h3> <p>Find a few podcasters you like to listen to and start paying attention to them. By paying attention I mean, listen to how they talk, their attitude, what they talk about, their intensity, and see if you can figure out their facial expression by the tone in their voice. Can you tell when they are smiling?</p> <p>Then, try to add some of those qualities you like in when you speak. Start slow with just one. Add it in to an everyday conversation first to take it for a test drive. This will make it more natural when you try to have that characteristic on the podcast.</p> <p>Think of this like an actor might. Actors work on their performances. They learn how to speak for the part and how to carry themselves for the part. And, they practice this first. Podcasters are trying to deliver a message and, while they are not playing a role, presentation matters.</p> <h3>Listen To Your Own Podcast</h3> <p>For me, this is one of the most difficult tasks to do. I can understand why some actors won't watch something they were in. But, to improve at podcasting you need to listen to yourself. Ask yourself if there is something you don't like about your delivery. Are you someone you would want to listen to? If not, why not.</p> <h3>Get Some Feedback</h3> <p>Find someone who can be truly honest with you and get feedback from them. Ask for specifics. If you can find someone who is a good speaker this would be better because they should know what works.</p> <p>I think of this like a golf coach. Someone who can look at your game and see what's stopping you from having that sweet swing.</p> <h3>Don't Talk About Yourself</h3> <p>Unless the podcast is about your life, don't talk about yourself very much on the podcast. People want to hear about the topic, not your life.</p> <p>I bring this up because I think it's a trap a lot of podcasters fall into. Talking about your life is an easy fall back when you aren't sure what to say or when you get nervous. It something you know. Fight the urge.</p> <h3>Learn To Be Comfortable</h3> <p>This tip is more for someone who has just started podcasting. When I first got behind a microphone I was nervous. Putting something out on the Internet that had my thoughts and voice on it made me nervous. I expect this out of new podcasters. Learning to be comfortable is one of the best things you can learn to do. People can hear discomfort. Discomfort makes you more critical in a bad way. Discomfort distracts from your train of thought and ability to do a good show.</p> <p>Work to get comfortable.</p> <p>These are just a handful of things that can bring about a dramatic difference in a podcast. The technology only gets a podcast so far. It's the podcaster that makes or breaks a podcast.</p> http://www.innovatingtomorrow.net/2008/02/05/5-tips-become-better-podcaster#comments actors attitude everyday conversation geeks god How To&#039;s intensity Internet pay attention paying attention podcast podcaster specifics test drive Theory Thu, 07 Feb 2008 11:00:00 +0000 Matt Farina 58 at http://www.innovatingtomorrow.net