Hi, I'm having a lot of trouble with getting a custom records loop to work on the browse.php page. I've tried all the things from these instructions, but no luck.
https://omeka.org/codex/Create_a_Custom_Loop_of_Items
Hi, I'm having a lot of trouble with getting a custom records loop to work on the browse.php page. I've tried all the things from these instructions, but no luck.
https://omeka.org/codex/Create_a_Custom_Loop_of_Items
Could you post up the code that you currently have, and which browse.php file (e.g., items, collections, etc)?
Sure, here it is:
<?php
set_items_for_loop(get_items(array('featured' => true),50));
?>
<?php if(has_items_for_loop()): ?>
<!-- Loop for items -->
<?php while(loop_items()): ?>
<div class="item">
<h2><?php echo link_to_item(); ?></h2>
<p><?php echo item('Dublin Core', 'Creator'); ?></p>
</div>
<?php endwhile; ?>
<?php else: ?>
<!-- Message if there are no items -->
<p>No items</p>
<?php endif; ?>
ah, sorry. I should've looked more closely at the link.
That's for Omeka 1.x. Guessing that you are using Omeka 2.x, you'll want to refer to the Omeka 2 documentation
Thanks, I just worked that out. Are there any examples showing how to do a custom loop for omeka 2.x versions?
This updating guide will help show the changes from your code to the Omeka 2 code.
Ok, so I have translated some things to omeka 2.x. But I can't work out how to load a custom list of items into the loop.
<?php
set_loop_records('items', get_records('items',array('featured' => true ),20));
?>
Ok, so the get_records function needs 'Item' as the type not 'items'. This seems to work:
<?php
$items = get_records('Item', array(), 25);
set_loop_records('items', $items)
?>