wiki:SortedProperties

The code below should be added to your wikidPadHooks.py file in user extensions (if you have other extensions, you may want to do an elif. The code dynamically generates a list of your properties to multiple levels. The syntax works like this:

DisplayProperty?[xxxSubprop[xxxSubsubprop]...][yyyValue[zzzValueWord2]...]

where

  • Display is the keyword
  • Property is the name of your base property (ALL PROPERTIES MUST BE LOWER CASE TO WORK -the Property can be uppercase in the WikiWord and the code converts it to lowercase)
  • xxx is literally "xxx" which is converted to a period since WikiWords cannot have punctuation
  • Subprop, Subsubprop, etc. are multi-levels of your properties (must be lower case in WikidPad - can be any case in the WikiWord)
  • yyy is literally "yyy" which is a delimiter for the value
  • Value is if you want to list a specific property value associated with your property name instead of all of them. Note that if you use a value, you MUST include the full property - as many levels as there are. See example below.(This is CASE SENSITIVE - Value is different than value)
  • zzz is literally "zzz" which is a delimiter for a space for multi-word values. It is replaced by a space character.
  • ValueWord2, ValueWord3, etc. are the second, third, etc. words of the property item following spaces. These too are case sensitive.

So, for

contact.work: Vendors
  • contact is Property
  • work is subproperty
  • Vendors is Value

you can thus have any of these WikiWords:

Now, if you add

contact.work.important: schools
contact.personal: friends and family

you can do

Make sure your indenting works! I hope this is helpful!

Add to your:

def openedWikiWord(wikidPad, wikiWord):

section.

if wikiWord.upper().startswith("DISPLAY"):
        data = wikidPad.getMainControl().getWikiData()
        formatting = wikidPad.getFormatting()
        editor = wikidPad.getSubControl("textedit")
	editor.GotoLine(2)
	s = editor.PositionFromLine(2)
        editor.SetSelection(s, editor.GetLength())
        editor.ReplaceSelection("\n")
	list =wikiWord.split("yyy")
   	keyword = list[0].replace("xxx",".")
    	if len(list) == 2:
        	searchterm =list[1].replace("zzz"," ")
   	else:
        	searchterm =""
    	values =data.getPropertyNamesStartingWith(keyword[7:].lower())
   	for val in values:
        	editor.AddText("+%s\n" % val)
       		if searchterm =="":
            		allvalues =data.getDistinctPropertyValues(val)
            		for listitem in allvalues:
                		editor.AddText("++%s\n" % listitem)
            
                		words = data.getWordsWithPropertyValue(val,listitem)
                		for word in words:
                    		     cc = formatting.isCcWikiWord(word)
                                     if cc:
                                          editor.AddText("%s\n" % word)
                                     else:
                                          editor.AddText("[%s]\n" % word)
                		editor.AddText("\n")
        	else:
            		editor.AddText("++%s\n" % searchterm)
            		words =data.getWordsWithPropertyValue(val,searchterm)
            		for word in words:
                		 cc = formatting.isCcWikiWord(word)
                                 if cc:
                                     editor.AddText("%s\n" % word)
                                 else:
                                     editor.AddText("[%s]\n" % word)
            		editor.AddText("\n")
        	editor.AddText("\n")
Last modified 8 years ago Last modified on Mar 18, 2010 7:51:18 PM