<?php
/**
* @package   BuBuJie.net Template
* @version   1.5.23 2011-07-13
* @author    bubujie@gmail.com http://www.bubujie.net/
* @copyright Copyright (C) 步步街 2008 - 2011 BuBuJie.net
*/
// 禁止直接访问
defined('_JEXEC') or die;
?>
<?php
// 模块的加div结构
function modChrome_div($module, &$params, &$attribs)
{
	$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;
	if (!empty ($module->content)) :
		echo "\n<!-- # # # module # # # -->";
		echo "\n<div class=\"module mod".$params->get('moduleclass_sfx')."\">";
		echo $module->content;
		echo "\n</div>";
		echo "\n<!-- # # # /module # # # -->";
	endif;
}

// 模块的zen garden风格结构
function modChrome_zen($module, &$params, &$attribs)
{
	$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;
	if (!empty ($module->content)) :
		echo "\n<!-- # # # module # # # -->";
		echo "\n<div class=\"module mod".$params->get('moduleclass_sfx')."\">";
		echo "\n  <div class=\"top\">";
		if ($module->showtitle) :
			echo "\n    <h".$headerLevel."><span>".$module->title."</span></h".$headerLevel.">";
		endif;
		echo "\n  </div>";
		echo "\n  <div class=\"mid\">"; 
		echo $module->content;
		echo "\n  </div>";
		echo "\n  <div class=\"btm\"></div>";
		echo "\n</div>";
		echo "\n<!-- # # # /module # # # -->";
	endif;
}

// 此函数会在beezTabs风格的位置按相应模块的数量n反复调用相同的次数,不同于普通的循环输出,它会取消前n-1次输出,而在第n次才整体输出全部内容。
function modChrome_tabs($module, $params, $attribs)
{
	// 后台无id属性设置,所以$area恒为1
	$area = isset($attribs['id']) ? (int) $attribs['id'] :'1';
	$area = 'area-'.$area;
	// 定义模块计数与模块数组
	static $modulecount;
	static $modules;
	// 某位置无模块则:将$modules定义为空数组
	if ($modulecount < 1) {
		$modulecount = count(JModuleHelper::getModules($attribs['name']));
		$modules = array();
	// 在第n次调用时输出:
	}
	if($modulecount == 1) {
		// stdClass()基类可以调用全部属性
		$temp = new stdClass();
		$temp->content = $module->content;
		$temp->title = $module->title;
		$temp->params = $module->params;
		$temp->id=$module->id;
		$modules[] = $temp;
		// TabsPanle外套
		echo "\n<!-- # # # TabbedPanle # # # -->";
		printf("\n".'<div id="%s" class="tab list jx">',
			$area
		);
		echo "\n  ".'<ul>';
		$counter=0;
		// 循环输出头部
		foreach($modules as $rendermodule) {
			$counter ? $activeClass='' : $activeClass=' class="active"';
			// Tab外套
			printf("\n    ".'<li%s><a href="#" id="link_%s">%s</a>',
				$activeClass,
				$rendermodule->id,
				$rendermodule->title
			);	
			$counter ++;
			echo "\n      ".'<ul>';
			printf("\n        ".'<li tabindex="-1" class="" id="module_%s">',
				$rendermodule->id
			);
			// 输出正文
			echo "\n<!-- # # # module # # # -->";
			echo $rendermodule->content;
			echo "\n<!-- # # # /module # # # -->";
			// Tab外套
			echo "\n        ".'</li>';
			echo "\n      ".'</ul>';
			echo "\n    ".'</li>';
		}
		// TabsPanle外套
		echo "\n  ".'</ul>';
		$modulecount--;;
		echo "\n".'</div>';
		echo "\n<!-- # # # /TabbedPanle # # # -->";
	} else {
		// 前第n<n-1次调用本函数不做输出,只将数组赋值给静态变量$modules[]用于最后一次调用时的输出,并计算剩余调用次数
		$temp = new stdClass();
		$temp->content = $module->content;
		$temp->params = $module->params;
		$temp->title = $module->title;
		$temp->id = $module->id;
		$modules[] = $temp;
		$modulecount--;
	}
}

modstyle的输出

div风格

<!-- # # # module # # # --> 
<div class="module <{mod_classname}>">
    <{$mod_body}>
</div> 
<!-- # # # /module # # # --> 

zen之A风格

<!-- # # # module # # # -->
<div class="module <{$mod_classname}>"> 
  <div class="top"></div> 
  <div class="mid"> 
    <{$mod_body}>
  </div> 
  <div class="btm"></div> 
</div> 
<!-- # # # /module # # # -->

zen之B风格

<!-- # # # module # # # -->
<div class="module <{$mod_classname}>"> 
  <div class="top"> 
    <h3><span><{$mod_title}></span></h3> 
  </div> 
  <div class="mid"> 
    <{$mod_body}>
  </div> 
  <div class="btm"></div> 
</div> 
<!-- # # # /module # # # -->  

tabs风格

<!-- # # # tabbedPanle # # # -->
<div class="tabbedPanle">
  <ul>
    <li class="active"><a href="#" id="link_16"><{$mod_title}></a>
      <ul>
        <li class="" id=""> 
          <!-- # # # module # # # -->
          <div class="module <{$mod_classname}>"> <{$mod_title}> </div>
          <!-- # # # /module # # # --> 
        </li>
      </ul>
    </li>
    <li><a href="#" id="link_38"><{$mod_title}></a>
      <ul>
        <li class="" id=""> 
          <!-- # # # module # # # -->
          <div class="module <{$mod_classname}>"> <{$mod_body}> </div>
          <!-- # # # /module # # # --> 
        </li>
      </ul>
    </li>
    <li><a href="#" id="link_38"><{$mod_title}></a>
      <ul>
        <li class="" id=""> 
          <!-- # # # module # # # -->
          <div class="module <{$mod_classname}>"> <{$mod_body}> </div>
          <!-- # # # /module # # # --> 
        </li>
      </ul>
    </li>
  </ul>
</div>
<!-- # # # /tabbedPanle # # # -->

Last edited Jul 27, 2011 at 12:00 AM by bubujie, version 10

Comments

No comments yet.