how to get metadata names for specific subtype?

$metadata = array('name' => 'metadata_name', value => 'metadata_value');

$options = array(

   'type' => 'object',

   'subtype' => 'my_subtype',

   'metadata_name_value_pairs' => $metadata,

);

$result = elgg_get_entities_from_metadata($options);

 

  • What do you want to achieve? If an entity has metadata either Elgg or a plugin would have added this metadata and you would find out the metadata_name in the code. If you would want to work with some metadata for some specific entity subtype, you would know from looking at the code what the name is. I don't think that some general advice how to find out about some metadata_name is of much help here. Just look at the code that deals with creation of the metadata in the first place.

  • Thanks iionly! What I wanted to achieve is to create a filter function that takes metadata_value as an input, i.e. "SELECT * FROM my_table WHERE metadata_name = 'metadata_value'".

  • I don't see how a general filter of metadata names for unspecific entity types/subtypes would make sense. You can use the entity explorer of the Elgg Developer tools plugin to get an idea what kind of metadata are connected to different type of entities. For example, blogs have metadata "status", "comments_on" and "excerpt". I don't see how any of these metadata types would give any useful search results. It might be different for some specific entity subtypes where some metadata would make sense to be used in a filter. But then I would think it would still be the only useful way to build up the filter specifically limited to certain entity subtypes and corresponding metadata_names (which you could either find out about using the entity explorer or maybe still better by looking into the code to figure out under what condititions a metadata exists in the first place).

    The activity page already has a filter for entity subtypes. Maybe you could use the code used for this filter to have a subtype filter. Then you might want to add an additional criteria for limiting search results for example by time_created between lower and upper limits (elgg_g* functions have parameters for that). I don't know what other features for a filter would make sense.

  • Thanks again iionly. I know I left out the type and subtype in my query above :). I am going to study those Elgg Developer tools as you suggested

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