Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Resource types: Difference between revisions

From MoodleDocs
No edit summary
(Note about plan not to migrate this page to the new developer resources. See template for more info.)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Resource types]]
{{Template:WillNotMigrate}}
{{Moodle 1.9}}
Resource types are located in the folder /mod/resource/type
 
== Create a new resource type ==
 
To create a new resource type, of name 'new'; create a folder in /mod/resource/type
And create the resource.class.php file: /mod/resource/type/new/resource.class.php
 
Structure of resource.class.php:
<syntaxhighlight lang="php">
class resource_new extends resource_base
{
 
    function resource_new($cmid=0)
    {
        parent::resource_base($cmid);
    }
 
    function display()
    {
        ///Display the resource
       
        global $CFG;
        parent::display();
    }
   
    function add_instance($resource)
    {
        return parent::add_instance($resource);
    }
 
    function update_instance($resource)
    {
        return parent::update_instance($resource);
    }
 
    function delete_instance($resource)
    {
        return parent::delete_instance($resource);
    }
 
    function setup_elements(&$mform)
    {
    }
 
    function setup_preprocessing(&$default_values)
    {
    }
 
}
</syntaxhighlight>
 
[[Category:Resource]]
[[Category:Resource]]
 
[[Category:Plugins]]
Resource types are located in the folder /mod/resource/type

Latest revision as of 14:07, 31 December 2022


Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


Moodle1.9

Resource types are located in the folder /mod/resource/type

Create a new resource type

To create a new resource type, of name 'new'; create a folder in /mod/resource/type And create the resource.class.php file: /mod/resource/type/new/resource.class.php

Structure of resource.class.php:

class resource_new extends resource_base
{

    function resource_new($cmid=0)
    {
        parent::resource_base($cmid);
    }

    function display()
    {
        ///Display the resource
        
        global $CFG;
        parent::display();
    }
    
    function add_instance($resource)
    {
        return parent::add_instance($resource);
    }

    function update_instance($resource)
    {
        return parent::update_instance($resource);
    }

    function delete_instance($resource)
    {
        return parent::delete_instance($resource);
    }

    function setup_elements(&$mform)
    {
    }

    function setup_preprocessing(&$default_values)
    {
    }

}