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:
<?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:
<?php
$test = new ElggObject();
$test->subtype="testtype";
$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):
<?php
echo "Hi";
I open http://localhost/elgg/testtype/test, and what I see:
------before:
url:http://localhost/elgg/
subtype:testtype
------after
uid:171
guid:171
url:http://localhost/elgg/
subtype:19
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.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Bui Van Thu@van7hu
Bui Van Thu - 0 likes
- Matt Beckett@Beck24
Matt Beckett - 0 likes
- Bui Van Thu@van7hu
Bui Van Thu - 0 likes
- Steve Clay@steve_clay
Steve Clay - 0 likes
- Chris She@freytagxiii
Chris She - 0 likes
You must log in to post replies.And, for more information, I am using the version 1.12.0, I have disabled caching in developer tools, deactivate and re activate the pluging many times.
There's nothing wrong with the view, it's correct, but you're hitting an undefined url and expecting to see it. You need to define the testtype/view/<guid> page where you will use elgg_view_entity($testtype);
Oh, thank you.
I'll have to re-look at file module for more information, thank you very much.
Also: Try to make state modifications (like creating an entity) only in actions.
I had the same problem and also managed to view the object as Matt said with elgg_view_entity($object);
what I am getting then is this (also with the full_view parameter set to true):
The object I want to display uses additional metadata. Is there any possibility to view the object with all metadata with a function like elgg_view_entity($object) or do I have to build the whole view and String formats on my own?
For now I just use echo($object->metadata_name)...