I have a marketing partner that would like to display content from a few (3 or 4) pages of my site within an iframe on a particular page on his site. I want to use a stripped down version of these pages when they are called from this site/iframe rather than having the normal pages render.
My thoughts were to create a custom-page.tpl.php template for this purpose. It would have a small version of our logo & site name & links to the content selected for this purpose. I only want this template to be used when the particular pages are called from that particular source and the normal page.tpl.php would be used for everything else. My idea was to have the pages called with something like http://www.mydrupalsite.com/page1?src=partnersite.
I'm a bit stuck on the implementation. PHP will store the values passed in the url to the $_GET array, but I don't know how to (a) tell Drupal to look there for those values then use custom-page.tpl.php only if they're present and (b) pass those variables to all subsequent pages called from links on that custom page.
I tried adding the following to my template.php file but it didn't do the job.
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'page':
if($_GET['src']=='partnersite') {
$vars['template_file'] = 'custom-page';
}
break;
}
return $vars;
}
I'm using Drupal 6.16 in case the Drupal version makes a difference in terms of how to do what I'm trying to do. Thanks.
Comments
In Drupal 6 you want to use
In Drupal 6 you want to use hook_preprocess_page(&$vars), note $vars is now passed by reference so there is no return. You would place this in your themes template.php file and replace 'hook' with the theme name. It also works as part of module.
Thanks! That solved (a)
Thanks! That solved (a) above. Any ideas about (b)? I guess I could hand-code the links in the custom template so they include the "?src=partnersite" string. However, it would make these pages easier if I could create a custom menu block and could pass these variables to those links via a function or something like that.
Since its only from a single
Since its only from a single site I would try using
$_SERVER['HTTP_REFERER'];which should reflect where the request came from.