DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:struct:sample:simple

⇐Back to the list of samples

struct: Simple sample

This is a very simple application of the struct plugin. The goal should be to add a fact box to each page in a namespace.

Prerequisites:

:!: As mentioned in the forum, this example is actually too simple to use struct effectively.


 Struct sample


We will create a simple struct schema, called fact.

Go to the admin page and follow the link “Struct Schema Editor”.

Under “Create new Schema” we enter the name of the new schema at “Schema Name:”, in this case fact.

We create 11 simple Fields:

Fields (Configuration - only not default is mentioned): Select first the Type of the field. Click “Save” after each Field, you get a new sort-number and a new row.

Schema: fact
Sort Field Name Multi-Input?1) Configuration Type Enabled
10 name false label: Name Text true
20 original name false label: Original Name Text true
30 real name false label: Real Name Text true
40 synonyms false label: Synonyms Text true
50 image false label: Image, width: 120 Media true
60 day of birth false label: Day of birth, pastonly: true Date true
70 day of death false label: Day of death, pastonly: true Date true
80 category true label: Category, Values: “none,Person,Technology,Hobby” Dropdown true
90 dimensions false label: Dimensions Text true
100 formula false label: Formula Text true
110 relations true label: Relations, usetitles: true Page true

Click the “Save” button after each new entry.

Why do we have so many fields for the names? struct will always display only the fields that are filled. Suppose we want to describe a movie with a factbox:

  • Name: the title of the movie in the local language.
  • Original Name: the original title of the movie

Similar for an actor:

  • Name: the known name, perhaps the stage name.
  • Real Name: the real or birth name

There are no required fields, but I would always fill the Category field.

Now it's time to make sure that the fact box is available on all pages of a namespace.

Go to the admin page and follow the link “Struct Schema Assignments”.

On the page “Schema Assignments”:

  • Page/Namespace: myns:**
  • Schema: fact

Click the “Add” Button.

For the namespace myns we have connected the schema fact for all pages (first *) and all subnamespaces (second *) and their pages.

The Factbox can be filled out on every page in myns.

:!: To create the page, insert text in the editor. Otherwise the page and the data in struct fields will not be saved! :!:

 Factbox

Thats all 8-)

1)
false – uncheck – [ ]
true – check – [✔]
plugin/struct/sample/simple.txt · Last modified: 2023-12-05 19:05 by 91.16.183.4

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki