I am creating a new module that is modeled off the Modal Fame Blocks contrib module. I want to change the function that was included with the blocks module so that the parent script of my new module is loaded on the parent page, and the child script is loaded on the child page. Below is the function that I am using as the model:


function modalframe_blocks_init() {
  if (!empty($_COOKIE['has_js'])) {
    if (preg_match('`^admin/build/block(?:/(?:list(?:/(?:[_a-z0-9]+)?)?)?)?$`', $_GET['q'])) {
      modalframe_blocks_add_js('parent');
    }
    elseif (preg_match('`^admin/build/block/(?:configure/|delete/|add).*$`', $_GET['q'])) {
      modalframe_blocks_add_js('child');
    }
  }
}

My modified function is below in a new module called modalframe_whoareyou2. I want the parent script to load on every page except the page ../content/who-are-you . The script is not working though.


function modalframe_whoareyou2_init() {
  if (!empty($_COOKIE['has_js'])) {
    if (preg_match('`^content/.*$`', $_GET['q'])) {
      modalframe_whoareyou2_add_js('parent');
    }
    elseif (preg_match('`^content/who-are-you.*$`', $_GET['q'])) {
      modalframe_whoareyou2_add_js('child');
    }
  }
}

Any thoughts on what is wrong with my script would be greatly appreciated. Been spending days on this and just getting my head around building modules and PHP...

Comments

burnbright’s picture

Status: Active » Closed (fixed)

For anyone who is interested, I ended up going about it this way:

function modalframe_whoareyou2_init() {
	$url = request_uri();

if (!empty($_COOKIE['has_js'])) {
if ($url == '/content/help-me-better-search') {
      modalframe_whoareyou2_add_js('child');
    }
	
	  else {
	 modalframe_whoareyou2_add_js('parent') ;
    }	
}
 }

Did the trick...