Jump to content

Category image in the left columns, instead of the center


Recommended Posts

I would like to move the image category to the left column. So i look into the category.tpl file and i copy this lines, but nothing happens:

{if $scenes}
       <!-- Scenes -->
       {include file=$tpl_dir./scenes.tpl scenes=$scenes}
   {else}
       <!-- Category image -->
       {if $category->id_image}

getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />

       {/if}
   {/if}



It seems like this only evaluates in the center column, somehow.

Is there any other technique to place the category image in the side bar?

Link to comment
Share on other sites

It's not that easy. The $category object is only available in category.tpl, not the header.tpl template. If you want to add it to that template, you must add the following to header.php before the $smarty->display:

if (isset($_GET['id_category']))
{
  $category = new Category(intval($_GET['id_category']), intval($cookie->id_lang));
  if (Validate::isLoadedObject($category))
     $smarty->assign('category', $category);
}



Then you can put the code before the {$HOOK_LEFT_COLUMN} in header.tpl.

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

This one might help you using jquery...

 

{if $scenes}

<!-- Scenes -->

{include file="$tpl_dir./scenes.tpl" scenes=$scenes}

{else}

<!-- Category image -->

{if $category->id_image}

<script type="text/javascript">

$(document).ready(function(){

$('.catimage').prependTo($('#left_column'));

});

</script>

<div class="catimage">

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

{/if}

Link to comment
Share on other sites

  • 3 months later...

Hi

Also I wanted to have image of category in left column, but when i wrote script image doesn't appears.

I use 1.4.4.1 version

In file header.php i don't found $smarty->display, i have only

$controller = new FrontController();

$controller->displayHeader();

 

So in header.php i have:

 

if (isset($_GET['id_category']))

{

$category = new Category(intval($_GET['id_category']), intval($cookie->id_lang));

if (Validate::isLoadedObject($category))

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

}

$controller = new FrontController();

$controller->displayHeader();

 

and in header.tpl i have

 

{if $scenes}

<!-- Scenes -->

{include file="$tpl_dir./scenes.tpl" scenes=$scenes}

{/if}

 

<!-- Category image -->

{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}

 

Could anyone help me?

Thank you very much

Link to comment
Share on other sites

  • 1 year later...

so in this case try to move code:

{if $scenes || $category->description || $category->id_image}
		<div class="content_scene_cat">
			{if $scenes}
				<!-- Scenes -->
				{include file="$tpl_dir./scenes.tpl" scenes=$scenes}
			{else}
				<!-- Category image -->
				{if $category->id_image}
				<div class="align_center">
					<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category_default')|escape:'html'}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />
				</div>
				{/if}
			{/if}

			{if $category->description}
				<div class="cat_desc">
				{if strlen($category->description) > 120}
					<p id="category_description_short">{$category->description|truncate:120}</p>
					<p id="category_description_full" style="display:none">{$category->description}</p>
					<a href="#" onclick="$('#category_description_short').hide(); $('#category_description_full').show(); $(this).hide(); return false;" class="lnk_more">{l s='More'}</a>
				{else}
					<p>{$category->description}</p>
				{/if}
				</div>
			{/if}
		</div>
		{/if}

from category.tpl to header.tpl right before the {$HOOK_LEFT_COLUMN}. 

i never tested it, but it is related to tutorial above (for 1.3)

Link to comment
Share on other sites

×
×
  • Create New...