Learning Moodle & PHP - How to make the connect??

Learning Moodle & PHP - How to make the connect??

W Page發表於
Number of replies: 4
Hello All!

Is there a module in Moodle or a set of files that interact to make up a functioning module or block that is simplistic enough that a person just learning PHP could dissect it (them) and learn a bit about how Moodle works as well as PHP.

BTW, can someone explain what "$CFG->" is.
  • Where can one find where it is defined in the Moodle code?
  • Why is it important? How does it relate to PHP.
  • Is there something about it at PHP.net?
  • Where can I read about it?
  • Why use it?

Thanks in advance.

WP1
評比平均分數:Useful (1)
In reply to W Page

Re: Learning Moodle & PHP - How to make the connect??

Janne Mikkonen發表於
Core developers的相片
BTW, can someone explain what "$CFG->" is.

$CFG is an object that include all the sitewide settings as properties
eg. $CFG->wwwroot = "http://www.somedomain.net";

$CFG is and object, wwwroot is its property and "http://www.somedomain.net" is the value of that property.

(http://www.php.net/manual/en/language.oop.php) and its defined in config.php and /lib/setup.php (gets the configuration settings from database) starting from line 78 (1.4 dev).

Prehaps you should start from something simpler first like: make a form handler that parses the data send from a form and displays it nicely formatted! (after that send it via email and when mailing is working, save the data in the database). And use the coding guide from http://moodle.org/doc

After that you can compare how the data is handled in Moodle when form is sent?
These are just suggestions 眨眼

- Janne -
In reply to Janne Mikkonen

Re: Learning Moodle & PHP - How to make the connect??

W Page發表於
Thanks Janne.

WP1
In reply to W Page

Re: Learning Moodle & PHP - How to make the connect??

Jan Dierckx發表於
Thanks Janne, for the explanation and the references. I wish I had found out about the Moodle coding guide. Could have saved me a lot of time....blush
Thanks WP, for your detaillistic approach to things. I really like the way you always want to know the inside workings of all things Moodle, and then seem to remember a post from 2 months ago, or a link outside of Moodle, that puts everything in another perspective.
(Not too mention the colors in your posts big grin)
I have recently discovered the Moodle code browser with cross-reference. It makes it really easy to find out where a variable gets defined, where it is referenced. If Moodle uses a function that you don't know, you can click on it and it sums up where it is defined and which parts of Moodle use the function...
Be careful though it's easy to get mesmerized by all the referencing inside the code... wink
You talk about blocks, modules. Have you ever downloaded NEWMODULE and NEWBLOCK from CVS? They are templates for creating new er... smile modules and blocks. There is a lot of documentation inside the template. I think developing a new block (not sure about module, my try at it was not a succes) is actually easier then hacking your way inside code that already exist. (WP, You've already done the hard part, making the course image display which involves changes in a lot of different files.)
The Moodle API documentation is very helpful. I started learning all this MySQL-stuff about connections, etc... in this book of PHP that I have... only to realise afterwards, that inside Moodle you can use Moodles built-in functions like get_record, update_record, which according to me me make much more sense...
Just some thoughts out of my own (short) experience...
In reply to Jan Dierckx

Re: Learning Moodle & PHP - How to make the connect??

W Page發表於
Thanks Jan!

All input and recommendations are appreciated.

WP1