Announcement

  •  » Extensions
  •  » detecting Lightbox conflicts

#1 2013-07-07 14:39:29

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

detecting Lightbox conflicts

Hello,

I have some issues with Lightbox plugin
the plugin loads Colorbox javascript (not the one released with Piwigo tough) and CSS files
no problem here

now I've two plugins using Colobox : oAuth and User Collections, as I don't mind offering the choice of a theme I load files from Piwigo core (style2 CSS)

there is no problem with the javascript as they have the same internal id and only load once by the template class, but the two CSS files are loaded, causing serious display issues

I though it would be simple to detect but it is not
things to know :
- oAuth load Colobox in the menubar
- Lightbox is applied on "loc_end_index_thumbnails" trigger

it is not as simple as knowing if Lightbox plugin is activated as it only applies when there are thumbnails on the current page

any ideas ?

Offline

 

#2 2013-08-03 10:23:20

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: detecting Lightbox conflicts

Code:

add_event_handler('loc_end_index_thumbnails', 'uc_anti_lightbox', 41);

function uc_anti_lightbox($tpl_thumbnails_var)
{
  global $template, $page;
  
  if ($page['section'] == 'collections')
  {
    foreach ($template->css_by_priority[0] as $file)
    {
      if (strpos($file[0], 'colorbox.css') !== false)
      {
        $template->assign('UC_NO_LIGHTBOX', true);
        break;
      }
    }
  }
  
  return $tpl_thumbnails_var;
}

Code:

{if not isset($UC_NO_LIGHTBOX)}
{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
{combine_css path='themes/default/js/plugins/colorbox/style2/colorbox.css'}
{/if}

but must think about a better way to do it, perhaps introduce ids for css files like we have for js files

Offline

 

#3 2013-09-04 18:19:47

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: detecting Lightbox conflicts

mistic100 wrote:

but must think about a better way to do it, perhaps introduce ids for css files like we have for js files

Good idea!

Offline

 

#4 2013-10-22 20:24:46

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: detecting Lightbox conflicts

Offline

 
  •  » Extensions
  •  » detecting Lightbox conflicts

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact