Skip to content
Matthew Bernhardt edited this page Mar 16, 2015 · 3 revisions

As of this writing, a new MIT Libraries News theme is under development. The repo for this theme is here.

While this theme exists as a child theme of the main libraries.mit.edu WordPress theme, many of the relevant styles and scripts for /news (as well as relevant Grunt tasks) are actually being built inside the parent theme. The news branch contains this development work. This is primarily to ensure that a comprensive, congruous design/theming system is maintained across the libraries.mit.edu WordPress instance.

News items on front page

The two news items on the front page the site (http://libraries.mit.edu) are built directly by WordPress, rather than a previous system that loaded them via the WP API. The logic that controls this process is found in page-home-direct.php. There are three basic steps:

  1. Determine the state of the candidate pool
  2. Build and run quer(ies)
  3. Render items

1) Determine the state of the candidate pool

This step attempts to determine whether two situations are true:

  • Are there only two eligible items? If so, follow option 2A below.
  • Is there only one "news" item? If so, follow option 2B below.

If neither of the above condition exists, then randomly choose either 2B or 2C

2) Build and run quer(ies)

The queries to pull news items fall into one of three catgories:

2A - Display two items This is used when there are only two eligible stories, so the query is very simple - just grab two items.

2B - Display one news and one feature This is used in cases where only one eligible news item exists, or when the coin flip in step one selects only one visible news story.

2C - Display two news items This is used only when there are two such eligible news items, and the coin flip elects to actually show two news items.

3) Render items

This step takes the built object of two items, and renders it as HTML.

Clone this wiki locally