What is the name of the table where view modes are stored?

What is the name of the table where view modes are stored?



We have 10 view modes that we created. When we run drush @env cex sync in our local we are able to export the config files related to these view modes such as core.entity_view_mode.node.related.yml (where related is the view mode).


drush @env cex sync


core.entity_view_mode.node.related.yml



Is there a database table where these View modes are stored? If so, what is the name of it?



We are not using Display Suite or Panels, just the out of the box View Modes from Core. We do not plan to add those modules.



Goal:



Definition of not being used:


not being used


Article


listing, minimum, related


Basic Page


Article


Article view mode = listing


Basic Page Default View Mode


listing


minimum






you say in definition - #2 "Article view mode = listing", then on #3 "listing and minimum are not being used.", can you review this please?

– Cesar Moore
Sep 6 '18 at 20:45






it seems like you know which view modes are not in use, so why don't you just delete them in the admin interface (/admin/structure/display-modes/view)?

– Cesar Moore
Sep 6 '18 at 20:48






@CesarMoore I have updated the questions goal and definition. We are looking for a programmatic way to figure out what is being used and what is not. Hopefully it is clear now.

– usernameabc
Sep 6 '18 at 22:53




2 Answers
2



The configuration is stored in the config table


mysql> describe config;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| collection | varchar(255) | NO | PRI | | |
| name | varchar(255) | NO | PRI | | |
| data | longblob | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)



This is an example query from the umami demo profile:


mysql> select name from config where name like 'core.entity_view_display.node.article.%';
+-------------------------------------------------------+
| name |
+-------------------------------------------------------+
| core.entity_view_display.node.article.card |
| core.entity_view_display.node.article.card_common |
| core.entity_view_display.node.article.card_common_alt |
| core.entity_view_display.node.article.default |
| core.entity_view_display.node.article.full |
| core.entity_view_display.node.article.rss |
| core.entity_view_display.node.article.teaser |
+-------------------------------------------------------+
7 rows in set (0.00 sec)






This is an answer to the original question: "What is the name of the table where view modes are stored?" ... "Is there a database table where these View modes are stored? If so, what is the name of it?"

– Cesar Moore
Sep 6 '18 at 20:58



View modes are stored in the configuration entity entity_view_mode which you can load like any other entity:


entity_view_mode


$view_mode = Drupal::entityTypeManager()
->getStorage('entity_view_mode')
->load('node.teaser');



To load all view modes for the entity type node:


node


$view_modes = Drupal::entityTypeManager()
->getStorage('entity_view_mode')
->loadByProperties(['targetEntityType' => 'node']);



View modes don't store much data other than a label for the view mode name.



How a view mode is displayed for a specific content type is stored in a different entity:


$display = Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load('node.article.teaser');



The usage depends on how you define what being used means. If you mean with not used that it is not configured in a content type, which you can query in the config entities mentioned before, this doesn't mean necessarily, that the view mode is not used anywhere. If you configure an entity to be displayed in a view mode, for example in a View or a entity reference field, and this view mode is not configured in the content type, then it fallbacks to the default view mode.






Just updated the question with definition of not being used

– usernameabc
Sep 6 '18 at 20:33


not being used






If this is only for the usage between referenced content types you could load all displays like in the last code example and check the field formatter settings of all reference fields. But this would be only one of many places where view modes can be used.

– 4k4
Sep 6 '18 at 21:18




Thanks for contributing an answer to Drupal Answers!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ