Loading...
 
Skip to main content

Features / Usability


'tagging' or 'categorizing' text within a wiki page

Everything I've found about "tagging" relates to entire tiki objects (wiki, tracker, article, etc). Is there any way to "tag" content within a wiki page? I use "tag" loosely. Call it what you will. What I want to be able to do is create links to text that is identified as being of a type, and ideally grouped by value. Here is what I mean, specifically:

In my current site, which I'm transitioning to tiki, I have created a css class to identify text as the name of a ship.

Copy to clipboard
(begin span class="ship-name")Titanic(end span)

(couldn't figure you how to add html as non-parsed - it got stripped anyway)

I use the class for formatting, but also as a parsing tool. I have a standalone application on my development machine (not the web client or server) that can parse all the files under a directory using the string "ship-name". It interprets the text between the tag elements as the ship name. It uses this name to group all pages containing a reference to that ship and then creates a link to each page. I then upload it as static index pageQuestion.

Ideally, I'd have an anchor at each span so that I could link directly to the reference, rather than just the page. Even more ideally, I would link only the first occurrence between header elements. I'm wondering if this could be automated with tiki. To much to hope for?

Assuming it can't be done, the rest of this post is a "change request" or "wish list" request for all the developers out there. I'm a programmer, but not for the web, and I'm just getting started with tiki for my "hobby" website. I'd be willing to help, but I think the learning curve would be too long and steep for the time I have. I so I'll do the "run it up the flag pole and see if anyone salutes" approach.

You might say that my theoretical, perfect-world, tiki plugin would combine PLuginAlink, PluginAname, and PluginDiv along with something that lists links, like PluginCategory. Here is my attempt at a spec:

{GROUPDIV(group=, item=, class=, list=0|1)}{GROUPDIV}

  • group: name identifying a logical collection of items (e.g. ship names, music categories, etc). Only one can be specified.
  • item: comma-separated (?) list of items within the group. The text string can belong to more than one item (useful for cross-references, e.g. ship that is renamed - example below). Can also be used to disambiguate duplicates (e.g. two ships with the same name - example below)
  • class: name of css class for formatting (optional)
  • list: whether or not to include in a listing using GROUPDIVLIST, i.e. whether or not to create an anchor. Default = 0


{GROUPDIVLIST(group=, item=, links=0|1, page=id, order=alpha|freq, linktext=title|?|?, format=list|table)}{GROUPDIV}

  • group: group specified in GROUPDIV. Use to get listing for only one group, or leave blank to get listing of all groups
  • item: item specified in GROUPDIV. Use to get links for only one item in the group, or blank to get all items. Ignored if 'group' is set, since different groups would not have same items.
  • links: 0 means to list group/item names only, 1 means to list group names/item name and links to each 'tagged' wiki text string
  • page: id of page from which to collect links. Optional. If not specified, includes links to all wiki pages
  • order: alphabetical listing or by descending number of references (only counts where link=1)
  • linktext: what to use as the link text
  • format: Display format. These options are just off the top of my head - just to show that some formatting options would be useful.
    • List is an unordered list, 'indented' at group/item/link level
    • Collapsed would be a the unordered list, but with expand (+) and collapse (-) control, starting with all collapsed
    • Expanded would be a the unordered list, but with expand (+) and collapse (-) control, starting with all expanded
    • Table would be a table with, say, groups in the first column, items in the second, and links in the third


Note: the hope would be that the plugin would add new groups and items as they are encountered automatically, i.e. it is not necessary to set up groups and items before using them, as with categories. This would make it easier for members to create wiki pages.

I don't know the tiki architecture, but I presume that for all of this a database backend would be required, with some stored proceedures to update tables when wiki pages are created/modified. Not sure that's even possible.

Usage:

on wiki page titled Enterprise-I...

Copy to clipboard
The first {GROUPDIV(group="ShipNames", item="Enterprise1", class="ship-name", list=1)}Enterprise{GROUPDIV}, a British supply sloop, was captured 18 May 1775 at St. Johns, Quebec, Canada, by Colonel B. Arnold, named {GROUPDIV(group="ShipNames", item="Enterprise1", class="ship-name")}Enterprise{GROUPDIV}, and armed for use on Lake Champlain.


would produce

The first Enterprise, a British supply sloop, was captured 18 May 1775 at St. Johns, Quebec, Canada, by Colonel B. Arnold, named Enterprise, and armed for use on Lake Champlain.

on a wiki page titled Enterprise-II...

Copy to clipboard
The second {GROUPDIV(group="ShipNames", item="Enterprise2", class="ship-name", list=1)}Enterprise{GROUPDIV}, a schooner, was a successful letter-of-marque before she was purchased on 20 December 1776 for the Continental Navy.


would produce

The second Enterprise, a schooner, was a successful letter-of-marque before she was purchased on 20 December 1776 for the Continental Navy.

on wiki page titled Enterprise-III...

Copy to clipboard
The third {GROUPDIV(group="ShipNames", item="Enterprise3", class="ship-name", list=1)}Enterprise{GROUPDIV}, a schooner, was built by Henry Spencer at Baltimore, Md., in 1799, and placed under the command of Lieutenant John Shaw. On 23 December 1803, {GROUPDIV(group="ShipNames", item="Enterprise3", class="ship-name" link=1)}Enterprise{GROUPDIV} joined with frigate {GROUPDIV(group="ShipNames", item="Constitution", class="ship-name", list=1)}Constitution{GROUPDIV} to capture the Tripolitan ketch {GROUPDIV(group="ShipNames", item="Mastico","Intrepid", class="ship-name", list=1)}Mastico{GROUPDIV}. Refitted and renamed {GROUPDIV(group="ShipNames", item="Mastico","Intrepid", class="ship-name", list=1)}Intrepid{GROUPDIV}, the ketch was given to Enterprise's commanding officer, Lieutenant Stephen Decatur, Jr....

would produce

On 23 December 1803, Enterprise joined with frigate Constitution to capture the Tripolitan ketch Mastico. Refitted and renamed Intrepid, the ketch was given to Enterprise's commanding officer, Lieutenant Stephen Decatur, Jr....

on wiki page titled 'The Barbary States'...

Copy to clipboard
Here we list three ships (four names) involved in the wars with the the Barbary States, just to illustrate a point: {GROUPDIV(group="ShipNames", item="Enterprise3", class="ship-name" link=1)}Enterprise{GROUPDIV} {GROUPDIV(group="ShipNames", item="Constitution", class="ship-name", list=1)}Constitution{GROUPDIV} {GROUPDIV(group="ShipNames", item="Mastico","Intrepid", class="ship-name", list=1)}Mastico{GROUPDIV} {GROUPDIV(group="ShipNames", item="Mastico","Intrepid", class="ship-name", list=1)}Intrepid{GROUPDIV}

would produce

Here we list three ships (four names) involved in the wars with the the Barbary States, just to illustrate a point:

Enterprise
Constitution
Mastico
Intrepid

A page anywhere on the site with this text

Copy to clipboard
{GROUPDIVLIST(links=0)}{GROUPDIVLIST}


would produce

  • Constitution
  • Enterprise
  • Enterprise
  • Enterprise
  • Intrepid
  • Mastico

Copy to clipboard
{GROUPDIVLIST(links=1)}{GROUPDIVLIST}


would produce

  • Constitution
    • Enterprise-III (link)
    • The Barbary States (link)
  • Enterprise
    • Enterprise-I (link)
  • Enterprise
    • Enterprise-II (link)
  • Enterprise
    • Enterprise-III (link)
    • The Barbary States (link)
  • Intrepid
    • Enterprise-III (link)
    • The Barbary States (link)
  • Mastico
    • Enterprise-III (link)
    • The Barbary States (link)

Wiki plugins are one of the easier ways to add custom functionality to Tiki, but it does take some background in PHP coding, or at least a good eye and some luck in copying and modifying an existing plugin. Of course, the more complex the function, the harder it would be to do. Your best bet would be to find someone (on the Consultants page probably - link in the footer below) that would do the work for a fee. What you want the plugin to do may be not generic enough to excite a developer to produce it for altruistic reasons.

In the simplest form, the functionality already exists - a term can have an HTML tag, like span, which can be given a class and an id, so it can be styled, etc., and can be used as a link destination; this would be similar to your first example, but with id="Titanic" added.

But from there, things get complicated and call for an somebody with the expertise, I'd say.

-- Gary


Gary,

Thank you very much for responding.

Of course I don't expect anything for free. But one can always hope someone else has their own selfish need for the same thing, the capability to do it, and the willingness to share (the reason I can enjoy using Tiki today). Never hurts to fish 😊

I won't go the consultant route, at least not at this time. I'm guessing it would be quite pricey. The club has no funds for it, and I'm not feeling quite generous enough to take on the expense myself (though I'm a member too). Maybe I'll be a Tiki contributor in the future, and maybe this will be my contribution. First I'll have to build up the nerve to dive in. Everything new is intimidating at first, at least for me. I've done a little php for my old website, and years of C++ helps with understanding the basic constructs. It will be hard to find time to learn how to program plugins. But because of this topic, my interest is building.

Before I even start considering this, I'll have to figure out what is even in the realm of possibilities. May I ask for quick answers to some questions? A point in the right direction? Yes or no answers (not how) to whether certain things are possible? Maybe this belongs in a different forum now. I'll continue here for one more round...

Starting with the self-help question:
Q: Is there a Tiki Plugin Programming Guide (quick Google search yielded nothing promising)

For my idea to work efficiently, I think the information will have to be stored in a database
Q: Is it possible to create custom tables?

To be useful, the user would not have to manually add anchors and links (the "simplest form" you mention). So to be useful, the plugin that identifies the items should be able to parse the code and create the database entries. MakeToc parses and creates links, so I know parsing the contents of the page is possible. But it creates static links on the page.
Q: Is it possible for a plugin to add/remove/modify entries in a database table? (I know you you can do this with PHP, I'm asking within the context of a Tiki plugin)
Q: Can the plugin know the difference between 'preview' and 'save'? The database should not be altered on preview, lest the user cancel the page edit). The result would be broken links on the index page.

I'll have to figure out how entries are removed from the database when the user edits a page and removes occurrences of the plugin. If there is no plugin, there is nothing to send database statements. The result would be broken links in the table. I guess there is no question here. I'll have to figure that one out on my own. I have a couple ideas already - but not good ones. I'll cross that bridge when I come to it...

Back to the subject of general usefulness, if I may:

I referred to this as 'tagging' before, but I'm just starting to realize that 'index' is a much better word for it (even though I use my current approach for a page titled "Ship Index"). It's exactly like the index for a book, or if you prefer, the yearly index for a periodical. That makes it sound of much more global interest than you (or I) may have originally thought. I don't expect volunteers to suddenly come out of the woodwork, but perhaps some encouragement for me to pursue this. So I'll amend my idea:

{INDEXITEM(index=, key=, class=}{INDEXITEM}

notes: 'group' change to 'index', 'item' changed to 'key', 'list' dropped (when not listed, all you get is formatting, which can be done more easily and with less overhead)

The purpose of 'index' is to allow more than one index per site. Books are the same in that they can have multiple indexes. I have one on wine with a generic index and a index to Chateau, for example.

{INDEX(index=, key=, links=1|0, page=id, order=alpha|freq, linktext=title|?|?, format=list|table)}{INDEX}

notes: 'group' change to 'index', 'item' changed to 'key'


Long post, I know. Thanks for your time,

Greg

P.S. You may be wondering why I don't simply include a Google site search field. I wonder too. I guess I like two things about an index: 1) it is browsable 2) as long as the plugin code is good, it is always up to date (don't have to wait for Google to crawl it)

> Q: Is there a Tiki Plugin Programming Guide

There's some information at http://dev.tikiwiki.org/Hello+WorldQuestion .

> Q: Is it possible to create custom tables?

There isn't functionality in Tiki to create custom tables. To get that in a virtual sense, Tiki has the TrackersQuestion feature.

> Q: Is it possible for a plugin to add/remove/modify entries in a database table? (I know you you can do this with PHP, I'm asking within the context of a Tiki plugin)

I imagine so, if it is programmed to do that.

> Q: Can the plugin know the difference between 'preview' and 'save'?

As far as I know, 'preview' doesn't touch the database, only memory; only 'save' makes changes in the database.

One difference I notice between what you are thinking of your plugin doing and what Tiki's plugins normally do is that the scope of a normal plugin is limited to its specific space in the wiki page. That is, a DIV plugin for example has a beginning and an end tag and defines what happens to the wiki content between those tags. (maketoc doesn't make changes in the page; it only parses it and creates the appropriate strings based on what headings are found.) Plugins in this sense aren't able to process anything outside the scope defined in that way, so I don't see how an index plugin could parse the full wiki page and make changes in it unless all the wikitext of the page is wrapped with this plugin, which suggests there's probably a more elegant way to do this whole-page processing, like in the libs that process wiki content. But this would be a question for one of the devs who knows the code on that level.

-- Gary