1
LazyBadger
One more way to implementing block-specific design

I think, I found my way of implementing more or less universal solution for creating "special blocks" in theme.
I want to discuss it and ask for possible refactoring of not-so-elegant (from my humble POV) smaty-peace.

Preface:
Imagine you have different designs for your theme, and want to implement in (template|language)-independent form with minimal work from end-user side.

Suggested solution:
Use blocktitle and add to titles special signs, which identify "special requirement" for this block. Before display blocktitle technical part must be removed

Implementation:
For block-types Alpha, Bravo, Charlie created 3 piece of code and types names used as block identity. No idenity means default block

Theme used something like
<{if $block.title|regex_replace:"/.*Alpha/":"Alpha" eq "Alpha"}>
      ...
       
Alpha block code with
       
<{$block.title|replace:"Alpha":""|strip}>
      ... 
      <{/if}>
      <{if 
$block.title|regex_replace:"/.*Bravo/":
      
Bravo block code with
      
....
      <{/if}>
      <{if 
$block.title|regex_replace:"/.*Charlie /":
      
Charlie block code with
      
...
      <{/if}>
      default 
block code


This way user of theme have to have only small addons to block titles (in source language, or, with small changes in theme, which can be easy described in theme doc - in own language)
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

2
LazyBadger
Re: One more way to implementing block-specific design

Any comments?
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

3
studioC
Re: One more way to implementing block-specific design
  • 2005/9/2 17:52

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


hello LazyBadger,
perhaps everybody with interest in themes stuff is in holliday since 8 weeks or this topic isn't that most viewed actually.

but it's my topic
Yes, there are several ways of achieving the same result, and we had some solutions here the last month using the title smarty and some other stuff. If it is working for you it is a good way.

I'm acutally using <{if $block.title|truncate:5:"" == "titleexpression"}> or something near this but this is a solution for me only which i won't give to a client. for it's not that great to handle for non XOOPS theme knowledged ...

haven't tried your solution and actually can't imagine what is your naming alpha... but SURE we should write dome some of our solutions, on the one hand using smarty to get "active" css classes and on the other hand using smarty to querry our output. i experienced some other ways abusing title for naming conventions eg. but i think it will be a good idea to write all together isn't it? Some stuff which describes the problem and the solution with a practical example?

michael

4
highlander
Re: One more way to implementing block-specific design
  • 2005/9/2 19:07

  • highlander

  • Not too shy to talk

  • Posts: 151

  • Since: 2004/12/5


Lazybadger,

This is really great thinking !!!
Using your technique it can be quite easy to create themes with more than the 5 "normal" block locations. I hope this will lead to themes with a slightly less uniform look.

great work !

kind regards, Highlander
So, I'm in the park wondering why frisbees get larger as they get closer when suddenly, it hits me...
www.AnimalPedigree.com

5
LazyBadger
Re: One more way to implementing block-specific design

Quote:

studioC wrote:
haven't tried your solution and actually can't imagine what is your naming alpha...

You (and everybody) can name different block design as you want. I just have different style of blocks in different files and include these files inside if (one if - one file)
Oooops, "fresh" idea - If block's design-id will use also as file name for this design and add one more assignment plus include file, which filename extracted design-id name
theme become more readable and clean
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

6
WarDick
Re: One more way to implementing block-specific design
  • 2005/9/3 0:13

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


It sounds good. I am having a hard time following though. Could you post a code snippet we could paste in a theme to try it out?

Great Idea.
Urging XOOPS to be the Best It Can Be.
Richard......

7
LazyBadger
Re: One more way to implementing block-specific design

Will add into new theme and publish it (I couldn't write core early morning)
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

8
studioC
Re: One more way to implementing block-specific design
  • 2005/9/3 7:57

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


to get a block via block title is normal simple to use
<{if $block.title == "Mainmenu"}>
<
div class="oneway"><h3><{$block.title}></h3></div>
<
div id="onewaycontent"><{$block.content}></div>

<{else}>
<
div class="otherway"><h3><{$block.title}></h3></div>
<
div class="otherwaycontent"><{$block.content}></div>
<{/if}>


but sometimes thats not that funny having tiles with spaces eg. So using "truncate" is ONE way. We can catch
the firs letters or more using truncate function and we can eliminate spaces ...

<{$block.title|truncate:5:"" == "mainm"}>
output of block mainmenu will be mainm using truncate:5

having a smarty like <{$block.title}> we can add some nice functions which we add in the way
<{$block.title|function here}> and expand it to
<{if $block.title|function here}> .... <{/if}>

The website of smarty.php.net gives us more examples we can use and have fun

michael

9
LazyBadger
Re: One more way to implementing block-specific design

<{if $block.title == "Mainmenu"}>
and (less) <{$block.title|truncate:5:"" == "mainm"}> are
- language independent
- block-centric, while I prefer design-centic solution (think as "how create", not "which create")
...
BTW I didn't test my smarty-scrap, I only wrote it using docs and logic
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

10
LazyBadger
Re: One more way to implementing block-specific design

Wake up...
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

Login

Who's Online

164 user(s) are online (107 user(s) are browsing Support Forums)


Members: 1


Guests: 163


vamptrix,

more...

Donat-O-Meter

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

Latest GitHub Commits