scalesplanet.com Posted July 12, 2012 Share Posted July 12, 2012 (edited) Hello Everybody, Just began with PS and having some difficulty with the concept of overriding. I checked in different webs for help but I dont fully understand it. I based my work on this web: http://tycoontalk.fr...script-css.html I read other pages and they spoke about creating a new file and pasting then the code. I didnt do this... What I did is paste the code under, inside the file prestashop/classes/FrontController.php This works but strangely only with one file... I have two CSS files. One reset.css and one style.css for everything. I pasted this code: class FrontController extends FrontControllerCore { public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'style.csss'); } } As I didn't create any extra file I think I didn't do something correct. Could somebody help me understand what I did wrong???? After I will also need insert Jquery that affects all the pages. Greetings and many thanks, Daniel Edited July 23, 2012 by scalesplanet.com (see edit history) Link to comment Share on other sites More sharing options...
scalesplanet.com Posted July 12, 2012 Author Share Posted July 12, 2012 Before anybody says anything: class FrontController extends FrontControllerCore { public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'style.csss'); } } style.csss is a typo while doing the the new topic. My code is style.css and it does work but still have problems as above mentioned. Link to comment Share on other sites More sharing options...
math_php Posted July 13, 2012 Share Posted July 13, 2012 Hi Put your override in the following file : override/controllers/FrontController.php Destroy everytime every file in the tools/smarty/compile (because it is allways filled, even in debug mode) Dump also your theme cache. After that you should see your css loaded. Good luck Link to comment Share on other sites More sharing options...
scalesplanet.com Posted July 13, 2012 Author Share Posted July 13, 2012 Hi Put your override in the following file : override/controllers/FrontController.php Destroy everytime every file in the tools/smarty/compile (because it is allways filled, even in debug mode) Dump also your theme cache. After that you should see your css loaded. Good luck Thanks for the reply... I put the code below in the file prestashop/classes/FrontController.php. Its working perfectly but I dont know if this is the correct method. I see in different webs and also in your post that you should create a file or insert in a file in the following directory: override/controllers/FrontController.php. You tell me to insert it in that directory but the funny thing is that when I check this directory I only find index.php. If I look in override/classes/ I will find the following file: _FrontController.php. Should I paste there my codes????? class FrontController extends FrontControllerCore { public function setMedia() { parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'reset.css'); parent::setMedia(); Tools::addCSS(_THEME_CSS_DIR_.'style.css'); parent::setMedia(); Tools::addJS(_THEME_JS_DIR_.'jquery-1.7.2.min.js'); parent::setMedia(); Tools::addJS(_THEME_JS_DIR_.'portamento.js'); } } P.D. By the way I'm using my own html and CSS. Where can I past my html in the modules so they work with my CSS??? Link to comment Share on other sites More sharing options...
math_php Posted July 13, 2012 Share Posted July 13, 2012 (edited) _FrontController.php is sample code, by adding an '_' the class will not be loaded. I will find the following file: _FrontController.php Yes put your override in /override/classes/ by creating FrontController.php file and put your code into it, this is the correct way. The override load first the 'prestashop' FrontController in classes folder (the parent) and then yours in the override. That's why your override call parent::setMedia()for example. This allow you to use the 'standard' FrontController and in the same time you add the behaviour you want in the override. For your html put it in the correct tpl file. Edited July 13, 2012 by math_php (see edit history) 1 Link to comment Share on other sites More sharing options...
scalesplanet.com Posted July 13, 2012 Author Share Posted July 13, 2012 For your html put it in the correct tpl file. Hello, Frist thanks for the help. The override is not anymore a problem, now I understnad how it works. I also have overrided to insert two CSS files, reset.css and style.css. These are two CSS created by me, but now I confront my next problem. Maybe you can help me with my next step. As I told you, I have already done HTML/CSS files of my end product. I already overrided my CSS files so the only thing I need to do is place correctly my html in the different sectors. I already did the header and the footer. Its my first prestashop project, so of course I encounter some difficulties. I found the code of the module homefeatures.tpl. there I want to put all my products as you can see in the picture I attached. HOw and where should I paste my HTML code. This way it will work with my CSS and finito!! The issue is of course make my html work with prestashop, otherwise it wouldnt make any sense to have a CMS if it cant work with it. In this case I think I have ti put my html code in headfeatured.tpl. Under you have the code of the module. Where would I have to put my HTML?? How could I make that my HTML works correctly with the CMS prestashop??? <!-- MODULE Home Featured Products --> <div id="featured-products_block_center" class="block products_block"> <h4>{l s='Featured products' mod='homefeatured'}</h4> {if isset($products) AND $products} <div class="block_content"> {assign var='liHeight' value=342} {assign var='nbItemsPerLine' value=4} {assign var='nbLi' value=$products|@count} {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines} {math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight} <ul style="height:{$ulHeight}px;"> {foreach from=$products item=product name=homeFeaturedProducts} <li class="ajax_block_product {if $smarty.foreach.homeFeaturedProducts.first}first_item{elseif $smarty.foreach.homeFeaturedProducts.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProducts.iteration%$nbItemsPerLine == 1}clear{/if} {if $smarty.foreach.homeFeaturedProducts.iteration > ($smarty.foreach.homeFeaturedProducts.total - ($smarty.foreach.homeFeaturedProducts.total % $nbItemsPerLine))}last_line{/if}"> <h5><a href="{$product.link}" title="{$product.name|truncate:32:'...'|escape:'htmlall':'UTF-8'}">{$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'}</a></h5> <div class="product_desc"><a href="{$product.link}" title="{l s='More' mod='homefeatured'}">{$product.description_short|strip_tags|truncate:130:'...'}</a></div> <a href="{$product.link}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" /></a> <div> {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if} <a class="button" href="{$product.link}" title="{l s='View' mod='homefeatured'}">{l s='View' mod='homefeatured'}</a> {if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE} {if ($product.quantity > 0 OR $product.allow_oosp)} <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart.php')}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeatured'}">{l s='Add to cart' mod='homefeatured'}</a> {else} <span class="exclusive">{l s='Add to cart' mod='homefeatured'}</span> {/if} {else} <div style="height:23px;"></div> {/if} </div> </li> {/foreach} </ul> </div> {else} <p>{l s='No featured products' mod='homefeatured'}</p> {/if} <!-- /MODULE Home Featured Products --> Link to comment Share on other sites More sharing options...
math_php Posted July 16, 2012 Share Posted July 16, 2012 Hi scalesplanet.com, I did not see that in fact the products you sell on your site are for very precise scientist Ok I found out how you can do in a very compliant way. Do a copy of home featured module and then adapt it. Else your gonna be in trouble, tpl ( is the user interface ) and receive data from a controller (or a module). Then if you want this specific display your controller (php) has to provide it to the tpl. I think it is possible to do it, but just one thing how to you store the top five of every categories. Good luck Link to comment Share on other sites More sharing options...
scalesplanet.com Posted July 16, 2012 Author Share Posted July 16, 2012 Hello Mr. Math_php, good name... everything solved and slowly getting a grip of how it works... The override is perfect and I began to see some of my template in action, sweet. I have another small question. I've never updated my prestashop but I have read it gives a lot of problems and thats why override exists. I'm going to manipulate a CSS of PS, of jqzoom.css to be more specific. This is in the folder: theme/css/jqzoom.css Do you have to also override these files or can you edit directly on them. I ask it as if you update your PS the new version could destroy your modification right?? Or when you update you always have to do a copy of the CSS files?!?! I don;t know how it works... so let me know. Dani P.D. For now I dont sell but I will in a future. Indeed, this is only used for scientific usage of course... Link to comment Share on other sites More sharing options...
math_php Posted July 17, 2012 Share Posted July 17, 2012 Hi Dani, When I work on Prestashop theme, I make a copy, rename it as mytheme and configure Prestashop to use the 'mytheme.' When you will update, the standard prestashop theme will be up to date and you will be able to switch from 'new standard theme' to 'mytheme' to find a working way. (usually it works without modification). Have a good day. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now