Not logged in. · Lost password · Register
Forum: General Help and Support Plugins RSS
Bureaucracy - question
Avatar
hj #1
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Subject: Bureaucracy - question
Hi, got a question about Bureaucracy plugin...

Documentation (excellent) says this:

Dependencies with Fieldsets
Sometimes part of a form should only be asked when a certain answer was picked for a previous question. Simple dependencies like that can be created by using Fieldsets.

This is excellent, and I've coded up a page with two alternative fieldsets, either of which displays depending on the choice made in an initial 'select' field (dropdown choice). Good so far.

However, I'm not sure how this 'either/or' function is handled by a template which bureaucracy is outputting to.  Should the template have placeholders for ALL the fields of both fieldsets?  And does bureaucracy output only the chosen fieldset data?  If so, what happens to the 'unused' placeholders from the fieldset not selected?

In an ideal world it would be good that if, for example, the initial select choice was ALPHA, then bureaucracy could output to an alpha-template.  If it was BETA then it would output to a separate beta-template.  But I'm not sure that this facility exists in bureaucracy?

I guess I'm just wondering how to handle the varying output from the bureaucracy form, depending on the fieldsets invoked?
Avatar
pop #2
Member since Nov 2016 · 147 posts
Group memberships: Members
Show profile · Link to this post
I have given some thought to your question and I have come up with a form which does some of the things you are asking for:

<form>
action template "description of @@product@@" @@product@@ :
fieldset "Choose a product type"
select "product" "table|chair"

fieldset "Higher furniture" "product" "table"
number "number of legs" @
submit "Add table description to wiki"

fieldset "To be sat on" "product" "chair"
number "height of seat" @
submit "Add chair description to wiki"

</form>

The form has one field which is always shown. It allows you to select one of two product types: table or chair. Depending on your selection, either the field set "Higher furniture" (for tables) or "To be sat on" (for chairs) will be shown, each with a number of  attributes specific to the type of product chosen and a submission button with another text.

The line beginning with "action template" has three parameters after the word "template":
"description of @@product@@" will be substituted to either "description of table" or "description of chair". These are the template files the form expects when executing the action.
"@@product@@" followed by space followed by : specifies the namespace where the new page is to be placed, either :table: or :chair:

The name of the page created will be either the number of legs or the height of the seat, depending on the product type.

This might be the content for the table template (description_of_table)
-----------------
===== Table with @@number of legs@@ legs =====

A table with @@number of legs@@ is particularly useful for ....
--------------

Similarly for the chair template (description_of_chair).

There's also the directive addpage in the bureaucracy plugin, but I have not been able to produce useful results with that, so far.
Avatar
hj #3
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
pop,

Many thanks for this, Sorry I've been diverted by other work, though you and I have talked directly on other issues, thanks for your views there, too.

This sounds like an excellent suggestion, if I can get my head around the coding for my form structure.  I will give it a go and see what happens.

Just one query - your action template ends with a destination namespace, @@product@@ :  That's ok, but you don't include a 'separator', which I think (in the documentation) is required for the page name to be constructed.  I have been using a hyphen '-', so presumably I need to add that as well?

Also, your template appears to be enclosed in apostrophes and with spaces... "description of @@product@@".  How does that look as a template name?...because I have to create the template and give it a file name.

Hugh
This post was edited on 2019-04-16, 00:48 by hj.
Avatar
pop #4
Member since Nov 2016 · 147 posts
Group memberships: Members
Show profile · Link to this post
Hugh -

In order to create the two templates, just create a page named "desrciption of table" and one named "description of chair", including all spaces. The spaces are the reason why I enclosed the template name in double quotes.

My form does indeed include the separator, which is a colon (":"). It will produce pages such as "table:4" and "chair:60", i.e. a page named "4" witin the name space "table" and a page named "60" within the name space "chair". That's not a very clever solution as you can only have one four-legged table. For your own solution, you would probably use hyphens,  as you noted.

It seems a bit convoluted at first, but after a while it's all straight forward.
Avatar
hj #5
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Hi Philipp,

The spaces are the reason why I enclosed the template name in double quotes.

I wouldn't know why you have to do that? But ok! 

As it happens I made two templates separately and saved them as .txt files, surface_trip and underground_trip. My action line code appears to be selecting the appropriate template, depending on the choice made in the first fieldset dropdown "Trip type". So that bit is working ok, and the resulting page is displaying the correct information as entered in all the other relevant fields. Good.

Where it is going wrong is in the destination of the created page; and the actual pagename which, of course, is also the URL.

I want the destination to create two sub-namespaces, triparchives:surface or triparchives:underground. Surface and Underground are the 'Trip type's. Instead, however, it is just creating a whole set of nested namespaces - see the screenshot attached.  The URL for a created page is also very convoluted, e.g.

/doku.php?id=triparchives:triptype:2019-04-16type:paku_valley


whereas I would like it something more like...


/doku.php?id=triparchives:underground-2019-04-16-paku_valley


This could be I'm using the wrong separator. But more importantly, the destination sub-namespaces surface or underground are not being created.

Here's my action line code:

Action template "@@Trip type@@ Trip" triparchives:@@Trip type@@: -


I'm probably not far off getting this right!  But there is such delicacy and detail in the action line code that one thing wrong and it all goes pearshape!

Hugh
The author has attached one file to this post:
nested-namespaces.jpg 21.5 kBytes
You have no permission to open this file.
This post was edited on 2019-04-16, 11:32 by hj.
Avatar
pop #6
Member since Nov 2016 · 147 posts
Group memberships: Members
Show profile · Link to this post
I think the part of the action line which specifies the target (namespace and filename) should be put between double quotes as well because it contains a space (in @@Trip type@@":

Action template "@@Trip type@@ Trip" "triparchives:@@Trip type@@:" -
Avatar
hj #7
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
 :-)
Avatar
hj #8
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Excellent, thanks pop.  Working just right, now.

One small issue is that if a file (jpg) is uploaded via the form, the location of the file is displayed in the created page.  However, it is not a link, so you can't just click it and view the file.  :-(

I'm not sure if this is a Bureaucracy problem, or whether I need to add some coding to my template to 'bring the link alive' so to speak.??  Attachment shows how the uploaded file is displayed, but isn't a 'green' link.

The file display line in my template is thus:

**Files:** @@Upload file@@\\

maybe I need to do something to this to make it a live link?

Hugh
The author has attached one file to this post:
Screen shot 2019-04-17 at 00.14.31.png 38.3 kBytes
You have no permission to open this file.
Avatar
pop #9
Member since Nov 2016 · 147 posts
Group memberships: Members
Show profile · Link to this post
I'm guessing here, but I think you should invoke the file as a link, such as:

**files:** {{@@Upload file@@?linkonly|}}\\

However, this would only work with one file.
Avatar
hj #10
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
That worked, too  :-)   Many thanks!

for my full understanding, I'm curious about the part of the link which is ?linkonly| - where do you get that from?  I looked in the syntax page but couldn't see any linkonly reference, and wonder what the ending pipe is for?
Avatar
pop #11
Member since Nov 2016 · 147 posts
Group memberships: Members
Show profile · Link to this post
The ending pipe is due to my sloppy editing. It doesn't belong there.

The linkonly parameter is straight out of the syntax description: https://www.dokuwiki.org/wiki:syntax#supported_media_formats
Avatar
hj #12
Member since Apr 2008 · 167 posts · Location: Lancaster, UK
Group memberships: Members
Show profile · Link to this post
Thanks.

Interesting to see that the syntax page you referenced there is different to the syntax page of my Frusterick Manners installation.  Mine doesn't have that clause you show, and indeed my syntax page section is called Images and Other Files as opposed to Media Files

You live and learn!
Avatar
pop #13
Member since Nov 2016 · 147 posts
Group memberships: Members
Show profile · Link to this post
My DW appears to be Release 2018-04-22a "Greebo"
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-06-24, 11:18:40 (UTC +02:00)