W
W
Warlynn2020-02-14 22:49:06
PHP
Warlynn, 2020-02-14 22:49:06

How to output standard slideshow variables in header.twig (banner and its name)?

Good afternoon.
Please tell me the algorithm of actions: it is

necessary to display the image variables and the names of the standard slideshow.twig in the header.twig file
, there is no need to transfer the slider module itself, only variables so that the header contains slides and their names.

I suspect that in the header.php controller it is necessary to include models as in the slideshow.php controller:

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


as well as:

$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'], $setting['height'])
                );
            }
        }


but it doesn't work, unfortunately. The notice "Undefined index: banner_id" pops up. I tried to set it manually - the result is zero. But where does it come from in slideshow.php then

?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lazuren, 2020-04-09
@lazuren

In the controller in which you plan to call the banner (in your case, the header), you need to pass the $setting settings array, which should contain the properties banner_id, width, height

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question