Skip to content
victorjonsson edited this page Oct 30, 2014 · 1 revision

When you create an article your're able to choose a "format" for the article (check point 6 in the interface walkthrough). An article format is nothing more than a class that will be added to the DIV element containing the article. Here's how the code could look like if you want to add your own formats:

<?php
function my_arlima_formats() {
    // Format that will be possible to choose for all templates
    arlima_register_format('my-format-class', 'My format label');

    // Format that only will be possible to choose for the template giant.tmpl
    arlima_register_format('my-other-format', 'My other format label', array('giant'));
}
add_action('arlima_register_formats', 'my_arlima_formats');

And in your stylesheet you would have something like:

.tmpl-article.my-format-class {
  /* some cool looking CSS that only will be applied to articles having this format */
}

.tmpl-article.my-other-format {
  /* some cool looking CSS that only will be applied to articles having this format */
}

Notice! You must use a custom css file if you want the format to be displayed in the article preview

Registering and deregistering formats

arlima_register_format($format_class, $label, $templates=array(), $ui_color='');

  • $format_class — Class name of that will be applied to the article container
  • $label — The label for the format, displayed in the list manager (check point 6 in the interface walkthrough)
  • $templates — Optional array with names of the templates that should support this format. It's important that each template name is the file name with the path and extension stripped out. Set this argument to an empty array if the format should be supported by all templates
  • $ui_color — Optional string with a HEX-color used as border color on all articles, having this format, in the list manager.

arlima_deregister_format($format_class, $templates=array());

  • $format_class — The format you want to remove from the list manager
  • $templates=array() — The templates that you declared to support this format when you called arlima_register_format()

Example

wp-content/themes/parent-theme/functions.php

function parent_theme_arlima_formats() {
   // Deregister the formats provided by arlima
   arlima_deregister_format('format-serif');
   arlima_deregister_format('format-inverted', array('giant'));

   // Register some awesome formats

   arlima_register_format(
       'format-pink-panther', 
       'Pink panther', 
       array('default-article', 'sidebar-article'), 
       '#FF6699'
     );

 arlima_register_format(
       'format-blue-whale', 
       'Blue Whale', 
       array(), 
       '#0066FF'
     );
}
add_action('arlima_register_formats', 'parent_theme_arlima_formats');

wp-content/themes/child-theme/functions.php

function child_theme_arlima_formats() {
   // This child theme should not support any of the silly formats
   // provided by the parent theme
   arlima_deregister_format('format-pink-panther', array('default-article', 'sidebar-article'));
   arlima_deregister_format('format-blue-whale');
}
add_action('arlima_register_formats', 'child_theme_arlima_formats');

This Wordpress plugin was created by Swedish newspaper Västerbottens-Kuriren to give its editorial staff an easy to use tool for customizing the front pages of their online magazines.

Installing Arlima

  1. Download the latest release from github and unzip the folder in your plugin directory.
  2. Open up wp-admin and activate the plugin.
  3. Go to "Article lists" -> "Edit lists" in wp-admin and create your first article list.
  4. Open up a page (or create it) in wp-admin. Down to the right you will see a meta box labeled "Arlima" where you choose the list that you created on step 2.
  5. Go to "Article lists" -> "Manage lists" and start stuffing your article list with interesting content.

Top links

Clone this wiki locally