Courses and News on Front Page

Re: Courses and News on Front Page

by Ferlin Scarborough -
Number of replies: 0

Hello again all,

I don't know much of anything about php, but I made the following hack to index.php in my moodle directory and it seems to give me the desired results.  Although it is hard coded to 1 news item.

[Code]


         case FRONTPAGECOURSELIST:
         case FRONTPAGECATEGORYNAMES:
             if (isset($USER->id) and !isset($USER->admin)) {
                 print_heading_block(get_string("mycourses"));
                 print_spacer(8,1);
                 print_my_moodle();
             } else {
                 print_heading_block(get_string("availablecourses"));
                 print_spacer(8,1);
                 if (count_records("course_categories") > 1) {
                     print_simple_box_start("center", "100%");
                     print_whole_category_list();
                     print_simple_box_end();
                     print_course_search();
                 } else {
                     print_courses(0, "100%");
                 }
             }

             if (! $newsforum = forum_get_course_forum($site->id, "news")) {
                 error("Could not find or create a main news forum for the site");
             }
   
             if (isset($USER->id)) {
                 $SESSION->fromdiscussion = "$CFG->wwwroot";
                 if (forum_is_subscribed($USER->id, $newsforum->id)) {
                     $subtext = get_string("unsubscribe", "forum");
                 } else {
                     $subtext = get_string("subscribe", "forum");
                 }
                 $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr>
                                <td>$newsforum->name</td>
                                <td align=right><font size=1>
                                <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
                                </td></tr></table>";
             } else {
                 $headertext = $newsforum->name;
             }
             print_heading_block($headertext);
             print_spacer(8,1);
             forum_print_latest_discussions($newsforum->id, 1);
         break;


[End Code]

If anyone else has a better solution please let me know.

Thanks.

Ferlin Scarborough - http://www.gameuniv.net