Resources

Envato Birthday Bundle

Monday, August 22nd, 2011

envato birthday bundle

Envato is turning five, and celebrating another year with an amazing bundle for sale, the Envato Birthday Bundle. This year they’re going all out and giving you more than $500 ($507 in fact) worth of some of the most awesome marketplace files around for the rock bottom price of $20. That’s a saving of more than 90%!

This bundles has motion graphics, sound effects, music, tutorials, code, site templates and themes, stock photography, Flash and Unity, graphics and vectors, 3d models and more! There are 51 files all for only $20! But be quick, this deal is available for 4 days only! ( 22nd to 26th midday AEST ).

This is a really great deal, get it while you can.

Cya

WordPress List Category Posts without Breaking Sidebar

Wednesday, July 20th, 2011

query_post codex
As I was creating a page template for wordpress, I wanted to list posts from a specific category on a page when I ran into a interesting problem, the query_posts function I was using was causing breaks in the execution of conditional tags like is_page(’25′) in the sidebar template.  I looked around on the web for a while before finally finding the solution that worked for me. So I am rewriting the solution here for reference and so anyone else may find it easier.

Here is how you list posts from a particular category in a wordpress page template, right before the “while (have_posts()) : the_post(); ” call add:

<?php query_posts('category_name=name&showposts=100'); ?>
<?php /*  change name to the name of the category posts you want to display   */  ?>

The reason the wordpress function query_posts() breaks the sidebar template is because its not a simple database query collecting posts from a specific category, but its resetting the query object as a whole to reflect a normal category query.

So to fix the sidebar template you have to go with creating a new query object through WP_Query() in your page template. So here is the before and after of the loop in a page template.

Page Template Loop BEFORE:

<?php query_posts('category_name=name&showposts=100'); ?>
<?php while (have_posts()) : the_post(); ?>
       <!-- do stuff ... -->
<?php endwhile; ?>

Page Template Loop AFTER:

<?php $cat_posts = new WP_Query('category_name=name'); ?>
<?php if($cat_posts->have_posts()) : ?>
         <?php while($cat_posts->have_posts()) : $cat_posts->the_post(); ?>
                 <!-- do stuff ... -->
         <?php endwhile; ?>
<?php endif; ?>

Hope that helps someone, cya.

How to Detect Android and Redirect to Android Version Website

Tuesday, February 22nd, 2011

android-phone

I have been posting redirect scripts for several devices such as the iphone and ipad, and I thought why not add android to the list. I own a android phone and I love it, and I have tested this script so I know it works. This code detects whether the person viewing your website is on a Android device. If they are on a Android phone, you can redirect them to a android version website or just to another page, its up to you. If they are on a normal computer it doesn’t redirect them and they go on as normal. Its just some simple javascript, and if you want to use it just change the “document.location” value to the url you want them redirected. Here is the code, and its just the same as when you detect for iPhone.

1
2
3
4
5
<script type="text/javascript"> // <![CDATA[
	if ( (navigator.userAgent.indexOf('Android') != -1) ) {
		document.location = "http://www.yoururladdress.com/yourpage.html";
	} // ]]>
</script>

Cya

Fade In and Fade Out in jQuery

Tuesday, April 27th, 2010

I have been working a lot more with jQuery lately, so I thought I would show you how to do the simple fade in or fade out jQuery hover effect that occurs to the navigation when you go to the Google homepage. You know the one that I am talking about, its occurs when your mouse goes over the page of the google homepage, all the navigation at the top appears.

For the first example, I will show you how to make the fade in jQuery hover effect. Hover over the box below to see the effect.

 

The rest of the content of the page

To do this, first place this jQuery code in the <head></head> section of your html file.

1
2
3
4
5
6
7
8
9
10
11
//the first line gets the latest jquery scripts
<script src="http://code.jquery.com/jquery-latest.js"></script>
//this function is called when the page is ready
<script>
$(document).ready(function() {
        //first hide the div with the id of googlenav
	$("div#googlenav").hide();
        //then when you rollover the specified div fade in the googlenav
	$("div#googlediv").hover(function(){$("div#googlenav").fadeIn('slow');});
});
</script>

Then add this html code into the <body></body> of your html document

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div id="googlediv" style="width:500px; height:200px; border:1px solid #ffffff;">
<div id="googlenav">
	<ul>
    <li><a href="#">Web</a></li>
    <li><a href="#">Images</a></li>
    <li><a href="#">Videos</a></li>
    <li><a href="#">Maps</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Shopping</a></li>
    <li><a href="#">Gmail</a></li>
  </ul>
</div>
<div style="margin:0px auto; width:500px; text-align:center;">
<p>&nbsp;</p><p>The rest of the content of the page</p>
</div>
</div>

You can style the content hover you like, I tried to keep all the links inline like google does. Here is my styling, you can add this in the <head></head> section too.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<style type="text/css">
#googlenav {
	padding:0px;
	margin:0px;
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
	border-bottom:1px solid #c9d7f1;
	height:26px;
	position:absolute;
	width:500px;
}
#googlenav ul {
	padding:3px 0px;
	margin:0px;
	padding-left:15px;
}
#googlenav ul li{
	display:inline;
	padding:0px 3px;
	margin:0px;
}
</style>

Now google fades in their links and navigation when you roll over the page, not a specific div. So if you wanted it to be exactly like that, you would target the page instead of that particular div. So in your jQuery instead of this:

$("div#googlediv").hover(function(){$("div#googlenav").fadeIn('slow');});

You would put this:

$(document.body).hover(function(){$("div#googlenav").fadeIn('slow');});

And style accordingly. Now if you want to fade out in jQuery, instead of fadeIn(), you would use the fadeOut() function. And Remember you don’t have to hide the content first, so the jQuery would look like this.

1
2
3
4
5
6
7
8
9
//the first line gets the latest jquery scripts
<script src="http://code.jquery.com/jquery-latest.js"></script>
//this function is called when the page is ready
<script>
$(document).ready(function() {
        //then when you rollover the specified div fade in the googlenav
	$("div#googlediv").hover(function(){$("div#googlenav").fadeOut('slow');});
});
</script>

An example of the fadeOut function is below using the code above.

 

The rest of the content of the page

That’s really about it, if this helps you out please leave a comment.

Cya

Loading Multiple XML Files in Flash

Wednesday, April 21st, 2010

While working on my second version of RocFolio, I came across a few errors while trying to load multiple xml files in Flash AS3. When loading the files sometimes Flash would randomly put additional characters at the end of my xml file giving me parsing errors. So I had to figure out a way to cut those out, and I’ll try to explain real quick what I did.

So to load your XML you have to create your load and request variables and then you should create a few event listeners for progress and complete events, like this:

1
2
3
4
5
6
var loader:URLLoader = new URLLoader();
var requestURL:URLRequest = new URLRequest(xmlfilename.xml);
 
//create progress and complete event listeners for the loader, and load the urlrequest
loader.addEventListener(ProgressEvent.PROGRESS, getBytesLoop);
loader.addEventListener(Event.COMPLETE, loadXML);

Now in your loadXML function all you have to do is figure out where the xml file actually ends, and then index that spot and then cut the rest of the string out with the substring() command. Here is how you do that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//function loadxml loads the xml and handles assigning to places
function loadXML(e:Event):void {
 
	var dataString:String = e.target.data;
	var finalString:String = "";
	var endofString:uint;
 
        //find out where the end of the xml file is, however your set it up it should be the last closing tag, this one is </settings>
	endofString = dataString.indexOf("</settings>", 0);
 
	//cut out the good part of the xml using substring, then use 0 as your starting point to where you got your endOfString
        //make sure to add whatever amount you need to be at the end of the your last closing tag, </settings> has 11 characters in it so +11
	finalString = dataString.substring(0, endofString+11);
 
	//then assign the finalstring to your XML variable
	try {
		var theXML:XML = new XML(finalString);
	} catch (e:TypeError) {
		//loader.load(requestURL);
		trace("A TypeError has occurred : \r\t" + e);
	}
 
//then go on with setting up your XMLLists so you can access the data how you want
}

So hopefully this helps those out there that are getting weird parsing errors when trying to load multiple XML files. I know I tried finding the solution out on the web and couldn’t so that’s why I wrote this, if it helps you out please leave a comment.

Cya