顺着tpl_index_default.php摸到的瓜

来源:互联网 发布:管家婆软件打印设置 编辑:程序博客网 时间:2024/04/29 23:26

今天研究tpl_index_default.php,希望将其首页改造一下。

去掉了<h1 id="indexDefaultHeading"><?php echo HEADING_TITLE; ?></h1>,这个本来是显示“恭喜安装zencart成功”之类的东西;

去除了对includes/lanuages/schinese/html_include下的define_main_page.php的引用,就是这一句话了:<div id="indexDefaultMainContent" class="content"><?php require($define_page); ?></div>


看到下面有一系列的输出产品相关的信息。找到这个(其他类型的产品以后再弄):

/**
 * display the New Products Center Box
 */
?>
<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?>
<?php } ?>


进而抓到:这个文件tpl_modules_whats_new.php,在默认模板下。

读取这个文件,发现它又引入了一个:

 include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_NEW_PRODUCTS));

这么好玩吗。。。

这个实际上就是includes/modules/new_products.php

在这个文件中,读取一系列的新产品,放入到一个数组:$list_box_contents = array();中了。

这个数组最终是要给页面显示的,就是给这个文件tpl_modules_whats_new.php的后面的语句用的。就是说在tpl_modules_whats_new.php文件里,先引入一个获取数据的文件进行获取数据,然后将数据交给另一个文件来显示:

<?php
  require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php');
?>

交给默认模板下的common/tpl_columnar_display.php文件显示。

在这个文件就可以显示$list_box_contents = array();这里的值了。

<?php
if (is_array($list_box_contents) > 0 ) {
 for($row=0;$row<sizeof($list_box_contents);$row++) {
    $params = "";
    //if (isset($list_box_contents[$row]['params'])) $params .= ' ' . $list_box_contents[$row]['params'];
?>


<?php
    for($col=0;$col<sizeof($list_box_contents[$row]);$col++) {
      $r_params = "";
      if (isset($list_box_contents[$row][$col]['params'])) $r_params .= ' ' . (string)$list_box_contents[$row][$col]['params'];
     if (isset($list_box_contents[$row][$col]['text'])) {
?>
    <?php echo '<div' . $r_params . '>' . $list_box_contents[$row][$col]['text'] .  '</div>' . "\n"; ?>
<?php
      }
    }
?>


很通用是吧,但是太曲折了。。。。。。


总结一下:


tpl_index_default.php         -------------->      tpl_modules_whats_new.php             ------------------------->   includes/modules/new_products.php

                                                                                                                                              -------------------------->  common/tpl_columnar_display.php

按照我的要求的话,我需要改造这个tpl_columnar_display.php,按照新的样式来整改。

同时,这个tpl_index_default.php也要除头去尾,不要左边栏,不要右边栏。


0 0
原创粉丝点击