<?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>Monday By Noon &#187; Pages</title>
	<atom:link href="http://mondaybynoon.com/tag/pages/feed/" rel="self" type="application/rss+xml" />
	<link>http://mondaybynoon.com</link>
	<description>A resource for Web designers and developers to read about and discuss their craft.</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>&#8226; Using Input Helpers in Pods CMS for WordPress</title>
		<link>http://mondaybynoon.com/feeder/?FeederAction=clicked&#038;feed=Posts+%28RSS2%29&#038;seed=http%3A%2F%2Fmondaybynoon.com%2F20100322%2Finput-helpers-pods-cms-wordpress%2F&#038;seed_title=%26%238226%3B+Using+Input+Helpers+in+Pods+CMS+for+WordPress</link>
		<comments>http://mondaybynoon.com/20100322/input-helpers-pods-cms-wordpress/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 13:36:40 +0000</pubDate>
		<dc:creator>Jonathan Christopher</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Workbench]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Input Helper]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[Pods]]></category>

		<guid isPermaLink="false">http://mondaybynoon.com/?p=1000</guid>
		<description><![CDATA[Input Helpers in Pods CMS for WordPress allow you to work with and manipulate the data available to your clients on a per-input-field basis. In this walkthrough we'll discuss limiting the WordPress Pages available in a Pick column as a method of applying a custom background image to the selected pages.<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1000&c=524561676' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1000&c=524561676' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></description>
			<content:encoded><![CDATA[<p>Pods CMS really aims to be a framework in the sense that you can do <strong>anything you want</strong> with it. The approach of the developers always seems to keep that in mind, which is sometimes the most difficult thing to do when writing software.</p>
<p>I&#8217;d like to review <a href="http://podscms.org/codex/input_helpers">Input Helpers</a> a bit. Out of the box, Pods offers a number of <a href="http://podscms.org/codex/column_types">column types</a> including date field, number, boolean, paragraph text, and more. We also can&#8217;t forget about one of the more unique column types offered; <a href="/2010/01/11/how-to-use-pick-columns-relationships-in-pods/">Pick columns</a>.</p>
<h2>Applying Input Helpers to Pick columns</h2>
<p>On a recent project (like many projects) I found myself using a Pick column set to <code>WP Page</code> that automagically pulls a list of all WordPress Pages when the Pod entry form is displayed.</p>
<p><a href="/wp-content/uploads/2010/03/01-pages-1.jpg"><img class="alignnone size-full wp-image-1012" title="01-pages-1" src="/wp-content/uploads/2010/03/01-pages-1.jpg" alt="Setting up a WP Page Pick column in Pods" width="327" height="406" /></a></p>
<p>The goal with this Pod was to allow the client to dynamically define a background image for their website on a per-page basis. Out of the box, the solution worked as expected:</p>
<p><a href="/wp-content/uploads/2010/03/02-stock-pod.jpg"><img class="alignnone size-full wp-image-1002" title="02-stock-pod" src="/wp-content/uploads/2010/03/02-stock-pod.jpg" alt="The default output of a Pick column in Pods CMS" /></a></p>
<p>There was a problem though. I didn&#8217;t want the client to have full control over each and every page of the site. There were a number of pages on which it wouldn&#8217;t make sense to have a custom background. This is one of the many cases where <a href="http://podscms.org/codex/input_helpers">Input Helpers</a> come to the rescue.</p>
<h3>The basics of Input Helpers</h3>
<p>Input Helpers were designed to do one thing:</p>
<blockquote cite="http://podscms.org/codex/input_helpers"><p>An Input Helper lets you completely customize the appearance of any input field.</p>
</blockquote>
<p>What this means is we&#8217;re given the opportunity to both <em>hook</em> and <strong><em>manipulate</em></strong> the data pulled to an input field before it is displayed on screen. Input Helpers are applied on a <strong>per-column basis</strong> (as opposed to a Pod as a whole). The possibilities here are literally endless. If you have a requirement for the options available in an input field, Input Helpers are where you&#8217;d start.</p>
<p>As mentioned in <a href="http://podscms.org/codex/input_helpers">the Codex</a>, Input Helpers have a number of variables available to use. Each variable is well explained in the Codex, and depending on the column type, you can use and interact with each of these variables at your will in an effort to obtain your desired result.</p>
<p>Input Helpers are created using the Helpers tab in the admin panel. When naming your Input Helper, ensure the title is comprised of <strong>all lowercase (non-special) characters, no dashes, and no spaces</strong>. Also be sure to define the helper as <strong>Input</strong>.</p>
<p><a href="/wp-content/uploads/2010/03/03-input-helper-init.jpg"><img class="alignnone size-full wp-image-1003" title="03-input-helper-init" src="/wp-content/uploads/2010/03/03-input-helper-init.jpg" alt="Screenshot outlining how to create an Input Helper in Pods CMS" /></a></p>
<p>After the Helper is created, you&#8217;re provided with a code editor. Here&#8217;s where the magic happens. Using this editor, you can manipulate your data using a combination of straight PHP and the variables outlined in <a href="http://podscms.org/codex/input_helpers">the Codex</a>.</p>
<p>After you&#8217;re done writing the PHP needed to manipulate the values available in your input column, the last step is to actually <em>apply</em> the Helper to your Input:</p>
<p><a href="/wp-content/uploads/2010/03/04-apply-helper.jpg"><img class="alignnone size-full wp-image-1004" title="04-apply-helper" src="/wp-content/uploads/2010/03/04-apply-helper.jpg" alt="Applying an Input Helper to an input column in Pods CMS" /></a></p>
<p><strong>Note:</strong> due to AJAX, you&#8217;ll need to refresh the page <em>before</em> attempting to apply your Input Helper.</p>
<h3>Limiting WordPress Pages with an Input Helper</h3>
<p>Circling back to our single use case, we&#8217;ll go ahead and write a quick and dirty Input Helper that&#8217;s going to limit our WP Page Pick column to only a select few Pages I want to make available to my client. Writing an Input Helper might require a bit of initial legwork in inspecting the default markup used for the existing (out of the box) data available. In this example we&#8217;re working a multiple Pick, so the markup is as follows:</p>
<pre class="sh_html"><code>&lt;div class=&quot;leftside pages&quot;&gt;
  &lt;label for=&quot;pods_form0_pages&quot;&gt;
    Page(s)
    &lt;span class=&quot;red&quot;&gt;*&lt;/span&gt;
  &lt;/label&gt;
&lt;/div&gt;
&lt;div class=&quot;rightside pages&quot;&gt;
  &lt;div class=&quot;form pick pages&quot; id=&quot;pods_form0_pages&quot;&gt;
    &lt;div class=&quot;option&quot; value=&quot;2&quot;&gt;About&lt;/div&gt;
    ...
    &lt;div class=&quot;option&quot; value=&quot;18&quot;&gt;Team&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre>
<p>The snippet has been truncated, but we can see how the Pick column is structured. We simply need to recreate that markup as we filter through the data supplied to the field:</p>
<pre class="sh_php"><code>&lt;?php
  $applicable_pages = array( 2, 31, 18, 23 );
?&gt;
&lt;div class=&quot;form pick &lt;?php echo $name; ?&gt;&quot;&gt;
  &lt;?php if ( !empty( $value ) ) : ?&gt;
    &lt;?php foreach ($value as $key =&gt; $val) : ?&gt;
      &lt;?php if( in_array( $val[&#x27;id&#x27;], $applicable_pages ) ) : ?&gt;

        &lt;?php
          $pagename = $val[&#x27;name&#x27;];
          $active= empty($val[&#x27;active&#x27;]) ? &#x27;&#x27; : &#x27; active&#x27;;
        ?&gt;
        &lt;div class=&quot;option&lt;?php echo $active; ?&gt;&quot; value=&quot;&lt;?php echo $val[&#x27;id&#x27;]; ?&gt;&quot;&gt;
          &lt;?php echo $pagename ; ?&gt;
        &lt;/div&gt;

      &lt;?php endif ?&gt;
    &lt;?php endforeach ?&gt;
  &lt;?php endif ?&gt;
&lt;/div&gt;</code></pre>
<p>What we&#8217;re doing with this Helper is first defining <code>$applicable_pages</code> which contains an array of the Page <code>ids</code> we&#8217;re permitting to show up for use. We then loop through <code>$value</code> (provided by Pods as per the Codex) and check to see if the current Page id is in our array. If it is, we&#8217;ll go ahead and make it available, else we move on to the next. What results is our refined list of available WordPress pages:</p>
<p><a href="/wp-content/uploads/2010/03/05-refined-pages.jpg"><img class="alignnone size-full wp-image-1005" title="05-refined-pages" src="/wp-content/uploads/2010/03/05-refined-pages.jpg" alt="Screenshot illustrating that our WP Page Pick column has indeed been filtered" /></a></p>
<p>A word of warning with this implementation: it&#8217;s tied to a single WordPress install. Additionally, problems will come up should the site be migrated to a new WordPress installation without a complete database export/import. WordPress Page ids are not retained using WordPress&#8217; import/export features. Keep that in mind as you write your Helpers.</p>
<h3>Input Helpers raise the bar</h3>
<p>Input Helpers open a ton of new doors when it comes to Pods. We&#8217;ve just scratched the surface with the example above, and as with pretty much anything &#8220;Pods&#8221; the possibilities are <strong>endless</strong>.</p>
<p>Another great resource you&#8217;ll want to bookmark is the <a href="http://podscms.org/packages/">Packages</a> section of the Pods CMS website. You can find a ton of available Helpers that have been made available by the community, some of which may come in handy straight away. The section isn&#8217;t limited to Helpers, but you can easily peruse the titles and poke around when you&#8217;ve got a minute.</p>
<br /><p><a href='http://rss.buysellads.com/click.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1000&c=1134940466' target='_blank' rel='nofollow'>
				<img src='http://rss.buysellads.com/img.php?z=1269068&k=2ee344414ac81fbb0f9de6ab08e9831e&a=1000&c=1134940466' border='0' alt='' /></a></p><p><a href='http://buysellads.com/buy/sitedetails/pubkey/2ee344414ac81fbb0f9de6ab08e9831e/zone/1269068' target='_blank'>Advertise here with BSA</a></p>]]></content:encoded>
			<wfw:commentRss>http://mondaybynoon.com/20100322/input-helpers-pods-cms-wordpress/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 1/48 queries in 0.059 seconds using apc
Object Caching 464/516 objects using apc

Served from: www.mondaybynoon.com @ 2012-02-10 19:26:55 -->
