I am trying to add a video on banner of my home page but the video doesn't appear, it shows a message no video with supported format. I uploaded a mp4 format and mov format but it shows the same message .. I added the video with a block on home page. what should I do to get it to work properly
Magento – adding a video to home page banner
blockshome-pagemagento2.2video
Related Solutions
Maria,
Your method is almost correct, you simply need give each block a unique name.
<reference name="content">
<block type="catalog/product_list" name="featured_1" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>1</category_id></action>
<block type="core/text_list" name="product_list.after" as="after" />
</block>
<block type="catalog/product_list" name="featured_2" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>2</category_id></action>
<block type="core/text_list" name="product_list.after" as="after" />
</block>
</reference>
Update The method above works in Magento 1.9.1.0, using the rwd/default package/theme. However does not address the OP's requirement to also display the category banner. To do this, I have revised the answer to the following:
Create this file:
app/code/frontend/PACKAGE_NAME/THEME_NAME/template/catalog/category/view/multiple.phtml
(replacing package name and theme name with what applies to your site)
In it, have the following contents:
<?php
/**
* Displays multiple category view templates along with the product list for it
*/
/* @var $this Mage_Core_Block_Template */
$category_ids = explode(',', $this->getData('category_ids'));
$current_category = Mage::registry('current_category');
if ($current_category) {
Mage::unregister('current_category');
}
foreach ($category_ids as $id) {
$category = Mage::getModel('catalog/category')->load(trim($id));
if (!$category->getId()) {
continue;
}
Mage::register('current_category', $category);
$product_list = $this->getLayout()->createBlock('catalog/product_list', 'product_list_'.$id, array('template' => 'catalog/product/list.phtml'));
echo $this
->getLayout()
->createBlock('catalog/category_view', 'category_'.$id, array('template' => 'catalog/category/view.phtml'))
->append($product_list, 'product_list')
->toHtml();
Mage::unregister('current_category');
}
if ($current_category) {
Mage::register('current_category', $current_category);
}
Within the "Design" tab of your CMS page, add the following XML instructions:
<reference name="content">
<block type="core/template" name="multiple_categories" template="catalog/category/view/multiple.phtml">
<action method="setData"><key>category_ids</key><val>1,2</val></action>
</block>
</reference>
Make sure to update the comma separated list of category ids with the IDs you actually want to display.
Pretty straight relation which invokes home-page-block, is Widgets.
Content -> Widgets -> Now click on Home Page widget. Storefront Properties -> Layout Updates -> specific page Widget Options -> Block > Home Page Block.
You can set/change CMS page by Stores-> Configuration-> General-> Web-> Default Pages-> CMS Home Page You can select the page by title.
By default the page is
Home Page
Module-Widget Module is responsible for all the code, a lot more questions can be covered if you observe the below file.
Magento root/vendor/magento/module-widget/view/adminhtml/templates/instance/edit/layout.phtml
Where does it get its list of Pages ?
As on the above if you go to line 136
$block->getLayoutsChooser();
/vendor/magento/module-widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/Layout.php
File contains
public function getLayoutsChooser()
{
$chooserBlock = $this->getLayout()->createBlock(
'Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Layout'
// Setting other variables
)
}
/vendor/magento/module-widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Layout.php
The below function will return the pages.
protected function _beforeToHtml()
{
if (!$this->getOptions()) {
$this->addOption('', __('-- Please Select --'));
$pageTypes = $this->_config->getPageTypes();
$this->_addPageTypeOptions($pageTypes);
}
return parent::_beforeToHtml();
}
Where the container can be rendered ?
in the layout.phtml $block->getDisplayOnContainers(); is responsible for getting all containers.
What is the container means ?
Containers are type of blocks for structured design which follows design fallback. Quick working example for create container.
which says "CMS Static Block Default Template". What's its role ?
Means it will follow static block default design
<input type="hidden" value="widget/static_block/default.phtml" name="widget_instance[0][pages][template]" disabled="disabled">
/vendor/magento/module-widget/view/frontend/layout/default.xml
Best Answer
create a block in magento admin use below code.