【问题标题】:Where are footer variable defined in opencart?opencart 中定义的页脚变量在哪里?
【发布时间】:2016-11-23 03:27:24
【问题描述】:

我正在尝试在以下 tpl 文件的页脚中编辑指向其中一项的链接:

<?php if ($informations) : ?>
<div class="col-lg-4 col-md-4 col-xs-6">

        <div class="module clearfix">
            <h3 class="modtitle"><?php echo $text_information; ?></h3>
            <div  class="modcontent" >
                <ul class="menu">
                    <?php foreach ($informations as $information) { ?>
                    <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
                    <?php } ?>
                </ul>
            </div>
        </div>

</div>

似乎他们正在遍历一个数组,我猜它在哪里说 foreach ($informations as $information) { ?,我应该在哪里找到 $informations 变量或者我如何访问这些变量的内容?

【问题讨论】:

    标签: php variables opencart footer


    【解决方案1】:

    此文件中定义的$informations

    catalog/controller/common/footer.php
    

    第 25 行,Opencart 2.2.0.0

    这部分:

        $data['informations'] = array();
    
        foreach ($this->model_catalog_information->getInformations() as $result) {
            if ($result['bottom']) {
                $data['informations'][] = array(
                    'title' => $result['title'],
                    'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
                );
            }
        }
    

    如何访问这些变量的内容?

    当您在管理面板中创建或编辑信息页面时,会有一个标记为Bottom的复选框,如果您选中此选项,该信息页面将在$informations数组中。

    如果您尝试通过代码更改链接,您可以修改上面的代码:

        foreach ($this->model_catalog_information->getInformations() as $result) {
            if ($result['bottom']) {
                if($result['title'] == 'About Us'){
                    $link = "myCustomLink";
                } else {
                    $link = $this->url->link('information/information', 'information_id=' . $result['information_id']);
                }
                $data['informations'][] = array(
                    'title' => $result['title'],
                    'href'  => $link
                );
            }
        }
    

    或者通过信息id:

    if($result['information_id'] == 4){
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      相关资源
      最近更新 更多