cancel
Showing results for 
Search instead for 
Did you mean: 

Editing default blocks

Editing default blocks

Hi,

I am new to Magento and just installed Magento 2.0 CE via github this week and am now trying to setup a homepage of my shop. The main issue I seem to be facing to get started is how to edit the default blocks of a theme. I.e. I understand magento uses CMS blocks to generate pages from it like top.links, top.menu, foot, bottom.container, top.links, footer_links etc and thus I want to edit these. However in the block section under Content \ Blocks I cannot find them. 

Is that a problem with the installation or is that as it should be?

 

Is there any configurable way to modify these default blocks?

 

I only found some articles regarding footer changes where it was recommend to change a default.xml. However as Magento seems to be really configurable that appears pretty odd to me and furthermore my directory frontend\app\design\frontend\Magento is empty where the file should be located after what I read.

 

Any advice?

Cheers

Tom

3 REPLIES

Re: Editing default blocks

Hi,

The blocks you're wanting to edit are a different thing than CMS blocks, they're a set of PHP classes and template files found in the Magento_Theme core module and are not configurable from the backend. Rather than editing the core files directly, you should overwrite them with a custom theme. Any decent beginner tutorial on theming should cover how to do this but I can personally recommend Alan Kent's book, 'Magento 2: Theme Web Page Assets.' Best of luck!

Re: Editing default blocks

Hi,

thanks a lot for the advise. Already started with the ebook. :-).

 

Quick note - there is so much configurable in magento - why not these things in a future version too. Not necessarily on css, xml, json, php level, but like the parts which are displayed as part of a layout in the different areas. Maybe an idea for the developers.

 

Cheers

Thorsten

Re: Editing default blocks

Well. after several hours I pretty much got nowhere unfortunately.  I tried multiple ways to remove the newsletter subscribtion by layout overwriting but regardless what block name I tried it didn't work. In HTML the tag is <div class="block newsletter"> as I saw in generated file.

So tried the following with name attribute as newsletter, block.newsletter, block_newsletter, block newsletter all without any effect on what is displayed.  Any suggestions?

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="newsletter" remove="true" />
    </body>
</page>

I know my templates works in general as with below code I could change the width and height. For some reason not the image src however though the image is present in web/images. Anybody know what's wrong there?
<referenceBlock name="logo">
    <arguments>
        <argument name="logo_file" xsi:type="string">images/my_logo.jpg</argument>
        <argument name="logo_img_width" xsi:type="number">300</argument>
        <argument name="logo_img_height" xsi:type="number">300</argument>
    </arguments>
</referenceBlock>

I would also like to get a reference of all the containers and blocks I can address in each pages template. But under .../frontend/vendor/magento/theme-frontend-blank I could not find any layout.xml files. Am I searching in the right place? Only attributes I know of are from http://docs.magento.com/m2/ce/user_guide/design/block-layout-standard.html. But some of those (e.g. breadcrumb) I could not find though in admin console under Stores/Configuration/General/Web Breadcrumbs is enabled.

Hope u guys can help here.

Cheers
Tom