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

    #31
    Thanks for this modification. It works perfect for me.

    Comment


      #32
      I just re-applied this mod after upgrading to V5.5.3 but it doesn't seem to work any longer ?

      Comment


        #33
        is this compatible with php 7.3.7 ?

        Comment


          #34
          Theoretically it should be compatible as there's nothing special being done that would break in future PHP versions. But I'd have to check to verify.

          Comment


            #35
            I updated the code in the first post. Could you try again?

            There's a bug in vB where backslash "\" in posts are stripped off. The code has "\" that were stripped off which would cause syntax error. This could explain why the mod stopped working.

            I found a workaround to prevent a backlash from being removed from posts by using double backslashes.

            Comment


              #36
              hi thanks for the mod however I noticed some issues, it will be grateful if you can help me with

              once applying the above the forum base links is redirecting to invalid link please see the attached screenshots

              it is directing to
              /vb/$rightlink

              instead of
              /vb/node/224397

              also I have file upload script in the same domain of my forum the same issue noticed with the links added to my forum

              it is directing to
              /vb/$rightlink

              instead of
              /up/do.php?id=1501


              Attached Files

              Comment


                #37
                I used the same method you described, however I discovered the issue in the code the below code with small adjustment worked for me perfectly

                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) {
                    return 
                "<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=";

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

                thanks alot

                Comment


                  #38
                  Hi

                  it seams it is not working for in RSS feeds, is their any way to enable it there also ?

                  Comment

                  Working...
                  X