Version Filter in TopNav Output

This forum is for all Flare issues not related to any of the other categories.
Post Reply
TabarSmith
Jr. Propeller Head
Posts: 2
Joined: Fri Jun 24, 2016 10:03 am

Version Filter in TopNav Output

Post by TabarSmith »

Hello!

I am hoping to find a way to apply Tregner's version filter (http://tregner.com/flare-blog/version-f ... l5-output/) to an entire TopNav site. My goal is to allow users to select the version of documentation that they need from the home page one time — then they won't need to select a version every time they navigate to a new topic.

Has anyone else had success in applying the version filter across the TopNav site? I would truly appreciate any insight and assistance!

Thanks!
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Version Filter in TopNav Output

Post by NorthEast »

We do something similar in one of our help projects.

In order to remember the 'version', we store a value for the version in localstorage (see http://www.w3schools.com/html/html5_webstorage.asp).

When we display a topic, a script checks the value in localstorage, and then sets a class on the HTML tag to indicate the version; e.g. html.versionA.

Our stylesheet is set up so that it will hide content based on this class; e.g. if it's versionA we hide content with the condition Versions.VersionB:

Code: Select all

html.versionA [data-mc-conditions*="Versions.VersionB"]
{
	display: none;
}
TabarSmith
Jr. Propeller Head
Posts: 2
Joined: Fri Jun 24, 2016 10:03 am

Re: Version Filter in TopNav Output

Post by TabarSmith »

Hi Dave Lee,

Thanks so much for your response. Please forgive my lack of coding skills, but would you mind clarifying a few things?

Where do you add the HTML code for local storage? To the master page?
What script are you using to check for the local storage value?
How do you define a class that excludes another class?

I'm revealing my ignorance in the realm of css, html, and javascript. Any additional insight you could provide would be greatly appreciated.

Thanks again!
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Version Filter in TopNav Output

Post by NorthEast »

TabarSmith wrote:Where do you add the HTML code for local storage? To the master page?
I usually put all scripts in js files then link to them from the master page.
TabarSmith wrote:What script are you using to check for the local storage value?
The link I posted shows you how to store/retrieve data using localstorage.

If you search (e.g try "localstorage select option"), you'll also be able to find plenty of examples of how you can store/retrieve values from form controls in localstorage.
TabarSmith wrote:How do you define a class that excludes another class?
I don't think you understood what I meant.

We check for a value in localstorage, e.g. we check the localstorage data 'AppVersion' and see it is set to 'versionA'.
Then we use that value and apply it as a class to the HTML tag, e.g change it to <html class="versionA">.
We can then use that class name to control what conditional content is displayed in the page, so content with the condition Versions.VersionB is hidden:

Code: Select all

html.versionA [data-mc-conditions*="Versions.VersionB"]
{
   display: none;
}
Giri
Jr. Propeller Head
Posts: 3
Joined: Fri Apr 26, 2019 11:22 pm

Re: Version Filter in TopNav Output

Post by Giri »

Hi Dave, I need some help with the version filter. I initially posted for the first time at: viewtopic.php?f=9&t=31577 (post titled Javascript in version filter does not redirect on 404). This was implemented by a UI developer but he left and am trying to fix it -- but so far no luck.

Am adding the same here in the hope that I would get your attention. I have seen that you provide solutions for all things Flare and scripts.

Could you please help?

Thanks
Giri
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Version Filter in TopNav Output

Post by NorthEast »

I've looked at the post, but don't know how to handle the redirect. Maybe ask your developer?
Giri
Jr. Propeller Head
Posts: 3
Joined: Fri Apr 26, 2019 11:22 pm

Re: Version Filter in TopNav Output

Post by Giri »

Dave Lee wrote:I've looked at the post, but don't know how to handle the redirect. Maybe ask your developer?
Thanks Dave.

Yes I have asked a developer to help. The 404 redirect (on the IIS server side) seems to have priority over what's done through the javascript...
Post Reply