Omeka Classic Logo
  • What’s new in Omeka
  • Tutorials
  • Reference
    • Global (Theming) Functions
    • Hooks
    • Filters
    • models
    • views/helpers
    • controllers
    • Packages
      • Acl
      • Application
      • Auth
      • Captcha
      • Controller
      • Db
      • File\Derivative
      • Filter
      • Form
      • Global Functions
        • Db-related functions
        • Locale-related functions
        • Log-related functions
        • Plugin-related functions
        • Search-related functions
        • Text-related functions
        • User-related functions
        • Utility-related functions
        • View-related functions
      • Http
      • Install
      • Job
      • Navigation
      • Output
      • Plugin
      • Record
      • Session
      • Storage
      • Test
      • Validate
      • View
    • libraries/Omeka
    • Omeka REST API
  • Helping With Documentation
  • Registering a new module or theme with omeka.org
Omeka Classic
  • Reference
  • Global (Theming) Functions
  • browse_sort_links — Get the list of links for sorting displayed records.
  • View page source

browse_sort_links — Get the list of links for sorting displayed records.

View-related functions

Summary

browse_sort_links($links, $wrapperTags = array())

Get the list of links for sorting displayed records.

Parameters:
  • $links (array) – The links to sort the headings. Should correspond to the metadata displayed.

  • $wrapperTags (array) – The tags and attributes to use for the browse headings - ‘list_tag’ The HTML tag to use for the containing list - ‘link_tag’ The HTML tag to use for each list item (the browse headings) - ‘list_attr’ Attributes to apply to the containing list tag - ‘link_attr’ Attributes to apply to the list item tag

Returns:

string

Usage

Generates HTML elements for sorting based on the metadata given.

When the records are presented as a table, as in most admin browse views, $wrapperTags should be:

array('link_tag' => 'th scope="col"', 'list_tag' => '')

Otherwise, you will want to add text and/or styling to make clear that the list presented is for sorting the displayed records.

Examples

Use the links array to set the properties on which items can be sorted in the browse views. The labels are arbitrary, while the property names are determined by the element set or the record model.

<?php
  $sortLinks[__('Title')] = 'Dublin Core,Title';
  $sortLinks[__('Creator')] = 'Dublin Core,Creator';
  $sortLinks[__('Date Added')] = 'added';
?>
<div id="sort-links">
    <span class="sort-label"><?php echo __('Sort by: '); ?></span><?php echo browse_sort_links($sortLinks); ?>
</div>

Include the wrapperTags array when creating a sortable table, as in the admin view. Note that the column with the “Type” label is not sortable because no property name has been entered.

<?php
$browseHeadings[__('Title')] = 'Dublin Core,Title';
$browseHeadings[__('Creator')] = 'Dublin Core,Creator';
$browseHeadings[__('Type')] = null;
$browseHeadings[__('Date Added')] = 'added';

echo browse_sort_links($browseHeadings, array('link_tag' => 'th scope="col"', 'list_tag' => ''));
?>

See Also

Previous Next

© Copyright 2012-2023, Omeka.

Built with Sphinx using a theme provided by Read the Docs.