Skip to content

Instantly share code, notes, and snippets.

@ivandoric
Created April 23, 2014 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivandoric/11215483 to your computer and use it in GitHub Desktop.
Save ivandoric/11215483 to your computer and use it in GitHub Desktop.
drupal: Example of EntityFieldQuery to make Flex slider in Drupal
<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->propertyCondition('status', 1)
->propertyCondition('type', array('slider_gornji'))
->propertyOrderBy('created', 'DESC')
->range(0, 5);
$result = $query->execute();
$nodes = node_load_multiple(array_keys($result['node']));
#print_r($nodes);
?>
<ul class="slides">
<?php foreach ($nodes as $slide) { ?>
<li style="background:url(http://did.gaussdev.com/sites/default/files/styles/main_slider_image/public/<?php print render($slide->field_slika['und'][0]['filename']); ?>) no-repeat top center">
<div class="slide-text">
<h2><?php print render($slide->title); ?></h2>
<p><?php print substr(render($slide->body['und'][0]['value']), 0, 200); ?></p>
<a class="more-link" href="<?php print render($slide->field_link['und'][0]['value']); ?>">Saznajte više...</a> </div><!--/slide-text-->
</li>
<?php /*print render($lokacija->field_naziv_tvrtke[LANGUAGE_NONE]['0']['value']).'<br />';*/ ?>
<?php } ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment