1
Sometimes it would be nice if every category could have it's own different templates. This is a quick and dirty solution. News module is taken as example. Open news/xoops_version.php in an editor and replace this code:
le="color: #000000"><?php // Templates $modversion['templates'][1]['file'] = 'news_archive.html'; $modversion['templates'][1]['description'] = ''; $modversion['templates'][2]['file'] = 'news_article.html'; $modversion['templates'][2]['description'] = ''; $modversion['templates'][3]['file'] = 'news_index.html'; $modversion['templates'][3]['description'] = ''; $modversion['templates'][4]['file'] = 'news_item.html'; $modversion['templates'][4]['description'] = '';
with this code:
le="color: #000000"><?php // Templates $modversion['templates'][1]['file'] = 'news_archive.html'; $modversion['templates'][1]['description'] = ''; $modversion['templates'][2]['file'] = 'news_article.html'; $modversion['templates'][2]['description'] = ''; $modversion['templates'][3]['file'] = 'news_index.html'; $modversion['templates'][3]['description'] = ''; $modversion['templates'][4]['file'] = 'news_item.html'; $modversion['templates'][4]['description'] = ''; $modversion['templates'][5]['file'] = 'news_article1.html'; $modversion['templates'][5]['description'] = 'Kat-ID 1'; global $xoopsDB; $i = 6; $result = $xoopsDB->query("SELECT topic_id FROM ".$xoopsDB->prefix("topics").""); while (list($topic_id) = $xoopsDB->fetchRow($result)) { $modversion['templates'][$i]['file'] = 'news_article'.$topic_id.'.html'; $modversion['templates'][$i]['description'] = 'Kat-ID '.$topic_id; $quelle = XOOPS_ROOT_PATH.'/modules/news/templates/news_article.html'; $ziel = XOOPS_ROOT_PATH.'/modules/news/templates/news_article'.$topic_id.'.html'; if ( !file_exists(XOOPS_ROOT_PATH.'/modules/news/templates/news_article'.$topic_id.'.html') ) { copy($quelle, $ziel); } $i++; }
Open news/article.php in an editor and delete following line:
le="color: #000000"><?php $xoopsOption['template_main'] = 'news_article.html';
Insert following line before including footer.php:
le="color: #000000"><?php $xoopsOption['template_main'] = 'news_article'.$article->topicid().'.html';
This it how it works: First you have to create categories in news, then you have to update the module. Then go to the Templates-Manager and generate the new templates. The original news_article.html is the source for the copies, so if you want to spare some time you can change this FILE.
Unfortunately news/templates must be writable.
I think my solution will work for any module working with categories.