Jump to content

Moving and enlarging category images


Recommended Posts

I'm working with the Prestashop_new template and version 1.4.7.3 and I'd like to be able to take the category image and move it up above the breadcrumbs and make it the full width of the center column. I want the category name to appear on top of the image.

 

I'm not sure if this can be done using a module or via changes to the template file. Can anyone point me in the right direction? I've looked through a few posts, but haven't quite seen something that will work.

 

I believe I need to edit header.tpl to add the category image and also make sure the category object is available, but this still isn't quite doing it for me (http://www.prestashop.com/forums/topic/86554-category-image-in-the-left-columns-instead-of-the-center/).

 

The site is here: http://www.fiddleheadartisansupply.com/shop/

 

Thanks for any help.

Link to comment
Share on other sites

I've found some more information, but this solution is not working for me and I can't figure out why. Can anyone help?

 

I've added the following code to header.php

 

if (isset($_GET['id_category']))
{
$category = new Category(intval(Tools::getValue('id_category')), intval($cookie->id_lang));
if (!Validate::isLoadedObject($category))
	$errors[] = Tools::displayError('category does not exist');
elseif (!$category->checkAccess(intval($cookie->id_customer)))
	$errors[] = Tools::displayError('you do not have access to this category');
else
{
	$category->name = Category::hideCategoryPosition($category->name);
	$smarty->assign('category', $category);
}
}

 

I've added this code to my header.tpl file:

		{if $category->id_image}
			<div class="align_center">
 <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
</div>
{/if}

Link to comment
Share on other sites

  • 4 weeks later...

Having a conversation with myself is not so much fun. It would be great to get some input from someone.

 

I now have the category name displaying in the header, but I don't seem to be able to get the category image to show up. I think I am missing the variable that pulls in the category id and therefore the image id, but I am not sure. Help would be appreciated.

 

Here's the code in my FrontController.php override file:

<?php
class FrontController extends FrontControllerCore
{
public function displayHeader()
{
 $pathinfo = pathinfo(__FILE__);
 $page_name = basename($_SERVER['PHP_SELF'], '.'.$pathinfo['extension']);
 $page_name = (preg_match('/^[0-9]/', $page_name)) ? 'page_'.$page_name : $page_name;
 if ($page_name == 'category' AND isset($_GET['id_category']))
 {  
  $category = new Category($_GET['id_category'], intval(self::$cookie->id_lang));
  if (Validate::isLoadedObject($category))
self::$smarty->assign('category_name', $category->name);
 }
 elseif ($page_name == 'product' AND isset($_GET['id_product']))
 {
  $product = new Product($_GET['id_product'], false, intval(self::$cookie->id_lang));

  if (Validate::isLoadedObject($product))
self::$smarty->assign('product_name', $product->name);
  $images = $category->getImages(intval($cookie->id_lang));
  foreach ($images AS $k => $image) {
if ($image['cover']) {
  $cover = $image;
  $cover['id_image'] = intval($category->id).'-'.$cover['id_image'];
  $cover['id_image_only'] = intval($image['id_image']);
}
  }
  if (!isset($cover)) $cover = array('id_image' => Language::getIsoById($cookie->id_lang).'-default', 'legend' => 'No picture', 'title' => 'No picture');
  self::$smarty->assign('cover', $cover);

 }
 parent::displayHeader();
}
}
?>

 

Here's the code in my header.tpl file:

 

{if isset($category_name)}{$category_name}<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" title="{$category_name|escape:'htmlall':'UTF-8'}" alt="{$category_name|escape:'htmlall':'UTF-8'}" width="{$categorySize.width}" height="{$categorySize.height}" />{else}{l s='Wrong again'}{/if}

 

Help! My site URL is here: http://www.fiddleheadartisansupply.com/shop/11-fabric

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...