Can I have different title if the sub forum if paginated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sowmya002
    Member
    • Feb 2014
    • 80
    • 5.0.X

    Can I have different title if the sub forum if paginated

    Hi,

    We have a forum and in this forum under a subforum we have more than 1 page pf topics. So when we click on next it takes us to /forum/subforum/2. Is it possible to have different titles for /forum/subforum and /forum/subforum/2.

    Thanks!
    Sowmya
  • Mark.B
    vBulletin Support
    • Feb 2004
    • 24286
    • 6.0.X

    #2
    No, this isn't possible, it would require custom coding.
    MARK.B
    vBulletin Support
    ------------
    My Unofficial vBulletin 6.0.0 Demo: https://www.talknewsuk.com
    My Unofficial vBulletin Cloud Demo: https://www.adminammo.com

    Comment

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

      #3
      By title did you mean the document title (as seen in the browser tab) or the forum title displayed on the page? Either way, if this is not for SEO, we can programmatically add the page number in the title via javascript and insert the script via template hook.

      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

      • sowmya002
        Member
        • Feb 2014
        • 80
        • 5.0.X

        #4
        Hi Mark and Glenn,

        Thanks for your replies!

        Glenn,

        By title I mean the <title> tag in view source which in fact appears in the browser tab too. If I need to add the page number how do I go about it? Can you please throw some more light on where and how the code can be inserted?

        Thanks!
        Sowmya

        Comment

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

          #5
          Create a mod via template hook. If you don't know how to create one, go check one of my mods (see my sig) and follow the instructions there. They're for different mods but the instructions are similar. You just have to change the hook title and template name and of course, the content of the template which is below:

          Code:
          <script>
          (function($) {
              var $channelWidget = $('.forum-channel-content-widget');
              if ($channelWidget.length) {
          
                  var addPaginationInTitle = function(firstLoad) {
                          var match = location.pathname.match(/\/page([0-9]+)$/);
                          if (match) {
                              var pageNum = match[1],
                                  totalPages = $('.conversation-toolbar:visible .pagenav .pagetotal').text();
          
                              document.title = document.title.replace(regex, '') + ' (Page ' + pageNum + ' of ' + totalPages + ')';
                          }
                          else if (!firstLoad) { //reset title to original
                              document.title = document.title.replace(regex, '')
                          }
                      },
                      regex = /\s\(Page\s[0-9]+\sof\s[0-9]+\)$/g;
          
                  $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
                      if (options.url.indexOf('/activity/get') !== -1) {
                          var origSuccess = options.success;
                          document.title = document.title.replace(regex, '');
                          options.success = function (data, textStatus, jqXHR) {
                              //call original success callback
                              origSuccess.apply(this, [data, textStatus, jqXHR]);
          
                              //add pagination in the document title
                              addPaginationInTitle();
                          };
                      }
                  });
          
                  addPaginationInTitle(true);
              }
          
          })(jQuery);
          </script>
          Note that since we are dynamically adding the title via javascript, search engines will not see this change.

          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

          • sowmya002
            Member
            • Feb 2014
            • 80
            • 5.0.X

            #6
            Hi Glenn,

            Thanks for your reply!

            But if search engines don't see this and it won't help with SEO what will be the relevance of this change. We were in fact trying to do this for SEO purpose so that we can avoid duplicate tags in multiple pages. Is that achievable?

            Thanks!
            Sowmya

            Comment

            • sowmya002
              Member
              • Feb 2014
              • 80
              • 5.0.X

              #7
              Hi,

              Any updates? Is there is any way with which we can append 1,2,3, etc to the paginated sub forum titles so that SEO part will be taken care and bots will be able to see that.
              Even if it is custom coding should be ok, but might need some directions to start with.

              Thanks!
              Sowmya

              Comment

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

                #8
                The smallest change you could do is to add the page number but excluding the page total. The page total is not in the $page variable so you have to modify page frontend controller if you want to add page total to the $page variable.

                In the header template, change this line:
                Code:
                <vb:if condition="$page['channelid'] != $nodeid AND !empty($conversationStarter) AND isset($conversationStarter['htmltitle']) AND !empty($conversationStarter['htmltitle'])">
                            {vb:raw conversationStarter.htmltitle} -
                <vb:elseif condition="isset($page['title'])" />
                to:

                Code:
                <vb:if condition="$page['channelid'] != $nodeid AND !empty($conversationStarter) AND isset($conversationStarter['htmltitle']) AND !empty($conversationStarter['htmltitle'])">
                            {vb:raw conversationStarter.htmltitle}
                            [COLOR=#FF0000]<vb:if condition="isset($page['pagenum']) AND $page['pagenum'] > 1">
                                        (Page {vb:raw page.pagenum})
                            </vb:if>[/COLOR] -
                <vb:elseif condition="isset($page['title'])" />
                The added code is in red. You have to keep the JS code for adding page number in the title to make it sync as you switch pages via AJAX. But you have to tweak it to make sure the Page X is in the same spot (in between the topic title and site name) as when the page loads and also to remove the page total.

                Sample output:
                HTML Code:
                <title>This is the thread title (Page 2) - Site Name</title>
                Last edited by glennrocksvb; Tue 3 Mar '15, 12:01am.

                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

                Related Topics

                Collapse

                Working...