Change a single course background image

Change a single course background image

by Theo Yianni -
Number of replies: 11

Is it possible to change the background of a specific course or course category? Please provide instruction.

Moodle v3 WMAP

Thank you.

Average of ratings: -
In reply to Theo Yianni

Re: Change a single course background image

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

If you look at the source code of your course page (using developer tools or firebug for example) you will see that Moodle adds a body class for the course and category.

<body id="page-course-view-topics" class="... ... ... pagelayout-course course-2 
context-16 category-1 ... ... ...">

You can use that to target css at specific courses or categories, eg.

body.course-2 {background-color:#ffff00;}
In reply to Richard Oelmann

Re: Change a single course background image

by Theo Yianni -

So do I add this line to the Custom CSS field in the theme settings? And change the course number to match the course I want it for?

In reply to Theo Yianni

Re: Change a single course background image

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Yes!

In reply to Mary Evans

Re: Change a single course background image

by Theo Yianni -

Thanks... i have done so but no luck changing the colour as a test! My course ID is 930  so i have added this in the Clean theme Custom CSS box under theme settings...

body.course-930 {background-color:##ff99ff;}



In reply to Theo Yianni

Re: Change a single course background image

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

body.course-930 { background-color: #ff99ff; }

It only needs one # you added two ##

In reply to Mary Evans

Re: Change a single course background image

by Theo Yianni -

Woops.... Thanks..


If I am trying to change the course background image... is it as either of these??


body.course-930 {background-image:url([[pix:theme|C:\Apache2\htdocs\moodle\server\moodle\theme\clean\pix\back.jpg]]);}

body.course-930 {background-image: url("back.jpg");}


Thanks.

In reply to Theo Yianni

Re: Change a single course background image

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Method 1.

body.course-930 {
    background-image: url([[pix:theme|back]]);
    background-position: left top;
    background-repeat: no-repeat;
}

1) You can only use the above method in a stylesheet so add it to the moodle/theme/clean/style/custom.css

Method 2.

body.course-930 {
    background-image: url(http://yoursitename.com/theme/clean/pix/back.jpg);
    background-position: left top;
    background-repeat: no-repeat;
}

2. You can use this method in the Custom CSS text area of the settings page for the Clean theme. But please make sure you have the correct URL where I added: http://yoursitename.com

I hope this helps?

Mary

Average of ratings: Useful (2)