Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Group membership

  • Beginning Developers

    Beginning Developers

    This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking

Activity

  • Ivan replied on the discussion topic How to add <select> type fields to profile
    Ok, I thought of posting an update in case the information is useful to someone. The way I solved this was by creating a custom input type under "view/default/input/mycustomtype.php" with the <options> I needed. Then i just... view reply
  • Ivan replied on the discussion topic Add metadata to an ElggObject
    @RvR Brilliant! Thank you! view reply
  • Ivan replied on the discussion topic Add metadata to an ElggObject
    @RvR thanks for the brilliant reply. I have a doubt tough, the method requests a user entity, I should then attach it to the user?, my code goes like this: $post = new ElggObject(); $post->subtype =... view reply
  • Ivan added a new discussion topic Add metadata to an ElggObject in the group Beginning Developers
    I have an ElggObject that works pretty much like The Wire. How can I add metadata to this?  Basically, I'm looking to add two extra fields to each post. The point is to later try query/filter based on the value of this extra item.
    • @RvR thanks for the brilliant reply. I have a doubt tough, the method requests a user entity, I should then attach it to the user?, my code goes like this:

      $post = new ElggObject();
      
      $post->subtype = 'match';
      
      $post->owner_guid = $userid;
      
      $post->access_id = $access_id;
      
      // this is what I'm looking ot add to the object.
      
      $post->somedata = $somedata1;
      
      $post->moredata = $somedata2;

      Then if I understood correctly, in order to add `somedata`and `moredata` to that object, I should then attach the metadata to ...the user?

      create_metadata($userid, 'somedata', $somedata1, 'text', $userid, 2);

      If so, I'm a bit confused. How would I get this metadata to display?  By getting the userId from getObjectEntity() then trying to get the user?   would this be the right way to do it?

    • Edited

      If you want to add metadata to 'object' ($post) then you should create metadata for it:

      create_metadata($post->guid, 'metadata_name', 'metadata_value', 'text', $userid, ACCESS_PUBLIC);

      For getting metadata from $post just use:

      $somedata1 = $post->somedata;
      
      $somedata2 = $post->moredata;

      If you know the post's GUID only then use elgg_get_metadata_from_id function.

      If you want to display posts by metadata then use elgg_get_entities_from_metadata function:

      echo elgg_get_entities_from_metadata(array(
      
         'type' => 'object',
      
         'subtype' => 'match',
      
         'metadata_name' => 'somedata',
      
         'metadata_value' => $value,
      
         'limit' => 0
      
      ));

      etc

      Some examples for creating metadata: 1, 2

      More metadata tests also.

      And more...

    • @RvR Brilliant! Thank you!

  • Ivan replied on the discussion topic How to add <select> type fields to profile
    Thanks @jerome ! I'll keep this idea as backup. The reason why I'm not using it just yet is that in this project, a specific user type has to have some fields available, and other user types have a different sets available, and in... view reply
  • Ivan replied on the discussion topic How to add <select> type fields to profile
    @jerome  Very nice plugin, it seems to do most I need. I however am looking to do it in a more programatically way, so when I move to the production server I don't have to run the fields setup again, and neither other developers when... view reply
  • Ivan added a new discussion topic How to add <select> type fields to profile in the group Beginning Developers
    I have created at a plugin to add some custom fields in the registration form. Some of these fields are dropdowns  (<select>... <option></option> ......</select>) . But I'm not sure how to display these new fields...
    • There is no way to do it programatically, however you can export the field config and import it on another site. So that's a thing

    • Thanks @jerome ! I'll keep this idea as backup. The reason why I'm not using it just yet is that in this project, a specific user type has to have some fields available, and other user types have a different sets available, and in the registration form we are "hiding" and "showing" fields depending on selection. So in order do manage this part I think is easier to keep the project's own plugin idea for now. 

      The main problem I'm facing now is just to extend somehow profile to just show a 'dropdown' type.  Open to more suggestions or ways to approach this.  Thanks!

    • Ok, I thought of posting an update in case the information is useful to someone. The way I solved this was by creating a custom input type under "view/default/input/mycustomtype.php" with the <options> I needed. Then i just specified the type of input as "mycustomtype" when needed, or called it through elgg_view('input/mycustomtype'). 

  • Ivan joined the group Beginning Developers