Not logged in. · Lost password · Register
Forum: General Help and Support Plugins RSS
Bureaucracy and optional fields in templates
Avatar
Urfaust #1
Member since Aug 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
Subject: Bureaucracy and optional fields in templates
Hi,

we're using bureaucracy to create new pages and also add a picture like this:

<form>
action template myns:mytemplate otherns:

fieldset "New Page" /^[^\/:]+$/
textbox  "Pagename" @
textbox  "Photo" "=noimage.jpg" !

....

Corresponding Template:
===== @@Pagename@@ =====
{{:otherns:@@Photo@@?100|@@Pagename@@}}

...

This works like a charm. Of course only if the picture was uploaded to the correct namespace with Media Manager, if no filename is put into the textbox "noimage.jpg" will appear.
Now it should be possible to add another picture. But instead of a placeholder, no picture at all should appear in the generated page if the users does not put a filename into the textbox.
The culprit seems that the image link is already in the template. Is it possible to make an additional link completely optional and wipe the link if no filename is put into the textbox in the first place?
Thanks in advance!
This post was edited on 2015-08-27, 15:38 by Urfaust.
Avatar
Urfaust #2
Member since Aug 2010 · 27 posts
Group memberships: Members
Show profile · Link to this post
First idea:

Simply create 2 templates. First containing a link to one picture (template1pic), second containing a link with two pictures (template2pics). I then tried to use the "hidden" field as a switcher in the form.

<form>
action template @@templateswitcher@@ otherns:

fieldset "New Page" /^[^\/:]+$/
textbox  "Pagename" @
textbox  "Photo" "=noimage.jpg" !
hidden "templateswitcher" "=myns:template1pic"

yesno    "Another Picture?"
fieldset "Another Picture" "Another Picture?"
textbox  "Photo 2" "=noimage2.jpg" !
hidden "templateswitcher" "=myns:template2pics"

...

Sadly, this does not work. Any idead why?

EDIT: Well, it kind of works. It only creates the page when clicking the yesno-box. Seems like the value of the hidden field is not available on page load but after clicking the checkbox once. Maybe a bug?
This post was edited on 2015-08-27, 20:07 by Urfaust.
Avatar
florious #3
User title: Floarea
Member since Jun 2014 · 15 posts
Group memberships: Members
Show profile · Link to this post
<form>
action template myns:mytemplate otherns:

fieldset "New Page" /^[^\/:]+$/
textbox  "Pagename" @


fieldset  "Upload a picture, if you want."
yesno     "Click to upload the first picure"

fieldset  "" "Click to upload the first picure"
file "Upload a file" !

hidden "acoldesch" "={{"
hidden "acolinch" "=}}"
hidden "foldedin" "=++Poza|"
hidden "foldedout" "=++"


fieldset  "Upload a second picture if you want."
yesno     "Click to upload the second picure"

fieldset  "" "Click to upload the second picure"
file "Upload second file" !

hidden "acoldesch" "={{"
hidden "acolinch" "=}}"
hidden "foldedin" "=++Poza|"
hidden "foldedout" "=++"

....

submit  "SAve"
</form>
....

Corresponding Template:
===== @@Pagename@@ =====
@@foldedin| @@@@acoldesch| @@@@Upload a file| @@@@acolinch| @@@@foldedout| @@
@@foldedin| @@@@acoldesch| @@@@Upload second file| @@@@acolinch| @@@@foldedout| @@

---------

The same thing you can do via pagemode plugin
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: 2018-12-14, 04:19:02 (UTC +01:00)