Item Detail page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webcms
    Senior Member
    • Jan 2014
    • 172
    • 5.0.X

    Item Detail page

    Is there a way in the header/footer to determine if the currently viewed page is a detail page or the homepage of forums/blogs/articles/etc? I need to render a javascript only on item detail pages (such as this page) but not on module homepages.

    TIA
  • glennrocksvb
    Former vBulletin Developer
    • Mar 2011
    • 4011
    • 5.7.X

    #2
    Check via javascript if the div that has a class of conversation-content-widget exists. If it does, it is on the conversation detail page of forum/blogs/groups/articles.

    Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

    Comment

    • glennrocksvb
      Former vBulletin Developer
      • Mar 2011
      • 4011
      • 5.7.X

      #3
      Or if you want it to detect it from the template, you can try this in the footer.

      Code:
      <vb:if condition="$page['templatetitle'] == 'Default Conversation Page Template'">
          <vb:comment>insert javascript</vb:comment>
          <script type="text/javascript">
              ....
          </script>
      </vb:if>
      For debugging purposes, you can add this:

      Code:
      {vb:debugvardump page}
      You may also find other identifying data for conversation detail page that could be better than 'templatetitle' from that info.

      Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

      Comment

      • webcms
        Senior Member
        • Jan 2014
        • 172
        • 5.0.X

        #4
        Hey thanks! I placed the code in the footer template and noticed that it works as expected for only Forums and Blogs but not Groups and Articles:

        Code:
        <vb:if condition="$page['templatetitle'] == 'Default Conversation Page Template'">
            ...
        </vb:if>
        I could live with it not rendering on Groups for now but rendering it on Article detail pages is very important. I wish vB had some kind of variable set to indicate the page as a detail one.

        Any other bright ideas ?

        Comment

        • glennrocksvb
          Former vBulletin Developer
          • Mar 2011
          • 4011
          • 5.7.X

          #5
          Place the debugvardump code in the footer and then load the article detail page and check what the templatetitle says.

          Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

          Comment

          • webcms
            Senior Member
            • Jan 2014
            • 172
            • 5.0.X

            #6
            That's brilliant! It uses the same templatetitle for Forums & Blogs but different values for Groups & Articles = a total of 3 different values.

            I have just one more question: How do I refer to global variables and global constants in templates? I tried the following but it does not work:

            Code:
            <vb:if condition="$GLOBALS['AltCSS']">
                ...
            </vb:if>
            TIA

            Comment

            • glennrocksvb
              Former vBulletin Developer
              • Mar 2011
              • 4011
              • 5.7.X

              #7
              You mean access the global variables and constants declared in the PHP code from the template? I don't think you can. What is it you want to access?

              Can't you use the config settings? For example

              Code:
              <vb:if condition="$config->debug">
                 ...
              </vb:if>
              Or the vB Options

              Code:
              <vb:if condition="$vboptions['facebookactive']">
                 ...
              </vb:if>

              Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

              Comment

              • webcms
                Senior Member
                • Jan 2014
                • 172
                • 5.0.X

                #8
                I was able to resolve my issue by moving my var into config.

                Thanks!

                Comment

                • webcms
                  Senior Member
                  • Jan 2014
                  • 172
                  • 5.0.X

                  #9
                  Oops, I was mistaken. I resolved another bug in a different way.

                  The one I'm up to resolving now is not debug-dependent. It needs to drive off another public var set in PHP code. How do I move this new public var into $config so I can reference it in templates? Do I place it in the 'Misc' element or a new element on its own:

                  Code:
                  $config[ 'Misc' ]['var'] = $value;
                  and reference it in templates:


                  Code:
                  <vb:if condition="$config->var">
                  OR:
                  Code:
                  <vb:if condition="$config->Misc->var">
                  OR:
                  Code:
                  $config[ 'my' ]['var'] = $value;


                  Code:
                  <vb:if condition="$config->my->var">
                  Which one works?

                  TIA

                  Comment

                  • webcms
                    Senior Member
                    • Jan 2014
                    • 172
                    • 5.0.X

                    #10
                    I'm noticing something buggy behavior on this site - when I edit a post and save it again and again, it does not get saved later on. Tried refreshing the page too - changes did not get saved.

                    Comment

                    • webcms
                      Senior Member
                      • Jan 2014
                      • 172
                      • 5.0.X

                      #11
                      Ok, I nailed it. At least, I found a bug saving edits in 5.1.12 beta 1

                      Comment

                      • webcms
                        Senior Member
                        • Jan 2014
                        • 172
                        • 5.0.X

                        #12
                        I tried fixing the typo 5.1.12 to 5.1.2 but it does not save changes. Using Chrome.

                        Comment

                        Related Topics

                        Collapse

                        Working...