Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

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

Options
  • 05-07-2019 4:02am
    #1
    Posts: 17,381


    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

  • Posts: 17,381 [Deleted User]


    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]


  • Registered Users Posts: 33,867 ✭✭✭✭Hotblack Desiato


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

    Life ain't always empty.



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