General developer forum

Picture of Wayne Lee
Adding a page to moodle?

Hello all,

I was wondering if it was possible to add another page to Moodle?

I want the page to use the login details of the user and query our database to display the user’s details such as Home address and Course details. The idea also is that a lecturer can fill in fields explaining what the student needs to improve on in their course(which will be stored against their details in the DB), and the student can then login and see what areas they need to improve on or see if we have the correct contact details for them. If I could just add a page that does this, it would make it easier for the page layout and theme etc. Otherwise I will have to write the whole thing in PHP that links from Moodle and try to replicate the layout.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Any help or ideas is most appreciated

Many Thanks

<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Wayne


Average of ratings: -
Greg watching STS 132 takeoff!
Re: Adding a page to moodle?
The short answer is Yes, it's very possible.

The long answer is way over my head, but to get you started, have a look at the index.php page of many of the folders in moodle.  You'll see much of what you need to build your own page.  Something along the lines of:

require_once('../config.php'); //this assumes your page is in a sub dir.
require_login(); //make sure user is logged in
print_header(); //Show the moodle header

/*your page content here*/

print_footer(); //show the moodle footer.
in a php page will get you a standard moodle-looking page.

Here are some Moodle development links it took me forever to find:
For Moodle 1.7:
For earlier vsn:

You might want to download a little page I use to review some of the standard moodle variables too.   It's called moodlevars.php and you can get it from this thread:

hopefully that will help get you started!
Average of ratings:Useful (1)
Picture of Wayne Lee
Re: Adding a page to moodle?

Thanks Greg you gave more a good place to start and I have been attempting to add another page, but it is really complex in deciding which index page to use, what is required in the config files etc. Isn't there an add on that allows you to add a page and provides you with an editable centre section?

Can anyone shed a little more light?


Average of ratings: -
Greg watching STS 132 takeoff!
Re: Adding a page to moodle?
try this attached page then. 

All you should do is add this page somewhere in the moodle folder structure.  I suggest making your own folder and placing it there.  Now log in to your moodle.  once you're logged in you can manually type the link to your new file to see it in action.

For instance: if your moodle is at you could make a new folder called custom and place this file there.  Once you log on you'd navigate to

$CFG, $USER etc will be populated already for you now, so the only editing you'll have to do is in the main content area of your page.  You can also edit the arguments for print_header() to customize your title and meta tags, etc.

Give it a try!
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Adding a page to moodle?
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers
Rather than calling it custom, call it local. Then, if necessary, you can but a version.php and a db folder in there, and create database tables. This outght to be documented somewhere.

But if at all possible, make you custom extension a module or a block. Since these are standard Moodle plugin points, this will make you life easier in many ways. Even if your plugin never produces any visible output within courses, you can still link to pages within it.
Average of ratings: -
Picture of Claire Browne
Re: Adding a page to moodle?
Is there a how to to make a moodle page from scratch?

I am after for my page to require login, set up in page format (which is the theme i am using).

could you point me in the right direction.
Average of ratings: -
Picture of vipin vihan
Re: Adding a page to moodle?

How can we add a new page with same header and footer please help me

Average of ratings: -
Matt Bury
Re: Adding a page to moodle?
Group Particularly helpful Moodlers
Hi Wayne,

Perhaps I've misunderstood what you're trying to do but it's already possible to add input fields to users' profiles.

Go to: Site Administration > Users > Accounts > User profile fields

It adds your required fields to the main user profile page. For other things like individual user feedback and one-to-one tutorial notes, you could use the private messaging system.

I'd recommend using Moodle's built-in facilities, if they meet your needs, as they offer all kinds of nice little details like forwarding messages as emails when a user is off-line and keeping a message history, setting user permissions over who can view what, etc.

Just my €0.02! smile

Average of ratings: -
Picture of rupak nepali
Re: Adding a page to moodle?

This is the link where you can find out program to create the new page

Thanking you

Average of ratings: -