A while ago we silently pushed a number of new features to the Wikidot engine that allow you to create even more advanced constructs! They were first tested by some of our users (thanks!) and now they are ready be announced. Here they are!
[[div_]], [[span_]] — no extra <p> nor <br/>
A number of users pointed out that [[div]] and [[span]] elements often force additional line breaks and paragraphs when compiled into HTML. This is OK when creating text documents but it's asking for trouble when composing layouts where uncontrolled whitespace can ruin the effect. This is especially true with Bootstrap layouts.
Here is a short illustration of the change:
Before
[[span]]
[[a href="#"]] example link [[/a]]
[[/span]]
compiles to
<p>
<span>
<br>
<a href="#" target="_blank">example link</a>
<br>
</span>
</p>
After adding underscores
[[span_]]
[[a_ href="#"]] example link [[/a]]
[[/span]]
compiles to
<span>
<a href="#" target="_blank">example link</a>
</span>
See the difference? Cleaner output and more control. The carousel like the one you can see above is now much easier to type — the parser should not surprise you with extra newlines nor paragraphs now, provided you put underscores to div and span elements.
Logical and mathematical operators — [[#if, [[#ifexpr, [[#expr
When creating dynamical pages, e.g. using ListPages module it was really hard to perform manipulation on numerical values. Some of our users pointed out they could do some great stuff if we added an extra processing layer on top of the parser. So we added three new simple constructs that work like this:
This code…
[[#expr abs(-100) ]]
[[#expr min(4, 1, -4, 6, -10) ]]
[[#expr max(4, 1, -4, 6, -10) ]]
[[#expr 2*4/12-4+66%2 ]]
is [[#ifexpr 2*4/12-4+66%2 < -3.5 | less than -3.5 | greater than -3.5 ]]
[[#expr 2*(2-1) ]]
[[#if true | display if true | display if false ]]
compiles to…
-10
6
-3.33333333333
is greater than -3.5
2
display if true
Sure these expressions are of little use in static pages but they become really useful when combined with ListPages. You could then dynamically add elements (HTML classes, page elements) based e.g. on data forms attributes! See the example below how it's used to add the "active" class to the first carousel element.
Interested? Read more on our doc pages.
[[head]], [[body]] and [[foot]] in ListPages
[[head]], [[body]] and [[foot]] replace prependLine and appendLine parameters with one huge advantage: they can capture blocks of code instead of just one-line values. Here is how they work:
The new code has the form:
[[module ListPages wrapper="no" separate="no"]]
[[head]]
[[ul]]
[[/head]]
[[body]]
[[li class="list-item"]]%%title_linked%%[[/li]]
[[/body]]
[[foot]]
[[/ul]]
[[/foot]]
[[/module]]
This is equivalent to the previously known form:
[[module ListPages wrapper="no" separate="no" prependLine="[[ul]]" appendLine="[[/ul]]"]]
[[li class="list-item"]]%%title_linked%%[[/li]]
[[/module]]
Note that prependLine and appendLine are inline parameters and can only contain a single line of code. The newer form, although requires more typing, allows several lines of wiki code in header and footer of ListPages. Both appendLine/prependLine and foot/head will continue to be supported, so if you are fine with one-liners you do not need to change your habits.
For more details see ListPages reference docs.
Let's put it together — a dynamically created carousel
The above changes should allow creating much more advanced constructs, e.g. using the Bootstrap carousel. The example below uses three new features, namely:
- [[div_]] to create block elements with clean layout,
- #ifexpr expression to add the "active" class to the first pane and #expr to bind nav elements to panes,
- ListPages with [[head]] and [[foot]].
We will use DataForms to provide content for carousel panes too.
To manage the carousel we created a simple page at http://forms.wikidot.com/carousel:_template containing the following code:
%%form_data{source}%%
----
[[button edit text="Edit" class="btn btn-primary"]] [[button delete text="Delete" class="btn btn-danger"]]
====
[[form]]
fields:
source:
label: Source/Description
type: wiki
active:
label: Active
type: select
values:
yes: yes
no: no
[[/form]]
One could set the category as private which would allow only admins to modify content of the carousel. This would prevent other users from seeing the pages. Actually they do not need to — their content will only be displayed via the ListPages module.
To make viewing and adding new content easier we created an extra "management page" at http://forms.wikidot.com/carousel:_manage
[[module ListPages category="carousel"]]
%%title_linked%% (active: %%form_data{active}%%)
[[/module]]
[[module NewPage category="carousel" button="Add"]]
Next we put a few pages to create content to work with.
Finally we created a new page at http://forms.wikidot.com/carousel:_example and pasted the following content:
[[module css]]
#u-carousel .carousel-inner {
background: #888;
border-radius: 20px;
}
#u-carousel .item {
text-align: center;
height: 200px !important;
}
#u-carousel .carousel-control.left {
border-radius: 20px 0 0 20px;
}
#u-carousel .carousel-control.right {
border-radius: 0 20px 20px 0;
}
[[/module]]
[[div_ id="u-carousel" class="carousel slide" data-ride="carousel"]]
[!-- Indicators --]
[[module ListPages category="carousel" wrapper="no" separate="no" _active="yes"]]
[[head]]
[[ol_ class="carousel-indicators"]]
[[/head]]
[[body]]
[[li data-target="#u-carousel" data-slide-to="[[#expr %%index%% - 1 ]]" class="[[#ifexpr %%index%% == 1 | active ]]"]]@< >@[[/li]]
[[/body]]
[[foot]]
[[/ol]]
[[/foot]]
[[/module]]
[!-- Wrapper for slides --]
[[div_ class="carousel-inner"]]
[[module ListPages category="carousel" wrapper="no" separate="no" _active="yes" order="random" limit="5"]]
[[div_ class="item [[#ifexpr %%index%% == 1 | active ]]"]]
[[div_ class="carousel-caption"]]
+ %%title%%
%%form_data{source}%%
[[/div]]
[[/div]]
[[/module]]
[[/div]]
[!-- Controls --]
[[a_ class="left carousel-control" href="#u-carousel" role="button" data-slide="prev"]]
[[span class="glyphicon glyphicon-chevron-left"]]@< >@[[/span]]
[[/a]]
[[a_ class="right carousel-control" href="#u-carousel" role="button" data-slide="next"]]
[[span class="glyphicon glyphicon-chevron-right"]]@< >@[[/span]]
[[/a]]
[[/div]]
That's it! Try it yourself — just go to http://forms.wikidot.com/carousel:_example to see the carousel in action. You can also add new elements at http://forms.wikidot.com/carousel:_manage. The carousel will display content random from five pages.
Hopefully the new improvements will allow even more advanced layouts and content. Take care!
Image credits: Mikael Miettinen, Barron Fujimoto and Hubert Yu, licenced under CC-2.0.
Thanks Michal,
for the new implementations and also for the information, what was going on in the last weeks in / on wikidot development. We all are/were waiting for communications what are you and your team doing in the development…
At the moment I am a litle astonished and I am thinking now about the changes which are now possible and where ( with the new span_ : easier "hoover"ing, with the expressions and if's: activ reactions on ListPages results?).
Lot of work to try on the communiy-playground & snippets!
Question: are now with the new "if's" also diffrerent includes in the life situation possible ( if a mobile… than include module-css else standard-css) ?
Well done , team!
Service is my success. My webtips:www.blender.org (Open source), Wikidot-Handbook.
Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?
Nice to hear you've been busy developing, there was recently some discussion about what the devs have been up to lately.
Could the test users post some more practical examples of the new functionality here?
___TTT___/ http://www.trumpetexercises.net
(_|||_) \ - Janne
Practical examples :)
http://blog.shane-smith.com/blog:wikidot-expressions
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Wow Thanks for this post! Good info and really amazing features.
Regards.
Great, thanks for updates! I am really glad that you constantly improve your services.
I expected more about this update. It's good that it was introduced but I thought that this update change more.
excellent. keep up the good work
Wow Thanks for this post! Good info and really amazing features.
Regards.
Thanks excellent work
Do these codes still work because i can see it is quite old.
my blog
Best Regards