Discussion

e.g.

<<CollectLists>>
<<CollectLists(filter_selection="Name,Instrument")>>

Thanks for your update; made some short tests over the lunchtime.... btw. moved my files to my public test wiki under: http://www.wikiwiki.ch/Test/CollectLists (some username, etc.. should work)

Feedback:

Questions:

Wishes

Search for Category

I would like to use this Macro for kind of a central phone dictonary. For this I created a new HomepageTemplate, like this:

{{attachment:nobody.jpg|MacroMarket/CollectLists/Discussion|class=mitarbeiterfoto}}


= MacroMarket/CollectLists/Discussion =

 Namen:: Nachname, Vorname
 Kürzel:: xxx
 Funktion:: Funktionstitel
 Abteilung:: [[Abteilungsnamen]]
 Arbeitsort:: Strasse Nummer, Stockwerk/Raum
 Telefon:: 044 xxx xx xx
 Fax:: 044 xxx xx xx
 Natel::
 E-Mail:: vorname.nachname@xxxxx.com
 

== Anmerkungen ==



----
CategoryMitarbeiter

Now I would like to collect all this entries / userhomepages together in a big list. The problem is that the current macro only supports subpages to collect and I do not want to move all homepages under a page, because this would also break the wiki username stuff.

my example:

<<CollectLists(column_heading="Namen,Funktion,Abteilung,Telefon,e-Mail",categoryname="CategoryMitarbeiter")>>

well, just a wish, thanx anyway!

bye -- MarcelHäfner 2009-02-26 17:15:27

Hi Marcel

I would be glad if you try this yourself. I think the currrent search logig by the pagename should be changed to a search pattern. needle = '^%s/(.*)' % pagename ← needs to be changes and the parameter and a bit more of code. Don't add a new parameter.

Look at from MoinMoin.search import searchPages and for an example how to use it at e.g. action.PackagePages.searchpackage

searchPages can be used to find everything or bundle pages of interests.

cheers

ReimarBauer/Photo/img.png -- ReimarBauer 2009-02-26 22:30:02

I Reimar

Changed the macro to only supporting CategoryNames... will try later to mix the "Category" and "Parent/Child" stuff together. I think about just to check if the given pagename starts with Category then it's a CategorySearch otherwise it would use your function.

btw. I'm completely new python/development, so be mercy with my code but tips & tricks are always welcome :-) bye Marcel

--- CollectLists.py.original    2009-02-27 12:37:17.025355600 +0100
+++ CollectLists.py.neu 2009-02-27 14:44:04.337409100 +0100
@@ -28,6 +28,7 @@
 from MoinMoin.util.dataset import TupleDataset, Column
 from MoinMoin.wikidicts import Dict
 from MoinMoin.widget.browser import DataBrowserWidget
+from MoinMoin.search import searchPages
 
 Dependencies = ["pages"]
 
@@ -62,7 +63,9 @@
         # Don't filter if syntax was wrong
         filter_column_value = u''
 
-    needle = '^%s/(.*)' % pagename
+    #needle = '^%s/(.*)' % pagename
+    #Marcel: because there is no child or subpage under the pagename exist, so no / to search for
+    needle = '^%s(.*)' % pagename
     filterfn = re.compile(needle).search
     pages = request.rootpage.getPageList(exists=1, filter=filterfn)
     if not pages:
@@ -71,7 +74,17 @@
     # ignore Template pages
     filterfn = request.cfg.cache.page_template_regexact.search
     templates = request.rootpage.getPageList(filter=filterfn)
-    subpages = [page for page in pages if page not in templates]
+    #subpages = [page for page in pages if page not in templates]
+    #Marcel: subpages are not generated from the parent/main pages
+
+    #Marcel:s earching now for the category pages = cat:CategogoryName
+    needle = "cat:%s" % pagename
+    searchresult =  searchPages(request, needle)
+    subpages = []
+    for title in searchresult.hits:
+        if not wikiutil.isSystemPage(request, title.page_name) or not title.page.getPageStatus()[0]:
+            subpages.append(title.page_name)
+            
     if not subpages:
         return _("Subpage of '%(pagename)s' does not exist or you don't have enough rights.") % {"pagename": pagename}
     subpages.sort()
@@ -116,8 +129,14 @@
                     row.append((wikiutil.escape(value, 1), wikiutil.escape(value, 1)))
             else:
                 row.append('')
-        parent, child = name.split('/', 1)
-        link = page.link_to(request, text="/%s" % child)
+        #parent, child = name.split('/', 1)
+        #Marcel: because the categorypage is not the parent page of the wanted page
+        parent = pagename #there is no need for this string... but for to stay compatible let it be
+        child = name
+        
+        #link = page.link_to(request, text="/%s" % child)
+        #Marcel: don't want the / before every pagelink
+        link = page.link_to(request, text="%s" % child)
         data.addRow([link] + row)
         if transpose:
             data.columns.extend([Column(link, label=link, align=align)])

We should implement a search param. needle = '^%s/(.*)' % pagename should become a parameter (search). So that a user can give a regex to search for. Then he can choose by the regex if he wants pages of a category or subpages or whatever. The parameter pagename is then needless. Template Pages should be always excluded from the search results. May be as default it can do the subpages search.

An extension of the alphabetical sort is in preparation -- ReimarBauer 2010-02-04 11:34:49

MoinMoin: MacroMarket/CollectLists/Discussion (last edited 2010-02-04 11:34:50 by ReimarBauer)