From: Patrick N. <ma...@pa...> - 2010-04-05 14:08:55
|
Hi Till, On 2010-04-05 12:24 UTC Till Kraemer wrote: > I installed Semantic Forms extension and created a template "Person" > and a property "Birthdate". > > If I enter for example "January 1, 2010", I want the template to use > that data to automatically add the following to the article: > > {{Age|2010|1|1}} > > [[Category:Born January 1]] > [[Category:Born 2010]] > > The big question is: Can I somehow use a part of the date property or > do I have to create three properties (month, day, year)? You can use the Parser Functions extension's #time function to extract date parts - for example {{#time: Y | {{{Birthdate}}} }} gives you the year. Your Age template call could then look like this: {{Age|{{#time: Y | {{{Birthdate}}} }}|...}} If you want to do direct semantic queries on those date parts, for example to show all people born between 1940 and 1950, you need to store the date parts in separate semantic properties though (Property:Birth year, Property:Birth month, Property:Birth day or something like that). I would store the date as a whole in a property (useful for sorting, showing the birth date, etc.), and in the same template I would set separate year, month and day properties (using above mentioned #date parser function, like so: [[Birth year::{{#time: Y | {{{Birthdate}}}| ]]). This will give you maximum flexibility, and you don't even need those old-fashioned year/month categories. ;) Patrick. -- Key ID: 0x86E346D4 http://patrick-nagel.net/key.asc Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4 |