Is there a way to automatically create categories from a list of items? - mediawiki

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.

Related

Retrieve Assortments (Dutch: "Assortimenten") on Exact Online

For a CSV dump of articles with stock and price information from Exact Online, I need to restrict the list of articles the CSV to articles in an Assortment (Dutch: "Assortiment").
The REST-APIs do not seem to offer this information. It is possible to retrieve Item information, but the assortment is nowhere to be found:
select * from exactonlinerest..items
It seems weird that it is missing from the APIs. Assortments are used often on Exact Online.
An alternative might be to maintain a separate table in addition to Exact Online for assortimenten (assortments).
Or is there a better approach?
You can use the XML API better:
select * from itemcategories
But note that the fields have a totally different naming style, since the XML APIs have typically very long column names. For item code, it would be ITEM_CODE_ATTR.
The GUIDs are only present in some weird text format {GUID}, so remember to remove the { and } first.

Retrieving id from database displayed and passing onto other page

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.

Best way to use a custom table in a relationship (in ExpressionEngine)?

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.

How can I get an array with the names of all defined categories?

I need to retrieve an array with category names.
It seems that tag names and category names are both stored in the same table (wp_terms), and to distinguish them you need to look in the wp_term_taxonomy table where the IDs from wp_terms are listed with options post_tag or category.
So I need to do some sort of relation query which, to be honest, is more than I can handle at this point. I did find that apparently there is some sort of a short cut to this. I haven't been able to find a good description of the function, but if you consider this: $wpdb->categories->cat_name` you may know what it's all about. I certainly don't.
How do I get an array with the names of all defined categories including nothing else?
You can use get_categories for this.
http://codex.wordpress.org/Function_Reference/get_categories
This will fetch all categories
get_categories(array('hide_empty' => 0));
http://codex.wordpress.org/Function_Reference/get_categories
I find the documentation to be quite good actually.
edit:
if you just need it for a static menu use the menu panel, add support for it in your theme first:
add_theme_support( 'menus' );
I would have thought using get_categories(); would work for you. The documentation in the codex seems pretty straight forward. You can see exactly how get_categories() is used with wp_list_categories()
A lot of times when I can't find the right documentation for it, I just google something like "Worpdress Codex Get 'xxx'" and I can find what I need.
Let us know if get_categories() works for you.
http://codex.wordpress.org/Function_Reference/get_categories

bot to edit mediawiki categories

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.)