Advertisement
How to add spoiler tags, edit posts, add images etc. How to - a user's guide to the new version of Boards
Mods please check the Moderators Group for an important update on Mod tools. If you do not have access to the group, please PM Niamh. Thanks!

A fix for Search forgetting forum / user / thread. 13 lines of JavaScript included.

  • #1
    Registered Users Posts: 17,208 ✭✭✭✭ Ads by Google


    There is a general breakdown in UX that is an obvious result of it being coded by someone who doesn't use the search function. boards.ie search basically sucks because of this.

    Advanced Search doesn't have a link anymore. Only /search/submit. What this does is remove the ability for posters to easily search with more than one variable.

    Step 1: Add a link for Advanced Search. You can do that or I'll add it to the code below.

    Step 2: Respect Query Parameters in the URL by adding the JS below, and change the placeholder text of the Search bar to "Search".

    [HTML]var params = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    var append = [];
    params.forEach(function(p){
    if (p.indexOf('user=') !== -1) append.push(p);
    if (p.indexOf('forum=') !== -1) append.push(p);
    if (p.indexOf('thread=') !== -1) append.push(p);
    if (p.indexOf('sort=') !== -1) append.push(p);
    });
    document.getElementById('user_search').addEventListener('click', function(e){
    e.preventDefault();
    var queryTerm = document.getElementById('user_search_input').value.replace(' ', '+');
    window.location.href='https://boards.ie/search/submit/?query=' + queryTerm + '&' + append.join('&');
    });
    [/HTML]

    That code gives the expected behaviour where if you are searching a user's posts, or a forum's posts, or a thread's posts, typing in a new search term will ensure that you are still searching within that user, forum, or thread's posts. It's miles better than the current brand new search every time.

    To test, just click my name and view all posts, click F12 and paste the code into the console. Type in a search term and when you submit, you'll be finding that search term in posts by me.
    Tagged:


Comments



  • This only works for Legacy site. boards.ie would need to adapt it for Responsive / Touch.

    If anyone wants to use this now on the legacy site, you can create a bookmark with the following for the URL. Click it before submitting each search if you want the user / forum / thread to be included in the new search. That's what I'm doing.

    [HTML]javascript:(function(){ var params = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); var append = []; params.forEach(function(p){ if (p.indexOf('user=') !== -1) append.push(p); if (p.indexOf('forum=') !== -1) append.push(p); if (p.indexOf('thread=') !== -1) append.push(p); if (p.indexOf('sort=') !== -1) append.push(p); }); var legacySite = document.getElementById('user_search'); if (legacySite) { document.getElementById('user_search').addEventListener('click', function(e){ e.preventDefault(); var queryTerm = document.getElementById('user_search_input').value.replace(' ', '+'); window.location.href='https://boards.ie/search/submit/?query=' + queryTerm + '&' + append.join('&'); }); } })();
    [/HTML]




  • I just edit the search URL to put in the query terms I want :D

    Bring back the :pac: !



Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.

Advertisement