Announcement

Collapse
No announcement yet.

Modify Link URL

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

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

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


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


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


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

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


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

              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
                The code I suggested was for links posted via the Link icon in the editor. It was not for any links in the post.

                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

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