Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » How to Redirect and Return based on...
How to Redirect and Return based on Part of URL ?
How to Redirect and Return based on Part of URL ?
Hi, I cannot live without metamod and ise it on all mu sites for years. Thanks for awesomness!
I played with a code prior to ask , ( by sing existing rule for keywords) but I am not a programmer and need your support.
There are two separate tasks i know that memtamod is capable to achieve.
Condition: when some one visit via a link that contains special identifiers that identify my ad number ( Facebook for example ) with a link such as http://mytsite.com/page/s22a77 where i use s22a77 or ?s22a77 to identify a particular ad,
ACTIONS:
1) I want metamod to recognize s22a77 in the link and Redirect to a page: http://mysite.com/specialpage
a) Instant redirects
b) Delay redirect for 3 seconds
2) I want metamod to recognize s22a77 in the link ONLY to return Module 234 and Module 345
3) I want metamod Redirect and Return by recognising s22a77 in the URL ( combintion of the two at the same tome)
I greatly appreciated your support, please help with the code if possible.
Re: How to Redirect and Return based on Part of URL ?
Hi Alex,
thanks for your questions.
You can detect the current URL this way:
if ($core_genius->check("url contains page/s22a77")) { ... }
You can do an instant redirect like this:
$app = JFactory::getApplication();
$app->redirect( $url );
You can do a timed redirect like this, inserting some JS code into the head section of the page:
$url = "http://mysite.com/specialpage";
$js = '<script>
window.setTimeout(do_redirect, 3000);
function do_redirect() {
document.location.href=\'' . str_replace("'", "'", $url) . '\';
}</script>';
JFactory::getDocument()->addCustomTag($js);
Putting these all together, here's the instant redirect version:
if ($core_genius->check("url contains page/s22a77")) {
$url = "http://mysite.com/specialpage";
$app = JFactory::getApplication();
$app->redirect( $url );
}
Here's the timed redirect version:
if ($core_genius->check("url contains page/s22a77")) {
$url = "http://mysite.com/specialpage";
$js = '<script>
window.setTimeout(do_redirect, 3000);
function do_redirect() {
document.location.href=\'' . str_replace("'", "'", $url) . '\';
}</script>';
JFactory::getDocument()->addCustomTag($js);
}
Here's the timed redirect plus show 2 modules (before the redirect) version:
if ($core_genius->check("url contains page/s22a77")) {
$url = "http://mysite.com/specialpage";
$js = '<script>
window.setTimeout(do_redirect, 3000);
function do_redirect() {
document.location.href=\'' . str_replace("'", "'", $url) . '\';
}</script>';
JFactory::getDocument()->addCustomTag($js);
}
return "234, 345";
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » How to Redirect and Return based on...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7627
- Newest User:
- rudys68879
- Members Online:
- 0
- Guests Online:
- 154
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked