Semantic Internal Objects to Headings
Good day:
I would like to use queries to concatenate a string that includes property values so that these can function as article headings something like the following.
==={{#ask:[[Name::+]] [[NameFirst::Bruce]] [[NameLast::Wayne]] |? NameFirst }} {{#ask:[[Name::+]] [[NameFirst::Bruce]] [[NameLast::Wayne]] |? NameLast }}===
I have managed the following.
{{#set_internal:Name |[[NameFirst::]]= |[[NameLast::]]= }}
I have created the above object on a template page. I assume I have done this incorrectly, which may be my problem. I have put data into several articles to test my syntax.
- Bruce Wayne
- Bruce Banner
- Peter Parker
- Kevin Matchstick
- Clark Kent
I then query the data successfully with the query below.
{{#ask:[[Name::+]] |? NameFirst |? NameLast }}
My problem so far is that I cannot get a query to produce plain text like: Bruce
How can I achieve this?
Thank you AKSHA
Try {{#show: Bruce Wayne | NameFirst}}
.
Thanks for that very good advice. The following provided the desired output: "Peter"
{{#show:[[Name::+]] [[NameFirst::Peter]] |?NameFirst }}
The following provided the output: "Bruce Bruce".
{{#show:[[Name::+]] [[NameFirst::Bruce]] |?NameFirst }}
This confused me until I realized that my data include: Bruce Wayne Bruce Banner
Thank you, thank you.
Have you any sense why both results come with the following error message?
Error
- Some part ".." of the query was not understood.
- The symbol "[[" was used in a place where it is not useful.
- The part "]]" of the query was not understood. Result might not be as expected.
{{#show:}}
shows a property of only one page. It's {{#show:Bruce Wayne | ?NameFirst}}
, not {{#show:[[NameFirst::Bruce Wayne]] [[Name::+]] | ?NameFirst}}
. I'm surprised it worked at all. If you need more complex query conditions than page name, use {{#ask:[[NameFirst::Bruce Wayne]] [[Name::+]] | ?NameFirst#- | format = list | mainlabel=- | limit=1 | searchlabel = - | headers = hide}}
I put in the following ask and get no output:
{{#ask:[[NameFirst::Bruce Wayne]] [[Name::+]] | ?NameFirst#- | format = list | mainlabel=- | limit=1 | searchlabel = - | headers = hide}}
I think this is because no property value corresponds to “Bruce Wayne” so I change [[NameFirst::Bruce Wayne]] to [[NameFirst::Bruce]]:
{{#ask:[[NameFirst::Bruce]] [[Name::+]] | ?NameFirst#- | format = list | mainlabel=- | limit=1 | searchlabel = - | headers = hide}}
This returns: Bruce-. I want to get rid of that “-” so I experimentally remove a “-” from the query and view the page without it. This makes for an unwanted output so I edit the query and repair what I broke. Then I try deleting another “-”. This testing proves that if I remove the “-” from “searchlabel”, I get a pure property value: Bruce
{{#ask:[[NameFirst::Bruce]] [[Name::+]] | ?NameFirst#- | format = list | mainlabel=- | limit=1 | searchlabel = | headers = hide}}
Lessons learned[edit]
In an #ask the first parameters are the object you are querying and the property value you are searching for. They come before the first pipe “|”. Otherwise, place order is not a factor so the following are equivalent:
- {{#ask:[[NameFirst::Bruce]] [[Name::+]] | }}
- {{#ask:[[Name::+]] [[NameFirst::Bruce]] | }}
Many formatting instructions can apply to a single query as long as no two contradict. Each must be separated by a pipe “|”.
This solution provides a fine grained example of how to provide multiple formatting instructions to a query. It also provides a working example so that an inexperienced user can make individual changes and see the result. This helps a new user get over a number of very basic mistakes. By new user I mean myself.
Thank you for walking me through this solution Alexander Mashin.
Equipped with this example, I feel confident of making a better class of mistakes.