我已经创建了一个自定义模块并分配了一个树枝模板文件,但它没有显示。以下是文件和文件夹结构
1.workbuster.module文件的代码如下
<?php
/**
* Implements hook_theme().
*/
function workbuster_theme()
{
return array(
'block_workbuster' => array(
'variables' => array('title' => NULL, 'description' => NULL),
'template' => 'block--workbuster-custom',
),
);
}
Run Code Online (Sandbox Code Playgroud)
2. WorkbusterBlock文件的代码如下
<?php
/**
* @file
*/
namespace Drupal\workbuster\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'Workbuster' Block
* @Block(
* id = "block_workbuster",
* admin_label = @Translation("Workbuster block"),
* )
*/
class WorkbusterBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
return array(
'#title' => 'Workbuster',
'#description' …Run Code Online (Sandbox Code Playgroud) 我试图覆盖块主题并使用html和twig重建它.
我似乎无法从块类型或内容类型中找到变量,并且无法找到图像URL.
我如何使用kint达到它?
我想在drupal 8中将省和城市字段添加到用户实体.通过更改省份,应更新城市列表.在drupal 7中我用条件字段模块完成了这个,但是这个模块还没有为drupal 8做好准备.在drupal 8中这样做的正确方法是什么?我应该添加字段,然后将jquery添加到我的注册模板中,或者是否有更好的标准方法来执行此操作.谢谢.
我的数据库中有一个表.我想使用该表的数据并创建该数据的形式.我创建了一个模块并创建了一个form.php页面.在函数中编写了select查询但是如何从该数据中创建表单?
我试图在每一页上附加一个树枝模板。
在 Drupal 7 中,我们基本上使用hook_page_alter
function hook_page_alter(&$page) {
$page['page_bottom']['devel']= array(
'#type' => 'markup',
'#markup' => '<div style="clear:both;">' . theme('TEST') . '</div>',
); // add test template on every page at bottom position.
}
Run Code Online (Sandbox Code Playgroud)
但hook_page_alter我认为在 Drupal 8 中没有。
如何在 drupal 8 中做到这一点?
将 Google 字体添加到 Drupal 8 主题的正确方法是什么?
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud) 我想link在自定义块中有一个字段。这是我的代码:
public function blockForm($form, FormStateInterface $form_state)
{
$form['key_1'] = [
'#title' => $this->t('Key 1 label'),
'#type' => 'textfield',
'#default_value' => '',
'#required' => false,
];
$form['key_2'] = [
'#title' => $this->t('key 2 link'),
'#type' => 'link',
];
return $form;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我进入 admin/structure/block/manage/myblock 时,我可以看到我的key 1字段。在key 2不渲染。如果我更改任何其他(文本字段、文本区域、文件管理)的类型,我的字段将正确呈现。默认链接模块已启用。
链接字段类型只能在节点形式中使用吗?我能理解为什么。
我正在设法解决这个问题:我不知道为什么调试调试不起作用:
Drupal版本8.2.6
Folder structure
Folder permissions
Settings.php
$settings['hash_salt'] = 'DEVELOPMENT_SALT';
$settings['update_free_access'] = FALSE;
$settings['file_public_base_url'] = 'http://localhost/files';
$settings['file_public_path'] = 'sites/default/files';
$settings['file_private_path'] = 'sites/default/private';
$settings['file_scan_ignore_directories'] = [
'node_modules',
'bower_components',
];
if (file_exists(__DIR__ . '/../development/settings.development.php')) {
include __DIR__ . '/../development/settings.development.php';
}
Run Code Online (Sandbox Code Playgroud)
/../development/settings.development.php
assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();
/**
* Enable local development services.
*/
$settings['container_yamls'][] = __DIR__ . '/development.services.yml';
$databases['default']['default'] = array(
'database' => 'dbname',
'username' => 'dbusername',
'password' => 'pw',
'prefix' => '',
'host' => '127.0.0.1',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', …Run Code Online (Sandbox Code Playgroud) 我正在使用drupal 8,我有一个实体,我想在实体表单中添加一个隐藏的类型字段。如何添加隐藏字段类型?像下面
<form>
<input type='hidden' name='my_hidden' />
</form>
Run Code Online (Sandbox Code Playgroud)
代码生成形式如下:
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the Timeslot entity.'))
->setReadOnly(TRUE);
return $fields;
}
Run Code Online (Sandbox Code Playgroud) 我是Drupal和PHP的新手。我有一个项目,在其中更新了css并保存在我的自定义主题中。
我的问题是,刷新页面时它没有更新。
我需要做些什么才能做到这一点吗???
我知道我有正确的文件和正确的选择器...
谢谢你的帮助!!