Open gallery default by a specific type at the Local Government maps and apps Gallery

2295
2
06-26-2014 03:35 AM
WilfredKnol
New Contributor
We are using the  Local Government maps and apps Gallery.
I was able to change the configuration so on startup the gallery is comming first and not the home page.

On the left side people can use filters. By default all the Categories and Types are show. But is it possible that on startup a specific type is shown and not all types?

Does anyone know if and how this is possible. Would help me out a lot.

Best Regards,
Wilfred
0 Kudos
2 Replies
MikeTschudi
Occasional Contributor
Wilfred,

Some background for others: when the app starts up, shortly after the ready(function () {, the code splits into two paths: "depends on config file" and "independent of config file".  The former is involved in reading the items from your group and setting up the gallery contents, which can take a little bit of time over the network; the latter are things that can be run right away.

A good place to switch to the gallery is at the end of the "independent" path; it would go right before the comment "// Show the site by hiding the loading background" that ends the path:
changeSubpage("Gallery", false);

// Show the site by hiding the loading background
configIndependentInitReady = true;
hideLoading();


For setting the initial filters, you'd do that after the items are fetched from the server, which is done with the following lines:
// Get the gallery data. We'll chain the three calls (for the Most Popular & Most Recent
// sections of the main page and for the Gallery page) so that we can use one fetch of
// data for all three. Otherwise, all three fetch calls are made before the data arrives
// and we end up making three fetches.
galleryData.fetch({
    sort: [{attribute: "numViews", descending: true}],
    start: 0, count: 7,
    onComplete: function(items, request){
        // Most Popular
        showPopular(items, request);

        galleryData.fetch({
            sort: [{attribute: "modified", descending: true}],
            start: 0, count: 4,
            onComplete: function(items, request){
                // Most Recent
                showRecent(items, request);

                // Gallery page
                updateGallery(null, null, null);
            }
        });
    }
});


Note the updateGallery(null, null, null); call towards the end. It is here that you set your initial filter. The three parameters of updateGallery() are strings giving the desired category, the desired type, and the desired search term; a null is used to indicate all categories, all types, and no search term, respectively.

So if I want to start up the app with the gallery showing the "Elections & Voting" category and the "Web" type with no search term, I'd change updateGallery(null, null, null); to
updateGallery("Elections & Voting", "Web", null);


Or for just the "Community Activities" category, I'd change updateGallery(null, null, null); to
updateGallery("Community Activities", null, null);


If I want to use the search term, I'd do something a little bit different for efficiency. Because it would be helpful for the user to see the search term in the type-in box, I'd insert the starting search term into the type-in box. But because any change to that type-in box triggers a updateGallery call, first I'd set the desired starting category (variable currentCategory) and/or the desired starting type (variable currentType). So if I wanted to see all "Web" types that include a search term "park", I'd use
currentType = "Web";
dijit.byId("searchBox").set("value", "park");

and delete the redundant updateGallery call.

Regards,
Mike
0 Kudos
WilfredKnol
New Contributor
Mike,

Thanks for helping out.
I was indeed looking for the setings in the updatgallery like you discribed.

So now we can move on with the gallery.

Regards,
Wilfred
0 Kudos