Creating new content (tables) through other tables
Thanks for the quick reply,
yes I am using templates for the projects (not for the tables yet since I didnt know how to create n+1 tables as of yesterday since I found this extension)
but it shouldnt be a problem to change the projects.
the template looks like that for now:
{{Movies |Picture= |Title= |Original Title= |Release= |Bluray= |Trailer= |Dubbing Studio= |Dialogue Script= |Dialogue direction= |Description= }}
and then I am adding the tables by hand
{| class="wikitable sortable" |- ! scope="col"|Actor ! scope="col"|Role ! scope="col"|Voice Actor |- | [[Actor 1 ]]||Role 1||[[Voice Actor 1]] |- | [[Actor 2 ]]||Role 2||[[Voice Actor 2]] |}
Hi Clemonde, Alexander made a mistake, probably by accident. Don't use #set for subobjects but #subobject, which is documented here.
You can define template {{role}}
like this:
<tr><td>[[{{{Actor|}}}]]</td><td>{{{Role|}}}</td><td>[[{{{Voice actor|}}}]]{{#subobject: | Project = {{FULLPAGENAME}} | Role = {{{Role|}}} | Actor = {{{Actor|}}} | Voice actor = {{{Voice actor|}}} }}</td></tr>
and call any number of times it on any project page between <table class="sortable wikitable"><thead><tr><th>Actor</th><th>Role</th><th>Voice actor</th></tr></thead><tbody>
and </tbody></table>
.
These table header and footer can also be wrapped in a template {{roles}}
: <table class="sortable wikitable"><thead><tr><th>Actor</th><th>Role</th><th>Voice actor</th></tr></thead><tbody>{{{1|<tr><td colspan="3">put one or more role templates here</td></tr>}}}</tbody></table>
.
Or better, create a Lua function that can accept a variable number of arguments.
before I can can even start testing:
maybe I am just too stupid for the basic installation of semantic mediawiki ...
do I need to install composer on my server where the wiki is located or on my local machine?
Maybe I should use the tarball method :D
The recommended way to install SMW is with composer, yes. The second best (I hope it is still working) is with git, although it will not take care of the dependencies. Downloading tarball will make upgrading difficult.
Composer is the recommended installation method (this is to ensure that dependencies as specified are loaded and not added by random selection or version).
I would not recommend git unless you are a developer or know what you are doing (if we change dependencies then this will have to be taken care of by the user him(her)self, and we do change dependencies).
Tarball is another option but if a new release occurred then you need to replace files in the extension and vendor directory to update all dependencies deployed by the new tarball.
> do I need to install composer on my server where the wiki is located or on my local machine?
Please have look at Help:Composer#Individual_file_release.
dear Alexander Mashin, could you show me the {{{role}}} and {{{roles}}} templates with an example in wiki please?
btw the ask function does work perfectly:
{{#ask: [[Actor::{{{Actor|+}}}]] | mainlabel=- | ?Year | ?Project | ?Role | ?Voice Actor | format = sortable | sort = Year | order = desc }}
btw you can use "nocinclude" to make it look like I did
and is it possible to set a width for the output-table?
I have not created those templates in any wiki. You could just copy the wikitext for them that I wrote in one of my previous replies.
As to table's width, you can use widetable format or set the table width for .smwtable class with site-wide CSS in MediaWiki:Common.css.
adding
.smwtable { width: 650px; }
in the Mediawiki.Common.css works like a charm
, and is no wikicode, is it?
It's plain HTML, which is also allowed in wikis. You can try to use equivalent wikicode, but there might be issues while assembling a table from several templates. You may need to screen pipes (|
→ {{!}}
) and carefully avoid extra spaces.
I've got the link to this community-portal from Clemonde and tried it on a fresh mediawiki with smw extension.
My sobobject tuples look like this.
{{#subobject: | Project = {{FULLPAGENAME}} | Year = 1995 | Role = Det. Mike Lowrey | Actor = Will Smith | Voice Actor = Leon Boden }} {{#subobject: | Project = {{FULLPAGENAME}} | Year = 1995 | Role = Det. Marcus Burnett | Actor = Martin Lawrence | Voice Actor = Torsten Michaelis }}
The following statement made it possible to put these subobjects in one table:
{{#ask: [[Actor::{{{Actor|+}}}]] | mainlabel= - | ?Actor | ?Role | ?Voice Actor | format = sortable | sort = Year | order = desc }}
What exactly does [[Actor::{{{Actor|+}}}]]
do? I red the user-manual but could not figured it out properly
I tried to write two actor/voice-actor/role tuple in one subobject. But as a result the site of the Actor/Voice-Actor did show all tuple and not just the one WHERE Actor.Name = Will Smith
The ask command in the actor template:
{{#ask: [[Actor::{{FULLPAGENAME}}]] | mainlabel=- | ?Year | ?Project | ?Role | ?Voice Actor | format = sortable | sort = Year | order = desc }}
Is there an easy way to fill the project table manually (by hand) and extract the needed data in the pages of Actor/Voice actor? A subobject for every tuple is a bit overwhelming.
Maybe a pseudo SQL statement helps:
SELECT Actor.Name, Role.Name, VoiceActor.Name FROM Project WHERE Actor.Name = Will Smith
> What exactly does [[Actor::{{{Actor|+}}}]]</code> do?
This is the
WHERE
clause of the query.
My example assumes that the
{{{#ask:…}}
statement is used on the template called, say Template:Actor's roles
, which receives Actor
as an argument: {{Actor's roles|Actor=John Smith}}
.
If
Actor
is not given ({{Actor's roles}}
), +
will be used to choose all role subobjects where Actor property is set.
Another possible solution is to use the page title as the default value for
Actor
argument: [[Actor::{{{Actor|{{FULLPAGENAME}}}}}]]
. In this case the template call on a page about an actor will look simply like this: {{Actor's roles}}
.