Not sure how many people are still around these parts. I woudn't be surprised if I am writing this to myself. I've neglected this blog for a long time now and most of the content isn't relevent to...
Creating Featured Posts for Croogo CMS
In this post I will describe how I created the featured post on the home page of my blog with Croogo. Looking at the database schema I noticed that there was a column named "sticky" that was not being utilized anywhere in the code so I thought that it would be a good place to store whether a post was featured or not. The first thing I did was edit the admin add and edit views to allow me to mark posts as featured under the publishing tab.
<div id="node-publishing">
<?php
echo $form->input('sticky', array('label' => __('Featured', true)));
echo $form->input('status', array('label' => __('Published', true)));
echo $form->input('promote', array('label' => __('Promoted to front page', true)));
echo $form->input('created');
?>
</div>
All I did here was add one line that will display a checkbox similar to the published and promoted checkboxes. The next thing I had to do was retrieve the latest featured post from the database. I did this in the nodes controller under the promoted action since this is the default home page for Croogo.
$featured = $this->Node->find('first', array(
'order' => 'Node.created DESC',
'conditions' => array('Node.sticky' => true)
));
$this->set('featured', $featured);
This just finds the first post marked as featured, ordered by the created date. I then set a variable for the view so that I can access this featured post in my view. The next step was displaying the featured post. For this I created a "featured" element and rendered it in the layout template if the current action was "promoted".
<? if ($this->action == 'promoted') : ?>
<?=$this->element('featured')?>
<? endif ?>
Inside of featured.ctp in the elements directory.
<p><?=$html->link($featured['Node']['title'], $featured['Node']['url'], array('class' => 'link'))?><p>
<p><?=$text->trim(strip_tags($featured['Node']['body']), 200, '...', false, true)?></p>
<p><?=$html->link('Read More...', $featured['Node']['url'])?></p>
This is a dumbed down version of what I am using but should still get you started. If you know your way around CakePHP you should be able to understand what is happening. I am using the text helper to show an excerpt from the post body then display a read more link below that will direct the user to the post.
This should be enough to get you started. In my next post I will explain how to use custom fields in your posts. I am using them to display the image beside my featured posts on the home page. If you have any questions leave a comment and I should get back to you shortly.
Hong Kong was a Success
I just got back to Bangkok today from Hong Kong where I spent the last 4 days. I went there with one of my good friends and we had a great time packed with a some hillarious memories. Although I had to spend most of my days working from the hotel room and my friend had to attend business meetings, we still managed to get out and experience the nightlife and view the harbor front. We went to Lan Kwai Fong to check out a few clubs and met some interesting people while we ate and went shopping around Kowloon. Big shout out to DJ Benny K and the whole crew at Fevar nightclub. Below are some photos of the harbor front and around Hong Kong.
I hope to post some CakePHP and Croogo posts later on this week so stay tuned.
My First Attempt at iPhone Icons
I made these a while ago in an attempt to create a theme for my iPhone. I think they came out OK for my first try. I am working on a group of icons for a project that I am working on at the moment and will post those once they are complete.

Let me know what you think.
Heading to Hong Kong Tomorrow
Living in Thailand requires a new visa every 30-90 days if you do not have a work permit or permanent residence. While working here I had a work permit and applied for 1 year visas during my employment. Now that I am still living here but doing freelance I need to leave the country every 30 days. I usually travel to Singapore due to the cheap air fare and free accommodation (my old roommate lives there) but this time decided to check out Hong Kong.

I have visited Hong Kong a total of 5 times already but my last trip was back in October 2006. I'm excited to touch down again and do some more exploring. I will be staying in Kowloon on the mainland side of Hong Kong this trip.
Welcome to andrw.net
Hello everyone welcome to andrw.net. This is the new home of my personal blog. It is powered by the CakePHP powered CMS Croogo and a fresh theme designed by me. I hope to post some interesting stuff, especially some design & development tips, techniques and tutorials.
I am planning on fixing up this Croogo theme and packaging it up for all the Croogo users out there in the next few days, releasing it for free.
Check out my about page to learn a little bit more about me and if you have any questions leave a comment below or use the contact form on the contact page. Thanks for stopping bye. Don't forget to subscribe to my RSS feed.


