我有一个 HTML 模板。将其转换为 Drupal 6 主题的步骤是什么?
5 回答
如果您提供我的主题图片,我可以告诉您一些常见的计划。谢谢你的形象。
我的建议是我建议不要真正实现 zen 主题,因为它建议只是更改 css。并且您已经拥有不是以 drupal 方式完成的 html 和 css。
- 将任何主题安装到您的站点/所有/主题。我将使用例如 zen 主题。所以路径将是 sites/all/themes/zen
- 将文件从 sites/all/themes/zen/zen 子主题复制到 sites/all/themes/zen/mytheme
- 将sites/all/themes/zen/mytheme/zen.info重命名为sites/all/themes/zen/mytheme/mytheme.info
- 在 mytheme.info 中更改主题名称
- 将所有 css 和 js 文件复制到 sites/all/themes/zen/mytheme(最好为 css 和 js 创建子目录)
- 删除 zen 默认的 zen css 文件
stylesheets[all][] = html-elements.css stylesheets[all][] = tabs.css stylesheets[all][] = messages.css stylesheets[all][] = block-editing.css stylesheets[all][] = wireframes.css stylesheets[all][] = zen.css stylesheets[print][] = print.css
- 将您的 css 文件添加到 mytheme.info。使用这种结构
stylesheets[all][] = mycss.css
将您的 js 文件添加到 mytheme.info。使用这种结构
脚本[] = myjs.js
有关 theme.info 文件的更多信息请看这里http://drupal.org/node/171205
- 看这张图
这就是我认为拆分页面更好的方式。
标题下的菜单看起来像主菜单。给他们添加主题
function mytheme_menu_links ($items, $type = 'free') {
if (!empty($items)) {
foreach ($items as $index => $link) {
$output = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']); /* insert your html*/
}
return $output;
}
右块看起来像块。所以检查 block.tpl.php 和块主题手册http://drupal.org/node/104319
内容区域主题取决于我们作为内容显示的内容。通常是视图或节点。所以视图 = http://drupal.org/node/352970 节点 = http://drupal.org/node/11816
所有其他 html 放入 page.tpl.php。但是您应该在主题块、菜单或内容区域之前执行此操作。 http://drupal.org/node/11812
没有自动方法可以将您的 HTML 转换为 drupal 主题。创建自己的 drupal 主题的最简单方法是从 Zen 主题开始,然后自定义 CSS。
这是 Zen 主题的链接 http://drupal.org/project/zen
There's no quick easy solution. I would suggest reading the documentation for theming at Drupal.org. After getting familiar with that information, hit up the Tools, best practices and conventions section specific to theming.
When it comes time to do the conversion from HTML to Drupal, I think you will find Firebug or the development tools of Chrome to be indispensable, inspect element in either tool will be very helpful.
如果您已经拥有自己的 HTML 模板,我建议您避免使用 zen 主题(当然,这很棒)。这是10分钟的工作:
根据 drupal.org/node/171205 创建您的 theme.info 文件
现在创建你的 page.tpl.php 文件。只需将您的 HTML 模板重命名为该名称即可。将这些放在您的标题中(替换 css、js 的实际链接标签...):
<?php print $head; ?>
<?php print $styles; ?>
<?php print $scripts; ?>
现在使用变量 $menu、$left、$right、$content 等...在您想要放置适当页面段的位置。不要忘记把这个
<?php if ($tabs): print '<div class="tabs">'.$tabs.'</div>'; endif; ?>
<?php if ($help) { ?><div class="help"><?php print $help ?></div><?php } ?>
<?php if ($messages) { ?><div class="messages"><?php print $messages ?></div><?php } ?>
在内容上方,因此您还将获得选项卡、帮助和消息。
样式它。而已。你可以看看这篇文章,不过它是斯洛伐克语的。但是从代码片段中应该很清楚发生了什么,如果没有,请使用谷歌翻译来熟悉一下。
祝你好运!