 
 
I want to list all categories of a certain category in the main_block but not to have them in the left block. The reason is that I have about 80 sucategories which I don't want in the menu where I use NAV_LIST_UL.
I found a solution, but I don't think it's the best one, so I decide to ask.
My solution is making the categories hidden and adding a new replacment tag called {NAV_LIST_ID_ALL:id}.
I use the following code:
- Code: Select all
- // {NAV_LIST_ID_ALL:id}
 if( ! ( strpos($content["all"],'{NAV_LIST_ID_ALL:')===false ) ) {
 $content["all"] = preg_replace('/\{NAV_LIST_ID_ALL:(.*?)\}/e', 'showCategoryContent("$1");', $content["all"]);
 }
and
/
- Code: Select all
- *
 * {NAV_LIST_ID_ALL}
 * thanks to Jens Zetterström who has initiated this in 2005
 * Shows all articles in a category without comparing acat_hidden.
 * use it {SHOW_CONTENT:id}
 * id is the corresponding ID
 */
 function showCategoryContent($param='') {
 $start_id = $param[0];
 if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
 $li_a .= '<a href="index.php?';
 if($GLOBALS['content']['struct'][$key]['acat_alias']) {
 $li_a .= $GLOBALS['content']['struct'][$key]['acat_alias'];
 } else {
 $li_a .= 'id='.$key.',0,0,1,0,0';
 }
 $li_a .= '"';
 } else {
 $redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
 $li_a .= '<a href="'.$redirect['link'].'"'.$redirect['target'];
 }
 $ul = "<ul>";
 foreach($GLOBALS['content']['struct'] as $key => $value) {
 if($GLOBALS['content']['struct'][$key]['acat_struct'] == $start_id)
 {
 $li_a = '';
 if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
 $li_a .= '<a href="index.php?';
 if($GLOBALS['content']['struct'][$key]['acat_alias']) {
 $li_a .= $GLOBALS['content']['struct'][$key]['acat_alias'];
 } else {
 $li_a .= 'id='.$key.',0,0,1,0,0';
 }
 $li_a .= '"';
 } else {
 $redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
 $li_a .= '<a href="'.$redirect['link'].'"'.$redirect['target'];
 }
 $li_title = $wrap_link_text[0];
 $li_title .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);
 $li_title .= $wrap_link_text[1];
 $li_a .= '>'.$li_title;
 $li = $TAB.' <li>'.$li_a.'</li>';
 $ul.= $li;
 }
 }
 $ul .= "</ul>";
 return $ul;
 }
Do you think it's a good solution and do you have another solution of the problem?

 by The_Brain on Fri May 11, 2007 17:07
by The_Brain on Fri May 11, 2007 17:07 
