Hi I've created Ajax menu in a .phtml file using some lib and JavaScript & html code however I called the file for 1 product type. I don't want it to appear except in this product. However the location is going in a different location than where I want this block to be. I'm quite new to magento so it's not easy for me to figure out the file locations in server side or where to find each file separate to put the code in directly.enter image description here

this picture is where the file appears when I called the block in the product page.

but I want it as this : enter image description here

any advice on how to actually change block position and where? thanks


is it posible to use this code in custom layout like thisenter image description here:


This solution if for Magento 2.0 version

It will be better if you'll describe how did you add your phtml file to that page.

I see you are on category page, so you need to make changes in catalog_category_view.xml located in: app/design/frontend/ThemeVendor/ThemeName/Magento_Catalog/layout

 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            <referenceContainer name="content">
                <block class="\Magento\Framework\View\Element\Template" name="bundle.product.grid"
before="category.products" />


Here you define where your phtml file is (with the block you want). You can change Magento_Catalog to whaterver module you want to use.

For version 1.9.x:

create local.xml file in your theme_folder/layout

<?xml version="1.0"?>
<layout version="0.1.0">    
       <reference name="content"
           <block type="core/template" name="your.custom.block" template="ajaxmenu/ajax_menu.phtml" before="product_list">

Using reference and before="product_list" you tell magento where to show your block.

  • {{block type="core/template" template="ajaxmenu/ajax_menu.phtml"}} – DirWolf Jun 1 '16 at 13:54
  • that's how I added the file into the page. I added the file to server then created static block and called the file using the code above – DirWolf Jun 1 '16 at 14:02
  • Is it posible to use the refrence container inside the custom layout on this category ? under custom layout? – DirWolf Jun 1 '16 at 15:33
  • @M.Ghaly please look at new answer description. I've changed it acording to your magento version – Vasilii Burlacu Jun 2 '16 at 7:10
  • For custom Layout use it like this: <reference name="content" <block type="core/template" name="your.custom.block" template="ajaxmenu/ajax_menu.phtml" before="product_list"> </reference> – Vasilii Burlacu Jun 2 '16 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.