Extension talk:Widgets

About this board

Old messages are archived.

2804:14C:6584:4F38:EC78:D90E:A50A:85DE (talkcontribs)

I'm getting the 502 Bad Gateway error when I save a page in my wiki that has the Widget template called, how do I solve this problem?

Reply to "502 Bad Gateway"

relative URL for a widget

Chantoune (talkcontribs)

I am using the widget video given in the list of already designed widgets

but this one use an absolute url

and i want something like src= instead of URL=

because videos are locales to my wiki and not external

Could you please give me the syntax to change this

best regards

Because in my old version of mediawiki i used HTML5Video extension and now with version 1.39 of mediawiki it doesn't work

Cavila (talkcontribs)

I would think that the Video widget already makes use of src internally. I'm not sure what you by mean "videos are locales to my wiki", but there's a couple of things you could do.

  • You could rewrite the widget to make use of $_SERVER['SERVER_NAME' ]
  • You could rewrite the widget to include a hard-coded reference to the domain.

Or before passing stuff to the widget:

  • You could use prefix your relative urls with Help:Magic words: e.g. https:{{SERVER}}/
  • If a video is uploaded to the wiki, you can retrieve its url by using filepath

Hope that helps.

Reply to "relative URL for a widget"

Unable to load template 'wiki:Iframe'

JanTappenbeck (talkcontribs)

hi !

i want to use in lokal wiki the Widget#Iframe.

The folder ..\extensions\Widgets\compiled_templates has full permisson to IIS_IUSRS and the .htaccess file, include this folder (source: deny from all) i rename.

the template .../index.php?title=Vorlage:Wiki:Iframe is create with

<includeonly><iframe src="<!--{$url|validate:url}-->" style="border: <!--{$border|escape:html|default:0}-->" width="<!--{$width|escape:html|default:400}-->" height="<!--{$height|escape:html|default:300}-->"></iframe></includeonly>

then i copy the example into side - but now i get the misstake:

Unable to load template 'wiki:Iframe'

did someone could help?

regards Jan

os Windows Server 2016
mediawiki 1.36.1
php php-7.4.20-nts-Win32-vc15-x64
mysql mysql-5.7.12-winx64
Aliaksei.S (talkcontribs)

Please review the widget description carefully, section 'Copy to your site' www.mediawikiwidgets.org/Widget:Iframe

To resolve the issue, you need to create Widget:Iframe page like this:


and copy the 'full source code' to the page.

Reply to "Unable to load template 'wiki:Iframe'"

Widgets loaded before mw.hook is available

PetraMagna (talkcontribs)

I ported some functional widgets from a different wiki running MW 1.31 and Widgets v1.3.1 to mine, which is running MW 1.38 and Widgets v1.4.1. However, some of these ported widgets are not working. In particular, I see errors about mw.hook and mw.loader.using not being a function.

I tried to log them in the console as the widget loads, mw shows up as an object with all the expected properties, but mw.hook and mw.loader.using are both undefined.

A simple script to reproduce the issue is as follows:

window.RLQ.push(async () => {
    console.log(mw); // this shows up as a regular object
    console.log(mw.loader.using); // this shows up as undefined
    console.log(mw.hook); // this shows up as undefined

I typed the names of all these packages in the console after the web page loaded. Everything shows up normally, implying that the widget is perhaps loaded before core mw packages are available.

I feel like I'm missing something very obvious, but I don't know much about javascript and cannot find any migration guides/tutorials that may explain this phenomenon. Everything I saw suggested that mw.hook and mw.loader.using are loaded before everything else and that I don't need to do anything special to use them. Any help is appreciated. Thank you!

Cavila (talkcontribs)

Hi, I honestly don't know but you're relying on a number of ResourceLoader's core modules (mw.loader.using, etc.). As far as I know, the Widgets extension has no support for them out of the box, so I wonder how that issue was solved on the older wiki.

One hack you could try, though it really is a stab in the dark, is to edit extension.json and load the required modules as dependencies, which may or may not also include jQuery.

Another route you might consider is move your JavaScript to MediaWiki:Common.js instead, which comes with built-in support for ResourceLoader although you will probably have to rewrite some of your code (or have it rewritten).

PetraMagna (talkcontribs)

@Cavila Thanks for the reply! I saw in another thread called "JQuery access" that upgrading from MW 1.31 to 1.34 breaks jquery, so the issues with mw.hook and mw.loader.using might have a similar cause.

I thought extension.json configures the dependencies of an extension, so it shouldn't affect the order in which js scripts are loaded?

Reply to "Widgets loaded before mw.hook is available"

What triggers widgets to get cached/compiled?

Justin C Lloyd (talkcontribs)

Our wikis have a lot of widgets, some of which I'm seeing get recompiled into the compiled_templates directories many times per minute, even sometimes multiple times in a second. In that particular example, the only thing changing in the compiled code is the JS function name that is randomly generated by the call to PHP uniqid('', true). Is this probably something with how our Widgets are written, or perhaps about how they are used within templates and themselves use templates (it gets messy)? FWIW a while back I opened a Phabricator task on this.

Justin C Lloyd (talkcontribs)

Any thoughts on my question?

Reply to "What triggers widgets to get cached/compiled?"

Widgets.php was not found!

Farvardyn (talkcontribs)

I upgraded from 1.34 to 1.38 and got Widgets error, so I used your manual for "mediawiki version 1.31 and later', it seems everything is done fine and I get no error, but Widgets.php is not under /Widgets folder. Why this file is missing from your git? I copied Widgets.php from my older 1.34 version to this new folder, but it seems there are still problems.

Kghbln (talkcontribs)

Did you migrate to wfLoadExtension( 'Widgets' );? See here.

Reply to "Widgets.php was not found!"

How to render mediawiki syntax before sending to a widget

FrViPofm (talkcontribs)

Hi, making a flashcard system on my wiki using SMW (flashcards are defined in pages and available in portals), the display is made with tabs with the input-radio trick (see for example : https://www.youtube.com/watch?v=oLqdy95LZSw ). So the html structure and css are in Widget:Flashcard.

But questions and answers may have links to pages (definitions...), images... in wikicode. And they are not rendered after being sent to the widget witch displays raw code.

Is it a way to render them ? Thanks

Reply to "How to render mediawiki syntax before sending to a widget"

Captcha on mediawikiwidgets.org not working

2 (talkcontribs)

Having issues creating a new account on mediawikiwidgets.org because the time calculation captcha says my answers are wrong. I have tried every combination of syntax I can think of. Any ideas how to get it to work?

Kghbln (talkcontribs)

Try e.g. 10:22. Probably you added the brackets [] which should not be done.

Reply to "Captcha on mediawikiwidgets.org not working"
2604:2D80:E507:3000:A5BA:527E:A9AE:8B43 (talkcontribs)

After trying to up any widget in i get "forbidden". I changed the dir to 777 and still no dice. Specifically iframe and form code gets me the forbidden.

Kghbln (talkcontribs)

Note that a lot of websites nowadays disallow iframing. This is probably where your "forbidden" comes from. Apart from that, I do not know.

Reply to "Forbidden?"

Error: Class 'Smarty' not found

4 (talkcontribs)

I got this error after updating my wiki recently. I tried to follow the steps under Installation from a .zip file, but I got a little confused by the wording.

So I installed the newest Widgest extension and then created a folder named 'smarty" (extensions/Widgets/smarty). Then I downloaded the newest Version of Smarty, unzipped it, and put the 'libs' folder in extensions/Widgets/smarty/libs.

But it didn't change anything, I still got the error message. What did I do wrong?

MGChecker (talkcontribs)

Please try installing the extension via Git, since the method via unzipping Smarty manually is outdated.

If you can not use git or composer directly on your server, you can run the respective command locally and afterwards upload the whole folder.

Gesslar (talkcontribs)

I am having the same error, but when I attempt to import from another wiki.

installed via git from github wikimedia/mediawiki-extensions-Widgets

I get the following:

[fae15bd5e378e271a99d65f5] /index.php?title=Special:Import&action=submit Error from line 24 of /frogdice/servers/com.thresholdrpg.wiki/extensions/mediawiki-extensions-Widgets/WidgetRenderer.php: Class 'Smarty' not found


MGChecker (talkcontribs)

As stated in the documentation at Extension:Widgets#Download, you need to run Composer afterwards. This can also be done at your local machine before syncing with the server.

Reply to "Error: Class 'Smarty' not found"
Return to "Widgets" page.