Use php, code and html tags as appropriate when posting code.
It is not at all clear what you are trying to do or what isn't working. There is no apparent connection between the two blocks of php code.
ezra1973;10966734 wrote:
This is my php file that already displays code correctly on my tpl file I just need to add the above code to it correctly.
The php code does not display code in any tpl files. The php code can generate output, and it can assign data to template variables that are used to generate output in the template file.
You should not add php code to any template file.
# The function does not return a string, it returns null. The doc block is
# correct though - your plugin should return a string
/**
* @return string
*/
# If the only thing the function deals with are dimensions, why not call it
# ..._getTrailerDimensions?
function smarty_function_getTrailerAttribs($params, &$smarty)
{
# Why is the error supression operator needed?
if ( @$trailer = new ffmpeg_movie($params['trailerLocation']) ) {
# Why use an array that is not used for anything but the equivalent of the
# two function calls you allready perform: getFrameWidth(), getFrameHeight?
/* just remove it
$trailerAttribs = array( 'width' => $trailer->getFrameWidth(), 'height' => $trailer->getFrameHeight() );
*/
# This is a bad idea. Once your plugins start assigning to smarty variables
# you have a high risk of ending up overwriting variables that are allready
# in use, and then you have a really hard time of debugging ahead of you.
# Still, this is where your member function calls should have been made
/* Just remove this part as well
$smarty->assign("trailerWidth", $trailer->getFrameWidth());
$smarty->assign("trailerHeight", $trailer->getFrameHeight());
*/
# This is how you should do it
return 'width: '.$trailer->getFrameWidth().'; height: '.$trailer->getFrameHeight().';';
# Or possibly like this
return 'width="'.$trailer->getFrameWidth().'" height="'.$trailer->getFrameHeight().'"';
}
}
It's also very likely that this plugin isn't needed, and that you could instead do
width: {trailer->getWidth()}; height: {$trailer->getHeight()};
The trailer should of course be assigned to a smarty variable first, and that's done in php code before the template is displayed.