Jump to content

jQueryFancyBox script loading by itself in frontend


pogidude
 Share

Recommended Posts

I can't quite figure out why the JqueryFancybox module js is loading in the frontend of the site. I have the following function in a file which I load before displaying the html:

function ssd_add_scripts(){
   $config = wire('config');
   $url = $config->urls->templates.'scripts/';

   $scripts = array(
       'modernizr' => $url.'modernizr.js'
      ,'jquery' => $url.'jquery.js'
      ,'masonry' => $url.'jquery.masonry.min.js'
      ,'fancybox' => $url.'jquery.fancybox.js'
      //,'bootstrap' => $url.'bootstrap.js'
      //,'main-js' => $url.'main.js'
      ,'responsive-slides' => $url.'responsiveslides.min.js'
      ,'main' => $url.'script.js'
      ,'placeholder' => $url.'placeholderfix.js'
      );
   
   foreach($scripts as $key => $file)
      $config->scripts->add($file);
}

ssd_add_scripts();

Then, in the <head> I load the scripts like this:

<?php foreach($config->scripts as $file) echo '<script src="'.$file.'"></script>'; ?>	

Unfortunately, the generated html looks like this:

<head>
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>Departments and Services</title>
	
	
   <meta name="description" content="">
   <meta name="HandheldFriendly" content="True" />
   <meta name="lOptimized" content="width" />
   <meta http-equiv="cleartype" content="on" />
   <meta name="viewport" content="width=device-width,minimum-scale=1.0,initial-scale=1,user-scalable=yes">

	
	<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Montserrat|Merriweather">
	<link rel="stylesheet" type="text/css" href="/site/templates/styles/jquery.fancybox.css">
	<link rel="stylesheet" type="text/css" href="/site/templates/styles/style.css">
	<link rel="stylesheet" type="text/css" href="/site/templates/styles/custom.css">
	<link rel="stylesheet" type="text/css" href="/wire/modules/Jquery/JqueryFancybox/JqueryFancybox.css?v=126">
	<script src="/site/templates/scripts/modernizr.js"></script><script src="/site/templates/scripts/jquery.js"></script><script src="/site/templates/scripts/jquery.masonry.min.js"></script><script src="/site/templates/scripts/jquery.fancybox.js"></script><script src="/site/templates/scripts/responsiveslides.min.js"></script><script src="/site/templates/scripts/script.js"></script><script src="/site/templates/scripts/placeholderfix.js"></script><script src="/wire/modules/Jquery/JqueryFancybox/JqueryFancybox.js?v=126"></script>	

</head>

See the last loaded script.

I've already grepped my files for "JqueryFancybox" on the offchance that I'm loading this module in my template.

Link to comment
Share on other sites

Just made some headway (sort of) and this seems like a bug or something. This is my template:

MyTemplate.php

function renderDepartments(PageArray $departments){

   $t = new TemplateFile(wire('config')->paths->templates . 'markup/departments.php');
   $t->set('departments', $departments);
   return $t->render();
}

$headline = $page->get('headline|title');
$content = $page->body . renderDepartments($page->children);

include('./default-archive.inc'); 

Inside "default-archive.inc"

<?php

include_once("./head.inc");

?>
<div class="row default-archive content <?php echo $classes; ?>">

<!-- CONTENT IS HERE -->

</div>

<?php include_once("./foot.inc"); ?>

Take note of the included "head.inc" and "foot.inc". Right now I'm getting the JqueryFancybox loaded. As I was out of things to do, I decided to *move* the "foot.inc" and "head.inc" out and into my template:

MyTemplate.php (new)

function renderDepartments(PageArray $departments){

   $t = new TemplateFile(wire('config')->paths->templates . 'markup/departments.php');
   $t->set('departments', $departments);
   return $t->render();
}

include("./head.inc"); 

$headline = $page->get('headline|title');
$content = $page->body . renderDepartments($page->children);

include('./default-archive.inc');

include("./foot.inc"); 

Inside "default-archive.inc" (new)

<div class="row default-archive content <?php echo $classes; ?>">

<!-- CONTENT IS HERE -->

</div>

and the result?? No more JqueryFancybox javascript loaded!! 

Link to comment
Share on other sites

JqueryFancyBox is not an autoload module, so there is very likely some other module you have installed that is calling upon JqueryFancyBox. You could tell which one by putting your site in debug mode and then adding this to the init() or __construct() method in /wire/modules/Jquery/JqueryFancyBox/JqueryFancyBox.module file:

throw new WireException('gotcha!'); 

That should give you a backtrace dump indicating which module loaded JqueryFancyBox for you. (very likely an autoload module)

Remember to delete that exception afterwards. :) 

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...