1

我正在寻找一种在管理员中为我的信息页面添加字段的方法。我只需要在管理员中使用它,而不是希望在前端显示任何来自该字段的数据。

为了更好地解释我的信息页面的列表页面设置如下:

Information Title | Sort Order | Action

我想添加一个识别信息,它将显示在 admin 中的标题之前,以便一目了然,我可以查看并查看该信息页面分配给哪个商店(我正在运行多商店)。我猜需要将实际字段添加到添加/编辑表单中,然后以某种方式告知在列表页面上显示该字段输入。

我确实安装了 vQmod 并查看了文档,但我无法解决这个问题。

我真的很感激这方面的任何帮助。

这是来自 information.php 的代码。

<?php
class ModelCatalogInformation extends Model {
    public function getInformation($information_id) {
        $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.information_id = '" . (int)$information_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");

    //return $query->row;
  $r = $query->row;
$r['title'] = preg_replace('/ ## .+/','',$r['title']);
return $r;
    }

    public function getInformations() {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' ORDER BY i.sort_order, LCASE(id.title) ASC");

        //return $query->rows;
    $result = $query->rows;

foreach ($result as $key => $r){
    $result[$key] = preg_replace('/ ## .+/','',$r['title']);
}

return $result;
    }

    public function getInformationLayoutId($information_id) {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_layout WHERE information_id = '" . (int)$information_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");

        if ($query->num_rows) {
            return $query->row['layout_id'];
        } else {
            return $this->config->get('config_layout_information');
        }
    }   
}
?>

当您提到检查 vQmod 缓存时,我突然意识到我正在使用一个通过使用 -1 排序顺序从菜单中隐藏信息页面的 mod。这是缓存文件夹中的 information.php。

<?php
class ModelCatalogInformation extends Model {
    public function getInformation($information_id) {
        $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE i.information_id = '" . (int)$information_id . "' AND id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1'");

    return $query->row;
    }

    public function getInformations() {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) LEFT JOIN " . DB_PREFIX . "information_to_store i2s ON (i.information_id = i2s.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND i.status = '1' AND i.sort_order <> '-1' ORDER BY i.sort_order, LCASE(id.title) ASC");

        return $query->rows;
    }

    public function getInformationLayoutId($information_id) {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_layout WHERE information_id = '" . (int)$information_id . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "'");

        if ($query->num_rows) {
            return $query->row['layout_id'];
        } else {
            return $this->config->get('config_layout_information');
        }
    }   
}
?>
4

2 回答 2

1

如果我正确理解您的目的,我会为您提供更简单的解决方案。在 Title 字段中添加你的描述,使用一些唯一的标记来指示该描述的开始,它不会在前端呈现,例如:我##在这里用作标记。

我的标题 ## 此页面适用于商店 1

然后编辑catalog/model/catalog/information,在函数getInformation()查找行:

return $query->row;

用。。。来代替:

//return $query->row;
$r = $query->row;
$r['title'] = preg_replace('/ ## .+/','',$r['title']);
return $r;

在函数getInformations()查找行中:

return $query->rows;

用。。。来代替:

//return $query->rows;

$result = $query->rows;

foreach ($result as $key => $r){
    $result[$key] = preg_replace('/ ## .+/','',$r['title']);
}

return $result;

你完成了。

于 2013-05-06T04:38:24.967 回答
0

这对于侧边栏信息显示非常有效,但是如果您使用带有列的主题并拉入信息链接以显示在那里,它只会拉入每个链接标题的第一个字母。

这是页脚的代码。我在同一购物车版本中使用与 flightoffancy 相同的设置:

这是来自目录/控制器/通用/页脚:

    $this->load->model('catalog/information');

    $this->data['informations'] = array();

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

    $this->data['contact'] = $this->url->link('information/contact');
    $this->data['return'] = $this->url->link('account/return/insert', '', 'SSL');
    $this->data['sitemap'] = $this->url->link('information/sitemap');
    $this->data['manufacturer'] = $this->url->link('product/manufacturer');
    $this->data['voucher'] = $this->url->link('account/voucher', '', 'SSL');
    $this->data['affiliate'] = $this->url->link('affiliate/account', '', 'SSL');
    $this->data['special'] = $this->url->link('product/special');
    $this->data['account'] = $this->url->link('account/account', '', 'SSL');
    $this->data['order'] = $this->url->link('account/order', '', 'SSL');
    $this->data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL');
    $this->data['newsletter'] = $this->url->link('account/newsletter', '', 'SSL');      
于 2013-05-07T12:59:12.923 回答