xoops forums

rtskoo

Just popping in
Posted on: 2010/8/30 10:30
rtskoo
rtskoo (Show more)
Just popping in
Posts: 5
Since: 2010/8/30
#1

How to hack about: one block with one template file,not share the same template file ??

Is there anyone knows:
How to make one block have one template file ,not share the same template file ??

Bleekk

Theme Designer
Posted on: 2010/8/30 10:51
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 735
Since: 2002/12/14
#2

Re: How to hack about: one block with one template file,not share the same template file ??

you can do it by checking the block id or block title
<{if $block.title=="block-name"}>
  <
div class="thisclass">
<{elseif 
$block.title=="blockname"}>
  <
div class="anotherclass">
<{/if}>

rtskoo

Just popping in
Posted on: 2010/8/30 18:29
rtskoo
rtskoo (Show more)
Just popping in
Posts: 5
Since: 2010/8/30
#3

Re: How to hack about: one block with one template file,not share the same template file ??

Thanks. But I have set the $block.title null, so I cannot use it in "IF". $block.id can be used.
Is there any better way without "IF" in template file?

Bleekk

Theme Designer
Posted on: 2010/8/30 18:45
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 735
Since: 2002/12/14
#4

Re: How to hack about: one block with one template file,not share the same template file ??

hmm you can ad a counter in the foreach loop so you will get for each block listed a new class
something like this
<div class="something<{counter}>">

result:
<div class="something0">
<
div class="something1">
<
div class="something2">
<
div class="something3">

rtskoo

Just popping in
Posted on: 2010/8/30 19:07
rtskoo
rtskoo (Show more)
Just popping in
Posts: 5
Since: 2010/8/30
#5

Re: How to hack about: one block with one template file,not share the same template file ??

good idea!thank u
but I need PHP code hacking the core so that I can use the template file in menu "System Configuration"->"Templates" which is empty berfore hack.Or other better way?
And I have try the module "Defacer".However it is for page,not for a block in the page.

Bleekk

Theme Designer
Posted on: 2010/8/30 19:25
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 735
Since: 2002/12/14
#6

Re: How to hack about: one block with one template file,not share the same template file ??

you are welcome.
sorry but I do not understand what you are trying to do. maybe you can explain it one more time for me

rtskoo

Just popping in
Posted on: 2010/8/30 19:45
rtskoo
rtskoo (Show more)
Just popping in
Posts: 5
Since: 2010/8/30
#7

Re: How to hack about: one block with one template file,not share the same template file ??

We know that when a new block is cloned ,its template file is empty ,even saved after some code written in this empty template file . Because this new block shares the same template file with the old block.So how can we do to make this new block's template file usefull ? That means this new block's template file will be not empty after modify it,and it will take effect for the new block.

Bleekk

Theme Designer
Posted on: 2010/8/30 20:58
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 735
Since: 2002/12/14
#8

Re: How to hack about: one block with one template file,not share the same template file ??

sorry this is something complete different. i hope someone else can help you

ghia

Community Support Member
Posted on: 2010/8/31 2:42
ghia
ghia (Show more)
Community Support Member
Posts: 4946
Since: 2008/7/3 1
#9

Re: How to hack about: one block with one template file,not share the same template file ??

You want not a cloned block, but a changed copy of the block.
Check out the module tutorial on kaotik.biz, there is a section that deals with blocks.
Then edit the xoops_version file of your module and add a new block by duplicating the target block entries and giving it new names. Then go to the file where the original block function is defined and duplicate there also the code and rename the function. Duplicate also the template file with the new name.
Update the module.
You now have two blocks with the same function, yet different setup and templates.