Building Category homepage showing subcategories with leading articles for each

More
7 years 10 months ago - 7 years 10 months ago #65534 by netenvie
Hi,
Happy new year !

This is my goal :
I want to show for a category all subcategories and for each subcategory only leading articles (4 to 8 ).
Subcategories should be stacked in lines and leading articles inside each subcat should be in columns (4).
What is the best way to do that ?

I have no problem with html and css and i want to manage this in a custom template to make different display for each subcategory.

So i have already created the custom template and assigned it to my main category.
But now i face the subcategory problem and as there is tons of code it is a bit complex ...
Some code to cycle thru subcats then cycle thru leading articles ?

In tmpl_common/category_subcategories.php i see we can cycle subcats with :
Code:
foreach ($this->categories as $sub) {
But after that how to cycle thru leading articles of the current sub-category ?

I would need something like :
Code:
foreach ($sub->leadings as $item) { echo $item->title; echo $item->image; }
But i guess i need some code to get leading items in each sub and also force some fields rendering (image and files).

Cheers
Last edit: 7 years 10 months ago by ggppdk.

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

More
7 years 10 months ago #65576 by netenvie

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

More
7 years 10 months ago #65660 by netenvie

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

More
7 years 10 months ago - 7 years 10 months ago #65675 by netenvie
After some search i use code from faq template.
This what i get now :
Code:
// -- Find all categories used by items $currcatid = $this->category->id; $cat_items[$currcatid] = array(); $sub_cats[$currcatid] = & $this->category; foreach ($this->categories as $subindex => $sub) : $cat_items[$sub->id] = array(); $sub_cats[$sub->id] = & $this->categories[$subindex]; endforeach; // -- Group items into categories for ($i=0; $i<count($items); $i++) : foreach ($items[$i]->cats as $cat) : if (isset($cat_items[$cat->id])) : $cat_items[$cat->id][] = & $items[$i]; endif; endforeach; endfor; foreach ($cat_items as $catid => $items) { $sub = & $sub_cats[$catid]; if ($sub->id == $currcatid) continue; ?> <!-- BOF sub-categories loop --> <h2><a href="index.php?option=com_flexicontent&view=category&Itemid=664&cid=<?php echo $sub->id; ?>"><?php echo $sub->title; ?></a></h2> <p><?php echo $sub->description; ?></p> <div class="uk-grid articles"> <?php foreach ($items as $i => $item) { ?> <?php echo $item->fields['photo']->display; ?> <h3><?php echo $item->title; ?></h2> <?php } ?> </div> <?php } ?>

Categories display well,
but i have no items showing
and i still don't know how to take leadings only ...

I have some flag and it don't enter in foreach ($items as $i => $item) loop ...
Last edit: 7 years 10 months ago by netenvie.

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

More
7 years 10 months ago #65677 by micker
did you check you categorie config to display all item in sub categorie ?

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
7 years 10 months ago - 7 years 10 months ago #65678 by netenvie
Last edit: 7 years 10 months ago by netenvie.

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

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