Drupal 6 中如何排列块?
我是 Drupal 的新手,我刚刚创建了一个模块并尝试显示。但块 HTML 代码打破了主题的所有边界。我们如何控制 HTML 的块?
例如我的块代码是
function node_example_block($op='list',$delta=0){
switch($op){
case "list":
$block[0]['info'] = t('THIS IS EXAMPLE NODE EXAMPLE ');
return $block;
case "view":
$block['subject'] = "THIS MY FIRST SAMPLE BLOCK";
$block['content'] = get_tree_data();
return $block;
}
}
function get_tree_data(){
/*
$output = HTML CODES HERE .....
*/
}
return $output;
}
I am a newbie in Drupal, I just created a module and try to display. But the block HTML code breaks all boundaries of the Theme. How we can control the HTML in blocks ?
For example my block code is
function node_example_block($op='list',$delta=0){
switch($op){
case "list":
$block[0]['info'] = t('THIS IS EXAMPLE NODE EXAMPLE ');
return $block;
case "view":
$block['subject'] = "THIS MY FIRST SAMPLE BLOCK";
$block['content'] = get_tree_data();
return $block;
}
}
function get_tree_data(){
/*
$output = HTML CODES HERE .....
*/
}
return $output;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定你所说的“打破主题的所有界限”是什么意思。如果这意味着您的主题在使用该块时出错,那么答案很简单,您的 HTML 是错误的 - 例如,它可能包含未封闭的 HTML 标签。
唯一的答案是修复您的 HTML。您可能想使用 Drupal 的 HTML 校正器来查看这是否确实是问题所在:
但我不建议保持这种方式,因为 HTML 中的错误可能只是您应该修复的更大错误的症状。
I am not sure what you mean by "breaks all boundaries of the theme". If that means that your theme goes wrong when you use that block, then the answer is simply that your HTML is wrong - it may contain unclosed HTML tags for instance.
The only answer to that is to fix your HTML. You may want to use Drupal's HTML corrector to see if that is indeed the problem :
But I wouldn't recomend keeping it this way, as having a bug in your HTML could merely be a symptom of a bigger bug which you should fix.
你有 block 的 tpl 文件吗?如果没有,则为 block-NAME.tpl.php 等块创建一个 tpl 文件,并根据您的主题定义 HTML div 标签。
只需查看 block.tpl.php 的默认花环主题以供参考。我认为在模块中包含 html 代码不是一个好主意,您可以将此 html 结构放在 tpl 文件中
Do you have a tpl file for block ? If not then create a tpl file for a block like block-NAME.tpl.php and define HTML div tags according to your theme.
Just check out default garland theme for block.tpl.php for reference.And i think its not a good idea to have html code in module, you can place this html structure in tpl file