3

As from official docs :

base : used for both front end and admin html.

  1. As the part of Magento Theming, how and when to use base folder and how the fallback work with base folder.
  2. As i observed in the modules, we are using base, for example \vendor\magento\module-wishlist\view\base\layout\catalog_product_prices.xml

  3. As of my knowledge both( Module & theme level) are for overriding, but how Magento 2 will handle the fallback logic for final rendering or merging the changes.

Knowledge sharing will be appreciated.

0

Source

base folder it's default fallbacks for all area and used to share resources across of areas

Fallback sequence

  1. <current_theme_dir>/<Namespace>_<Module>/layout/
  2. <parent_theme(s)_dir>/<Namespace>_<Module>/layout/
  3. <module_dir>/view/frontend or adminhtml/layout/
  4. <module_dir>/view/base/layout/

Magento layout processing

  1. Collects all layout files from modules. The order is determined by the modules order in the module list from app/etc/config.php.
  2. Determines the sequence of inherited themes [<parent_theme>, ..., <parent1_theme>] <current_theme>
  3. Iterates the sequence of themes from last ancestor to current:

    a. Adds all extending theme layout files to the list.

    b. Replaces overridden layout files in the list.

  4. Merges all layout files from the list.


Custom module only extends the core layout file.

Namespace/Moduelname/view/frontend/layout/catalog_product_view.xml

means you are extending product page into your module.

where as

app\design\frontend\<Vendor>\<theme>\Module_Vendor\layout\override\base\catalog_product_view.xml

here you are overriding the core layout.

then according to Magento layout processing if you are overriding layout in theme it will replace also extended layout (in custom module ).

  • How Magento 2 will handle the fallback logic for final rendering or merging the changes with Base – Krishna ijjada Feb 21 '17 at 8:49
  • How the fallback will work if theme and module have base folders. – Krishna ijjada Feb 21 '17 at 8:52
  • magento 2 theme do not contain base folder @Krishati95Dev – Gopal Patel Feb 21 '17 at 9:06
  • Please check the related question magento.stackexchange.com/questions/160232/… – Krishna ijjada Feb 21 '17 at 9:06
  • As i mentioned in the question from official docs, we can use base folder for fallback, please refer Magento official "Core principals of theming in Magento 2" – Krishna ijjada Feb 21 '17 at 9:11
2

The base folder is an area to share for front-end representation logic (less, js, images, layout etc.), the resource which is for both admin and front-end, you can keep those files in the base folder.

For Example:

view/base/web/js/library.js which you are using in both for admin and front-end in this case you have should keep that library file on the base folder.

find the flowchart for fallback mechanism:

enter image description here

source [Click here][2]

  • then what is purpose of web folder ? – Gopal Patel Feb 21 '17 at 7:43
  • Files which you want to use in both adminhtml and front-end those files should be place on base folder. – rajat kara Feb 21 '17 at 7:47
  • How Magento 2 will handle the fallback logic for final rendering or merging the changes with BASE – Krishna ijjada Feb 21 '17 at 8:49
  • How the fallback will work if theme and module have base folders. – Krishna ijjada Feb 21 '17 at 8:52
  • Please check the related question magento.stackexchange.com/questions/160232/… – Krishna ijjada Feb 21 '17 at 9:07

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.