How to change product.tpl in a good way?

Hi, I need for my module to make changes in the product.tpl file. But it is a include file so I cannot override it like I would with e.g. payment.tpl, or can I? I would rather not change directly in that file as it will possibly affect other systems negatively.

[QUOTE=betatest;32438]Hi, I need for my module to make changes in the product.tpl file. But it is a include file so I cannot override it like I would with e.g. payment.tpl, or can I? I would rather not change directly in that file as it will possibly affect other systems negatively.[/QUOTE]
Of course you can override it, as any other template file.

[QUOTE=avenger;32444]Of course you can override it, as any other template file.[/QUOTE]

That sounds great, so where do I do that?

With the other template files I override it in its corresponding views/somefile.php file. But there is no product.php file.
And I do it by changing what the render function returns. Maybe Im doing it wrong?

Not just overwrite, use a awn variable and extend it.

eg:
[{influde file=“inc/product.tpl” sMyVar=“details”}]

In the product.tpl:


[{if $sMyVar=='details'}]
  ..
[{elseif $sMyVar=='whatEver'}]
  ..
[{else}]
  [{*include the basic template, needs realtive path*}]
  [{include file="../../basic/tpl/inc/product.tpl"}]
[{/if}]

So you can use your product.tpl and, if not, orignal oxid tpl.

[QUOTE=MBa;32462]Not just overwrite, use a awn variable and extend it.

eg:
[{influde file=“inc/product.tpl” sMyVar=“details”}]

In the product.tpl:


[{if $sMyVar=='details'}]
  ..
[{elseif $sMyVar=='whatEver'}]
  ..
[{else}]
  [{*include the basic template, needs realtive path*}]
  [{include file="../../basic/tpl/inc/product.tpl"}]
[{/if}]

So you can use your product.tpl and, if not, orignal oxid tpl.[/QUOTE]
Thanx for a worthy idea :slight_smile: But that doesnt work either. Why? Well it is being included in pretty precisely 20 places and 13 files. To change 13 files so you dont have to change 1 is unfortunately not working.

Im sorry for being unclear and not sharing this information right away in post 1. Should have been more clear with the include file thingy in the first post :frowning:

[QUOTE=betatest;32476]Thanx for a worthy idea :slight_smile: But that doesnt work either. Why? Well it is being included in pretty precisely 20 places and 13 files. To change 13 files so you dont have to change 1 is unfortunately not working.

Im sorry for being unclear and not sharing this information right away in post 1. Should have been more clear with the include file thingy in the first post :([/QUOTE]

I dont understand well. For me it works fine.

you don’t need to change any file… of course, you can switch the template by standard oxid variables.

[QUOTE=MBa;32487]I dont understand well. For me it works fine.

you don’t need to change any file… of course, you can switch the template by standard oxid variables.[/QUOTE]

Well, the problem is that you can do that, but if you build a module that shall work on as many systems as possible then doing it like this aint really a good option. Ive solved this in my own way instead now, i.e. by not doing it. Verry sad that there is no sufficent solution imo.

And for those that aint mindreaders like me and reading this post in the future; he is most likely refering to the config.inc.php file in which you can change both the template and add a custom template. And the problem: What if the shop already has both set?

And where is the Problem?
If you write a Modul, you can do something like this:


echo oxConfig::getInstance()->getConfigParam('sTheme');
echo oxConfig::getInstance()->getConfigParam('sCustomTheme');

If you need this informations in a Template, you can register this variables or register a function (modules/functions.php). How to call a normal, registered function in Smarty, you find in the smarty-docu.

[QUOTE=MBa;32608]And where is the Problem?
If you write a Modul, you can do something like this:


echo oxConfig::getInstance()->getConfigParam('sTheme');
echo oxConfig::getInstance()->getConfigParam('sCustomTheme');

If you need this informations in a Template, you can register this variables or register a function (modules/functions.php). How to call a normal, registered function in Smarty, you find in the smarty-docu.[/QUOTE]
Yes, im verry well aware of that as I tried to mention in my previous post. I also know how to save the variable from within my code.

Anyhow…
Here is my last attempt at explaining this, after this maybe we could end this discussion as there seems to be some language barrier in the way?

Imagine you have a real store, you have several modules, you have 1 sTheme(aka own template) and then you have 1 sCustomTheme(aka template files that modules need to edit explisitly like product.tpl).
Now what will happen if your shop as just said have these two set already due to other modules and templates, and then here comes my module and writes over sCustomTheme or sTheme? Would you be happy with me crashing your application?

I want it to be compatible with as much as possible without need to explisitly overwrite anything. The overwriting is up to the user in my opinion.

That is my thought process anyhow.