Unable to show selected category

Started by baardman, December 28, 2017, 06:29:38 PM

Previous topic - Next topic

baardman

Via IMatch.categoryBrowser I want to select a category. A few steps further I want to call the Image Processor and give IMatch.idlist.selectedCategories as a parameter. It gives me output of a different unknown selection.

I tried the piece of code below to see if IMatch.idlist.selectedCategories works as I expect it to be. The resultwindow doesn't show the contents of categoryId 2147. What am I doing wrong?

                    IMatch.gotoCategory({
                        categoryId: '2147'
                    }).then(function(response) {
                        AddResponseLog(response);
                    }, function(error) {
                        AddResponseLog(error);
                    });

                    IMatch.openResultWindow({
                        idlist: IMatch.idlist.selectedCategories                           
                    }).then(function(response1) {
                        AddResponseLog(response1);
                    }, function(error) {
                        AddResponseLog(error);
                    });

Mario

#1
The result window takes a list of files, not a list of categories. You can either specify an idlist or a list of file ids.
With ImageProcessor you mean what?

I'm not quite sure what you want to to...

You first select a category. This switches IMatch to the category view and shows all files in the category. OK.
Then you want to open a result window for what purpose?

You can do that. But you will have to retrieve the files in the selected category and use that to open the result window. But then you have basically what you had before, a file window showing the files in the selected category...?

Also, note that gotoCategory returns a Promise. The category may not even be selected when you call openResultWindow.
gotoCategory returns immediately and resolves the returned promise once IMatch has finished switching to the category. You need to call openResultwindow from the then(...) branch of gotoCategory.

If all you want to do is to open a result window with the files in a specific category, it is much easier to:

1. Get the files in that category.
2. Open the result window with these files.


-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

baardman

I use IMatch to generate my website pages. I have my photo galleries divided in categories in IMatch.

What I want is to select a category (which contains the photos I want displayed in a particular webpage).
The files within the category have to be resized for thumbnails and other formats. For that I call Image Batch Processor (I think that's the right name, I've a Dutch version so I've to guess).
Ideally I want to pass the categoryID to the Image Batch Processor, but I understand from your reply that it's not possible. Too bad, it works manually with the drag & drop function.

I made the piece of code in this post to try to understand why it's not working. I understand it now. The ID I was passing through was interpreted as a file ID.

OK, then my next question is how I can select all files within a category from the script?
When I use IMatch.categoryBrowser and select a category I will get the file ID's, but how can I select all files within a category (for example an category that was selected before the script was started).


Mario

To get information about a category (name, id, the files assigned to it) you use the /categories endpoint.
See the documentation of this endpoint and the "Categories" sample app for examples on how to use this endpoint to process categories.

Note: There is currently no way to run the batch processor from an IMatch app.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

baardman

#4
Hi Mario,

Thnkx for your reply. There is a way to run the batch processor. I just got it working :-)
I made some predefined settings for resizing and added them to my Favorites panel.

                function CreateImageFiles(favoriteName, selectedFiles) {
                    IMatch.favoritesList().then(function(response) {
                        // get GUID of favorite
                        var favoriteSet = jQuery.grep(response.favorites, function(item,i){return item.name == FAVORITE_SETNAME});
                        var favoriteItem = jQuery.grep(favoriteSet[0].favorites, function(item,i){return item.name == favoriteName});
                        var favoriteItemID = favoriteItem[0].id;
                        var fileIDList = selectedFiles.join(",");


                       IMatch.favoriteExecute({
                            guid: favoriteItemID,
                            id: fileIDList
                        }).then(function(response) {
                            AddResponseLog(response);
                        },
                        function(error) {
                            AddResponseLog(error);
                        });
                    });
                    return true;
                }

Mario

Ah, yes. This is a way to run it.

It's just not accessible directly yet. I have plans to implement this for a later release of IMWS - I need this for IMatch Anywhereâ„¢ and IMatch will benefit from that as well.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook