I've written a lil module with the very limited purpose of creating a link to the subdomain /$uri, so that users can switch between subdomains and stay on the same page.

Mysteriously, the link never makes it onto the menu, if I use a subdomain of my domain in the path =>. If i use some other domain, the link appears fine. I've looked at the array output, and its fine. Drupal is filtering out the result somewhere downstream from the rendering of that menu array.

Where is that?, and how do i fix it?

This might be useful for anyone exploring cross subdomain navigation.

Comments

cog.rusty’s picture

There are a few things that I am not sure I understand:

with the [...] purpose of creating a link to the subdomain /$uri

Do you mean a subdomain as in http://sub.example.com? Does /$url mean that site's place in the file system? Or is it about sites with URLs containing a path?

so that users can switch between subdomains and stay on the same page.

What does it mean to switch between subdomains and stay on the same page? Can you give an example of what the user would do and what should happen if it worked?

if I use a subdomain of my domain in the path =>. If i use some other domain, the link appears fine. I've looked at the array output, and its fine. Drupal is filtering out the result somewhere

There is a lot of security filtering in Drupal (if this is the case here). If you showed some example code someone might know why this array is filtered and how to circumvent the problem.

mkahn’s picture

There is nothing wrong with the code. My print array shows the same array structure from this regardless of what i put into $base. But when $base is my domain, the link stops appearing in my menu.
I got lost reading through menu.inc and bootstrap.inc trying to figure out where its getting filtered out. Its all about what ends up in that path=> statement.

The idea is to go from www.domain.com/currentpage to sfbay.domain.com/currentpage. The link disappears from either part of the if statement when linking to the anything.domain.com. Whereas anything.anyotherdomain.tld works fine.



<?php
// $Id$

/**
*  Implementation of hook menu().
*/

function mymenu_menu($may_cache){
	// Create an array to hold the menu item links
        $items = array();

	if ($may_cache) {
		//  Define a static menu item
		$items[] = array(
		'title' => t('greeting'),
		'path' => 'http://sfbay.domain.com/',
		'callback' => 'mymenu_hello',
		'access' => TRUE
        	);
	}


	else {
		// Define a dynamic menu item
               $baseurl = "qcitysf.com";
		$base = "http://sfbay.domain.com";
		$URI = $base . $_SERVER['REQUEST_URI'];
		$items[] = array(
		'title' => T('sfbay.domain.com'),
		'path' => $URI  ,    
		'callback' => 'mymenu_menu',
		'access' => TRUE
		);
	}

	//print_r($items);

	return $items;
}


function mymenu_hello(){
	return t('Hello');
}

Mark Kahn,
Droople Apprentice

drumm’s picture

If you can reproduce this problem on Drupal 6, go ahead and file an issue. The menu system is not really designed to use external URLs for module-created items.

If all else fails:
* Make a local menu item with callback 'drupal_goto' and the dynamic path in the callback arguments.
* Or, make a block that makes the link with l().