Announcement

Collapse
No announcement yet.

How to reference the thread URL without the page variable

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

  • [Forum] How to reference the thread URL without the page variable

    I'm rolling my own addition of FB to my vBulletin forum since I've already done the same for the rest of my site.

    I have this tag in the SHOWTHREAD tempalte:

    <fb:like href="?????" show_faces="false"></fb:like>

    I can leave the href off and FB will "like" the current page. However, I want to specify the URL of the thread, minus the page number because I don't want likes separated by page. I want them to like the thread, not the page of the thread.

    If it matters, I'm also using VBSEO for friendly URLS. The format for the thread page is: [thread_title]-[thread_id]-[thread_page]

    So if someone is at:

    http://www.domain.com/forums/this-is-my-thread-4122-2 (thread id 4122, page 2) I just want the FB like element to look like this:

    <fb:like href="http://www.domain.com/forums/this-is-my-thread-4122" show_faces="false"></fb:like>

    No matter which page they're on.

  • #2
    Do you have Canonical URLs turned on?

    Settings -> Options -> Friendly URL -> Enforce Canonical URL for Registered Users
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      It's already on, but what does that do exactly and how will that help accomplish what I want to do?

      Just to clarify, I'm looking for some sort of a variable that I can drop into the template like this:

      <fb:like href="{vb:threadurlwithoutpage}" show_faces="false"></fb:like>
      Last edited by Scott927; Thu 29 Dec '11, 2:53pm.

      Comment


      • #4
        There is no easy variable like that, you are going to need a custom plugin, probably with this code as a start:

        Code:
          require_once ("./includes/functions_facebook.php");
        
        
          $threadurlwithoutpage = get_fbcanonicalurl();
        The function get_fbcanonicalurl will return the URL without the page number... it won't be the fancy VBSEO URL but it should still work, it really doesn't have to look pretty for Facebook.

        But basically there is a lot more to this including having to register the variables to use in the templates you want and plugin basics... This type of customization is discussed on www.vbulletin.org.

        I'm not really sure why you need to re-invent the Facebook like button- the built in one does this already- you can alter it's look by altering the facebook_likebutton template if you want.

        Comment


        • #5
          My way is a bit messy but it works:

          Plugin. Location - parse_templates
          PHP Code:
          if ($vbulletin->options['ogfb_onoff']){$facebook_liked_url $_SERVER['VBSEO_URI'];$templater->register('facebook_liked_url'$facebook_liked_url);

          vB_Template::preRegister('navbar'$templatevalues);vB_Template::preRegister('vbcms_page'$templatevalues);vB_Template::preRegister('fbog_like_showthread',array('facebook_liked_url' => $facebook_liked_url));vB_Template::preRegister('SHOWTHREAD',array('facebook_liked_url' => $facebook_liked_url)); vB_Template::preRegister('BLOG',array('facebook_liked_url' => $facebook_liked_url));vB_Template::preRegister('blog_entry',array('facebook_liked_url' => $facebook_liked_url));vB_Template::preRegister('vbcms_page',array('facebook_liked_url' => $facebook_liked_url)); vB_Template::preRegister('vbcms_content_article_page',array('facebook_liked_url' => $facebook_liked_url)); vB_Template::preRegister('facebook_likebutton',array('facebook_liked_url' => $facebook_liked_url)); 


          In whichever of the templates -
          HTML Code:
          <fb:like href="{vb:raw vboptions.bburl}{vb:raw facebook_liked_url}" layout="standard" show_faces="true" width="225" action="like" colorscheme="light" />
          My Live vB5 Site - NZEating.com
          vBulletin Hosting | vBulletin Services - Need hosting for your vB? Need it installed? Something else? Let me take that hassle off your hands.

          Comment


          • #6
            Code modification is really a discussion for vBulletin.org.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API - Full / Mobile
            Vote for your favorite feature requests and the bugs you want to see fixed.

            Comment

            Related Topics

            Collapse

            Working...
            X