Help needed - Custom Category Template

More
14 years 2 months ago #9750 by Bigdave788
Hi there,

I have created an new category template but it doea not work and I don't know why.

This is the coding for my new Template:
Code:
<?php /** * @version 1.5 stable $Id: category.php 171 2010-03-20 00:44:02Z emmanuel.danan $ * @package Joomla * @subpackage FLEXIcontent * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr * @license GNU/GPL v2 * * FLEXIcontent is a derivative work of the excellent QuickFAQ component * @copyright (C) 2008 Christoph Lukes * see www.schlu.net for more information * * FLEXIcontent is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ defined( '_JEXEC' ) or die( 'Restricted access' ); ?> <div id="flexicontent" class="flexicontent"> <!-- BOF buttons --> <p class="buttons"> <?php //echo flexicontent_html::addbutton( $this->params ); ?> <?php echo flexicontent_html::printbutton( $this->print_link, $this->params ); ?> <?php echo flexicontent_html::mailbutton( 'category', $this->params, $this->category->slug ); ?> </p> <!-- EOF buttons --> <!-- BOF page title --> <?php if ($this->params->get( 'show_page_title', 1 ) && $this->params->get('page_title') != $this->category->title) : ?> <h1 class="componentheading"> <?php echo $this->params->get('page_title'); ?> </h1> <?php endif; ?> <!-- EOF page title --> <!-- BOF category description --> <?php if (($this->category->id > 0) && ((!empty($this->category->image) && $this->params->get('show_description_image', 1)) || ($this->params->get('show_description', 1)) || ($this->params->get('show_cat_title', 1)))) : echo $this->loadTemplate('category'); endif; ?> <!-- EOF category description --> <!-- BOF sub-categories --> <?php //only show this part if subcategories are available if (count($this->categories) && $this->category->id > 0 && $this->params->get('show_subcategories')) : echo $this->loadTemplate('subcategories'); endif; ?> <!-- EOF sub-categories --> <!-- BOF item list display --> <?php echo $this->loadTemplate('items'); ?> <!-- BOF item list display --> <!-- BOF pagination --> <?php if ($this->params->get('show_pagination', 2) != 0) : ?> <div class="pageslinks"> <?php echo $this->pageNav->getPagesLinks(); ?> </div> <?php if ($this->params->get('show_pagination_results', 1)) : ?> <p class="pagescounter"> <?php echo $this->pageNav->getPagesCounter(); ?> </p> <?php endif; endif; ?> <!-- EOF pagination --> <?php if (isset($this->item->positions['description1'])) : ?> <div id="Description1"> <?php foreach ($this->item->positions['description1'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['modleft1'])) : ?> <div id="ModuleTopLeft1"> <?php foreach ($this->item->positions['modleft1'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['modright1'])) : ?> <div id="ModuleTopRight1"> <?php foreach ($this->item->positions['modright1'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['modleft2'])) : ?> <div id="ModuleTopLeft2"> <?php foreach ($this->item->positions['modleft2'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['modright2'])) : ?> <div id="ModuleTopRight2"> <?php foreach ($this->item->positions['modright2'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['bottom1'])) : ?> <div id="Bottom1"> <?php foreach ($this->item->positions['bottom1'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['bottom2'])) : ?> <div id="Bottom2"> <?php foreach ($this->item->positions['bottom2'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> <?php if (isset($this->item->positions['bottom3'])) : ?> <div id="Bottom3"> <?php foreach ($this->item->positions['bottom2'] as $field) : ?> <span class="element"> <?php if ($field->label) : ?> <span class="label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span> <?php endif; ?> <span class="value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></span> </span> <?php endforeach; ?> </div> <?php endif; ?> </div>

I want to just to show a description field,4 modules fields and 3 fields at the bottom, I dont want any listing of items in the Category. I have placed fields in the Category template. When I go to the frontend of the homepage nothing shows up and I don't know why. Can anyone help me please

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #9764 by vlester
I think it's because you copied the syntax from an item view template and not from a category template.
The coorect syntax for the "if" is
Code:
if (isset($items[$i]->positions
and not
Code:
if (isset($this->item->positions


and for the "foreach", it's
Code:
foreach ($items[$i]->positions
and not
Code:
foreach ($this->item->positions


Hope this helps

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.480 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline