X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   How to add statements to head section (https://forum.x-cart.com/showthread.php?t=69854)

JannieB 08-20-2014 09:30 AM

How to add statements to head section
 
Hi,
I need add some script statements to the Head section of the page so that i can can utilise typekit fonts....
pretty basic stuff but can't work out how to do it ...
can anyone help?

qualiteam 08-20-2014 08:45 PM

Re: How to add statements to head section
 
Hello!

Is it X-Cart 4, or X-Cart 5?

JannieB 08-21-2014 01:05 AM

Re: How to add statements to head section
 
xcart 5.1.5

just trying to find my way around the new architecture ...

Also I will need to add some custom javascript as well. I don't want to edit the common.js can I add a new js.file

Jan

JannieB 08-21-2014 02:03 AM

Re: How to add statements to head section
 
I have tried adding a tpl via custom skin in default/en/header/parts as follows:

Code:

{**
 * Head list children
 *
 * ...
 *
 * @ListChild (list="head", weight="700")
 *}

<script type="text/javascript" src="//use.typekit.net/dap7cpb.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>


Then rebuilding the cache, but this just generates an internal error. If I comment out the script statements all is fine ....

How should I include these?

Jan

qualiteam 08-21-2014 11:15 PM

Re: How to add statements to head section
 
Hello Jan,

This is because the templater finds "{" and "}" and decides that it is an instruction to him that he doesn't know.

Try this:

Code:

{**
 * Head list children
 *
 * ...
 *
 * @ListChild (list="head", weight="700")
 *}

<script type="text/javascript" src="//use.typekit.net/dap7cpb.js"></script>
<script type="text/javascript"><!--try{Typekit.load();}catch(e){}--></script>



Does this help?

A better way would be decorating the getJSFiles() method in the \XLite\View\Controller widget and adding a new JavaScript file that does the job on the page load.

JannieB 08-22-2014 12:55 AM

Re: How to add statements to head section
 
Thanks Alex,

This did the trick but could you explain how I would go about using the other method, as I will have other javascript to add and would prefer to do it properly!

I have another question about removing the sidebars ..... but I will start a separate thread for that!

Jan

tony_sologubov 08-22-2014 04:55 AM

Re: How to add statements to head section
 
Hi Jan!

There is a guide how you can attach JS file to your module:
http://kb.x-cart.com/display/XDD/Adding+CSS+and+JS+files

You can simply use Custom Skin module in order to apply this change.

JannieB 08-22-2014 05:34 AM

Re: How to add statements to head section
 
Thanks I have implemented it that way now .... much better!

Jan


All times are GMT -8. The time now is 02:24 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.