Help with Nav Links for Offsite Page

Alright guys, I am using offsite pages to point to specific Armadillo categories. I wanted to sort Armadillo content by category in a way that the user clicks the page nav button and it takes you to that Armadillo category. The problem with this is that the page nav links cannot show which “page” you are on because it is just an onsite link. Do you guys think the nav links can be forced to show the correct “page” with some sort of if statement and some CSS? I am not sure how to accomplish this. Go to https://thatcollegelife.com/?category=Students and look at the nav link. It will not show the Students Page as highlighted (it can’t because it is offsite). Thanks!

I can’t think of an easy fix.

The problem is that the offsite links aren’t really links to a different page, but are on the home page with a query string added to the URL.

It could be done possible with some custom JavaScript.

1 Like

Thanks @teefers . I may do more research on this idea.

@Parker,

Did you get this worked out. I came accross some JavaScript of mine that with a little modifications(mainly class names based on the theme you are using) that should work.

I think looking at your site I got it set. Just at this to sitewide javascript code section if you want to test it.

function ready(callbackFunction) {
    if (document.readyState != 'loading')
        callbackFunction(event);
    else
        document.addEventListener("DOMContentLoaded", callbackFunction);
}
ready(event => {
    let urlParams = window.location.search;
    if (urlParams === '') {} else {
        let SelectCurrent = document.querySelector('a.current');
        if (SelectCurrent) {
            SelectCurrent.classList.remove('current');
            SelectCurrent.classList.add('normal');
        }
        let anchorList = document.querySelectorAll('#navLinks a');
        anchorList.forEach(AnchorItem => {
            let navHref = AnchorItem.href;
            if (navHref == document.baseURI) {
                AnchorItem.classList.add('current');
                AnchorItem.classList.remove('normal');
            }
        });
    }
});
2 Likes

Thanks @teefers !!! I will try this code soon and see what happens. Thanks for all your help with this site. It is coming along nicely.

I just tried your code and it works great!! Thank you very much. It is live at thatcollegelife.com

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.