I need to create a sidebar with various user information for the owner of each page.
For example, if I am viewing a poll, guestbook, blog entry or whatever owned by a specific person, the sidebar would contain information about that person with links to various relevant content.
This is turning out to be much harder than I expected and I wonder if I am missing something.
I am using the phptemplate engine. My first plan was to create a variable called "$page_owner" from $node->uid in _phptemplate_variables in templates.php.
However, I soon discovered that $node is often not available in this function. Apparently it is only provided if the URL is of the form /node/$uid, which it often is not. Eg blogs. Moreover, some objects like guestbooks have owners but are not created as nodes in the guestbook module. In other cases, comments on an object are not nodes, etc.
So my next plan was to create a global variable called $page_owner and define appropriately it in various modules.
However, it appears that no global variables I define in my modules are visible to template.php. The values are always blank no matter where I define them - eg. hook_menu defines a title field that the theme system can use, but no global variables set there can be accessed from template.php .
I have never seen this kind of behaviour in other PHP applications I have coded - it appears that Drupal is wiping out my global variables in the middle of the page creation process.