Category view - show items in subcategories

More
16 years 2 months ago #1829 by WebDesignHero
The way I am looking at implementing Flexicontent beyond just articles is in a DB way. I currently have a top level category called "Glossary" with many specific glossaries underneath it. When you visit the top level glossary page, there are no items there because they are all in subcategories. I think it would be nice if i could automatically list children-item down X levels of the hierarchy, so I can see all of the glossary items no matter which specific glossary they are in.

Looking at other possible solutions. I could put everything in one glossary and create a filtering field to differentiate or I could also manually add every glossary item to the parent categories manually as secondary categories, but this could cause management headaches later if there is some kind of reorganization.

Looking for comments or code modes, thanks.

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

More
16 years 1 month ago #3173 by vlester
I think you could do what you're looking for with the Directory menu of Flexicontent.

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

More
16 years 1 month ago #3218 by Rooney
Nope. Don't think so. There have been several questions like this...

E.g.: www.flexicontent.org/forum/index ... =viewtopic

Would be great to have a solution.

Rooney

Joomla! 3.9.24 and FC 3.3.9

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

More
16 years 1 month ago #3231 by vlester
I solve this problem by using a News Module.
I create a category "A" but with no items in it, then a Flexicontent menu (type category) that points to this category "A".
Then I create a new module of NEWS (I use JA NEWS) and make it display on the category A Menu.
In this module, you can display all the categories you want with their items, just their title or the full text.

I do this for my frontpage but also for the menus with sublevels.

JA News is not free unfortunately but may be you can find another free News Module that will do it.

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

More
16 years 1 month ago #3236 by WebDesignHero
Ideally, this would be coded as a simple option. the problem is that no one uses nested sets ( dev.mysql.com/tech-resources/art ... -data.html ) which give you the decendants in one database call, and its a paint to recurse a tree with paret-id based relationships.

However, you sparked an idea in my mind that we can modify the view to do the children recursing, then have an option to specify how many levels deep and use the technique with the JOINs for Adjacency List on the page above, unfortunately you cannot just have it do unlimited traversing without a loop and multiple db queries which is not good. This would be a good menu based solution I guess, but I don't like relying on menu options. Perhaps it could be an option in the category settings to traverse down X number of levels.

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

More
16 years 1 month ago #3294 by Rooney

vlester wrote: In this module, you can display all the categories you want with their items, just their title or the full text.


The problem here is that you cannot display Flexicontent only fields...

Rooney

Joomla! 3.9.24 and FC 3.3.9

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

More
16 years 3 weeks ago #3599 by Rooney

WebDesignHero wrote: This would be a good menu based solution I guess, but I don't like relying on menu options. Perhaps it could be an option in the category settings to traverse down X number of levels.


Just checking. Have you found a solution for this?

Rooney

Joomla! 3.9.24 and FC 3.3.9

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

  • Anonymous
  • Visitor
  • Visitor
16 years 1 day ago #4246 by Anonymous
Replied by Anonymous on topic Category view - show items in subcategories
hacked together a function for this
Code:
function getItemsViaCategoryId($id){ global $mainframe, $option; $params = & $mainframe->getParams('com_flexicontent'); $user = & JFactory::getUser(); $db = & JFactory::getDBO(); $lang = JRequest::getWord('lang', '' ); $where = ' WHERE rel.catid = '.$id; // Second is to only select items the user has access to $states = '1, -5'; if ($user->authorize('com_flexicontent', 'state')) { $states .= ', 0 , -3, -4'; } $where .= ' AND i.state IN ('.$states.')'; $where .= ' AND i.sectionid = ' . FLEXI_SECTION; if (FLEXI_FISH) { $where .= ' AND ie.language LIKE ' . $db->Quote( $lang .'%' ); } $query = 'SELECT DISTINCT i.*, ie.*, u.name as author, ty.name AS typename,' . ' CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END as slug' . ' FROM #__content AS i' . ' LEFT JOIN #__flexicontent_items_ext AS ie ON ie.item_id = i.id' . ' LEFT JOIN #__flexicontent_types AS ty ON ie.type_id = ty.id' . ' LEFT JOIN #__flexicontent_cats_item_relations AS rel ON rel.itemid = i.id' . ' LEFT JOIN #__categories AS c ON c.id = '. $id . ' LEFT JOIN #__users AS u ON u.id = i.created_by' .$where; $db->setQuery( $query); $db->query(); $data = $db->loadObjectList(); $items = FlexicontentFields::getFields($data, 'category', $params); return $items; }

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

More
16 years 1 day ago #4254 by Rooney
Excellent. Could you briefly describe how to use it in a template?

Thanks in advance!
Rooney

Joomla! 3.9.24 and FC 3.3.9

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

  • Anonymous
  • Visitor
  • Visitor
16 years 9 hours ago #4299 by Anonymous
Replied by Anonymous on topic Category view - show items in subcategories
copy paste the entire code in categories.php
in the subcategories in the
Code:
foreach ($this->categories as $sub) :
loop you could for example
Code:
$items = getItemsViaCategoryId($sub->id); foreach ($items as $item) : //...now you can do your position magic endforeach;

you can use almost the entire code in the items section, to show items from the same category.
Code:
just replace the line $items = FlexicontentFields::getFields($data, 'categories', $params);
with
Code:
$items = FlexicontentFields::getFields($data, 'items', $params);

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