Norwegian Rat Posted May 3, 2013 Share Posted May 3, 2013 (edited) Vekia has written a thorough walktrough on how to do this. You'll find the answer here: http://mypresta.eu/en/art/developer/gallery-on-cms-page-fancybox.html A huge thanx to vekia for doing such an awesome job in this forum! ------------------------------------------------------------------------------------------------------------------------------ I'm currently working on a store in PS 1.5.4.1 where i want thickbox to be enabled in my CMS pages.I successfully managed to do this in 1.4.9 & 1.4.10 placing the CMSController.php in the override/controllers folder. This file contains this code:<?phpclass CmsController extends CmsControllerCore {public function setMedia() {parent::setMedia();Tools::addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen');Tools::addJS(array(_PS_JS_DIR_.'jquery/jquery.fancybox-1.3.4.js',_PS_JS_DIR_.'jquery/jquery.serialScroll-1.2.2-min.js',_THEME_JS_DIR_.'product.js'));if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) {Tools::addCSS(_PS_CSS_DIR_.'jqzoom.css', 'screen');Tools::addJS(_PS_JS_DIR_.'jquery/jquery.jqzoom.js');}}}This is the html code I'm using for calling fancybox:<a class="thickbox" rel="gal1" href="/img/cms/big/001.jpg" title="Picture Title"><img src="/img/cms/thumbnail/001.jpg" alt="Thumbnail Alt" /></a>This works like charm in my 1.4.9+ stores.I noticed 1.5 got different locations and names for jquery now, so I tried to rewrite the working 1.4.9+ file for 1.5.4.1. I ended up with this code and placed it in this folder: /override/controllers/front<?phpclass CmsController extends CmsControllerCore {public function setMedia() {parent::setMedia();Tools::addCSS(_PS_JS_DIR_.'jquery/plugins/fancybox/jquery.fancybox.css', 'screen');Tools::addJS(array(_PS_JS_DIR_.'jquery/plugins/fancybox/jquery.fancybox.js',_PS_JS_DIR_.'jquery/plugins/jquery.serialScroll.js',_THEME_JS_DIR_.'product.js'));if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) {Tools::addCSS(_PS_JS_DIR_.'jquery/plugins/jqzoom/jquery.jqzoom.css', 'screen');Tools::addJS(_PS_JS_DIR_.'jquery/plugins/jqzoom/jquery.jqzoom.js');}}}Now...when I try to load my CMS page nothing happens. it's totally blank. Anyone got an idea what's causing this and if it's an easy fix to it?Clean 1.5.4.1 install and default theme with no modifications being usedThanx in advanceIzraelviz Edited October 12, 2013 by Izraelviz (see edit history) Link to comment Share on other sites More sharing options...
Norwegian Rat Posted May 3, 2013 Author Share Posted May 3, 2013 (edited) Thank you for your swift reply! Do you mean like this: (and is the /controllers/front the right folder?) <?php class CmsController extends CmsControllerCore { public function setMedia() { parent::setMedia(); $this->context->controller->addCSS(_PS_JS_DIR_.'jquery/plugins/fancybox/jquery.fancybox.css', 'all'); $this->context->controller->addJS(array(_PS_JS_DIR_.'jquery/plugins/fancybox/jquery.fancybox.js', _PS_JS_DIR_.'jquery/plugins/jquery.serialScroll.js', _THEME_JS_DIR_.'product.js')); if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) { $this->context->controller->addCSS(_PS_JS_DIR_.'jquery/plugins/jqzoom/jquery.jqzoom.css', 'all'); $this->context->controller->addJS(_PS_JS_DIR_.'jquery/plugins/jqzoom/jquery.jqzoom.js'); } } } Most likely I'm doing something wrong here, but if this is correct, I still get the same error. Blank page. Edited May 3, 2013 by Izraelviz (see edit history) Link to comment Share on other sites More sharing options...
phm2000 Posted May 31, 2013 Share Posted May 31, 2013 (edited) Hello I just find, you just have to delete class_index.php in cache folder With thickbox class, your red code in last post, it works for me thanks Edited May 31, 2013 by phm2000 (see edit history) Link to comment Share on other sites More sharing options...
itfidds Posted August 6, 2013 Share Posted August 6, 2013 I believe that the file name is case sensitive; So CMSController.php is not the same as CmsController.php Not sure if that is your issue? Link to comment Share on other sites More sharing options...
vekia Posted October 1, 2013 Share Posted October 1, 2013 if someone is interested i created tutorial about fancybox gallery on cms pages 3 Link to comment Share on other sites More sharing options...
Norwegian Rat Posted October 2, 2013 Author Share Posted October 2, 2013 Yay! Thanx vekia! Highly appreciated! 1 Link to comment Share on other sites More sharing options...
vekia Posted October 2, 2013 Share Posted October 2, 2013 I created it especially for this thread now everyone can easily create own galleries on cms pages 1 Link to comment Share on other sites More sharing options...
Norwegian Rat Posted October 4, 2013 Author Share Posted October 4, 2013 Looking forward to give it a go. This issue has been a little torn in my side, to be honest. That's why I'm still on 1.4 =D Link to comment Share on other sites More sharing options...
vekia Posted October 4, 2013 Share Posted October 4, 2013 tutorial that i created is for prestashop 1.5, have you tried it? let me know if you will have any problems with tutorial that i created, i will definitely try to help Link to comment Share on other sites More sharing options...
Norwegian Rat Posted October 12, 2013 Author Share Posted October 12, 2013 Worked like a charm!! Absolutely fantastic! I REALLY appreciate it you taking the time to follow up this topic so thoroughly! Thank you so much for your invaluable work and helpfulness in this forum! Link to comment Share on other sites More sharing options...
vekia Posted October 13, 2013 Share Posted October 13, 2013 thank you for confirmation that it works for you as you expected glad to hear that i could help you a little in this case if you've got any suggestions to this tutorial - feel free to write with regards, Milos 1 Link to comment Share on other sites More sharing options...
Norwegian Rat Posted October 13, 2013 Author Share Posted October 13, 2013 If something comes to mind I certainly will do! Link to comment Share on other sites More sharing options...
Andr3Ace Posted April 29, 2014 Share Posted April 29, 2014 thanks vekia. it works also on ps 1.5.6.1 but about validate.phppublic static function isCleanHtml($html, $allow_iframe = false){ return true;}is that really need to be applied? because when it applied, my page went blank. otherwise it went well Link to comment Share on other sites More sharing options...
vekia Posted April 29, 2014 Share Posted April 29, 2014 thanks vekia. it works also on ps 1.5.6.1 but about validate.php public static function isCleanHtml($html, $allow_iframe = false){ return true; } is that really need to be applied? because when it applied, my page went blank. otherwise it went well if your page is blank, it just mean that you changed something wrong in validate.php file. there is no other way. can you show how your changed file looks like? it's necessary when you want to include some <script> inside cms page content. otherwise while you will try to save cms page - prestashop will spawn error about wrong description. 1 Link to comment Share on other sites More sharing options...
Andr3Ace Posted April 29, 2014 Share Posted April 29, 2014 (edited) well i've never laid my hand on that validate.php bfore untill i followed your tuts in your web. and yes there was a little different code-line with the one i supposed to modify. here's the code i'm talking about: - my validate.php: //if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) // return false; - supposed to modify: //if (preg_match('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))//return false; i know nothing about php code (only 3months using prestashop) but then again we commented it out, right? NB: all the script worked fine if i didnt modify that additional param: $allow_iframe = false. no error in front or when to save modified cms page. here you can check that out here . but when i add that {return true;} to the last line, my page goes blank the fact that fancybox script works fine in my cms page proofed it went well & i dont know why many thanks to your brilliant tuts Validate.php Edited April 29, 2014 by wwg_jkt (see edit history) 1 Link to comment Share on other sites More sharing options...
shirani Posted May 2, 2014 Share Posted May 2, 2014 well i've never laid my hand on that validate.php bfore untill i followed your tuts in your web. and yes there was a little different code-line with the one i supposed to modify. here's the code i'm talking about: - my validate.php: //if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) // return false; - supposed to modify: //if (preg_match('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) //return false; i know nothing about php code (only 3months using prestashop) but then again we commented it out, right? NB: all the script worked fine if i didnt modify that additional param: $allow_iframe = false. no error in front or when to save modified cms page. here you can check that out here . but when i add that {return true;} to the last line, my page goes blank the fact that fancybox script works fine in my cms page proofed it went well & i dont know why many thanks to your brilliant tuts Validate.php OMG it worked for me !!! Thanks to both guys ! Anyway Andr3Ace is right, is working also like he said !!!! Thanks a lot And3Ace and also to you Vekia ! GREAT ! now need to see if i can add galley !!!! Link to comment Share on other sites More sharing options...
vekia Posted May 2, 2014 Share Posted May 2, 2014 +1 Link to comment Share on other sites More sharing options...
Andr3Ace Posted June 27, 2014 Share Posted June 27, 2014 NB: all the script worked fine if i didnt modify that additional param: $allow_iframe = false. no error in front or when to save modified cms page. here you can check that out here . but when i add that {return true;} to the last line, my page goes blank the fact that fancybox script works fine in my cms page proofed it went well & i dont know why many thanks to your brilliant tuts Validate.php UPDATE: just for confirmation. vekia was always right from the begining!!! it was my mistake... so sorry. turn out i already have that {return true;} & it's at the bottom of the code. that's why it's still work when i didn't add the {return true;} & goes blank when i add public static function isCleanHtml($html, $allow_iframe = false) // i was adding the {return true;} here. my mistake !!! { $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange'; $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend'; $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove'; $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel'; $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart'; $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange'; $events .= '|onselectstart|onstart|onstop'; //if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) // return false; if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) return false; return true; } sorry for the trouble. silly me. you're the best. lessons learned. thank you 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