承接 drupal-generics/entity_theme_suggestions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drupal-generics/entity_theme_suggestions

Composer 安装命令:

composer require drupal-generics/entity_theme_suggestions

包简介

Provides theme suggestions plugin for all type of entities.

README 文档

README

This module provides a plugin which can define new theme suggestions for entities. It replaces hook_theme_suggetions_alter(). The module provides a base suggestions class, "EntityThemeSuggestionsBase", that can be extended by any plugin so that it inherits the most common theme suggestions.

Usage

Create a class in "Plugin/ThemeSuggestions" directory structure of your module, that implements "EntityThemeSuggestionsInterface" interface. The "alterSuggestions" function should return all the theme suggestions for your entity.

To mark your class as an entity theme suggestions plugin, you have to add an annotation:

/**
 * @EntityThemeSuggestions(
 *   id = "your_plugin_id",
 *   entityType = "your_entity_type_id",
 *   priority = "the priority of the suggestion"
 * )
 */

The plugin id is required and has to be unique. The entity type is required also. The priority field is optional and set to 1 by default.

Example:

<?php

namespace Drupal\example\Plugin\ThemeSuggestions;

use Drupal\entity_theme_suggestions\EntityThemeSuggestionsBase;

/**
 * Alters suggestions for user.
 *
 * @EntityThemeSuggestions(
 *   id = "user_theme_suggestions",
 *   entityType = "user"
 * )
 */
class UserThemeSuggestions extends EntityThemeSuggestionsBase {
}

This code creates the provided default suggestions from the module for the user entity. The suggestions are defined in the base class by the "alterSuggestions()" method. The method provides the following suggestions:

  • [entity_type_id]
  • [entity_type_id]--[view_mode]
  • [entity_type_id]--[bundle]
  • [entity_type_id]--[bundle]--[view_mode]
  • [entity_type_id]--[entity_id]
  • [entity_type_id]--[entity_id]--[view_mode];

统计信息

  • 总下载量: 1.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-12-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固