<?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>Gabriel de Kadt &#187; php</title>
	<atom:link href="http://www.lazydada.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazydada.com</link>
	<description>Personal notes on Mac based web development and design.</description>
	<lastBuildDate>Tue, 30 Aug 2011 10:47:39 +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>PHP 101. Basic stuff: get value from URL querystring with PHP</title>
		<link>http://www.lazydada.com/2011-07-11/basic-get-value-from-url-querystring-with-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=basic-get-value-from-url-querystring-with-php</link>
		<comments>http://www.lazydada.com/2011-07-11/basic-get-value-from-url-querystring-with-php/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 09:14:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=934</guid>
		<description><![CDATA[As I&#8217;m still an idiot when it comes to media queries and mobile devices and can pass this stuff on to other folks &#8211; but needed to give myself and the interested parties a visual representation of how different sized graphics will be delivered to different mobile devices&#8230; I was after a simple &#8216;switch&#8217; that [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m still an idiot when it comes to media queries and mobile devices and can pass this stuff on to other folks &#8211; but needed to give myself and the interested parties a visual representation of how different sized graphics will be delivered to different mobile devices&#8230; I was after a simple &#8216;switch&#8217; that would allow a single wedge of HTML to render according to a variable.</p>
<p>The example here goes along the lines of http://example.com?width=340 where the width has a few values it accepts or will default to a preset size&#8230;</p>
<p>This variable can then get passed around in the PHP file to set image dimaensions CSS etc&#8230;</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
function getUrlStringValue($urlStringName, $returnIfNotSet) {    if(isset($_GET[$urlStringName]) &amp;&amp; $_GET[$urlStringName] != &quot;&quot;)      return $_GET[$urlStringName];    else      return $returnIfNotSet;  }
$width = getUrlStringValue(&quot;width&quot;, &quot;480&quot;);

?&gt;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;meta name=&quot;viewport&quot; content=&quot;width=&lt;?php echo $width ;?&gt;&quot; /&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-07-11/basic-get-value-from-url-querystring-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting a page ID in WordPress</title>
		<link>http://www.lazydada.com/2011-04-28/getting-a-page-id-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-a-page-id-in-wordpress</link>
		<comments>http://www.lazydada.com/2011-04-28/getting-a-page-id-in-wordpress/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 19:39:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=918</guid>
		<description><![CDATA[Q. Want to get something in your theme to work with data from a particular page or post &#8211; but don&#8217;t know for sure what that post&#8217;s ID is? A. Try this in your functions.php file: &#8230;then you can then pass a variable about in your theme&#8217;s templates.]]></description>
			<content:encoded><![CDATA[<p>Q. Want to get something in your theme to work with data from a particular page or post &#8211; but don&#8217;t know for sure what that post&#8217;s ID is?</p>
<p>A. Try this in your functions.php file:</p>
<pre class="brush: php; title: ; notranslate">$my_id = $wpdb-&gt;get_var(&quot;SELECT ID FROM $wpdb-&gt;posts WHERE post_name = 'myPost'&quot;);</pre>
<p>&#8230;then you can then <a href="http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/">pass a variable about</a> in your theme&#8217;s templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-04-28/getting-a-page-id-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing a variable about in a WordPress theme</title>
		<link>http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=passing-a-variable-about-in-a-wordpress-theme</link>
		<comments>http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:58:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=915</guid>
		<description><![CDATA[I&#8217;m used to using php variables set in included  file being used in another included file if all are included in the same document. This doesn&#8217;t work in WordPress theme parts. It&#8217;s easy to overcome though&#8230; you just need to recall the variable first&#8230; somewhere in functions.php Now i can do this somewhere in header.php]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m used to using php variables set in included  file being used in another included file if all are included in the same document. This doesn&#8217;t work in WordPress theme parts. It&#8217;s easy to overcome though&#8230; you just need to recall the variable first&#8230;</p>
<p>somewhere in functions.php</p>
<pre class="brush: php; title: ; notranslate"> $my_var = &quot;xyz&quot; </pre>
<p>Now i can do this somewhere in header.php</p>
<pre class="brush: php; title: ; notranslate">&lt;?php global $myVar ;  ?&gt;
&lt;?php echo $myVar; ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-04-28/passing-a-variable-about-in-a-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple WordPress excerpt lengths</title>
		<link>http://www.lazydada.com/2011-04-28/multiple-wordpress-excerpt-lengths/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=multiple-wordpress-excerpt-lengths</link>
		<comments>http://www.lazydada.com/2011-04-28/multiple-wordpress-excerpt-lengths/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:51:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=910</guid>
		<description><![CDATA[Q. Got a theme that needs two different excerpt lengths? A. Found here: set the standard, longer excerpt as normal in the functions.php file and the override locally using this code: &#160;]]></description>
			<content:encoded><![CDATA[<p>Q. Got a theme that needs two different excerpt lengths?</p>
<p>A. Found <a href="http://wordpress.org/support/topic/possible-to-have-2-excerpt-lengths" target="_blank">here</a>: set the standard, longer excerpt as normal in the functions.php file and the override locally using this code:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php echo substr( get_the_excerpt(), 0, strrpos( substr( get_the_excerpt(), 0, 75), ' ' ) ); ?&gt;</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-04-28/multiple-wordpress-excerpt-lengths/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turn a text list into an HTML Select Option list with PHP</title>
		<link>http://www.lazydada.com/2011-02-03/list-to-html-select-option-list-with-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=list-to-html-select-option-list-with-php</link>
		<comments>http://www.lazydada.com/2011-02-03/list-to-html-select-option-list-with-php/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 17:53:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=884</guid>
		<description><![CDATA[Easy solution to this basic HTML coding need posted over at Stack Overflow by a random clever bloke. Thanks RCB. My only issue was with UTF-8 characters coming through garbled. Bodged a workaround using this encode entities plug-in for Dreamweaver.]]></description>
			<content:encoded><![CDATA[<p>Easy solution to this basic HTML coding need posted over at <a title="list to HTML select option list" href="http://stackoverflow.com/questions/4573883/convert-simple-list-into-html-select-list" target="_blank">Stack Overflo</a>w by a <a href="http://stackoverflow.com/users/220819/jacob-relkin" target="_blank">random clever bloke</a>. Thanks RCB.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

  $fc = file_get_contents('./test.txt');
  $fc = utf8_encode ( $fc );
	$lines = explode(&quot;\n&quot;, $fc);

  $html = '&lt;select&gt;';
  foreach($lines as $line)
     $html .= '&lt;option value=&quot;' . $line . '&quot;&gt;' . $line . '&lt;/option&gt;';

  $html .= '&lt;/select&gt;';
  echo $html;
?&gt;
</pre>
<p>My only issue was with UTF-8 characters coming through garbled. Bodged a workaround using this <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&amp;extid=15427#" target="_blank">encode entities plug-in</a> for Dreamweaver.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-02-03/list-to-html-select-option-list-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS in PHP</title>
		<link>http://www.lazydada.com/2011-02-02/css-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=css-in-php</link>
		<comments>http://www.lazydada.com/2011-02-02/css-in-php/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 11:43:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=875</guid>
		<description><![CDATA[The last time I tried to render CSS through PHP was many, many moons ago. I didn&#8217;t work and I couldn&#8217;t figure it out. Yesterday I tried again and found out why&#8230; the MIME type must be set as text/css. D&#8217;oh. Set MIME type like this:]]></description>
			<content:encoded><![CDATA[<p>The last time I tried to render CSS through PHP was many, many moons ago. I didn&#8217;t work and I couldn&#8217;t figure it out. Yesterday I tried again and found out why&#8230; the MIME type must be set as text/css. D&#8217;oh. Set MIME type like this:</p>
<pre class="brush: php; title: ; notranslate">&lt; ?php
header(&quot;Content-Type: text/css&quot;);
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2011-02-02/css-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP web forms</title>
		<link>http://www.lazydada.com/2010-09-24/php-web-forms/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-web-forms</link>
		<comments>http://www.lazydada.com/2010-09-24/php-web-forms/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 16:15:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=800</guid>
		<description><![CDATA[Websites are a point of contact &#8211; and a contact form that sends an email is the way to normally handle enquiries. (Of course phone numbers/addresses must first be easy to find!) A contact form requires a web server to actually do something &#8211; ie send you an email &#8211; it&#8217;s not just displaying HTML [...]]]></description>
			<content:encoded><![CDATA[<p>Websites are a point of contact &#8211; and a contact form that sends an email is the way to normally handle enquiries. (Of course phone numbers/addresses must first be easy to find!) A contact form requires a web server to actually do something &#8211; ie send you an email &#8211; it&#8217;s not just displaying HTML code anymore. There&#8217;s options to get by without a script on your server &#8211; the excellent <a title="WuFoo Woo Forms online iFrame forms service" href="http://wufoo.com/" target="_blank">WuFoo</a> online form builder is a great option here &#8211; but if you want a form as part of your page that you can style yourself it ain&#8217;t the ticket. So, knowing a little PHP, a PHP script is sought that:</p>
<ol>
<li>makes sure all input is cleaned and sanitized to avoid nasty things being done on/to your server</li>
<li>checks for errors in the data without discarding the well formed data</li>
<li>uses some form of <a href="http://en.wikipedia.org/wiki/CAPTCHA" target="_blank">CAPTCHA</a> to keep those spam bots at bay</li>
<li>sends email through an authorised SMTP email account (Gmail, for example, will either mark as spam or simply not accept mail that isn&#8217;t)</li>
</ol>
<p>Other nice things to consider would be nice, cross-browser <a title="HTML5 forms placeholder text" href="http://diveintohtml5.org/forms.html#placeholder" target="_blank">(HTML5) placeholder text</a> (that doesn&#8217;t get submitted).</p>
<h2>Finding a PHP web form framework</h2>
<p>Last time I set up a form was a while ago &#8211; I&#8217;ve been doing mostly WordPress sites (or other CMS work) recently and have found the premium <a title="Premium WordPress form plugin" href="http://www.gravityforms.com/" target="_blank">Gravity forms</a> plugin for WordPress to work a treat. Anyway, cut to the chase already&#8230; the old script I had used  failed on points 3 &amp; 4 above I&#8217;d like to say I can lean on <a href="http://pear.php.net/" target="_blank">PEAR PHP</a> (which is already on my webserver) but I&#8217;m really not a programmer. I found a solution in the excellent <a title="PHP form script" href="http://www.dagondesign.com/articles/secure-php-form-mailer-script/" target="_blank">PHP form &#8220;library&#8221; from Dagon Design</a>. I&#8217;d never heard off it but it&#8217;s the first serious result for &#8220;PHP form script&#8221; in Google at the moment &#8211; so it  must at least be popular. More importantly it ticks all the boxes above (plus much more) and is well documented. Go <a title="donationware PHP form script download " href="http://www.dagondesign.com/articles/secure-php-form-mailer-script/#download" target="_blank">get it</a>. The only thing it doesn&#8217;t do is verify numerical input.</p>
<p>There&#8217;s no need for me to go into the setup at all &#8211; it is very well documented &#8211; just spend a half hour or so to read through it.</p>
<h2>Adding placeholder text to the form framework</h2>
<p>All I have to add is that I&#8217;ve edited the script a bit to set default text as HTML5 placeholder text (and remove default text from text inputs). The form is run in conjunction with Daniel Stocks&#8217; <a title="jQuery HTML5 placeholder pugin" href="http://github.com/danielstocks/jQuery-Placeholder" target="_blank">HTML5 Placeholder Plugin</a> for jQuery to make sure that the placeholder text works with IE etc.</p>
<p>To get the placeholder text working I changed the last few lines of the  below (from 754):</p>
<pre class="brush: php; first-line: 742; title: ; notranslate">
function ddfm_gen_text($item) {

	// type=text|class=|label=|fieldname=|max=|req=(TRUEFALSE)|[ver=]|[default=]

	global $form_submitted, $form_input, $show_required;

	$req_text = (($show_required) &amp;&amp; ($item['req'] == 'true')) ? '&lt;span class=&quot;required&quot;&gt;' . DDFM_REQUIREDTAG . '&lt;/span&gt; ' : '';

	$gen = &quot;&quot;;
	$gen .= '&lt;p class=&quot;fieldwrap&quot;&gt;&lt;label for=&quot;' . $item['fieldname'] . '&quot;&gt;' . $req_text . $item['label'] . '&lt;/label&gt;';
	$gen .= '&lt;input class=&quot;' . $item['class'] . '&quot; type=&quot;text&quot; name=&quot;' . $item['fieldname'] . '&quot; id=&quot;' . $item['fieldname'] . '&quot; value=&quot;';

	if ($form_submitted) {
		$gen .= ddfm_bsafe($form_input[$item['fieldname']]);
	} else if (isset($item['default'])) {
		$gen .= ddfm_bsafe($item['default']);
	}

	$gen .= '&quot; /&gt;&lt;/p&gt;' . &quot;\n\n&quot;;

	return $gen;
}
</pre>
<p>to:</p>
<pre class="brush: php; first-line: 754; title: ; notranslate">
	if ($form_submitted) {
		$gen .= ddfm_bsafe($form_input[$item['fieldname']]);
	}

	$gen .= '&quot; placeholder=&quot;' . ddfm_bsafe($item['default']) . '&quot; /&gt;&lt;/p&gt;' . &quot;\n\n&quot;;

	return $gen;
</pre>
<p>So what&#8217;s all the fuss about &#8211; well you can see the version I worked on, in action, as part of  a website for this <a title="Fuengirola hair salon" href="http://besohair.com/make.php" target="_blank">fancy (in the good sense) hair salon in Fuengirola</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-09-24/php-web-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rotating Twitter Tweet feed in WordPress</title>
		<link>http://www.lazydada.com/2010-06-12/rotating-twitter-tweet-feed-in-wordpress/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rotating-twitter-tweet-feed-in-wordpress</link>
		<comments>http://www.lazydada.com/2010-06-12/rotating-twitter-tweet-feed-in-wordpress/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 17:04:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=735</guid>
		<description><![CDATA[Again, this is for one my current projects: my mate Phil&#8217;s digital DJ tips site&#8230; OK &#8211; so there&#8217;s loads of plugin&#8217;s out there that do this kind of thing but I&#8217;m not after anything fancy (or bloated), I&#8217;m happy to code this into the theme files with a bit of PHP and well &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Again, this is for one my current projects: my mate Phil&#8217;s <a title="digital DJing advice and reviews" rel="friend met" href="http://www.digitaldjtips.com/">digital DJ tips</a> site&#8230;</p>
<p>OK &#8211; so there&#8217;s loads of plugin&#8217;s out there that do this kind of thing but I&#8217;m not after anything fancy (or bloated), I&#8217;m happy to code this into the theme files with a bit of PHP and well &#8211; it&#8217;s something slightly new to learn &#8230;</p>
<p>Primary requirements:</p>
<ul>
<li>We want this thing to use the <a href="http://simplepie.org/">SimplePie</a> feed parser and cacheing system, as already included with a standard WordPress install. This will copy the latest tweets into WordPress and avoid running-off to bother Twitter every time our WP site gets a visit. This will also make the thing more robust as Twitter does occasionally&#8230; fail.</li>
<li>A raw Twitter feed will include your user name at the beginning of each tweet. This unnecessary when the blog and tweets are from the same person/identity/brand so we&#8217;ll need to remove that.</li>
<li>We need the SimplePie cache to expire fairly regularly &#8211;  not enough to bust Twitter&#8217;s balls with extra requests &#8211; but enough to keep the tweets fresh</li>
<li>We may want to trim the tweets (yes even less than 140 characters!) so they fit on one line without having the set an explicit width or css &#8220;overflow:hidden;&#8221;. [This is a graphic design call here as I like backgrounds fills to match the variable length of text (inline) rather than be fixed-width with trailing whitespace of block level element - makes each tweet look like the unique thing it is.]</li>
<li>Once this is done it goes into a simple carousel to rotate through the last x tweets.</li>
</ul>
<p>The code comes in a couple of pieces:</p>
<h3>The main engine: get the twitter feed &#8211; pack it up and process it.</h3>
<p>I put the following into an include file to keep it all wrapped together for easy access. This code mostly based on the excellent WordPress codex article &#8220;<a href="http://codex.wordpress.org/Function_Reference/fetch_feed">Function Reference/fetch feed</a>&#8220;. The String replace reference came from the classic <a href="http://www.tizag.com/phpT/php-string-str_replace.php">tizag PHP guide</a> and the shorten to the nearest whole word came from somewhere else</p>
<pre class="brush: php; title: ; notranslate">
	&lt;?php
	// Get RSS Feed(s)
	include_once(ABSPATH . WPINC . '/feed.php');

	// Get a SimplePie feed object from the specified feed source. CHANGE THE USER ID BELOW!
	$rss = fetch_feed('http://twitter.com/statuses/user_timeline/126881491.rss');
	if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
	    // Figure out how many total items there are, but limit it to 5.
	    $maxitems = $rss-&gt;get_item_quantity(5);

	    // Build an array of all the items, starting with element 0 (first element).
	    $rss_items = $rss-&gt;get_items(0, $maxitems);
	endif;

	// shorten string function
	function short_str( $str, $len, $cut = true ) {
	    if ( strlen( $str ) &lt;= $len ) return $str;

	    return ( $cut ? substr( $str, 0, $len ) : substr( $str, 0, strrpos( substr( $str, 0, $len ), ' ' ) ) ) . '...';
	}
	?&gt;

&lt;div id=&quot;djt-twitter-feed&quot;&gt;&lt;!-- djt classes and ID to be replaced by something that is useful to you --&gt;
	&lt;ul id=&quot;djt-tweets&quot; class=&quot;jcarousel-skin&quot;&gt;
	    &lt;?php if ($maxitems == 0) echo '&lt;li&gt;No tweets!&lt;/li&gt;';
	    else
	    // Loop through each feed item and display each item as a hyperlink.
	    foreach ( $rss_items as $item ) : ?&gt;
	    &lt;li class=&quot;cfn&quot;&gt;
	        &lt;span&gt;&lt;a href='&lt;?php echo $item-&gt;get_permalink(); //or hardcode link to Twitter homepage ?&gt;'
	        title='&lt;?php echo 'Posted '.$item-&gt;get_date('j F Y | g:i a'); ?&gt;'&gt;
	        &lt;?php //get tweets (but remove twitter ID before displaying)
	        	$djt_twitter_tweet = $item-&gt;get_title();
	        	$djt_twitter_tweet = str_replace(&quot;YourTwitterUsername: &quot;, &quot;&quot;, $djt_twitter_tweet) ;
	        	echo short_str( $djt_twitter_tweet , 140, false) //OK - not actually doing any shortening with this line now ;
	        ?&gt;&lt;/a&gt;&lt;/span&gt;
	    &lt;/li&gt;
	    &lt;?php endforeach; ?&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<h3>Set the cache expiry in functions.php</h3>
<pre class="brush: php; title: ; notranslate">
// Alter expiry lenght on feeds (set in seconds)
add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 480;') );
</pre>
<h3>Finally make it pretty with jCarousel</h3>
<p>The idea was to have one tweet visible at a time &#8211; scrolling/rotating through the list. Grab your copy of <a href="http://sorgalla.com/projects/jcarousel/">jCarousel</a> (it&#8217;s much bigger than <a href="http://www.gmarwaha.com/jquery/jcarousellite/">jCarousel lite</a> but by the time I&#8217;d figured out the <a href="http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/">trouble with my </a><code><a href="http://www.lazydada.com/2010-06-12/wordpress-jquery-conflict-solved/">wp_head()</a></code> it was time to leave well enough alone. To be revisited when there&#8217;s some time to optimize.) I&#8217;ll not go into the CSS &#8211; that&#8217;s there online.</p>
<pre class="brush: xml; title: ; notranslate">
	&lt;!-- jCarousel --&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;

	function mycarousel_initCallback(carousel) { };

	jQuery(document).ready(function() {
	    jQuery('#djt-tweets').jcarousel({
	        auto: 8,
	        wrap: 'last',
	        vertical: false,
	        scroll: 1,
	        animation: 0,
	        initCallback: mycarousel_initCallback
	    });
	});
	&lt;/script&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-06-12/rotating-twitter-tweet-feed-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Long/short headings (or title tags) using WordPress Custom Fields</title>
		<link>http://www.lazydada.com/2010-05-19/longshort-headings-or-title-tags-using-wordpress-custom-fields/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=longshort-headings-or-title-tags-using-wordpress-custom-fields</link>
		<comments>http://www.lazydada.com/2010-05-19/longshort-headings-or-title-tags-using-wordpress-custom-fields/#comments</comments>
		<pubDate>Wed, 19 May 2010 11:24:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=698</guid>
		<description><![CDATA[[ This post is now largely if not entirely redundant now thanks to WordPress 3 menu options ] Problem: WP titles are too long to fit in your navigation. Solution: Make the title short enough to fit in the navigation and then add a Custom Field into your post (in the example bellow it is [...]]]></description>
			<content:encoded><![CDATA[<p>[ This post is now largely if not entirely redundant now thanks to WordPress 3 menu options ]</p>
<h4>Problem: WP titles are too long to fit in your navigation.</h4>
<h4>Solution:</h4>
<p>Make the title short enough to fit in the navigation and then add a Custom Field into your post (in the example bellow it is set as &#8220;heading&#8221;) then edit your template file to render the longer version (&#8220;heading&#8221;) on the page.</p>
<h4>Example:</h4>
<p>In the Loop of  your template swap out</p>
<pre class="phpcode">&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;</pre>
<p>for:</p>
<pre class="phpcode">&lt;h1&gt;&lt;?php// If has a custom field of heading ; then use that:
$customField = get_post_custom_values("heading");
if (isset($customField[0])) {
echo $customField[0];
} else {
the_title();
} ; ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;</pre>
<p>Hat-tip: <a href="http://www.smashingmagazine.com/2009/05/13/10-custom-fields-hacks-for-wordpress/" target="_blank">Smashing Magazine</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-05-19/longshort-headings-or-title-tags-using-wordpress-custom-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Include an HTML file in a PHP variable</title>
		<link>http://www.lazydada.com/2010-05-12/include-an-html-file-in-a-php-variable/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=include-an-html-file-in-a-php-variable</link>
		<comments>http://www.lazydada.com/2010-05-12/include-an-html-file-in-a-php-variable/#comments</comments>
		<pubDate>Wed, 12 May 2010 09:38:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web design & development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lazydada.com/?p=663</guid>
		<description><![CDATA[I couldn&#8217;t get PHP to accept an HTML file include as the definition of a variable without throwing my templated page into disarray.  An answer came from the venerable desilva then checked with the php folk; use output  buffering (see example six in that last link): &#60;?php $string = get_include_contents('somefile.php'); function get_include_contents($filename) { if (is_file($filename)) { ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); return $contents; } [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t get PHP to accept an HTML file include as the definition of a variable without throwing my templated page into disarray.  An answer came from the <a href="http://www.desilva.biz/php/ob_start.html" target="_blank">venerable desilva</a> then checked with <a href="http://php.net/manual/en/function.include.php">the php folk</a>; use output  buffering (see example six in that last link):</p>
<pre class="phpcode">&lt;?php
$string = get_include_contents('somefile.php');

function get_include_contents($filename) {
 if (is_file($filename)) {
 ob_start();
 include $filename;
 $contents = ob_get_contents();
 ob_end_clean();
 return $contents;
 }
 return false;
}

?&gt;</pre>
<p>Also worth a look: <tt><a href="http://es2.php.net/manual/en/function.file-get-contents.php">file_get_contents</a></tt></p>
<p>Why? Because <a title="Text editor and web development in one window for Mac" href="http://www.panic.com/coda/" target="_blank">Coda</a>, my favourite Macintosh text editor+,  doesn&#8217;t do syntax highlighting of HTML for a PHP string. The site I&#8217;ve just finished for a <a title="Villa Mirador - large exclusive villa in marbella" href="http://www.villamiradormarbella.com/" target="_blank">high-end luxury villa in Marbella</a> I had a big block of HTML to include (and work on) for the images page&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazydada.com/2010-05-12/include-an-html-file-in-a-php-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
