Sounding out ideas on language, vivid sensory words, and iconicity

Now live: SemiotiX New Series, a WordPress-based e-journal

Now online: SemiotiX New Series, an e-journal in semiotics. SemiotiX Bulletin has been around for several years, in hand-edited HTML. Its reincarnation, SemiotiX New Series, runs on WordPress, automating all of the technical stuff so that the editors can spend their time writing and editing contributions. Geek alert: the rest of this post details some of the technical stuff behind the scenes. Feel free to skip!

Why WordPress?

WordPress handles the e-journal format effortlessly. It’s a breeze to include RSS feeds, organization by sections like ‘editorial’ and ‘review’, automatic archives of past issues, pages for static content, dynamic content areas that can be used for announcements, an interactive comment section, and nice thumbnails for articles. Search engines love WordPress, so the articles are easily findable.

The only slightly more complicated issue is how to do per-issue publishing in WordPress. By default, WordPress assumes a post-centered, chronological format (basically a timeline with dots representing individual posts). An e-journal however is issue-centered: clusters of posts published together periodically. The chronology of the posts within an issue doesn’t really interest us; in fact, we want to be able to reorder posts at will. The best solution, both from a design and code point of view, is to explicitly recognize this difference in ontology using hierarchical categories. In the SemiotiX case, all individual issue categories are subcategories of ‘Issues’, and all content categories are subcategories of ‘Sections’. This is easy to get for end-users, and it is easy to code for developers. With that basic bifurcation in hand, we can easily get the front page to display all posts from the latest issue rather than the 10 latest posts regardless of category (the default setting). A simple category test (snippet 1 below) makes it possible to handle archives differently depending on whether people are looking at an issue or a content category.

Flexibility through theme functions

What I like most about the SemiotiX implementation is that there are no hardcoded category ID’s anywhere in the theme; all relevant ID’s are pulled out from settings on a separate Publishing page, which is itself generated by a theme functions file (functions.php). The latest issue is chosen from a drop-down menu on the Publishing page. Defaults are put in place by retrieving the main category names (‘Issues’ and ‘Sections’) directly from the database, so it will work out of the box in a new setup. Drop-down lists show the existing parent categories so that other terms can be used if needed (e.g. Volumes vs. Topics), so the user never has to worry about finding category ID’s. A dedicated Dashboard widget displays vital information on the dashboard (snippet 2 below).

But how do we order the posts? Well, it turns out the orderby=menuorder feature also works with posts, contrary to what the WordPress docs say! This means that we can use a plugin like postMash to reorder the articles in an issue at will. Issue archives display the posts neatly by menu_order, while section archives and search result pages order the posts chronologically (snippet 1 again). An admin hook allows us to display a direct link to an ordering page on individual category pages (snippet 3).

The new SemiotiX also takes advantage of the built-in support for post thumbnails, making it very easy for editors to upload an image and use it as a thumbnail for display on the frontpage (snippet 4). Different sizes are generated automatically on the server, so there is no need anymore to use complex and error-prone plugins like Post Thumb Revisited and TimThumb. Finally, some unneeded options can be pruned from the visual editor using another snippet of code in functions.php (snippet 5).

Code snippets

All of these go into functions.php.

1. Test whether we’re on an issue or a section archive

        		<?php if (is_category()) { 
				// If this is a category archive
				// Are we looking at an 'Issues' or a 'sections' subcategory?
				  $cat = get_query_var('cat');
				  $args = array(
					'include' => $cat,
					  'hide_empty' => 0
					  );
				  $categories = get_categories($args);
				  if ( ($cat == $sections_cat) || ($categories[0]->category_parent == $sections_cat) ) {
					$archive_type = 'section' ;
				  } elseif ( ($cat == $issues_cat) || ($categories[0]->category_parent == $issues_cat) )  {
				  	$archive_type = 'issue' ;

				// For Issue archives, let's order posts by menu_order
					global $query_string;
					query_posts($query_string . "&order=ASC&orderby=menu_order");
				}

				?>

2. Display a widget on the Dashboard

// Setting and printing the widget content
function semiotix_dashboard_content() {
	
	global $custom_settings;
	$custom_settings = get_custom_settings(); 
	$current_issue_id = $custom_settings["current_issue"] ;
	$current_issue_name = get_cat_name( $current_issue_id );
	$cat = get_category($current_issue_id);
	$numarticles = $cat->category_count ;

	?>
	
    <p>Currently live: <?php echo '<strong>'.$current_issue_name.'</strong>, with '.$numarticles ; ?> articles (<a href="<?php bloginfo('wpurl') ; ?>/wp-admin/admin.php?page=<?php echo __FILE__ ; ?>">change here</a>)</p>
    <?php 
} 

// Create the widget
function semiotix_dashboard_setup() {
	wp_add_dashboard_widget('semiotix_dashboard', 'Publishing', 'semiotix_dashboard_content', 'semiotix_dashboard_options');
}

// Add the widget to the dashboard
add_action('wp_dashboard_setup', 'semiotix_dashboard_setup' );

3. Add an Admin hook for postMash

if(function_exists(postMash_getPages) ) {
// Add the action to the hook
add_action ( 'edit_category_form', 'post_order_link');

// Define the function
function post_order_link($category) {

	$cat_ID = (int) $_GET['cat_ID'];
	$cat_name = get_cat_name($cat_ID);
	
	?>
	
	<h2>Article order (<?php echo $cat_name; ?>) </h2>
	<a href="<?php echo bloginfo(wpurl)."/wp-admin/edit.php?page=postmash-filtered%2FpostMash.php&m=0&cat=".$cat_ID ;?>">Order the articles in this category</a>
	
	 
	<?php
	}
}

4. Add theme support for thumbnails

// Add theme support for thumbnails
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 48, 48, true ); // 48 pixels wide by 48 pixels tall, hard crop mode
// Define several thumbnail sizes
add_image_size( '48x48-square', 48, 48, true );
add_image_size( 'featured-image', 100, 100 );

5. Prune the ‘format’ dropdown options in the visual editor

// Get rid of some option bloat in TinyMCE
function change_mce_options( $init ) {
 $init['theme_advanced_blockformats'] = 'p,h2,h3,blockquote';
 $init['theme_advanced_disable'] = 'forecolor';
 return $init;
}
add_filter('tiny_mce_before_init', 'change_mce_options');
,

One response to “Now live: SemiotiX New Series, a WordPress-based e-journal”

Leave a Reply

Your email address will not be published. Required fields are marked *