Drop down categories on homepage.

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Drop down categories on homepage.

Post by mqley » 2021-12-07 22:04

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
Best Wishes,

Mark

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Drop down categories on homepage.

Post by peebee » 2021-12-08 06:48

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.

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Drop down categories on homepage.

Post by mqley » 2021-12-08 19:51

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. :D
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Drop down categories on homepage.

Post by mqley » 2021-12-19 16:59

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?
Best Wishes,

Mark

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Drop down categories on homepage.

Post by mqley » 2021-12-19 20:08

Maybe not possible?
Best Wishes,

Mark

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

Re: Drop down categories on homepage.

Post by jsetzer » 2021-12-20 05:59

(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.
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: Drop down categories on homepage.

Post by jsetzer » 2021-12-20 06:30

(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
chrome_k4Y2pPTbhp.png (7.35 KiB) Viewed 2790 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.
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

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Drop down categories on homepage.

Post by mqley » 2021-12-21 20:30

That works like a treat. Love this hook solution. Thanks jsetzer.
Best Wishes,

Mark

Post Reply