Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

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. 
smile

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

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("'", "&apos;", $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("'", "&apos;", $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("'", "&apos;", $url) . '\';
  }</script>';
  JFactory::getDocument()->addCustomTag($js);
}
return "234, 345";

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: How to Redirect and Return based on Part of URL ?

O, man, this is awesome! I know you walked a "second mile" for my question, including some java script. Thank you very much, I will test it immediately. I cannot live without metamod.  Thank you very very much!

alexmartin
Junior Modder
ranks
useravatar
Offline
31 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5910
Total Posts Today:
1
User Info:
 
Total Users:
10144
Newest User:
leonard5412396
Members Online:
2
Guests Online:
294


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked