Jump to content

Recommended Posts


I, have just upgraded prestashop 1.6, and I am getting a lot of jquery errors now.  From many modules, including paypal module. 

 

This is my code from header.tpl (I am trying to load jquery from a cdn for perfomance) but simply it wont work, and any script reference get moved to the bottom of the page. 

 

I want to simple declare the script link to jquery, and keep it there in the header. To many dependancies on it, and not logical to have it on the bottom. It worked fine in version 1.5 but not in this version.

 

I tried literal tag, locating it in the body, etc. But no luck.

Please help, thanks


 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7 lt-ie6 " lang="en"> <![endif]-->

<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8 ie7" lang="en"> <![endif]-->

<!--[if IE 8]>    <html class="no-js lt-ie9 ie8" lang="en"> <![endif]-->

<!--[if gt IE 8]> <html lang="fr" class="no-js ie9" lang="en"> <![endif]-->

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang_iso}">

 <head>

{literal}

<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>

{/literal}

  <title>{$meta_title|escape:'htmlall':'UTF-8'}</title>

{if isset($meta_description) AND $meta_description}

  <meta name="description" tg="tg" content="{$meta_description|escape:html:'UTF-8'}" />

{/if}

{if isset($meta_keywords) AND $meta_keywords}

  <meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" />

{/if}

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

  <meta http-equiv="content-language" content="{$meta_language}" />

  <meta name="generator" content="PrestaShop" />

  <meta name="robots" content="{if isset($nobots)}no{/if}index,{if isset($nofollow) && $nofollow}no{/if}follow" />

  <link rel="icon" type="image/vnd.microsoft.icon" href="{$favicon_url}?{$img_update_time}" />

  <link rel="shortcut icon" type="image/x-icon" href="{$favicon_url}?{$img_update_time}" />

 

  <script type="text/javascript">

   var baseDir = '{$content_dir}';

   var baseUri = '{$base_uri}';

   var static_token = '{$static_token}';

   var token = '{$token}';

   var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};

   var priceDisplayMethod = {$priceDisplay};

   var roundMode = {$roundMode};

  </script>

{if isset($css_files)}

 {foreach from=$css_files key=css_uri item=media}

 <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />

 {/foreach}

Link to comment
Share on other sites

Actually, it's highly recommended to load javascript at the bottom of the page;

Anyway, it's a bit more complicated than it seems. It's echoed out by the main controller, here

 

COntroller.php

	protected function smartyOutputContent($content)
	{
		$this->context->cookie->write();
		if (is_array($content))
			foreach ($content as $tpl)
				$html = $this->context->smarty->fetch($tpl);
		else
			$html = $this->context->smarty->fetch($content);

		$html = trim($html);

		if ($this->controller_type == 'front' && !empty($html))
		{
 			$dom_available = extension_loaded('dom') ? true : false;
 			if ($dom_available)
				$html = Media::deferInlineScripts($html);
			$html = trim(str_replace(array('</body>', '</html>'), '', $html))."\n";
			$this->context->smarty->assign(array(
				'js_def' => Media::getJsDef(),
				'js_files' => array_unique($this->js_files),
				'js_inline' => $dom_available ? Media::getInlineScript() : array()
			));
			$javascript = $this->context->smarty->fetch(_PS_ALL_THEMES_DIR_.'javascript.tpl');
			echo $html.$javascript."\t</body>\n</html>";
		}
		else
			echo $html;
	}
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...