CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
回帖数:15
Hi.

After several days journey into cms-system sourcecode I found some kind of solution for incompatibility between cms-system (newest ) and moodle 1.7.+

My site used cms in 1.6.2 moodle very well and we have a lot of cms pages inside it. That's why I must do patch to cms-system.
Some caution to remember: New moodle uses roles ... and my patch don't use them. Use this at your own risk !!!


a) I assume that you have upgradet cms to newest version.
Make sure that your cms datatables is in rigth format !! My tables was not
after upgrading cms under moodle 1.7+ . Use MySqlAdmin to look it.
That's very important !!! Add missing fields in right format. ( Don't !!!! if you do not know how to do it !!!! )
Dig into mdl_cmsnavi_data table and give value to pagename-field for every line in that table. Functions need those names.

Ok. Lets go forward...

b) Just like in old cms-installation insert
define('FRONTPAGECMS', 5);
at the beginning of file /course/lib.php. You see the place 微笑

c) Also in /admin/site.html insert line
FRONTPAGECMS => get_string("frontpagecms","cms"),
in right place .... you find it... just under FRONTPAGECATEGORYCOMBO

I'm not sure is previous necessary because you must dig yourself into
/lib/adminlib.php and find place
FRONTPAGECATEGORYCOMBO => get_string('frontpagecategorycombo'),
There insert under that line:
FRONTPAGECMS => get_string('frontpagecms','cms'),
in proper place.

d) And then two hacks ...

First in file /cms/pageadd.php find lines:

$page->isfp = 0;
$page->sortorder = 2000;
$page->parentid = clean_param($page->parentid, PARAM_INT);

and comment last one out and write a new one
$page->parentid = 0;
For some reason you do not get right value and that's why you can't see your new page.


Second in file /cms/pageupdate.php find lines

$page->id = clean_param($page->nid, PARAM_INT);
$page->naviid = clean_param($page->naviid, PARAM_INT);
$page->title = stripslashes(strip_tags($page->title));
if ( !empty($page->title) and preg_match("/^\S{3,}/", $page->title) ) {
$page->parentid = !empty($page->parentid) ? intval($page->parentid) : 0;

and comment last one outand write new one
$page->parentid = 0;
for same reasons.

I think that's all. Use at your own risk and upgrade when Janne makes
official version of cms-system.

..lasse..

ps. Pardon my poor English.





回复lasse utti

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
Hmmm...

In my patch ...for some reason ... when you mark (editing) another page to defaultpage .. you lose both !!! Neither is defaultpage anymore 伤心
I've crawling thoroughly cms-code back and forth and noticed that set_field function ( introduced in /lib/dmllib.php ) in /cms/pages.php does not update field isfp in cmsnavi_data datatables ? This function is moodle database core-function ??
If you already lose defaultpage .. you can go in datatable cmsnavi_data and sort table with naviid field. Then you can see cms-menus !! Select row and edit field isfp to 1. Then you get defaultpage to menu.
But ... do it at your own risk !!!!

..lasse..

Ps. Use phpMyAdmin to look and edit your databases in moodle.

回复lasse utti

本讨论区帖子已移除

本讨论区帖子的内容已移除,无法再访问。
回复lasse utti

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

Talking Jazz -
Hi Lasse,

thanks for your try!

I had no CMS before so I tried to install a new one - but failed, as the data-tables could not be created. So I did that manually. I´m now able to create menus and pages - but I´m still NOT able to see them.

I did everything you suggested - except the change in /admin/site.html (no such site existes in 1.7?) - but still can´t see my pages 伤心.

Greetings TalkingJazz


回复Talking Jazz

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

Talking Jazz -
Hi Lasse, me again.

At last I got to work it - somehow.

I was succesfull in showing the sites ... after making some changes in my index.php of the site (as I had no 1.6 version I refused to upload the suggested index.php ...).

But I´ve still got one problem: There is an ERROR-MESSAGE when the pages of the plugin are shown:

Notice: Undefined property: footer in /home/www/web44/html/moodle/blocks/moodleblock.class.php on line 246

Hm.

I have really no guess, why? As far as I could see, there is nothing special in this line, it´s just the output for the blocks. What does the cms scritp miss? When I DO NOT call the cms-pages - and there is just the CMS-block shown with some other content, the error-message doesn´t show...

Greetings TalkingJazz
回复Talking Jazz

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
Have you done everything ??

I try to remember all places where I've done something.
Verify what you have done ...

1) path /cms
copy all cms files there!!!
edit /cms/pageadd.php as I wrote.
edit /cms/pageupdate.php as I wrote.



2) path /course/format/cms
have you copy all nessessary there ??
config.php
format.php
You need those for cms-style course

3) path /course
edit file lib.php
insert in proper place
define('FRONTPAGECMS', 5);
You need that for selecting cms-style course

4) path /lib
edit adminlib.php and find
FRONTPAGECATEGORYCOMBO => get_string('frontpagecategorycombo'),
insert under that line:
FRONTPAGECMS => get_string('frontpagecms','cms'),
You need that for selecting frontpage cms.

5) path /blocks/social_activities
edit file block_social_activities.php
function applicable_formats() {
return array('course-view-social' => true, 'course-view-cms' => true);
}
You need that for cms-navigation block

6) path /
edit index.php
find:
case FRONTPAGETOPICONLY: // Do nothing!! 微笑
break;

and insert:
case FRONTPAGECMS:
include_once($CFG->dirroot .'/cms/cmslib.php');
if ( ! empty($pid) ) {
$pages = explode(",", $pid);
foreach ($pages as $key => $value ) {
$pages[$key] = clean_param($value, PARAM_INT);
}
$pid = (int) end($pages);
} else {
$pid = 0 ;
}

if ($editing) {
cms_print_page($pid, $SITE->id, $editing);
} else {
cms_print_page($pid, $SITE->id);
}

break;


You need that for frontpage cms.

I think that was all ...... Hope that this helps you.

..lasse..


回复lasse utti

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

Julian Ridden -
This wasnt easy, but I can confirm the above instructions work. I too now have CMS running in 1.7.1+. Thanks for sharing your knowledge. I wonder if this will still work in 1.8? black eye
回复Julian Ridden

Vast: Re: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
Hi Julian.

I've made just upgrade 1.7.1+ to 1.8.2+ and ..... surprise .... it work's !!!
I've not restarted server yet ... let's see what happens.

Upgrade overwrote every standart moodle file ... I did not see any patches for cms there ... cms directory/files are like before with my patches.

.... After rebooting server ... cms works !!!!

Ok. There is problem that you can't change default page.... but you can create the system and afterwards put "default" flag to page in database.
Now the last checking ... create new course with cms-tree ....

... and it work !!!

So cms seems to work 微笑


..Lasse..
回复lasse utti

Vast: Re: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
So .... allways there is problems !!!!

I can't turn course editing on !!!! Somebody says that new module / block system with old modules makes that problem. Solution is to drop out all ols blocks/modules and then you get editing-button back. Not good 伤心

Must go back 1.7.1.+

..Lasse...


回复lasse utti

Vast: Re: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
Downgrading did not work .... just back in 1.8.2+ .... searchin whats wrong.
Ok. I upgradet book anf quickmail modules ... drop some old ( not used ) away ... and I got "edit-button" back and can turn course editing on.

...Lasse...


回复lasse utti

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

Verdon Vaillancourt -
Hi lasse,

Your instructions have been very clear, and pretty darn good for working in a language not native to yourself 微笑

I've almost got it, but not quite. I feel I'm missing something basic, but am unsure what. I can create menus and I can create pages. I can edit pages and menus and save my edits.

However, I cannot view pages either from links in a block menu - which gives me urls in the manner http://www.mydomain.ca/moodle/index.php/My%20First%20CMS%20Page - or from the list of pages in the manage pages admin screen - which gives me urls in the manner http://www.mydomain.ca/moodle/index.php?pid=1

In either case, clicking on the link just shows me the default home page content and not the cms content referenced in the url.

Any suggestions?

salut,
verdon
回复Verdon Vaillancourt

Απάντηση: Re: Solution for Incompatibility between cms and moodle 1.7+

aggelos panagiotakis -
I would like an explaination of the following
  • what "cms datatables is in rigth format !!" means?
  • can you post your database structure of the mysql tables involved?
  • what version of the cms_plugin we are talking about and were to download it from?
回复aggelos panagiotakis

Vast: Απάντηση: Re: Solution for Incompatibility between cms and moodle 1.7+

lasse utti -
Hi Aggelos !

I have used cms-block from it's first version to the
last one. After every Moodle upgrade I've modified all
necessary files by hand just as told in Janne's README
files. Also cms-upgrade was working everytime well.

Last time there was modifications in datatablestructure
and upgrade does not work in my system. At the same time
I upgraded Moodle 1.6.3 -> 1.7.1 and the mess was ready.
No cms anymore !!!

First I found missing datafields and inserted them into
datatables. Second I figured out how Janne was thinking
trafic between datatables. And at last I searched those
places in sourcecode where the troubles was grown up.

Now my cms-system works and all pages is in use. I can insert
new cms, delete old ...

I hope that this works in your system too.

..Lasse..

Here is my datatable structures.

---------------------------
cms:
id int(10) No
name varchar(100) No
value varchar(255) Yes NULL
---------------------------
cmsnavi:
id int(10) No
course int(10) No 1
name varchar(255) No
intro blob Yes NULL
created int(10) No 0
modified int(10) No 0
requirelogin tinyint(1) No 0
allowguest tinyint(1) No 0
printdate tinyint(1) No 1
--------------------------
cmsnavi_data:
id int(10) No
naviid int(10) No 0
pageid int(10) No 0
pagename varchar(40) No
title varchar(100) No No title
showblocks tinyint(1) No 0
showinmenu tinyint(1) Yes 1
isfp tinyint(1) No 0
sortorder int(10) No 0
parentid int(10) No 0
url varchar(255) Yes NULL
target varchar(10) Yes NULL
-------------------------
cmspages:
id int(10) No
body mediumblob Yes NULL
created int(10) No 0
modified int(10) No 0
publish tinyint(1) No 1
------------------------
cmspages_history:
id int(10) No
pageid int(10) No 0
modified int(10) No 0
version varchar(10) No 1.0
content mediumblob Yes NULL
author int(10) No 0


回复Verdon Vaillancourt

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

WriteToShare .org -

Verdon,

I've got a solution for you.  I was having the same problem, and after some digging through the code, I came up with the following modification.

In the /blocks/cmsnavigation/block_cmsnavigation.php around line 90, replace the code with this:

                        $baseurl = ($navi->course == SITEID)
                                ? ((!$CFG->slasharguments)
                                    ? $CFG->wwwroot.'/cms/view.php?page='.$navi->pagename
                                    : $CFG->wwwroot.'/cms/view.php/'. $navi->pagename )
                                : $CFG->wwwroot.'/course/view.php?id='. SITEID .'&page='.$navi->pagename;

I could not get CMS to work with slash arguments, so I had to turn that off in the Moodle admin.

Let me know how that works for you.

Milan Indru Malkani

回复WriteToShare .org

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

Verdon Vaillancourt -
Hi Milan,

Thank you for the reply and information.

I won't be able to test that though. I gave up on the cms and came up with some other solution for this particular client. I've moved on and am in other contracts at the moment, that are not moodle-based.

Thanks again,
verdon
回复WriteToShare .org

Re: CMS integrations: Solution for Incompatibility between cms and moodle 1.7+

hasikala anuruddhi -
thanx Milan,
it's grate, it's worked 4 me
I have done lots of changes as specified in these threads but what you have done here was finally help me...

thanx a lot