WordPress.org

Forums

Zotpress
[resolved] shortcode tag filter (7 posts)

  1. doctorproctor
    Member
    Posted 3 years ago #

    I would like to display a list of references by tag filter, and this appears easy to do in shortcode but generates server errors each time; are others experiencing this problem? I can generate refs by collection, but not by tag.

    This leads to another question: can one enter both a collection and a tag filter in shortcode such that it implies all items with a given tag inside a given collection?

    Finally, is it possible to display a list of references having a certain tag by link (vs. shortcode), similar to how collections or items can be displayed by link?

    Many thanks,

    Jim

  2. Katie
    Member
    Plugin Author

    Posted 3 years ago #

    I'm not able to recreate this problem. What server error are you getting? What is the exact shortcode you're using?

    Right now, filtering by collection and tag can't be done, because of the way the Zotero API is set up:

    <userOrGroupPrefix>/tags The set of all tags in the library
    <userOrGroupPrefix>/tags/<url+encoded+tag> A specific tag in the library
    <userOrGroupPrefix>/tags/<url+encoded+tag>/items The set of items in the library tagged with a specific tag
    <userOrGroupPrefix>/collections The set of collections in the library
    <userOrGroupPrefix>/collections/<collectionKey> A specific collection in the library
    <userOrGroupPrefix>/collections/<collectionKey>/collections The set of subcollections within a specific collection in the library
    <userOrGroupPrefix>/collections/<collectionKey>/items The set of items within a specific collection in the library

    As you can see, it's an either-or setup: either collections or tags.

    I'm not sure what you mean by "displaying by link". Can you give me an example?

  3. doctorproctor
    Member
    Posted 3 years ago #

    Okay, read through the read API and now understand how this can be done via https://...but perhaps I should ask a further question given your shortcode is a bit more powerful than their API options: which filters can and cannot be combined in Zotpress shortcode? I understand that the various display settings can easily be added, but when I for instance would like to add a filter datatype = "tags" can I add that to e.g. a collection filter?

    Thanks again,

    Jim

  4. Katie
    Member
    Plugin Author

    Posted 3 years ago #

    I don't think it can be done by directly accessing an API URL? (Do I misunderstand?) You can add the tag and collection parameters together in a shortcode call but I'm not sure what it'll do, probably whichever defaults first, and I don't recall off-hand. I could manually filter by category and tag, but that begs the question: which one filters first? If you filter by tag and then collection you'll get a different result than if you filter by collection and then tag. Hmm ... my thought is that it might be better to just give items a new tag, which would put a little more effort on the user (you) but would save me a significant amount of programming and also load citations a ton faster (Zotpress has to make TWO calls to the Zotero server already, and to do this I believe it would be at least FOUR ... yikes).

  5. doctorproctor
    Member
    Posted 3 years ago #

    So, it seems possible to do e.g.

    https://api.zotero.org/groups/45298/tags/cultural+politics/items/?format=bib&style=chicago-author-date

    and generate a Chicago B-formatted output of a certain tag, though clearly not (yet) a certain tag within a certain collection. I suppose the code would have to load an array of items in a given collection and an array of items with a given tag, then compare the two arrays to identify common items...you're right that this would necessitate multiple API calls, but I could imagine the routine could be generalized so that it could handle any two requirements (e.g., items that have tag A and tag B).

    I'd like to go back to my first question, if possible, as well as my latest question:

    (a) When I enter e.g. [zotpress userid="45298" tag="cultural+politics"] I get "Sorry, but Zotpress was unable to contact the Zotero server. (Try again?)" The same happens whether or not I enter the userid, and as you can see from the API above the groupID and tag should work. What is wrong with the syntax of my shortcode?

    (b) Which of the filters noted on your Zotpress help tab can be combined? I would imagine any of the display settings can be combined, and that at least some of the filter settings (e.g., collection and tag) cannot, but perhaps other filters can?

    Many thanks again for all your great support!

    Jim

  6. doctorproctor
    Member
    Posted 3 years ago #

    Ah, item (a) now fixed via Zotpress update v4.3....thanks! Jim

  7. Katie
    Member
    Plugin Author

    Posted 3 years ago #

    (a) Great!

    (b) This might sound strange, but offhand I'm not sure about every case. Tags and collections are restricted to one or the other due to the Zotero API setup. Author and year, which I'm coding for in Zotpress manually, can be used together, and with either tags or collections. I think that's it ... well, you could always try putting different shortcode parameters together and see what happens. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags