-
Notifications
You must be signed in to change notification settings - Fork 57
Pagination #100
Comments
I'll try to reproduce this issue asap. |
thanks @stephpy Any idea? |
I'm sorry, i'm busy at this moment, i'll look at this as soon as possible |
Ok No problem! : ) |
Any update on this? Seeing the same thing. |
I'll have a look on it this week, sorry ... |
Awesome, thanks |
I created exactly same context, but i have not this issue :s What do you do on twig template ? if you only iterate on results, it's throw the exception ? It seems somewhere something try to cast in string the Component which is very very weird. It's dirty, but you could add a __toString method on your Entity/Component ... May it'll fix your issue. public function __toString()
{
return $this->getId();
} Can you paste me your twig file ? I can't define at this moment where/when a string cast is made on component :\ |
In exception, it seems subject_id is {} ... it should be the of compoennt id, weird. |
This is my twig template.
And the controller is :
|
There's nothing freak ... did you try to put __toString method on Component ? If you comment {{ timeline_render }}, do you still have this exception ? |
I dont know. This is what I have. config.yml of timeline
My twig template
My component.php
And my controller
And I get the same error. |
And yes !! If I comment this line:
I get the error. How can I use the pagination of timeline bundle ?? Maybe the problem is knpPaginator... |
Mmmh, what is Try to comment it ... ElseIf you setted Catchable Fatal Error: Object of class ant\SocialBundle\Entity\Component could not be converted to string Edit it and retry: public function __toString()
{
return (string) $this->getId();
}
You tried without knp paginator ? I guess you did. If it's not throw an exception, uncomment |
{{ knp_pagination_render(timeline) }} is to use knp_paginator. It show the select of pagination. If I comment it, I see 3 actions, but I cant choose more pages. I modified it:
And now, in my timeline, I dont see none action. The timeline is empty. But I dont get error. To use without knp paginator that I have to write ? I did same documentation:
Because I don't see the select of choose page of pagination, how include it in my template twig ... ? Thanks for help me! : ) |
That's the knp_pagination_render which make this fail by this way. $timeline is not an instanceof There is 2 solutions: You define your own macro for
$pager->getIterator() will return an object managed by Knp\Paginator component :) Let me know. |
aaahmmm I think it doesnt work. I changed, {{ knp_pagination_render(timeline.iterator) }} in my template twig Now, I deleted the __tostring method on Component. How can I use the pagination timeline, without use the pagination Knp ?? |
I did'nt try with this use case (with pagination render), i'll look at this tomorrow. If you can't wait, as i said, you have a https://github.com/stephpy/timeline/blob/master/src/Spy/Timeline/ResultBuilder/Pager/PagerInterface.php object, and you'll be able on your twig to deal with that {% if timeline.haveToPaginate %}
{% set lastPage = timeline.lastPage %}
{% set currentPage = timeline.page %}
....
{% endif % |
That's sure this error comes from this pagination renderer, by this way, i should have the same issue at home. |
I found issue, i tested with old version of KnpPaginatorBundle which changes his method to fetch number of results to paginate. There is an issue on their new behavior, doctrine allow to give as parameter a object which has doctrine metadata and will automatically return primary keys on SQL. KnpPaginatorBundle expects scalar results and by this way ... it fails ... You still have to use Really, really sorry for delay. |
@stephpy nothing has changed. I repeat my code ok ? Maybe you see some wrong.
My twig template
And my controller:
Is all correct ? I dont get the error, but the timeline is empty... |
I'll give a new try this night. Without paginate => true option, you have some actions ? What is the version of your knpPaginatorBundle knpComponents ? I tried with same configuration and i had no issue. May version of KnpPaginatorBundle/KnpComponents is not the same. |
This my version of knp.
If you know a version that works with the pagination of timeline , you tell me and I change! : ) |
I used exactly same code. Can you answer to this question please:
It's anormal, could you dump me that. public function myTimelineAction($u = null)
{
if ($u == null) $u = $this->get('security.context')->getToken()->getUser();
$actionManager = $this->get('spy_timeline.action_manager');
$subject = $actionManager->findOrCreateComponent($u);
$timeline = $actionManager->getSubjectActions($subject, array('page' => 1, 'max_per_page' => '3', 'paginate' => true));
var_dump(count($timeline));
return array('timeline' => $timeline, 'usuario'=> $u);
} It's important for me to know if without pagination you have results, and without no. |
Yes ! |
Weird :s If you're comfortable with sql, you could look at difference between SQL requests with pagination and without. (in sf debug tool bar). Execute theses SQL requests and you'll be able to know why 0 actions are returned. This behavior does not occur at me. If you are not comfortable with sql, please, paste me theses requests. |
Hello @stephpy sorry for delay. The difference between the call with and without paginate is this call to mysql: SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id6 FROM (SELECT s0_.verb AS verb0, s0_.status_current AS status_current1, s0_.status_wanted AS status_wanted2, s0_.duplicate_key AS duplicate_key3, s0_.duplicate_priority AS duplicate_priority4, s0_.created_at AS created_at5, s0_.id AS id6, s1_.type AS type7, s1_.text AS text8, s1_.id AS id9, s2_.model AS model10, s2_.identifier AS identifier11, s2_.hash AS hash12, s2_.id AS id13, s1_.action_id AS action_id14, s1_.component_id AS component_id15 FROM spy_timeline_action s0_ INNER JOIN spy_timeline_action_component s3_ ON s0_.id = s3_.action_id AND ((s3_.action_id = s0_.id AND s3_.component_id = 'subject' AND s3_.type = 109)) LEFT JOIN spy_timeline_action_component s1_ ON s0_.id = s1_.action_id LEFT JOIN spy_timeline_component s2_ ON s1_.component_id = s2_.id WHERE s0_.status_current = 'published' ORDER BY s0_.created_at DESC) dctrn_result) dctrn_table This SQL request is with paginate, when I have paginate false, this request doesnt exist... this help to you? |
Another discovery
And in my template:
I see the last Page and the currentPage. 5 and 1 respectively. But the line {{ knp_pagination_render(timeline.iterator) }} show the error:
|
Hi everybody... paginator: spy_timeline.paginator.knp and doing $timeline = $actionManager->getSubjectActions($subject,
array('page' => 1, 'max_per_page' => '10', 'paginate' => true)); I got an empty resultset. If I set the last parameter to false, i will get the expected results. Is there something that i'm missing? Thanks |
Hello. I get the following error to paginate:
I tried the two configuration:
My config actually is:
My controller is:
And I get the following error:
The text was updated successfully, but these errors were encountered: