Wait, what is a Cultural Heritage Technologist?

A Cultural Heritage Technologist is a “double domain expert”, straddling the line between technologist and museologist. We deal with web development, digitization of collections, digital asset management, and archive and museum informatics.

Posts Tagged ‘Roman Numerals’

An Adventure in arbitrary PHP in WordPress.

posted August 6th, 2009 to Code, Server Side

One of the finishing touches I wanted to add to this blog theme was a copyright
statement in roman numerals. Inserting arbitrary PHP into WordPress isn’t as straightforward as it should be, so I’ve outlined instructions below:

1. Edit the functions.php file of your theme to add the following code (courtesy Pradeep S).

// A function to return the Roman Numeral, given an integer
  function numberToRoman($num){
    // use int value
    $n = intval($num);
    $result = '';
    $lookup = array(
      'M' => 1000, 
      'CM' => 900, 
      'D' => 500, 
      'CD' => 400,
      'C' => 100, 
      'XC' => 90, 
      'L' => 50, 
      'XL' => 40,
      'X' => 10, 
      'IX' => 9, 
      'V' => 5, 
      'IV' => 4, 
      'I' => 1
     );
 
    foreach ($lookup as $roman => $value){
      $matches = intval($n / $value);
      $result .= str_repeat($roman, $matches);
      $n = $n % $value;
  }
  return $result;
}

2. Edit the footer.php file in the theme to add a reference to the new function in the copyright block.

    <div id="footer" class="grid_12">
      <p>&copy; <?php echo numberToRoman(date("Y")); ?></p>
    </div>
  <?php wp_footer(); ?>
</body>

3. You’re done!