![]() |
Integrating with Moodle (problem) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Integrating with Moodle (problem) (/showthread.php?tid=2547) |
Integrating with Moodle (problem) - El Forum - 08-11-2007 [eluser]Jay Jennings[/eluser] I'm using Moodle as a shell for some of my online tools -- creating a "course" that links to an external page (also on the same server as Moodle). But now I'm trying to switch over to CodeIgniter for my PHP development (I love it!) and am having some problems. Specifically, for the external PHP pages to use the Moodle vars, I need to include this line at the top of my pages: include("/path/to/Moodle/config.php"); That allows my pages to make sure the user is logged in to Moodle, etc. But when I try to include that line in my controller file, I get this error: A PHP Error was encountered Severity: User Notice Message: Fatal: $CFG->wwwroot is not configured! Exiting. Filename: lib/setup.php Line Number: 88 I believe that's coming from Moodle, not CI, but I'm kind of lost as to why it's happening and what to do to fix it. Have I given anyone enough information to point me in the right direction? Thanks! Jay Jennings Integrating with Moodle (problem) - El Forum - 08-11-2007 [eluser]Jay Jennings[/eluser] Just something else that may help. This is the code that's causing the error message: if (!isset($CFG->wwwroot)) { trigger_error('Fatal: $CFG->wwwroot is not configured! Exiting.'); die; } And I don't believe what it says because every other external (and internal) page on the site works. Thanks. Jay Jennings Integrating with Moodle (problem) - El Forum - 08-11-2007 [eluser]esra[/eluser] CodeIgniter's front controller instantiates the Config library as $CFG in Codeigniter.php at line 79 (v1.54) but the line number could be different for other versions. $CFG is only used in two places within CodeIgniter. You might try to temporarily change the variable to something else in both places (the second place is line 91 in the same file) just to see if this is causing a conflict. Integrating with Moodle (problem) - El Forum - 08-11-2007 [eluser]Jay Jennings[/eluser] Wow, I had great hopes for that -- it sounded like a quick and easy fix. I found all the locations in CI where $CFG was referenced and changed them to $ciCFG and uploaded those files -- only to find there was no change in the problem. I even switched to a different machine just to make sure there wasn't a browser caching issue. Any ideas from anyone else? Thanks. Jay Jennings Integrating with Moodle (problem) - El Forum - 08-12-2007 [eluser]esra[/eluser] Is moodle running independently? What is the wwwroot parameter set to in moodle's config.php? Where is moodle installed in relation to application/? Integrating with Moodle (problem) - El Forum - 08-12-2007 [eluser]Jay Jennings[/eluser] Yes, Moodle is running independently. I have other tools (pre-CI) running fine. This is what Moodle see in the config file: $CFG->wwwroot = 'http://sonictoolkit.com/members' ; I know that file is being loaded by the controller because the last line in that file does a require_once and it's *that* file that spits out the error. Moodle is running in that folder shown above, and the app is down here: http://sonictoolkit.com/members/external/split/index.php/listpages/ You can hit that, but then try and click one of the items in the list and you'll see the error message show up. At the top of the page showing the error I had it spit out APPPATH just for the fun of it (so I could figure out where things were). Thanks. Jay Jennings Integrating with Moodle (problem) - El Forum - 08-12-2007 [eluser]esra[/eluser] I managed to get moodle running under another framework some time ago and will try to do the same with CI. Will get back soon. Integrating with Moodle (problem) - El Forum - 08-12-2007 [eluser]Jay Jennings[/eluser] Thanks, I appreciate the help. I'm wondering at the wording you used in your last message, so I wanted to make clear that I'm not trying to "merge" CI and Moodle to any great degree -- Moodle lets you run code in a framed window and take advantage of the user's login info, etc. I can run "plain" PHP programs like that just fine, but when I try to include the Moodle config file inside CI, that's where things fall apaer. Thanks. Jay Jennings Integrating with Moodle (problem) - El Forum - 08-12-2007 [eluser]esra[/eluser] You can probably get it to work using an iframe embedded in a view. But, you will probably need to let moodle's index.php handle the config file loading. Aside from using the same $CFG variable name, moodlelib includes a function called get_config which is also a function in CI's common.php. Loading moodle from a controller without using an iframe would require hacks in one or the other application. Integrating with Moodle (problem) - El Forum - 10-30-2008 [eluser]Allen Dino[/eluser] Hi Jay, (sorry, didn't notice that this thread was old. :lol: ) I have that exact same issue! I need to load moodle variables in CI so that I can be able to create CI pages (which is faster rather than tinkering with Moodle's code) that rely on Moodle session variables. But I can't seem to load the variables from Moodle eventhough I have included the config.php file of moodle. Here's my moodle and CI directory structure: <root>/moodle <root>/CI stuffs I tried using Code: include ("<root>/moodle/config.php"); I think CI prevents something in the config.php of Moodle, but I'm not really sure. I'll keep working on it and I'll keep you posted if ever I find a workaround on this... I hope! Anyhow, any suggestions from the community will be greatly appreciated. |