$PAGE->requires

$PAGE->requires

by 康 陈 -
Number of replies: 12

How can  i set the $PAGE->requires in moodle 2.2 ? I want to set CSS for the page ,what should I do ?

Average of ratings: -
In reply to 康 陈

Re: $PAGE->requires

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The CSS is defined in the theme... see http://docs.moodle.org/dev/Themes#CSS

I wonder if this is what you mean, though? It would help if you gave a little background about what you are trying to do?

With moderator hat on... I understand that english is probably not your first language but your (many) questions are impossible to answer without some basic information. If something doesn't work...

- what did you do?
- what did you expect?
- what happened?
In reply to Howard Miller

回复: Re: $PAGE->requires

by 康 陈 -

I have defined a CSS in moodle 1.9 and it can work normally.But when I imigrate the plugin to moodle 2.2 ,the page can not be shown incorrectly. So i think the CSS in moodle 2.2 had been changed or the method of use CSS in moodle 2.2 is different from 1.9 .  When i use print_header() I need $meta,but when I use $OUTPUT->header(),how can I make use of $meta;$meta is related to CSS and javascript.

In reply to 康 陈

Re: 回复: Re: $PAGE->requires

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Moodle 2's output routine's are completely different. Did you read the theme documentation for Moodle 2? I'm not sure what else to say sad
In reply to Howard Miller

回复: Re: 回复: Re: $PAGE->requires

by 康 陈 -

Sorry ,I have not . Can you give me a link ?

In reply to Howard Miller

回复: Re: 回复: Re: $PAGE->requires

by 康 陈 -

I think there is something i have not clarified;I just want  my css to work in my plugin.

what i want to know is how can I set css such as "<link rel="stylesheet" type="text/css" href="http://localhost:8881/moodle/theme/yui_combo.php?2.9.0/build/assets/skins/sam/skin.css" />" in moodle 2.2 ?   In moodle 1.9 I can do it by pass $meta to print_header();But how can I do it in moodle 2.2.  

In reply to 康 陈

Re: 回复: Re: $PAGE->requires

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you want css in Moodle 2.x, put it in a file called 'styles.css', within your block's main folder and it will be included.

In reply to Davo Smith

Re: 回复: Re: $PAGE->requires

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

To complete Davo's correct response:

The stylesheets pertaining to a plugin are placed inside that plugin's folder and called:

in moodle 1.9: styles.php

in moodle 2.x: styles.css (logically wink)

Joseph

Average of ratings: Useful (1)
In reply to Joseph Rézeau

回复: Re: 回复: Re: $PAGE->requires

by 康 陈 -
I have create a styles.css,but how can make it work? Now it does not work. In moodle 1.9 , I can make it work by pass $meta to print_header() .Now in moodle 2.2 how can make it work ?
In reply to 康 陈

Re: 回复: Re: 回复: Re: $PAGE->requires

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Site admin > developer > purge caches, then your CSS will be automatically included (usually it is included whenever your plugin's version number changes).

In reply to Davo Smith

回复: Re: 回复: Re: 回复: Re: $PAGE->requires

by 康 陈 -

I think there is something i have not clarified;I just want  my css to work in my plugin.

what i want to know is how can I set css such as "<link rel="stylesheet" type="text/css" href="http://localhost:8881/moodle/theme/yui_combo.php?2.9.0/build/assets/skins/sam/skin.css" />" in moodle 2.2 ?   In moodle 1.9 I can do it by pass $meta to print_header();But how can I do it in moodle 2.2.

In reply to Davo Smith

回复: Re: 回复: Re: 回复: Re: $PAGE->requires

by 康 陈 -

I have done as you said. In moodle 1.9  set css by $CFG->stylesheets[] = $CFG->wwwroot.'/mod/programming/styles.css'; In moodle 2.2  is it do this atuomatically by system ,when I do as you said ?