Jump to content

Eihwaz

Members
  • Posts

    57
  • Joined

  • Last visited

About Eihwaz

  • Birthday 11/13/1985

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Eihwaz's Achievements

Newbie

Newbie (1/14)

9

Reputation

  1. It seems CSS alone won't do it, you'll need a small module to determine what page we're currently on. I presume you're using Prestashop v 1.3 or lower, so here's two probable solutions (test first, as this was thrown together really quickly): <?php class cmsClass extends Module { public function __construct() { $this->name = 'cmsclass'; $this->version = '0.1'; $this->tab = 'Tools'; parent::__construct(); $this->displayName = 'CMS Page Class'; } public function install() { return (parent::install() && $this->registerHook('header')); } public function hookHeader() { global $page_name, $smarty; $body_class = false; if ($page_name == 'cms') { $id_cms = Tools::getValue('id_cms', false); if ($id_cms && Validate::isUnsignedId($id_cms)) { $body_class = 'cms_' . (int)$id_cms; } } $smarty->assign('body_class', $body_class); } } This solution requires changes to your header.tpl file - you need to add "{if $body_class}class="{$body_class}"{/if}" to your <body> tag. And then you can style it in CSS like this: body.cms_1 #left_column {display: none;} The second solution does not require changes, but it uses an inline CSS. It is more flexible in some ways, because you can use it not only for cms, but for other pages as well: <?php class cmsClass extends Module { private static $_column_settings = array( 'cms' => array( 'identifier' => 'id_cms', 'settings' => array( 1 => 'l', 2 => 'lr' ) ) ); public function __construct() { $this->name = 'cmsclass'; $this->version = '0.1'; $this->tab = 'Tools'; parent::__construct(); $this->displayName = 'CMS Page Class'; } public function install() { return (parent::install() && $this->registerHook('header')); } public function hookHeader() { global $page_name; $body_class = false; if (array_key_exists($page_name, self::$_column_settings) && array_key_exists('identifier', self::$_column_settings[$page_name])) { $identifier = Tools::getValue(self::$_column_settings[$page_name]['identifier'], false); if ($identifier && Validate::isUnsignedId($identifier)) { $page_settings = (array_key_exists('settings', self::$_column_settings[$page_name]) && is_array(self::$_column_settings[$page_name]['settings'])) ? self::$_column_settings[$page_name]['settings'] : false; if ($page_settings && array_key_exists($identifier, $page_settings)) { $selectors = array(); if (strpos(strtolower($page_settings[$identifier]), 'l') !== false) { array_push($selectors, '#left_column'); } if (strpos(strtolower($page_settings[$identifier]), 'r') !== false) { array_push($selectors, '#right_column'); } if (sizeof($selectors)) { return '<style type="text/css">' . (implode(',', $selectors) . ' {display: none;}') . '</style>'; } } } } } } See this part: private static $_column_settings = array( 'cms' => array( 'identifier' => 'id_cms', 'settings' => array( 1 => 'l', 2 => 'lr' ) ) ); The "cms" key is the page that you want to remove columns from. "Identifier" is a _GET parameter to look for, so, in cms case (cms.php?id_cms=1) it is "id_cms". The "settings" contains cms ids and column settings for them, 1 => 'l' means that the left column will be REMOVED from this particular cms page. That's about it. Cheers!
  2. You can also try styling it like this: #center_column .products_block ul { text-align: justify; line-height: 0; font-size: 1px; text-justify: newspaper; zoom: 1; text-align-last: justify; list-style: none; } #center_column .products_block ul:after { width: 100%; height: 0px; visibility: hidden; overflow: hidden; content: ''; display: inline-block; } #center_column .products_block ul li { width: 120px; /* or whatever */ display: inline-block; text-align: left; line-height: normal; font-size: 14px; /* Do not use ems or % here, because we've reset parent's font size */ vertical-align: top; /* Inline-block for IE */ *display: inline; *zoom: 1; } This should distribute your blocks evenly inside the "ul" container (basically it's text-align: justify, but for blocks), so you don't have to calculate margins manually.
  3. Hi Sofie, Try the updated code in my first post. As for the English phrases - unfortunately you'll have to translate them again in your Tools -> Translations -> Front Office Translations, because Prestashop takes template name into account, so you do have translations for your product.tpl file, but not for your product_giraf.tpl file. Other than that, this code should work fine now. Cheers!
  4. I would do something like this (warning: haven't tested): create a file in your /overrides/controllers/ called ProductController.php with the following content: <?php class ProductController extends ProductControllerCore { private static $_product_category = false; public function process() { parent::process(); $method = method_exists(self::$smarty, 'get_template_vars') ? 'get_template_vars' : method_exists(self::$smarty, 'getTemplateVars') ? 'getTemplateVars' : false; if ($method) { $category = call_user_func(array(self::$smarty, $method), 'category'); if (is_object($category) && Validate::isLoadedObject($category)) { self::$_product_category = $category; } } } private static function checkProductTemplate($link_rewrite) { return file_exists(_PS_THEME_DIR_ . 'product_' . $link_rewrite . '.tpl'); } public function displayContent() { FrontController::displayContent(); $template = 'product.tpl'; if (self::$_product_category && Validate::isLoadedObject(self::$_product_category)) { // Check if child category product template exists if ( ! Tools::isEmpty(self::$_product_category->link_rewrite) && self::checkProductTemplate(self::$_product_category->link_rewrite)) { $template = 'product_' . self::$_product_category->link_rewrite . '.tpl'; } else { // If not, check if parent's category producttemplate exists $parents = self::$_product_category->getParentsCategories(); if (is_array($parents) && sizeof($parents) > 1) { $parent_category = array_pop($parents); if ( ! Tools::isEmpty($parent_category['link_rewrite']) && self::checkProductTemplate($parent_category['link_rewrite'])) { $template = 'product_' . $parent_category['link_rewrite'] . '.tpl'; } } } } self::$smarty->display(_PS_THEME_DIR_ . $template); } } Now you can simply create different product templates, just add the category's SEO url to the filename, like so: product_music-ipods.tpl And put it in your theme templates directory, next to the original product.tpl. This should work for both - categories and subcategories.
  5. Ищу бета-тестеров для генератора модулей Morgen, желающим просьба писать в личку или в раздел "контакты" на странице генератора. К сожалению, пока не могу дать доступ всем желающим - умрет сервер.
  6. Updated, some new features added, thanks to d(oekia) - can't really thank you enough, man. There are still some beta-testers positions open.
  7. This is a prestashop module generator. It is currently in an early stage, but it already is of a great help. It can generate a module, register it to the hooks you select, generate module configuration HTML (getContent method), validate and save it, place a module on a seperate tab, create and display template files, assign variables, etc. Then it creates a zip file with your module for you to download and use. It does not create a module for you, but it can generate most of the routine that really takes a lot of time when designing a module, so you can concentrate on algorithms rather than doing that same things from one module to another. Currently I'm looking for beta-testers, and actual module creation process is only available to them. If you would like to apply, please drop me a message. Note that at this stage I'm only looking for experienced developers and there's only a finite beta-testers positions I can take yet in order to keep the server alive. If you're interested, please provide some links to your previous works. Finally, here's the link to generator, so you could see the available settings (tested in Chrome and FF, I recommend Chrome): http://baldinsearch.com/morgen/generator (yes, this is a prestashop module)
  8. I was tired of writing something like if (Validate::IsInt($var) || Validate::[...]($var) || Validate::[...]($var)){} So here's an easier way (note that it requires PHP version 5.3 or higher and changes to core files, if you're on 1.4, just add this snippet to overrides). In your classes/Validate.php add the following method: public static function __callStatic($method, $arguments) { $argument = array_pop($arguments); $method = explode('_or_', $method); $validStack = array(); foreach ($method as $validate) if (method_exists('Validate', $validate)) array_push($validStack, $validate); if ( ! sizeof($validStack)) die(Tools::displayError('No valid methods were passed')); foreach ($validStack as $methodToPass) if ( ! call_user_func(array('Validate', $methodToPass), $argument) === false) return true; return false; } Now you can do this: if (Validate::isInt_or_isFloat_or_isEmail($var)){} Have fun
  9. Hi everyone! I've tried summing up my findings about PrestaShop basic classes before, but describing even one class was taking very long time, so I tried a different approach. Using PHP's Reflection API, we can get a lot of information about any given class. So I used this API to generate documentation. The comments in code were also parsed so that documentation would be more complete (return values, parameters). Now, because it was generated automatically, it would sometimes guess parameter type (integer, array, boolean, etc.) wrong, and I will of course be fixing these manually. But it's kind of helpful even now as it is. Anyway, visit my blog to see it. I'll appreciate all comments and requests you may have. Cheers! P.S.: I anticipate some questions so I'll answer them right away: 1) No, the documentation is not generated on the fly, it was pre-generated and later added as news entries. 2) Using filter you can filter out the methods or properties you don't need (eg. show "public" methods only). To reset the filter, click the active button again. 3) Click "show" button at the end of each method description to show its source code. 4) The documentation is for the latest RC 7 version of PrestaShop.
  10. As whitelighter said, $smarty->register_function('convertPrice2', array('Product', 'convertPrice2')); This line means convertPrice2 is defined in classes/Product.php, in your case, this function is defined in classes/Tools.php.
  11. In fact, I found out today they're not really working with our country. Well, WE can pay for services, not accept money to our accounts, so I'm going to have to go with 2checkout, I think...
  12. Wow, I don't like the direction this is going to... Awaiting for explanations from Fre-do, if anything, that was my module, so you should probably talk to me.
  13. 2 snco: Hi! Sorry, I don't even have the psd file for it, I just did it as an example, saved directly to gif. But I see you did a cool sprite yourself, very nice!
  14. I just wanted to say one thing: when you put a someone else's free module on your website with a donation button, the only thing us developers can do is make new versions of our modules paid. Not because we're greedy or anything, just because it usually takes a lot of time and effort to create one. So it's up to you to keep it free All my new modules will have a link to legal notice in them (not readme.txt or licence.txt, no, the actual link next to module name). P.S.: This forum is full of threads about bad developers whose modules do not work at all and who provide little to no support. As you see, it's not always developers to blame
×
×
  • Create New...