This is my first time using CakePHP.

According to Wikipedia : CakePHP is an open source web application framework for producing web applications.

you can read the rest from here And you can learn CakePHP more from here :!/view/4/Beginning-With-CakePHP.

basically CakePHP is a MVC framework that working in PHP.

This note is made for my personal memo.

I won’t talk a lot about CakePHP definition, so let’s get going to the problem that I have yesterday on my work.

CakePHP is supporting automatic pagination link for it’s page that generated in it’s view.

it’s very helpful for me, but there is a disadvantage from this.

It’s okay using the CakePHP pagination to your site, but if you work on Social Games Platform especially in japan that need you to wrap all your application’s link with the platform’s link rule.

You can read about CakePHP pagination rule from here

According to pagination rule, “Next” and “Prev” link is generated using $paginator->prev() and $paginator->next().

This will be generate html’s link like this :

<a href="<your page>/page:2">  xx </a>

First problem is CakePHP paginator will not passing your GET parameter that you have passed it to url.

You have to make a custom pagination helper for this. For this problem I referencing this blog

First problem solved!

Then the second problem, for social games you need to wrap all your application’s link with the platform’s link rule.

In order to do so, there are some ways.

1) Make custom Route::Connect

This technique is way too dangerous, this will be change your entire application’s link or form that in or out the framework.

2) Edit the generated link using preg_replace

Yeah this technique is most appropriate. I referencing this article for this

but, this reference is not enough to solve the problem. So I made a custom pagination helper for this.

I made my custom regex that will be use to change the href source.

function pagination_url($page_url){
if (env('HTTP_HOST') == 'localhost') {
return $page_url;
$str_tmp = preg_replace('/href=\"(.+)\"/',  'href="http://'.GADGET_SERVER.'/'.APP_ID.'?guid=ON&url='.  urlencode('http://' . env('HTTP_HOST')). '$1"', $page_url);
return $str_tmp;

And in the view page just do like this :

$pagination_helper>pagination_url($paginator->prev('<< Previous  '));

Then the problem solved !!

this problem made me spent my 4 hours working time T_T;

Time to work again, bye! ノシ