Hi Guys,
I've confused myself or reached that point in the night where all i can do is scratch my head - So I'm hoping someone can help.
I've created a hook around the default comment system in a plugin and would like to now add to the river anytime someone comments on the primary/main object in the plugin...
in the add.php action for adding a comment I have the following stored;
$entity_guid = (int) get_input('entity_guid');
// get other input info from the new comment form....then
$newcomment = new ElggObject();
$newcomment->subtype = "comment";
$newcomment->owner_guid = $_SESSION['user']->getGUID();
$newcomment->container_guid = $_SESSION['user']->getGUID();
$newcomment->access_id = 1;
$newcomment->parent_guid = $entity_guid;
$newcomment->description = $comment_desc;
$newcomment->save();
then below the line where a successful system msg is called to let the user know their comment post was successful....I have;
add_to_river('river/object/myplugin/annotate','comment',$_SESSION['user']->guid, $newcomment->parent_guid);
have also tried;
add_to_river('river/object/myplugin/annotate','comment',$_SESSION['user']->guid, $entity_guid);
But when accessing the river after successfully posting a comment
the river/object/myplugin/annotate.php returns an error stating that
Fatal Error: Call to a member function getSubject() on a non-object in line 11 of blah blah annotate.php
which is;
$performed_by = $statement->getSubject();
Basically I'm not sure if the $subject_guid and/or $object_guid are being appropriately set.
Ideally if someone comments on an object in the plugin a link to that object (parent_guid?) would be the preference.
Any help greatly appreciated.
Thanks,
Jimbo
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.
- James@feel_sickened

James - 0 likes
- trackhed@trackhed

trackhed - 0 likes
- James@feel_sickened

James - 0 likes
You must log in to post replies.Can anyone offer some clear reference material in regards to the river.
I don't understand the create.php or annotate.php or whatever the line i've questioned calls in the views/object/river/what-I'm-trying-to-do.php
?
what's in annotate.php? i'll need the code from annotate.php to understand the context in which "$performed_by = $statement->getSubject();" is used.
Solution found - I don't know where I got that $performed by line -
the annotate.php file looks as follows for the river ->
$performed_by = get_entity($vars['item']->subject_guid);
$object = get_entity($vars['item']->object_guid);
$url = $object->getURL();
$by = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
$string = sprintf(elgg_echo("myplugin:river:posted"),$by) . " ";
$string .= elgg_echo("myplugin:river:annotate") . " <a href=\"" . $url . "\">" . $object->title . "</a>";
Happy days :D