The more recent versions of MediaWiki no longer include skins/common/shared.css. By copying bits from the old shared.css into my custom skin, I can regain things like the float property.
I can find the old wikitable code, but I can't seem to make tables sortable in my custom skin. The sortable table code works fine when viewed with the Vector skin.
This leads me to believe I ought to be able to find how the sorting works somewhere in the Vector skin files, but I haven't had any luck so far. Does anyone know where I can find the code that will allow me to use sortable tables in my custom skin?
Edited to add: I have found jquery.ui.sortable.js in resources/lib/jquery.ui, but I have no idea what to put into my custom skin's code to refer to that and make table sorting work.
In recent releases of MediaWiki, you just have to use the "wikitable" class together with the "sortable" class.
Example from the manual:
{| class="wikitable sortable"
|-
! Fruit !! Price
|-
| Apples || £0.95
|-
| Oranges || £0.85
|-
| Pears || £1.15
|}
Related
I was thinking about creating different templates for products (not with different features but with different html organization and css) because the standard "pic on the left and data on the right" is not enough for a well-made user-centered ecommerce.
I tried the custom post types but they are blog post and can't access the product data.
in my custom product.conf i added my custom post data
"acceptTypes" : ["store_item", "custom-product-item"]
but obv. it won't work.
maybe if I could access the store_item could be easier to do this, but i can't find on the repo.
anyone has some suggestion?
Unfortunately, although it used to be possible to create custom post type products, that stopped being possible within the last year or so.
If you want to create your own template for products, you need to override the products.list and/or products.item files with your own. By placing them within your /collections folder, it will override the system default ones.
That means you have to write it entirely from scratch. Here are a couple resources that may help (despite being outdated):
http://www.bcarroll.us/developer-platform-tutorials/2014/10/20/products-pages
https://answers.squarespace.com/questions/57343/productsitem-for-adirondack-template.html
Having overridden products.item, if you want to have different templates for different products, you can do something like:
{.equal? item.urlId "myurlid1"}
{#|apply products1.block}
{.or equal? item.urlId "myurlid2"}
{#|apply products2.block}
{.or}
etc.
I've a question about Drupal 8, again and again and again...
Today, I've two views displayed on my front page and this two views display two differents informations types (in the first : Last articles in a caroussel, in the second : Recents events like a calendar with date and little description).
So, I would like to know if it's possible to template those views differently (two types) ?
Template those with preprocess functions ?
Or
Template those with templates files and template each field of those views ?
If your template is not complex, you can simply add in your views a field of type Custom text.
In there you can write HTML, use your fields (replacement patterns) and even use twig for custom logic.
*Make sure you have all the fields you need hidden.
*Make sure the field "Global: Custom text" is the last field in the list.
Another way is to create a theme by following the naming convention (see the docs here
I'm building a mediawiki infobox. I'm using the standard table based infobox as opposed to importing the various templates and CSS functionality, and extensions that Wikipedia is now using.
One of the fields in the infobox is a link to various wiki categories. I'd like to keep the linking code in the template, so the source article can just list the category names as perameter values for the infobox.
For example, my template currently contains
<tr>
<th>Some Categories</th>
<td>[[:Category:{{{category_name}}}|{{{category_name}}}]]</td>
</tr>
This works fine if I enter the category name on the source article in my infobox declarations as:
| category_name = Cat-1
In this case, the article displays an infobox, with a link to the Cat-1 category.
However I can't find how to include multiple category entries in the source article, and allow them to link to each one separately. The articles which use this infobox can have from one to eight of these categories to declare.
Do I need to import all of the wikipedia style CSS infobox templates in order to achieve this, or can it be done with a simple table-based infobox?
You will need to add as many template parameters as the maximum number of category names you want to pass to the template and to test for their being defined
So your template code might be something like
<td>[[:Category:{{{cat1}}}|{{{cat1}}}]]<!--
-->{{#if: {{{cat2|}}} |, [[:Category:{{{cat2}}}|{{{cat2}}}]] |}}<!--
-->{{#if: {{{cat3|}}} |, [[:Category:{{{cat3}}}|{{{cat3}}}]] |}}</td>
Etc. This was a common strategy before the Scribunto/Lua templates, which can just loop through data.
(For the downvote: the reason I am asking on Stack Overflow is because this is a problem involving "programming" with MediaWiki's template system)
I am looking for a way of including data on a MediaWiki article page, such that the data values can be referenced from other pages as well, without needing to duplicate the data on the other pages. Preferably without installing extra extensions.
What I am after is the ability to create an article page that looks like this:
<!-- This page is 'Example' in the main namespace -->
{{Infobox
| CreationDate = 2015-01-01
| CreatedBy = John Smith
}}
This article is about the item created by {{d|CreatedBy}}.
When this page is viewed in the browser, it should appear like this:
+------------------------+
| Example |
| Created on: 2015-01-01 |
| Created by: John Smith |
+------------------------+
This article is about the item created by John Smith.
And then on another page, I can reference the data in the above 'Example' page, like this:
* Example created by {{d|Example|CreatedBy}} on {{d|Example|CreationDate}}
Which will appear like this:
* Example created by John Smith on 2015-01-01
The typical use for this is to place the data on the article page, then be able to provide lists which are richer than you can achieve by using categories. Currently all the data on the lists is duplicated, so if it is ever changed it needs to be updated in two places - both within the article and in the "rich list".
I think I have worked out how to do this. Firstly, the correct solution seems to be to use Semantic MediaWiki, an extension designed for using MediaWiki for data storage. However in normal MediaWiki, this can be achieved as follows.
Page Template:D:
{{#if:{{{2|}}}|{{:{{{1}}}|{{{2}}}}}
| {{:{{FULLPAGENAME}}|{{{1}}}}}
}}
This allows {{d|Page|Field}} and {{d|Field}} to work as in the original question.
The infobox code also needs to be changed so that it is surrounded by this:
{{#if:{{{1|}}}|{{#ifeq:{{{1}}}|_valid|1|{{{{{{1}}}|}}}}}|
<!-- Existing infobox goes here -->
}}
This makes the infobox data-enabled. It means you can treat pages with one of these infoboxes on it as a template, and include it in another page. This is what Template:D does - it includes the whole article as a template, and this bit of code in the infobox ensures that instead of the entire page content being included at the Template:D point, only the field of interest gets included.
It also adds a special field called _valid with a value of 1 which can be used to detect pages that contain a valid infobox or not. If you make sure {{d|Pagename|_valid}} is equal to 1 (e.g. with {{#ifeq:...}}) before using any fields on that page, then you will get correct data. This is important because if the page you are using does not have a data-enabled infobox, then each Template:D occurrence will embed the entire contents of the page!
Last of all, each infobox has to be changed to be entered like this:
<onlyinclude>{{My Infobox|{{{1|}}}
| Field1 = Value1
| Field2 = Value2
| etc.
}}</onlyinclude>
This is required because MediaWiki can't embed <onlyinclude> tags within templates. The |{{{1|}}} at the end of the infobox name is used to pass the field parameter from Template:D through the article page and onto the infobox template itself.
Here is a working example of this:
Template:D
Data-enabled Infobox
List of pages, with content extracted from each page's infobox - note this page uses a custom {{#foreach:}} command to repeat wikitext for each page in a category, where {{#i:}} is replaced with the name of the page in each loop iteration. So {{d|{{#i:}}|Example}} is used to extract the Example field from the page in the current loop iteration.
I would like to allow users to create content for their own languages. I am running a single MediaWiki instance, so I cannot set it up for one language per install.
I would like to try and format the pages like the following, where a different language version of the page has the language code appended to it.
myWiki/SomePageContent
myWiki/SomePageContent/de
myWiki/SomePageContent/fr
How can I ensure users follow this structure? Is there some setting in MediaWiki that can help with this? I have no idea what are best practices for this.
Thanks!
Best practices are to use a separate instance of MediaWiki for each language and use interwiki links to connect them. This way, users are in one language and everything works as you'd expect: if you're in the English instance, a link to [[Foo]] stays in English, and only a link to [[fr:Foo]] goes to the French Foo. It's not particularly hard to set this up even with a single server and single database, see http://www.mediawiki.org/wiki/Manual:Wiki_family. The way this appears to the user is configurable: eg. Wikipedia uses http://en.wikipedia.org/wiki/Paris, Wikitravel uses http://wikitravel.org/en/Paris.
If this is not possible for whatever reason, the next best thing to do is to set up a separate namespace for each language (eg. "de" or "fr"), and this way you can at least do eg. searches across one (or more) languages. However, users of languages other than the 'main' language still have to manually punch in the language code in front of every article name and link, so it's not nearly as user-friendly. See http://www.mediawiki.org/wiki/Manual:Namespace.
An easier way for smaller wikis is through the use of a simple template. It may not be as efficient as an extension or creating a family of wikis, which is a lot of work, but quite fast to set up.
Create a page under Template:Otherlang with the following code:
{{otherlang
|ru=Template:Otherlang:ru
}}
This template adds available translations for the page to the top through the use of flags.
To prevent issues, this template must be placed '''at the very beginning of a page'''.
Tip! When contributing a new translation to a document that already has other translations, please carry over the existing translations to the otherlang template of your contributed page. This way all multilingual pages are linked.
== Syntax ==
{{otherlang
| noborder=true (OPTIONAL)
| title=localized page display title
| lang=page:lang
| lang2=page:lang2
| etc...
}}
Warning! Do not include the language of the current page. This will only confuse readers.
=== Example ===
On a page called [[Template:Otherlang]]:
{{otherlang
| title=Template:Otherlang
| ru=Category:Programming:ru
}}
Note that:
* The language "en" is not included, as it is the language of the page that template is being used on.
* title is assigned the translated name of the page, and will appear as the display title (heading) for the page. This can replace the existing {{wrongtitle}} and {{DISPLAYTITLE}} templates currently in common use.
* The English page has no suffix.
== Available Languages ==
{| class="table table-bordered" border="2" cellpadding="7"
! Language
! Syntax
! Result
|- id="en"
|English
|en=Page_name
|[[File:En.png]]
|- id="ru"
|Russian
|ru=Page_name:ru
|[[File:Ru.png]]
|}
{{#if: {{{title|}}} | {{DISPLAYTITLE:{{{title}}}}} }}{{#if: {{{en|}}} | '''[[File:En.png|alt=English|link={{{en}}}]]''' }} {{#if: {{{ru|}}} | [[File:Ru.png|alt=Русский|link={{{ru}}}]] }}
Then within each English article, paste use the following code to get a flag to show up, representing the respective language.
{{otherlang
| title=Tutorials/Galacticraft Getting Started Guide
| ru=Tutorials/Galacticraft_Getting_Started_Guide/ru
}}
An example of this can be found here. If you click on the Russian flag to the right you will find a Russian translation of the article.
anyone interested, you might wanna try this
http://www.mediawiki.org/wiki/Help:Extension:Translate
when this page
myWiki/SomePageContent
is translated to German, it will create the link like this:
myWiki/SomePageContent/de
and so on :)