im trying to get my river create.php to display basicly this
right now it displays : USERA Has Sent A GIFT To USERB
i want to to display USERA Has Sent A (Gift's Name, Exmaple: Banana) To USERB
now i found in my database elgg_private_settings that i can find all the gifts with there name as the value, how the heck do i get the system to display the gifts name insted of the plugins name???????? been stuck on this for days
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.
- Jpardee@joshpardee
Jpardee - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Jpardee@joshpardee
Jpardee - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Jpardee@joshpardee
Jpardee - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Jpardee@joshpardee
Jpardee - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- iionly@iionly
iionly - 0 likes
You must log in to post replies.running 1.8 btw not 1.7
Which Gifts PlugIn ? You should have posted this on that PlugIn's page ;-)
The action code does this :=
add_to_river('river/object/gifts/create','gifts',$gift->owner_guid,$gift->receiver);
There is currently no room for for the additional item <Gift Name> in there -- that will have to be added to the river view and the gift name then needs to be passed in so that the river object can display that as well as the current fields.
Gifts
iionly, Galdrapiu, Christian Heckelmann
1.8.0beta1
\Public HTML\mod\gifts\views\default\river\object\gifts/create.php
<?php
/**
* Elgg Gifts plugin
* Send gifts to you friends
*
* @package Gifts
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Christian Heckelmann
* @copyright Christian Heckelmann
* @link http://www.heckelmann.info
*/
// THANK YOU DDFUSION
// Added Fix from DDFusion
$performed_by = get_entity($vars['item']->subject_guid);
$performed_on = get_entity($vars['item']->object_guid);
$object = get_entity($vars['item']->object_guid);
$person_link = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
$object_link = "<a href=\"{$performed_on->getURL()}\">{$performed_on->name}</a>";
$gift = "<a href=\"{$vars['url']}gifts/{$_SESSION['user']->username}/index\">".elgg_echo("gifts:gift")."</a>";
$string = sprintf(elgg_echo("gifts:object"), $object_link, $gift) . " <a href=\"{$performed_by->getURL()}\">" . $performed_by->name . "</a> ";
echo elgg_view('river/elements/layout', array(
'item' => $vars['item'],
'message' => $string,
));
this code already displays performed by, then the gifts plugin name, then performed on, it has 3 %s but i want the one that displays the gifts plugin name ($gift = "<a href=\"{$vars['url']}gifts/{$_SESSION['user']->username}/index\">".elgg_echo("gifts:gift")."</a>";) to display the specific gift ID for example in the database under elgg_private_settings i can see the gift item with its ID and Name (Gift_2,Banana) so i know there must be some function that will tell it to display when that specific gift id gets sent it displays that gift id's name on record.....its got to be posible
gifts\views\default\river\object\gifts\create.php :-
(
$gift=
"<a href=\"{$vars['url']}gifts/{$_SESSION['user']->username}/index\">"
.elgg_echo("gifts:gift")
."</a>";
)
-- only displays the sender and receiver names, etc for the river.
elgg_private_settings has the data you want -
but that in the DB is quite far away from the code !
ID and Name (Gift_2,Banana)
The send.php will need to setup the Gift Name data
-- so that the create.php can later fetch the actual Gift's Name
Gift's Name for display on the River itself.. This may be
a little bit 'twisted' extra code to do -
because this logic in not there right now at all.
I'll think over this and write some comments
you be ready for some not trivial coding ;-)
don't be a newbie or afraid to code !
... tomorrow - after coffee -
now is 3:30 am here ;-P
And.. I think better goto sleep soon.
im not a noob and i write code all day every day so im ready
oki ;-)
send.php =>
// Add to river
// [0] := Gift Name <- 'Gift-Text' ? <-- $body | Description ??
add_to_river('river/object/gifts/create','gifts',$gift->owner_guid,$gift->receiver);
system_message(elgg_echo('gifts:sendok'));
$gift->description
Should have the Gift Name (I think - I've not not verified;)
That gifts shud be current text used now
if substitute with -> body|descr - shud be what's needed..
try that..
get 500 internal server error when trying to send the gift
no change in the wording at all still UserA has sent a GIFT to UserB
code.....
<?php
/**
* Elgg Gifts plugin
* Send gifts to you friends
*
* @package Gifts
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Christian Heckelmann
* @copyright Christian Heckelmann
* @link http://www.heckelmann.info
*/
// only logged in users
gatekeeper();
action_gatekeeper();
// get the form input
$receiver = get_input('send_to');
$gift_id = get_input('gift_id');
$body = get_input('body');
$cost = get_input('giftcost');
$access = get_input('access');
$sender = get_entity(elgg_get_logged_in_user_guid());
// No Friend selected?
if (empty($receiver) || empty($gift_id)) {
register_error(elgg_echo("gifts:blank"));
forward("gifts/".$sender->name."/sendgift");
}
// Userpoints
$useuserpoints = elgg_get_plugin_setting('useuserpoints', 'gifts');
if($useuserpoints == 1 && function_exists('userpoints_subtract')) {
$pTemp = userpoints_get(elgg_get_logged_in_user_guid());
$points = $pTemp['approved'];
// Set new Point Value
if(userpoints_subtract(elgg_get_logged_in_user_guid(), $cost, 'gifts')) {
system_message(elgg_echo('gifts:pointsuccess'));
}else{
system_message(elgg_echo('gifts:pointfail'));
}
}
// create a gifts object
$gift = new ElggObject();
$gift->description = $body;
$gift->receiver = $receiver;
$gift->gift_id = $gift_id;
$gift->subtype = "gift";
$gift->description = "value";
$gift->access_id = $access;
$gift->owner_guid = elgg_get_logged_in_user_guid();
// save to database
$gift->save();
$sender = get_entity(elgg_get_logged_in_user_guid());
$msgto = get_entity($receiver);
// send mail notification
global $CONFIG;
notify_user($msgto->getGUID(), $sender->getGUID(), elgg_echo('gifts:mail:subject'),
sprintf(
elgg_echo('gifts:mail:body'),
$sender->name,
$CONFIG->wwwroot . "gifts/" . $msgto->username . "/index"
)
);
// Add to river
[0] := Gift Name <- 'Gift-Text' ? <-- $body | Description ??
add_to_river('river/object/gifts/create','gifts',$gift->owner_guid,$gift->discription,$gift->receiver);
system_message(elgg_echo('gifts:sendok'));
// display gift
forward("gifts/".$sender->name."/sent");
'500' means diddley in this context ;) --- caused by *anything (else) at all... yr server logs will say what's causing #500. my guess = you did(or not do) <something *else> to trigger '500'; code above is north & south poles apart re: 500. and by the way - the code i pasted is suggested pseudo (commented out:-oO) code only not full & real code b/c not wanna steal fun of discovering solution from the send.php code by oneself ;-P -> can be fun..
To be able to include the name of the gift in the river entry you first need to modify the add_to_river() call in /action/send.php because this function only allows to include two Elgg object guids to be used in the river entry. Currently, the user sending the gift is included as "subject_guid" and the user receiving the gift is included as "object_guid". Unfortunately, it's not possible to retrieve the gift name later on using these Elgg objects. But by changing the line to
the gift name will be accessible and the receiver name can also be retrieved.
The second problem is to handle river entries for gifts sent that were created prior the change. Unfortunately, these entries will not be changeable and will still not include the gift name. So, the file views/default/river/object/create.php has to be modified accordingly:
You might also want to modify the language strings accordingly, or even include two different strings for old and new river entries. Additionally, it seems necessary to add the language string
to the language file, because this string is called by Elgg automatically (maybe starting with Elgg 1.8.3?).