Canapin  
                
                  
                    June 23, 2018, 11:47am
                   
                  1 
               
             
            
              Hi.
I wanted my top menu identical to my Wordpress site (I use WP-Discourse), this is why I kept the “Forum” menu item.
I would like this link to reload the forum body when clicked on, exactly when we click on the logo from the regular discourse header bar.
How can I achieve this?
             
            
              
                
            
           
          
            
              
                Johani  
              
                  
                    June 23, 2018, 11:52am
                   
                  2 
               
             
            
              Do you mean reload as in cause the whole page to reload - reload the entire app - or do you just want the link to take you to the homepage within the app?
             
            
              
            
           
          
            
              
                Johani  
              
                  
                    June 23, 2018, 12:06pm
                   
                  4 
               
             
            
              Try setting the href of the link to "/" Like so:
<a href="/">FORUM</a>
             
            
              
            
           
          
            
              
                Canapin  
              
                  
                    June 23, 2018, 12:07pm
                   
                  5 
               
             
            
              Hi, I already tried that as well as adding data-auto-route="true" with no success.
             
            
              
            
           
          
            
              
                Johani  
              
                  
                    June 23, 2018, 12:19pm
                   
                  6 
               
             
            
              Try something like this:
<a href="/" class="home-link">FORUM</a>
<script type="text/discourse-plugin" version="0.8.20">
$(function() {
  $("a.home-link").click(function() {
    require("discourse/lib/url").default.routeTo(
      $(event.currentTarget).attr("href")
    );
    return false;
  });
});
</script>
Where you give your link the classname home-link and run a tiny script when it’s clicked to force it to load within the app.
             
            
              2 Likes 
            
            
           
          
            
              
                Canapin  
              
                  
                    June 23, 2018,  3:36pm
                   
                  7 
               
             
            
              Hi, thanks for your reply.
<script>Discourse._registerPluginCode('0.8.20', function (api) {
  $(function () {
    $("a.home-link").click(function () {
      console.log("test");
      require("discourse/lib/url").default.routeTo($(event.currentTarget).attr("href"));
      return false;
    });
  });
});</script>
 
            
              
            
           
          
            
              
                Johani  
              
                  
                    June 23, 2018,  3:44pm
                   
                  8 
               
             
            
              I’m not sure what’s going on on your side, but I’m positive that that would work. Here’s a basic live example on theme creator:
https://theme-creator.discourse.org/theme/Johani/forum-link 
             
            
              3 Likes 
            
            
           
          
            
              
                Canapin  
              
                  
                    June 23, 2018,  3:49pm
                   
                  9 
               
             
            
              Hi, I’ not sure what I did before but it is indeed working. Thank you very much!
             
            
              1 Like 
            
            
           
          
            
              
                system  
              
                  
                    July 23, 2018,  3:49pm
                   
                  10 
               
             
            
              This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.