开发者

Drupal6: How to programmatically style a block?

开发者 https://www.devze.com 2023-03-16 18:03 出处:网络
In Drupal6, I basically have a block (a hierarchical menu structure) that turns out like this in HTML:

In Drupal6, I basically have a block (a hierarchical menu structure) that turns out like this in HTML:

<div class="block block-menu_block" id="block-menu_block-1">
&开发者_开发知识库lt;div class="content">
    <div class="menu-block-1 menu-name-menu-navigation parent-mlid-0 menu-level-1">
    <ul class="menu">
        <li class="leaf first menu-mlid-248 active active-trail"><a class="active-trail active" title="" href="/">Start</a></li>
        <li class="expanded menu-mlid-249 active"><a class="active" title="" href="/">Aktuell</a>
            <ul class="menu">
                <li class="leaf first menu-mlid-259">
                    <a title="News und Presse" href="/news-und-presse">News and Press</a>
                </li>...

What I would like to get is actually a lot simpler:

<div id="topmenu">
    <ul class="one">
    <li>some main entry
        <ul>
        <li>
            some sub entry ...

or maybe:

<div id="topmenu">
    <h2>some main entry</h2>
        <h3><a href="#">some sub entry</a></h3>
        <h3><a href="#">another sub entry</a></h3>
    <h2>another main entry</h2>

So, keeping the structure, but being able to use simpler, even completely different tags, if and when needed. I think I understand from the drupal docs, that I am (maybe) looking at

<div class="block block-menu_block"
id="block-menu_block-1"

==>     module := menu_block
    delta  := 1 (?)

regrettably, none of the suggested

  • block-[module]-[delta].tpl.php
  • block-[module].tpl.php
  • block-[region].tpl.php

placed next to page.tpl.php (yes, I did clear the cache), has any impact. Even with just a big, shiny HELLO WORLD inside... no luck...

What do I need to override and how? (ideally some sort of recursive function?)

Thank you!


You can control all html output by overriding theme functions and templates in your own custom theme. Read the documentation to learn how: http://drupal.org/node/341628.

That said: if this really bothers you about Drupal, you may want to save yourself a headache and choose a different CMS/framework. Drupal is designed to produce generic html with enough divs and classes for 95% of the use cases. Clean and minimal html can be accomplished, but it can take a lot of time.


you can install the devel and the theme developer module. then you cativate theme developer and in the bottom left corner you can switch it on. after pointing on your block you get much information which templates are userd or if it's functions who generate the code, which functions to use for naming the overwrite.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号