Posted by ErichSteinboeck on 12 May 2008 21:14, last edited by GoVegan on 09 May 2010 06:00
How to Set Up an Infobox — Exclude Specific Attributes
Follow these steps, if you'd like to set up an infobox that doesn't display those attributes that a user marks “to be excluded”. Other attributes are displayed.
Step by Step
Create an infobox template where the code for all optional attributes (those that a user might want to exclude) is surrounded by
- “[!--{$attrib}--]@@@@” (where attrib is any infobox attribute name) and
- “[!----]”,
for example:
[[table]]
[[row]]
[[cell]]**Name:**[[/cell]][[cell]]{$name}[[/cell]]
[[/row]]
[!--{$player}--]@@@@[[row]]
[[cell]]**Player:**[[/cell]][[cell]]{$player}[[/cell]]
[[/row]][!----]
[!--{$origin}--]@@@@[[row]]
[[cell]]**Origin:**[[/cell]][[cell]]{$origin}[[/cell]]
[[/row]][!----]
[[/table]]
Note:
1. The template should not contain any Wikidot comments ([!-- … --]) within the source code of an optional block (except the ones needed for the above structure)
2. The Wikidot syntax does not allow “[!--{$attrib}--]@@@@” to be specified between the [[table]] and the following [[row]] tag (in case you wanted to make the first row of a table optional). For a solution how to make the first row optional, see the Examples.
Putting “[!--{$attrib}--]@@@@” between an [[/row]] and a [[row]] tag is acceptable.
3. As the Wikidot parser will not accept an empty table (coded [[table]][[/table]]) as a valid syntax, hiding all rows will need an extra step — please see Examples for a solution.
On your including page, if you want to exclude an attribute, specify
attrib=@@
or, if you want this attribute to be displayed, specifiy
attrib=any-attribute-value
on the [[include infobox-template-name …]] tag.
Examples
What you type … | What you get … | ||||||
|
|
||||||
|
|
||||||
|
|
Need to hide first row or all rows?
If you want to
- define the first row of a table as optional,
- or you want to be able to hide all rows
the following extra step is needed: add an empty row (see code below) as the first row after your [[table]] tag. This will satisfy the Wikidot parser requirement “a table must contain at least one row” as this empty row will always be available.
[[table]]
[!-- Empty row to satisfy Wikidot parser --][[row style="display : none;"]][[cell]][[/cell]][[/row]]
Links
This is an application of the ideas presented in Include Part of a Page Only (Tricky Version)
There is also an alternative way to set up an Infobox — see Set Up an Infobox
This is How-to make the appearance of the photo automatic — see set-up-an-infobox-automatic-picture
Backlinks
Author
ErichSteinboeck. Please visit his/her userPage.
James Kanjo. Please visit his/her userPage.
I tried out this and it worked fine up to the first line in the table. I don't know what should be put in include module, because I put @@ and it does not disappear, but it stays there together with @@. Another question is: it says here that in the first line @@@@ should be in line with [!--parameter--], but when I put the [[cell]] in line with [[row]] I get spoiled infobox.
Another question is: how do I hide the table that does not contain any changeable parameters? For example, I want to hide this one:
How do I do that? Is that possible?
Here are my infobox: http://isbitestsite.wikidot.com/infobox:vladar
and the same in action: http://isbitestsite.wikidot.com/vladar
You can try out your ideas there, since the site is open for all wikidot users.
Thank you very much for your help!
Bruni
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
> it says here that in the first line should be in line with , but when I put the [[cell]] in line with [[row]] I get spoiled infobox.
I've removed the line break after [[row]] (see code below) — this made “majka” work.
> how do I hide the table that does not contain any changeable parameters?
Unfortunately the parser does not accept
as being valid. One solution would be to add an empty row
so that — even if all attributes have been hidden, the parser will still see a valid (empty) table:
A disadvantage is, that, on close inspection, you can see that this empty row introduces some small white-space. Have a look at the very bottom of the infobox. If this white-space isn't satisfactory, we'll have to think of something else — not sure yet how to do that.
Maybe you could restructure your infobox to be a single table (instead of several tables for headers and attributes)? That way, even when removing all attributes associated with one header, there would always be at least one attribute visible.
Thank you Erich, but I still see the green table with the text Породица and this is what I want to remove.
The code is:
On the other hand, I did try to make one table from these two, but somehow I cannot get the same result. If I put it in the same table, the green static line with the text Породица shortens to the length of the first cell under it. Look it now, I shall put it as one table.
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
If you want to remove the green table with the Породица text, you could just add display:none to the cell style:
which shows (you should see nothing below this except my signature):
Rob
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Yes, but then it will disappear from all the pages in which I have this infobox included, and this is NOT what I want. I want that this table be variable, too. I'll explain. This is infobox for rulers. The last part is meant for family. So, in the green line it is written Породица, which means, family. So, the variables that follow are: majka (mother), otac (father) wives (supruge) and deca (children). So, I can exclude all of them thank's to Eric's code, BUT I cannot remove the title i.e. Породица (Family), and if I remove all parameters for family, why should I keep the title Family? Then it should be removed, too, if I don't have any parameter that refers to family.
Therefore, some kind of variable should be included in divs, and also something that is conected with that variable should be added to include module in order to be able to include/exclude this part, too…. I know this far… But I don't know how to do it, and I son't know if it is possible, anyway…
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
> try to make one table from these two, but somehow I cannot
> the green static line with the text Породица shortens to the length of the first cell
The missing colspan problem. You'd probably have to use nested tables, with each header and each attribute in its own table.
For now, I've simply put Породица back into its own table.
> the green table with the text Породица and this is what I want to remove
Whatever you want to be able to hide — same procedure: you surround it with “[!--{$name}--]@@@@” and “[!-- --]”.
I've done it for you. If you'd like to hide the Породица header, use “poro=@@”. You'll need to do that manually (only) in the case you've hidden all depending attributes.
Eric, you're a genious! Thanks a lot! This is what I need, something simple and neat. Thanks again!
PS: Maybe you should add this to the instruction page….
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
Eric, I have a problem! If I want to make invisible only the first row in the table (in my table it is majka), I cannot do that. If I put in majka= I loose all other rows that are under the row majka…. Look!
http://isbitestsite.wikidot.com/vladar
Is there a possibility for this to be fixed?
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
> If I put in majka= I loose all other rows that are under the row majka
I've fixed that in your code by moving the special “empty row to satisfy the Wikidot parser” directly after the [[table]] tag.
That was an oversight (error) in my How to — I will fix that.
Thanks, Eric. I think that now it is even simpler… Now there is no need for the first row to be different.. They all have the same synatax…
Thanks again for this wonderful feature! :)
If slaughterhouses had glass walls, everyone would be vegan. - Paul McCartney
I changed the code for the "empty row to satisfy Wikidot parser" from this:
To this:
Which truly hides the first row. It is notable that this could be done in every table, regardless of whether the first row should displayed or not.
I have to say, Eric, that since you discovered the display : none; trick with spaces so that the Wikidot parser would process it, you have opened a huge world of possibilities! Thanks =D
> Which truly hides the first row
That's perfect, thanks
> since you discovered the display : none; trick with spaces so that the
> Wikidot parser would process it, you have opened a huge world of possibilities
I feel the same. I had to find a way, as I really disliked the [[collapsible show=" " hide=" "]] solutions
Anyone knows if the parser intentionally does not process display:none (if it doesn't contain spaces)?
> the parser intentionally does not process display:none
To answer my own question: Yes, the Div.php parsing code intentionally strips off visibility:hidden and display:none
$style = preg_replace('/visibility:\s*hidden;?/is', '', $style); $style = preg_replace('/display:\s*none;?/is', '', $style);
I've got no idea why.
That worries me that they may one day change the code to counter-act the bypass trick.