Change 'Recently Added' to 'Recently Updated' on Front Page

Hey,

I would like to modify the ‘Recently Added’ feature of Omeka Classic so that instead of using the date added (which I am guessing it is using) for a record, it instead uses the date modified. I am using the Berlin theme. Any advice?

Thx.

–Eric

That’ll call for some changes to the index.php file in the theme’s directory.

Instead of what’s currently there for the recent-items div, use this:


    <div id="recent-items">
        <h2><?php echo __('Recently Updated Items'); ?></h2>
        <?php
            $num = 3;
            $updatedItems = get_db()->getTable('Item')->findBy(array('sort_field' => 'modified', 'sort_dir' => 'd'), $num);
            $html = '';
            $view = get_view();
            foreach ($updatedItems as $updatedItem) {
                $html .= $view->partial('items/single.php', array('item' => $updatedItem));
                release_object($updatedItem);
            }
            echo $html;
        ?>
        <p class="view-items-link"><a href="<?php echo html_escape(url('items')); ?>"><?php echo __('View All Items'); ?></a></p>
    </div><!--end recent-items -->

This basically cobbles together pieces from the recent_items() function and the get_recent_items() function that it uses, then switches it to sort by modified instead of added. $num in the above code is the number of recently updated items to display.

Works like a charm. Thx!!

–Eric

Great! I just noticed a tiny inefficiency in my cobbling, though. Instead of setting the $view variable, you can directly use the view from the theme file:

$html .= $this->partial('items/single.php', array('item' => $updatedItem));

and get rid of the

$view = get_view()

Not a big deal, but just a little redundant and sloppy on my part!