Нужна помощь по php

Braindbrigada
На сайте с 10.01.2010
Offline
84
590

Есть два файла

1. product.tpl

{*

Template name: Товар

Отображение отдельного товара

Used by: Strefront.class.php

Assigned vars: $product, $comments, $category

*}

2. products.tpl

{*

Template name: Список товаров

Вовод списка товаров в категории

Used by: Strefront.class.php

Assigned vars: $products, $brands , $category, $total_pages, $page

*}

Не могу сделать чтобы переменная $brands относилась и к product.tpl

Код: Strefront.class.php

/** 

*
* Отображение списка товаров в категории
*
*/
function fetch_category($category_url, $brand_url)
{

// Если задан бренд, выберем его из базы
if (isset($brand_url) && !empty($brand_url))
{
$query = sql_placeholder('SELECT * FROM brands WHERE url=? LIMIT 1', $brand_url);
$this->db->query($query);
$brand = $this->db->result();
if (empty($brand))
{
return false;
}
$this->smarty->assign('brand', $brand);
}

// Выберем текущую категорию
$category = $this->category_by_url($this->categories, $category_url);
if (empty($category))
{
return false;
}
$this->smarty->assign('category', $category);

// Выбираем из базы товары
$products = $this->get_products(null, $category->subcats_ids, isset($brand->brand_id)?$brand->brand_id:null, $start_item);

$this->smarty->assign('products', $products);

// Выбираем все бренды, они нужны нам в шаблоне
if(is_array($category->subcats_ids))
$category_filter = "AND products.category_id in(".join($category->subcats_ids, ',').")";

$query = sql_placeholder("SELECT DISTINCT brands.*
FROM brands, products
WHERE products.brand_id = brands.brand_id
AND products.enabled=1
$category_filter
ORDER BY brands.name", $category->category_id, $category->category_id);
$this->db->query($query);
$brands = $this->db->results();

$this->smarty->assign('brands', $brands);

$this->body = $this->smarty->fetch('products.tpl');
return $this->body;
}

/**
*
* Отображение отдельного товара
*
*/
function fetch_product($product_url, $brand_url)
{

// Если задан бренд, выберем его из базы
if (isset($brand_url) && !empty($brand_url))
{
$query = sql_placeholder('SELECT * FROM brands WHERE url=? LIMIT 1', $brand_url);
$this->db->query($query);
$brand = $this->db->result();
if (empty($brand))
{
return false;
}
$this->smarty->assign('brand', $brand);
}

// Выбираем товар из базы
$product = $this->get_product($product_url);
if (empty($product))
{
// страница 404
return false;
}

// Выберем текущую категорию
$category = $this->category_by_url($this->categories, $product->category_url);
if (empty($category))
{
// страница 404
return false;
}

$this->smarty->assign('category', $category);

// Выбираем все бренды, они нужны нам в шаблоне
if(is_array($product_url))
$category_filter = "AND products.category_id in(".join($product_url, ',').")";

$query = sql_placeholder("SELECT DISTINCT brands.*
FROM brands, products
WHERE products.brand_id = brands.brand_id
AND products.enabled=1
$category_filter
ORDER BY brands.name", $category->category_id, $category->category_id);
$this->db->query($query);
$brands = $this->db->results();

$this->smarty->assign('brands', $brands);

$this->body = $this->smarty->fetch('product.tpl');
return $this->body;
}
if(isset($this->user->name))
{
$this->smarty->assign('name', $this->user->name);
}
Braindbrigada
На сайте с 10.01.2010
Offline
84
#1

Всем Спасибо.... Сам разобрался.🤣

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий