Object view not work.

Hi folks,

I have completed the tutorial for blog plugin, now I decided to make something more advanced.

My plugin has structure as follow, using tree inside mod/testtype:

├── manifest.xml
├── start.php
├── test_object.php
└── views
    └── default
        └── object
            └── testtype.php


The content of start.php:


        elgg_register_page_handler('testtype', 'testtype_page_handler');
        function testtype_page_handler($segments) {
                if($segments[0] == 'test') {
                        require elgg_get_plugins_path() . 'testtype/test_object.php';
                        return true;
                return false;


The content of test_object.php:


        $test = new ElggObject();
        $test->title = "a title";
        $test->description = "description?";
        $test->access_id = ACCESS_PUBLIC;
        $test->owner_guid = elgg_get_logged_in_user_guid();
        echo "------before:" . "<br/>";
        echo "url:" .$test->getURL() . "<br/>";
        echo "subtype:" . $test->subtype. "<br/>";;
        $test_uid = $test->save();
        if($test_uid) {
                echo "------after" . "<br/>";
                echo "uid:" . $test_uid . "<br/>";
                echo "guid:" . $test->getGUID(). "<br/>";
                echo "url:" . $test->getURL() . "<br/>";
                echo "subtype:" . $test->subtype. "<br/>";
                echo "user_guid: ". $test->owner_guid;


And, the content of views/default/object/testtype.php (it's just a test):

        echo "Hi";

I open http://localhost/elgg/testtype/test, and what I see:

user_guid: 38

So, I think I shoud browse to http://localhost/elgg/testtype/view/171/ to view the object view of object which was created, but I got 404 - page not found error. Using inspect in Developer Tools I could see "object/testtype    500    mod/testtype/views/default/object/testtype.php".

What am I wrong?

Thank you for help.


Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking