I get the following error when I copied the region--branding.tpl.php to my subtheme and named it region--branding_second.tpl.php

Notice: Undefined variable: linked_logo_img in include() (line 7 of /sites/all/themes/omega_msk/templates/region--branding_second.tpl.php

The issue at http://drupal.org/node/1182838 is similar but the solution seems a work-around to a what I see as a more basic problem which shouldn't require modifying the template.php file.
The branding region is default, I haven't made any changes to it.
This is a new site; with no beta or previous code so I don't think there are any cache issues going on.
Logo, Site Name and Site Slogan are checked in my themes setting and it occurs regardless of whether I have the default logo checked or not checked, or have added my own.

Comments

marcoka’s picture

Status: Active » Needs review
cellar door’s picture

Status: Needs review » Postponed (maintainer needs more info)

Are you still dealing with this error? If so can you include more information on what you're trying to do in the branding second region? We may be able to solve this another way.

yashadev’s picture

Title: undefined variable linked_logo_img in region--branding_second.tpl.php » Undefined variable when defining a new region
Version: 7.x-3.0 » 7.x-3.x-dev
Status: Postponed (maintainer needs more info) » Active

I'm getting a similar error. If you create a new region in templates folder, for example region--sidebar.tpl.php in my case, and use a variable from the variables database, you would get an error saying that the variable is undefined. My guess is that it needs to be declared in template.php first. Is that correct?

cellar door’s picture

Category: bug » support

Are you trying to create a new region or a tpl for a region already declared? If you haven't yet declared the region in your .info file this could be the reason you are getting the error.

See this page on creating new regions for omega http://drupal.org/node/1416128

yashadev’s picture

Sorry for the confusion, the region's already declared in info file. I am trying to modify the tpl file from default (for example, to display some static information). I have a module that is storing some values in, let's say, $somevariable. Which has a value of $variables['somevariable']. Even though $somevariable and $variables are accessible and defined, they are not accessible from the tpl file. Does that make sense?

I'm having trouble accessing the variable (and essentially its value) from any modified tpl file.

yashadev’s picture

Title: Undefined variable when defining a new region » Undefined variable when modifying a *.tpl file

Corrected the title to make more sense of the problem

cellar door’s picture

Yes I would try using a pre-process function to declare the variable and see if you can access it that way. Be sure to use the THEME_alpha_preprocess_hook on your function.

yashadev’s picture

Nope, still unable to access it. The only method I found is to use variable_get('variable_name'); instead of using $variables['variable_name] or $variable_name (that is defined in preprocess function obviously).

vdchristelle’s picture

Any follow up on this one? I have the same problem.

spidersilk’s picture

Having this same issue, in Omega 7.x-3.1, while trying to divide the branding region into branding_first and branding_second, with the site logo in one and slogan in the other.

I did find a preprocess function called omega_alpha_process_region(&$vars) in Omega's template.php file, copied it into my theme's template.php, changed the name, and modified the branding section of it to reflect the two branding regions and which variables should be available in each - that enabled the elements in question to show up, but I still got the undeclared variable message, even though it was successfully rendering the logo and slogan.

I tried changing the format of the variable names from $variable_name to $vars['variable_name'], and got a new (this time fatal) error: "Function name must be a string on line 3". Line 3 of that template is :
<?php if ($vars('linked_logo_img') || $site_name): ?>
so there isn't even a function name in there - I have no idea what it's referring to.

I also tried using variable_get() as suggested in comment #8, and that had the effect of removing the PHP errors, but the site name and slogan didn't show up any more.

Really not sure what else to try...

spidersilk’s picture

Version: 7.x-3.x-dev » 7.x-3.1
Issue summary: View changes