Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

Перенос хлебных крошек в header 1.5.3.1


Recommended Posts

Добрый день! Пользуюсь opencart 1.5.3.1. Пытаюсь перенести хлебные крошки в шапку сайта, но ничего не получается. Подскажите пожалуйста как это можно реализовать? Большое спасибо!

Надіслати
Поділитися на інших сайтах


Зависит от того, куда именно в шапке вы хотите перенести и смотря где - если на странице с товаром, то это в одном месте, если в категориях, то в другом. А делается это так:

\catalog\view\theme\default\template\product\product.tpl

там находите код:

 <div class="breadcrumb">
   <?php foreach ($breadcrumbs as $breadcrumb) { ?>
   <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
   <?php } ?>
 </div>

и ставите его после:

<?php echo $header; ?>

все это в самой шапке файла находится.

Надіслати
Поділитися на інших сайтах

Это не совсем то что что я хотел сделать. Я хотел хлебные крошки полностью перенести в шапку ( как было в 1.4.9)

Для этого я этот код:

 <div class="breadcrumb">
   <?php foreach ($breadcrumbs as $breadcrumb) { ?>
   <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
   <?php } ?>
 </div>

Вставил в header.tpl В результате (как и предполагалось) вылазит ошибка. Я принялся колдовать над header.php =) Но пока безрезультатно. =(

Надіслати
Поділитися на інших сайтах


Ошибку-то приведите...

Notice: Undefined variable: breadcrumbs in /sata2/home/users/germida/www/www.germida.com.ua/catalog/view/theme/default/template/common/header.tpl on line 151
Warning: Invalid argument supplied for foreach() in /sata2/home/users/germida/www/www.germida.com.ua/catalog/view/theme/default/template/common/header.tpl on line 151

При попытке выпилить код из котроллера карточки товара и вклеить в контроллер шапки - все превращается в иероглифы

Надіслати
Поділитися на інших сайтах


В котроллере шапки после

<?php  
class ControllerCommonHeader extends Controller {
protected function index() {

добавьте

 $this->language->load('product/product');

 $this->data['breadcrumbs'] = array();
 $this->data['breadcrumbs'][] = array(
  'text'	  => $this->language->get('text_home'),
  'href'	  => $this->url->link('common/home'),  
  'separator' => false
 );

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

 if (isset($this->request->get['path'])) {
  $path = '';

  foreach (explode('_', $this->request->get['path']) as $path_id) {
if (!$path) {
 $path = $path_id;
} else {
 $path .= '_' . $path_id;
}

$category_info = $this->model_catalog_category->getCategory($path_id);

if ($category_info) {
 $this->data['breadcrumbs'][] = array(
  'text'	  => $category_info['name'],
  'href'	  => $this->url->link('product/category', 'path=' . $path),
  'separator' => $this->language->get('text_separator')
 );
}
  }
 }

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

 if (isset($this->request->get['manufacturer_id'])) {
  $this->data['breadcrumbs'][] = array(
'text'	  => $this->language->get('text_brand'),
'href'	  => $this->url->link('product/manufacturer'),
'separator' => $this->language->get('text_separator')
  );

  $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
  if ($manufacturer_info) {
$this->data['breadcrumbs'][] = array(
 'text'	 => $manufacturer_info['name'],
 'href'	 => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id']),	
 'separator' => $this->language->get('text_separator')
);
  }
 }

 if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])) {
  $url = '';

  if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
  }

  if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
  }

  if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
  }

  if (isset($this->request->get['filter_category_id'])) {
$url .= '&filter_category_id=' . $this->request->get['filter_category_id'];
  }

  $this->data['breadcrumbs'][] = array(
'text'	  => $this->language->get('text_search'),
'href'	  => $this->url->link('product/search', $url),
'separator' => $this->language->get('text_separator')
  );
 }

 if (isset($this->request->get['product_id'])) {
  $product_id = $this->request->get['product_id'];
 } else {
  $product_id = 0;
 }

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

 $product_info = $this->model_catalog_product->getProduct($product_id);

 $this->data['product_info'] = $product_info;

 if ($product_info) {
  $url = '';

  if (isset($this->request->get['path'])) {
$url .= '&path=' . $this->request->get['path'];
  }

  if (isset($this->request->get['manufacturer_id'])) {
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
  }  
  if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
  }

  if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
  }

  if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
  }

  if (isset($this->request->get['filter_category_id'])) {
$url .= '&filter_category_id=' . $this->request->get['filter_category_id'];
  }

  $this->data['breadcrumbs'][] = array(
'text'	  => $product_info['name'],
'href'	  => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']),
'separator' => $this->language->get('text_separator')
  );
 }

Возможно здесь что-то лишнее есть...

  • +1 1
Надіслати
Поділитися на інших сайтах


В котроллере шапки после

<?php  
class ControllerCommonHeader extends Controller {
protected function index() {

добавьте

 $this->language->load('product/product');

 $this->data['breadcrumbs'] = array();
 $this->data['breadcrumbs'][] = array(
  'text'	  => $this->language->get('text_home'),
  'href'	  => $this->url->link('common/home'),  
  'separator' => false
 );

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

 if (isset($this->request->get['path'])) {
  $path = '';

  foreach (explode('_', $this->request->get['path']) as $path_id) {
if (!$path) {
 $path = $path_id;
} else {
 $path .= '_' . $path_id;
}

$category_info = $this->model_catalog_category->getCategory($path_id);

if ($category_info) {
 $this->data['breadcrumbs'][] = array(
  'text'	  => $category_info['name'],
  'href'	  => $this->url->link('product/category', 'path=' . $path),
  'separator' => $this->language->get('text_separator')
 );
}
  }
 }

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

 if (isset($this->request->get['manufacturer_id'])) {
  $this->data['breadcrumbs'][] = array(
'text'	  => $this->language->get('text_brand'),
'href'	  => $this->url->link('product/manufacturer'),
'separator' => $this->language->get('text_separator')
  );

  $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
  if ($manufacturer_info) {
$this->data['breadcrumbs'][] = array(
 'text'	 => $manufacturer_info['name'],
 'href'	 => $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $this->request->get['manufacturer_id']),	
 'separator' => $this->language->get('text_separator')
);
  }
 }

 if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])) {
  $url = '';

  if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
  }

  if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
  }

  if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
  }

  if (isset($this->request->get['filter_category_id'])) {
$url .= '&filter_category_id=' . $this->request->get['filter_category_id'];
  }

  $this->data['breadcrumbs'][] = array(
'text'	  => $this->language->get('text_search'),
'href'	  => $this->url->link('product/search', $url),
'separator' => $this->language->get('text_separator')
  );
 }

 if (isset($this->request->get['product_id'])) {
  $product_id = $this->request->get['product_id'];
 } else {
  $product_id = 0;
 }

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

 $product_info = $this->model_catalog_product->getProduct($product_id);

 $this->data['product_info'] = $product_info;

 if ($product_info) {
  $url = '';

  if (isset($this->request->get['path'])) {
$url .= '&path=' . $this->request->get['path'];
  }

  if (isset($this->request->get['manufacturer_id'])) {
$url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
  }  
  if (isset($this->request->get['filter_name'])) {
$url .= '&filter_name=' . $this->request->get['filter_name'];
  }

  if (isset($this->request->get['filter_tag'])) {
$url .= '&filter_tag=' . $this->request->get['filter_tag'];
  }

  if (isset($this->request->get['filter_description'])) {
$url .= '&filter_description=' . $this->request->get['filter_description'];
  }

  if (isset($this->request->get['filter_category_id'])) {
$url .= '&filter_category_id=' . $this->request->get['filter_category_id'];
  }

  $this->data['breadcrumbs'][] = array(
'text'	  => $product_info['name'],
'href'	  => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']),
'separator' => $this->language->get('text_separator')
  );
 }

Возможно здесь что-то лишнее есть...

:o

Надіслати
Поділитися на інших сайтах


Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.