fixed articles in home base materials grid
This commit is contained in:
parent
cc9ceede26
commit
d49700753a
|
@ -37,18 +37,23 @@ class ComputedMaterialsReferences extends EntityReferenceFieldItemList
|
|||
* Compute the values.
|
||||
*/
|
||||
protected function computeValue() {
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'materiau')
|
||||
->exists('field_materiau_images')
|
||||
->condition('field_materiau_images.%delta', 3, '>')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,200);
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
$storage = \Drupal::service('entity_type.manager')->getStorage('node');
|
||||
$query = $storage->getQuery()
|
||||
->condition('status', 1)
|
||||
->condition('type', 'materiau')
|
||||
->condition('field_materiau_images.%delta', 3, '>')
|
||||
->exists('field_materiau_images')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,200);
|
||||
$results = $query->execute();
|
||||
if ($results) {
|
||||
$nids = array_rand($results, 100);
|
||||
$nids = array_values($results);
|
||||
shuffle($nids);
|
||||
array_slice($nids, 0, 100);
|
||||
// $nids = $results;
|
||||
$i = 0;
|
||||
foreach ($nids as $nid) {
|
||||
foreach ($nids as $key => $nid) {
|
||||
$this->list[$i] = $this->createItem($i, $nid);
|
||||
$i++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue