Magento Forum

head section automatically reordered in Magento 1.5 - causing javascript error
 
madla
Jr. Member
 
Total Posts:  25
Joined:  2009-03-29
 

I upgraded a Magento 1.3 theme to Magento 1.5. I updated page.xml layout file but Magento now throws a javascrip error: Mage doesn\\\’t exist.

Looking through the rendered code I noticed that the page/js/cookies.phtml file content is added before the javascript files are included.

The page.xml layout file however has the addjs and block elements in the right order:

<layout version=\\\"0.1.0\\\">
<!--
Default 
layoutloads most of the pages
-->

    <default 
translate=\\\"label\\\" module=\\\"page\\\">
        <
label>All Pages</label>
        <
block type=\\\"page/html\\\" name=\\\"root\\\" output=\\\"toHtml\\\" template=\\\"page/3columns.phtml\\\">

            <
block type=\\\"page/html_head\\\" name=\\\"head\\\" as=\\\"head\\\">
                <
action method=\\\"addJs\\\"><script>prototype/prototype.js</script></action>
                <
action method=\\\"addJs\\\" ifconfig=\\\"dev/js/deprecation\\\"><script>prototype/deprecation.js</script></action>
                <
action method=\\\"addJs\\\"><script>lib/ccard.js</script></action>
                <
action method=\\\"addJs\\\"><script>prototype/validation.js</script></action>
                <
action method=\\\"addJs\\\"><script>scriptaculous/builder.js</script></action>
                <
action method=\\\"addJs\\\"><script>scriptaculous/effects.js</script></action>
                <
action method=\\\"addJs\\\"><script>scriptaculous/dragdrop.js</script></action>
                <
action method=\\\"addJs\\\"><script>scriptaculous/controls.js</script></action>
                <
action method=\\\"addJs\\\"><script>scriptaculous/slider.js</script></action>
                <
action method=\\\"addJs\\\"><script>varien/js.js</script></action>
                <
action method=\\\"addJs\\\"><script>varien/form.js</script></action>
                <
action method=\\\"addJs\\\"><script>varien/menu.js</script></action>
                <
action method=\\\"addJs\\\"><script>mage/translate.js</script></action>
                <
action method=\\\"addJs\\\"><script>mage/cookies.js</script></action>
               
                <
block type=\\\"page/js_cookie\\\" name=\\\"js_cookies\\\" template=\\\"page/js/cookie.phtml\\\"/>

                <
action method=\\\"addCss\\\"><stylesheet>css/styles.css</stylesheet></action>
                <
action method=\\\"addCss\\\"><stylesheet>css/clears.css</stylesheet></action>
                 <
action method=\\\"addItem\\\"><type>skin_css</type><name>css/styles-ie.css</name><params/><if>lt IE 8</if></action>
                <
action method=\\\"addCss\\\"><stylesheet>css/widgets.css</stylesheet></action>
                <
action method=\\\"addCss\\\"><stylesheet>css/print.css</stylesheet><params>media=\\\"print\\\"</params></action>
                <
block type=\\\"page/html\\\" name=\\\"store_language_js\\\" as=\\\"store_language_js\\\" template=\\\"page/html/head-translator.phtml\\\"/>

                <
action method=\\\"addItem\\\"><type>js</type><name>lib/ds-sleight.js</name><params/><if>lt IE 7</if></action>
                <
action method=\\\"addItem\\\"><type>js</type><name>varien/iehover-fix.js</name><params/><if>lt IE 7</if></action>
                <
action method=\\\"addItem\\\"><type>skin_js</type><name>js/client.js</name></action>
                <
action method=\\\"addItem\\\"><type>skin_js</type><name>js/ie6.js</name><params/><if>lt IE 7</if></action>
            </
block>

In the code above, the js_cookies block shows up after the js includes (I even tried moving it to the bottom of the block and Magento still reorders it. I also turned of combining js files in the admin .... same results.

Here\\\’s what the rendered html looks like:

<!DOCTYPE html PUBLIC \\\"-//W3C//DTD XHTML 1.0 Strict//EN\\\" \\\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\\\">
<
html xmlns=\\\"http://www.w3.org/1999/xhtml\\\" xml:lang=\\\"en\\\" lang=\\\"en\\\">
<
head>
    <
title>Wild RiceDried VegetablesDried Fruits, & Survival Food</title>

<
meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\" />




<
link rel=\\\"shortcut icon\\\" href=\\\"http://208.69.126.155/skin/frontend/nbt/default/favicon.ico\\\" type=\\\"image/x-icon\\\" />
<
script type=\\\"text/javascript\\\">
//<![CDATA[
    
var BLANK_URL \\\'http://208.69.126.155/js/blank.html\\\';
    var 
BLANK_IMG \\\'http://208.69.126.155/js/spacer.gif\\\';
//]]>
</script>

<script type=\\\"text/javascript\\\">
//<![CDATA[
if (!window.Mage) var Mage {};
if (!
Mage.CookiesMage.Cookies {};
Mage.Cookies.path     \\\'/\\\';
Mage.Cookies.domain   \\\'.208.69.126.155\\\';
//]]>
</script>
<link rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"http://208.69.126.155/media/css/806414be6f3351efd564a9c05b1aa4fd.css\\\" media=\\\"all\\\" />
<
link rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"http://208.69.126.155/media/css/4a26eac3f661360641e4a6d70ac73ea0.css\\\" media=\\\"print\\\" />
<
script type=\\\"text/javascript\\\" src=\\\"http://208.69.126.155/media/js/a938587ae5e398b6aedc7836e5b0f1c3.js\\\"></script>

Any idea what causes this and how to solve it?

Thanks in advance…

 
Magento Community Magento Community
Magento Community
Magento Community
 
ziq2004
Member
 
Avatar
Total Posts:  71
Joined:  2008-06-05
 

Hi smile

be sure that <?php echo $this->getChildHtml() ?> in app/design/frontend/default/default/template/page/html/head.phtml
occurs after <?php echo $this->getCssJsHtml() ?>

Let me know

 
Magento Community Magento Community
Magento Community
Magento Community
 
ziq2004
Member
 
Avatar
Total Posts:  71
Joined:  2008-06-05
 

Hi smile

be sure that <?php echo $this->getChildHtml() ?> in app/design/frontend/default/default/template/page/html/head.phtml
occurs after <?php echo $this->getCssJsHtml() ?>

Let me know

 
Magento Community Magento Community
Magento Community
Magento Community
 
madla
Jr. Member
 
Total Posts:  25
Joined:  2009-03-29
 

That was it...a holdover from 1.3...makes me wonder how many more there are.

Thank you very much.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ziq2004
Member
 
Avatar
Total Posts:  71
Joined:  2008-06-05
 

You are welcome

hmm a lot wink

take care of form key on my account.. what else? i do not remember…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top