Page 1 of 1
Drop down categories on homepage.
Posted: 2021-12-07 22:04
by mqley
Hi, on your Northwind demo you have drop downs where tables live and can be separated. i.e. Sales/Operations/Catalog. How is this acheived? I've set the Table Group up in Appgini and assigned tables to the groups but they don't show on the homepage. I'm using the very latest Appgini 5.98. And emptied cached - totally regenerated all files and it doesn't seem to work for me. Where would one look to work this out? Thank you. Mark
Re: Drop down categories on homepage.
Posted: 2021-12-08 06:48
by peebee
I've set the Table Group up in Appgini and assigned tables to the groups but they don't show on the homepage
That should be all that's necessary, assuming the Groups/tables are assigned correctly?
Check incCommon.php around line 40 for this function (first function under the notes):
Code: Select all
function get_table_groups($skip_authentication = false) {
$tables = getTableList($skip_authentication);
$all_groups = ['None', 'Group 1', 'Group 2', 'Another Group'];
If you don't have your Groups listed under the $all_groups variable, then something has gone wrong.
Re: Drop down categories on homepage.
Posted: 2021-12-08 19:51
by mqley
Thanks peebee. The code was there. I think it may have been the fact I only had set up one Group to test. I added another field with a different Group and it works fine now.

Re: Drop down categories on homepage.
Posted: 2021-12-19 16:59
by mqley
Just another quick thing related to these Groups on the homepage. How would one go about not having the first Group open by default? So you go to the homepage and all Groups are closed, until one is clicked on?
Re: Drop down categories on homepage.
Posted: 2021-12-19 20:08
by mqley
Maybe not possible?
Re: Drop down categories on homepage.
Posted: 2021-12-20 05:59
by jsetzer
(1) Simpe solution with backdraw
Remove that line from
home.php
:
Code: Select all
$j('.collapser:visible').eq(0).click();
Attention
This file will be overwritten on next code-generation.
Re: Drop down categories on homepage.
Posted: 2021-12-20 06:30
by jsetzer
(2) Pure hooks-only solution
If you need a hooks-only solution, this becomes more complex. We have to cancel opening the first panel on load but keep click-handler for follow up-clicks on panel-headers. AppGini automatically changes the arrow-icon ("chevron") on load from right-arrow to down-arrow, and we have to reset it on initial load, too.
Code
The following copy & paste-ready code works for me:
Code: Select all
<!-- file: hooks/header-extras.php -->
<script>
var initial_load = true;
jQuery(document).on("show.bs.collapse", function(e) {
if (initial_load) {
initial_load = false;
e.preventDefault();
let id = jQuery(e.target).attr("id");
jQuery(`a.collapser[href='#${id}']`).find("i.glyphicon").toggleClass("glyphicon-chevron-down glyphicon-chevron-right");
}
});
</script>
Result
After reload with my code enabled, the homepage looks like this:

- chrome_k4Y2pPTbhp.png (7.35 KiB) Viewed 4087 times
All panels are collapsed, chevron-icons indicate "closed" status and click handler still works.
Note
As this is a hooks-only solution, this will
not be overwritten on next code-generation.
Re: Drop down categories on homepage.
Posted: 2021-12-21 20:30
by mqley
That works like a treat. Love this hook solution. Thanks jsetzer.