<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>UNIQUEsite.co.uk</title>
<link>http://www.uniquesite.co.uk</link>
<description>Latest news and updates from UNIQUEsite.co.uk</description>
<pubDate>Wed, 11 Nov 2009 13:09:06 +0000</pubDate>
<atom:link href="http://www.uniquesite.co.uk/feed.xml" rel="self" type="application/rss+xml" />
<item>
<title>To Wordpress or not to Wordpress?</title>
<link>http://www.uniquesite.co.uk?page=1#blog</link>
<description>I am undecided about relying on products like wordpress to heavily in website design. Don&#039;t get me wrong, wordpress is a great product, it is powerful, efficient, well designed and modular. But I&#039;m seeing an increasing number of websites that all look essentially the same, as they are just adjusted versions of wordpress blogs.<br /><br />With Laura&#039;s website at www.laura-jane-evans.com I wanted to leverage the features of wordpress, whilst freeing myself from the design constraints. I could have created a theme for wordpress and achieved an incredibly similar result, but, being stubborn, I wanted to try creating a website outside of wordpress and then &amp;quot;plugging in&amp;quot; to it.<br /><br />The essential code to include on your page is<br /><pre>&amp;lt;?PHP<br />define(&#039;WP_USE_THEMES&#039;, false);<br />require(&#039;wordpress/wp-blog-header.php&#039;);<br />?&amp;gt;</pre><br />From this point, you can include all your usual tags such as  wp_list_categories and the statement<br /><pre>&amp;lt;?PHP while (have_posts()) : the_post(); ?&amp;gt;<br />...<br />&amp;lt;?PHP endwhile; ?&amp;gt;</pre><br />I used the mod_rewrite statement in a .htaccess file to point each page to my index.php which did all the work.<br /><pre>&amp;lt;IfModule mod_rewrite.c&amp;gt;<br />RewriteEngine On<br />RewriteCond %{REQUEST_FILENAME} !-f<br />RewriteCond %{REQUEST_FILENAME} !-d<br />RewriteRule . index.php [L]<br />&amp;lt;/IfModule&amp;gt;</pre><br />This means that any request that isn&#039;t a file or folder on the server will just load index.php.<br /><br />If my wordpress &amp;quot;blog address&amp;quot; is configured to /blog, a link to /blog/?p=123 will load that post. Or it can be made prettier by changing your <a href="http://codex.wordpress.org/Using_Permalinks">permalink settings</a>.<br /><br />I know it seems like a lot of work to achieve something simple, but I feel it gave me the freedom to create my own site design, with a seamless integration of the wordpress blog. It could even be used to include a blog in an existing site without major changes.</description>
<pubDate>Wed, 11 Nov 2009 12:22:30 +0000</pubDate>
<guid>http://www.uniquesite.co.uk?page=1&amp;id=3#blog</guid>
</item>
<item>
<title>&quot;Read More&quot; Javascript Technique</title>
<link>http://www.uniquesite.co.uk?page=1#blog</link>
<description>For my blog, I wished for people to be able to begin reading an article before delving into the entire entry, especially for longer posts. This is a common technique, resulting in a &amp;quot;Read More&amp;quot; link after a set number of characters. The only difference here, is the rest of the article loads into the same page, it was simply hidden, and is revealed by javascript.<br /><br />The script for determining where to place the read more link was taken from <a href="http://snipplr.com/view/10426/php-get-first-characters-of-string-in-complete-sentences/">Snipplr</a> and cuts text off after a given number of charaters, but tries to keep whole sentences intact (it looks much nicer).<br /><br />I altered the function to include the read more text:<br /><pre>function trimText($intLength, $strText) {<br />	// Find last fullstop in $strText before $intLength characters.<br />	$intLastPeriodPos = strpos(strrev(substr($strText, 0, $intLength)), &amp;quot;.&amp;quot;);<br />	// If no fullstops, trim until $intLength characters.<br />	if ($intLastPeriodPos === false) {<br />		$intLastPeriodPos = 0;<br />	}<br />	// Shorten the text...<br />	$strReturn = substr($strText, 0, ($intLength - $intLastPeriodPos));<br />	// ...create the link...<br />	$strReturn .= &amp;quot;&amp;lt;a href=&#039;#&#039; class=&#039;readmore&#039;&amp;gt;Read more...&amp;lt;/a&amp;gt;&amp;quot;;<br />	// ...and put the remaining text in a hidden span.<br />	$strReturn .= &amp;quot;&amp;lt;span class=&#039;hidden&#039;&amp;gt;&amp;quot; . substr($strText, ($intLength - $intLastPeriodPos)) . &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;;<br />	return $strReturn;<br />}</pre><br />Whenever you want to shorten some text, simply write:<br /><pre>if (strlen($textToBeReplaced) &amp;gt; 300) {<br />	$articleText = trimText(300, $articleText);<br />}<br />echo $articleText;</pre><br />This hides the last text (a sentence just before 300 characters), and creates the link, but what about showing it again? Simple Javascript is all that is needed (with the help of <a href="http://jquery.com">jQuery</a>).<br /><br />The Javascript looks like this:<br /><pre>$(document).ready(function() {<br />	$(&amp;quot;.readmore&amp;quot;).click(function() {<br />		// Hide the link.<br />		$(this).hide();<br />		// Fade in the remaining text.<br />		$(this).next().fadeIn();<br />		return false;<br />	});<br />});</pre><br />That is essentially all there is to it, and I&#039;m pleased with the outcome. It creates an article that is just an overview, but can easily be expanded without waiting for anything to load.<br /><br />Don&#039;t forget you don&#039;t want to handicap non-javascript visitors, so make sure the hidden spans are only hidden via javascript. I didn&#039;t show this above in order to simplify the code.</description>
<pubDate>Wed, 30 Sep 2009 12:38:56 +0100</pubDate>
<guid>http://www.uniquesite.co.uk?page=1&amp;id=2#blog</guid>
</item>
<item>
<title>Welcome</title>
<link>http://www.uniquesite.co.uk?page=1#blog</link>
<description>I decided it was time I added a blog to my website, so I can let people know what I&#039;m up to, and hopefully offer some advice to other website designers. I hope to update this on a regular basis, so stay tuned!</description>
<pubDate>Wed, 30 Sep 2009 03:11:29 -0500</pubDate>
<guid>http://www.uniquesite.co.uk?page=1&amp;id=1#blog</guid>
</item>
</channel>
</rss>
