Building Category homepage showing subcategories with leading articles for each

More
9 years 1 month ago - 9 years 2 weeks 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: 9 years 2 weeks ago by ggppdk.

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

More
9 years 4 weeks ago #65576 by netenvie

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

More
9 years 3 weeks ago #65660 by netenvie

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

More
9 years 3 weeks ago - 9 years 3 weeks 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: 9 years 3 weeks ago by netenvie.

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

More
9 years 3 weeks 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
9 years 3 weeks ago - 9 years 3 weeks ago #65678 by netenvie
Last edit: 9 years 3 weeks ago by netenvie.

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

More
9 years 3 weeks ago #65679 by micker
in faq template you need
1 master cat (lien menu to)
|_ sub cat1
|_ sub cat2
|_ sub cat3
|_ sub cat4
in master cat assign faq template all level not only 1 subcatégorie

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
9 years 3 weeks ago - 9 years 3 weeks ago #65680 by netenvie
I found the solution ...

I forgot this line :
$items = & $this->items;

in my template ...

Now i just need to know how to display leadings only ??
Last edit: 9 years 3 weeks ago by netenvie.

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

More
9 years 3 weeks ago - 9 years 2 weeks ago #65710 by netenvie
Hi all,
Finally i don't need to display leading and whatever i had a solution.
So all is ok except i need to display items from subcats of one subcat in my page ... :/

I have this :

Master cat
|_ sub cat1
|_ sub cat2
|_ sub cat3
|___ sub sub cat1
|___ sub sub cat2

On my page only sub cats 1 and 2 are displayed and i would need to display also items from sub sub cats 1 and 2 ... And mix together.
in other words i need to display items from sub cats of sub cat3 together ...

This is my actual code, what can i add or change to make this run ok ?
Code:
<?php endif; $items = & $this->items; // -- 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> <h4><?php echo $sub->description; ?></h4> <div class="uk-grid articles"> <?php $ic = 0; foreach ($items as $i => $item) { $ic++; if ($ic>4) continue; ?> <div class="uk-width-1-1 uk-width-small-1-2 uk-width-medium-1-4 epcomexp"> <div> <?php echo $item->fields['photo']->display; ?> </div> <h2><?php echo $item->title; ?></h2> <div class="epartdesc"><?php echo substr($item->text,0,100)." ..."; ?></div> </div> <?php } ?> </div> <?php } ?>
Last edit: 9 years 2 weeks ago by netenvie.

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

More
9 years 2 weeks ago #65725 by netenvie

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

Moderators: vistamediajoomlacornerggppdk
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
Save