Override the template block

Hello all,

I am using oxid eshop version 6.2.3. Further, I have overridden the block "block' => 'account_order_history'" to show some custom information to end-customer.
metadata.php:
‘blocks’ => [
[ ‘template’ => ‘page/account/order.tpl’,
‘block’ => ‘account_order_history’,
‘file’ => ‘/views/blocks/page/account/order.tpl’
]
];
So, could anyone please assist me with either this is the right way? Or oxid eshop provides some other possibilities to handle this.

Thanks in advance.

1 Like

Yes, this is the way

Thank you so much for your feedback.

I need one more clarification with above(block overriding) while using themes. Currently, I am using the theme adaption using the following method.

function getTheme() {
$oTheme = oxNew(‘oxTheme’);
return $oTheme->getActiveThemeId();
}

[{if $oViewConf->getTheme() == ‘flow’}]
/** custom information **/
[{/if}]

But I have faced some template issues(responsive) with the “waves” theme when using the above. Also, I found some other option like below(mentioned theme id for each block overriding),
‘blocks’ => [
[
‘theme’ => ‘shop_theme_id’
‘template’ => ‘name_off_shop_template_which_contains_block’,
‘block’=>‘name_off_shop_block’,
‘file’=>‘path_to_module_block_file’
]
];
Could you please suggest which one is the correct way to handle it in the custom module?

in my oinion, it strongly depends on the amount of changes you need in your block tempalte in ordner to make it work with wave-based themes.
E.g. if its just the class name like “col-6” for wave instead of “col-xs-6” for flow, i would simply put both classes into elements, if there are no side ffects from using bootstrap classes from different version.

If you really need to maintain two different template files, i would go with theme definition in metadata.php since it also considers the parent theme. The if-condition like this [{if $oViewConf->getTheme() == ‘flow’}] is only true if you use the flow theme itself, but false if you have a child theme of flow, while theme definition in metadata will also work if your child theme is based on flow no matter of theme’s actual id or name.

Thank you so much for your feedback.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.