Division between Pages and categories in a Category

Working for 1.3.6 (latest)
03/31/2016:version 2.1 (see below).

this version builds on the beta-version from JavaWoman (running on this wiki) and has in total the following cchanges to the official action:


Todo:


Explanations

The new search-method uses two queries instead of one: one search for subcategories (searching for the category-action) and another for pages (searching for the new link version) belonging to a category (they only load the name, since we know from the search if its a category or not).

This allows any page to become a category, their names don't have to start with "Category" anymore. For this reason, i took the "forcecat" param out (if you put the action, for example, on the SandBox without "categorylinking" any page it will simply show that nothing could be found).


Comments?


Installation


Three things have to be changed:

1. addition to formatters/wakka.php

right before
                // forced links
                // \S : any character that is not a whitespace character
                // \s : any whitespace character


add the following:
                //links to category pages
                else if (preg_match("/^\[\[\(cat\)(\S+)(\s(.+))*\]\]$/si", $thing, $matches))
                {
                        list(, $categorylink, $text) = $matches;
                        if ($categorylink)
                        {
                            return $result.$wakka->Link($categorylink, "", $text);
                        }
                        else
                        {
                            return "";
                        }
                }


2. library/common/showarray.php

The following file has to be saved as library/common/showarray.php:
  1. <?php
  2. /**
  3.  * Sorts a given array in a given number of columns.
  4.  *
  5.  * @package     Library
  6.  * @subpackage  Common
  7.  * @name        ShowArray
  8.  *
  9.  * @author      {@link http://wikka.jsnx.com/JavaWoman JavaWoman} (table-less columns)
  10.  * @author      {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (function and "divison" of the array)
  11.  * @copyright   Copyright © 2004,
  12.  * @license     http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  13.  * @since       Wikka 1.0.0
  14.  *
  15.  * @input       array       $array  necessary: the data to be shown
  16.  * @input       integer $colnumber  optional: number of colums; default: 0.
  17.  * @input       string  $class  optional: class(es) to determine styling of the output list of table; default: none.
  18.  * @output      list of data from an array, formatted as in columns
  19.  *
  20.  * @todo        - possible? use a single list also for columns, using CSS to visually split up into columns - JW 2005-01-19
  21.  */
  22.  
  23. function ShowArrayInColumns($array, $colnumber=1, $class="")
  24. {
  25.     $str = "";
  26.     if (is_array($array))
  27.     {
  28.         $entries = count($array);
  29.         $width = (int) (100 / $colnumber);
  30.         $lines = 0;
  31.         $a = 0;
  32.        
  33.         $str .= '<div'.$class.'>'."\n";
  34.                
  35.         //how many lines with an entry in every column do we have?
  36.         while ($entries / $colnumber > 1)
  37.         {
  38.             $lines++;
  39.             $entries = $entries - $colnumber;
  40.         }
  41.        
  42.         //prepare output
  43.         for ($i=0;$i<$colnumber;$i++)
  44.         {
  45.             $str .='    <div style="width: '.$width.'%; float: left;">'."\n";
  46.             for ($j=0;$j<$lines;$j++)
  47.             {
  48.                 $str .= '       '.$array[$a].'<br />'."\n";
  49.                 $a++;  
  50.             }
  51.            
  52.             //the rest of the entries (less then the number of cols)
  53.             if ($entries)
  54.             {
  55.                 $str .= '       '.$array[$a].'<br />'."\n";
  56.                 $entries--;
  57.                 $a++;  
  58.             }
  59.             $str .="    </div>\n";
  60.    
  61.         }
  62.         $str .= '</div><br  style="clear: both;">'."\n";
  63.         return ($str);
  64.     }
  65.     $str .= 'The data delivered to the function ShowArrayInColumns was no array.';
  66.     return ($str);
  67. }  
  68.  
  69. /**
  70.  * Sorts a given array as a list.
  71.  *
  72.  * @package     Library
  73.  * @subpackage  Common
  74.  * @name        ShowArray
  75.  *
  76.  * @author      {@link http://wikka.jsnx.com/JsnX JsnX} (list)
  77.  * @author      {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (function and "divison" of the array)
  78.  * @copyright   Copyright © 2004,
  79.  * @license     http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  80.  * @since       Wikka 1.0.0
  81.  *
  82.  * @input       array       $array  necessary: the data to be shown
  83.  * @input       string  $class  optional: class(es) to determine styling of the output list of table; default: none.
  84.  * @output      list of data from an array, formatted as a list
  85.  *
  86.  */
  87.  
  88. function ShowArrayAsList($array,$class="")
  89. {
  90.     $str = "";
  91.     if (is_array($array))
  92.     {
  93.         $entries = count($array);
  94.         $str .= '<div'.$class.'>'."\n";
  95.         $str .= "<ul>\n";
  96.         for ($i=0;$i<$entries;$i++)
  97.         {
  98.             $str .= '   <li>'.$array[$i].'</li>';
  99.         }
  100.         $str .= "</ul>\n</div>\n";
  101.         return ($str);
  102.     }
  103.     $str .= "The data delivered to the function ShowArrayAsList was no array.";
  104.     return ($str);
  105. }
  106. ?>



3. Plugin this in plugins/actions/category/category.php
<?php
/**
 * Shows the pages and subcategories belonging to a category.
 *
 * See WikiCategory to understand how the system works.
 *
 * @package     Actions
 * @version     $Id$
 *
 * @input   string $page optional: the category for which you want to display the pages and categories. Default: current page
 * @input   integer $compact optional: 0 produces a columnar layout with a layout table; 1 produces output in the form of an unordered list. Default: 0
 * @input   integer $col optional: number of columns (for compact=0). Default: 1
 * @output  A html table with pages
 * @uses    Wakka::GetPageTag();
 * @uses    Wakka::ListPages()
 * @uses    Wakka::LoadPagesLinkingTo()
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @filesource
 */


//including the needed functions
require_once 'libs/showarray.php'; #the two functions showing the output in a list/ in columns

# 'col' option
$col = 1;
if(isset($vars['col']))
    $col = $this->htmlspecialchars_ent($vars['col']);

# 'compact' option
$compact = 0;
if(isset($vars['compact']))
    $compact = $this->htmlspecialchars_ent($vars['compact']);

# 'class' option
$class = 0;
if(isset($vars['class']))
    $class = $this->htmlspecialchars_ent($vars['class']);

# 'sort' option
$sort = 'ASC';
if(isset($vars['sort']))
{
    $val_sort = strtoupper($this->htmlspecialchars_ent($vars['sort']));
    if(in_array($val_sort, ['ASC','DESC'])) $sort = $val_sort;
}

# 'inctpl' option
$inctpl = FALSE;
if(isset($vars['inctpl']))
    $inctpl = TRUE;

# 'show' option
$show = 'all';
if(isset($vars['all']))
{
    $val_show = $this->htmlspecialchars_ent($vars['class']);
    if(in_array($val_show, ['all','pages','categories'])) $show = $val_show;
}

# 'page' option
if(isset($vars['page']))
    $page = $this->htmlspecialchars_ent($vars['page']);
else
{
    #232 : if page is not given, and if this action is called from an included page, use the name of the page that is included
    #  and not the caller's PageTag.
    if (isset($this->config['includes']) && is_array($this->GetConfigValue('includes')))
    {
        $count = count($this->GetConfigValue('includes')) - 1;
        $page = $this->config['includes'][$count];
        echo $page.":"; print_r($this->config['includes']);
    }
    else
    {
        $page=$this->GetPageTag();
    }
}
if ($page=="/") $page="CategoryCategory";

if (!$inctpl && preg_match('/Template$/',$page))
{
    if (!preg_match('/^Category/',$page)) $page = 'CategoryCategory';   # exception for a category that contains templates
}

//searching for categories belonging to the requested category, if necessary, and preparing the output
if ($show == 'all' || $show == 'categories')
{
    $categorySearchphrase = "
        SELECT tag AS page_tag
        FROM "
.$this->GetConfigValue('table_prefix')."links
        INNER JOIN "
.$this->GetConfigValue('table_prefix')."pages
            ON from_tag = tag
            AND latest = 'Y'
            AND body LIKE '%[[(cat)"
.$page."]]%'
            AND body LIKE '%{{category%'
        GROUP BY tag
        ORDER BY tag "
.strtoupper($sort);
    $results = $this->LoadAll($categorySearchphrase);

    // filter what we show AS content of the requested category
    if($keys = array_keys(array_column($results, 'page_tag'), ['CategoryCategory', $page]))
        foreach($keys as $key) unset($results[$key]);

    $errmsg = '<em>'.sprintf(T_("No categories found for %s"), $page).'</em>';
    $list_pages_option = array(
            'nopagesText' => $errmsg,
            'class' => $class,
            'columns' => $col,
            'sort' => 'no',
            'compact' => $compact
            );
    $str = $this->ListPages($results, $list_pages_option);
    print($this->Format(T_("=====Categories=====")));
    if ($str != $errmsg)
    {
        if(1 < count($results))
            printf(T_("The following %d categories belong to %s").'<br /><br />', count($results), $page);
        else
            printf(T_("The following category belongs to %s").'<br /><br />', $page);
    }
    print($str);
}
//if necessary, a division between the categories and the pages
if ($show == 'all') print('<br /><br />');
if ($show == 'all' || $show == 'categories')
{
    $categorySearchphrase = "
        SELECT tag AS page_tag
        FROM "
.$this->GetConfigValue('table_prefix')."links
        INNER JOIN "
.$this->GetConfigValue('table_prefix')."pages
            ON from_tag = tag
            AND latest = 'Y'
            AND body LIKE '%[[(cat)"
.$page."]]%'
            AND body NOT LIKE '%{{category%'
        GROUP BY tag
        ORDER BY tag "
.strtoupper($sort);
    $results = $this->LoadAll($categorySearchphrase);

    // filter what we show AS content of the requested category
    if($keys = array_keys(array_column($results, 'page_tag'), ['CategoryCategory', $page]))
        foreach($keys as $key) unset($results[$key]);

    $errmsg = '<em>'.sprintf(T_("No pages found for %s"), $page).'</em>';
    $list_pages_option = array(
            'nopagesText' => $errmsg,
            'class' => $class,
            'columns' => $col,
            'sort' => 'no',
            'compact' => $compact
            );
    $str = $this->ListPages($results, $list_pages_option);
    print($this->Format(T_("=====Pages=====")));
    if ($str != $errmsg)
    {
        if(1 < count($results))
            printf(T_("The following %d pages belong to %s").'<br /><br />', count($results), $page);
        else
            printf(T_("The following page belongs to %s").'<br /><br />', $page);
    }
    print($str);
}
?>


Older Versions

Working for 1.1.6.0 to 1.1.6.4 (latest)
04/04/2005:version 2.0 (see below).

Installation


Three things have to be changed:

1. addition to formatters/wakka.php

right before
                // forced links
                // \S : any character that is not a whitespace character
                // \s : any whitespace character


add the following:
                //links to category pages
                else if (preg_match("/^\[\[\(cat\)(\S+)(\s(.+))*\]\]$/si", $thing, $matches))
                {
                        list(, $categorylink, $text) = $matches;
                        if ($categorylink)
                        {
                            if (!$help) $help = $categorylink;
                            return $result.$wakka->Link($categorylink, "", $text);
                        }
                        else
                        {
                            return "";
                        }
                }


2. library/common/showarray.php

The following file has to be saved as library/common/showarray.php:
  1. <?php
  2. /**
  3.  * Sorts a given array in a given number of columns.
  4.  *
  5.  * @package     Library
  6.  * @subpackage  Common
  7.  * @name        ShowArray
  8.  *
  9.  * @author      {@link http://wikka.jsnx.com/JavaWoman JavaWoman} (table-less columns)
  10.  * @author      {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (function and "divison" of the array)
  11.  * @copyright   Copyright © 2004,
  12.  * @license     http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  13.  * @since       Wikka 1.0.0
  14.  *
  15.  * @input       array       $array  necessary: the data to be shown
  16.  * @input       integer $colnumber  optional: number of colums; default: 0.
  17.  * @input       string  $class  optional: class(es) to determine styling of the output list of table; default: none.
  18.  * @output      list of data from an array, formatted as in columns
  19.  *
  20.  * @todo        - possible? use a single list also for columns, using CSS to visually split up into columns - JW 2005-01-19
  21.  */
  22.  
  23. function ShowArrayInColumns($array, $colnumber=1, $class="")
  24. {
  25.     $str = "";
  26.     if (is_array($array))
  27.     {
  28.         $entries = count($array);
  29.         $width = (int) (100 / $colnumber);
  30.         $lines = 0;
  31.         $a = 0;
  32.        
  33.         $str .= '<div'.$class.'>'."\n";
  34.                
  35.         //how many lines with an entry in every column do we have?
  36.         while ($entries / $colnumber > 1)
  37.         {
  38.             $lines++;
  39.             $entries = $entries - $colnumber;
  40.         }
  41.        
  42.         //prepare output
  43.         for ($i=0;$i<$colnumber;$i++)
  44.         {
  45.             $str .='    <div style="width: '.$width.'%; float: left;">'."\n";
  46.             for ($j=0;$j<$lines;$j++)
  47.             {
  48.                 $str .= '       '.$array[$a].'<br />'."\n";
  49.                 $a++;  
  50.             }
  51.            
  52.             //the rest of the entries (less then the number of cols)
  53.             if ($entries)
  54.             {
  55.                 $str .= '       '.$array[$a].'<br />'."\n";
  56.                 $entries--;
  57.                 $a++;  
  58.             }
  59.             $str .="    </div>\n";
  60.    
  61.         }
  62.         $str .= '</div><br  style="clear: both;">'."\n";
  63.         return ($str);
  64.     }
  65.     $str .= 'The data delivered to the function ShowArrayInColumns was no array.';
  66.     return ($str);
  67. }  
  68.  
  69. /**
  70.  * Sorts a given array as a list.
  71.  *
  72.  * @package     Library
  73.  * @subpackage  Common
  74.  * @name        ShowArray
  75.  *
  76.  * @author      {@link http://wikka.jsnx.com/JsnX JsnX} (list)
  77.  * @author      {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (function and "divison" of the array)
  78.  * @copyright   Copyright © 2004,
  79.  * @license     http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  80.  * @since       Wikka 1.0.0
  81.  *
  82.  * @input       array       $array  necessary: the data to be shown
  83.  * @input       string  $class  optional: class(es) to determine styling of the output list of table; default: none.
  84.  * @output      list of data from an array, formatted as a list
  85.  *
  86.  */
  87.  
  88. function ShowArrayAsList($array,$class="")
  89. {
  90.     $str = "";
  91.     if (is_array($array))
  92.     {
  93.         $entries = count($array);
  94.         $str .= '<div'.$class.'>'."\n";
  95.         $str .= "<ul>\n";
  96.         for ($i=0;$i<$entries;$i++)
  97.         {
  98.             $str .= '   <li>'.$array[$i].'</li>';
  99.         }
  100.         $str .= "</ul>\n</div>\n";
  101.         return ($str);
  102.     }
  103.     $str .= "The data delivered to the function ShowArrayAsList was no array.";
  104.     return ($str);
  105. }
  106. ?>


3. Replacement of actions/category.php

<?php
/**
 * Generates a list of pages belonging to the specified or top-level category.
 *
 * If no category page is specified, the current page is assumed to be a category.
 *
 * Template pages (page name ending with 'Template') may contain category names; they are filtered
 * out automatically unless 'inctpl' is set to 1. One exception: pagenames that start with
 * 'Category' and end with 'Template' are considered a proper category so templates can themselves
 * be categorized.
 *
 * Note: the list view ('compact' = 1) is nice for a sidebar while the columnar view
 * ('compact' = 0) is more suited for a category page.
 *
 * Syntax:
 * {{category [inctpl="0|1"] [page="categoryname"] [col="n"] [compact="0|1"] [class="class"] [show="pages|categories|all"]}}
 *
 * @package      Actions
 * @subpackage   SystemContent
 * @name             Category
 *
 * @author       {@link http://wikka.jsnx.com/JsnX JsnX}
 * @author       {@link http://wikka.jsnx.com/JavaWoman JavaWoman} (rewrite with filtering and table-less columns)
 * @author       {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (seperation of categories, functions for output)
 * @copyright    Copyright © 2004, Jason Tourtelotte
 * @license      http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @since        Wikka 1.0.0
 * @version      2.0
 *
 * @input           integer    $inctpl   optional: include "template" pages (1) or not (0); default: 0.
 * @input           integer    $page     optional: category to list members of; default: current page or CategoryCategory
 * @input           integer    $col      optional: number of columns for table; default: 1
 * @input           integer    $compact  optional: use table (0) or list (1); default: 0
 * @input           integer    $class    optional: class(es) to determine styling of the output list of table
 * @input           string     $show     optional: show "pages" "categories" or "all"; default: all
 * @output          list of categories and/or pages belonging to the specified or top-level category,
 *               formatted as a list or in columns
 *
 * @uses        LoadAll()
 * @uses        Link()
 * @todo        - possible? use a single list also for columns, using CSS to visually split up into columns - JW 2005-01-19
 */


//including the needed functions
require_once 'library/common/showarray.php'; #the two functions showing the output in a list/ in columns

// set defaults
$lIncTpl    = FALSE;            # do not show template pages or treat a template as a category
$lPage    = $this->tag;        # current page is default category
$lCol        = 1;                # one column for table
$lCompact    = FALSE;            # use table, not list
$lClass    = '';                # no class
$lShow    = 'all';            # show pages and categories
$lOutput = '';                 # the final output

// get parameters
if (is_array($vars))
{
    foreach ($vars as $param => $value)
    {
        switch ($param)
        {
            case 'inctpl':
                if ($value) $lIncTpl = TRUE;
                break;
            case 'page':
                if ($this->existsPage($value)) $lPage = $value;
                break;
            case 'col':
                if ($value === (string)(int)$value && (int)$value > 0) $lCol = (int)$value;
                break;
            case 'compact':
                if ($value) $lCompact = TRUE;
                break;
            case 'class':
                if ('' != $value) $lClass = $value;
                break;
            case 'show':
                if ($value == 'pages' || $value == 'categories') $lShow = $value;
                break;
        }
    }
}

// filter WHICH category we (may) show the content OF
if ($lPage == '/')
{
    $lPage = 'CategoryCategory';
}
if (!$lIncTpl && preg_match('/Template$/',$lPage))
{
    if (!preg_match('/^Category/',$lPage)) $lPage = 'CategoryCategory';    # exception for a category that contains templates
}

//searching for categories belonging to the requested category, if necessary, and preparing the output
if ($lShow == 'all' || $lShow == 'categories')
{
    $lCategorySearchphrase = "SELECT tag FROM ".$this->config['table_prefix']."pages WHERE latest = 'Y' AND body LIKE '%[[(cat)".$lPage."%' AND body LIKE '%{{category%'";
    $categoryresults = $this->LoadAll($lCategorySearchphrase);
    //print_r($categoryresults); //DEBUG
    if ($categoryresults)
    {
         $categorylist = array();

         // filter what we show AS content of the requested category
         foreach ($categoryresults as $ccategory)
         {
             // do not list top-level category as member
             if ('CategoryCategory' == $ccategory['tag'])
             {
                 continue;
             }
             // do not list requested category as member
             if ($ccategory['tag'] == $lPage)
             {
                 continue;
             }

             // we have a valid result: add to the list
             if ($lCompact)
             {
                 $categorylist[] = $this->Link($ccategory['tag'],'',preg_replace( "/Category/", "",$ccategory['tag']));
             }
             else
             {
                 $categorylist[] = $this->Link($ccategory['tag'],'',preg_replace( "/Category/", "",$ccategory['tag']));
             }
         }
         sort($categorylist);

         // make simple list (useful for sidebar)
         if ($lCompact)
         {
             $lOutput .= ShowArrayAsList($categorylist,$lClass);
         }
         // make columnar overview (useful for category pages)
         else
         {
             $categorycount = count($categorylist);
             $lOutput .= 'The following '.$categorycount.' categories belong to '.$lPage.':<br /><br />'."\n"; #i18n
             $lOutput .= ShowArrayInColumns($categorylist, $lCol, $lClass);
         }
    }
    else
    {
        $lOutput .= 'No categories found for '.$lPage.".\n"; #i18n
    }
}

//if necessary, a division between the categories and the pages
if ($lShow == 'all') $lOutput .= '<br /><br />';

//searching for pages belonging to the requested category, if necessary, and preparing the output
if ($lShow == 'all' || $lShow == 'pages')
{
    $lPageSearchphrase = "SELECT tag FROM ".$this->config['table_prefix']."pages WHERE latest = 'Y' and body LIKE '%[[(cat)".$lPage."%' AND body NOT LIKE '%{{category%'";
    $pageresults = $this->LoadAll($lPageSearchphrase);
    //print_r($pageresults); //DEBUG
    if ($pageresults)
    {
         $pagelist = array();

         // filter what we show AS content of the requested category
         foreach ($pageresults as $cpage)
         {
             // do not list requested category as member
             if ($cpage['tag'] == $lPage)
             {
                 continue;
             }
             // unless inctpl is set, do not list template pages
             elseif (!$lIncTpl && preg_match('/Template$/', $cpage['tag']))
             {
                          continue;
             }

             // we have a valid result: add to the list
             if ($lCompact)
             {
                 $pagelist[] = $this->Link($cpage['tag'],'',$cpage['tag']);
             }
             else
             {
                 $pagelist[] = $this->Link($cpage['tag']);
             }
         }
         sort($pagelist);

         // make simple list (useful for sidebar)
         if ($lCompact)
         {
             $lOutput .= ShowArrayAsList($pagelist,$lClass);
         }
         // make columnar overview (useful for category pages)
         else
         {
             $pagecount = count($pagelist);
             $lOutput .= 'The following '.$pagecount.' pages belong to '.$lPage.':<br /><br />'."\n"; #i18n
             $lOutput .= ShowArrayInColumns($pagelist, $lCol, $lClass);
         }
    }
    else
    {
        $lOutput .= 'No pages found for '.$lPage.".\n"; #i18n
    }
}

echo $lOutput;
?>



CategoryDevelopmentActions
Comments
Comment by JavaWoman
2005-02-22 15:31:17
Nils, Nice idea!

However, your code doesn't seem to take advantage of my new improved category action (running as a beta feature on this site now). Although it still needs a little refinement, it would probably be better if you started with that code, instead of the current "official" one. It no longer uses a table for display and vertically-arranged columns instead of a horizontal layout that's harder to scan (amongst other improvements to do with filtering).
Comment by NilsLindenberg
2005-02-23 11:48:54
Haven't found the code :)
It is miles away from a perfect code, just a little draft.
Comment by JavaWoman
2005-02-23 11:53:35
Nils, I thought you as Admin had FTP access?
If not, I can email you the code.
Comment by NilsLindenberg
2005-02-23 11:57:48
Not yet. But you know my email.
Comment by MovieLady
2005-02-26 08:33:08
Marvelous, Nils, thanks.

Mini-bug (not sure what to call it) I noticed while adding/adapting it for my site tonight: when there are only four subcategories or pages, if I have {{category show="3"}}, it displays them in two columns of two (2-2-0), not 2-1-1. It works fine with more or less than four pages or subcategories, but not exactly on four. (Example: http://directorium.org/CategoryHost - I removed the "sorry, there are no categories..." message, so that's why you don't see it on that page, just fyi.)
Comment by DarTar
2005-02-26 13:06:51
Nice work Nils
Comment by JavaWoman
2005-02-27 14:22:59
MovieLady,
The columns problem is probably my fault (Nils used that part of my code); I'll have to re-evaluate how I "calculate" the columns. (I'd call it a "buglet". :)) Thanks for the report.
Comment by JavaWoman
2005-02-27 14:26:45
@Nils,
There are now two code blocks with the same algorithm, one for displaying categories, and another for displaying page; it would be better to separate them into a function (see WikkaCodeStructure for where it should be put!) - which could then also be used for a better version of the backlinks action(!)
That said, it looks like it does the job nicely. :) Add yourself as Author to the docblock!
Comment by NilsLindenberg
2005-02-28 15:04:00
@Movielady: if you find the time, please try out the new version and see if the problem is fixed.

@JavaWomen: the first function is there, but in the action at the moment and not documented.
Comment by NiehLe
2005-02-28 16:42:20
Update: the list is done by a function, too.

one thing:
What (would that line do?)
//$classattr = ('' != $class) ? ' class="linklist '.$class.'"' : ' class="linklist"';
Comment by MovieLady
2005-03-01 04:10:59
Yep, it's splitting them correctly (2-1-1) now. Thanks! :)
Comment by FishPete
2006-06-01 08:44:18
Hi!
I encountered the following "problem" after installing this plugin.
there is a page called "WikiCategory" explaining the concept of categories, belonging to the category CategoryWiki

1) {{category page="/"}} doesn't seem to work anymore, so I wrote page="CategoryCategory" instead.

2) The page WikiCategory appears on CategoryWiki as a subcategory (not page) of CategoryWiki, only displaying "Wiki" as name
Firstly, WikiCategory is no category, it only displays another category.
secondly without looking at the url itself, there is no way to decide wether Wiki points to CategoryWiki or WikiCategory.

Maybe one could exclude pages containing {{category page="xyz"}} from beeing regarded as a category?
Or only pages containing a {{category}} action without the page parameter are considered to be categories (thus categories which additionally display another category would rightly be regarded as categories)

Regards,
Fischi
Comment by MasinAlDujaili
2006-11-03 17:37:27
Is there any simple way to convert the old categories to the new syntax? Something like a script that walks through all pages and changes occurences of old category references to new category references?
Comment by DaC
2007-01-09 13:34:37
Any chances that will be added as a standard behaviour of WikkaWiki?

I like the separation between Pages and Categories as it helps to clarify the structure of the Wiki but it is quite an effort to change all Categories from {{category}} to [[(cat)CatName]] in an existant system respectively rewriting the help section.
Comment by DarTar
2007-01-10 06:27:24
this is not scheduled for 1.1.7 but I agree it's an interesting (and apparently popular) enhancement. A ticket should be opened in the tracker (if it doesn't exist yet) and maybe Nils—as author of the code—could take care of that?
Comment by MasinAlDujaili
2007-01-10 07:53:26
As I asked above: Does any script exist to update category links? Or: Should I try myself at it? This could be the beginning of an admin tool box -- if you hadn't started it already ;-)
Comment by DarTar
2007-01-10 12:44:25
Hi Masin, there's no script at the moment to do this for all pages in the DB, you could run a search and replace SQL on your DB (possibly restricted at fresh content, i.e. the latest versions of each page) but be careful (and back up everything!) because this could seriously screw up your Wikka tables ;)

See for example: http://www.zimmertech.com/tutorials/php/60/mysql-search-replace-phpmyadmin.php
Comment by MasinAlDujaili
2007-01-10 13:01:56
As currently, every category link is counted as 'belongs to this category' wouldn't it be sufficient to
~-replace any link to a CategoryName not enclosed by [[ and ]] by a link to a [[CategoryName]] and afterwards
~-replace all links to a [[CategoryName]] by [[(cat)CategoryName]] and maybe additionally
~-clone all CategoryName to Name, if Name does not exist and replace all references accordingly

At least this last step cannot be done by simple search and replace SQL stuff, I guess.

Furthermore, as this question will be asked more then once, should this extension be used as default, I'll try to set something up to automatize this process.
Comment by DarTar
2007-01-10 13:50:51
right, this a bit tricky, and I confess I'd refrain from making major syntax changes if I wanted to keep my DB content compatible with the main Wikka development branch.

Mahefa (DotMG) has also worked on optimization of category links so maybe he has something to add in here.
Comment by DaC
2007-01-12 08:47:41
Opening a ticket would be great - I really like the new system and gives a better overview of the structure of the Wiki!

Thanks!

P.S.: MySQL replace did work for me as I only had a few pages. The few bugs which resulted could be resolved manually.
Comment by WillyPs
2007-11-12 21:35:52
Under explanations, it says the word category is required in front of a page name to make it a category page. Not true! Or, am I missing something?
Comment by NilsLindenberg
2007-11-20 18:47:20
"their names ___don't___ have to start with "Category" anymore" <- yes you have missed something :D But otherwise you are right
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki