Archive for November, 2012

Lemonstand simple display product list from category

I quite often get asked how to achieve this easily by friends and colleagues and in there defence it’s not ‘clearly’ documented. So I thought i’d knock something up really quickly to show you how it can be done.

In this example I create a category called ‘Featured’ and I importantly set the ‘API code’ for this category to ‘featured’. This is found at the very bottom of the category creation / edit page.

I want to pull in some featured products into my homepage so I dive into the CMS and pull up the homepage.

You’ll want to enter the below snippet into the template.

<?
$category = Shop_Category::create()->find_by_code('featured');
$this->render_partial('shop:product_list', array(
    'products'=>$category->list_products()->find_all()
)) ?>

This snippet first fetches the correct category object and then renders a partial called shop:product_list (or shop;product_list.htm if you use template based files) with all of the products under this category.

Now you just need to make your partial and add some basic code to it.

I’m not going to dive into the full extent of what you can now do with the below code but just get you on your way.

In your shop:product_list partial add the following code:

<ul>
<? foreach ($products as $product): ?>
<li>
<h3><a href="<?=  $product->page_url('/product') ?>"><?= h($product->name) ?></a></h3>
<p><?= h($product->short_description) ?></p>
</li>
<? endforeach ?>
</ul>

And that’s all there is to it. You’ll now be getting a list of all the products in this category on your homepage. Of course it is also worth noting you could use this same partial in many places across your site. It’s use will probably largely depend on how heavily uniform or customised the section on your site is.

Hope this is of some use.

Linode – My early impressions

linode logo gray Linode   My early impressionsFor quite sometime now i’ve been looking for a place to house my personal projects, which gives me the flexibility of a cloud style host but with full root access so that I may toy around with installing whatever I need.

Linode offers the ability to deploy Linux virtual servers in the Linode cloud. With it’s simple Stackscripts for quick deployment of LAMP or LEMP server stacks. You can also deploy Stackscripts with popular open source CMS WordPress, CMS Drupal and even a Minecraft multiplayer server in a few clicks.

Check out some of the awesome Stackscripts on Linode – http://www.linode.com/stackscripts/

Linode might not be the cheapest cloud based VPS you’ll find, but with it’s basic package starting at just $19.99 a mere £12 p/month it’s still pretty in-expensive.

I deployed the WordPress and Ubuntu Stackscript from Linode in a few minutes then successfully setup vhosting and my WordPress sites in not a great deal longer. So far my Linode has 16 days of uptime. Running this very blog icon smile Linode   My early impressions (amongst others)

This blog is running on an Ubuntu LAMP stack, with WordPress (Version 3.4.2 at the time of writing), fine tuned with WP Super Cache and CDN Sync Tool for fast static content delivery. It’s also fully responsive icon wink Linode   My early impressions buzzzwwooorrdddds.

One thing I have noticed since deploying my Linode is the fantastic community behind it. Unlike other alternatives, i’ve noticed Linode has an extremely knowledgeable and loyal following of fellow mostly friendly and happy to help Linux server enthusiasts. Linode has some excellent tutorials and help guides coupled with an excellent IRC channel which is almost always buzzing.

I’m so far very impressed with Linode and in comparison to AWS it provides a combination of cloud, community, help and control at a good price. AWS micro instances are cheap at about £10 p/m but do not offer guaranteed resources, where as Linode does. I also kept getting MySQL crashes on my AWS instance.

Linode even offers a generous 7 day money back guarantee.

Get latest 3 tweets from twitter

Just blogging this for future reference. It’s useful to grab twitter status’s asynchronously. But does not provide any niceties like nice formatting of dates or hashtag links etc. On the flip side it does give you ultimate flexibility to play with the data as you will.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
var url = 'http://api.twitter.com/1/statuses/user_timeline/daveheward.json?count=3&include_rts=1&callback=?';
$.ajax({
    url: url,
    dataType: 'json',
    async: false,
    success: function(json){
        $.each(json, function(index, value){
            //console.log(value);
            $("#twitter_update_list").append(value.text+'<br>');
        });
    }
});
</script>