Skip to content

Commit

Permalink
Add author info correctly to nodes, esp recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jen Lampton committed Jul 31, 2018
1 parent ad73ecc commit f149a2b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions structured_data.module
Original file line number Diff line number Diff line change
Expand Up @@ -414,21 +414,21 @@ function structured_data_get_node_info($node) {
// Special handling for node property data.
elseif (substr($field, 0, 5) == 'node_') {
$field = str_replace('node_', '', $field);
if (property_exists($node, $field)) {
if ($field == 'author') {
$acount = user_load($node->uid);
$data[$property] = array(
'@type' => 'Person',
'name' => $acount->name,
);
}
elseif (property_exists($node, $field)) {
if ($field == 'title') {
$fieldname = str_replace('node_', '', $field);
$data[$property] = $node->{$field};
}
elseif ($field == 'created' || $field == 'changed') {
$data[$property] = format_date($node->{$field}, 'custom', 'Y-m-d\TH:i:s');
}
elseif ($field == 'author') {
$acount = user_load($node->nid);
$data[$property] = array(
'@type' => 'Person',
'name' => $acount->name,
);
}
}
}

Expand Down Expand Up @@ -491,6 +491,8 @@ function structured_data_get_node_info($node) {
} // foreach $property_info
} // if enabled node type

dpm($data);

return $data;
}

Expand Down

0 comments on commit f149a2b

Please sign in to comment.