Create custom page for a single category

Create custom page for a single category

by Fabio Cunha -
Number of replies: 11

Hi everyone, I want to know if it's possible to create a custom page for a single category on moodle based in the category id?

If it's possible, how I could do that.

I'll be very grateful if someone can help, see ya.

Average of ratings: -
In reply to Fabio Cunha

Re: Create custom page for a single category

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

If you mean can you create a theme for a category, then yes, you can.

Themes can be applied to courses and categories - just apply the theme to the category in its settings page

Richard

In reply to Richard Oelmann

Re: Create custom page for a single category

by Fabio Cunha -

I don't want a theme for a category, I want to display a diferent content directly inside a particular category. Only one category will have this content(created directly in HTML) inside, all others will work normally

I think this because of the funcionality based on Wordpress software, I think Moodle can have something similar

In reply to Fabio Cunha

Re: Create custom page for a single category

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

Hi Fabio,

Content isn't displayed directly in a category, it is displayed in courses - categories, as I see it, are groups of courses, an organisational tool, a bit like folders holding files and files holding the content on your pc.

What I would suggest is creating a single course to hold your HTML, add that HTML to the Topic0 section of the course using the HTML editor and hide all the other sections below it. You can then choose whether or not to have any side blocks etc. on your page. If you remove all the side blocks so you are left with just the centre content section and you do as I have suggested, then this should look as if you have your HTML content sat immediately under the site header and menu. If you need to remove those as well, then you can apply a display:none rule to parts of the page based on the courseid found in the bodyclasses of that page as needed - I wouldn't apply it to the categoryid as this would hide those sections in all the courses held in that category!

The alternative would be to just put your html as a file in your web directory then instead of linking to a moodle course in that category, set your menu/hyperlinks or whatever navigation you are using to point to that html file instead of a course page.

HTH

Richard

In reply to Fabio Cunha

Re: Create custom page for a single category

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

Try this:

  1. make a copy of ../theme/yourthemname/layout/general.php , and rename it category.php
  2. change $THEME->layout in ../theme/youtthemename/config.php where you see this code...

        'coursecategory' => array(
            'file' => 'general.php',
            'file' => 'category.php',
            'regions' => array('side-pre', 'side-post'),
            'defaultregion' => 'side-post',
        ),
  3. next , depending on where you want text/images to appear in YOUR CATEGORY PAGE, you can add something like...
    <?php
    if ($COURSE->course_categories->id='3' ) {
            include('catfile.php') ;
    } ?>

    to the header or the footer, of the main content area of your config.php, or wherever you like, but remember to change the ID value '3' for your category ID whatever that may be.

  4. next you will need to create and save 'catfile.php' into your theme's layout directory and then populate that file with some xhtml to display on that page.

I have not tested this idea...so it might not work as you would like to see.

HTH

Mary
EDITED: 05/05/2010 - 14:12AM (UK)

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Create custom page for a single category

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

I have just tested this and it works OK.

Cheers

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Create custom page for a single category

by Arjun Baliga -

 how can i add a php file like forum.php in theme/layout directy  and configure in config.php to have customized forum page
'forum' => array(
'file' => 'forum.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
is not working for me 

In reply to Arjun Baliga

Re: Create custom page for a single category

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

That is because there is no 'forum' layout as such.

I think Forum pages fall under either 'course' layout or 'incourse' layout...it may even be 'standard' layout.

If you go to Site Administration > Development > Debugging and Enable the General page information, you will see at the bottom of the page which layout it uses.

HTH

Mary

In reply to Mary Evans

Re: Create custom page for a single category

by Arjun Baliga -

thanks for your  reply Mary!

yeah i realised slowly that we cannot add forum.php like that smile 

so is there a way i can have customized page for every activity inside course. like quiz , assessment ,forum 

or atleast can i  use different bg image for a div, inside quiz assessment and forum pages using same incourse.php 

in other words how can i get to know the curent activity inside 'incouse' layout 

 

In reply to Arjun Baliga

Re: Create custom page for a single category

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

Hi Arjun,

If you look at the page source of the page you want to style, you can look at the body classes - for instance the below is the <body> for this page

<body id="page-mod-forum-discuss" class=" path-mod path-mod-forum gecko dir-ltr lang-en yui-skin-sam yui3-skin-sam moodle-org pagelayout-incourse course-5 context-115 cmid-46 category-1 content-only">


You can the ids and classes of this to target sections of your css to style various different elements of your site.

HTH

Richard

Average of ratings: Useful (1)
In reply to Arjun Baliga

Re: Create custom page for a single category

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

You can STYLE any ELEMENT on a page the way you want it to appear.

Just as Richard pointed out each page has a set of predefined 'body classes'. This means you can use these 'body classes' in your CSS stylesheet.

I hope this helps?

Mary

Average of ratings: Useful (1)