PEAK XOOPS - Free Layout of center parts (Blocks&Body) in englishin japanese

Archive | RSS |
Site News
Site News : Free Layout of center parts (Blocks&Body)
Poster : GIJOE on 2005-08-01 06:50:41 (35944 reads)

in englishin japanese
In XOOPS >= 2.0.10JP and 2.2.x , `weight` is assigned in header.php.

(`weight` is not assigned in older XOOPS 2.0.x even with 2.0.13)

This means that you can fully controll the orders of center parts by changing their weights.

Now, I've made a theme has such a feature.

You can download from here.
http://www.peak.ne.jp/xoops/md/mydownloads/singlefile.php?cid=3&lid=57

This theme is based on matchan's "KIHON1" which was made for our book "Customizing XOOPS".

I'm appreciated if this feature is included in many themes





<td id="centercolumn">

	<!-- Display center blocks if any -->
	<{if $xoops_showcblock == 1}>

	<{php}>
	$prev_htmls = array(
		'bdbd' => '' ,
		'bdcc' => '<table cellspacing="0"><tr><td class="centerCcolumn" colspan="2">' ,
		'bdcl' => '<table cellspacing="0"><tr><td class="centerLcolumn">' ,
		'bdcr' => '<table cellspacing="0"><tr><td class="centerLcolumn"></td><td class="centerRcolumn">' ,
		'ccbd' => '</td></tr></table>' ,
		'cccc' => '' ,
		'cccl' => '</td></tr><tr><td class="centerLcolumn">' ,
		'cccr' => '</td></tr><tr><td class="centerLcolumn"></td><td class="centerRcolumn">' ,
		'clbd' => '</td><td class="centerRcolumn"></td></tr></table>' ,
		'clcc' => '</td><td class="centerRcolumn"></td></tr><tr><td class="centerCcolumn" colspan="2">' ,
		'clcl' => '' ,
		'clcr' => '</td><td class="centerRcolumn">' ,
		'crbd' => '</td></tr></table>' ,
		'crcc' => '</td></tr><tr><td class="centerCcolumn" colspan="2">' ,
		'crcl' => '</td></tr><tr><td class="centerLcolumn">' ,
		'crcr' => '' ,
	) ;

 	$i = 0 ;
	$xoops_cblocks = array() ;
	foreach( $this->_tpl_vars['xoops_ccblocks'] as $i => $block ) {
		$weight = $block['weight'] * 65536 + $i ;
		$block['align'] = 'cc' ;
		$xoops_cblocks[ $weight ] =  $block ;
	}
	foreach( $this->_tpl_vars['xoops_clblocks'] as $i => $block ) {
		$weight = $block['weight'] * 65536 + $i + 16384 ;
		$block['align'] = 'cl' ;
		$xoops_cblocks[ $weight ] =  $block ;
	}
	foreach( $this->_tpl_vars['xoops_crblocks'] as $i => $block ) {
		$weight = $block['weight'] * 65536 + $i + 32768 ;
		$block['align'] = 'cr' ;
		$xoops_cblocks[ $weight ] =  $block ;
	}
	// body's weight = 100
	$xoops_cblocks[ 100 * 65536 + 49152 ] = array( 'align' => 'bd' ) ;
	ksort( $xoops_cblocks ) ;
	array_push( $xoops_cblocks , array( 'align' => 'bd' ) ) ;
	
	$prev_align = 'bd' ;
	foreach( $xoops_cblocks as $key => $block ) {
		$xoops_cblocks[$key]['prev_html'] = $prev_htmls[ $prev_align . $block['align'] ] ;
		$prev_align = $block['align'] ;
	}

	/* foreach( $xoops_cblocks as $key => $block ) {
		echo htmlspecialchars("$key:{$block['align']}:{$block['prev_html']}")."<br />" ;
	}
	exit ; */

	$last = array_pop( $xoops_cblocks ) ;
	$this->_tpl_vars['xoops_cblocks'] = $xoops_cblocks ;
	$this->_tpl_vars['xoops_cblocks_terminator'] = $last['prev_html'] ;
	<{/php}>

	<{foreach item=block from=$xoops_cblocks}>
	<{$block.prev_html}>

		<{if $block.align == "bd"}>

		<div id="content">
		<{$xoops_contents}>
		</div>

		<{else}>

		<div style="padding: 5px;">
		<{if $block.title|regex_replace:"/.*none/":"none" ne "none"}>
		<div class="blockTitle"><{$block.title}></div>
		<{/if}>
		<div class="blockContent"><{$block.content}></div>
		</div>

		<{/if}>

	<{/foreach}>
	<{$xoops_cblocks_terminator}>

	<{else}>
		<div id="content">
		<{$xoops_contents}>
		</div>
	<{/if}>
	<!-- End display center blocks -->

</td>


-------------------
(2005/8/2) modified codes better
(2005/8/6) a carless mistake add red lines.
(2005/8/10) added a description about XOOPS 2.2

Refer also http://www.peak.ne.jp/xoops/md/news/article.php?storyid=97

0 comments

Related articles
Printer friendly page Send this story to a friend

Comments list

Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!