Jump to content
Sign in to follow this  
megrel

[Решено] Изображения производителей в хедере

Recommended Posts

Вывел производителей в хедер

header.php

$this->load->model('catalog/manufacturer');
		$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
		foreach ($manufacturers as $manufacturer) {
					$manufacturer_children_data[] = array(
						'name'  => $manufacturer['name'],	
						'image'     => $manufacturer['image'],
                                                'image_src'     => $server . 'image/' . $manufacturer['image'],
						'href' => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $manufacturer['manufacturer_id'])	
					);
		}
				
		$this->data['manufacturers'][] = array(
					'name'     => 'Brands',
					'children' => $manufacturer_children_data,
					'column'   => 1,
					'href'     => $this->url->link('product/manufacturer')
				);

header.tpl

<?php if ($manufacturers) { ?>
  <ul>
    <?php foreach ($manufacturers as $manufacturer) { ?>
    <li> 
      <?php if ($manufacturer['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($manufacturer['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($manufacturer['children']) / $manufacturer['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($manufacturer['children'][$i])) { ?>
          <li><a href="<?php echo $manufacturer['children'][$i]['href']; ?>"><?php echo $manufacturer['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
<?php } ?>

По разному пробовал, но ничего не вышло. Опытные люди, подскажите пожалуйста, как вывести image брендов в хедер?

Share this post


Link to post
Share on other sites

Если нужно просто вывести одним списком, то я бы сделал как-то так. Задумку с колонками не понял вашу.

$this->load->model('catalog/manufacturer');
$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
$this->data['manufacturers'] = array();
foreach ($manufacturers as $manufacturer) {
    $this->data['manufacturers'][] = array(
        'name'      => $manufacturer['name'],    
        'image'     => $manufacturer['image'],
        'image_src' => $server . 'image/' . $manufacturer['image'],
        'href'      => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $manufacturer['manufacturer_id'])    
    );
}

А это в шаблон:

<?php if(!empty($manufacturers)) : ?>
    <ul>
        <?php foreach($manufacturers as $manufacturer) : ?>
            <li>
                <a href="<?php echo htmlspecialchars($manufacturer['href']); ?>">
                    <img src="<?php echo htmlspecialchars($manufacturer['image_src']); ?>" alt="<?php echo htmlspecialchars($manufacturer['name']); ?>" title="<?php echo htmlspecialchars($manufacturer['name']); ?>" />
                </a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

Share this post


Link to post
Share on other sites

Спасибо за подсказку. Помогло, все вывелось как надо.

А решение этот из одного vqmod-а. Поэтому вручную если - лучше вашим способом.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.