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.
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
-
the code I used
PHP Code:$rightlink_host = parse_url($rightlink, PHP_URL_HOST);
$forum_baseurl = vB::getDatastore()->getOption('frontendurl');
$forum_host = parse_url($forum_baseurl, PHP_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>";
}
- Top
- Translate
- Bottom
Leave a comment:
-
Originally posted by glennrocksvb View PostI 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.
- Top
- Translate
- Bottom
Leave a comment:
-
I'm referring to the PHP code you posted in post #37
- Top
- Translate
- Bottom
-
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.
- Top
- Translate
- Bottom
Leave a comment:
-
Originally posted by glennrocksvb View PostTry replacing the 2 instances of the return statements into:
PHP Code:$myhtml = "the html string here";
- Top
- Translate
- Bottom
Leave a comment:
-
Try replacing the 2 instances of the return statements into:
PHP Code:$myhtml = "the html string here";
- Top
- Translate
- Bottom
Leave a comment:
-
Any update to make this Mod works
could any body compile this help topic from vbulletin forum into readable instructions
- Top
- Translate
- Bottom
Leave a comment:
-
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
- Top
- Translate
- Bottom
Leave a comment:
-
Hi
it seams it is not working for in RSS feeds, is their any way to enable it there also ?
- Top
- Translate
- Bottom
Leave a comment:
-
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($rightlink, PHP_URL_HOST);
$forum_baseurl = vB::getDatastore()->getOption('frontendurl');
$forum_host = parse_url($forum_baseurl, PHP_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>";
}
- Top
- Translate
- Bottom
Leave a comment:
-
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
- Top
- Translate
- Bottom
Leave a comment:
-
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.
- Top
- Translate
- Bottom
Leave a comment:
-
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.
- Top
- Translate
- Bottom
Leave a comment:
Users Viewing This Page
Collapse
There is 1 user viewing this forum topic.
- Guest
Latest Posts
Collapse
-
Comment on Topic Starter Ribbon for vBCloudby glennrocksvbThanks for confirming the fix works.Today, 08:20 AM
-
Reply to Topic Starter Ribbon for vBCloudby glennrocksvbI have updated the template code in the first post. Please try it again.Today, 06:38 AM
Leave a comment: