unread or new records count on home page.

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
zkarwinkar
Veteran Member
Posts: 32
Joined: 2021-06-12 21:01

unread or new records count on home page.

Post by zkarwinkar » 2021-09-25 19:44

how to get * mark or some count on table name button on home page for unread posts ,same as appgini forum post, i have a table where users posts issues, but it is impossible to track which post u read and which u not .

help please !

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: unread or new records count on home page.

Post by jsetzer » 2021-09-26 06:47

AppGini stores when a record was created and last updated but not when viewed by whom.

So, first you will have to save whenever a user views a record. A good place for this is TABLENAME_dv hook.

Create a table record_views with columns id, tableName, pkValue, memberID (²).

In _dv hook, if selectedID, insert a new record for the current user, if not already exists.

Next step is to calculate the number of UNSEEN records for the current user: number of total records of that table minus number of viewed records of that table by that user.

This is "SELECT count(*) FROM YOURTABLENAME" (¹) minus "SELECT count(*) record_views WHERE tableName='YOURTABLENAME' and memberID='{$YOURUSERNAME}'".

¹ The SQL commands may become more complicated if you have to consider permisions. Take a look at sql_from() function which returns necessary constraints for the FROM part of the SQL command.

² Personally I would add created_on column.

Last step is display of the number of unseen records per table in homepage. For me this seems to be the most tricky part and there is no real hook for modifying the links in the homepage as far as I know. So, you will have to use javascript/jQuery for finding the links and then adding for example '<span class="badge">' + NUMBEROFUNSEENRECORDS + '</span>' per table.

Summarizing, it looks so easy but it is not, unfortunately.

Maybe it would be easier to display badges in the navbar instead of homepage. So users could see these indicators ("bell") in every page and not only in the homepage. Counting would be identical, but display should be easier.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: unread or new records count on home page.

Post by jsetzer » 2021-09-26 06:55

I forgot: when deleting a record you will have to delete all related views, too. Otherwise calculation will be wrong.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: unread or new records count on home page.

Post by onoehring » 2021-09-26 08:02

Hi,

thank you Jan for your very nice explanation.
Yes, using a count in the menu, by simply adding the code to the /hooks/links-navmenu.php is very easy. You can simply pull the requested value using SQL directly from the database and show it next to the navigation.
Nevertheless, I am using both methods at the same time (not for "new" entries, but to show other information. Please see my example screenshot:

Please note, that in the first image there is an additional badge count in "Containerliste" - which also has a title attached to it that shows once you move your mouse over that. Besides from that the other badgecounts show the same information in the menu as well as in the main.
main2.png
main2.png (29.36 KiB) Viewed 1689 times
menu2.png
menu2.png (7.94 KiB) Viewed 1689 times
Olaf

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: unread or new records count on home page.

Post by jsetzer » 2021-09-26 17:19

Well done, @Olaf! Good idea using hooks/links-navmenu.php
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

zkarwinkar
Veteran Member
Posts: 32
Joined: 2021-06-12 21:01

Re: unread or new records count on home page.

Post by zkarwinkar » 2021-09-26 19:10

thank you guys, it really helped me .

Post Reply