I've got Gworks up and running nicely, but I would like to know how to change the number of buttons that appear across the top? But default there are 6: how do I change to have 7, or 8?

Is it something to do with table widths?

Comments

nedjo’s picture

Assigned: Unassigned » nedjo
Category: support » feature

I've hard-coded the number of buttons because the button display uses a background image (the button) that should have a width that is a fixed fraction of the total table width. In other words, if there were too many buttons, the bar would be too wide. Preferably, there would be narrower images when using more buttons (though this would also mean less space for the text, so term names would have to be shorter).

If you wish to make the change anyway, edit taxonomy_context.module as follows:

  • To function taxonomy_context_settings(), add the following line:
      $output .= form_select("Number of buttons", "taxonomy_context_buttons_number", variable_get("taxonomy_context_buttons_number", 6), array(5 => "5", 6 => "6", 7 => "7", 8 => "8"), t("Number of buttons (taxonomy terms plus \"home\" link) to display"));
    
  • In function taxonomy_context_get_buttons(), find the following line (near the end):
          if($t == (5) {
    

    and edit to read

          if($t == (variable_get("taxonomy_context_buttons_number", 6)) {
    
  • Then upload this modified version to your modules/taxonomy_context directory, open the taxonomy_context settings page, and select the number of tabs you wish to use.
nedjo’s picture

That second change to the code should have been:

  if($t == (variable_get("taxonomy_context_buttons_number", 6) - 1) {
nedjo’s picture

... should have been:

if($t == (variable_get("taxonomy_context_buttons_number", 6) - 1) {
joel_guesclin’s picture

Strangely, I found that when I did this the code to input the variables worked fine (and I could see the variable when I looked in MySQL), but when I tried to change the condition in taxonomy_context_get_buttons, all I got was a blank page. Much frustration, went back and messed about a bit and finally discovered that this worked:


a) before the loop in taxonomy_context_get_buttons put:

$zzz = variable_get("taxonomy_context_buttons_number", 6)



b) Replace this:

if($t == (5) {

with this

if($t == ($zzz) {

It works! Except that now I have to find the place where I actually define the width of the buttons in the first place, which I presume is somewhere in the Theme?
One day, I really must learn to program in PHP... instead of just banging things to see what happens

nedjo’s picture

Version: 4.4.x-1.x-dev »
Status: Active » Closed (fixed)

No longer relevant, as we've removed buttons.