I’m trying to add the google custom search engine to the header of our discourse forum. I put in the javascript to the head tag and then in the body there is something like <gcse:search linkTarget="_self"></gcse:search> - which will show the google custom search engine.
When I put this in and save it however, it doesn’t show up on the site. I imagine it is being removed by some sort of html filter? (and I should add that by “doesn’t show up” I mean the code itself, not just that the javascript isn’t loading somehow - when I surround it with <!-- -->, the code passes through, but obviously doesn’t work).
This is just a proof of concept, so you’ll have to play around with it to see how/if it can work for your needs. Try adding this to the </head> tab of a theme:
Actually I may have spoke a little too soon… It’s fairly intermittent when it will show up. I had both versions of your script in so I thought this newer one was working (and it did once - minus putting the search bar on top of the menu, etc. - lower half of the header).
The first script appears to work on the front page only if I put in at the body close section - then it shows up at the top of the page oddly.
I’d like to try to get it right below the header bar on top on every page.
Instead of ‘header-contents:after’ - is there a ‘body-contents:before’? that I could try. I went through the api docs, but couldn’t find anything that showed such a declaration…
Sure, if you change it from header-contents:after to just header:after, that should do the trick. You will need to style it with CSS to get it exactly how you want it, but that should get you on track
안타깝게도 저는 더 이상 gcse를 사용하지 않기 때문에 많은 도움을 드리기 어렵습니다. 한동안 잘 작동했지만, 결국 구글 서비스 전반에서 손을 뗀 후 discourse의 여러 버전 전부터 이를 제거했습니다. 위에 게시된 방법은 작동했지만, 무한 스크롤 문제와 discourse의 변경 사항 사이에서 꽤 많이 조정해야 했습니다.
지금까지 무엇을 시도해 보셨으며, 어떤 오류나 문제가 발생했나요?
관리 부담이 적고 더 깔끔하며 쉬운 방법으로는, 상단에 구글이 호스팅하는 검색 페이지나 여러분이 원하는 다른 위치로 이동하는 버튼을 단순히 포함하는 것이 있을 수 있습니다.
GCSE용 Overlay 테마를 사용 중인데, 검색 결과를 다른 페이지가 아니라 현재 페이지에 표시하고 싶습니다. Discourse에서는 두 가지 페이지 형식을 동시에 사용할 수 없기 때문입니다. 하지만 여전히 검색 버튼이 쿼리 문자열 "?search=search+term"을 추가하고 있습니다.
이로 인해 “No Latest Topics”(최근 주제 없음) 메시지가 표시되고 검색 결과가 나오지 않습니다.
무엇을 놓치고 있는지 알려주시면 감사하겠습니다.
감사합니다.