Jump to content
thirty bees forum
  • 0

Can I get blockbanner to open a picture in fancybox on every page?


Question

Posted

I'm already using fancybox to display pictures in a CMS gallery page, which I accomplished by putting this javascript into 'Custom Code' in the back office:

$(document).ready(function() { $("a.fancybox").fancybox(); });

So for the banner link I thought, 'Great, I probably just need to edit blockbanner.tpl to append class="fancybox" to the URL.' But nothing is ever that straightforward, is it? It actually works on CMS and product pages, but not on the home, category or search pages. I've tried putting that js directly into the global.js file and the index.js file but it doesn't work. Any ideas what, if anything, I can do to fix this?

5 answers to this question

Recommended Posts

  • 0
Posted

Investigating further I remembered I'd also had to insert these two lines…

$this->addCSS(_PS_CSS_DIR_.'jquery.fancybox-1.3.4.css', 'screen'); $this->addJqueryPlugin('fancybox'); …at the bottom of the setMedia function in CMSController.php so I guess that's why it's working on CMS pages. Is there somewhere I could put this code – or something similar – so that fancybox will work wherever it's called from?

  • 0
Posted

Okay, so I've figured out I can add those two lines of code to each individual controller and that gets me what I want, but it seems like an awfully laborious way of doing it. Is there somewhere I can add them globally so it's just one file to edit?

  • 0
Posted

There is no file CMSController.php. Probably you mean CmsController.php.

If you want to have this in all controllers, add the code to the parent of this controller, classes/controller/FrontController.php.

  • 0
Posted

Thanks @traumflug.

I've put the code at the bottom of the setMedia function just above the return true; line. Is that the best place for it or would you recommend putting it somewhere else?

  • 0
Posted

Also, can you mark your comment as the correct answer please? Only being able to pick one's own comments as answers is one of this forum's more annoying features.

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