1
ZPC
how to differentiate blocks in theme.html?
  • 2005/4/27 22:32

  • ZPC

  • Official Support Member

  • Posts: 76

  • Since: 2002/1/16


Hi I am creating more or less table-less three column design, but I came to the point where I would have to change all the default templates for all blocks or give different css classes to mainmenu, user menu and default to other blocks.
But how to do it?
I tried to find what is being sent to the theme template and it's only array of left blocks, right blocks, etc. each only with fields block heading and block content. No bid or blockname or anything, is that right?

What would be the easiest way how to do it? Did I miss something?


The goal is simple, minimum system-templates changes and different html code for different blocks based on their bid or some block_name or something like that...

e.g. menu like on http://www.myxoops.de in regular block is impossible cause of the padding which you usualy have to give to regular text blocks...

any advices are welcome...

thx

2
LazyBadger
Re: how to differentiate blocks in theme.html?

Add own classes into theme's CSS, rewrite block templates and distribute templates with theme...

If I understood your question correct.

3
ackbarr
Re: how to differentiate blocks in theme.html?

you'd have to modify the templates in question. For example here is a modified main menu block I'm in a work-in-progress theme.
<ul id="mainmenu">
    <
li><a href="<{$xoops_url}>/"><{$block.lang_home}>a>
<{foreach 
item=module from=$block.modules}>
    <{if 
count($module.sublinkseq 0}>
    <
li><a href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}>a>li>
    <{else}>
    <
li><a href="<{$xoops_url}>/modules/<{$module.directory}>/"><{$module.name}>a>
        <
ul class="mainSub">
        <{foreach 
item=sublink from=$module.sublinks}>
            <
li><a href="<{$sublink.url}>"><{$sublink.name}>a>li>
        <{/foreach}>
        ul>
    li>
    <{/if}>
<{/foreach}>
ul>


I changed the rendering from a table based layout to a nested
    one. In addition, I added an id to the top
      as a styling hook. Now that they are in a list and have a hook, you can style them however you want.

      To use your modified styles, you can create a custom template set in System -> Templates then save the entire set as a tar.gz file, or you can include them in the theme directly.

      /themes/mytheme/templates/news customized templates for the news module
      /themes/mytheme/templates/news/blocks customized templates for news blocks


      You only have to include those you want to customize. You can get the names and purpose of each template in System -> Templates as well.

4
ZPC
Re: how to differentiate blocks in theme.html?
  • 2005/4/28 9:39

  • ZPC

  • Official Support Member

  • Posts: 76

  • Since: 2002/1/16


As you guys didn't give me any hint how to differentiate with smarty, I guess there is no way without hacking into the core, right?

Regarding the default template set, resp. modyfing those templates... I am completely aware of that, but I am a bit lazy so I wanted to find some "easier" way how to do it...

basicaly the only problem is that you ususaly need some padding inside a block, but NOT in all blocks ... e.g. main and user menu ... so my idea was the code in theme.html:
...
<{foreach 
item=block from=$xoops_lblocks}>
<
div class="leftblock">
<
div class="blockHead"><{$block.title}>div>
<
div class="blockContent"><{$block.content}>div>
div>
<{/foreach}>
...

change to something like this:
...
<{foreach 
item=block from=$xoops_lblocks}>
<
div class="leftblock">
<
div class="blockHead"><{$block.title}>div>
<{if 
$block.bid != 1}><div class="blockContent">
<{else}><
div class="menuBlockContent">
<{/if}>
<{
$block.content}>div>
div>
<{/foreach}>
...


so one could have e.g. the menu block quite different than any other block.

Now I will have to change every template on my site and add
in each and every one of them, except the menu-block templates ... damn...
Right?

5
Mithrandir
Re: how to differentiate blocks in theme.html?

Quote:
As you guys didn't give me any hint how to differentiate with smarty, I guess there is no way without hacking into the core, right?

Please re-read Ackbarr's reply.

Quote:
[...]or you can include them in the theme directly.
/themes/mytheme/templates/news customized templates for the news module
/themes/mytheme/templates/news/blocks customized templates for news blocks



You only have to include those you want to customize. You can get the names and purpose of each template in System -> Templates as well.

6
ZPC
Re: how to differentiate blocks in theme.html?
  • 2005/4/28 10:53

  • ZPC

  • Official Support Member

  • Posts: 76

  • Since: 2002/1/16


I did, couple times ... but my first question was more about variable $block for using in theme.html, than about block templates, which I know, that I can easily modify etc...
I guess my english is getting worse every day... sorry for that ... but one more try ...

On this page is basicaly what is this all about:
http://xoops.zpc.cz/dev/csslayout/test.html

There you can see the left and right menu blocks ... they don't have any padding inside the .blockContent DIV which is INSIDE the theme.html:
...
<{foreach 
item=block from=$xoops_rblocks}>
<
div class="rightblock">
<
div class="blockHead"><{$block.title}>div>
<
div class="blockContent"><{$block.content}>div>
div>
<{/foreach}>
...


but you can see that the other modules should have the padding ...

Now, what should I do ... change the code inside theme.html to something like this:

...
<{foreach 
item=block from=$xoops_rblocks}>
<
div class="rightblock">
<
div class="blockHead"><{$block.title}>div>
<{
$block.content}>
div>
<{/foreach}>
...


and modify all templates of blocks on my site - adding the div into every one of them with any variety of css classes as I wont ... right?

<div class="blockContent">...original block-template content...div>


so I could have in my MENU block-templates:

<div class="blockMenu">...original menu block-template content...div>


That is what I call pain in ... you know where ...

did you get my point? do I really have to do it that way?

7
ackbarr
Re: how to differentiate blocks in theme.html?

Quote:

ZPC wrote:
basicaly the only problem is that you ususaly need some padding inside a block, but NOT in all blocks ... e.g. main and user menu ... so my idea was the code in theme.html:

...
<{foreach 
item=block from=$xoops_lblocks}>
<
div class="leftblock">
<
div class="blockHead"><{$block.title}>div>
<{if 
$block.bid != 1}><div class="blockContent">
<{else}><
div class="menuBlockContent">
<{/if}>
<{
$block.content}>div>
div>
<{/foreach}>
...




As you have already determined for yourself the block id is not passed into smarty with the title and content, so you cannot do it that way, only by using hooks in the block's template itself.

Login

Who's Online

304 user(s) are online (199 user(s) are browsing Support Forums)


Members: 0


Guests: 304


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits