Category view - show items in subcategories

More
14 years 9 months 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
14 years 8 months 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
14 years 8 months 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
14 years 8 months 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.

More
14 years 8 months ago #4302 by Rooney
Honestly, I am grateful, but do not really know where to change or add what... :roll:

Any chance that you would explain in a little bit more detail?

Thanks a lot
Rooney

Joomla! 3.9.24 and FC 3.3.9

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

More
14 years 8 months ago #4534 by ewel
Sounds interesting! Could you post a link to a demo page?

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

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