I've created an ChronoConnection with a custom front end list. How can I display the row number of each table row in a custom list?
Regard, Hans
Regard, Hans
Hi Hans,
Is this starting from 1 again for each listing?
Then I think I'd do it like this. In the Header box add
Bob
Is this starting from 1 again for each listing?
Then I think I'd do it like this. In the Header box add
<?php
global $row_counter;
$row_counter = 1;
?>and in the Row box add<?php
global $row_counter;
echo $row_counter; // but pretty this up a bit
$row_counter++;
?>Bob
Bob,
That works fine.
Is there also a solution when this must be a record number which continues counting after page-breaks? What I have a list of 30 records, with a list limitation of 10 per page, in this solution the first record of the second page will start at 1 again. Is it possible to continu counting, so the first record on the second page will get nummer 11 instead of 1?
Since the autolist has got this solution, I figured there must be some kind of variable which can be used.
Regards, Hans
That works fine.
Is there also a solution when this must be a record number which continues counting after page-breaks? What I have a list of 30 records, with a list limitation of 10 per page, in this solution the first record of the second page will start at 1 again. Is it possible to continu counting, so the first record on the second page will get nummer 11 instead of 1?
Since the autolist has got this solution, I figured there must be some kind of variable which can be used.
Regards, Hans
Hans,
I have this same issue, did you resolve it. If yes, kindly share.
Thanks
Amal
I have this same issue, did you resolve it. If yes, kindly share.
Thanks
Amal
Hello GreyHead / Max,
Kindly let me know if this has a solution. Paginator knows total number of rows and start of each page, can we get that information somehow. That might help.
Regards
Amal
Kindly let me know if this has a solution. Paginator knows total number of rows and start of each page, can we get that information somehow. That might help.
Regards
Amal
Sorry Amal, I didn't find a solution either and be interested if someone has one.
Regards, Hans
Regards, Hans
You can check the "page" param in the code in the header box, and do a small calculation:
The variables values need to be found....
Regards,
Max
<?php
global $row_counter;
$row_counter = 1 + (($page - 1) * $page_limit);
?>
The variables values need to be found....
Regards,
Max
$page and $page_limit seems to be non-existing variables. With or without declaring them as global variables, they remain empty so this solution doesn't work. I've tried to find how to fill these variables or if other similar variables exists, but I can't find anything usefull.
Hans
Hans
Well, looks like I mixed between V4 and V5🙂
I think in V4 you could get the start limit using this:
Check this and let us know!
Regards,
Max
I think in V4 you could get the start limit using this:
<?php
global $row_counter;
$row_counter = 1 + (int)JRequest::getVar('limit_start', 0);
?>
Check this and let us know!
Regards,
Max
Sorry, it still doesn't work. Perhaps the variable has a different name?
Hans
Hans
Please check the variable name when you hover with your mouse over any of the pagination links, it should be "limit_start".
Hans / Max,
I can see a variable "start" in URL when I use the paginator. If you use "start" in what Max wrote, it works.
Amal
I can see a variable "start" in URL when I use the paginator. If you use "start" in what Max wrote, it works.
Amal
Thanks Amal!🙂
Is this solutions for CCv5 or v4 ?? as i try this in my CCv5 under Front List setting Under PHP Functions seems like it does not show anything ...
I do this in my PHP Functions field :
Bor.session_profail:global $row_counter;
echo $row_counter;
$row_counter++;
I do this in my PHP Functions field :
Bor.session_profail:global $row_counter;
echo $row_counter;
$row_counter++;
Razlie,
Seems like nobody is able to help, I will tell you my understanding. The $start solution was for CC v4. The solution Max mentioned earlier with $page & $page_limit was probably for v5. I didn't understand the code you wrote. Where are you writing that.
Amal
Seems like nobody is able to help, I will tell you my understanding. The $start solution was for CC v4. The solution Max mentioned earlier with $page & $page_limit was probably for v5. I didn't understand the code you wrote. Where are you writing that.
Amal
Hi guys,
v4 offset solution has already been posted. now for v5, this code can be used in the custom header/body/footer:
So, in order to display a row count, just use Bob's code in the 2nd post here:
http://www.chronoengine.com/forums/posts/t93552/p322080/show-row-count-in-custom-front-end-list.html#p322080
And modify it to use the offset:
Regards,
Max
v4 offset solution has already been posted. now for v5, this code can be used in the custom header/body/footer:
<?php
$this->view->Paginator->total; //returns the total number of rows in the whole list
$this->view->Paginator->limit; //returns the number of rows in a full page
$this->view->Paginator->offset; //returns the current offset from the 1st record
So, in order to display a row count, just use Bob's code in the 2nd post here:
http://www.chronoengine.com/forums/posts/t93552/p322080/show-row-count-in-custom-front-end-list.html#p322080
And modify it to use the offset:
<?php
global $row_counter;
$row_counter = $this->view->Paginator->offset;
?>
Regards,
Max
Max,
How can I get a row count in V4, I can't find that. Unless I go to the last page of paginator I can't know the number of rows. If I understand correctly the $db->loadResult() returns the first row first column value. I had a good look on many posts but don't see how to get the number of rows using loadResult(). Can we use some other function like loadObject() etc here which might return the total number of rows in Header itself rather than navigating to last page.
I tried count($row), count($data), sizeof($data) but they didn't work. If "data" is an array containing the result set as also shown in the debugger then count($data) should give the total number of rows but it gives some figure which I could not understand. Like when my CC query was returning 14 rows or 49 it kept giving 3.
Thanks
Amal
How can I get a row count in V4, I can't find that. Unless I go to the last page of paginator I can't know the number of rows. If I understand correctly the $db->loadResult() returns the first row first column value. I had a good look on many posts but don't see how to get the number of rows using loadResult(). Can we use some other function like loadObject() etc here which might return the total number of rows in Header itself rather than navigating to last page.
I tried count($row), count($data), sizeof($data) but they didn't work. If "data" is an array containing the result set as also shown in the debugger then count($data) should give the total number of rows but it gives some figure which I could not understand. Like when my CC query was returning 14 rows or 49 it kept giving 3.
Thanks
Amal
Bob,
That reply is only for v5. I tried it in v4, doesn't work.
Amal
That reply is only for v5. I tried it in v4, doesn't work.
echo $this->view->Paginator->total; shows nothing.
Amal
Hi Amal,
I don't have the v4 files handy now to check the variables names, but you may get them with "loadResult" using a "COUNT" query, it will be an extra query on the page though!
Regards,
Max
I don't have the v4 files handy now to check the variables names, but you may get them with "loadResult" using a "COUNT" query, it will be an extra query on the page though!
Regards,
Max
Max,
I already have
Another query, why doesn't count($data) work. Shouldn't that give the exact number of rows in the "data" array.
Thanks
Amal
I already have
$count = $db->loadResult(); in my Header code as given in Bob's Dynamic Filters tutorial. As I mentioned, it only gives the value of first field of the first row. The $count doesn't contain the row count.
Another query, why doesn't count($data) work. Shouldn't that give the exact number of rows in the "data" array.
Thanks
Amal
Hi Amal,
Before that code you will need a new SQL query with "COUNT" function for your table, then loadResult will return the total number of records!
Regards,
Max
Before that code you will need a new SQL query with "COUNT" function for your table, then loadResult will return the total number of records!
Regards,
Max
Max,
I am able to get a row count using
If the data is present in the "form->data" array and is visible in debug then what is the need for running another SQL query?
There is another issue, it gives only the total row count for each page, should it give the total row count if I use that code just after loadResult() call, even before invoking the {paginator}.
Regards
Amal
I am able to get a row count using
$ll_RowCount = count($form->data['mymodel']);
If the data is present in the "form->data" array and is visible in debug then what is the need for running another SQL query?
There is another issue, it gives only the total row count for each page, should it give the total row count if I use that code just after loadResult() call, even before invoking the {paginator}.
Regards
Amal
Hi Amal,
Yes, you will need a new COUNT query to get the count of all rows in the table, the count function you use will only count the returned records in that page!
Regards,
Max
Yes, you will need a new COUNT query to get the count of all rows in the table, the count function you use will only count the returned records in that page!
Regards,
Max
Hello,
I tried to follow your instructions for the row count on CCv5:
http://www.chronoengine.com/forums/posts/t93552/p323477/show-row-count-in-custom-front-end-list.html#p323477
I really dont understand where to post the second code which is called in this posting from Bob as "Row box":
http://www.chronoengine.com/forums/posts/t93552/p322080/show-row-count-in-custom-front-end-list.html#p322080
Maybe anyone can explain this to me.
Thanks a lot.
I tried to follow your instructions for the row count on CCv5:
http://www.chronoengine.com/forums/posts/t93552/p323477/show-row-count-in-custom-front-end-list.html#p323477
I really dont understand where to post the second code which is called in this posting from Bob as "Row box":
http://www.chronoengine.com/forums/posts/t93552/p322080/show-row-count-in-custom-front-end-list.html#p322080
Maybe anyone can explain this to me.
Thanks a lot.
Hi merten,
The FAQ was written for CCv4. In CCv5 the nearest I can see would be the Body Code box whch is usable if you have a Custom Listing. See Front List | List Display | Custom
Bob
The FAQ was written for CCv4. In CCv5 the nearest I can see would be the Body Code box whch is usable if you have a Custom Listing. See Front List | List Display | Custom
Bob
it should be possible to use that code in header/footer or body boxes, both the table and custom lists have header/footer boxes!
Regards,
Max
Regards,
Max
Not really knowing how to handle it, i just copied this code in the Header box (front list, list Display, table):
So, everythings works, except the row count. Without knowing i think ist not quite good to mix php-code with the html things but...
Have you any hint for me?
thanks a lot!
<?php
$this->view->Paginator->total; //returns the total number of rows in the whole list
$this->view->Paginator->limit; //returns the number of rows in a full page
$this->view->Paginator->offset; //returns the current offset from the 1st record
<?php
global $row_counter;
$row_counter = $this->view->Paginator->offset;
?>
<br>
_PAGINATOR_NAV_ _PAGINATOR_LIST_
<p>
<br>
<input type="text" name="fltr[Usergroupname][title]" placeholder="Klassenfilter" class="form-control A" /><input type="submit" name="submit" value="OK" />
<br>
</br>
So, everythings works, except the row count. Without knowing i think ist not quite good to mix php-code with the html things but...
Have you any hint for me?
thanks a lot!
Sorry, but I can't understand what you are trying to do, what's the $row_counter ?
And you have a PHP block open, so you can't use "<?php" again!
Regards,
Max
And you have a PHP block open, so you can't use "<?php" again!
Regards,
Max
This topic is locked and no more replies can be posted.
