Demo VisualData 1.0
/ Dependent values
Editing
Demo VisualData/Dependent values
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
The following form demonstrates the use of VisualData to query and record dependent values (the classical case is the country-state-city relationship) and to easily create and store them on your wiki through a couple of maintenance scripts. It uses the schema [[VisualDataSchema:Dependent_values]] created through the Schema Builder (see special page [[Special:ManageSchemas]] then open the schema "Dependent values"). {{#visualdataform: Dependent values |title = Dependent values |action = create |edit-page = |return-page = |view = inline |popup-size = medium |css-class = |pagename-formula = |edit-freetext = false |edit-categories = false |edit-content-model = false |default-categories = |default-content-model = json |layout-align = top |popup-help = true |submit-button-text = |layout = tabs |submit-button-text = |validate-button-text = }} The first field (country) is a OOUI DropdownInputWidget with items taken from the template [[Template:Countries]]. The second field (state) is a LookupElement with query <pre> [[name::<country>]][[states/name::<value>~]] </pre> where <code><nowiki><country></nowiki></code> is the name of the first field and <code><nowiki><value></nowiki></code> is the value being inserted in the input.<!-- Note that the field names if nested have to be expressed using a path, for instance -->. The requested printout is <code>states/name</code> that matches the path <code>properties/states/items/properties/name</code> in the schema [[VisualDataSchema:Country]]. (where only relevant property names have to be concatenated, leaving aside <code>properties</code> and <code>items</code> that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property <code>name</code> equal to the value of the first field, and value of the property <code>states/name</code> equal to the state input value. The third field (city) uses this query <pre> [[name::<country>]][[states/name::<state>]][[states/cities/name::<value>~]] </pre> The query as above will search json data related to the schema "Country" with value of the property <code>name</code> equal to the value of the first field, value of the property <code>states/name</code> equal to the second field, and value of the property <code>states/cities/name</code> equal to the city input value. The requested printout in this case is <code>states/cities/name</code>. '''The query searches within a database of [[Data:Countries|250 wiki pages]] with json content model like [[Data:Countries/Afghanistan]], containing more than 620,000 entries in total.''' The database can been created downloading this data [https://github.com/dr5hn/countries-states-cities-database/blob/master/countries%2Bstates%2Bcities.json countries%2Bstates%2Bcities.json] from [https://github.com/dr5hn/countries-states-cities-database github.com/dr5hn/countries-states-cities-database] and then importing them on your wiki using the following maintenance command: <pre> php extensions/VisualData/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot </pre> The script takes only a few minutes to create all the required entries (including the related schema if it does not exist) and the data can be rebuilt any time through the following command: <pre> php extensions/VisualData/maintenance/RebuildData.php </pre> This is the wikitext used to create the form itself: <pre> {{#visualdataform: Dependent values |title = Dependent values |action = create |edit-page = |return-page = |view = inline |popup-size = medium |css-class = |pagename-formula = |edit-freetext = false |edit-categories = false |edit-content-model = false |default-categories = |default-content-model = json |layout-align = top |popup-help = true |submit-button-text = |layout = tabs |submit-button-text = |validate-button-text = }} </pre> Have fun using your wiki as an open-source database management system !! == See also == {{Demo VisualData footer}}
Summary:
Please note that all contributions to Wikisphere may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Wikisphere:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Template:Demo VisualData footer
(
edit
)
Navigation menu
Personal tools
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
Edit data
View history
More
Delete
Move
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information
Browse subpages
VisualData
New article
Browse data
Subpage navigation
Browse subpages