<?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>WordPress Web Hosting &#187; WordPress database</title>
	<atom:link href="http://www.shrewdies.net/blog/wordpress-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shrewdies.net</link>
	<description>Business Web Hosting For Shrewdies Not Dummies</description>
	<lastBuildDate>Thu, 26 Aug 2010 19:11:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WordPress Database With Pods Wings</title>
		<link>http://www.shrewdies.net/1382/wordpress-database-with-pods-wings/</link>
		<comments>http://www.shrewdies.net/1382/wordpress-database-with-pods-wings/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 16:01:24 +0000</pubDate>
		<dc:creator>Keith from shrewdies</dc:creator>
				<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Happiness Today]]></category>
		<category><![CDATA[WordPress database]]></category>

		<guid isPermaLink="false">http://www.shrewdies.net/?p=1382</guid>
		<description><![CDATA[I start my detailed look at the anatomy of our WordPress Pods plugins by showing you how Pods CMS makes the WordPress database fly. Though we are all working with data at the heart of the WordPress database, we often take it for granted. But data drives our content, our navigation, our presentation, our whole [...]]]></description>
			<content:encoded><![CDATA[<div class="kctIntro">I start my detailed look at the anatomy of our WordPress Pods plugins by showing you how Pods CMS makes the WordPress database fly.</p>
<p>Though we are all working with data at the heart of the WordPress database, we often take it for granted.</p>
<p>But data drives our content, our navigation, our presentation, our whole website.</p>
<p>Wouldn&#8217;t it be a good idea if we managed it properly?</p></div>
<p>I must confess, I love data. Actually, that&#8217;s as perverted as loving money &#8211; I actually love what can be done with data, rather than data itself. Structured and handled properly, application development, from the most basic WordPress plugin to a full blown web application becomes much more scalable and easier to manage if we get the data right.</p>
<p><div id="attachment_1389" class="wp-caption alignright" style="width: 310px"><a href="http://www.shrewdies.net/wp-content/uploads/wordpress-database-with-pods.png"><img src="http://www.shrewdies.net/wp-content/uploads/wordpress-database-with-pods-300x272.png" alt="WordPress Database With Pods" title="WordPress Database With Pods" width="300" height="272" class="size-medium wp-image-1389" /></a><p class="wp-caption-text">WordPress Database With Pods (click image for full size)</p></div>Our sample project Happiness Today, relies on data, just as it&#8217;s inspiration, Hello Dolly does. Whereas Hello Dolly data, the song lyrics, are hard-coded in the plugin, Happiness Today data is put where it belongs &#8211; in the WordPress database.</p>
<p>Each Pods project starts with data. This is the basic building block, known simply as a Pod. In complex applications, the hard part is learning how to structure data, especially if it needs to be split into different Pods.</p>
<p>Our example is very simple &#8211; every record in the Pod is just a lyric from the song. Experience tells me that I need keys to data in databases. In this case I use a simple line number identifier, which allows me to sort the records should I wish to output the whole song.</p>
<p>It is a good habit to always think of record keys when designing a Pod, or any other database. Pods helps us here by always creating a field called name, which will always uniquely identify records. With the Pod created, we simply need to add the text to each record, which we do with the standard Pods CMS record editing screens.</p>
<p>Job done, except that we need to get the data out.<span id="more-1382"></span> I&#8217;ll be looking at presentation in the next article. In practice, when planning this type of application, you would start by designing the display(s) that need to be produced, and work back to the data required to fulfill that. The crucial point is that the two are completely separate. We have the song data held independently as text records, unchanged but for some keys to identify individual lines.</p>
<p>It is important to grasp this separation between data and presentation. It is also important to plan them both before you start. This example is fairly trivial, but it illustrates the guiding principles. For example, had the application been to present random words, then the database structure would be different.</p>
<p>If you are new to databases, it is a good idea to create some example Pods to familiarize yourself with the features available. When you design an application in future, you will always start planning the outcomes first, then the data structures. When we build the application, it is data first, followed by presentation and often some calculation or other forms of data manipulation.</p>
<p>In this series, we are also concerned with distributing our data via the WordPress Pods Plugin Builder. There are two elements &#8211; the data structure, and the data records.</p>
<p>Pods has an inbuilt mechanism for exporting and importing Pods data structures within its Pods Package feature. This is exposed programatically through the Pods UI plugin, with an import routine demonstrated in the Pods UI demo plugin. The demo has the import code hard-coded into the plugin, but I needed this to be file based for maximum portability. As this is more than just data, I&#8217;ll cover the routines for programatically exporting and importing Pods packages in a later installment (I should also suggest this for the Pods codex, so remind me if I forget).</p>
<p>Similarly, the Pods API exposes import and export methods, so I included these in the builder, to build sample data and import it. To my delight, the proof of concept works fine. The builder creates files for the data structure and data records and a plugin.php file. The plugin imports these during initialization and all is fine, except that it doesn&#8217;t really&#8230;</p>
<p>It is still fine, but the data import has to be separate from the structure import. I have a fairly good idea why this is the case, but as I was thinking about the solution I realized that the data record import SHOULD be separate from the structure import.</p>
<p>To make Happiness Today really useful, it is important to allow users to easily package their own text messages and links. Therefore, I believe that the data import, complete with block delete and export functions should be included in the basic plugin as user routines, separate from installation routines.</p>
<p>My only dilemma is that the extra layer of functionality adds a little more complexity to the idea of a very simple example. Perhaps it is pointless to take simplicity below the level of usefulness?</p>
<p><!--more--><div style="margin-left:-1em;"><table><tr><td><script type="text/javascript"><!--
google_ad_client = "pub-7512621270035949";
/* shrewdies 300x250, created 22/12/09 */
google_ad_slot = "4026195862";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></td><td>
<script type="text/javascript"><!--
ch_client = "GoutPal";
ch_type = "mpu";
ch_width = 300;
ch_height = 250;
ch_color_bg = "ffffff";
ch_color_border = "ffffff";
ch_color_title = "00009e";
ch_color_site_link = "00009e";
ch_non_contextual = 4;
ch_vertical ="premium";
ch_sid = "ShrewdiesReward";
ch_alternate_ad_url = "http://www.shrewdies.net/ad.html";
var ch_queries = new Array( );
var ch_selected=Math.floor((Math.random()*ch_queries.length));
if ( ch_selected < ch_queries.length ) {
ch_query = ch_queries[ch_selected];
}
//--></script>
<script  src="http://scripts.chitika.net/eminimalls/amm.js" type="text/javascript">
</script></td></tr></table></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shrewdies.net/1382/wordpress-database-with-pods-wings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Database Extension</title>
		<link>http://www.shrewdies.net/579/wordpress-database-extension/</link>
		<comments>http://www.shrewdies.net/579/wordpress-database-extension/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:25:25 +0000</pubDate>
		<dc:creator>Keith from shrewdies</dc:creator>
				<category><![CDATA[Function]]></category>
		<category><![CDATA[menu bar]]></category>
		<category><![CDATA[shrewdBar]]></category>
		<category><![CDATA[WordPress database]]></category>
		<category><![CDATA[WordPress Pods CMS]]></category>

		<guid isPermaLink="false">http://www.shrewdies.net/?p=579</guid>
		<description><![CDATA[Extending the WordPress database is the first step in developing my menu bar. In most WordPress extensions, a lot of data is hidden in the code. The massive advantage of Pods is that we can easily store additional data, and manage it very efficiently. In the first installment of this series, I introduced shrewdBar, explaining [...]]]></description>
			<content:encoded><![CDATA[<div class="kctIntro">Extending the WordPress database is the first step in developing my menu bar.</p>
<p>In most WordPress extensions, a lot of data is hidden in the code.</p>
<p>The massive advantage of Pods is that we can easily store additional data, and manage it very efficiently.</p></div>
<p>In the first installment of this series, I introduced shrewdBar, explaining it was based on a WordPress plugin that creates a menu by outputting data in the form of a CSS LIst driven menu. This type of menu is quite common &#8211; you style a nested list to have hidden items that reveal themselves when the mouse hovers over them. The added attraction of this type of menu is that without the styling, you simply have a nested list of items that search engines can follow.</p>
<p>The CSS issues are for another time. What I need you to realize is that these menus are usually built in code, with a lot of hard-coded links. True, the original menubar, DashBar, on which shrewdBar is roughly based, does have some items that are extracted from WordPress database tables. In my first  version of the menu bar, I extended this to extract messages and topics from the Simple:Press forum.</p>
<p>Pods allowed me to put all the menu items into WordPress database tables, and I explain in this article, how I achieved this.</p>
<h3>shrewdBar Database</h3>
<p>In its current release, I have limited the menu to two tiers, so we have a Pod for the top tier, that you see across the top of the page. Optionally, each of these top level records can have a variable number of child items.</p>
<p>The schematic is:</p>
<table>
<tr valign="top">
<th>shrewdies_bar</th>
<th style="color:#9e009e;">&nbsp;&nbsp;&nbsp;link&nbsp;&nbsp;&nbsp;</th>
<th>shrewdies_bar_item</th>
</tr>
<tr valign="top">
<td>name (txt)</td>
<td></td>
<td>name (txt)</td>
</tr>
<tr valign="top">
<td>slug (slug)</td>
<td></td>
<td>slug (slug)</td>
</tr>
<tr valign="top">
<td>bartext (txt)</td>
<td align="right" style="color:#9e009e;"></td>
<td>itemtext (txt)</td>
</tr>
<tr valign="top">
<td>bartitle (txt)</td>
<td align="center" style="color:#9e009e;"></td>
<td>itemtitle (txt)</td>
</tr>
<tr valign="top">
<td>barurl (txt)</td>
<td align="center" style="color:#9e009e;"></td>
<td>itemurl (txt)</td>
</tr>
<tr valign="top">
<td>baritems (pick shrewdies_bar_item)</td>
<td style="color:#9e009e;">&nbsp;&sup1;&mdash;&mdash;&infin;</td>
<td>itembar (pick shrewdies_bar)</td>
</tr>
<tr valign="top">
<td>bardisplay (code)</td>
<td></td>
<td></td>
</tr>
<tr valign="top">
<td>barhold (bool)</td>
<td></td>
<td></td>
</tr>
</table>
<p>Pods automatically creates the name and slug fields when we create a new pod. name identifies the record, and I also use it as a sort order. slug is very useful in many Pods packages, and I&#8217;ll cover it in depth later, but it is not really required in the current version of shrewdBar.</p>
<p>The text, title and url fields are the menu links that are used to navigate to different pages. The pick fields are used to relate tables &#8211; in this case a one to many relationship.</p>
<p>The top level menu records have two additional fields. The boolean hold field allows menu items to be temporarily hidden, without deleting the record. This is not required for second level items, as it is a simple click to break or make the relationship to a top level menu. The display field allows us to enter PHP code which can programatically control the display giving us very powerful dynamic menus. I&#8217;ll be discussing this at length in the next installment.</p>
<h3>shrewdBar Options</h3>
<p>Like most plugins, shrewdBar needs options to control colors and positioning. Unlike most WordPress plugins, these options no longer have to live in the options table where they soon get lost. I put the shrewdBar options in its own table, which makes it very easy to manage. The options data could be managed using the standard Pods edit page, however I find it better to write a special page with information and instructions. I&#8217;ll be covering this in detail in a later installment.</p>
<p>In the next installment, I will explain how simple Pods procedures act on the data to produce the list output that forms the shrewdBar menu.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shrewdies.net/579/wordpress-database-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
