Announcement

Collapse
No announcement yet.

How to change external links to internal links to do something before redirecting to the destination

Collapse
This is a sticky topic.
X
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #46
    the code I used

    PHP Code:
    $rightlink_host parse_url($rightlinkPHP_URL_HOST);
    $forum_baseurl vB::getDatastore()->getOption('frontendurl');
    $forum_host parse_url($forum_baseurlPHP_URL_HOST);        

    // if same host, then use the link directly
    if (vB5_String::stripos($rightlink_host$forum_host) !== false) {
        
    $myhtml "<a href="$rightlink" target="_blank"" . ($is_external ' rel="nofollow"' '') . ">$text</a>";  
    }
    else { 
    // link to your redirect page and pass the encoded external link

        // specify path of the redirect URL (exclude forum base url) including the querystring parameter name
        // this is the path you used when you created the redirect page in Sitebuilder
        
    $redirect_path "/redirect?url=";

        
    $myhtml '<a href="' $forum_baseurl $redirect_path urlencode($rightlink) . '" target="_blank"' . ($is_external ' rel="nofollow"' '') . ">$text</a>";

    Comment


      #47
      The article doesn't say to use HTML Module. Please read the article carefully again.

      In the main.php file, replace the block where it says "insert your custom PHP code here" with the code you have for this mod.
      Helpful? Donate. Thanks!
      Buy me a coffeePayPal QR Code
      Fast VPS Host for vBulletin:
      A2 Hosting & IONOS

      Comment

      Users Viewing This Page

      Collapse

      There is 1 user viewing this forum topic.

      • Guest Guest

      Latest Posts

      Collapse

      Working...
      X
      Searching...Please wait.
      An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

      Please push the back button and reload the previous window.'
      An unexpected error was returned: 'Your submission could not be processed because the token has expired.

      Please push the back button and reload the previous window.'
      An internal error has occurred and the module cannot be displayed.
      There are no results that meet this criteria.
      Search Result for "|||"