Announcement

Collapse
No announcement yet.

Item Detail page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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.

    GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

    Comment


    • #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.

      GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

      Comment


      • #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


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

          GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

          Comment


          • #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


            • #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>

              GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

              Comment


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

                Thanks!

                Comment


                • #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


                  • #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


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

                      Comment


                      • #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...
                        X