Semantic MediaWiki Templates and #arraymaps are Awesome

Templates are awesome.

As I’ve written about before, we use Semantic MediaWiki extensively at work. One way we use it is to handle research requests for or Solution Architecture team. We have a customer-facing form1 for all requests and the resulting page is accessible for anyone across the organization – sharing our findings beyond the original requester.

For any requests submitted, the form creates a new wiki article as a sub page of “Research”. This is done by adding an attribute of “query string=super_page=Research” to the form.

It helps us to keep things organized by denoting which pages are specific to research vs. general wiki pages.

The problem is how semantic queries display pages that have a ‘super page’ prefix. By default the query results will show the super page as part of the formatting.

Demo of a default query with no template

 

See the “Research/” prefix on every item? That’s rather redundant (and ugly), so I sought out a way to remove the ‘Research/’ prefix when displaying the results, but still provide the correct link to the sub page.

The magic is two-part. First, you need to make sure your #ask query has the attribute of “link” set to none (link=none) and “format” set to template (format=template)2. This strips out any default formatting of the results. Here’s the #ask query we’re using. Note you’ll obviously want to change the variables to fit your properties.

{{#ask: [[Category:Research]]
|?Research_Level_Requested
|?Research_Submitted_Date
|limit=15
|link=none
|format=template
|template=Research Results Template
|order=DESC
|default=No related research found. Submit a [[Research]] request?
|searchlabel=”’15 Most Recent Research Requests Loaded. View all Research?”’
}}

Then, for your template you’ll use the #arraymap function to format the output.

{{#arraymap:{{{1}}}|Research/|noSuperName|[[Research/noSuperName|noSuperName]]}} – {{{2}}} – {{{3}}}

What this does is for each result it removes the “super-page” prefix (in this case Research/) from the first property returned – the page name.

{{#arraymap:{{{1}}}|Research/|

It then replaces it with the variable noSuperName. 

|Research/|noSuperName|

Finally we actually construct a normal internal wiki hyperlink by adding “Research/” and the variable together in the proper syntax.

[[Research/NoSuperName|NoSuperName]]

The remaining variables {{{2}}} and {{{3}}} are called as normal and a break tag is added to keep each query result on its own line.

The result is something like the following screenshot.

Custom template sans-super page prefix

You will then have nicely formatted results that are easier to digest.

I hope this helps those looking to extend the semantic queries and produce clean, repeatable results. Let me know in the comments if you have any questions or ideas of your own.

A Networked Mine is a Terrible Thing to Waste

I throughly enjoyed this video from Manuel Lima, senior UX design lead at Microsoft Bing, (via RSA) on how a networked view of the world is better suited to explain the complex relationships between things than the past “tree” view.

I feel a little vindicated as a person who is not very “T” shaped in the sense of skills or specialty. I’m much more of a polymath – knowing a little bit about many areas of knowledge – and perhaps that’s an asset, not what I’ve worried about being a negative thing.

Must-have WordPress Plugins

Recently I was asked to consult with someone developing a website for their small business. We discussed their goals, developed requirements and at the end settled on WordPress for the content management system. As the individual was developing the site they became familiar with the feature of plugins and asked what would be some essential ones to include in their site. I sat down and put this list together and I’d like to share it with you.

In no particular order, my favorite and most useful WordPress plugins.

Advanced Blogroll – For links to other sites or other online presence (Facebook, LinkedIn, Twitter, etc.) you create links in what’s called a blogroll (The name is a holdover from the early days of WordPress.) The default WordPress configuration displays them in alphabetical order. This plugin allows you to arrange them as you see fit. You can see how “Latest” comes before “Elsewhere” on the navigation to the right. ->

WordPress Database Backup – Lets me sleep at night. Since WordPress stores all of your pages and post content in a database, keeping a backup is a smart idea. I have this setup to email me once a week with a zip file of my database. It’s a small little email and I have Gmail set to filter it out of my inbox automatically.

Jetpack – What once was a gathering of separate plugins is now a super kung-fu collection of some great features. Two of my favorite features are the WordPress Stats and After the Deadline. The stats gives you near real-time feedback on traffic to and from your site. Popular pages, keywords and links displayed automatically in your dashboard. After the Deadline is a super grammar, style and spell checker that uses artificial intelligence to make you sound more-than artificially intelligent. That’s just two of the many features of Jetpack.

Update: I can’t recommend Jetpack highly enough. It’s continued to become the most awesome plugin for WordPress that I’ve ever used. The just recently added a CSS editor that lets you customize your site design without modifying your theme, new comment capabilities (including login using Twitter or Facebook) and Retina support for images!

Akismet – Comment spam blocking magic. Spammers target popular content management systems like WordPress in an attempt to trick site owners into allowing spammy comments. Akismet sits in the background and filters these fake comments without any interaction. According to my stats it’s blocked over 17,000 spam comments with a 99.87% accuracy over 6 years. Not too bad.

Google Analytics – Google Analytics is the most powerful web tracking tool out there. Coupled with WordPress and a good email campaign tool (like MailChimp) you can track your readership with great detail. I could spend hours just going over how useful good web metrics are!

WP Super Cache – This is just incase you suddenly get hit with a million visitors. Normally, WordPress dynamically generates each page and post, which causes a lot of requests for information in the database and all the pictures and styles in  your theme. This plugin uses a complex set of rules to create a static version of your page, making the load on the server much less. There by allowing for many more visitors at the same time.

One last recommendation is not a WordPress plugin but a web service called if this then that. ifttt allows me to glue things I do online together. For example, when I post a photo to Instagram ifttt automatically creates a new post on my site and posts the picture. It can greatly help in automating posting to a lot of other web services, which allows you to spend more time writing content and growing your business than messing with tech stuff.

I hope this helps you firm up your WordPress site and please leave a comment if you have a suggestion of your own.

Update: Two other great plugins I’ve come across since writing this list:

Admin Quick Jump – From the horse’s mouth, “Admin Quick Jump is a very simple plugin that adds a drop down list to the admin edit-post area.” Very handy for moving between posts while editing. Here’s a little screenshot showing how simple it is.

Advanced Custom Fields – This one is definitely more on the geeky side of things (if that could be possible given the topic we’re discussing) but it’s pretty amazing. This plugin allows you to create super extensible custom fields that can contain any number of things. I friend of mine showed me how he’s using it for a site with staff profiles. Each element in the profile (position, title, and other bio information) can easily be edited in a custom field and populated into a formatted template. Easy for users to manage.

Siri, With Headphones On

Today I learned that when using Siri with headphones on3 she will read back any text or email messages before they are sent.

From Apple,

“When you use earphones or a headset, Siri reads back text messages and email messages that you’ve dictated before you send them, and it reads back the subjects of reminders before you create them. This is especially helpful when you’re driving and can’t see the iPhone 4S screen.”

I wish this option was the default behavior. There have been numerous times when I’m walking between buildings or to the car and want to send a note without looking at the screen and I’m not wearing headphones.

Unification ≠ iOS-ification

I originally wrote this in the comments to this tongue-in-cheek article – itself a response to the plethora of pundits claiming that Apple is dumbing down OS X by leveraging consistent UI elements across their products.

There been this idea floating around that computers should have scalable modes. An “easy” or beginners mode for people new to the environment. As their skills and comforts develop the software would somehow adjust to open new interfaces like advanced menus or shortcuts.

Well, this isn’t coming to fruition. It’s nearly impossible to predict and implement. But you know what is close? Familiarity and simplicity – both things OS X has been trying for years to do and (In my humble opinion) iOS excels at.

As for the worry that Apple devices will become nerfed consumption machines where no one can produce anything of value (the written word, art, programs) is a bit dramatic. Things in life are rarely black and white.

As someone who could be considered a power user, I’m not in the least bit worried. The command line is still there, a plethora of 3rd-party apps that aren’t “dumbed down” still (and will continue to) exist and frankly most of the design decisions have been positive for users of all types. (Unified conventions, consistent app names, gestures, etc.)

iOS-ification sounds scary because certain mindsets see that as a negative thing. What isn’t being discussed or recognized is the judicial use of iOS ideas. If Apple wanted to make OS X just like iOS they could in a second. They chose however, to select the best ideas and are starting to integrate them across their product line. No longer is the iOS devices over here and the OS X devices over there similar in little ways, but in big ways.