When a search result is invoked using .../g2/initial/i, where 'i' is an initial, it would be nice to optionally insert the linked alphabetical pager into the header and/or footer, so that users do not have to go back up the breadcrumb to move to terms with another letter.

This is a very common feature in online glossaries.

I would be glad in the meantime for support on how to achieve that in code (as I'm having to now diverge from the most recent release to meet client requirements concerning UI strings, and to use our custom Definition type).

Many thanks for continued maintenance of this promising module,

Webel

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fgm’s picture

Status: Active » Closed (won't fix)

The best way is to use the alphabar block in the content region (or content_bottom if your theme has one) and a custom block invoking g2_alphabar() in a custom block in the content-top region if your theme has one.

I do not think this needs to be a standard mechanism since it is quite specific to one site layout and so simple to implement.

webel’s picture

thanks, have read, will try.

webel’s picture

Hi, I've turned my hand to this and would like to present the result when a custom block is used to carry an alphabar, using PHP code input format (as admin) and (amongst other code) the snippet:

print '<p class="g2-alphabar ">'.theme('g2_alphabar', _g2_alphabar()).'</p>';

I then place that block in the region content top (I am using theme adapted from the Zen theme), and I set the option Show on only the listed pages to:

g2/initial/*

Although this does enable users to navigate from the initials search result page to any other initials search via the alphabar links, there is a slight problem with this approach, namely that the region content top appears above the
breadcrumb (which shows a link to home >). So on the main G2 glossary page (accessed via /g2) the alphabar and description is below the home link, whereas on the initial result page it is below it.

Please compare the 2 attached images.

All in all it took quite a bit of tweaking and fiddling in different places
(and some custom CSS styling to handle display of the same text in different region contexts), and I think there is a compelling case for making this a default feature with easily (centralised) customisable content through the G2 admin page.

I will now have a go at doing it directly in code (i.e. hacking your module) to see whether I can't get a more consistent result than with the block approach.

webel’s picture

Well its easy enough to generate an alphabar (along with other eye candy) and insert it after the "initialed" title, by introducing a customised alphabar and returning it within function _g2_initial($initial) by including it in $ret (see attachment).

However I don't see how to get that customised alphabar to appear before the initialed title, yet after the home link in the breadcrumb, which is where common sense dictates it belongs:

function theme_g2_initial($initial = NULL) {
  $initial = filter_xss($initial);
  drupal_set_title(strtr(G2TITLEINITIAL, array('%initial' => $initial)));
  $ret = _g2_initial($initial);
  return $ret;
}

In the above the "initialed" title is set through drupal_set_title(), and I don't see where else there is an opportunity for me to intervene (hack in) my customised alphabar. I'd welcome any further suggestions.

In the meantime I'll keep using the custom block approach, however it is definitely not yet the desired result.

thanks,

Webel

fgm’s picture

Status: Closed (won't fix) » Active

Well if you do something on it, let's reset the issue as active otherwise it won't get listed :-)

fgm’s picture

Status: Active » Fixed

I've looked at it in more detail, and this really is a theme question: what you need is be able to insert the alphabar in your own theme between the breadcrumb and the main content, and this is off-limits for a module.

So I have added a new feature to G2: a "G2 context". Whenever you are on one of the G2 pages (main page, initial, entries, node page), the page-g2.tpl.php in your theme is enabled if it exists, so you can customize just these pages by serving them a modified page template with the alphabars wrapping the content.

The "context-g2" class is now also enabled on the <body> element on the same pages, whether you use a page-g2 template or not. Zen subthemes and some others recognize this by default, others don't... if you are no longer using a Zen subtheme, you can always add this by implementing yourtheme_preprocess_page to get this variable so your page templates get it.

This is included in today's dev. version.

fgm’s picture

Status: Fixed » Patch (to be ported)

To be ported to D7 probably on top of Context instead of natively.

fgm’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Patch (to be ported) » Needs review
FileSize
10.8 KB

Patch fixes this by providing full Context 7.3 integration

- Ctools plugin api
- Context condition, 3 cases
- Context reaction: enable alternate page--g2 template
- Default G2 context declarations for privileged and unprivileged users

Status: Needs review » Needs work

The last submitted patch, g2_contexts-700012-8.patch, failed testing.

fgm’s picture

Status: Needs work » Fixed

Patch failure is apparently a limitation of qa.drupal.org. Committed to dev branch.

webel’s picture

@fgm thanks for recent efforts, which I will have the opportunity to employ on future sites; the previous fix/workaround will remain in place unchanged on the previous client site which instigated this thread.

Status: Fixed » Closed (fixed)

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