Topic on Project:Support desk

Unique background image on a category basis?

6
Krayfishkarl (talkcontribs)

So my wiki used to have the option of displaying unique background images and CSS stylings but I've recently had to look for new methods of implementing it after a MediaWiki update disabled the method I was using before (which was HTML tags). Recently, we got something very basic working that just the changes the background color for certain groups of pages, but the background-image tag does not appear to load correctly. As a matter of fact, it actually disables all other elements. We devised a workaround of just overlaying an image to act as a fake background, but I'm hoping to find a more elegant solution.

tl;dr I'd like some assistance in trying to figure out how to get the background-image option to work on multiple pages.

Long version:

MediaWiki: 1.34.1

PHP: 7.3.14 (litespeed)

MySQL: 5.6.44-cll-lve

ICU: 63.1

Lua: 5.1.5

The goal is to have it so that pages based on categories (determined by a template on each page that automatically adds a category) change background images and CSS stylings on a per page basis.

Here is a link to my wiki: http://omniversenexus.net/wiki/Main_Page

On the sidebar are "settings" themed after different genres. Depending on what "setting" a page is part of, the background image and link colors change.

Here are some examples of differently colored pages:

http://omniversenexus.net/wiki/Galactic_Crucibles

http://omniversenexus.net/wiki/Infinite_Histories

http://omniversenexus.net/wiki/Dreamwalkers

The respective templates that control these pages' appearances can be found here:

http://omniversenexus.net/wiki/Template:Galactic_Crucibles

http://omniversenexus.net/wiki/Template:Infinite_Histories

http://omniversenexus.net/wiki/Template:Dreamwalkers

And lastly, here's an experimental page that attempts to use the template's code on its own CSS page. There's only one of these so far:

http://omniversenexus.net/wiki/MediaWiki:GC.css

Things I've looked in to:

While searching for help, I came across this on the Extension:CSS page:

"Using the parser function to use the CSS from another page does not work to change the color or background of the page, however, using the parser function on a single page by itself does allow the background to be changed. To overcome this problem, it is possible to load the CSS through transclusion, which does not cause the problem of failing to load the change to the page background."

However, I'm not sure I follow what exactly this means.

---

In the Template Styles Extension, there's a parameter called $wgTemplateStylesAllowedUrls. A default is given as follows:


    "audio" => [

        "<^https://upload\\.wikimedia\\.org/wikipedia/commons/>"

    ],

    "image" => [

        "<^https://upload\\.wikimedia\\.org/wikipedia/commons/>"

    ],

    "svg" => [

        "<^https://upload\\.wikimedia\\.org/wikipedia/commons/[^?#]*\\.svg(?:[?#]|$)>"

    ],

    "font" => [],

    "namespace" => [

        "<.>"

    ],

    "css" => []

]

However, replacing the URLs with that of my own site had no noticeable effect and the background-image option still wasn't working. The result was the following error:

'Page MediaWiki:GC.css must have content model "Sanitized CSS" for TemplateStyles (current model is "CSS").'

This occurs on this particular edit revision of the Galactic Crucibles template:

http://omniversenexus.net/wiki/index.php?title=Template:Galactic_Crucibles&direction=prev&oldid=9251

I'm not 100% sure if my syntax is correct so a possible example would be appreciated.

Also, please let me know if there's anything I need to clarify or if you have further questions about what we're trying to do here.

Bawolff (talkcontribs)

templatestyles does not normally use the mediawiki namespace. Use a page named something like template:galactic/styles.css

Krayfishkarl (talkcontribs)

Thank you. We'll give this a shot. I may post further on this thread if we are still running into problems.

Krayfishkarl (talkcontribs)

Update, so I'm still running into issues. I just upgraded to the latest version of MediaWiki (1.34.1) and redownloaded the TemplateStyles extension version (1.34) . Whenever I attempt to change the content model of the css page to sanitized css at Special:ChangeContentModel, I get the following error:

[Xo4YCfSR5HaBHlnlGfPK9AAAAgI] /wiki/Special:ChangeContentModel Error from line 78 of <URL cleared for privacy purposes>omniversenexus.net/wiki/extensions/TemplateStyles/includes/TemplateStylesContent.php: Class 'Wikimedia\CSS\Parser\Parser' not found

The current page I'm trying to change the content model of is located here: http://omniversenexus.net/wiki/Template:Galactic_Crucibles/style.css

I've tried to look into this solution and found something about running "composer update --no-dev". However, I don't have (or at least don't know how to) access to the terminal. I'm using cPanel to manage the site and I haven't found any sort of ability to access the terminal. I am the site owner and administrator so I figure it should be something I'd be able to find.

Is there another way to fix this error without the use of a terminal?

Bawolff (talkcontribs)
Krayfishkarl (talkcontribs)

Alrighty then. I'll give it a try within the next day or two. I'll post back here when I have the results.

Reply to "Unique background image on a category basis?"