Jump to content

[Solved] Need a little help. Cant seem to get fancybox to work in cms 1.5.4.1


Recommended Posts

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:


<?php
class 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

<?php
class 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 used

Thanx in advance

Izraelviz

Edited by Izraelviz (see edit history)
Link to comment
Share on other sites

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 by Izraelviz (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...
  • 1 month later...
  • 2 weeks later...
  • 6 months later...

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

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

well i've never laid my hand on that validate.php bfore :P 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 by wwg_jkt (see edit history)
  • Like 1
Link to comment
Share on other sites

well i've never laid my hand on that validate.php bfore :P 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

attachicon.gifValidate.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 :D !!!!

Link to comment
Share on other sites

  • 1 month later...

 

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

attachicon.gifValidate.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

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...