flexicontent sitemap

More
12 years 2 weeks ago #24550 by Amélie33
Replied by Amélie33 on topic flexicontent sitemap
I coded it from scrtach. It may not be the most beautiful code but I can modify and adapt it as I need.

To (maybe) help someone else :
Code:
########################################## plan du site $db =& JFactory::getDBO(); $where[] = 'published = 1'; $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); $query = 'SELECT *, id AS value, title AS text' .' FROM #__categories' .$where .' ORDER BY parent_id, ordering' ; $db->setQuery($query); $rows = $db->loadObjectList(); //set depth limit $levellimit = 10; //get children $children = array(); foreach ($rows as $child) { $parent = $child->parent_id; $list = @$children[$parent] ? $children[$parent] : array(); array_push($list, $child); $children[$parent] = $list; } //get list of the items $lists = flexicontent_cats::treerecurse(0, '', array(), $children, true, max(0, $levellimit-1)); $exparentid = 'no'; $exid = '0'; $enfants = array(); $parents = array(); foreach( $lists as $list ){ if(!isset($enfants[$list->parent_id])) $enfants[$list->parent_id] = array(); $enfants[$list->parent_id][] = $list->id; $parents[$list->id] = $list->parent_id; } foreach( $lists as $list ){ if($list->parent_id != $exparentid){ if($list->parent_id == $exid){ echo '<ul>'; }else{ $fin = false; $exid2 = $parents[$exid]; while ($fin == false){ echo '</li></ul></li>'; if($parents[$exid2] == $list->parent_id){ $fin = true; }else{ $exid2 = $parents[$exid2]; } } } $exparentid = $list->parent_id; }else{ echo '</li>'; } $catlink = JRoute::_(FlexicontentHelperRoute::getCategoryRoute($list->id,$list->id)); echo '<li>[url='.$catlink.'" title="'.$list->title.']'.$list->title.'[/url]'; $query = 'SELECT a.introtext as texte, a.title as title, a.id as artid, a.catid as catid '. 'FROM #__content AS a '. 'JOIN #__flexicontent_cats_item_relations AS cir ON a.id = cir.itemid '. 'WHERE a.catid = '.$list->id.' '. 'ORDER BY cir.ordering'; $db->setQuery($query); $rows = $db->loadObjectList(); if(count($rows) > 0) { echo '<ul>'; foreach ($rows as $row) { $catlink = JRoute::_(FlexicontentHelperRoute::getItemRoute($row->artid, $row->catid)); echo '<li>[url='.$catlink.'" title="]'.$row->title.'[/url]</li>'; } echo '</ul>'; } $exid = $list->id; }

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

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