Location of head in Magento - php

I am trying to modify the head of my website made in the Magento platform and I am having very much trouble in dooing this. Everywhere I search I read something about app/design/frontend/default/modern/template/page/html/head.phtml
What is this? The physical location of the code ? I only have access to the Magento platform. Is there any way to have acces to the head file? I want to add a metadata (<meta name="google-site-verification" content="quuawwomLqURQt6N34_Pr0cBlYnWcYdiRz8tdXC3Oe8" />) in it and I tried to overwrite the XML file and failed.
I tried something like this:
default>
<reference name="head">
<block type="cms/block" name="google verification" as="google verification">
<action method="setBlockId"><block_id>google_plus</block_id></action>
</block>
</reference>
</default>

If you want to add a custom meta tag to your Magento store, you need to edit the head.phtml file of your current running template.
app/design/frontend/Your-template/default/template/page/html/head.phtml
If you not found this file in your template then you can get this file in
app/design/frontend/base/default/template/page/html/head.phtml
Edit head.phtml file and flush magento cache. Refresh the page and check the source code of page.
In case if you want to add meta title and description data for specific product page then you can check the Link.
To check which template is running currently on your site.
Login into admin panel.
System > configuration > under the left menu find General tab and under this you will get Design tab . Click on Design tab.
Current Package Name is the current template name.
OR To solve your problem (easier):
Use the field Miscellaneous Scripts from System->Configuration->Design->Head and put your scripts in there.
They will be added before the </head> tag and you can set different scripts per website or even store views.

Related

Magento 2 About Us Layout

We want to edit the left part of the page layout of about us as seen in the photo, we want to remove the "compare" part and customize it. Where can we edit it?
For this functionality i see you're using layout 2columns-left
To edit this functionality in magento you can do it by updating the layout file for your page.
You can remove this part of the page by using this xml handle in your xml config:
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
After you have removed compare from left sidebar you can create your own block and assign it to left sidebar using this command
<referenceBlock name="left">
<block name="your.custom.block.name" class="Vendor\Module\Block\YourBlock" template="Vendor\Module::template.phtml" />
</referenceBlock>
These two command layouts updates will do:
First one will remove the compare products from sidebar
Second one will add your custom block to the sidebar, where you can put code you need to
Only thing you should be carefull to put this is on right layout handle.
The handle for this will lay in your module: Vendor\YourModule\view\frontend\layout
In case that you showed here it would be
cms_tmt_about_us.xml
Please check this in your configuration that this is the right handle

Is it local.xml the right location for my layout update? Or should I create another file?

I have added the following code in local.xml
<checkout_onepage_success>
<reference name="head">
<block type="core/template" name="cj_udo" template="cj/udo.phtml" />
</reference>
</checkout_onepage_success>
on /app/design/frontend/base/default/layout/local.xml
Is this the right place, or should be separated?
What does it mean base folder? it means it applies to all themes and if I change theme it will continue working
It depends on who you are.
If you're a Magento system owner, or working on a specific system for a Magento system owner, local.xml is the right place for your layout updates.
However, if you're a module developer creating code you want to port to many different systems, then the correct thing to do would be
Create a new module
Add a layout update XML file (namespace_module.xml) to the config.xml for your module
Add this layout update XML file to app/design/frontend/base/default/layout/namespace_module.xml
If you are working on a theme, it is debatable but it is fine to update the layout file local.xml in your custom theme.
If you are working on a module, you should define a custom layout file, something like namespace_module.xml I prefer namespace/module.xml though. Even if you are theming, it is best to create a new module so you can define you custom xml anyway.
Under no circumstance should you directly modify core files, eg /app/design/frontend/base/default/layout/local.xml. app/code/core, etc..
I think you need to research best practice development more, good start is http://magentotherightway.com/.

Magento: different home page for each theme, but using same store view, and without changing URL?

I've recently developed a new mobile theme for my Magento site, containing different CSS/JS/layout/template files than the normal desktop theme.
I'm using Magento's "matched expression" feature in the Design section to switch to the mobile theme if a mobile user-agent string is detected.
I'd like the mobile site to have a different home page than the desktop one, but both themes are running off the normal store view, so I'm not sure how to do this.
Is it possible to set a different home page on a per-theme basis, as opposed to per-store-view?
So if Desktop User navigates to www.example.com/, they'll see CMS Page "home", but if Mobile User navigates to the same URL, they'll see CMS Page "mobile-home"?
#Marius answer is correct, when only considering a stock Magento install, you cannot separate layouts for CMS pages, however having said that, Magento is still OOP and PHP so there is a way to set up a facility to do what you want.
The trick to it is to creating a custom layout handler that gets added to the CMS's page layout, that way, you can specify what content you want on a page through a layout.xml file.
I have done this myself, so it is possible.
Create a custom module that has a layout file and an observer model with a function that you can trigger on the following event.
<controller_action_layout_load_before>
This function can then be used to determine what page you are on. This is the code that I used in the function to inject a layout handle (this could be greatly improved for better scalability)
// Triggered on the controller_action_layout_load_before Event
public function addCustomHandles( $observer ) {
$update = Mage::getSingleton('core/layout')->getUpdate();
if ( Mage::app()->getFrontController()->getRequest()->getModuleName() == 'cms' ) {
$update->addHandle( 'cmslayouthandler_cms_page_' . Mage::getSingleton('cms/page')->getIdentifier() );
}
}
This function gets the layout singleton, confirms it is on a CMS page, and the constructs a handler based off of the currently selected page. It would add a handler like the following:
'cmslayouthandler_cms_page_home'
You will then be able to update the layout for that page in the modules layout file that you created, kinda like this:
<layout version="1.0.0">
<cmslayouthandler_cms_page_home>
<reference name="content">
<block type="core/template" name="home_page" template="page/template/home.phtml" />
</reference>
</cmslayouthandler_cms_page_home>
</layout>
Take into consideration that CMS pages created through the Magento Admin Panel require a value in the 'Content' section, you can easily place a blank dummy value or zero out the value through the DB directly, I prefer the first method personally.
Good Luck!
I ended up experimenting with Marius' suggestion above, and edited cms.xml to override the index page (i.e. home page) with my own template, which worked:
<cms_index_index translate="label">
<reference name="content">
<block type="catalog/navigation" name="alternative_home" template="alternative_home.phtml" />
</reference>
<remove name="cms.wrapper"/>
</cms_index_index>
You might also wish to try overriding cms_index_defaultindex too.
You cannot have 2 homepages on the same store view.
But you can add the content of both your pages content on the same page and just hide the own that's not needed. If you are on mobile hide the desktop content and the other way around.

how to add css when creating new page in Magento?

I created new page in CMS blocks > pages . but I need to add new classes "css" to the new page , how can I manage this from Magneto , also If I want to add new users who access the Magneto and how can I give them permissions to access some menus as Catalog , system ...etc and they didn't access others how can I do it.
Thanks,
The cleanest and most efficient way to add styles to one specific CMS page only is to use the Layout Update XML input area in the Design tab of that page. I've included a screenshot below that shows you what I mean, in that case it's adding in some JS.
For you to add CSS you'd just create your CSS file and upload it to your active theme's CSS directory. You'd use the following code in your Layout Update XML input area;
<reference name="head">
<action method="addCss"><stylesheet>css/pagestyles.css</stylesheet></action>
</reference>

How to show wishlist block in header magento

I would like to able load my 'wishlist' on header block in my magento-1.6 site.
I am using magento1.6.2.0. Now my wishlist is showing up on left side block.
I just changed the reference of wishlist.xml from left to header like
<reference name="header">
<block type="wishlist/customer_sidebar" name="wishlist_sidebar" as="wishlist" template="wishlist/sidebar.phtml"/>
</reference>
But its not coming
How can I achieve that..? Which xml file i want to edit ..?
All layout XML files are one - that is, they are merged as part of typical rendering.
You need to edit the page/html/header.phtml file and add this bit of code:
<?php echo $this->getChildHtml('wishlist') ?>
Before you do any of this though you should read through the articles at the Official Magento Knowledge Base, paying particular attention to the theme hierarchy and developer articles. The time to get theme customizations right is at the beginning of a project.

Categories