MediaWiki : is it possible to add an edit link in a template? - mediawiki

I have a template on my wiki, kind of a box template.
Then, there is this page where I use it several times.
Can I add an edit link to each of the boxes so I don't have to edit the whole page in order to modify one of the boxes?
The boxes contain only text, not other templates.
Thanks!
Edit: Actually there's an easier way to ask my question:
Let's say I have a page without sections defined (namely without == titles ==):
content A
content B
content C
Is there a way to open an edit form only for content B?

"Is there a way to open an edit form only for content B?" - in standard mediawiki - no, but you can do sth like this
Main page will look like this:
{{/subpageA}}
{{/subpageB}}
{{/subpageC}}
subpageA will contain link to edit subpageA etc
But it is worse than sections in every possible way.

If I understand your question, and I'm not sure I do, I'm assuming your box is a div or table of some sort? If so, you could add id="{{{1|Some identifying parameter}}} to it.. Now, similar to if you had used == header 2 == you will be able to link to that section of the page with [[{{PAGENAMEE}}#{{{1|Some identifying parameter}}}]]. The only trick is to edit that section. You would likely have to set up a <span class=plainlinks>[http://somewiki.com/edit/{{PAGENAMEE}}&section={{{1|Some identifying parameter}}}]</span> Although, I'm not sure using the section name will work on your wiki, it works on only one of four that I edit. The other three require the section number, which may be harder to figure out, or at very least is beyond my pay-grade atm..

Not sure what you're asking here. Do you want to edit the template from the referring page?
Update:
One: The ugly but simple solution:
Add the following code above the text you want to edit:
=== ===
This will create a section with no name, but with an edit link. If you make four or more of these links, you will create a TOC in the page. You can suppress this with:
__NOTOC__
Two: The neat but extensive solution:
Make your wiki semantic and use Semantic_Forms to edit the page using a form.

Not with the standard installation.
But, I'm sure you could write an extension to do this. Eg. Right click on the page and it will start editing there.

It is possible to add link to edit template, so you can make ugly hack and create separate templates/subpages for every single box.

Related

Mediawiki get Content from one page to another

I searched way too long to find an answer to this problem, but I keep finding the wrong things.
My problem is I need to extract content from page A by writing code on page B.
So, for example, I have Page A with the content:
here is some text
and on page B my code is something like:
getcontent(Page A)
and it shows:
here is some text
Obviously I will work with that output, but for now, I just need to transfer the content.
Thanks in advance
The answer was provided by Tgr in comments and it was Title:getContent().
You can transclude a page with the same syntax as a template call, just put a : before the page title (that represents "main namespace"):
in page B:
{{:Page A}}

Changing page title as it appears in MediaWiki category

I've been trying to use DEFAULTSORT to sort pages based on a template parameter instead of the page title. This is how it appears at the top of the template:
{{DEFAULTSORT:{{{Username}}}}}
This is how it appears after the argument is transcluded:
{{DEFAULTSORT:d3xus}}
It would be nice for it to appear in categories as d3xus and not D3xus. There's no change in how the page is sorted because they both begin with the same symbol. Using an extension or magic word, is it possible to change how a page appears when viewed in a category? DEFAULTSORT only changes how the page is sorted with respect to other pages in the same category, but it does not change the page title in the category.
That's actually impossible without a bigger change in the code. There is a task for it in Wikimedia's bug/feature tracking software Phabricator: T19212, but it's actually stalled :(
There is no such thing. If you want to change the page title regardless where it is displayed, you can use $wgCapitalLinks or {{DISPLAYTITLE}}.
Actually it seems there is such a thing: Extension:Semantic Title. It is very hacky though (and you need to install Semantic MediaWiki).
Try this:
Method 1: Add to your MediaWiki site: {{DISPLAYTITLE:d3xus}} and [[Category:d3xus]].
Method 2: https://www.mediawiki.org/wiki/Extension:Semantic_Title

Conditional contact formula (in Wordpress)

I've Googled around for about an hour, without luck.
I'm trying to build an advanced contact formula i a Wordpress environment. The contact formula should do this:
At first, there should only be a single dropdown-menu available, like this:
Option1
Option2
Option3
If 'Option1' is selected, then some information should be shown, and then another dropdown-menu is shown, as such:
Option4
Option5
Option6
If 'Option2' is selected, then it should again show some information, but then show three other options, like this:
Option7
Option8
Option9
And so on. Many survey-formulars are built in this way - but I need to make it, to make a support-site for some different products.
I tried Googling for Wordpress-plugins, but without any luck (I must admit, I'm unsure of, what I should search for). I've used Wufoo-formula's before, but it doesn't appear to me, that Wufoo has that option.
How is this made the easiest and the best? Hand-coding it using HTML, javascript and CSS? Or are there a cool online-tool that I'm unaware of?
I had the same problem and made some research, which ended up in some results.
1. Buy the required functions
If you have a great number of forms to create and the money to invest, you could use something like Ninja Forms and buy the Conditional Logic plugin. With this you can create multiple forms and connect their elements with the needed criteria to show or hide them or to change their values.
https://ninjaforms.com/extensions/conditional-logic/
2. Code the form
Actually we have only one form we use. This is the reason, because I decided to save my money and did it myself.I expanded our wordpress theme by another page template and created the form that fits our needs in it. After that I added the PHP code to send the form via email on the top and the JavaScript code for the conditional logic on the bottom of my php file. In Wordpress I created a new page and applied the newly created page template.
I'm not sure if this is best practice, but for me it was an easy way to achieve my goal and save some time.
Best regards

Headings created inside of a template

I have a number of templates that create headings based on a formula. I am wondering if there is anyway to create an "edit" link that will take you directly to that section? The way that it currently works, the edit link takes you to editing the template itself. Could I possibly create a customized link that would keep you on the page and take you to right part?
Here is some sample code to help clear things up...
Template:Head:
==={{{1}}}===
This is a heading titled "{{{1}}}"
Test Page:
=Section 1=
{{head|1.1}}
{{head|1.2}}
{{head|1.3}}
=Section 2=
{{head|2.1}}
{{head|2.2}}
{{head|2.3}}
At the moment, if I want to edit the information for template "2.3", I have to edit all of section 2. (Note that for this example, that isn't a big deal. For the actual templates I am working with on my site, the templates have dozens of parameters and there are sometimes 10 or more in a section.)
Bottom line, is there way to create a custom edit link inside of the {{head}} template that would take you directly to editing the templates call on the page "Test Page"? Hope that makes sense.
Edit: Is there perhaps a way to make use of "anchor" tags? Can anchors be passed in to the URL?
To restate your problem, when you transclude a section heading the header isn't treated as being part of the destination page, so the edit link takes you back to the source. So you need a separate container for the template in order to edit it individually, and a complete section is the smallest editable container.
The only way I can think of doing this is using subpages (or virtual subpages if you don't have that ennabled in this namespace, doesn't change anything). So instead of placing {{head|1.1}} on MyPage, put it on MyPage/Subpage1 and then transclude that into MyPage in the usual way ({{:MyPage/Subpage1}}).
{{head}} can then include a custom edit link to the template input by using HTML heading tags (<h2> is equal to ==, etc.) to suppress the standard edit link and then use one of these templates (probably {{ed right}}) to create a custom edit link pointing to MyPage/Subpage1.
The way to create anchors in Mediawiki, by the way, is to use a <span id="name"/> tag, but that doesn't create a container that can be edited (or at least, not that I've been able to work out through URL tinkering).
I'm pretty sure there's no way to do that. As far as MediaWiki's section editing feature is concerned, the only thing that begins a new section is a line of the form:
=== Some text here ===
with the number of = signs determining the level of the heading. There's no way to get MediaWiki to let you edit any segment of the document that doesn't begin and end with such a line (or the beginning or end of the page).
Well, OK, I'm sure you technically could do it with an extension, in the sense that you can do anything with a MediaWiki extension. All you'd need to do is provide some way (e.g. a special parameter in an edit URL) for to user to indicate "I want to edit this template", then extract the template from the wikitext, present it to the user for editing, and write the result back into the page text over the original.
The tricky part will be extracting the template from the page source. (Finding and replacing templates on a page is a fairly common task for MediaWiki bot writers, so you might want to look for ideas there.) Whatever method you end up using for that, there will probably be edge cases where you need to give up and tell the user "Sorry, but I can't figure out how that template is transcluded here."

How do I get table-like formatting in a textbox or textarea?

I'm using TinyMCE textareas or textboxes for an event logger app, and I need the text to be formatted a certain way. Something like this:
I can't figure out how to do this without a table, which I cannot nest in the textarea or textbox. Any suggestions?
You cannot -layout- content in a textbox or textarea. You want to either go for TinyMCE as an iframe (where layout is broken relatively easy), or create separate inputfields for dates and logs (and layout using html/css).
TinyMCE has a table plugin that you can use. Have you tried that?
Search for "tinymce table plugin". Your example seems to be a 3x2 table.
You may also want to look into the TinyMCE template plugin.
Like Jeff Yang mentioned, you can use tables to help your users lay out their content without CSS (it makes me cringe, but yes on CMS-driven sites with users of all types editing content, I still give them a table to save me headaches).
The template plugin will allow you to set up your own table, lock it in place, and then let the users select it from a dropdown. So, you could set up a table to your specifications above, name it "2-column with dates" or something, and train your users to select that when they needed it.
The plugin also has a preview option so your users can pick and choose exactly which template they need.