Redirect / for non-logged in users?

(Sam) #12

And it works quite nicely! Thanks @riking and @JSey for your little plugin that I’ve been using up until now. :grinning:

(Glynhudson) #13

Now that his patch has been integrated how can I implement on my site? I would like to direct logo click to /latest and make categories the first landing page to help new users.


(Sam) #14

Just copy and paste riking’s script here into </head> in Admin -> Customize -> CSS/HTML to have the logo redirect to /latest.

To make categories the landing page, go to Admin -> Site Settings -> Basic Setup and make categories the first entry in the list for the top menu setting.

(Glynhudson) #15

Works a treat :smiley:

Thanks so much for quick reply.

My new forum setup is coming along nicely So much nicer than our old Durpal 6
PHP setup Forums | Archived Forum

(Joe Seyfried) #16

Uh - and @Yuun’s code broke again:

Error: Could not find module discourse/components/home-logo

Where did that disappear to? Did a quick recursive grep, but came up with nothing?!

Help us test the new header code!
(Rafael dos Santos Silva) #17

It’s broke because the new header.

(Joe Seyfried) #18

Yup, seen that, thanks. I guess I will x-post my question there since it belongs to that new addition.

(Robin Ward) #19

I’ve added a new widget setting to customize that url in this commit:

Here’s an example of how to use it via a customization:

<script type="text/discourse-plugin" version="0.4">
  api.changeWidgetSetting('home-logo', 'href', '/new-url')

Just replace /new-url whatever you want the path to be and you should be good to go.

Show 'Categories' to New Users, 'Latest' to Members 📈
(Rafael dos Santos Silva) #20

I want to change the behavior of the home logo only when users are at my home page (window.location === ‘’).

Should passing a function as the third parameter work?

(Robin Ward) #21

Hmmm, how did you do that before? I thought targetUrl was just a parameter?

(Joe Seyfried) #22

Thanks a lot Robin - looks great. Only that the snippet you posted just gives me this error:

TypeError: Attempted to assign to readonly property.

or, on Chrome:

Uncaught TypeError: Cannot set property 'href' of undefined

…and makes the whole header disappear.

I guess I’m just missing something here?

(Robin Ward) #23

Did you get the latest master first? I tried it locally and it worked fine.

(Joe Seyfried) #24

That’s the first thing I did before trying it! Is there a special section where I have to put the script code?

(Robin Ward) #25

Aha it seems the tests-passed branch failed to build due to a failing test. I’m fixing it now.

edit: fixed the test. Give it 15-20 mins and it should have a new version for you.

(Rafael dos Santos Silva) #26

Sorry, this was done in a hurry :laughing:

  window.goToPortal = function() { 
      if (window.location.href === '') { 
          window.location = '';

  var HeaderView = require('discourse/views/header').default

    didInsertElement : function(){
      this._super();'afterRender', this, this.afterRenderEvent);
    afterRenderEvent : function(){
      var logo = $('img#site-logo.logo-big').parent()[0];
      logo.addEventListener('click', window.goToPortal, false);

Can you help me @eviltrout ?

(Joe Seyfried) #27

Like a charm. Thanks!

(Robin Ward) #28

Hmmm that is a little complicated to establish in the new settings. Does adding that event work in the case where the url is not ? It seems the click handler would do nothing.

(Rafael dos Santos Silva) #29

Yes, when the user isn’t at the forum home, I want the normal behavior (scroll up / go back to home).

Only when we are already at the forum home, I want to go back to my Portal home.

(Robin Ward) #30

It’s quite tricky to do what you’re asking, because once an event is handled from the logo it prevents default.

I’ve added the ability for the href setting to be a function. Whatever value you return will be the destination when the user clicks the logo:

(Rafael dos Santos Silva) #31

Should this work?

<script type="text/discourse-plugin" version="0.4">
  api.changeWidgetSetting('home-logo', 'href', function() { 
          return '';


Setting it to ‘/another/page’ when using Discourse under ‘/forum’ also breaks :sadpanda:.

Home logo url points to the root of the domain even in a subfolder install?