<?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>CM &#187; PHP</title>
	<atom:link href="http://corymathews.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://corymathews.com</link>
	<description>Things I should remember and then some...</description>
	<lastBuildDate>Thu, 26 Jan 2012 16:27:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>List Current Parent and Child Pages in WordPress</title>
		<link>http://corymathews.com/list-current-parent-and-child-pages-in-wordpress/</link>
		<comments>http://corymathews.com/list-current-parent-and-child-pages-in-wordpress/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 20:19:16 +0000</pubDate>
		<dc:creator>CoryMathews</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://corymathews.com/?p=805</guid>
		<description><![CDATA[Recently in WordPress I needed to create a navigation that would display a page&#8217;s parent page and all of that pages children, I am a bit rusty with PHP but here is what I got to work. &#60;ul&#62; &#60;?php if($post-&#62;post_parent == 0) { $pageLinkID = $post-&#62;ID; $title = $post-&#62;post_title; } else { $pageLinkID = $post-&#62;post_parent; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently in WordPress I needed to create a navigation that would display a page&#8217;s parent page and all of that pages children, I am a bit rusty with PHP but here is what I got to work.</p>
<pre class="prettyprint linenumstrigger linenums">
&lt;ul&gt;
&lt;?php
  if($post-&gt;post_parent == 0) {
    $pageLinkID = $post-&gt;ID;
    $title = $post-&gt;post_title;
  } else {
    $pageLinkID = $post-&gt;post_parent;
    $title = get_the_title($post-&gt;post_parent);
  }
  echo '&lt;li class=&quot;parent&quot;&gt;&lt;a href=&quot;'.get_page_link($pageLinkID).'&quot;&gt;'.$title.'&lt;/a&gt;&lt;/li&gt;';
  $pages = get_pages('child_of='.$pageLinkID);
  foreach ($pages as $p) {
    echo '&lt;li&gt;&lt;a href=&quot;'.get_page_link($p-&gt;ID).'&quot;&gt;'.$p-&gt;post_title.'&lt;/a&gt;&lt;/li&gt;';
  }
?&gt;
&lt;/ul&gt;
</pre>
<p>If you need to order the posts by the order value change the
<pre class="prettyprint linenumstrigger linenums">$pages = </pre>
<p> Line to </p>
<pre class="prettyprint linenumstrigger linenums">$pages = get_pages('child_of='.$pageLinkID.', 'sort_column' =&gt; 'menu_order', 'sort_order' =&gt; 'asc');</pre>
]]></content:encoded>
			<wfw:commentRss>http://corymathews.com/list-current-parent-and-child-pages-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Multiple WordPress Menus</title>
		<link>http://corymathews.com/multiple-wordpress-menus/</link>
		<comments>http://corymathews.com/multiple-wordpress-menus/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 18:19:30 +0000</pubDate>
		<dc:creator>CoryMathews</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://corymathews.com/?p=690</guid>
		<description><![CDATA[WordPress 3+ allows for custom theme controlled menus. For this example I will be adding 3 but the same works for 2, 3 or any number of wordpress menus. In the functions.php file of the theme we first need to add support for menus. if (function_exists('add_theme_support')) { add_theme_support('menus'); } The function_exists is only there for [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress 3+ allows for custom theme controlled menus. For this example I will be adding 3 but the same works for 2, 3 or any number of wordpress menus.</p>
<p>In the functions.php file of the theme we first need to add support for menus.</p>
<pre class="prettyprint linenumstrigger linenums">if (function_exists('add_theme_support')) {
    add_theme_support('menus');
}</pre>
<p>The function_exists is only there for backward compatability.. so you can probably safely remove it. Without the add_theme_support when someone clicks on Appearance -&gt; Menus they will get the message</p>
<blockquote><p>&#8220;The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.&#8221;</p></blockquote>
<p>Next we need to define our menus using the register_nav_menu  function. The following defines 3 different menus; main, top and side to be used within our skin</p>
<pre class="prettyprint linenumstrigger linenums">if ( function_exists( 'register_nav_menu' ) ) {
  register_nav_menus( array(
    'main' =&gt; 'Main Navigation',
    'top' =&gt; 'Smaller top nav',
    'side' =&gt; 'nav within sidebar'
  ))
}</pre>
<p>Now if we go to the menus page within WordPress we should see that our skin supports 3 different menus. With the descriptions we provided in the functions.php file.</p>
<p><img class="alignnone size-full wp-image-691" title="menus" src="http://corymathews.com/wp-content/uploads/2011/07/menus.png" alt="" width="300" height="316" /></p>
<p>Now we need to add these menu place holders to our theme so the menus appear in the appropriate places. So within your themes .php pages add the following line</p>
<pre class="prettyprint linenumstrigger linenums">&lt;? php wp_nav_menu( array( 'theme_location' &gt; 'top', 'container' &gt; '' ) ); &gt;</pre>
<p><em>*The container parameter removes the (pointless) wrapping div tag.</em></p>
<p>Then for each of the other menus you add the above code again giving it the other menu items.</p>
]]></content:encoded>
			<wfw:commentRss>http://corymathews.com/multiple-wordpress-menus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving a PHP File as a Word Document</title>
		<link>http://corymathews.com/saving-a-php-file-as-a-word-document/</link>
		<comments>http://corymathews.com/saving-a-php-file-as-a-word-document/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 12:43:27 +0000</pubDate>
		<dc:creator>CoryMathews</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://corymathews.com/?p=287</guid>
		<description><![CDATA[So you are looking for a way to save a PHP page as a word doc programatically? Then you have come to the right place. When I had to overcome this problem my main requirement was that I could not open word on the server. Searching around the net produced countless pages with the same [...]]]></description>
			<content:encoded><![CDATA[<p>So you are looking for a way to save a PHP page as a word doc programatically? Then you have come to the right place.</p>
<p>When I had to overcome this problem my main requirement was that I could <strong>not open word on the server</strong>.</p>
<p>Searching around the net produced countless pages with the same responses of using <a href="http://www.php.net/manual/en/class.com.php">COM</a> or using some third party library&#8217;s and software. However as with any project if it is possible I, as well as many other developers, try to avoid third party <a href="http://www.codinghorror.com/blog/archives/000497.html">products</a>.</p>
<p>I eventually came up with this solution:</p>
<pre name="code" class="html">&lt;?php
	header("Content-type: application/vnd.ms-word");
	header("Content-Disposition: attachment; Filename=SaveAsWordDoc.doc");
?&gt;</pre>
<p>Then along with your meta tags add the following</p>
<pre name="code" class="html">&lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\"&gt;</pre>
<p>Placing this meta tag on a page will cause the browser to think it is a html word document. Thus prompting you to open/save the document instead of rendering it like a normal webpage.</p>
<p>The only downside to this is that when you open the file in word it will open in the web layout mode of word instead of print layout.</p>
<h3>Example Usage:</h3>
<p><a href="http://www.isearchnotes.com/single.php?id=136">You can view a demo of this in use over at iSearchNotes.com</a></p>
<p><strong>Word Page</strong>: (<a href="http://corymathews.com/src/SaveAsWordDoc.php">SaveAsWordDoc.php</a>)</p>
<pre name="code" class="html">&lt;?php
	header("Content-type: application/vnd.ms-word");
	header("Content-Disposition: attachment; Filename=SaveAsWordDoc.doc");
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\"&gt;
&lt;title&gt;Saves as a Word Doc&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Header&lt;/h1&gt;
  This text can be seen in word
&lt;ul&gt;
&lt;li&gt;List 1&lt;/li&gt;
&lt;li&gt;List 2&lt;/li&gt;
&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Calling Page:</strong><br />
Just your normal html <a> link.</p>
<pre name="code" class="html"><a href="SaveAsWordDoc.php">link</a></pre>
<p></a></p>
]]></content:encoded>
			<wfw:commentRss>http://corymathews.com/saving-a-php-file-as-a-word-document/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

