I have a mediawiki with different type of categories.
If a page has 2 categories
[[Category:Pear]][[Category:Strawberry]])
I want to add a third category
[[Category:Fruit_Salad]]
Is it possible to do that automatically? (using a bot for instance)
Edit: In fact, what I need is an API for categories
a way to read the category
a way to add a new category
The rest can be done by any program
You are probably looking for the pywikipediabot framework. (Check catlib.py for the category manipulation code, and category.py for an end-user-friendly mass category modification bot.)
Related
I want to add some recipes to a part of my Mediawiki site and have each ingredient create a relevant category.
This is easy to do by hand, but subject to human error - each ingredient has to be entered twice.
for example
* [[category:apples]] apples
* [[category:bananas]] bananas
* [[category:cherries]] cherries
This works, but I feel there should be a way to automate it however I'm not really sure of what the best way forward would be. Is there already an extension to do this (I've searched on all the terms I can think of), should I be writing a script ? Is there some other method to solve this that I should be looking at ?
You could use a template, lets call it Template:Ingredient,
<includeonly>* [[Category:{{{1}}}]] {{{1}}}</includeonly>
Then call it in your page with:
{{Ingredient|apples}}
This will both display the ingredient name and add the page to the category.
I'd like to include a table with all registered users on a page in my MediaWiki but the only user list I can find is the special page "Active users list".
Is it possible to include this (or a similar list with e.g. the entered real name) on a wiki page?
Thanks in advance for your help.
You can use the Special:ListUsers special page for this. It's a list of all users registered in your wiki.
You can include some special pages just like templates. So, to include the Special:ListUsers page on any wiki, you just need to paste the following wikitext code into the page where you want to show the user list:
{{Special:ListUsers}}
The limit for the list is 50 (iirc), so if you want to increase the length of the list, you can pass the limit parameter to the inclusion syntax:
{{Special:ListUsers|limit=100}}
However, I don't think that Special:ListUsers provides a way to show the real names of users, sorry.
How to take a list of pages which need edit based on categories and sub-categories by using MediaWiki API?
If assuming that all Wikipedia pages that need edit include Template:Cleanup, which means that all they will be placed in Category:All articles needing cleanup, to get a list of all them by using MediaWiki API you have two variants:
Variant 1: Get all articles which include Template:Cleanup with embeddedin:
https://en.wikipedia.org/w/api.php?action=query&list=embeddedin&einamespace=0&eititle=Template:Cleanup
Variant 2: Get all articles from Category:All articles needing cleanup with categorymembers:
https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmnamespace=0&cmtitle=Category:All articles needing cleanup
I'm displaying the contents of a database on a particular page(recipe names).
I'd like each recipe to be a link which opens to another page. I understand I would have to obtain the recipe id for that particular recipe, pass the id to another page and print the recipe contents onto that page. I would like to know how to retrieve the unique recipe id of a particular recipe ON BEING CLICKED upon mainly.
If you are displaying the contents of a database on a particular page, then definitely you are using a server side scripting like like ASP or PHP or some JavaScript + AJAX. I am quite unclear about that. But for your question, I can tell you one thing that, if, suppose you are using PHP, then you may display the link as;
echo ''.$recipiename.'';
where $recipeid is the variable carrying recipe id and $recipiename is the name of your recipe. In your PHP file (yourpage.php), you may catch this data like $_GET["recipeid"]
You may try a Google search for tutorials.
Use;
$strLink = ''.$strName.'';
echo "<li>".$strLink."</li>";
Don't use spaces.
You just make the id part auf the URL the recipe link points to.
Iced Water
Would be a link pointing to the recipe with ID 23. Since the url is available on the server side you are all set.
So, I’m a bit on how to use a separate table in a relationship, or something like that…
I have a table with around 5000 hotels called exp_h_hotels.
On my website, I use the pages module to create a static subpage for each part of the country. I want to list all hotels that belong to a specific region.
I have understood that I can’t do something like this (using ExpressionEngine tags with the query module):
{exp:query sql="SELECT * FROM exp_h_hotels WHERE h_regionname ='{regionname}'"}
{hotel_name}
{/exp:query}
Anyone knows the best way to go forward with this?
I have looked into using the ExpressionEngine API to insert the data into a channel – however, I get the feeling that it wouldn’t be optimal to flood the channel entries table with 5000 posts with 14-20 fields with data each.
There's no reason why this shouldn't work as you expect, so long as your exp:query tag is inside your channel:entries tag:
{exp:channel:entries channel="pages" limit="1"}
<h1>Hotels in {regionname}</h1>
<ul>
{exp:query sql="SELECT * FROM exp_h_hotels WHERE h_regionname ='{regionname}'"}
<li>{hotel_name}</li>
{/exp:query}
</ul>
{/exp:channel:entries}
However, for the long-term, importing your hotels into a new channel in EE is a much better plan. You could export from your database to CSV (using phpMyAdmin perhaps) and then import into EE using DataGrab. Nothing wrong with adding 5000 new entries to EE.