Theme Functions for Omeka 0.9

Please Note: The following documentation reflects theme functions included in Omeka version 0.9. Updated documentation is on the Theme API page, and reflects changes in versions 0.10 and later releases.

css()

Returns the path to a css file in your public template, usually located in themes/yourtheme/css

Available arguments:

  • $file: the name of the file.
<link rel="stylesheet" href="<?php echo css('screen'); ?>" />

Returns:

<link rel="stylesheet" 
      href="http://example.com/themes/yourtheme/screen.css" />

collection()

Returns a specific collection by ID

collections()

Returns an array of collections.

common()

Include a partial template within a theme page.

Available arguments:

  • $file: The name of the file (stored in the 'common' directory)
  • $vars: One or more variables to pass to the partial file. These are passed by giving an array of key => value pairs.

Example:

<?php common('archive-nav', array('tags'=>$item->Tags)); ?>

current_user()

Returns the User object for the currently logged-in user. The User object can be used to display information for the user such as first/last name, email address, username, and role (admin, researcher, etc.). This function returns false if there is no user currently logged in.

Example:

<?php if($user = current_user()): ?>
<p>Hello <?php echo $user->first_name; ?>!</p>  
You are registered under the following email address: <?php echo $user->email; ?>
<?php endif; ?>

display_empty()

Echoes a fully escaped and html-safe string, or if the string is empty, it displays a placeholder value.

Available arguments:

  • $val: Any string.
  • $alternative: Default value of "[Empty]", which will display if the given string is empty.

Example:

<?php echo display_empty($item->description); ?>

Outputs:

<p>Here is the description</p>

entities()

Returns an array of entities.

flash()

Returns any error messages, alerts, etc. that Omeka would need to display on a given page.

Available arguments:

  • $wrap: (true/false) Whether or not to wrap the message in a div with an appropriate class, i.e.
    <div class="error">Msg</div>
    Default value is true.

Example:

<?php echo flash(); ?>

Outputs:

<div class="alert">You are not wearing pants!</div>


foot()

Include the footer for the template, which is most commonly 'footer.php' in the common directory.

For more information, see #head()

fullsize()

h($str [,$allowedTags])

A wrapper for htmlentities() with some more interesting behavior. h() escapes a piece of text to make it html safe, but it leaves intact a certain subset of tags which is specified as an argument. $allowedTags should be a string of pipe separated tags, for example, "i|em|b|strong|del|span". By default, i, em, b, strong, del, and span tags are allowed.

has_collectors()

Determine whether or not a specific collection has collectors.

Available arguments:

  • $collection: The collection that is to be tested.

Returns: boolean

Example:

<?php if(has_collectors($collection) ): ?>
    <h3>Collector(s)</h3>
        <div class="field-value">
            <ul><?php foreach($collection->Collectors as $collector):?>
                <li><?php echo nls2p(h($collector->name)); ?></li>
                <?php endforeach; ?>
            </ul>
        </div>
<?php endif; ?>

has_collection()

Determine whether or not a specific Item has a Collection associated with it.

Available arguments:

  • $item: The Item object that is to be tested.

Returns: boolean

has_files()

Determine whether or not an item has any files associated with it.

Example:

<?php if(has_files($item): ?>
<div id="files-for-item">
This div only shows up if the Item has some files!
</div>
<?php endif; ?>

has_permission()

has_tags()

has_thumbnail()

has_type()

head()

img()

Returns a path to a file in the "images" directory in a public theme.

Example:

<img src="<?php echo img('image.jpg'); ?>" />

is_current()

item()

Returns a specific item by ID.

items()

Returns an array of items.

items_search_form()

Returns an advanced search form for searching items. Function has three arguments: The first are any attributes to the <form> element you want to add (id, class, et cetera); the second is the path you want the search results to go (usually items/browse); the third allows you to set the toggle for advanced search to true or false (true by default).

Example:

<?php 
echo items_search_form(array('id'=>'searchform'), uri('items/browse'), false); ?>

link_to()

link_to_collection()

link_to_exhibit()

link_to_home_page()

Returns an html anchor to omeka's WEB_ROOT.

Available arguments:

  • $text: the text to be used as the link.
  • $props: an array of properties to be used as tag attributes.
<?php echo link_to_home_page('View Public Site', array('id'=>'public-link')); ?>

Returns:

<a href="http://example.com/omeka" id="public-link">View Public Site</a>

link_to_item()

link_to_thumbnail()

link_to_fullsize()

link_to_next_item()

link_to_previous_item()

nav()

Generate a navigation list

Available arguments:

  • $links: array Key = Text of Navigation, Value = Link
<?php echo nav(array('Items' => uri('items'),
   'Exhibits' => uri('exhibits'))); ?>"

Returns:

<li class="nav-items current">
  <a href="http://example.com/omeka/items">Items</a></li>
<li class="nav-exhibits">
  <a href="http://example.com/omeka/exhibits">Exhibits</a></li>

nls2p()

Turns two or more consecutive line feeds within a string into a <p> ... </p> combination.

Example:

<?php echo nls2p("This is a test\n\n"); ?>

Result:

<p>This is at test</p>

pagination_links()

path_to()

people()

Returns an array of people.

random_featured_item()

Returns a random item that has been checked "featured."

recent_collections()

Returns an array of collections most recently added to your Omeka installation.

Available arguments:

  • $num: the number of collections to return in the array. Default = 10.

recent_exhibits()

Returns an array of exhibits most recently added to your Omeka installation.

Available arguments:

  • $num: the number of exhibits to return in the array. Default = 10.

recent_items()

Returns an array of items most recently added to your Omeka installation.

Available arguments:

  • $num: the number of items to return in the array. Default = 10.

recent_tags()

Returns an array of tags most recently added to your Omeka installation.

Available arguments:

  • $num: the number of tags to return in the array. Default = 30.

settings()

snippet()

square_thumbnail()

src()

tag_cloud()

tag_string()

tags()

Returns an array of tags.

text_to_id()

theme_path()

thumbnail()

total_collections()

Returns the total number of collections added in your Omeka installation.

total_items()

Returns the total number of items added to your Omeka installation

total_results()

Returns the total number of results for a query.

total_tags()

Returns the total number of tags added to your Omeka installation.

total_types()

Returns the total number of types added to your Omeka installation.

total_users()

Returns the total number of of users added to your Omeka installation.

type()

Returns a specific type.

types()

Returns an array of types.

uri()

users()

Returns an array of users.

web_path()