Search code examples
javascriptphpjoomla

Show text only if page url contain specific word


I need to show some text on one page only if URL contain specific word. I tried few examples I found on stackoverflow but nothing seems to work.

So I need to show text on this URL - "/index.php?option=com_registration&task=register"

I tried to write the code to recognise word "register" in the URL, but it doesn't work. The text is visible on all pages.

EDIT: The text I want to show is "Creating account will automatically put you on our bi-monthly newsletter email list. Please note: you can unsubscribe at any time."

And it should be located before every content on page.


Solution

  • your URL is - "/index.php?option=com_registration&task=register" if you are doing it with php

    <?php 
      $check = $_GET['task'];
      if(isset($check)){
         #do something...
      }
    ?>
    

    Point is to take query from url and check if it is set, you are doing it with GET method this way, so you will take it with $_GET['parameterName'], variable $check will have value of parameter assigned value