Oops, I just checked this again.
This isn’t still working.
My apologies @nixie, I did not get to this last week. I’ve got a reminder set now to look at this Monday.
@nixie, just took a look, but I can’t reproduce this using the steps you shared.
I did the following:
- Copied Falco’s code above into
<\head>
and enabled the theme. - Returned to the homepage
/latest
- Clicked “Unanswered”, homepage filtered to posts without a reply.
- Clicked latest, filter was removed from URL.
- Clicked “Unanswered”, homepage was again filtered.
I tried the exact same steps from a category /latest
page, and didn’t have any issues there either.
Hmm…not sure on that. @cpradio would need to explain. I’ve always put navigation bar code changes in <\head>
not <\body>
.
I still cannot reproduce it. I just removed all other top nav items and still have no issues. Do you have any other themes with head or body code?
I PM’d you my site URL, you may have a look at it.
Do let me know if you have any questions.
I’m more than happy to do all help that I can to straighten this out
Sounds like it could be this bug:
Update:
Pasting the code under \body - also produces the error.
Pasting the code under \head - also produces the error.
Having 2 nav links - also produces the error.
Having 3 or 4 or 5 nav links - also produces the error.
@jomaxro - checked my site’s config - he couldn’t find anything wrong there.
If anyone have successfully implemented this - please PM me your site’s URL.
To be clear, looking at the existing site customizations as well as the nginx config I said nothing stood out - I never said nothing was wrong.
UPDATE:
It wasn’t my site’s fault.
I just installed a brand new discourse site - (sandbox site) and added the code in there - and it doesn’t work there either.
If anyone got this code working - please post the URL here.
Does this still work?
I’ve tried adding but the link didn’t show up. Perhaps 'cause I’ve added some custom links of my own to my header like this:
<div id="top-navbar" class="container">
<span id="top-navbar-links" style="display:none;">
<a href="http://example.com" class="dow-menu" id="renovar" target="_blank">Assinatura</a>
<a href="http://example.com" class="dow-menu" id="links_menu">Treinamentos</a>
<a href="https://example.com" class="dow-menu" id="links_menu">Categorias</a>
</span>
</div>
Can I somehow add that search as a 4º link on there but to show ONLY to staff?
Actually, I’ve tried adding Falco’s code to show that (1) as a top menu and (2) only to staff. But also didn’t work.
Does anyone knows how to do it?
I’d like to show that link here if possible:
Thanks in advance
That header html has nothing to do with the navigation. This is the post that restricts it to staff
Gotcha!
But I did try to add that code to the section and still does not show at the top menu
Any ideas of what I might be doing wrong?
Like this right?
Still nothing here:
It is hard to tell if you enabled it from that screenshot. I can tell you I have the exact same snippet on my sandbox and it works fine.
@brunoedigital
Did you refresh the page by pressing F5?
But the placement is correct right?
Edit CSS/HTML > Common > </body>
@nixie, I did. But still no go
A new link should appear in the top menu there right?
Do I need to do anything else besides that change? Like settings or something like that?
Adittionaly, and in case this for some reason does not work, could I somehow code my links that I’ve added to my top navigation as to only show to staff?
I mean these ones here:
<div id="top-navbar" class="container">
<span id="top-navbar-links" style="display:none;">
<a href="http://example.com" class="dow-menu" id="renovar" target="_blank">Assinatura</a>
<a href="http://example.com" class="dow-menu" id="links_menu">Treinamentos</a>
<a href="https://example.com" class="dow-menu" id="links_menu">Categorias</a>
</span>
</div>
I don’t know if I can somehow use this if(!category && currentUser != null && currentUser.staff) {
in one of those links somehow.
Even when I try like this it doesn’t work (that’s probably not the way it should work I believe, still tried just to make sure):
I think there is some confusion as to what you are attempting to achieve. Do you want to add a menu item next to Latest, Categories, Unread, New? Or show/hide links at the very top based on whether a person is logged in?
The former is what I linked to for putting in the </body>
or </head>
area. The latter, requires an entirely different process.
So given, your existing HTML markup, you simply need the following HTML and CSS.
<div id="top-navbar" class="container">
<span id="top-navbar-links">
<a href="http://example.com" class="dow-menu" id="renovar" target="_blank">Assinatura</a>
<a href="http://example.com" class="dow-menu" id="links_menu">Treinamentos</a>
<a href="https://example.com" class="dow-menu" id="links_menu">Categorias</a>
</span>
</div>
CSS
html.anon #top-navbar-links { display: none; }
I was actually trying to add the link as a menu item right next to those ones, Latest, Categories, Unread and New.
And if possible I’d like to have that link to be only shown to staff.
But since, for some reason, I cannot make that work, I was thinking of a different implementation by having it up there with my custom nav links.
I even tried creating a new empty theme to try the code and even that didn’t work. Not sure why. It’s not a fresh install. So we might have changed something that’s causing that. No idea what though.
So, moving on:
That CSS code will make the links only available to staff users… or all logged in users will be able to see it?
Is there a CSS code to show it just for staff?
Thanks again for your help!
It is hard to say what you may be doing wrong. As your screenshots have yet to show enough info for us to gleam it was enabled properly.
All logged in, to make it staff, change the HTML and CSS to
<div id="top-navbar" class="container">
<span id="top-navbar-links" style="display:none">
<a href="http://example.com" class="dow-menu" id="renovar" target="_blank">Assinatura</a>
<a href="http://example.com" class="dow-menu" id="links_menu">Treinamentos</a>
<a href="https://example.com" class="dow-menu" id="links_menu">Categorias</a>
</span>
</div>
CSS
body.staff #top-navbar-links { display: inline-block; }
Got it! Will try that! Thanks a bunch!
Yeah no idea as well. But it’s ok. I can work around with that Than ks again!