Topic on Project:Support desk

Jump to navigation Jump to search

Creating category from field value

9
Ziggurat146 (talkcontribs)

I might be asking the wrong question or just simply be stuck on the wrong method, but if I have the field 'Star=' in my form to create a page titled Earth in the Planets category, how do I assign the page to a category of that field's value (in this case, Sol, so Category:Sol)? Of course the page itself is categorized under Planets automatically by way of the form, and I have also added the page to a category matching it's own name using the magic word PAGENAME, but I can't figure out how to call that Star field and turn it into a Category.

Thanks for helping a newb out!

Malyacko (talkcontribs)

What is a "form" in MediaWiki? Please provide context. Is this maybe about the PageForms extension?

2601:283:300:6470:A11F:5F52:A1C3:1648 (talkcontribs)

Yes that's right, though I think I figured it out, by using triple brackets around the field name it finally figured out what I wanted to do. Now I just have to figure out how to stop all these subcategories from showing up in a dropdown menu for pages from a specific category...

Jonathan3 (talkcontribs)

[[Category:{{{Star|}}}]]

Jonathan3 (talkcontribs)

"Now I just have to figure out how to stop all these subcategories from showing up in a dropdown menu for pages from a specific category..." Could you please describe your problem?

Ziggurat146 (talkcontribs)

Thanks for checking back with me! And no, I still haven't sorted this one out, ha. And I am indeed using the PageForms extension for all of this, btw.


To start, I have one category 'Star' which currently only contains two entries, 'Sol' and 'Alpha Centauri'. Each is a page and a category of the same name, which is then used to hold the pages and categories for subsequent planets.

For example: The page 'Sol' is in Category:Stars and Category:Sol. The page 'Earth' is in Category:Planets, Category:Sol, and Category:Earth. The page 'Luna' will be in Category:Moons, Category:Earth, and Category:Luna.

In a slightly different example, the page 'Alpha Centauri' is in Category:Stars and Category:Alpha Centauri. The page 'New Terra' is in Category:Planets, Category:Alpha Centauri, and Category:New Terra. The page 'Luna 2' is in Category:Moons, Category:New Terra, and Category:Luna 2.

And so on and so forth.


When creating new locations, I select a Star and then a Planet, but since the Planet selection only pulls from Category:Planets, it shows all planets in all star systems. So the second dropdown uses 'values from category=Planets' but I would like to somehow cross-reference with a second 'values from Category=STARNAME' so that it only pulls pages which match both categories.


The final kicker for all of this is that I will have one final form for submitting new locations, which will need to be drilled down through Star>Planet>Moon. However, there is a 'None' option for moons, so in the case this is selected the form will need to recognize that the new page needs to be in Category:PLANETNAME, and not in Category:None (for the moon selection).

Jonathan3 (talkcontribs)

I have a feeling that this whole thing could be redesigned (I haven't read through it in detail though). Have you had a look at Extension:Cargo?

Ziggurat146 (talkcontribs)

Just a little, as this wiki is hosted on a third-party site that has the option to enable the Cargo extension, but I am trying to keep the structure of the wiki as 'vanilla' as possible, if that makes sense.

As an alternative to the form with the dropdowns, I have thought about using InputBox to create quick and easy child pages, but I cannot determine a way to assign categories using an InputBox or pass parameters from the page the InputBox is on.

To be frank, I may have spent too much time on it today and it has grown late, so I'll leave it for now as everything is coming through a bit fuzzier and it's harder to switch tracks!

Jonathan3 (talkcontribs)

Definitely go for Cargo. You’re trying to create a database using categories, so might as well do it properly :-) I’ve never tried Semantic MediaWiki but that would likely work for you too. I found Cargo less daunting as it’s all in a single extension.

Reply to "Creating category from field value"