Filtered Links

Parmeisan
Parmeisan

Hi,

(I'm sorry if this has been suggested before, but searches in this forum seem to be by post instead of thread, making it near impossible to check.)

So, I know it's possible to perform a search/filter in this manner and then link to it:

image

And I know it's possible to filter characters like so:

image

What I'd really love is to be able to link to the second one too.

For most purposes in my campaign I have been able to just use the first one and it meets my needs.  But there is one place where I actually had to create a second campaign so that I could provide the experience I needed.  I have one campaign for enemies only and one for everything else.  Characters in the main campaign include NPCs but not enemies.  This lets me set up both "NPCs" and "Enemies" links in the sidebar and still have the images displayed.

The lack of this isn't a huge problem, but as someone with some programming experience I suspect it would also be very easy to add.  And it would make a big difference to the visual impact of my campaign to the various users.

(I should perhaps mention that this isn't a campaign, exactly, I am using Obsidian Portal to host an entire setting for a tabletop RPG that I am making and hope to publish.  In almost all regards, it is perfect for this purpose!  But being able to link to all characters used in a given adventure module, and have it go to the nicer-looking version, would make the modules look a lot more professional.)

Anyway, that's it.  Thanks for listening. :)

Comments

  • thaen
    thaen
    Posts: 943

    Thanks for the request!  Makes sense.  And a number of people have asked for pages to display "factions", so I could see tagging each member of a faction, and then using a url that filters to just those tags as the "faction page".

    I've added it to the list.

    Obsidian Portal Developer

  • Frak_Lou_Elmo
    Frak_Lou_Elmo
    Posts: 170

    I could see a use for this in my campaign too, a page showing just characters with a tag would really simplfiy my cast of thousands character page into a few pages of casts of dozens. :D



    twitter: @Frak_Lou_Elmo

  • thaen
    thaen
    Posts: 943

    @Parmeisan, @Frak_Lou_Elmo, this should work now.

    First, go to the Characters or Items page.  (Both have this ability now.)

    Filter the page the way you want it by clicking the checkboxes.

    Notice while you are checking/unchecking that the url in the browser is updating to include the filters you have selected.

    When you're happy with your selected filters, copy the current url from the browser.

    Now use that in your links.  When you click the link, it will auto-filter to match the previously selected filters.

    Let me know how it goes!

    Btw, side note, I first used Custom JavaScript to create this feature, since it's all entirely JavaScript.  So anyone could have added this feature to their own Campaign without waiting for me to add it to the codebase.  I like the idea that we (OP devs) don't have to be a bottleneck to GMs doing what they want with their Campaigns.

    Obsidian Portal Developer

  • Frak_Lou_Elmo
    Frak_Lou_Elmo
    Posts: 170 edited March 16
    dude this is awesome! now I can guilt trip my players to no end with a continuous reminder of their failure to save NPCs: https://gaximplague.obsidianportal.com/characters?filters=tag_DEAD

    Is there a way that to make it so that when they follow said link, the filter box is not automatically opened?

    Is there a way to have two filter tags selected, for example I want to show on one page "A-Team" and "STEEDS"?
    Post edited by Frak_Lou_Elmo on



    twitter: @Frak_Lou_Elmo

  • thaen
    thaen
    Posts: 943

    Hahaha!!!  That DEAD page is fantastic!

     

    Is there a way that to make it so that when they follow said link, the filter box is not automatically opened?

    There's not a builtin way to have the filter panel not open, but you can use Custom JavaScript to close the panel quickly after the page loads with this code:


    $(function() {
    if ((new URLSearchParams(window.location.search)).get('filters')) {
    $('.show-tag-check-list').click();
    }
    })

    That code says "when the page is done loading, if there is a query string with "filters" in it, then click the "Filters" button on the page."

     

    Is there a way to have two filter tags selected, for example I want to show on one page "A-Team" and "STEEDS"?

    There's no builtin way to have two filter tags show at the same time.

    The "easy" way to do this would be to just give them all (all the A-Teams and all the STEEDs) the same additional tag ... maybe "ateam_and_steeds", and then just link to that.

    But the "hard" way to do this is with Custom JavaScript.  : )


    $(function() {
    var filters = (new URLSearchParams(window.location.search)).get('filters');
    if (filters == "ateam_and_steeds") {
    var characters = $([]);
    characters = characters.add($(".tags-list .tag-link[data-tag=\"A-Team\"]").parents('.character-list-item'));
    characters = characters.add($(".tags-list .tag-link[data-tag=\"STEED\"]").parents('.character-list-item'));
    $('.character-list-item').parents('.character-list-item-container').hide();
    characters.parents('.character-list-item-container').show();
    }
    });

    That code says "when the page is done loading, if the filter says only "ateam_and_steeds", then find all the A-Team Characters and add them to a list.  Then find all the STEED Characters and add them to the same list.  Then hide all of the Characters on the page.  Then show only the Characters from the A-Team and STEED list.

    Obsidian Portal Developer

  • Frak_Lou_Elmo
    Frak_Lou_Elmo
    Posts: 170

    thanks for the code. This is pretty cool that I can then hide the filter block. still contemplating how many character pages I want... I may need to consult my players to see what they find the most useful.



    at the same time I will ask them about going through the enable custom java script. I do realize then that I would need to adapt the code above (easy enough) and add as new custom java for every combined tag group I want.



    I assume that at some time in the past someone must have asked for a feature request to have a toggle button for the filter to switch between AND / OR tags?



    twitter: @Frak_Lou_Elmo

  • thaen
    thaen
    Posts: 943

    I assume that at some time in the past someone must have asked for a feature request to have a toggle button for the filter to switch between AND / OR tags?

     

    Yes, I think it's been requested before.  But adding a visible switch would complicate the UI too much, and most visitors/members are not going to be familiar with what AND / OR means.  And since these are "filters", the normal usage is for them to get "tighter and tighter" to narrow down to what you're looking for.

    You're wanting to use them as an alternative way to display, which makes sense, but is not the normal intent.  So, this is a perfect use of Custom JavaScript.

    Obsidian Portal Developer

  • Frak_Lou_Elmo
    Frak_Lou_Elmo
    Posts: 170

    Is there a way that to make it so that when they follow said link, the filter box is not automatically opened?

    There's not a builtin way to have the filter panel not open, but you can use Custom JavaScript to close the panel quickly after the page loads with this code:


    $(function() {
    if ((new URLSearchParams(window.location.search)).get('filters')) {
    $('.show-tag-check-list').click();
    }
    })

    That code says "when the page is done loading, if there is a query string with "filters" in it, then click the "Filters" button on the page."

    @thaen My Gm did find a way to reduce the space the filters take up with custom js:

    image



    @JayDoubleA could you use this js to instantly minimize the filter?



    twitter: @Frak_Lou_Elmo

Sign In or Register to comment.

July 2022
Signs and Portends

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions