Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 创建新主题后出现Drupal错误,未定义变量:hide_site_name和其他类似错误_Php_Drupal_Drupal 7_Drupal Theming_Drupal Themes - Fatal编程技术网

Php 创建新主题后出现Drupal错误,未定义变量:hide_site_name和其他类似错误

Php 创建新主题后出现Drupal错误,未定义变量:hide_site_name和其他类似错误,php,drupal,drupal-7,drupal-theming,drupal-themes,Php,Drupal,Drupal 7,Drupal Theming,Drupal Themes,我不熟悉drupal主题。我已经创建了一个direcorymyteme并向其中添加了myteme.info,并从drupal的默认主题目录复制了其他文件。现在,在编辑了页面.tpl.php之后,drupal显示了以下错误 Notice: Undefined variable: hide_site_name in include() (line 99 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.ph

我不熟悉drupal主题。我已经创建了一个direcory
myteme
并向其中添加了
myteme.info
,并从drupal的默认主题目录复制了其他文件。现在,在编辑了
页面.tpl.php
之后,drupal显示了以下错误

Notice: Undefined variable: hide_site_name in include() (line 99 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined variable: hide_site_name in include() (line 109 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: featured in include() (line 168 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: highlighted in include() (line 187 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: sidebar_second in include() (line 212 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_first in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_middle in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_last in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_firstcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_secondcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_thirdcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_fourthcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).

在谷歌上搜索之后,我发现清除缓存可以解决这个问题。但即使在清除我的缓存后,它仍然保持不变

如果你想创建一个新的主题,最好的做法是使用类似的东西。它是空白的,完全可以定制


只要按照规定的说明操作,就可以避免上述严重错误。通常,在调用主题的
.info
文件中不存在的
页面.tpl.php
文件中的区域时,会发生这些错误

页面.tpl.php中

$page['footer_firstcolumn'];
在主题的
.info
中:

regions[footer_firstcolumn] = Footer first column

在重新检查所有区域后,不要忘记在编写自定义子模板时刷新缓存

我遇到了几乎相同的问题,消息中说“注意:未定义的索引:include()中的myIndex(某些/path/myPage.tpl.php中的第n行)”

对于通知消息中的每一行,我都使用php函数isset()解决了这个问题

例如,在您的第99行中,我将使用:

if(isset(hide_site_name)){
    //use hide_site_name in the normal way
}
还是在你的队伍里

if(isset( some_var[featured] )){
    //use "featured" index in the normal way
}
希望这有助于别人,因为这帮助了我经过长时间的寻找解决方案。 顺便说一句,我从未找到这种行为的原因。
抱歉语法不好,如果有的话。

在创建子主题后,我也遇到了同样的问题,我遵循了Meiker的答案,在包含isset时效果非常好。但由于我没有太多的编程经验,我遇到了一个障碍,第220行和多个三联画在同一行

注意:未定义索引:triptych_include()中的第一行(第220行) C:\wamp\www\dtest\sites\all\themes

因此,我添加了如下设置:

if(isset($page['triptych_first']) || (isset($page['triptych_middle']) || (isset($page['triptych_last'])))) :
对类似的错误行也做了同样的处理,现在我没有出现任何错误


我希望这有助于其他面临编程挑战的人。

感谢这一点,我现在只收到两条消息为什么?:注意:未定义变量:在include()中隐藏站点名称(E:\inetpub\wwwroot\sites\all\themes\jelly\page.tpl.php的第99行)注意:未定义变量:在include()中隐藏站点名称(E:\inetpub\wwwroot\sites\all\themes\jelly\page.tpl.php的第103行)。请参阅