Moodle
  1. Moodle
  2. MDL-14306

The course category hierarchy should be reflected in CSS classes on the body tag

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 2.0
    • Component/s: Themes
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      35115

      Description

      If a course is within a category, that should be reflected in the CSS classes to allow it to be styled appropriately. The category id number could be used, combined with some text e.g. "category-1" and added as a class to the body tag.

      If a course is nested within one or more categories, then all of them should be added to the body tag as classes. To ensure that the CSS cascade works properly the designer should ensure that the CSS for the lower level categories comes later than the higher categories (assuming that you wish them to override).

      This would make it much easier to make subtle style changes via categories. We're currently trying to theme over a hundred departments, which mostly involves just changing a prominent header image and have implemented something similar just by adding PHP code to the header.

        Activity

        Hide
        Martin Dougiamas added a comment -

        +1 for this

        Show
        Martin Dougiamas added a comment - +1 for this
        Hide
        Tim Hunt added a comment -

        OK so, it will always add a "category-123" class with the current category (unless you are in the front page, or somewhere else where there is no category).

        If $CFG->allowcategorythemes is on, then it also adds classes for any parent categories - we don't do that all the time becuase it costs DB queries.

        Show
        Tim Hunt added a comment - OK so, it will always add a "category-123" class with the current category (unless you are in the front page, or somewhere else where there is no category). If $CFG->allowcategorythemes is on, then it also adds classes for any parent categories - we don't do that all the time becuase it costs DB queries.
        Hide
        Tim Hunt added a comment -

        That is, it does this in my git development branch. Not in CVS yet.

        Show
        Tim Hunt added a comment - That is, it does this in my git development branch. Not in CVS yet.
        Hide
        Tim Hunt added a comment -

        Went into CVS weeks ago as part of MDL-12212. Resolving this bug now.

        Show
        Tim Hunt added a comment - Went into CVS weeks ago as part of MDL-12212 . Resolving this bug now.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: