Jump to content

[Solved] Modifying product.php


Recommended Posts

Hi guys,

Looking for some assistance here. I am currently building my own theme for a customer. As a part of the theme, the customer wishes to use fancyzoom for displaying the images, rather than thickbox.

I realise I can quite easily modify the product.php file in the root directory of prestashop, however I don't see this as a good solution, incase of upgrades in the future, this change will be lost.

My question is, is there a way to override the product.php file from the theme, so I can make a copy of it and place it in the theme folder, and therefore not change the original source code. This way only this particular theme will use fancyzoom, and all others will be unaffected, still using the thickbox css.

Is this possible? I know with modules you can override the php by creating a modules folder within the theme folder, and copying the files across. I assume this same logic would apply to the core php files?

Thanks, Tas

Link to comment
Share on other sites

I'm not aware of any way to override the files in the root directory of PrestaShop. You can only override module TPL files in the theme directory. I think it is possible to do what you want in your theme without modifying any of PrestaShop's core files. I suggest that you add code in header.tpl to ignore the thickbox includes and replace them with fancybox includes in your theme, then change the thickbox code in product.tpl and order.tpl from thickbox to fancybox.

For example, change lines 16-20 of header.tpl in your theme's directory from:

{if isset($css_files)}
   {foreach from=$css_files key=css_uri item=media}
   <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
   {/foreach}
{/if}



to:

{if isset($css_files)}
   {foreach from=$css_files key=css_uri item=media}
       {if $css_uri|strrpos:'thickbox.css' == true}
       <link href="{$css_dir}fancybox.css" rel="stylesheet" type="text/css" media="{$media}" />
       {else}
       <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
       {/if}
   {/foreach}
{/if}



and change lines 32-36 from:

{if isset($js_files)}
   {foreach from=$js_files item=js_uri}
   <script type="text/javascript" src="{$js_uri}"></script>
   {/foreach}
{/if}



to:

{if isset($js_files)}
   {foreach from=$js_files item=js_uri}
       {if $js_uri|strrpos:'thickbox-modified.js' == true}
       <script type="text/javascript" src="{$js_dir}fancy-box.js"></script>
       {else}
       <script type="text/javascript" src="{$js_uri}"></script>
       {/if}
   {/foreach}
{/if}

Link to comment
Share on other sites

@rocky,

There is a module for sale in the prestastore that "replaces" the default htmleditor TinyMCE for CKeditor.
I dont know how they do it, but it seems that tinyMCE is getting overrided. At least 2 core Admin files need to be changed to enable this.
What are your thoughts about that ?

Link to comment
Share on other sites

That's how I would do it. I'd create separate class and tab files and then change the database to point to the module's tab instead of the default PrestaShop tab. You'd need to create a separate version of the module for each PrestaShop version though.

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...