Lullabot / windup

A Drupal starter theme
GNU General Public License v2.0
26 stars 8 forks source link

Issue #58: Updates template_preprocess_node(). #87

Closed carwin closed 8 years ago

carwin commented 8 years ago

This commit drops a lot of old functionality from the 7.x branch.

We no longer strictly need an "unpublished" class. Partly because D8's attribute array makes a node--published class available and partly because we could just use the node object's isPublished() method. I've left the code for it in place as an example of how it could be done.

The theme hook suggestions were dropped from preprocess_node since D8 actually already has most of the suggestions we were adding in 7.x. I did create some theme suggestions for the page templates however based on the entity type. This is done with hook_theme_suggestions_alter().

carwin commented 8 years ago

@wesruv: According to the comments in node.html.twig we should have a bunch of nice default classes in our attributes array, but I see no sign of them:

/** 
 *   The attributes.class element may contain one or more of the following
 *   classes:
 *   - node: The current template type (also known as a "theming hook").
 *   - node--type-[type]: The current node type. For example, if the node is an
 *     "Article" it would result in "node--type-article". Note that the machine
 *     name will often be in a short form of the human readable label.
 *   - node--view-mode-[view_mode]: The View Mode of the node; for example, a
 *     teaser would result in: "node--view-mode-teaser", and
 *     full: "node--view-mode-full".
 *   The following are controlled through the node publishing options.
 *   - node--promoted: Appears on nodes promoted to the front page.
 *   - node--sticky: Appears on nodes ordered above other non-sticky nodes in
 *     teaser listings.
 *   - node--unpublished: Appears on unpublished nodes visible only to site
 *     admins.
 */

I've tried a few different things and the only class I ever see on the node's <article> tag is contextual-region. Are we removing all of these somewhere and I'm just blind or is there some kind of bug you're aware of?

If we can actually get these to show up in makes a lot of the work we were doing in the 7.x branch unnecessary, which is great.

carwin commented 8 years ago

Actually, I'm a dork. Figured it out with that last commit.

wesruv commented 8 years ago

FWIW, there's nothing removing classes in windup right now.