Jump to content
Sign in to follow this  
Ilya

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

Recommended Posts

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

Share this post


Link to post
Share on other sites

что именно не получается ? на каком этапе стоп ? ))

Share this post


Link to post
Share on other sites

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

\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; ?>

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

Share this post


Link to post
Share on other sites

Это не совсем то что что я хотел сделать. Я хотел хлебные крошки полностью перенести в шапку ( как было в 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 =) Но пока безрезультатно. =(

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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

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

Share this post


Link to post
Share on other sites

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

<?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

Share this post


Link to post
Share on other sites

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

<?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

Share this post


Link to post
Share on other sites

:o

Работает не корректно: на стр корзины в "хлебных крошках" отображается только Главная , на стр поиска тоже самое и тд

Share this post


Link to post
Share on other sites

Значит надо смотреть в котроллере корзины и поиска чего не хватает и добавлять в контроллер шапки.

Ищите все, что касается breadcrumb.

  • +1 1

Share this post


Link to post
Share on other sites

Значит надо смотреть в котроллере корзины и поиска чего не хватает и добавлять в контроллер шапки.

Ищите все, что касается breadcrumb.

Большое спасибо!

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.