The alphabar on my main g2 page is being shown twice consecutively - I'm using Drupal 4.7 beta 4, and this is a site in development. I've done a few minor mods to the module, mainly just with what display text is shown; I can't see that anything I've done would cause this, so I'm reporting it as a bug. I'm happy to demonstrate the error at my site if required.

CommentFileSizeAuthor
#5 g2.module.patch4.22 KBfgm

Comments

fgm’s picture

Actually, it's a feature: unless you adapt your theme specifically for G2, the default theme emits two alphabars to wrap the contents of the custom non-zero page you define as being the main G2 page (see admin/settings/g2: "Node used for the main page of G2 on this site" textfield).

You can overload this by creating a <your_theme>_alphabar() function in <your_theme>.theme.

Note that your custom main G2 page can be a PHP page if you so choose, allowing you to have dynamic content, for instance a dynamically built list of taxonomy terms to link to sections of your glossary.

fgm’s picture

Assigned: Unassigned » fgm
Status: Active » Closed (works as designed)

Actually, I made an error in my previous answer: you have to write <mytheme>.theme/<mytheme>_g2_main()/function riff_g2_main(), not <mytheme>_alphabar().

Here is a sample <mytheme>_g2_main():

  {
  // $alphabar = theme('links', _g2_alphabar(), ' ');

  $node = node_load(variable_get(G2VARMAIN, 0));
  if (isset($node))
    {
    drupal_set_title($node->title);
    // $node->body = $alphabar . $node->body . $alphabar ;
    $ret .= node_view($node, false, true); // theme('box', $node->body, FALSE, TRUE) ;
    }
  return $ret;
  }

The commented-out code is the default formatting.

As it is not a bug, I'm closing this issue: if you (or some other reader) thinks the default themeing should be different, please contact me.

robert castelo’s picture

Status: Closed (works as designed) » Reviewed & tested by the community

I'd classify this as a bug, since if no node has been defined the alphabar will be displayed twice as one continuos text.

Here's some code that avoids the problem all together:

In function theme_g2_main()

Change:

$node->body = $alphabar . $node->body . $alphabar;

To:

$node->body = (isset($node->body)) ? $alphabar . $node->body . $alphabar : $alphabar;

Note that isset($node) is TRUE even when $node is returned set to bool(FALSE).

robert castelo’s picture

I'd actualy advice you to move all the code from theme_g2_main() in to function _g2_main().

Use theme_g2_main() just to wrap some markup around the output. Ideally have as little logic as possible in theme functions.

fgm’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.22 KB

Robert,

I agree with your first suggestion, but the very fact of agreeing with the rationale of your second suggestion forces me to disagree with the suggestion itself.

Here is a patch against the latest CVS version. It includes comments regarding the second suggestion

It incorporates various other changes created in the meantime and not yet stabilized, though

robert castelo’s picture

Thanks, that looks excellent.

By the way, if you pass the output from g2_main() through theme_g2_main() you could wrap the whole node like this:

<div id="glossary-index">
$output
</div>

That would allow themes to style any part of the node using CSS inheritance, e.g. in CSS:

#glossary-index .node-title {
  color: #fff
}
fgm’s picture

Status: Needs review » Closed (fixed)

Or, Robert confirmed off-site that this was a different issue that will be processed separately, so I'm committing the patch.

fgm’s picture

Category: bug » feature
Status: Closed (fixed) » Fixed

Version 1.15.2.7 now displays by default a single alphabar if the selected main page is empty, as is the case if it is the default (node 0).

Anonymous’s picture

Status: Fixed » Closed (fixed)