I agree, I see some extremely great uses for this.
A typo for Brett's query above:
$query = "INSERT INTO elggredirection (subdomain, guid) VALUES ('$escapedURL', '$id')";
Also, I would use insert_data() insert of execute_query()
Ints don't need to be quoted for MySQL ;) But it is probably good practice...
insert_data() is the better function to use! Good catch on that one.
Thanks very much everyone - just to update, execute_query() didn't seem to work at all, whereas insert_data() worked fine, so the code ended up like:
// Save the clean URL to the database with the GUID
$escapedURL = mysql_real_escape_string($page->cleanurl);
$id = mysql_real_escape_string($page->getGUID());
$query = "INSERT INTO elggredirection (subdomain, guid) VALUES ('$escapedURL', '$id')";
insert_data($query);
Now I've just got to make sure when a page is deleted the database entry is removed, which should be as simple as using delete_data(). I'll need to tidy it up before I release it as a plugin (currently I'm putting together an extranet using Elgg), so once I'm done with that I'll post it.
I agree, I see some extremely great uses for this.
A typo for Brett's query above:
$query = "INSERT INTO elggredirection (subdomain, guid) VALUES ('$escapedURL', '$id')";
Also, I would use insert_data() insert of execute_query()
Ints don't need to be quoted for MySQL ;) But it is probably good practice...
insert_data() is the better function to use! Good catch on that one.
Thanks very much everyone - just to update, execute_query() didn't seem to work at all, whereas insert_data() worked fine, so the code ended up like:
// Save the clean URL to the database with the GUID
$escapedURL = mysql_real_escape_string($page->cleanurl);
$id = mysql_real_escape_string($page->getGUID());
$query = "INSERT INTO elggredirection (subdomain, guid) VALUES ('$escapedURL', '$id')";
insert_data($query);
Now I've just got to make sure when a page is deleted the database entry is removed, which should be as simple as using delete_data(). I'll need to tidy it up before I release it as a plugin (currently I'm putting together an extranet using Elgg), so once I'm done with that I'll post it.
I agree, I see some extremely great uses for this.
A typo for Brett's query above:
$query = "INSERT INTO elggredirection (subdomain, guid) VALUES ('$escapedURL', '$id')";
Also, I would use insert_data() insert of execute_query()
Ints don't need to be quoted for MySQL ;) But it is probably good practice...
insert_data() is the better function to use! Good catch on that one.
Thanks very much everyone - just to update, execute_query() didn't seem to work at all, whereas insert_data() worked fine, so the code ended up like:
// Save the clean URL to the database with the GUID
$escapedURL = mysql_real_escape_string($page->cleanurl);
$id = mysql_real_escape_string($page->getGUID());
$query = "INSERT INTO elggredirection (subdomain, guid) VALUES ('$escapedURL', '$id')";
insert_data($query);
Now I've just got to make sure when a page is deleted the database entry is removed, which should be as simple as using delete_data(). I'll need to tidy it up before I release it as a plugin (currently I'm putting together an extranet using Elgg), so once I'm done with that I'll post it.
The flickr/messaging plugins are older and weren't updated to use the built in core views. The advantage of the core views is picking up the same css styles and filtering of content.
You need to post you code here if you want someone to point out any problems.
Well, ideally I want to use the built-in pulldown view, so I have this:
echo elgg_view('input/pulldown',
array( 'name'=>'send_to',
class'=>'sendMsgSelect',
'options_values'=>$friendnames));
...which populates a pulldown with a list of friend name ($friendnames is an array created by iterating through an array of $friend objects), but this doesn't pass anything back to view.php. What I really want to know is if I can just take the array returned by get_friends(), have the user select a friend name, and then have view.php pick up the GUID of that friend. Thanks again.
The hello wodget tutorial says: "The name of the input text box is params[message] because Elgg will automatically handle widget variables put in the array params. The actual php variable name will be message"
You are not using params[] and so Elgg will not automatically pass that variable.
The flickr/messaging plugins are older and weren't updated to use the built in core views. The advantage of the core views is picking up the same css styles and filtering of content.
You need to post you code here if you want someone to point out any problems.
Well, ideally I want to use the built-in pulldown view, so I have this:
echo elgg_view('input/pulldown',
array( 'name'=>'send_to',
class'=>'sendMsgSelect',
'options_values'=>$friendnames));
...which populates a pulldown with a list of friend name ($friendnames is an array created by iterating through an array of $friend objects), but this doesn't pass anything back to view.php. What I really want to know is if I can just take the array returned by get_friends(), have the user select a friend name, and then have view.php pick up the GUID of that friend. Thanks again.
The hello wodget tutorial says: "The name of the input text box is params[message] because Elgg will automatically handle widget variables put in the array params. The actual php variable name will be message"
You are not using params[] and so Elgg will not automatically pass that variable.
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.