On 8/13/2009 9:27 AM, Michael Fake wrote:
Hello everyone,

I'd like to be able to set up a simple tagging system, whereby on each page you can add a tag which acts as a direct link to another page. E.g. You could tag the page 'Main/Daschund' with the 'Dogs' tag, and clicking on that link would take you to Main/Dogs. I'd then like to have the option to list, in Main/Dog, all those pages that have the 'Dogs' tag. This seems to be how tags in the ever-useful TiddlyWiki <http://www.tiddlywiki.com/> work, and I'd like a similar navigation option in pmwiki.
In your config.php:
$CategoryGroup = 'Main';

In Main.GroupFooter:
(:pagelist link=Main/Dogs:)

The stuff that follows this point might surprise you with how much closer PmWiki can get to Tiddlywiki.

-----

I suggest you download and install the EditAttributes recipe like this:

First, copy editattr.php into your cookbook.

In you config.php:
$EditAttrFields = array(
    'title' => array(
        'attribute' => 1,
        'markup' => '(:title $1:)',
        'filter' => 'EditAttrAutofillTitle'
    ),
 'tags' => array(
        'attribute' => 1,
        'markup' => '(:tags:$1:)',
        'filter' => 'EditAttrFormatTags'
    )
);

# Format Tags
function EditAttrFormatTags( $pagename, $fn, &$new ) {
    global $CategoryGroup;

    $EaCleanArray = array('[',']','!',
        'Category:',"$CategoryGroup:",
        'Category/',"$CategoryGroup/",
        'Category.',"$CategoryGroup."
    );

    $EaMatches = $new['tags'];
$EaMatchesArray = explode(',',str_ireplace($EaCleanArray,'',$EaMatches));

    Foreach($EaMatchesArray as $EaM) {
        $EaM = trim($EaM);

        if($EaM == '')
            $EaFixed .= '';
        elseif(strstr($EaM,'/') === FALSE && strstr($EaM,'.') === FALSE)
            $EaFixed .= '[[!'.$EaM.']], ';
        else
            $EaFixed .= '[['.$EaM.']], ';
    }

    $new['tags'] = substr($EaFixed,0,-2);
}

include_once($FarmD.'/cookbook/editattr.php');

Finally, edit Site.EditForm. Just copy and replace:
!!Editing {*$FullName}
(:messages:)
<div id='wikiedit'>
(:input e_form:)
[[#top]]
<table style="width:100%;">
<tr><td style="text-align:right;">Title:</td><td>(:input e_title:)</td><td style="text-align:right;">Tags:</td><td>(:input e_tags:)</td></tr>
<tr><td colspan="4">(:input e_textarea:)</td></tr>
<tr><td colspan="4">(:input e_savebutton:)(:input e_savedraftbutton:)(:input e_saveeditbutton:)(:input e_previewbutton:)(:input e_cancelbutton:)</td></tr>
</table>
(:input end:)
</div>
(:if e_preview:)
!!Preview {*$FullName}
'''$[Page is unsaved]'''
(:e_preview:)
<hr />
[[#top|Top]]
(:ifend:)

----

Now, all you have to do is fill the Tags box with a comma separated list of tags:
Dogs, Friendly Dogs, Dogs with all their Teeth
And you can even link outside your CategoryGroup like this:
Pictures/Dogs, Stories.Dogs, Wolves.That look like Dogs

You might also install the AutoSave and GetRidOfMain recipes for some added functionality.

Michael Continues
_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to