Announcement

Collapse
No announcement yet.

Can I have different title if the sub forum if paginated

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

  • 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

  • #2
    No, this isn't possible, it would require custom coding.
    MARK.B | vBULLETIN SUPPORT

    TalkNewsUK - My vBulletin 5.5.2 Demo
    AdminAmmo - My Cloud Demo

    Comment


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

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


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

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


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


              • #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}
                            <vb:if condition="isset($page['pagenum']) AND $page['pagenum'] > 1">
                                        (Page {vb:raw page.pagenum})
                            </vb:if> -
                <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 Glenn Vergara; Tue 3rd Mar '15, 12:01am.

                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

                Related Topics

                Collapse

                Working...
                X