+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: How to work with Template:Mindtouch/Control template commands?

  1. #1

    Default How to work with Template:Mindtouch/Control template commands?

    I've been browsing the Mindtouch community and this forum for hours now, but I can't find an answer to the following:

    Mindtouch 10 comes with some template files, under the template path: Mindtouch/..
    Examples for templates are ListPages, PageDirectory, or TagDirectory.

    I tried the command, named in the code, for example:

    Code:
    {{ ListPages ( pages: wiki.getpage("/").subpages, sort: "viewcount", reverse: true, limit: 10 ) }}
    But I get an error message:

    Code:
    EOF expected: /content/body/p/span, line 1, column 9
    How can I use these templates in my own structure?

  2. #2
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    You're calling a template using a parameter map, so you need to enclose it using curly braces {} rather than parentheses ():

    Code:
    {{ ListPages { pages: wiki.getpage("/").subpages, sort: "viewcount", reverse: true, limit: 10 } }}
    See this knowledge base item for a full explanation.

  3. #3
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    Aaaaaand one more thing. To call the ListPages template inside Mindtouch/Controls, you actually need to use this form of call:
    Code:
    {{ wiki.template( "Mindtouch/Controls/ListPages", { pages: wiki.getpage("/").subpages, sort: "viewcount", reverse: true, limit: 10 } ) }}
    This form is also shown in the referenced KB item, albeit not in the detail it deserves. I'll have to update that one of these days.

  4. #4

    Default

    YES! Thanx Neil, that was the trick!
    I like the Mindtouch Controls Templates very much, but didn't know how to use them. Now it works!

  5. #5

    Default

    One more thing: Why isn't the following syntax displaying subpages from root?

    Code:
    {{ wiki.template( "Mindtouch/Controls/ListPages", { pages: wiki.getpage("/").subpages, sort: "created", reverse: true, limit: 10 } ) }}

  6. #6
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    Same code works fine on the MCP. Do you have that code inside a DekiScript block, or just entered on a page? If you're surrounded by double-curly braces, then it should just be entered directly on a page. If it's in a DekiScript bock, get rid of the surrounding curly braces. See this if you're not clear. Otherwise, it should work.

    Oh, and the ListPages template allows you to simply specify the path of a parent page, and it'll automatically take the subpages of that page. So you could do this:
    Code:
    {{ wiki.template( "Mindtouch/Controls/ListPages", { pages: "/", sort: "created", reverse: true, limit: 10 } ) }}

  7. #7

    Default

    The code DO show me a list of pages, but only parent pages are shown.
    I need a list on the root wiki page, which shows me the latest pages that are added in the whole wiki.. Is that possible with ListPages?

  8. #8
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    Ah, the old "newest pages" problem. First off, the "subpages" of a page only refers to the direct children of the page, not all descendants. That's why you weren't getting anything useful.

    There is not, at present, any built-in way to get a list of the newest pages. It's easy enough to get a list of most-recently-updated pages, but not most-recently-created pages.

    Methods to produce this list via DekiScript get very slow very quickly unless your wiki is very small, so I don't recommend them.

  9. #9

    Default

    Hi to all,

    Its really fun working with templates. I wonder if there is a way to pass in parameters to a template directly by typing as URL.

    example: ..wiki/Titre_de_la_page_&action=edit&template=../A_template + parameters

    thanks

  10. #10
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    There are ways to do pretty much everything, but in this case I'm not sure what you're asking. Do you want to pass parameters to a *script* through the URL, or pre-populate the fields of a page template via the URL? I initially assumed the former, but then I noticed "action=edit" in your sample URL, and I got confused. Please describe exactly what you're trying to do.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts