Re: Cake 1.3 custom pagination

2015-09-02 Thread Shandy
Kuroi, Can you share your solution once again. As I am facing same sort of 
problem currently.

On Monday, 5 December 2011 12:08:32 UTC, KuroiNeko wrote:
>
> oops. i forgot another one example
>
> http://pastebin.com/R6VqKnS6
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Inserting named parameter for custom pagination route

2013-09-12 Thread Chris White
I'm using the pagination component and would like to use a custom route for 
a prettier URL. At the moment I have a page at /things, and I would like 
the individual pages to be /things/2, /things/3 etc. I'm using the 
following code in my thing controller's action:

public function index() {
$this->set('things', $this->paginate());
}

Then, in my element (which is included into the view for the index action) 
I've got the pagination helper showing number links:

echo $this->Paginator->numbers(array(
'separator' => '',
'tag' => 'li',
'currentTag' => 'a',
'currentClass' => 'active'
));

As that stands, it works perfectly. I can use the page numbers and get the 
correct page. I then tried to add this route to make some pretty page URLs:

Router::connect('/things/:page', array('controller' => 'things', 'action' 
=> 'index'), array('page' => '[0-9]+'));

Now, the pagination helper correctly outputs the pretty URLs, however when 
I click them the page doesn't change even though the URL does. So I end up 
on /things/3 and I'm seeing results for the first page. After a bit of 
digging, I think this is because the named parameter "page" isn't being 
sent as a named parameter. Below is a dump of $this->request->params:

array(
'plugin' => null,
'controller' => 'things',
'action' => 'index',
'named' => array(),
'pass' => array(),
'page' => '2'
)

So, I amended my route like so:

Router::connect('/things/:page', array('controller' => 'things', 'action' 
=> 'index'), array('page' => '[0-9]+', 'named' => array('page')));

But it still only shows the first page of results regardless of what page 
I'm on. What do I need to do to make sure the page parameter is a named 
parameter? I'd rather not fiddle with it in my controller action, but 
rather let the route handle it.

Thank you very much in advance. :)

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How Can I do custom pagination in Cake PHP ?

2011-12-08 Thread McScreech
Here are a few more good discussions:

http://bakery.cakephp.org/articles/AD7six/2006/10/09/pagination
http://www.cakephpforum.net/index.php?showtopic=186
http://www.sakic.net/blog/changing-cakephp-pagination-urls

McS .

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How Can I do custom pagination in Cake PHP ?

2011-12-08 Thread McScreech
Here are a few more good discussions:
http://bakery.cakephp.org/articles/AD7six/2006/10/09/
pagination">
http://www.cakephpforum.net/index.php?showtopic=186";>
http://www.sakic.net/blog/changing-cakephp-pagination-urls/";>
McS

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How Can I do custom pagination in Cake PHP ?

2011-12-06 Thread phpMagpie
as euromark says without more information all we can say is, read the book:
http://book.cakephp.org/view/1237/Custom-Query-Pagination

HTH, Paul.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How Can I do custom pagination in Cake PHP ?

2011-12-06 Thread euromark
what do mean by that?
without more specifics and some code you already tried out nobody will
be able to help you I'm afraid


On 6 Dez., 07:55, Sandip Ghosh  wrote:
> How Can I do custom pagination in Cake PHP ?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


How Can I do custom pagination in Cake PHP ?

2011-12-06 Thread Sandip Ghosh
How Can I do custom pagination in Cake PHP ?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Cake 1.3 custom pagination

2011-12-05 Thread KuroiNeko
oops. i forgot another one example

http://pastebin.com/R6VqKnS6

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Cake 1.3 custom pagination

2011-12-05 Thread KuroiNeko
My friend helped me. He gave me few examples :
http://pastebin.com/2S8Q23YB
http://pastebin.com/KHUrDMJE

In the end, i found that i needed a little different query
both my solutions here :
http://bin.cakephp.org/view/917901050

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Cake 1.3 custom pagination

2011-12-05 Thread AD7six
well, don't be shy - share what you found.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Cake 1.3 custom pagination

2011-12-05 Thread KuroiNeko
Solution was found. Question closed :)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Cake 1.3 custom pagination

2011-12-05 Thread KuroiNeko
Hello. I have the problem with pagination. I need to paginate this
query but i dont know how to do it.

query:

SELECT cmx_posts.title, cmx_rates.name, count(cmx_posts_rates.rate_id)
FROM cmx_posts_rates
   INNER JOIN cmx_rates ON cmx_posts_rates.rate_id = cmx_rates.id
   INNER JOIN cmx_posts ON cmx_posts_rates.post_id = cmx_posts.id
  GROUP BY cmx_posts_rates.post_id,cmx_posts_rates.rate_id

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Custom pagination with plain SQL

2010-06-19 Thread Lucca Mordente
I GOT IT!

After some exhaustive researches I found the solution... And here is
how to paginate a custom query using plain SQL:

in the controller:

 $userQuery = 'user terms';
 $results = $this->paginate(array('conditions'=>array('query'=>
$userQuery')));

the paginate() function:

function paginate($conditions, $fields, $order, $limit, $page = 1,
$recursive = null, $extra = array()) {
$recursive = -1;
$query = $conditions['query']; // the user query
$sql = $this->__generateSearchQuery($query); // made by me to
generate a plain SQL query with UNION to merge many tables
$sql .= ' LIMIT '.$limit.' OFFSET '.(($page-1)*$limit); //
limit and offset must be calculated by you
return $this->query($sql);
}

the paginateCount() function:

function paginateCount($conditions = null, $recursive = 0, $extra
= array()) {
$recursive = -1;
$query = $conditions['query']; // the user query
$sql = $this->__generateSearchQuery($query); // made by me to
generate a plain SQL query with UNION to merge many tables
$sql = 'SELECT count(*) FROM ('.$sql.') as sub';
$count = $this->query($sql);
return $count[0][0]['count'];
}

I'm using PostgreSQL. Syntax may vary for other databases.

Thank you all!
Cheers!



On 15 jun, 14:21, cricket  wrote:
> On Jun 15, 10:17 am, Lucca Mordente  wrote:
>
> > SearchableBehavior seems to be very nice indeed.
>
> > I'd have to create a setup to index the existing data and modify it to
> > match my needs, that which would spend a lot of time.
> > Yes, I'll consider to use this behavior.
>
> > However, I have no enough time to swap right now, facing the time
> > spent creating my own.
>
> > Isn't there a way to use CakePHP paginator to paginate a plain SQL?
>
> I've no experience with that, although i'm sure it's come up before.
> Can it be done? Dunno. This page seems to be at least related:
>
> http://book.cakephp.org/view/249/Custom-Query-Pagination
>
> Make sure to check the comments.
>
> There seems to be a few other pages out there. Google "cakephp
> paginate custom" and see if anything that comes up helps.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-15 Thread cricket
On Jun 15, 10:17 am, Lucca Mordente  wrote:
> SearchableBehavior seems to be very nice indeed.
>
> I'd have to create a setup to index the existing data and modify it to
> match my needs, that which would spend a lot of time.
> Yes, I'll consider to use this behavior.
>
> However, I have no enough time to swap right now, facing the time
> spent creating my own.
>
> Isn't there a way to use CakePHP paginator to paginate a plain SQL?

I've no experience with that, although i'm sure it's come up before.
Can it be done? Dunno. This page seems to be at least related:

http://book.cakephp.org/view/249/Custom-Query-Pagination

Make sure to check the comments.

There seems to be a few other pages out there. Google "cakephp
paginate custom" and see if anything that comes up helps.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-15 Thread Lucca Mordente
SearchableBehavior seems to be very nice indeed.

I'd have to create a setup to index the existing data and modify it to
match my needs, that which would spend a lot of time.
Yes, I'll consider to use this behavior.

However, I have no enough time to swap right now, facing the time
spent creating my own.

Isn't there a way to use CakePHP paginator to paginate a plain SQL?

Thanks!



On 14 jun, 22:19, cricket  wrote:
> On Jun 14, 2:26 pm, Lucca Mordente  wrote:
>
> > The search is performed in about 40 tables.
> > Imagine instantiate 40 models to do this.
> > And I have some other tricks that force me to useplainSQL.
>
> > Any sugestions?
>
> Yes, take a look at the SearchableBehavior I linked to. It'll create
> an index, in a single table, of all your searchable model records.
>
> I think it really should be re-written as a plugin (and I've modified
> it myself in other ways) but it does the job.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-14 Thread cricket
On Jun 14, 2:26 pm, Lucca Mordente  wrote:
> The search is performed in about 40 tables.
> Imagine instantiate 40 models to do this.
> And I have some other tricks that force me to use plain SQL.
>
> Any sugestions?

Yes, take a look at the SearchableBehavior I linked to. It'll create
an index, in a single table, of all your searchable model records.

I think it really should be re-written as a plugin (and I've modified
it myself in other ways) but it does the job.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-14 Thread Lucca Mordente
The search is performed in about 40 tables.
Imagine instantiate 40 models to do this.
And I have some other tricks that force me to use plain SQL.

Any sugestions?

On Jun 12, 8:20 pm, cricket  wrote:
> On Jun 10, 3:34 pm, Lucca Mordente  wrote:
>
> > Hello there
>
> > I have a Search model which uses no database table that makes a
> > fulltext search in some tables using plain SQL.
>
> Have you explored having the model use those tables? Or, you could
> bind to the other model(s) on the fly. Or implement something like
> this, which stores an indexed copy of text data in its own 
> table:http://code.google.com/p/searchable-behaviour-for-cakephp/

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-12 Thread cricket
On Jun 10, 3:34 pm, Lucca Mordente  wrote:
> Hello there
>
> I have a Search model which uses no database table that makes a
> fulltext search in some tables using plain SQL.

Have you explored having the model use those tables? Or, you could
bind to the other model(s) on the fly. Or implement something like
this, which stores an indexed copy of text data in its own table:
http://code.google.com/p/searchable-behaviour-for-cakephp/

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-12 Thread Ed Propsner
Have you checked out the section of the book on custom query pagination?
http://book.cakephp.org/view/1237/Custom-Query-Pagination

Even though in
the end I ended up not using it  I was able to paginate a custom query
working from the examples in the book.

- Ed

On Sat, Jun 12, 2010 at 5:53 PM, Lucca Mordente wrote:

> Anybody?
>
> On 10 jun, 16:34, Lucca Mordente  wrote:
> > Hello there
> >
> > I have a Search model which uses no database table that makes a
> > fulltext search in some tables using plain SQL.
> >
> > How can I paginate the results of a $this->query($plainSQL) call ?
> >
> > Precisely, how do I implement the paginate() method using query()
> > instead of find() ?
> >
> > Thanks!
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Custom pagination with plain SQL

2010-06-12 Thread Lucca Mordente
Anybody?

On 10 jun, 16:34, Lucca Mordente  wrote:
> Hello there
>
> I have a Search model which uses no database table that makes a
> fulltext search in some tables using plain SQL.
>
> How can I paginate the results of a $this->query($plainSQL) call ?
>
> Precisely, how do I implement the paginate() method using query()
> instead of find() ?
>
> Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Custom pagination with plain SQL

2010-06-10 Thread Lucca Mordente
Hello there

I have a Search model which uses no database table that makes a
fulltext search in some tables using plain SQL.

How can I paginate the results of a $this->query($plainSQL) call ?

Precisely, how do I implement the paginate() method using query()
instead of find() ?

Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: create custom pagination from 2 independent models

2010-04-12 Thread dreamingmind
Andrei,

It seems like you should be able to set $uses (http://book.cakephp.org/
view/961/components-helpers-and-uses) to bring both models into a
single controller. From there, just write your action to query the two
models and prep the data for your view.

Regards,
Don

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.


create custom pagination from 2 independent models

2010-04-12 Thread andrei.b
Hello,

I want to paginate the search on 2 independent models(news and
articles).

For example: I want to search for a word "foo" in both news and
articles  tables and I want to return the result from news and
articles table ordered by add date on the same screen.

It is posible?
Can someone give me a hint?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.


Custom Pagination

2008-10-20 Thread si-mon

Hi,
First of all, I am a beginner in cake.
In my application, I need to include pagination, which is in the
style
<>
with AJAX.
In this, the links are properly working.
The problem is, I have to enter a specific page number in the textbox
and I need to directly go to that page.
But, it is not working.
Please let me know how this possible?
Thanks in advance

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: custom pagination url

2007-08-08 Thread hausburger

a hint from felix fixed my problem:

in the view:

options['url']['action'] = '-whatever';
?>




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



custom pagination url

2007-08-08 Thread hausburger

hello.

i defined for some parts of my new project some custom-made urls in
the routes definition, they look like this:

Router::connect('/groups/:group_url/:action/*',array('controller' =>
'groups', 'action' => 'show'));

Example:
http://mywebsite.com/groups/the-name-of-a-group/topic/10/

$this->params['action']  =  topic
$this->params['controller']  =  groups
$this->params['group_url']  =  the-name-of-a-group


in the groups controller:

// show messages that belong to topic

public function topic($id) {

$this->paginate = array(
'limit' => 15,
'page' => 1,
'order' => 
array('GroupMessage.created' => 'asc')
);

$this->set('messages', $this->paginate('GroupMessage',
array('GroupMessage.group_topic_id' => $id)));
}

Everything works fine at the first page, 15 rows and the pagination-
numbers are displayed in the view ...
but the generated urls look like this:

http://mywebsite.com/groups/topic/page:2


How can i force the pagination to show a custom url. I played with the
$this->paginate[url] ... but it without success. Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---