Change Citation style

Hi. I want to change the style of the citation on Items. Can you help how to do it?

You need to create a plugin to do this, but luckily that's not very difficult. I just did the same thing. First, you need to create a plugin.ini file following the guidelines.

http://omeka.readthedocs.org/en/latest/Tutorials/pluginStructure.html

Then, you just need to add one function in your plugin file, say it's called MyCitations. What I did was copy the existing Citation function and change it as needed. Put it in your plugins directory, install it, and you're good to go! This will change the way citations are formatted whenever they are called. There's no need to change anything in items/show.

<?php

class MyCitationPlugin extends Omeka_Plugin_AbstractPlugin
{
	protected $_filters = array('item_citation');

	public function filterItemCitation($citation, $args)
	{
		$citation = '';

		$creators = metadata('item', array('Dublin Core', 'Creator'), array('all' => true));
	/// Strip formatting and remove empty creator elements.
		$creators = array_filter(array_map('strip_formatting', $creators));
		if ($creators) {
			switch (count($creators)) {
				case 1:
				$creator = $creators[0];
				break;
				case 2:
	/// Chicago-style item citation: two authors
				$creator = __('%1$s and %2$s', $creators[0], $creators[1]);
				break;
				case 3:
	/// Chicago-style item citation: three authors
				$creator = __('%1$s, %2$s, and %3$s', $creators[0], $creators[1], $creators[2]);
				break;
				default:
	/// Chicago-style item citation: more than three authors
				$creator = __('%s et al.', $creators[0]);
			}
			$citation .= "$creator. ";
		} else {
			$citation .= "Unknown. ";
		}
	/// Get year
		$date = strip_formatting(metadata('item', array('Dublin Core', 'Date')));
		if ($date) {
			switch ($date) {
				case (preg_match('/([0-9]{1,}\-)([0-9]{1,}\-)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{1,}\-)([0-9]{1,}\-)([0-9]{4})/', "$3", $date);
					break;
				case (preg_match('/([0-9]{1,}\-)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{1,}\-)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([A-z]{1,}\,)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([A-z]{1,}\,)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([A-z]{1,}\s)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([A-z]{1,}\s)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([A-z]{1,}\s[0-9]{1,}\,)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([A-z]{1,}\s[0-9]{1,}\,)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([A-z]{1,}\s[0-9]{1,}\s)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([A-z]{1,}\s[0-9]{1,}\s)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([0-9]{4})(\-)([0-9]{1,})(\-)([0-9]{1,})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{4})(\-)([0-9]{1,})(\-)([0-9]{1,})/', "$1", $date);
					break;
				case (preg_match('/([0-9]{4})(\-)([0-9]{1,})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{4})(\-)([0-9]{1,})/', "$1", $date);
					break;
				case (preg_match('/([0-9]{1,}\/[0-9]{1,}\/)([0-9]{4})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{1,}\/[0-9]{1,}\/)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([0-9]{1,}\/)([0-9]{2,})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{1,}\/[0-9]{1,}\/)([0-9]{4})/', "$2", $date);
					break;
				case (preg_match('/([0-9]{1,}\/[0-9]{1,}\/)([0-9]{2})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{1,}\/[0-9]{1,}\/)([0-9]{2})/', "19$2", $date);
					break;
				case (preg_match('/([0-9]{1,}\/)([0-9]{2,})/', $date) ? true : false):
					$date = preg_replace('/([0-9]{1,}\/[0-9]{1,}\/)([0-9]{2})/', "19$2", $date);
					break;

				default:
					$date = $date;
			}
				$citation .= "$date. ";
		}
		$title = strip_formatting(metadata('item', array('Dublin Core', 'Title')));
		if ($title) {
			$citation .= "“$title.” ";
		}
	/// Chicago-style item Publisher and Archive
		$citation .= "Repository Name";

		$accessed = format_date(time(), Zend_Date::DATE_LONG);
		$url = html_escape(record_url('item', null, true));
	/// Chicago-style item citation: access date and URL
		$citation .= __('accessed %1$s, %2$s.', $accessed, $url);
		return $citation;
	}
}

Thanks, sheepeeh. Unfortunately, I'm not good at making plugins. About our site citation must be Harvard style. Can you help me with this?

I am not familiar enough with the Harvard style to do this. But if it helps, to re-arrange the order of the elements in the citation, you just rearrange where they appear within the plugin. e.g. if URL came before title, you'd move:


$accessed = format_date(time(), Zend_Date::DATE_LONG);
$url = html_escape(record_url('item', null, true));
/// Chicago-style item citation: access date and URL
$citation .= __('accessed %1$s, %2$s.', $accessed, $url);

to above


$title = strip_formatting(metadata('item', array('Dublin Core', 'Title')));
if ($title) {
	$citation .= "“$title.” ";
}

If any elements are missing, I can tell you where to add them.