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:
- 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.
- ValueWord?2, ValueWord?3, etc. are the second, third, etc. words of the property item following spaces. These too are case sensitive.
- 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
- DisplayContact? (displays all)
- DisplayContactxxxWork? (displays only work)
- DisplayContactxxxWorkxxxImportantyyyschools? (displays only contact.work.important: schools)
- DisplayContactxxxPersonalyyyfriendszzzandzzzfamily? (displays contact.personal: friends and family)
Make sure your indenting works! I hope this is helpful!
Add to your:
def openedWikiWord(wikidPad, wikiWord):
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.replace("xxx",".") if len(list) == 2: searchterm =list.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")