The easy Weblog and Wiki Software
[ start | index | login ]
start > label-search

label-search

Created by dave. Last edited by doll, 3 years and 42 days ago. Viewed 1,583 times. #15
[diff] [history] [edit] [rdf]
labels
Category:snipsnap-documentation
attachments
snipsnap-help says of the {label-search} macro,

MacroDescriptionParameters
label-searchtype: Lister to render found snips (AtoZ, Vertical, Simple)
name: Name of a Label to search for
value: Value of the label too look for
Show all snips that have a certain label.

You need to provide the named parameters name and value describing the label you want to search for snips with. The parameter type defines the ListFormatter used to format the result, like Vertical, Simple, AtoZ.

One way to find out what values you need to give for name and value; visit a snip that has the label you want to search for, and follow the [add label] link. A table on the first [add label] page lists the name and value for all the snip's existing labels.

Example

Give some snips a label, for example a Category label Customers. Now, use the label-search macro to retrive these...

{label-search:type=Vertical|name=Category|value=Customers}

Note that if you don't have the option to give snips the label Customers, you can add the option like this:

  1. Create a new snip called Customers
  2. Add a 'TypeLabel' to the snip and choose the 'Category' type
  3. Customers should now be in the list of categories when you add a CategoryLabel
Adding a {label-search} like the example above to your new Customers snip would now be a cunning plan.

Icon-Comment dave, 4 years and 144 days ago. Icon-Permalink

So how do I make it work? This is what I've tried...

{label-search:Customers} produces:
label-search: Number of arguments does not match

{label-search:Category|Customers} produces:
snips with category: (0)
none found.

Icon-Comment petef, 4 years and 141 days ago. Icon-Permalink

OK I too can't get this to work. Having created a snip called help and added a Type label of Category to it and successfully added a Category label of Help to another snip {label-search:Category|Help} still gives

snips with category: (0)
none found.

I've tried all sixteen possible combinations of | or = as a separator and C or c for category and H or h for help and " or no quotes around help - all give the same result.

Icon-Comment phobia, 4 years and 141 days ago. Icon-Permalink

Try {label-search:type=CategoryLabel|name=Category|value=FAQ}

Here's how this renders:

I've posted this example for future reference as Category Search.

dave's example, of course, would require {label-search:type=CategoryLabel|name=Category|value=Customer}

Icon-Comment dave, 4 years and 140 days ago. Icon-Permalink

Well 'aint that cool.

I updated the snip to match phobia's comment. Also, I added this to the bottom of snipsnap-documentation,

{label-search:type=CategoryLabel|name=Category|value=snipsnap-documentation}

Icon-Comment phobia, 4 years and 139 days ago. Icon-Permalink

Source code is the ultimate documentation… as long as you can read it.

Icon-Comment jlous, 4 years and 137 days ago. Icon-Permalink

Now, if only we could assign more than one category to a snip, and search for combinations of labels, it might actually be useful too.

Icon-Comment phobia, 4 years and 137 days ago. Icon-Permalink

What prevents you from assigning more than one category?

More robust searching criteria should be simple to implement. The hardest part, I think, would be defining the signature of the macro.

Icon-Comment germuska, 4 years and 47 days ago. Icon-Permalink

I want to do something like {snip-tree} but with taxonomy labels. Is this supported yet? I don't quite see how to adapt the {label-search} macro to that.

Icon-Comment phobia, 4 years and 46 days ago. Icon-Permalink

To answer my own question: you cannot assign more than one category because the implementation of CategoryLabel uses a hardcoded name of "Category", and a snip cannot of labels with duplicate names.

This would easily be solved by having the Category label simply use the selected category as the name of the label, rather than the value. The label-search macro would also need to be refactored to support this change.

I know at least one person considering using Confluence largely because of this weakness :-(

Icon-Comment comforteagle, 3 years and 317 days ago. Icon-Permalink

I tried the change you suggested and it works perfectly Now i can have multiple categories per Snip

And they have name = "name of category snip" type = CategoryLabel value = "Category"

Also had to make a small change to the Category form used to edit the catogory so that it changes the name of the category instead of the value.

Icon-Comment GaryPaulson, 3 years and 161 days ago. Icon-Permalink

Ok when I try it I get a mess when I use type=AtoZ

The jiberish at the top looks like something is broken??

For Example {label-search:type=AtoZ|name=Category|value=FAQ}

produces:

 comment-label-search-11#idxA">A...  comment-label-search-11#idxB">B...  comment-label-search-11#idxC">C...  comment-label-search-11#idxD">D...  comment-label-search-11#idxE">E...  comment-label-search-11#idxF">F...
 comment-label-search-11#idxG">G...  comment-label-search-11#idxH">H...  comment-label-search-11#idxI">I...  comment-label-search-11#idxJ">J...  comment-label-search-11#idxK">K...  comment-label-search-11#idxL">L...
 comment-label-search-11#idxM">M...  comment-label-search-11#idxN">N...  comment-label-search-11#idxO">O...  comment-label-search-11#idxP">P...  comment-label-search-11#idxQ">Q...  comment-label-search-11#idxR">R...
 comment-label-search-11#idxS">S...  comment-label-search-11#idxT">T...  comment-label-search-11#idxU">U...  comment-label-search-11#idxV">V...  comment-label-search-11#idxW">W...  comment-label-search-11#idxX">X...
 comment-label-search-11#idxY">Y...  comment-label-search-11#idxZ">Z...  comment-label-search-11#idx0-9">0-9...  comment-label-search-11#idxAT">@...
snips with Category=FAQ: (31)
A B
Apache2Proxy Booboo
andremanuelbarbosa boymice
C D
category Developer tips
comment-amaro-1 development
cyflux
E F
exec error on SunOS Free wiki hosting
fahroe
G H
halls34
I J
Import SQL database dump jmerelo
Installation & Configuration
internal-file-links
K L
Label
M N
Misc FAQ
O P
ononco
Q R
S T
Sandbox Themes
Starter
Support
second version
sidebar
sunweifeng
U V
UI Language
User management
W X
Y Z
zheng_kylin
0-9 @
石头记

Icon-Comment stiber, 3 years and 139 days ago. Icon-Permalink

I agree with GaryPaulson; type=AtoZ appears broken. It's also overkill, unless you have a lot of snips. Vertical is quite nice, but would be better if it sorted snips alphabetically, rather than in order of creation.

Icon-Comment GaryPaulson, 3 years and 134 days ago. Icon-Permalink

I did find a patch to fix the 'lister' AtoZ problem at ThoMo's snip. He calls it

uttoxeter patch

and a couple of the things it does:

  • patched label search to correct display AtoZ rendered results
  • patch snip-tree macro to only display the searched tree (see SnipSnap)
  • patched AtoZ lister to display namespaces in index too (e.g. displays "config (SnipSnap)" instead of "config"). Also all snips with the same name (but different namespace) are listed.
Regarding 'overkill' - I agree but I did find hidden in the code another argument for the lister: Collator when used instead of AtoZ it only displays those letters that have listings. It has the same display problem that AtoZ had - so I patched it using ThoMo's patch as a guide.

For Example {label-search:type=Collator|name=Category|value=FAQ}

produces:

 comment-label-search-13#idx41">A...  comment-label-search-13#idx42">B...  comment-label-search-13#idx43">C...  comment-label-search-13#idx44">D...  comment-label-search-13#idx45">E...  comment-label-search-13#idx46">F...
 comment-label-search-13#idx48">H...  comment-label-search-13#idx49">I...  comment-label-search-13#idx4a">J...  comment-label-search-13#idx4c">L...  comment-label-search-13#idx4d">M...  comment-label-search-13#idx4f">O...
 comment-label-search-13#idx53">S...  comment-label-search-13#idx54">T...  comment-label-search-13#idx55">U...  comment-label-search-13#idx5a">Z...  comment-label-search-13#idx77f3">石...
snips with Category=FAQ: (31)
A B
Apache2Proxy Booboo
andremanuelbarbosa boymice
C D
category Developer tips
comment-amaro-1 development
cyflux
E F
exec error on SunOS Free wiki hosting
fahroe
H I
halls34 Import SQL database dump
Installation & Configuration
internal-file-links
J L
jmerelo Label
M O
Misc FAQ ononco
S T
Sandbox Themes
Starter
Support
second version
sidebar
sunweifeng
U Z
UI Language zheng_kylin
User management
石头记

Please login to post a comment.

What is SnipSnap?
SnipSnap is a free and easy to install weblog and wiki tool written in Java.

SnipSnap download
Current version: 1.0b3-uttoxeter
Try our >>Web Start Demo!

Resources

5567 Users and 13712 Snips. Installed 6 years and 9 days ago

Logged in Users: (0)
… and 11 Guests.

snipsnap-changed for older changes.

< July 2008 >
SunMonTueWedThuFriSat
12345
6789101112
13141516171819
20212223242526
2728293031

snipsnap
Listed on BlogShares
XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

pico-powered

Powered by SnipSnap 1.0b3-uttoxeter
YourKit >>Java Profiler

Fraunhofer FIRST

snipsnap.org | Copyright 2000-2006 Fraunhofer FIRST