Wiki templates

ZorkFox
ZorkFox
edited May 2013 in General Archive
I would like to have special wiki pages that can be used as templates on other pages. As just a simple example, if I create a menu internal to the wiki, I want to be able to change it in one spot rather than on all ten, fifty, or one hundred pages of my wiki that also use that menu. This is a staple of MediaWiki, so I don't know if that puts a kibosh on using it for Obsidian Portal.

Edit: this was meant to go on the reforging beta forum, but I seem to have erred in how to go about posting to it.

Comments

  • berdman
    berdman
    Posts: 46
    I second ZorkFox's request. Any ability to template the wiki pages would be appreciated. A lot can be done with CSS, but there are sill many things that are copy-paste HTML today.
  • Micah
    Micah
    Posts: 894
    This is a common request, and I want to say yes to it. There are a lot of implementation details to consider, but I think it's possible.

    One of the main reasons I want to do this is that it would help people deal with any breaking changes that we make in the reforging. I don't think we're going to be able to do what we want without fundamentally changing the underlying HTML structure, which will break a lot of carefully crafted pages. Like you say, if that involves editing 100s of pages, then it's a real chore. But, if you could edit a template...

    So, I can't promise anything right now, but I will definitely be looking into some form of templating. It will probably be much less fancy than anyone is hoping (like no fancy variable substitution or embedded scripting), and perhaps a little rough around the edges, but if it can ease the pain of migrating to the new layout, that's a huge plus.

    Also, thanks for referencing MediaWiki. If you can point me to examples of where others are doing things, that really helps me research things. If there is anything in particular that you like or dislike about MediaWiki's implementation, please say so. For example, if their way of including or referencing a template is good or bad, tell me why.
  • xb95
    xb95
    Posts: 6
    MediaWiki lets you do: {{Namespace:Pagename}}

    Then, when rendering, it basically invokes the renderer again on the referenced page and dumps the content into the local page. I think it only lets you render one level deep, so you can avoid having to do any sort of depth analysis or cycle breaking logic. (Even though multi-level embeds could be useful, I really don't think it's a necessary feature.)
  • Langy
    Langy
    Posts: 364
    One thing I'd recommend would be to have one template that is automatically placed on every single page of the entire site; this template, unlike others, should probably include at least one level of recursion, so you can reference other templates within that template. No real need for further recursion than one or two levels, though.
  • ChainsawXIV
    ChainsawXIV
    Posts: 530 edited May 2013
    I know it's a bit of reinventing the wheel, given that pretty much every commercially distributed wiki system has an implementation of this in some form, but quite possibly the easiest way to handle this would be to offload the heavy lifting and replacement work to the client. What you'd need:

    * The ability to request a page as a template (?template=true) whereupon only its content would be served
    * A client script which does a replace of a properly formed tag (as above) with the above, fetched AJAX style

    Supporting static token replacement would be easy enough in that context, as you can simply have the script extract additional parameters from the tag (maybe structure the tag as JSON?) and replace them in for tokens. You could even support things like variable row counts in a templated table that way as a little stretch.

    Edit: Possible down sides to this approach would be slightly longer rendering time for pages (probably not even noticeable for most users), and some extra requests to the server (which may or may not be a thing you care about).

    The more I think about it, the more workable that sounds... I'd probably even have fun whipping up a working example if you're interested.
    Post edited by ChainsawXIV on
  • Micah
    Micah
    Posts: 894
    Well, we're not a commercially distributed wiki system, so we have to reinvent a lot of wheels.

    I think I see the idea here, with serving the template and the content separately and then combining them client side. I'm not sure that's the route I would take because it's much easier (for me) to do heavy lifting on the server side. But any final product will probably be a combination of server and client side. I really want to make the overall UX much nicer, and that usually means more javascript.
  • xb95
    xb95
    Posts: 6
    I'm not suggesting templating be done client-side and wouldn't. Doing it server-side is generally saner and easier and is how I've done it and would do it if I did it again. (That sentence is a bit tortured, but I think you get the gist.)
Sign In or Register to comment.

June 2022
Baldur's Gate

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions