简体   繁体   English

Drupal 7如何在自定义主题中添加内容

[英]Drupal 7 how to add content in custom theme

I am developing my custom theme in drupal 7. 我在drupal 7中开发自定义主题。

I have .info , page.tpl.php and style.css file . 我有.infopage.tpl.phpstyle.css file

I want to add content (from admin panel article and other contents) in my theme. 我想在主题中添加内容(来自管理面板文章和其他内容)

How will I do this ? 我该怎么做? I have added print render($page['content']); 我添加了print render($page['content']); in page.tpl.php but it doesn't work. page.tpl.php但是它不起作用。

You need to declare the regions in .info file, 您需要在.info文件中声明区域,

name = themename
description = Your theme description.
version = 7.x
core = 7.x
stylesheets[all][] = css/style.css 

scripts[] = js/yourscript.js 


regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer

then clear the cache tho affect the changes. 然后清除缓存,以免影响更改。

You can use the same <?php print render($page['content']); ?> 您可以使用相同的<?php print render($page['content']); ?> <?php print render($page['content']); ?> for displaying the content in page.tpl.php <?php print render($page['content']); ?>用于显示page.tpl.php中的内容

After that go to admin-> structure->blocks 在那之后去admin-> structure-> blocks

Assign "main page content" to the "content" block 将“主页内容”分配给“内容”块

More detailed documentation here. 更详细的文档在这里。

Please follow the folder and file naming structure. 请遵循文件夹和文件的命名结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM