Modify Link URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wdwms
    Member
    • Jan 2013
    • 90
    • 4.2.X

    Modify Link URL

    I want to modify link URLs (that is, URLs that users have included in a thread/post using the insert link icon in the editor). Specifically this is so that I can re-write ebay URLs to be compliant with their affiliate program.

    I've been able to modify in-line URLs by adding some custom code to /includes/vb5/template/bbcode.php - essentially before the // standard URL hyperlink code is called in function handle_bbcode_url I review the URL and modify it.

    This works for in-line links, but not for those that users insert via the Link button.

    I'd like to do the same for the link button, but can't seem to find where the code is that displays the URL. I see it is using the link template, but i can't find what calls it. Can you advise? Thanks!
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 73981

    #2
    The output is formatted by the display_contenttype_conversationreply_Link template. This is located within the Template Editor section of the Style Manager. Go to Styles & Templates (Styles & Themes in 5.1.8+) in the AdminCP and click on Style Manager. Then either select Edit Templates off the Dropdown menu for your Style or click the <<>> button on the far right. Please not that if you're using a theme, you need to create a Child Style before you can edit any templates. You would need to make your changes to each style/theme that you want to use.

    For more help with your custom coding and modifications, you should visit www.vbulletin.org.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment

    • wdwms
      Member
      • Jan 2013
      • 90
      • 4.2.X

      #3
      Wayne Luke That is the display template for entering data. I want to modify it as it is displayed. For instance here is the code I have inserted into /includes/vb5/template/bbcode.php

      PHP Code:
      $rightlink str_replace('  '''$rightlink);
              
      $parsedurl = @parse_url(vbstrtolower($rightlink));

              
      // check if this URL is an eBay one
              
      if (!strpos($parsedurl['host'], '.ebay.'))
              { return 
      "<a href="$rightlink" target="_blank"" . ($is_external ' rel="nofollow"' '') . ">$text</a>"; }
              
      $encodedlink urlencode($rightlink);
              
      $rightlink 'http://rover.ebay.com/rover/1/711-53200-19255-0/1?campid=5337223410&amp;toolid=10001&amp;mpre=' $encodedlink;
              return 
      "<a href="$rightlink" target="_blank"" . ($is_external ' rel="nofollow"' '') . ">$text</a>"
      I want to do the same for the display of a link, but can't find the file where this is done.

      Comment

      • Wayne Luke
        vBulletin Technical Support Lead
        • Aug 2000
        • 73981

        #4
        I don't know. You would be best off asking at www.vbulletin.org.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API

        Comment

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

          #5
          Not tested but try adding this in the link template in the first line.

          PHP Code:
          {vb:set parsedurl, {vb:php vB5_String::parseUrl, {vb:raw url}}}
          <
          vb:if condition="strpos($parsedurl['host'], '.ebay.')=== FALSE">
              {
          vb:set newurl'http://rover.ebay.com/rover/1/711-53200-19255-0/1?campid=5337223410&amp;toolid=10001&amp;mpre='}
              {
          vb:strcat newurl, {vb:urlencode, {vb:raw url}}
              {
          vb:set url, {vb:raw newurl}}
          </
          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

          • Schraubär
            New Member
            • May 2007
            • 13
            • 3.8.x

            #6
            Glenn Vergara
            I tested it and it didn't work.

            I can not save the template after including the code.

            Have anyone a solution ?

            BR

            Comment

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

              #7
              Is there any error when saving the template? There may be syntax errors in the code.

              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

                #8
                The code I suggested was for links posted via the Link icon in the editor. It was not for any links in the post.

                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

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...