Moodle App CSS not working

Moodle App CSS not working

by Plum Bum -
Number of replies: 8

Hi,

I followed the instructions from https://docs.moodle.org/35/en/Moodle_app_guide_for_admins#Customise_your_app_theme to customize the moodle app but it's not loading at all.

I also used #1, #2 at the end of the url to make sure the file is loading after editing (like explained here: https://docs.moodle.org/dev/Moodle_Mobile_Themes#Updating_your_theme_in_the_app) but this doesn't work too.

Could anyone provide some help?

Thanks in advance,

Patrick

Average of ratings: -
In reply to Plum Bum

Re: Moodle App CSS not working

by Vinny Stocker -
Picture of Plugin developers

Hello Patrick.

You can use https://mobileapp.moodledemo.net/ along with a browser inspector / browser CSS plugin, to check that you are using the correct css classes. 

Vinny

In reply to Plum Bum

Re: Moodle App CSS not working

by Plum Bum -

It's a pitty that no one came up with a solution. I can only tell that I found out that when the app tries to load the css file I'll get this error: "No 'Access-Control-Allow-Origin' header is present on the requested resource." So it seems to be a CORS problem.

In the app on smartphone and tablet I got the styles running. But while developing it would be great to view changes directly in the desktop browser, instead of the app on the smartphone.

Any help?


Thanks, Patrick

In reply to Plum Bum

Re: Moodle App CSS not working

by Vinny Stocker -
Picture of Plugin developers

Hello Patrick,

As I mentioned, you can use https://mobileapp.moodledemo.net/ along with a browser inspector / browser CSS plugin to make CSS changes and view them directly in the browser. I use a Chrome plugin called "User CSS".

Hope that helps.

Vinny

In reply to Vinny Stocker

Re: Moodle App CSS not working

by Plum Bum -

Hi Vinny,

thanks for your reply but your answer unfortunately misses the point. I'm not searching for a way to add new css styles because I'm aware of the great Chrome, Firefox or Safari inspector and using them all the time.

I'm missing the opportunity to see my changes saved in the stylsheet for the moodle app. At the moment this only works in the app itself. But it would be great to see them in the desktop browser too. While the Chrome plugin you mentioned is a good workaround it cures just the symptoms but not the cause.

Maybe an experienced Moodle developer can take a look at this. I already posted an error message of the problem in one of my posts before.

Thanks, Patrick

In reply to Plum Bum

Re: Moodle App CSS not working

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Patrick,

you need to open Chrome or Chromium with the following flags to be able to prevent those CORS errors:

--allow-file-access-from-files --disable-web-security --user-data-dir --allow-running-insecure-content

It is explained in here:

https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium#Installation

We usually recommend Chromium over Chrome, I think Chrome doesn't support one of those flags but I'm not sure about that.

Kind regards,

Dani

In reply to Dani Palou

Re: Moodle App CSS not working

by Plum Bum -

Hi Dani,

I downloaded Chromium, entered the flags and it worked immediately! Thanks a lot!

While it's a good workaround I still hope moodle developers will get around this problem so it will be possible to load the css without changing the actual browser.

However, thanks! : )

Patrick