打开购物车删除$ width和$ height

时间:2014-02-01 16:20:51

标签: php opencart

我使用开放式购物车我试图通过我的幻灯片控制器删除$width$height

然后获取图片,标题和链接。我试图删除$widths$height,但仍然会收到错误

<?php  
class ControllerModuleSlideshow extends Controller {
    public function index($setting) {
    static $module = 0;

    $this->load->model('design/banner');
    $this->load->model('tool/image');

    $this->document->addStyle('catalog/view/javascript/jquery/flexslider/flexslider.css');
    $this->document->addScript('catalog/view/javascript/jquery/flexslider/jquery.flexslider-min.js');

    $data['width'] = $setting['width']; //need to remove
    $data['height'] = $setting['height']; //need to remove

    $data['banners'] = array();

    $results = $this->model_design_banner->getBanner($setting['banner_id']);

    foreach ($results as $result) {
        if (is_file(DIR_IMAGE . $result['image'])) {
            $data['banners'][] = array(
                'title' => $result['title'],
                'link'  => $result['link'],
                'image' => $this->model_tool_image->resize($result['image'], $setting['width']//need to remove, $setting['height']//need to remove)
            );
        }
    }

    $data['module'] = $module++;

    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/slideshow.tpl')) {
        return $this->load->view($this->config->get('config_template') . '/template/module/slideshow.tpl', $data);
    } else {
        return $this->load->view('default/template/module/slideshow.tpl', $data);
    }
}
}

似乎无法找到替代宽度和高度的方法

public function getImage($image){
$image = DIR_IMAGE . $image;

if($this->request->server['HTTPS']) {
    return $this->config->get('config_ssl') . 'image/' . $image;
} else {
    return $this->config->get('config_url') . 'image/' . $image;
}   
}

$this->getImage($result['image']);

3 个答案:

答案 0 :(得分:0)

宽度和高度是帮助您动态分配宽度和高度的功能,您可以从管理面板设置

admin>extensions>modules>slideshow[edit]

如果您不希望此功能生效

只需转到模板文件

即可

find(catalog / view / theme / default / template / module / slideshow.tpl)

<div id="slideshow<?php echo $module; ?>" class="nivoSlider" style="width: <?php echo $width; ?>px; height: <?php echo $height; ?>px;">

替换为

<div id="slideshow<?php echo $module; ?>" class="nivoSlider">

答案 1 :(得分:0)

两种方式来帮助你:) 目录/ controller / module / slideshow.php

$this->data['width'] = $setting['width'];
$this->data['height'] = $setting['height'];

 $this->data['width'] = '0';  // or NULL 
 $this->data['height'] = '0'; // or NULL

在catalog / view / theme / default / template / module / slideshow.tpl

<div id="slideshow<?php echo $module; ?>" class="nivoSlider" style="width: <?php echo $width; ?>px; height: <?php echo $height; ?>px;">

<div id="slideshow<?php echo $module; ?>" class="nivoSlider">

如果您需要添加自定义高度和宽度,请将此添加到上面的代码更改000到您的大小

 <div id="slideshow<?php echo $module; ?>" class="nivoSlider" style="width: 000px; height: 000px;">

答案 2 :(得分:0)

不久前我遇到了这个问题。它让我感到愚蠢,我想要的只是让幻灯片显示响应,但W x H值变得非常麻烦,删除而不影响其他类。 便携性也是我的一个严重问题。基本上所有这一切都是在使用nivoslider代码,但使用bootstrap carousel进行显示。因此,您可以像往常一样更改幻灯片横幅,并始终显示在前端。

如果你碰巧使用了bootstrap 3框架,这是一个很好的工作,证明是成功的。不要编辑slideshow.php,而是编辑 slideshow.tpl 。我强烈建议你不要乱用php文件,除非你对php和opencart中mvc的想法非常熟悉。说实话,你可能永远不应该编辑,只是扩展或从头开始,因为它使用后退机制。

但无论如何,代码:

<div class="col-md-12" >
    <div id="homepage" class="carousel slide">
        <div class="carousel-inner">
            <?php 
              $flag = 0;
              foreach ($banners as $banner) { ?>
              <div class="item <?=$flag==0?"active":""?>">

              <?php if ($banner['link']) { ?>
              <a href="<?php echo $banner['link']; ?>"><img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" /></a>
               </div>
              <?php } else { ?>
              <img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" />
              </div>
              <?php } ?>
              <?php 
              $flag=1; 
              } ?>
    </div>
  </div> 

...和JQuery

 <script>
        $(document).ready(function(){
          $('.carousel').carousel({
            interval: 5000
          });
        });
  </script>

欢迎编辑