My name is Clayton McIlrath and I am an entrepreneur currently living in CO. I personally enjoy the process of learning, exploring, and doing all things creative as well as sharing my experiences with others. Being an entrepreneur and business owner, I hope that my experiences may help someone else start their own venture and find success and freedom as I have! Feel free to contact me anytime for questions or opportunities.

close
more

»

«


Automate to save time and money!

The guys over at Chosen Creative have given us yet another awesome way to make are lives easier! This script generates a list of all files in a directory using a PHP function to read the directory files starting with the underscore _ character, and then it outputs them into a JQuery styled accordion menu!

Here’s the JQ

$(document).ready(function(){
	$("li.child:visible").hide();
	$("li.parent").click(function(){
		if ($(this).children().hasClass("selected")) {
			$(this).children().removeClass('selected');
			$(this).next().toggle("slow");
			return false;
		}
		else {
			$(this).children().addClass('selected');
			$(this).next().load($(this).children().attr("href")).toggle("medium");
			return false;
		}
 
	});
});

Here’s the PHP

if ($handle = opendir('./'))
{
	while (false !== ($file = readdir ($handle)))
	{
		if ( preg_match("/^\_/", $file) )
		{
			$filename = preg_replace('/\_/', ' ', $file);
			echo "
	<li class="\&quot;parent\&quot;"><a href="\">" . $filename ."</a></li>
\n
	<li class="\&quot;child\&quot;"></li>
";
		}
	}
	closedir($handle);
}

close