$options = [
'type' => 'object',
'subtype' => 'posts',
'limit' => 10,
];
$entities = elgg_get_entities($options);
$values = [];
foreach($entities as $entity) {
$values[] = $entity->area;
}
echo var_export($values, true);
$metadata = elgg_get_metadata([
'type' => 'object',
'subtype' => 'posts',
'metadataname' => 'area',
'limit' => false,
'batch' => true, // if you have a lot of posts
]);
$values = [];
foreach ($metadat as $md) {
$values[] = $md->value;
}
$unique = array_unique($values);
There are metadata function, no need to get it through the entities.
'metadata_names' => 'area',
instead of
'metadataname' => 'area',
So I have a mandatory form I want them to fill out before the access any other page on the site.
1 - In the form:
Add 'required' => true param to the mandatory field.
2 - In the action:
Check the value for the mandatory field:
if(!$request->getParam('param')) {
return elgg_redirect_response($url);
}
3 - Validate the field:
You may want to validate all values in the form before sending them to server (via action).
You can use some libs for this (google it).
Look at this plugin also.
Sorry, I'm looking to not give them access to any other pages until they feel out a form.
Override this view:
\views\default\page\elements\topbar.php
By deleting:
<?= elgg_view('core/account/login_dropdown') ?>
You already asked about it here.
Your question is similar to the previous one.
Add
'order_by_metadata' => [
'name' => 'customtime',
'direction' => 'DESC',
'as' => 'integer',
],
as option within elgg_get_entities or elgg_list_entities. DESC or ASC sets the direction the results are ordered.
$matching_entities = elgg_get_entities([
'type' => 'object',
'subtype' => 'user_status',
'metadata_name_value_pairs' => [
[
'name' => 'status',
'value' => 'notactive',
'operand' => '=',
],
[
'name' => 'approved',
'value' => 'yes',
'operand' => '=',
],
[
'name' => 'count',
'value' => '3',
'operand' => '>',
],
],
]);
Elgg only uses Datepicker Widget by default.
Therefore, you're limited only by its API.
To use multidate you need to use https://github.com/ehynds/jquery-ui-multiselect-widget
Try to use elgg_list_entities with these 'wheres' clauses:
'wheres' => function(QueryBuilder $qb, $alias) {
$qb->joinMetadataTable($alias, 'guid', 'status', 'left', 'ma');
return $qb->merge([
$qb->compare('ma.name', '=', 'status', ELGG_VALUE_STRING),
$qb->compare('ma.value', '=', 'active', ELGG_VALUE_STRING),
]);
},
what is $qb and $alias?
And that kind of attitude is why open source projects die. People get afraid to ask questions or suggest input. Thanks for your help though.
And that kind of attitude is why open source projects die.
All I am saying is that people like free buffet. All the solution just served to them on plates. A little curiosity is good. It help you learn new things (and sometimes also contribute to the open source projects, which will definitely keep the project alive). If you would have tried to understand what the piece of code does you could have easily found the solution on your own.
Anyways, It was not to offend you. I am sorry if it was in-appropriate in any way.
Imho Rohit Gupta has provided actual help with actual code. This is what helps a forum as well as open source run. While this will be out of topic : open source projects' deaths have got nothing to do ( or more or less nothing to do) with "attitudes" in general. During the past 10 years or so there has been no significant new open source project in php. No new open source web scripting language as successful as php too. Just think projects like Elgg, Wordpress, Drupal will never happen again. The world is now sheepishly slave to the trio Google-Apple-Facebook. Many entities now have only fb/ address in billboards and elsewhere and not www address. Apps are killing the open and interconnected net, and for Apps you have to be "slave" to Google or Apple ( and MS). Why Apps are something not like http html php websites - where you host your own either on free or paid servers or even your own server ?? No one complains, no lawsuits !!
Opensource generation is a dying generation thus. Despite several ongoing projects, its not that the flourishing majority when Tim Lee "invented" www and Rasmus Lerdorf "created" Php. Its sad. Many "opensource" projects got sold to biggies. And many opensource projects made their own commercial firms like Wordpress and Drupal. Opensource and money earning has no conflict with each other as such ( without money you cannot survive) but the spirit ... I dont know. There will be no more "whiz kids" like Matt (Wordpress), Dries (Drupal) or for that matter Ben Werdmuller who started Elgg but has shifted to other priorities now ( I think so). Many opensource projects actually died as the young ones who started these needed money for survival ( or needed to be "more rich") and commercialization of open source was not that much success for most of them. So they had to devote more and more time to jobs ( or in some cases their own companies or in the companies which "purchased" them). Elgg 2x has many and many more plugins( and thus more adoption) than Elgg 3x will ever have because of the same reason. The number of interested and talented youth who could have contributed are now in look out for actual jobs and money or are absorbed passively in the Apps world or rather than trying out php are chatting on Fb. The existing opensource projects do have some flaws which do not let them flourish, that is another issue.
Short answer: "no". The "jpg" extension is hard-coded and the Elgg core code is written to create jpg files.
Longer (incomplete) answer. "maybe". The creation of the icon files is not done completely within saveIconFromUploadedFile() but there is a cascade of functions that are involved (the functions are split to be able to deal with different parts of the work separately to be able to reuse them depending on the requirements in different situations). The function saveIconFromUploadedFile() calls the functions saveIcon() and within this function the plugin hook "entity:<type>:save", "<entity_type>" is triggered (for example for creation of icons for entities of type object it would be "entity:icon:save", "object"). This seems the only point in the process where you could interrupt Elgg with dealing with the icon creation when registering a callback function for this plugin hook. But then you would have to implement your own code that creates the icon file within this callback function. Additionally, there might be other issues arise then if the icon files are saved as png and not jpg when Elgg tries to output the files expecting it to be jpg files and therefore might serving them with the wrong mimetype which could cause trouble with displaying the images in the browsers (I think Chrome is very sensible with regards to filetype/mimetype).
Short answer: yes.
Maybe a bit more details... For example Tidypics has a page that lists photos in order of most recent comments. The code (in mod/tidypics/views/default/resources/tidypics/lists/recentlycommented.php) used to get the entities in the corresponding order is
$db_prefix = elgg_get_config('dbprefix');
$options = array(
'type' => 'object',
'subtype' => 'image',
'limit' => $limit,
'offset' => $offset,
'joins' => array(
"JOIN {$db_prefix}entities ce ON ce.container_guid = e.guid",
"JOIN {$db_prefix}entity_subtypes cs ON ce.subtype = cs.id AND cs.subtype = 'comment'"),
'order_by' => "ce.time_created DESC",
'full_view' => false,
'list_type' => 'gallery',
'gallery_class' => 'tidypics-gallery'
);
$result = elgg_list_entities($options);
Of course, you would have to modify it a bit for other type of entities and implement it within a view that outputs it. For further reference you could take a look at the code of the Tidypics plugin.
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.