I've set up a plugin to exclude tags and tiddlers from tag and
reference lists only when my site is in read-only mode and only then
if the tag or tiddler is tagged with a special Editor-Only Tag, which
indicates that that tag or tiddler is strictly backstage and should
not be visible to the casual visitor.

>From the visitor's standpoint, the plugin works great. It does what it
is supposed to do. However, when I am backstage myself and manually go
to a tiddler with the Editor-Only Tag, I'm getting a 'macro error' in
the tag list instead of a 'no tags' label.

Here's my plugin code:

//{{{

config.macros.tags.handler =
function(place,macroName,params,wikifier,paramString,tiddler)
{
        params = paramString.parseParams("anon",null,true,false,false);
        var ul = createTiddlyElement(place,"ul");
        var title = getParam(params,"anon","");
        if(title && store.tiddlerExists(title))
                tiddler = store.getTiddler(title);
        var sep = getParam(params,"sep"," ");
        var lingo = config.views.wikified.tag;
        var label = null;
        for(var t=0; t<tiddler.tags.length; t++) {
                var tag = store.getTiddler(tiddler.tags[t]);
                if(!tag || !tag.tags.contains("excludeLists")) {
                        if(!config.options.chkHttpReadOnly || !
tag.tags.contains(config.options.txtEditorOnlyTag)) {
                                if(!label)
                                        label =
createTiddlyElement(ul,"li",null,"listTitle",lingo.labelTags.format([tiddler.title]));
        
createTagButton(createTiddlyElement(ul,"li"),tiddler.tags[t],tiddler.title);
                                if(t<tiddler.tags.length-1)
                                        createTiddlyText(ul,sep);
                        }
                }
        }
        if(!label)
        
createTiddlyElement(ul,"li",null,"listTitle",lingo.labelNoTags.format([tiddler.title]));
};

//}}}

The only thing I did to change it from the main tags handler was to
add this conditional mid-way down:
{{{if(!config.options.chkHttpReadOnly || !
tag.tags.contains(config.options.txtEditorOnlyTag)) }}}

(I'm currently using excludeSearch as txtEditorOnlyTag since
excludeSearch does a number of viewer/editor segregation chores for me
already.)

The conditional I'm trying to understand is {{{ if(!tag || !
tag.tags.contains("excludeLists")) }}}
It comes right after {{{ var tag =
store.getTiddler(tiddler.tags[t]); }}}

Why is !tag in there as the first part of the OR formula? It looks
like it will never evaluate to true if there's a value for tag. It
will evaluate to true if tag is empty, but that would mean we've gone
through the entire tag list and are trying to keep going even though
we're inside of a for loop based on the length of that tag list,
right?

So why is that conditional an OR formula with !tag as one of the
components?

Sorry if I'm being completely daft.

Thanks,

Scott

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to