hook_node_api: Move code inside the conditional
Todd Nienkerk - February 11, 2009 - 09:23
| Project: | Read More link (Drupal 6 and earlier) |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Todd Nienkerk |
| Status: | closed |
Jump to:
Description
The current 3.0 version does a bunch of stuff before checking if the module should move the link:
<?php
function ed_readmore_nodeapi(&$node, $op, $teaser, $page) {
$enabled = variable_get('ed_readmore_readmore_tweak', 1);
$inlineflag = variable_get('ed_readmore_readmore_inline', 1);
$strong = variable_get('ed_readmore_readmore_strong', 1);
if ($strong) {
$strong_l = '<strong>';
$strong_r = '</strong>';
}
else {
$strong_l = '';
$strong_r = '';
}
$link_text = $strong_l . t(variable_get('ed_readmore_text', ED_READMORE_TEXT_DEFAULT)) . $strong_r;
$options = array('html' => true);
$readmore_url = l($link_text, "node/$node->nid", $options);
if ($enabled) {
...
?>It should probably look like this:
<?php
function ed_readmore_nodeapi(&$node, $op, $teaser, $page) {
if (variable_get('ed_readmore_readmore_tweak', 1)) {
$inlineflag = variable_get('ed_readmore_readmore_inline', 1);
$strong = variable_get('ed_readmore_readmore_strong', 1);
if ($strong) {
$strong_l = '<strong>';
$strong_r = '</strong>';
}
else {
$strong_l = '';
$strong_r = '';
}
$link_text = $strong_l . t(variable_get('ed_readmore_text', ED_READMORE_TEXT_DEFAULT)) . $strong_r;
$options = array('html' => true);
$readmore_url = l($link_text, "node/$node->nid", $options);
...
?>
#1
Fixing typo in title.
#2
Fixed in the 3.x-dev branch.
#3
#4
Automatically closed -- issue fixed for 2 weeks with no activity.