Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Activity

  • lxt05 replied on the discussion topic SQL Query from plugin in the group Plugin Development
    First off, I know it's not recommended for a plugin to deal directly with the database. Bear with me. I am writing a plugin that creates clean URLs for pages - for example: myelggsite.com/mypage ...redirects...
    • 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.

  • lxt05 replied on the discussion topic SQL Query from plugin in the group Plugin Development
    First off, I know it's not recommended for a plugin to deal directly with the database. Bear with me. I am writing a plugin that creates clean URLs for pages - for example: myelggsite.com/mypage ...redirects...
    • 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.

  • lxt05 added a new discussion topic SQL Query from plugin in the group Plugin Development
    First off, I know it's not recommended for a plugin to deal directly with the database. Bear with me. I am writing a plugin that creates clean URLs for pages - for example: myelggsite.com/mypage ...redirects...
    • 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.

  • lxt05 joined the group Plugin Development
  • lxt05 replied on the discussion topic Annoyingly simple widget dev question in the group Elgg Technical Support
    I have what should be a really simple problem that I'm having trouble working with. I have a widget that I've written that displays a blog feed that the user can select. I would like the user to have a pulldown menu displaying all their friends in...
    • 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.

  • lxt05 added a new discussion topic Annoyingly simple widget dev question in the group Elgg Technical Support
    I have what should be a really simple problem that I'm having trouble working with. I have a widget that I've written that displays a blog feed that the user can select. I would like the user to have a pulldown menu displaying all their friends in...
    • 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.

  • lxt05 joined the group Elgg Technical Support