0

I am a newbie to Magento 2.2.4 and i want to get bootstrap 4 css and my own js files.. As a first step trying to override the theme layout file.

I created a theme and enabled it successfully. (All js and css call are routed to my theme). The theme is inherited from magento-blank theme

Now i am trying to override the parent blank theme with my theme layout following this guide https://devdocs.magento.com/guides/v2.2/frontend-dev-guide/layouts/layout-override.html

I am getting the following error :

Trying to override modular view file 'C:/xampp/htdocs/magento/app/design/frontend/TridentTechnominds/store/TridentTechnominds_Theme/layout/override/theme/magento/blank/default_head_blocks.xml' for theme 'magento/blank', which is not ancestor of theme 'TridentTechnominds/store'

I tried all methods like :

  1. theme/Magento/theme-frontend-blank/default_head_blocks.xml => getting error over here
  2. theme/Magento/frontend-blank/default_head_blocks.xml
  3. theme/Magento/blank/default_head_blocks.xml => getting error over here
  4. theme/magento/theme-frontend-blank/default_head_blocks.xml

Kindly guide me the right folder structure. I have been just making and googling for 6 hours now.

Attached is the folder structure...enter image description here

Update 1:

My mistake in naming convention of the folder. The blue underlined folder name was changed.

Even then, the trident.css is getting loaded from position black underlined i.e. under layout folder.

If i take it inside theme/magento/blank it doesnt work. Note: I tried Magento as foldername too.

Attaching the updated folder structure. enter image description here

1

To override layout from parent theme, here in your case default_head_blocks.xml from Magento/blank :

app/design/frontend/{Vendor}/{themeName}/Magento_Theme/layout/override/theme/Magento/blank/default_head_blocks.xml

More information in Magento DevDocs.

  • I figured out the naming convention error. The folder name should be Magento_Theme but i gave as TridentTechnominds_Theme which caused the error. But still the theme is not overriding, but still i am getting the error. I will update my question shortly – Alaksandar Jesus Gene May 24 '18 at 5:59
  • 1
    Please try exactly my path – PЯINCƏ May 24 '18 at 8:10
0

Your theme should have the blank theme as the parent. app/design/frontend/TridentTechnominds/TridentTechnominds_Theme/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>TridentTechnominds Theme</title>
<parent>Magento/blank</parent>
<media>
    <preview_image>media/preview.jpg</preview_image>
</media>

By using below structure in the theme you can do changes to the xml file of Magento_Theme module. app design frontend TridentTechnominds (namespace - recommends to use lowercase) TridentTechnominds_Theme (theme - recommends to use lowercase) Magento_Theme layout default_head_blocks.xml

If you want to override the file in blank theme itself use the structure mentioned in @Prince's comment below.

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.