Rename News Forum

Rename News Forum

by Sherri Yerk-Zwickl -
Number of replies: 5

We would like to rename the News Forum to "Announcements"

We're on version 1.9.2

When I edited the forum.php file (image attached) it looks like the setting has been saved, yet all existing news forums are still named news forum.

What am I missing here?

Attachment newsforum.jpg
Average of ratings: -
In reply to Sherri Yerk-Zwickl

Re: Rename News Forum

by Gordon McLeod -

Ditto - I finally got around to trying to rename News forum (suggests 2-way discussion) to Announcements in the language settings, but have exactly the same issue.

Sherri did you ever get a solution (or does anyone else have one)?

I've edited other content using the same technique and it worked - so what's different?

Thanks.

In reply to Gordon McLeod

Re: Rename News Forum

by Pascal Maury -
Picture of Plugin developers

I did the same thing and have exactly the same issue. But it works for a new course. If you create a new course, the news forum will be named with the new name.

So, I guess you have to rename all the old news forums in your database.

Has anyone already tried this ?

Anyway, I will try it on my website.

Thanks.

In reply to Pascal Maury

Re: Rename News Forum

by Ann Adamcik -

I suspect that for existing courses, you're getting a cached forum name. Try this - turn editing on in a course, and then hide/show a topic or week. That should trigger a cache rebuild.

In reply to Ann Adamcik

Re: Rename News Forum

by Pascal Maury -
Picture of Plugin developers

When the news forum is created, the name of the forum is "News forum" (depending of the language, of course).

Even if you rename "News forum" in the forum.php file, the existing news forums keep their name "News forum".

So, you have to execute the request :
UPDATE forum SET name = "NEW_NAME" WHERE type = 'news' and name = 'News forum"

But I discovered that it is not enough ! You have to rebuild the cache course as well ! The forum name is also in the field modinfo of the course table. This field is used as cache. Even if you execute the previous request, when you visit a course, the old name still displays.

To display the new name, the cache course must be rebuilt. If you edit the forum, the new name will appears in the name field and when you saved the page, the cache course is rebuilt.

More information here :
- modinfo in the course table (2005)
- a problem with modinfo field in mdl_course database table (2008)
- courses and modinfo (2007)

I think that the best is to call the function rebuild_course_cache($courseid), where $courseid is the id field of the course.

Pascal

Average of ratings: Useful (1)
In reply to Pascal Maury

Re: Rename News Forum

by Pascal Maury -
Picture of Plugin developers

I realised that the script admin/replace.php calls the function rebuild_course_cache.

So I wrote the attached script "rebuild_course_cache.php" from replace.php where I only kept the last code lines about rebuilding course cache. I tried it on my test website and it works.

You can download it from my post and try it. If there is something wrong with my script, tell me !

Be carefull ! Use this script on a test website before to make sure everything is ok with your moodle !
And anyway make a backup of your database !

To rename all news forum on a moodle website already in use :
- rename "News forum" in the forum.php file via Language moodle menu
- execute the request in your database : UPDATE forum SET name = "NEW_NAME" WHERE type = 'news' and name = 'News forum"
- copy the script attached to the folder /var/www/moodle/admin and execute it by calling :
http//yourwebsite.com/admin/rebuild_course_cache.php

Average of ratings: Useful (1)