Free Android CakePHP GMaps Articles by Bali Web Design

Google

September 4, 2010

How to redirect wordpress blog url cakephp

Filed under: cakephp, php, wordpress — admin @ 7:15 pm

Cakephp have great routing capability, i was install wordpress blog on my main website root directory. And then i need to move my blog into new folder, i put it on /app/webroot/blog/ because i build new web application on root directory using cakephp.

I use rewriting rule for my wordpress blog. The rule is http://www.balistupa.com/year/month/slug/. I want to redirect into http://www.balistupa.com/blog/year/month/slug/. I don’t want to loose my blog visitors because the blog posting has good ranking on google.

So i do setting on app/config/routes.php and add this line

Router::connect(’/:year/:month/:slug’, array(’controller’ => ‘pages’, ‘action’ => ‘redirect_blog’), array(’pass’ => array(’year’, ‘month’, ’slug’), ‘year’ => ‘[0-9]{4}’, ‘month’ => ‘[0-9]{2}’, ’slug’ => ‘[A-Za-z0-9-]+’));

(more…)

August 2, 2010

How to redirect /app/webroot/blog/ into /blog/ Wordpress Cakephp

Filed under: cakephp, php, wordpress — admin @ 8:16 pm

At this time, a company website normally should have blog to post some business activity or related activity with website themes. Wordpress is the best blog framework (CMS) that i ever used. When i was build web application under my own php framework, i wasn’t worried about integrating wordpress into my website. It would has separated setting with main application.

However, now i am using cakephp framework. And if we need to put file or folder, it need to be put inside app/webroot folder. So if i need to install wordpress blog in http://www.balistupa.com/blog, i need to put the blog folder inside /app/webroot/.

The problem is about the url, with standard setting the blog would be redirected to http://www.balistupa.com/app/webroot/blog/ not to http://www.balistupa.com/blog/. This is not look good for visitor and also for seo. Because the folder structure is to deep.

(more…)

August 19, 2009

How to do GROUP BY HAVING in CakePHP

Filed under: cakephp, php — admin @ 11:23 pm

Before June 2008, there is no clean implementation for GROUP BY. commonly people code with CakePHP will put GROUP BY sintak on conditions, something like this

$this->Product->find(’all’, array(‘conditions’ => ‘1=1 GROUP BY Product.category_id’));

Now CakePhp have a clean sintak for GROUP BY by new additional paramater on find function. We can use ‘group’ to define GROUP BY on cakephp. For example

$this->Product->find(’all’, array(’fields’ => array(’Product.category_id’, ‘COUNT(Product.hotel_id) as total’), ‘group‘ => array(’Product.category_id’)));

How if we want to have HAVING sintak on query? i ussually use this solution for new cakephp

$this->Product->find(’all’, array(’fields’ => array(’Product.category_id’, ‘COUNT(Product.hotel_id) as total’), ‘group’ => array(’Product.category_id HAVING COUNT(Product.hotel_id) > 1′)));