aneesahmadweb@gmail.com     03040836207

    Adding and deleting static resources

    To add static resource in page like stylesheet (style.css) or external style sheet defaine a node <head> either in default.xml in your module or you can add it into theme xml file default_head_blocks.xml

    You_theme/Magento_Theme/layout/default_head_blocks.xml.

    You can add a css file using the following instruction:

    <css src="css/my-styles.css"/>

    To add a locally hosted JavaScript file, you can use one of the following instructions:

    
    <script src="Magento_Catalog::js/sample1.js"/>
    <link src="js/sample.js"/>

    In order to get external resource, you should add the src_type attribute with the url value. For example:

    <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" src_type="url" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" src_type="url" />

    To add Font

    Use a mandatory addition of the rel=”stylesheet” and type=”text/css”:

    <link rel="stylesheet" type="text/css" src="http://fonts.googleapis.com/css?family=Montserrat" src_type="url" />

    Adding a new containers

    <container name="you.container.name" as="yourContainer" label="Any container Label" htmlTag="div" htmlClass="my-container-class" />

    To change Reference containers (For adding a block)

    <referenceContainer name="header.panel">
       <block class="YouVendor\YouModule\Block\AnyBlock" name="name.of.block" />
    </referenceContainer>

    To Add a block

    <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.sku" template="product/view/yourfile.phtml" after="product.info.type" />

    To Add a Refernceblock

    <referenceBlock name="new.template" template="Your_Module::yourtemplatefile.phtml"/>

    OR

    <referenceBlock name="new.template">
        <arguments>
            <argument name="template" xsi:type="string">Your_Module::new_template.phtml</argument>
        </arguments>
    </referenceBlock>

    About Author

    You may also like

    No Comment

    You can post first response comment.

    Leave A Comment

    Please enter your name. Please enter an valid email address. Please enter a message.