Is the livesearch macro parameters not supposed to be used when you press enter

I have a livesearch macro on a page in my space. It only searches the space, and only pages - not showing for example gliffy diagrams or images.

I works very fine, when users type in a word, and wait for the suggestions.

But if the user wants to get more results than just the few listed in the drop down, and either presses carriage return or selects the possibility in the buttom of the list, the query changes.

(searching for 'word' in the space MYSPACE)

https://yousee.jira.com/wiki/dosearchsite.action?queryString=word&where=MYSPACE

So, I would have expected the type=pages in the search. Now the user also gets all images and diagrams, and that confuses, since we have named many diagrams after the page/subject.

Our end users are not necesary it experts and don't understand, the difference between the diagram icon and the page icon. They can not be though to just select Pages as type in left side of the search bar. (we have 2.000 users).

Thank you

Helle

 

1 answer

0 vote
Stephen Deutsch Community Champion Aug 18, 2017

Hi Helle,

I wrote this short javascript to be able to carry livesearch parameters over to the regular search. You can either install it in the custom HTML and it will take effect on all livesearch macros, or you can put it inside a user macro (with ## @noparams at the top) and put the user macro in the one page for it to take effect only on that page.

<script>
AJS.toInit(function() {
$("form[name=livesearchForm]").each(function() {
var labelVal = $(this).find("input[name=labels]").val();
var typeVal = $(this).find("input[name=contentType]").val();
if (labelVal || typeVal) {
$(this).find("input[name=queryString]").on("keyup", function() {
var input = $(this).val();
var livesearchForm = $(this).parent().parent().parent();
var spaceKey = livesearchForm.find("input[name=where]").val();
var newLink = '/dosearchsite.action?cql=siteSearch+~+"' + input + '"';
if (labelVal) {
newLink += '+and+label+%3D+"' + labelVal + '"';
}
if (typeVal) {
newLink += '+and+type+%3D+"' + typeVal + '"';
}
if (spaceKey !== "conf_all") {
newLink += "+and+space+%3D+" + spaceKey;
}
livesearchForm.attr("action", AJS.params.contextPath + newLink);
setTimeout(function() {
var moreLink = livesearchForm.prev().find("a.search-for");
moreLink.attr("href", AJS.params.baseUrl + newLink);
}, 500);
});
}
});
});
</script>

thanks. I'll try that. I might help some of my problem.

I doesn't make sense to change the search globally. I have a searchbar on my "front page", and hopefully the script will help me there.

My other searchbox is in the header for the space (I made the header in wiki markup in the configuration.

My guess is that in order to make it work, in the header as well, I could make the header as a css in stead?

Again, thanks for the answar.

Helle

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

327 views 17 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you