I'm using the extension "Youama Ajax Login and Register", and it inserts an html page that serves as a modal window (lightbox popup or do not know how to call it).
however, it inserts the html on:
<div class="wrapper">
<div class="page">
<div class="main-container">
<div class="main">
<div class="col-main">
<div class="col-home">
/* [HERE] */
I wish he was inserted after the body.
any idea how to do this?
You would need to identify the XML that Youama is using to place that block at that point in you code and then move it to be rendered as a child of the block after_body_start.
So for example in your local.xml file you could do something like...
<default>
<!-- Youama Ajax Login and Register -->
<reference name="after_body_start">
<block type="youama/ajaxlogin" name="youama_login" as="youama_login" template="youama/ajaxlogin.phtml" />
</reference>
</default>
Please note I made all the attribute values up - you will need to copy them from the Youama XML for the block.
You will also need to remove the Youama block from it's current assignment or you will have it on your page twice. Which might be something like
<reference name="content">
<action method="unsetChild"><name>youama_login</name></action>
</reference>
Plan B : write some JavaScript to rip the DOM node out from its current posisiton and re-insert it after <body> but that is a bit of a hack and not really encouraged.
Either way you might have to check the CSS selectors in case moving the HTML changes the CSS paths to the nodes that are being styled or selected via JavaScript.
Related
I have this in my local.xml.
<reference name="header">
<block type="core/template" name="wc-customheadblock" template="wc-customheadblock.phtml" />
</reference>
Inside wc-customheadblock.phtml i have:
<div style="height:100px; background-color:green">
<h1>This is the wc custom head block</h1>
</div>
But this block is not appearing in the header. I've tried the same for the sidebars (by changing the xml reference name) and it works just fine. Why does this not work for the header?
This site claims its possible to make add blocks to the header using local.xml!
http://www.classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout
Go to your header.phtml file (app/design/frontend/package/theme/page/html/header.phtml) and place one of the following lines:
<?php echo $this->getChildHtml(); ?>
or
<?php echo $this->getChildHtml('wc-customheadblock'); ?>
Most likely header doesn't render child blocks by default because it would cause some template crashes. On the sidebars, extra childs can be easily appended at the end.
I want to use 2-colums with left design in add to cart page.I am adding this code in
app\design\frontend\default\casezilla\layout\catalog.xml. The code is
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
So the left column is coming at the bottom of the page not the left side of the page.I tried to solve this but unable to do that.
If anyone knows this,please help me out.
Thanks!
I found that in every 2-columns with left page the
<div class="main">
<ul class="page_coms-in"></div>
<div class="col-main"></div>
<div class="col-left sidebar"></div>
</div>
under the main section <div class="col-left sidebar">is coming. BUT in add to cart page
<div class="main">
<div class="col-main"></div>
</div>
<div class="col-left sidebar"></div>
here
<div class="col-left sidebar"> is coming outside the main function.So anyone can tell me why it is coming outside the main thats why my left menu is coming at the bottom.If anyone have any idea to solve this issue then please help me out.
Add that code in checkout.xml. Under <checkout_cart_index> possibly.
First set the template like this
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
after that add your <reference name="left"> tag.
step1: Open checkout.xml file
step2: find ' < remove name="left" />' It may be at line no. 59.
step3: Comment or delete this line.
I have a custom template block (phtml) that is defined like this:
<block type="catalog/product" name="a.unique.name" template="dir/dir/customlist.phtml"/>
that is defined in CMS home page within this block
<reference name="left">
However if I move it to header block, it does not appear
<reference name="header">
What am I missing here?
** ---- addition -----
I tried this as suggested by D. Sloof, but it does not work. (I suspect more due to my mis-actions than his explanation.)
I added getChildHtml('customlist'); ?> to
mytheme\template\page\html\header.phtml
just under div "top-col-1"
<div class="wrapper">
<div class="top-col-1">
<?php echo $this->getChildHtml('customlist'); ?>
where "customlist" can befound in
mytheme/template/dir/dir/customlist.phtml
What am I doing wrong?
got it...
block name a.unique.name in xml file
<block type="catalog/product" name="a.unique.name" template="dir/dir/customlist.phtml"/>
must match what is called in mytheme\template\page\html\header.phtml
<?php echo $this->getChildHtml('a.unique.name'); ?>
The header block is of type Mage_Page_Block_Html_Header and will not automatically render child blocks. You can have a look at the template file page/html/header.phtml how the child block html is retrieved.
You essentially have 2 options:
Add your own getChildHtml call in the header template (by copying it to your own theme), or;
Put your block inside a container that will automatically render child blocks. The left block is of type Mage_Core_Block_Text_List which will do this. There is a similar block inside the header block called top.container that is of type Mage_Page_Block_Html_Header that will do this as well: you can reference this block instead.
I have the following chunk of code in my footer.phtml
<!-- Customer Modal -->
<?php if (array_key_exists("customer_select", $_COOKIE) == FALSE ): ?>
<script type="text/javascript" src="<?=$this->getSkinUrl('js/jqModal.js')?>"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#customer_type_dialog").jqm().jqmShow();
});
</script>
<?php include("../../templates.eu/templates.sbc.de/_includes/customer_select.php"); ?>
<?php endif; ?>
When I turn on the block caching it stops evaluating this an only returns the value that was cached. HOw do I work around this problem or what is a better way to do this? Basically I'm checking to see if a cookie exists and if it does I'm adding some js and another file to the page.
Put the above code in it's own template file and make this layout change:
<reference name="before_body_end">
<block type="core/template" template="your/cookie/check/file.phtml" />
</reference>
This way the footer gets to be cached (which helps keep pages fast) and your cookie check is evaluated each time. Also the Javascript is left until the last possible point of the page which is a best practice for inline scripts.
How do you add a class to a div in a Magento layout? I want to change it on only one of my pages. By default, I have:
<div class="col-left sidebar">
I want:
<div class="col-left sidebar my-class">
I can't change this in 2-columns-left because it will change on all pages of Magento. Is it possible?
If you just want to change one page, you could try copying the 2-columns-left template, renaming and editing it, then editing the page to use the new template.
Rename and edit the 2-columns-left.phtml file. This is found in /app/design/frontend/default/YOUR_THEME/template/page . At around line 50 you'll see the <div class="col-left sidebar"> line.
Edit the config.xml file so that the page uses the new template. Config.xml is in /app/code/core/Mage/Page/etc . About halfway down you'll see code referring to two_columns_left; copy this code, and edit it to point to the new page.
Finally, edit the page through the backend > CMS > Pages to use the new template. You can now add styles through the CSS in your theme.
More instructions here.
Method 1 - layout.xml :
a. For files you want to include on every page
For css or js files you want to add to every page, you edit the page.xml files located in your layout folder (app/design/frontend/default/your_theme/layout/page.xml). Within this file, at the top you will find the <default> area with the **<block name="root" … >**. This block has a child named head which contains the included css and js elements.
<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>prototype/validation.js</script></action>
<action method="addJs"><script>scriptaculous/builder.js</script></action>
...
</block>
Here you can add your javascript and css. Note that any Js files you add are relative to the “js” folder in your root directory. The css files are included from the skin files of the current and default templates (skin/frontend/default/your_template(& default)/css).
b. Specific areas
If you want to include css or js on only certain areas (such as the checkout process or catalog pages), you can do that also. For instance, if you want it in a single product view (product view vs product list), you can open up catalog.xml, find <catalog_product_view> area (near line 168 in vs 1.2.1). Add your code in there – notice that we are using the <reference> tag rather than <block> tags. We use the “reference” tag to reference other blocks that are in other areas of the template.
<reference name="head">
<action method="addJs"><script>varien/product.js</script></action>
<action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/lang/calendar-en.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
</reference>
The use of can also be used in your layout XML areas in the admin backend (CMS pages, category and product designs). This can accomplish the same thing, as well as adding or removing other blocks.
Method 2 - Block Code :
We can accomplish all of this in code as well. These functions are defined within Mage_Page_Block_Html_Head. So, we can use this code with in a block class (not a .phtml file!):
$headBlock = $this->getLayout()->getBlock('head');
$headBlock->addJs('somefolder/yay.js');
I suggest looking over the page.xml files as long as finding the removeItem syntax ($type, $name for the method, for the xml), which will be very handy for you for adding or removing assets as and when you need them!
<action method="removeItem"><type>js</type><name>calendar/calendar.js</name</action>
$this->getLayout->getBlock('head')->removeItem('js', 'calendar/calendar.js');
The article was published : http://www.exploremagento.com/magento/adding-and-remove-js-css.php