Assign item layout to category view

More
12 years 11 months ago #20816 by klas
Is it possible to somehow assign item template to the category of articles? I would like to have one articles category styled differently - all I found was a way to assign item template to content type or to each item separately - not too practical.

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

More
12 years 11 months ago #20820 by ggppdk
mmm , so you want to use an item layout to display the items in the category view.

-- The category view uses the category layout, which can be shaped to be whatever you need

-- Using the item layout in the category view is not allowed or possible for a good reason, the data variables are different plus a couple of more things, it is not about being practical, just, item layout is for item view and category layout is for category view

-- This is not a limitation but rather an expected behavior, the item layout is for the item view and the category layout is for the category view.

Now if you want to ADAPT an item layout to display the items in the category view, this is possible if you have basic knowledge of php and programming, with a little work:

1. Duplicate the default template as 'mytemplate1'


2. Open the item.php file of the default (or ?other? template) template which contains the item layout, copy the code between:
<div id="flexicontent" ...>
...
</div> note this is the last div in the file


3. Open the category_items.php of the mytemplate1 template and

-- 3.a Replace line
<?php if ($this->params->get('show_title', 1) || count($columns)) : ?>
with:
<?php if (1) : ?>

-- 3.b delete all code:
<table id="flexitable" class="flexitable" ...>
...
</table>


4. At the exact place that you delete the above code, enter this code:
<?php foreach ($items as $item) : ?>
... the code you copied from the item.php file
<?php endforeach; ?>


5. Replace all occurrences of $this->item with $item BE CAREFULL NOT TO MATCH $this->items (plural), so use match whole word in your editor, but do use editor to replace otherwise you will miss something, better in interactive mode


6. If you want the read more link, then copy the code from the category_items.php of the blog template:
<?php if (
( $this->params->get('show_readmore', 1) && strlen(trim($item->fulltext)) >= 1 )
...
</span>
<?php endif; ?>


7. In this read more code replace (again) all occurrences of $items[$i] with $item


8. Test and correct other errors. (you may have to remove something e.g. the comments code)


NOTE: You must have some knowledge of PHP and HTML to do this.
NOTE: I have only run this once and seemed to work, not really tested this ..., so it should work but not guarantees, that you will not need to fix something more.

I have taken the time to write this so that it will be useful to other people to, as this POST has been more than half an hour for me.

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.531 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