andrw.net
  • Home
  • Code
  • Work
  • About
  • Contact
  • Subscribe
CakePHP Toronto Meetup
thumb

Tonight we held Toronto's first CakePHP meetup (or so we think). I did a talk on RESTful web development with CakePHP and demoed building a RESTful application with CakePHP and consuming the REST...

Read More...

New Croogo Theme for Download: Simple

30 Comments
Posted by Andrew on November 17th 2009, 9:17am

Update: September 4th, 2010

I have released this theme for Croogo 1.3.2 and should be forward compatible. Please comment on the new post for questions and problems.

http://andrw.net/blog/simple-theme-released-for-croogo-132

Here it is. My first theme release for Croogo. Not sure how many people out there are using Croogo yet but it's showing a lot of potential and it's especially good news if you are already a CakePHP developer. Ensure that you read the README file included in the archive as it explains how to get things like full text searching and the tag cloud working. 

Simple: Croogo Theme

I already have a few ideas for my second theme so stay tuned and as always if you have any questions drop me a line in the comments.

Preview: Simple Croogo Theme

Last Updated: September 4th 2010, 10:27am

Download: Simple Croogo Theme

Bookmark and Share
Tags: • themes • croogo • development • design
Posted in Themes, Croogo | 30 Comments

New Croogo Theme Preview

8 Comments
Posted by Andrew on November 16th 2009, 10:30pm

Update November 17th

You can now test out the theme above by clicking here. If you want to go back to the normal theme just head back to this post and click here, or end you browsing session.

Original Post

This is a preview of the new theme I am working on for the Croogo CMS. It should be released some time within the next week or so. I will be releasing it for free and it can be used for any type of personal or commercial project. It will include search functionality and tag clouds similar to the current implementation on my site.

Croogo Theme

Let me know what you think and if you would like to see some changes leave a comment and I will try and implement them.

Bookmark and Share
Tags: • themes • croogo • design
Posted in Croogo, Design | 8 Comments

Croogo Tip: After Adding New Actions, Refresh ACL Permissions

2 Comments
Posted by Andrew on November 16th 2009, 6:41pm

Recently I have been adding new features to my site (search, tag cloud) that involved adding new actions. Little did I know that the default ACL permissions use a whitelist instead of a blacklist meaning that all new actions by default will not be publicly avaiable.

When you add a new action to Croogo make sure you log in to your admin panel, go to Users > Permissions and then click on the "Generate Actions" button. This will generate all of the actions in your controllers and allow you to set the correct permissions for your new actions.

Bookmark and Share
Tags: • development • cakephp • croogo
Posted in Croogo | 2 Comments

Adding Full Text Search to Croogo

0 Comments
Posted by Andrew on November 16th 2009, 4:18am

I just launched full text search on my blog. I am sure that this is something planned for the future of Croogo but I wanted some to add search functionality and not have to wait. Once I figure out Git/Github I will fork the main project and get some of my additions up there.

Adding full text searching is actually quite easy. I limited it to searching the title and the body of the posts and only allowed searching of blog posts. Below is the code I used. This goes in the nodes controller.

function search () {
// Import sanitize library
App::import('Core', array('Sanitize'));

$query = mysql_escape_string(Sanitize::html($this->params['url']['q']));

$this->paginate['Node']['order'] = 'Node.id DESC';
$this->paginate['Node']['limit'] = Configure::read('Reading.nodes_per_page');
$this->paginate['Node']['conditions'] = array(
'Node.type' => 'blog',
'Node.status' => 1,
"MATCH(Node.title, Node.body) AGAINST('{$query}' IN BOOLEAN MODE)"
);
$this->paginate['Node']['contain'] = array(
'User',
'Meta',
'Comment',
'Term' => array('Vocabulary')
);

$this->Node->recursive = 0;
$this->set('nodes', $this->paginate());
$this->set('q', $query);
$this->set('title', "Search results for {$query}");
}

Now all that's needed is a form that will request the search action in the nodes controller and a search template to display your search results. For my form I used the "GET" method. In my search template I used the text helper to highlight the search term and also show an excerpt instead of the full post as shown below.

<p><?=$text->highlight($text->excerpt(strip_tags($this->element('node_body', array('node' => $node))), $q, 200, '...'), $q)?></p>

As usual if you have any questions leave a comment and I should get back to you shortly.

Update November 19th

Croogo Full Text Search

Bookmark and Share
Tags: • croogo • cakephp • development
Posted in Croogo | Leave a comment

Creating Featured Posts for Croogo CMS

1 Comments
Posted by Andrew on November 15th 2009, 7:02am

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.

Bookmark and Share
Tags: • croogo • tutorial • cakephp • development
Posted in Croogo | 1 Comment
1 | 2 | 3 | 4 | 5

Tweet, Tweet, Tweet

Please wait while my tweets load  

Follow @andruu on Twitter.

Tags

design   development   cakephp   news   tutorial   hong kong   icons   iphone   croogo   themes   mozilla   django   javascript   plugin  

Categories

  • CakePHP
  • Croogo
  • Design
  • Site News
  • Themes
  • Travel
  • Uncategorized

Archives

  • October 2011
  • November 2010
  • September 2010
  • January 2010
  • December 2009
  • November 2009

Affiliate Marketing Made Easy

Blogroll

  • CakePHP
  • Croogo
  • Matt Curry
  • Debuggable
  • Mark Story
  • Miles Johnson
  • Fahad Ibnay Heylaal

Meta

  • Site Admin
  • Entries (RSS)
  • Comments (RSS)
Copyright © 2012 Andrew Weir, All Rights Reserved.
Powered by Croogo, Built with CakePHP.