Drupal 7 with Omega version 3.0-rc4 theme generates a username class for the article tag in the html code, something like :
class="node node-page node-published node-not-promoted node-not-sticky author-USERNAME odd clearfix".

I'd like to avoid having the username displayed in the code for security reasons.

After investigating, this comes from the code "omega_alpha_preprocess_node()" in the "sites/all/themes/omega/omega/template.php" where you find the following line:
"$vars['attributes_array']['class'][] = drupal_html_class('author-' . $vars['node']->name); "

I copied the code of "omega_alpha_preprocess_node()" to the "template.php" of my Omega subtheme, I renamed the "omega_alpha_preprocess_node()" to "MYTHEME_alpha_preprocess_node" and removed the line "$vars['attributes_array']['class']". Unfortunatly, it does not work.

Can someone help me find a solution to remove the username from the html code, as I'm not a very experienced Omega developer and I need guidance? Thank you.

Comments

FL26’s picture

I found the solution. Simply add the following code in the template.php file of the Omega subtheme and the username class for the article tag in the HTML code will not be displayed:

function [MYTHEME]_preprocess_node (&$vars){
$count = 0;
foreach($vars['attributes_array']['class'] as $class){
if(substr( $class, 0, 7 ) === "author-"){
unset($vars['attributes_array']['class'][$count]);
}
$count += 1;
}
}

FL26’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jenna.tollerson’s picture

In case anyone is searching, here's how I removed the author-username class in my theme's template.php:

function [MYTHEME]_preprocess_node(&$vars) {
  $author_class_id = array_search(drupal_html_class('author-' . $vars['node']->name), $vars['attributes_array']['class']);
  array_splice($vars['attributes_array']['class'], $author_class_id, 1);
}