How to know what page is being accessed in header.tpl ?



  • I'm trying to exclude a feature on the profile page using the header.tpl file. I need an if statement that will say if this is not a profile page then do this. Any ideas? I'm not sure how to identify pages inside the tpl files nodebb provides.


  • Plugin & Theme Dev

    @SatoshiCamp try this...

    $(window).on('action:ajaxify.contentLoaded', function(ev, data) {
      if (data.tpl !== 'account/profile') {
        // things to do if it's not profile page
      }
    });
    


  • @pichalite Thanks. I would rather do this on the server side though because I don't want to load this content on the profile page at all. With client side javascript, the best I can do is remove the node after the page is loaded and that is messy. It would have to be an if statement in the header tpl file. Something like this...

    <!-- IF page.profile -->
    

    Is that possible? I'm not sure what variable hold that information. Also, does nodebb reload the entire template when changing pages? Or does it only load the header file once? The latter would probably make a server side implementation not possible. Thanks again.


  • Admin

    @SatoshiCamp The header is loaded once, and if you navigate between pages, the header is not loaded again.

    So it looks like you'll want to use a client-side solution for this.


Log in to reply
 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.