<?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>Benjamin Ashcroft &#187; PHP</title>
	<atom:link href="http://www.benjaminashcroft.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benjaminashcroft.com</link>
	<description>Manchester based web developer and designer of high quality websites, printed matter and moving images.</description>
	<lastBuildDate>Thu, 24 Jun 2010 13:33:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Wordress sub-menu navigation</title>
		<link>http://www.benjaminashcroft.com/web-design/wordress-sub-menu-navigation/.</link>
		<comments>http://www.benjaminashcroft.com/web-design/wordress-sub-menu-navigation/.#comments</comments>
		<pubDate>Tue, 08 Sep 2009 16:29:00 +0000</pubDate>
		<dc:creator>Benjash</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[get_post_ancestors()]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Section]]></category>
		<category><![CDATA[Sibling]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress Themes]]></category>
		<category><![CDATA[wp_list_pages]]></category>

		<guid isPermaLink="false">http://www.benjaminashcroft.com/?p=153</guid>
		<description><![CDATA[Been developing a solution for a new corporate site in development. Utilizing WordPress as a fully blown CMS, a major priority was developing a dynamic sub navigation solution within the theme. I found loads of sub menu and section navigation plug-ins but there where all a little too complicated. Additionally I came up against two [...]]]></description>
			<content:encoded><![CDATA[<p>Been developing a solution for a new corporate site in development. Utilizing WordPress as a fully blown CMS, a major priority was developing a dynamic sub navigation solution within the theme. I found loads of sub menu and section navigation plug-ins but there where all a little too complicated.</p>
<p>Additionally I came up against two other issues:</p>
<ol>
<li>Finding out the depth of the page within the hierarchy of the site.</li>
<li>Control over whether the menu displayed  &#8220;sibling&#8221; links or &#8220;children&#8221; links.</li>
</ol>
<p>A lot of the existing tutorials are great, but their implementation is very broad. The <strong>&#8220;wp_list_pages&#8221;</strong> function within WordPress is great, very flexible and well documented. Yet swapping between section or child menu based on page depth seemed to be a dead end. Until I read this <a href="http://www.cmurrayconsulting.com/wordpress-tips/current-section-navigation-wordpress/">great tutorial by </a><a title="Posts by Jake Goldman" href="http://www.cmurrayconsulting.com/author/jgoldman/">Jake Goldman</a> talking about a hardly mentioned but great function, called <strong>&#8220;get_post_ancestors();&#8221;.</strong> This cool function will create an array of the current posts ancestors. Using this I expanded on Jake Goldman&#8217;s great article, adding a little more finite control over the submenu.</p>
<h2>Page depth and sibling / child code for WordPress</h2>
<p>Heres the PHP code I dropped into the sidebar.php of my WordPress theme. Hopefully should be of use. My example displays the sibling/ section links into the navigation. While displaying the child links for all the pages higher in the hiarachy.  Hope this code is usefull.</p>
<pre name="code" class="php">

#Creates Array from the pages ancestors post ID's
$post_ancestors = get_post_ancestors($post);

#Un-comment array for guidence
#print_r($post_ancestors);

#Gets the base post id
$top_page = array_pop($post_ancestors);

#Get post depth
#After a certain depth into the page hierarchy the page displays sibling menu items in sub menu.

if (count($post_ancestors) &lt;= 1) {
#Shallow Link Display Children
$children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0&amp;depth=1');

 } elseif (count($post_ancestors) &gt;= 2) {

#Deep Link Display Siblings or Section Links
$children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;post_parent.'&amp;echo=0&amp;depth=1');

} elseif (is_page()) {

#Default Display Children
$children = wp_list_pages('title_li=&amp;child_of='.$post-&gt;ID.'&amp;echo=0&amp;depth=1');

} 

if ($children) {
#Outputs the submenu if it exists
echo('
<ul>Sub Menu');
echo($children);
echo('</ul>

');
</pre>
<h3>Example of the hierarchy of the site</h3>
<ul><a class="post-edit-link" title="Edit post" href="http://ved.selectproperty.com/wp-admin/page.php?action=edit&amp;post=495"></a></p>
<li class="page_item page-item-489 current_page_ancestor current_page_parent">Locations
<ul>
<li class="page_item page-item-490">Manchester</li>
<li class="page_item page-item-497">Dubai</li>
<li class="page_item page-item-499">Turkey</li>
<li class="page_item page-item-495 current_page_item">Dubai Marina
<ul>
<li class="page_item page-item-534">Botanica</li>
<li class="page_item page-item-511">The Torch
<ul>
<li class="page_item page-item-516">Overview</li>
<li class="page_item page-item-518">Facilities</li>
<li class="page_item page-item-520">Properties
<ul>
<li class="page_item page-item-524">2 Bedroom Apartment</li>
</ul>
</li>
<li class="page_item page-item-522">Payment Plans</li>
<li class="page_item page-item-527">FAQ’s</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.benjaminashcroft.com/web-design/wordress-sub-menu-navigation/./feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Datatables slide and select property finder</title>
		<link>http://www.benjaminashcroft.com/web-design/datatables-slide-and-select-property-finder/.</link>
		<comments>http://www.benjaminashcroft.com/web-design/datatables-slide-and-select-property-finder/.#comments</comments>
		<pubDate>Wed, 02 Sep 2009 23:03:05 +0000</pubDate>
		<dc:creator>Benjash</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[datatables]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider ui]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[wearehome]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.benjaminashcroft.com/?p=130</guid>
		<description><![CDATA[Had a very busy few weeks learning how to use Mysql, PHP, XML and jquery. To create a dynamic property listing page with a dynamic slider. Have a play here. Makes extensive use of the Jquery Slider ui and Datatables plugin. Feeding off my first Mysql database, that in turn is populated by an xml [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wearehome.com/fractional-ownership-slider.php"><img src="http://www.benjaminashcroft.com/wp-content/uploads/2009/09/Picture-2-299x191.png" alt="Slide and select" title="Slide and select" width="299" height="191" class="alignleft size-medium wp-image-131" /> </a> Had a very busy few weeks learning how to use Mysql, PHP, XML and jquery. To create a dynamic property listing page with a dynamic slider. Have a play <a href="http://www.wearehome.com/fractional-ownership-slider.php">here</a>. </p>
<p>Makes extensive use of the Jquery Slider ui and <a href="http://www.datatables.net/">Datatables</a> plugin.  Feeding off my first Mysql database, that in turn is populated by an xml file. All ive got to do now is tie the rest of the site into the new pricing database.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benjaminashcroft.com/web-design/datatables-slide-and-select-property-finder/./feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Flexible Automatic Jquery gallery.</title>
		<link>http://www.benjaminashcroft.com/web-design/a-flexible-automatic-jquery-gallery/.</link>
		<comments>http://www.benjaminashcroft.com/web-design/a-flexible-automatic-jquery-gallery/.#comments</comments>
		<pubDate>Mon, 20 Jul 2009 16:35:10 +0000</pubDate>
		<dc:creator>Benjash</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[easing]]></category>
		<category><![CDATA[fancybox]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[pikachoose]]></category>
		<category><![CDATA[slider.js]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.benjaminashcroft.com/?p=91</guid>
		<description><![CDATA[I&#8217;ve been working on site recently which features a number of galleries in lightboxes. Using the fancybox lightbox plugin it launches an iframe with the gallery. I highly recomend the Pikachoose gallery simple for its amazing simplicity and ease of use. Easy to style and adapt to my own needs, including a inbuilt carousel feature [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on site recently which features a number of galleries in lightboxes. Using the fancybox lightbox plugin it launches an iframe with the gallery. </p>
<p>I highly recomend the <a href="http://pikachoose.com/demo/">Pikachoose</a> gallery simple for its amazing simplicity and ease of use. Easy to style and adapt to my own needs, including a inbuilt carousel feature utilizing slider.js.<em> I&#8217;ll post a link to an example lightbox gallery soon.</em></p>
<h2>List images from a folder automatically via PHP</h2>
<p>Heres a little code snippet I used to list all the images in a folder.</p>
<pre name="code" class="php">

// the directory, where your images are stored
$imgdir = '/images/'; 

// list of filetypes you
$allowed_types = array('png','jpg','jpeg','gif'); want to show

$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
 if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
 {
  $a_img[] = $imgfile;
  sort($a_img);
  reset ($a_img);
 }
}
// total image number
$totimg = count($a_img); 

for($x=0; $x < $totimg; $x++)
{
 $size = getimagesize($imgdir.'/'.$a_img[$x]);

 // do whatever
 $halfwidth = ceil($size[0]/2);
 $halfheight = ceil($size[1]/2);
 echo '
<li><img src="'.$imgdir.''.$a_img[$x].'"/></a></li>

';
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.benjaminashcroft.com/web-design/a-flexible-automatic-jquery-gallery/./feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get Live Support chat. For Free.</title>
		<link>http://www.benjaminashcroft.com/web-design/get-live-support-chat-on-your-site-the-free-way/.</link>
		<comments>http://www.benjaminashcroft.com/web-design/get-live-support-chat-on-your-site-the-free-way/.#comments</comments>
		<pubDate>Sun, 28 Jun 2009 21:12:25 +0000</pubDate>
		<dc:creator>Benjash</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Free]]></category>
		<category><![CDATA[Help Center Live]]></category>
		<category><![CDATA[Live Support Chat]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Opensource]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.benjaminashcroft.com/?p=44</guid>
		<description><![CDATA[Live support chat is a great way of engaging with customers, in a freindly way. Letting you connect directly with your customers as they look through your site. Enabling you and your staff guide your customers throughout their journey on a website. Its good to chat, especially when it&#8217;s free After getting endless quotes, for [...]]]></description>
			<content:encoded><![CDATA[<p>Live support chat is a great way of engaging with customers, in a freindly way. Letting you connect directly with your customers as they look through your site. Enabling you and your staff guide your customers throughout their journey on a website.</p>
<h3>Its good to chat, especially when it&#8217;s free</h3>
<p>After getting endless quotes, for expensive solutions. <a href="http://www.helpcenterlive.com/">Help Center Live </a>was brought to my attention. This php mysql based solutions seems great, except its windows only at the moment. The good news is, version 3 is coming out soon with full support. </p>
<p><a href="http://www.helpcenterlive.com/">Help Center Live</a> is an open-source, community driven live chat &#038; support system. You may easily provide live support on your website just like large companies do with very little work. With Help Center Live, you can provide a real-time, live support or sales person experience.</p>
<p>Take a look at <a href="http://www.helpcenterlive.com/">Help Center Live</a> and let me know how things go</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benjaminashcroft.com/web-design/get-live-support-chat-on-your-site-the-free-way/./feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
