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 !
unread or new records count on home page.
-
- Veteran Member
- Posts: 32
- Joined: 2021-06-12 21:01
Re: unread or new records count on home page.
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.
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
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: unread or new records count on home page.
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
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: unread or new records count on home page.
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. Olaf
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. Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: unread or new records count on home page.
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
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
-
- Veteran Member
- Posts: 32
- Joined: 2021-06-12 21:01
Re: unread or new records count on home page.
thank you guys, it really helped me .