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

  • glennrocksvb
    replied
    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.

    Leave a comment:


  • HaMooooDi
    replied
    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>";

    Leave a comment:


  • HaMooooDi
    replied
    Originally posted by glennrocksvb View Post
    I don't have access to a computer right now to try it myself but try replacing return with $myhtml =. Then follow the rest of the instructions in that article.
    tried doing that but I got error with the all the forum see attached , just to confirm what to do with PHP module ? it is not existed any more I placed the code from the article in HTML module is that correct ?
    Attached Files

    Leave a comment:


  • glennrocksvb
    commented on 's reply
    I'm referring to the PHP code you posted in post #37

  • glennrocksvb
    replied
    I don't have access to a computer right now to try it myself but try replacing return with $myhtml =. Then follow the rest of the instructions in that article.

    Leave a comment:


  • HaMooooDi
    replied
    Originally posted by glennrocksvb View Post
    Try replacing the 2 instances of the return statements into:

    PHP Code:
    $myhtml "the html string here"
    thanks for reply , could you please provide more explanation what is exactly to be changed in the original PHP code ?

    Leave a comment:


  • glennrocksvb
    replied
    Try replacing the 2 instances of the return statements into:

    PHP Code:
    $myhtml "the html string here"

    Leave a comment:


  • HaMooooDi
    replied
    Any update to make this Mod works


    ​could any body compile this help topic from vbulletin forum into readable instructions

    &amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;p&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;We've created a new package that is intended to facilitate the replacement of custom PHP modules with custom Display Template

    Leave a comment:


  • HaMooooDi
    replied
    Any update to make this Mod works

    Leave a comment:


  • HaMooooDi
    replied
    all PHP modules stopped by design after the latest security update

    The PHP module will no longer work after applying the latest security patch. This is by design. This redirect would have to be reworked using a custom API extension or Javascript. See: https://forum.vbulletin.com/articles...php-in-modules

    Leave a comment:


  • HaMooooDi
    replied
    Hi

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

    Leave a comment:


  • HaMooooDi
    replied
    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

    Leave a comment:


  • HaMooooDi
    replied
    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

    Leave a comment:


  • glennrocksvb
    replied
    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.

    Leave a comment:


  • glennrocksvb
    replied
    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.

    Leave a 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 "|||"