Forums

hpeterse 12 Jan, 2014
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
GreyHead 13 Jan, 2014
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
<?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
hpeterse 13 Jan, 2014
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
amsharma 22 Jan, 2014
Hans,

I have this same issue, did you resolve it. If yes, kindly share.

Thanks
Amal
amsharma 24 Jan, 2014
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
hpeterse 24 Jan, 2014
Sorry Amal, I didn't find a solution either and be interested if someone has one.

Regards, Hans
Max_admin 24 Jan, 2014
You can check the "page" param in the code in the header box, and do a small calculation:


<?php
global $row_counter;
$row_counter = 1 + (($page - 1) * $page_limit);
?>


The variables values need to be found....

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
hpeterse 26 Jan, 2014
$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
Max_admin 26 Jan, 2014
Well, looks like I mixed between V4 and V5🙂

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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
hpeterse 26 Jan, 2014
Sorry, it still doesn't work. Perhaps the variable has a different name?

Hans
Max_admin 26 Jan, 2014
Please check the variable name when you hover with your mouse over any of the pagination links, it should be "limit_start".
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
amsharma 27 Jan, 2014
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
Max_admin 27 Jan, 2014
Thanks Amal!🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
hpeterse 27 Jan, 2014
Works for me as well. Thx Max and Amal!

Regards, Hans
razlie 29 Jan, 2014
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++;
amsharma 30 Jan, 2014
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
razlie 31 Jan, 2014
I think Max going to release new update for this problem CCv5
Max_admin 01 Feb, 2014
Hi guys,

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, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
amsharma 19 Feb, 2014
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
GreyHead 19 Feb, 2014
Hi Amal,

Please check Max's post immediately before yours.

Bob
amsharma 19 Feb, 2014
Bob,

That reply is only for v5. I tried it in v4, doesn't work.
echo $this->view->Paginator->total;
shows nothing.

Amal
Max_admin 19 Feb, 2014
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
amsharma 20 Feb, 2014
Max,

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
Max_admin 02 Mar, 2014
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
amsharma 03 Mar, 2014
Max,

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
Max_admin 03 Mar, 2014
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
merten 10 Sep, 2014
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.
GreyHead 11 Sep, 2014
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
Max_admin 12 Sep, 2014
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
merten 30 Sep, 2014
Not really knowing how to handle it, i just copied this code in the Header box (front list, list Display, table):

<?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!
Max_admin 01 Oct, 2014
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.