English 中文(简体)
Adding custom CSS into a new Moodle assignment
原标题:

I m working on a new Moodle Assignment plugin. How can I include a custom CSS to my plugin? I m using Moodle 1.9.7.

Thanks in advance.

最佳回答

just add a file called styles.php into the Module s folder. the file should output CSS code when it is parsed.

Moodle goes into each Module s folder and looks for that file, when the page s CSS layout is constructed.

Some themes can ignore these files using a special setting in the theme s config.php file

$THEME->modsheets = true;

/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Activity modules and
/// include them.   This allows modules to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.

here is a short sample of what could be the content of this styles.php file:

/* simple CSS code */ 
.left { float:left; }

/* php that generate CSS code */
< ?php if ( right_to_left() ) {echo ".right:text-align:left;"} 
else {echo ".right:text-align:right;"} ?>
问题回答

Perhaps could take a look at the function print_header_simple() defined in lib/weblib.php.

If you are writing a module which generates module specific pages, and they use the normal moodle libraries then stick something in $meta to be added to the <head> section while the page is being generated.

in lib/weblib.php:

function print_header_simple($title=  , $heading=  , $navigation=  , $focus=  , $meta=  , $cache=true, $button= &nbsp; , $menu=  , $usexml=false, $bodytags=  , $return=false) {

This means that you probably want something like the following in your module:

$extra_css = $CFG->wwwroot. /theme/SUPA4/supa_report.css ;
$extra_css_meta =  <link rel="stylesheet" type="text/css" href=" .$extra_css. " /> ;
print_header_simple($mytitle, "", $navigation, "", "", true, "", navmenu($course),   , $extra_css_meta);




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签