Make a Lasting Impression





How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From Spain
Posts: 1281
Really my smarty skills are limited and I do not know how load a block without using foreach

Example: in our themes we have

<{foreach item=block from=$xoBlocks.page_topleft}>

If I want apply CSS code only to a concrete block I can write

<{if $block.id == "60"}>class="x"<{else}>bla,bla<{/if}>


The question is if it is possible load a block without foreach:

if $blocks.page_topleft
if block id == x ->load that block
else
foreach item block from topleft blocks

Posted on: 2012/3/9 10:15
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From Dallas, TX
Posts: 3553
You need foreach I think. It sounds like ytou always want a certain block to be on top? Or do you want to only load that block if it exists - otherwise load as normal?

I am gonna go with the first one:

<div id="leftColumn">
<{foreach 
item=block from=$xoBlocks.page_topleft}>
<{if 
$block.id == "60"}>
<
div id="leftColumnTop">
...
BLOCK CODE...
</
div>
<{/if}>
<{/foreach}>

<{foreach 
item=block from=$xoBlocks.page_topleft}>
<{if 
$block.id != "60"}>
<
div id="leftColumnBottom">
...
BLOCK CODE...
</
div>
<{/if}>
<{/foreach}>

Posted on: 2012/3/9 14:07
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
Posts: 4242
Sorting blocks is easy to do with weight - so I don't think that's what you're trying to do.

If you want a block to load only if it exists and, if it does, don't display the other blocks in that zone - that's a bit trickier.

$xoBlocks is a multi-dimensional array - the first dimension is the block position, then each position has an array of blocks. Each block is an array of properties - and that is where the blockid is. In PHP, $xoBlock['page_topleft'][index]['blockid'].

It might be easier to create a custom block position and assign your special block to it. Then, in your theme,

<{if $xoBlocks.your_position}>
  
//display your block
  
<{foreach item=block from=$xoBlocks.your_position}>
    
// your stuff here
  
<{/foreach}>
<{else}>
  
//display the blocks in the other block position
    
<{foreach item=block from=$xoBlocks.page_topleft}>
      
// your stuff here
    
<{/foreach}>
<{/if}>

Posted on: 2012/3/9 18:19
_________________
Steve
Twitter: @skenow
Facebook: Steve Kenow
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From Spain
Posts: 1281
Sorry, perhaps I was not clear explain the question.
For me it seems strange if I have five special designs for right blocks I must to do five ifs before "foreach each block from...". Or for one custom block position with only one block using make a foreach too.
Foreach seems neccesary if I apply the same design for all blocks, or using cycle values, but not in those cases.
But really there is no matter if the performance is right, just I want to know if there were different possibilities.

Thanks for the replies.

Posted on: 2012/3/12 17:30
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From MSM/MG/BR
Posts: 293

<div class="xo-block">
<
div class="xo-blocktitle"><h3><{$xoBlocks.position_name.block_id.title}></h3></div>
<
div class="xo-blockcontent"><{$xoBlocks.position_name.block_id.content}></div>
</
div>


Hope this help!

Posted on: 2012/3/12 17:56
_________________


If you like my work you can Donate
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From Dallas, TX
Posts: 3553
Rodrigo, that is cool as hell!

Posted on: 2012/3/12 19:20
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From MSM/MG/BR
Posts: 293
Yes, really cool and useful.
I've always used it this way, I thought everyone knew it.

Posted on: 2012/3/12 20:50
_________________


If you like my work you can Donate
Transfer the post to other applications Transfer


Re: How to load a concrete block?
Home away from home
Joined:
2007/12/4 9:00
From Spain
Posts: 1281
That is!
Rodrigo, It seems you have some rabbits in your hat...
Any more?

Posted on: 2012/3/14 11:48
Transfer the post to other applications Transfer






You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]