Ticket #142 (closed defect: fixed)

Opened 10 months ago

Last modified 9 months ago

Themes don't work properly if they don't define filter functions

Reported by: rickc Owned by:
Priority: major Milestone: 0.4
Component: Themes Version: SVN
Keywords: themes, plugins, has_patch Cc:

Description

What I did: I placed calls to $theme->header() in my theme's header template, and $theme->footer() in my theme's footer template. I installed a plugin that defined a theme_footer( $theme ) function to output data in my theme's footer.

What I expected: The data to appear in my theme's footer.

What I got: The page display was either truncated or this error appeared on my login page:

Error: implode() [function.implode]: Invalid arguments passed /system/classes/theme.php : Line 517

I worked around the error by defining a basic filter_theme_call_footer() function in my theme:

function filter_theme_call_footer( $return, $theme ) {

return $return;

}

The same events occur with the header, except the reader is left staring at a blank page since anything in the body of the page is truncated. The fix is also the same, define a minimal filter_theme_call_header() function in the theme class.

It is my understanding that placing calls to $theme->header/footer/sidebar() in a theme's templates is supposed to allow plugins to define theme_header/footer/sidebar() and filter_theme_call_header/footer/sidebar() functions to output into the theme's templates or filter the information before it is output without having to define these filter functions in the theme class.

Attachments

theme.php.diff (1.2 kB) - added by dmondark 10 months ago.
142.diff (8.7 kB) - added by ringmaster 10 months ago.
Attempt at a larger fix.

Change History

Changed 10 months ago by dmondark

Both of these filter methods in the base theme class are passed the output as an array but handle it as a string. This resulted the $output variable to be casted to a string and the implode to fail as a result.

	public function filter_theme_call_header( $output, $theme ) {
		$output .= Stack::get( 'template_stylesheet', '<link rel="stylesheet" type="text/css" href="%s" media="%s">'."\r\n" );
		$output .= Stack::get( 'template_header_javascript', '<script src="%s" type="text/javascript"></script>'."\r\n" );
		return $output;
	}

If these methods are defined in the template's theme.php they will override the ones in the base class. This is why we don't get the error when they are added to the template.

A patch is attached which should fix this particular issue.

Changed 10 months ago by dmondark

Changed 10 months ago by rickc

dmondark - The patch worked for me.

Changed 10 months ago by ringmaster

Attempt at a larger fix.

Changed 10 months ago by morydd

  • keywords plugins, has_patch added; plugins removed

Changed 9 months ago by ringmaster

  • status changed from new to closed
  • resolution set to fixed

Fixed in r1348.

Note: See TracTickets for help on using tickets.