
As DataForms seem to be problematic for Wikidot users we wish to present you a small tutorial — how to create an editable table using Forms. As an example we will create a catalog of weapons for an online game.
Let's start!
1. Things you need:
- Data Forms to hold your structured data
- Templates — you will create DataForm definition here
- ListPages Module to display data in a table
2. You may also need:
- CSS Module to add custom look to your content
- Redirect Module to come back to table automatically after editing
- special URL parameter edit/true (automatically turns edit mode on) and noredirect/true (prevents redirection)
- some admin:manage configuration
3. How to put it together:
First of all, you need to choose category for your data, e.g. weapon and create your DataForms definition like this:
Page content: weapon:_template
[!-- this module redirect you to your list after edit --]
[[module Redirect destination="/weapon-list"]]
====
[!-- this is DataForm definition - it define fields --]
[[form]]
fields:
image:
label: Image
type: file
category: weapon-images
name:
label: Name
description:
label: Description
height: 3
type:
label: Weapon type
type: select
values:
1: "Bow"
2: "Dagger"
3: "Sword"
4: "Staff"
5: "Axe"
[[/form]]
Set weapon category as autonumbered in admin:manage » Autonumbering of pages.
Next you need to create a page with ListPages, i.e.:
Page content: weapon-list
[!-- here you can style in your table --]
[[module CSS]]
.weapon-list {
width: 100%;
margin-top: -2px;
}
.weapon-list td {
border: 1px solid #AAA;
}
[[/module]]
[[table class="weapon-list"]]
[[row]]
[[cell style="width:160px"]] Image [[/cell]]
[[cell]] Name/Description [[/cell]]
[[cell style="width:100px"]] Type [[/cell]]
[[cell style="width:40px"]] Edit [[/cell]]
[[/row]]
[[/table]]
[[module ListPages category="weapon" separate="no" order="name" perPage="9999"]]
[[table class="weapon-list"]]
[[row]]
[[cell style="width:160px"]] [[image %%form_raw{image}%% width="160px"]] [[/cell]]
[[cell]]
**%%form_data{name}%%**
%%form_data{description}%%
[[/cell]]
[[cell style="width:100px"]] %%form_data{type}%% [[/cell]]
[[cell style="width:40px"]] [[[%%link%%/edit/true/noredirect/true | edit]]] [[/cell]]
[[/row]]
[[/table]]
[[/module]]
[[[/weapon:new/edit/true/noredirect/true | + Create New]]]
Now you can create and edit items, add/delete a column in table, create different tables from one data set and you can manage even the most complex tables. Once you dig into documentation you can learn how to add sorting, pagination and harness more advanced use cases to manage your dataset.
Check out the live example: http://forms.wikidot.com/weapon-list
I like this tutorial a lot. Just curious, but is there a site for tutorials like these?
A Simple Plan by ARTiZEN
Sorry posted by Artizen but wrong profile
Hi,
I'm starting to feel really stupid by now but i have tried the above several times and can't get it to work. Every time i click on create new entry i get prompted with a 'this page (New) does noet exist yet'. Also following Artizen's sample has the same result. The new page somehow is not linked to the template with the form definition.
Any suggestions would be appreciated.
Regards,
Dirk
You probably create pages using "New page" button, its truncate "_" from "_template" word (look at browser location bar). You need to rename yours pages from "template" to "_template" ( bottom toolbar: + Options -> Rename).
Bartłomiej Bąkowski @ Wikidot Inc.
';.;' TeRq (Write PM)
Thanks, TeRq,
That was it! Works fine now…thanks a million! I just started using Wikidot today so am still finding my way around…
Cheers, Dirk
Did you find my tutorial helpfull?
Should I change something?
A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.
This is a great tutorial and I have it working perfectly. Thank you! Now, if someone wants to delete one of the pages they've added, what's the easiest way to set that up?
Go to the bottom of the page, click Options, then click Delete. You have the option to delete the page completely or rename it to deleted:…
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Thanks Rob. That's the hard way, and people entering form data are lazy. There's no way to create a clickable link in the page list table to delete each entry (as there is to edit each entry)?
One way you could do it uisng the button delete syntax is as follows:
A working version of this is at http://www.strathviewconsultants.co.uk/support:delete although I have set the permissions so you can not actually delete my pages!
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Rob, you're a legend!
If the delete button actually works in the ListPages results as it should (deletes the current result, rather than the page with the LP module on it) - then you just solved a long standing issue I've had with my "no comment" page-based forum.
Thanks!
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Ah…..rats! As you hinted, it deletes the page with the LP on, not the current result line. I'll have a re-think.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
If all the pages have a tag that switches visibility on or off.OR the pages that don't need to be seen get a tag "_hide" for example… an automated taggingsystem should do the trick. SO the "delete-button" triggers an action to change the tags of the targetted page, and it adds for example "_hide" to the tags. In the Listpages that creates your table… you need a tag-selector or you need to expand it with tags="-_hide"…
I'll see if I can make a CSI for this.
A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.
@Leiger…
if you would set the tag to "_delete-by-cron" you could get a cron-script running on your server that sweeps those pages by renaming them to the delete-category.
I asked for a delete-option for the API but that wish was rejected.
A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.
This CSI (cross side include) works and makes it possible to add a link to your table or inside your listpages-module that generates your list, that will remove that line from the list or table. The corresponding page is not deleted however but will not be visible in this list.
Link to CSI
A - S I M P L E - P L A N by ARTiZEN a startingpoint for simple wikidot solutions.