Connect with us

Blog

How to Use Magento 2 Layouts, Blocks and Templates

mm

Published

on

Please have a look below example that will show you how to use layouts, blocks and template file in magento2.

For example if you are trying to call custom blocks at frontend page then you need to follow the following steps given below:

  1. Create layout folder in your theme folder ex: app/design/frontend/Vendor/theme/Magento_Cms/layout
  2. Now create cms_index_index.xml because front end call index page by default in magento 2 with the below showing xml code:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
	<body>
        <referenceContainer name="content">
            <block class="Magento\Framework\View\Element\Template"  name="home_page"  template="Magento_Cms::home.phtml" />
        </referenceContainer>
    </body>
</page>

Now create home.phtml file in template folder in below mentioned path:

app/design/frontend/Vendor/theme/Magento_Cms/templates

In this file you can apply your custom code like below:

<?php
 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 //media path
 $mpa = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
//slider section
 $conf_img1 = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('magp/magp/magp_cars1');
//echo $mpa.'magp_cars1/'.$conf_img1;
?>
<div class="slider_main_panel">
  <ul class="slider">
     <li>
	   <img src="<?php echo $mpa.'magp_cars1/'.$conf_img1; ?>" />
	 </li> 
  </ul>
</div>

Also Read :   Gionee P7 Max launched with 3,100 mAh battery & fingerprint scanner

Hi, Thank you for reading my article. I am Victor, a professional blogger from Jaipur, India.I started webetutorial for blogging & sharing solution for developer questions, and now it’s empowering globally by helping them to make money.I am writing about starting & managing a blogs, WordPress, Magento, Social Media, SEO, Marketing, making money online, Investment, Finance, Gadgets, Fitness and more.

Continue Reading
Advertisement
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

nineteen + fourteen =

Blog

Keys to Blogging Success: How to Write an Awesome Blog Post

mm

Published

on

Keys to Blogging Success: How to Write an Awesome Blog Post

In this article we will talk about how to write a quality blog post. This article will give you some idea to enhance your post quality and increase content word limit.

Follow the below points to write a blog:

Make A Plan:

Before starting on any blog we have to make a plan on which topic we are going to write and how many words we can write. We need to choose the words and headings of content on which readers is driving on search engine. Blog plan will maintain a well-created synopsis with a target goal to reach your readers.

Create A Good Title Of Blog:

You need to stand out in the today competition need a good title for your blog which define your whole blog in a single line. Your title should be completed in a 60 characters because greater title will escape by some search engine like Google.

Make sure your blogs all point is clear from the beginning which creates a connection between you and your readers not only for current blog they will connect for further blogs.

Also Read :   Enhanced Order Grid for Magento 1 - Magento Tutorial

Keep It Clean & Formatted:

Blog content should be proper aligned and well-formatted with an organized structure. Only need to describe the information which is important and will not confuse your reader.

First all blogs should write in the Microsoft word or open word which gives formatted structure to your blog and make low chance for wrong spell.  After ensuring that your post is good enough and everything looks fine to be published upload content on your live blogging website.

Write Down The Truth:

When you are going to write a any blog you need to write down the truth content because readers only love true websites. You also need to respect your readers and competitor bloggers to increase traffic on your website.

On-Page SEO:

Blog must have SEO friendly title, meta keywords, meta description, Image alt tags, Headings, Inbound and outbound links. On-page seo will give change to your blog to show on top of search result in search engines. For the WordPress blogs you can install and configuring Yoast SEO plugin.

Also Read :   Magento : Brand Designer

Wrap Up:

Once you have completed your blog you should write a 2-3 line of short description which you have wrote because that will wrapping your blog overview and make your blog attractive.

For example: In this blog we talk about grows in traffic, revenue, authority topic and sharing personal experiences. The all of things describe here will increase your content quality for blogs.

To get more news on content writing, subscribe us or join us to advertise your blog with us.

Continue Reading

Trending