I could use some assistance in figuring out how to do the following:

Given a vocabulary like this example:

Vocabulary: Content
Term: Trees <---- one kind of payout
Term: Apple <---- and these pages using a different layout
Term: Maple <
Term: Willow <

What steps do I need to take to customize the pay layout for the "Trees" taxonomy page in one layout, and for the "Apple," "Maple," and "Willow" taxonomy term pages using a different layout?

What I've tried:

- Setting up the taxonomy with URL Aliases so URLS for the above would be
www.site.com/category/trees
www.site.com/category/trees/maple

- Setting up a custom page with the Path:
category/%vocab/%tid1/%tid2
with those 3 arguments configured in that order on the Arguments pane
and under the Variant, those 3 contexts defined

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

teleted’s picture

Pardon my poor typing. "Payout" should be "layout", and "pay layout" should be "page layout."

teleted’s picture

Here is an export of the custom page I set up attempting to customize the pages for children terms of parent terms in a vocabulary as I outlined above.

$page = new stdClass;
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'subcategory_page';
$page->task = 'page';
$page->admin_title = 'Subcategory Page';
$page->admin_description = 'Controls display of subcategory pages';
$page->path = 'category/%vocab/%tid1/%tid2';
$page->access = array(
  'plugins' => array(),
  'logic' => 'and',
);
$page->menu = array(
  'type' => 'none',
  'title' => '',
  'name' => 'navigation',
  'weight' => '0',
  'parent' => array(
    'type' => 'none',
    'title' => '',
    'name' => 'navigation',
    'weight' => '0',
  ),
);
$page->arguments = array(
  'vocab' => array(
    'id' => 1,
    'identifier' => 'Vocabulary ID',
    'name' => 'vid',
    'settings' => array(),
  ),
  'tid1' => array(
    'id' => 1,
    'identifier' => 'Taxonomy term',
    'name' => 'term',
    'settings' => array(
      'input_form' => 'term',
      'breadcrumb' => 1,
    ),
  ),
  'tid2' => array(
    'id' => 2,
    'identifier' => 'Taxonomy term 2',
    'name' => 'term',
    'settings' => array(
      'input_form' => 'term',
      'breadcrumb' => 1,
    ),
  ),
);
$page->conf = array();
$page->default_handlers = array();
$handler = new stdClass;
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_subcategory_page_panel_context';
$handler->task = 'page';
$handler->subtask = 'subcategory_page';
$handler->handler = 'panel_context';
$handler->weight = 0;
$handler->conf = array(
  'title' => 'Panel',
  'no_blocks' => FALSE,
  'css_id' => '',
  'css' => '',
  'contexts' => array(),
  'relationships' => array(),
  'access' => array(
    'logic' => 'and',
  ),
);
$display = new panels_display;
$display->layout = 'flexible';
$display->layout_settings = array();
$display->panel_settings = array();
$display->cache = array();
$display->title = '%tid2:name';
$display->content = array();
$display->panels = array();
  $pane = new stdClass;
  $pane->pid = 'new-1';
  $pane->panel = 'center';
  $pane->type = 'block';
  $pane->subtype = 'block-11';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'override_title' => 1,
    'override_title_text' => 'Subcategory Content Placeholder',
  );
  $pane->cache = array();
  $pane->style = array();
  $pane->css = array();
  $pane->extras = array();
  $pane->position = 0;
  $display->content['new-1'] = $pane;
  $display->panels['center'][0] = 'new-1';
$display->hide_title = PANELS_TITLE_FIXED;
$display->title_pane = '0';
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;
$handler = new stdClass;
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
$handler->api_version = 1;
$handler->name = 'page_subcategory_page_panel_context_2';
$handler->task = 'page';
$handler->subtask = 'subcategory_page';
$handler->handler = 'panel_context';
$handler->weight = 1;
$handler->conf = array(
  'title' => 'Panel',
  'no_blocks' => FALSE,
  'css_id' => '',
  'css' => '',
  'contexts' => array(),
  'relationships' => array(),
);
$display = new panels_display;
$display->layout = '';
$display->layout_settings = array();
$display->panel_settings = array();
$display->cache = array();
$display->title = '%tid2:name';
$display->content = array();
$display->panels = array();
$display->hide_title = PANELS_TITLE_FIXED;
$display->title_pane = '0';
$handler->conf['display'] = $display;
$page->default_handlers[$handler->name] = $handler;
Gerhard Killesreiter’s picture

Version: 6.x-1.3 » 6.x-1.x-dev
Category: support » feature
Status: Active » Needs review
FileSize
2.71 KB

Here is an acccess handler that let's you chose the condition "does the current term have a parent term in a given vocabulary".

It should help you do this.

merlinofchaos’s picture

Status: Needs review » Needs work

Two minor issues:

  'default' => array('vids' => array()),

Should be 'vid'.

I'd just fix that and commit but the second one takes a couple more minutes: This should have a negation, so you can test for has a parent term or does not have a parent term.

The name should probably also be 'Taxonomy: has parent term' which I think will be a touch more descriptive of what this does.

killes@www.drop.org’s picture

Status: Needs work » Needs review
FileSize
3.44 KB

Does this look better?

killes@www.drop.org’s picture

FileSize
3.48 KB

Ok, the previous version was foobarred.

killes@www.drop.org’s picture

FileSize
3.42 KB

Another update...

merlinofchaos’s picture

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

Thanks for the work on this! SOrry it took so long to get to it. Committed to D6.

humanchimp’s picture

Pardon me —

I am losing my mind trying to use this plugin. To my mind, the behavior should be this:

IF the "term currently being viewed" has a parent term in a given vocabulary, THEN it should return TRUE unless the negate is set, in which case it should return FALSE.

Well, that doesn't seem to be what the implementation actually does. Consider the following SQL statement, copied from term_parent.inc:

SELECT COUNT(*) FROM {term_hierarchy} th INNER JOIN {term_data} td ON th.parent = td.tid WHERE th.parent = %d AND td.vid = %d

Surely, this code does not work as I described.

Essentially it is saying, if this term is in a given vocabulary, count its children. Was this the plugin author's intention? If so, how does this correspond to the use-case described in the main post?

Thanks,
Chris

humanchimp’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Category: feature » bug
FileSize
717 bytes

Here's a patch which fixes a couple problems that I found with the term_parent.inc. I don't know about pgsql compatibility, so it will need review. I'm not sure if the previous plugin was tested properly, because beyond the faulty query which I reported in #9, it also contained this disturbing bit:

$count = db_query('SELECT count(*) FROM...');

Instead of:

$count = db_result(db_query('SELECT count(*) FROM...'));

Which makes a difference if you want to use type-coercion later to convert the "integer" to a boolean, which the code then goes on to do.

Thanks,
Chris

Summit’s picture

Subscribing, greetings, Martijn

merlinofchaos’s picture

Status: Patch (to be ported) » Needs review

Changing status so this gets seen.

sdboyer’s picture

This entire thread has me confused. There is, as far as I can understand, zero use for this plugin that's now already been committed - while the datastructure allows the possibility that a term is in a different vocabulary than its parent, it is impossible to create such a relationship without directly inserting it yourself; the UI doesn't allow it, and afaik the taxonomy helper functions don't make it easy. So in effect, this plugin does nothing that the standard term access plugin which can restrict on vocabulary doesn't do already.

Assuming that there is a legit use case for this, though, humanchimp is right that there should be a db_result() in there, but the logic change is wrong. You've misread the original query - it says, "given a term_hierarchy row where the tid = x, count the number of records where the 'parent' term is in vocabulary = y". Exactly as the plugin describes. Your patch unnecessarily joins from term_data to term_hierarchy, then back to term_data to check the vid (and as written, is also wrong because it is checking td.vid instead of ptd.vid). There's nothing added there except an irrelevant additional join; WHERE on th.tid in the original is the same as WHERE on td.tid + the join in your patch.

merlinofchaos’s picture

The use case is to test to see if this is a top level term or has a parent term (the "in the same vocabulary" is kind of a red herring). It'd be most useful with a negation option.

merlinofchaos’s picture

Status: Needs review » Fixed

I checked in the changes.

One thing to note is that using the term parent relationship is a different way to get this.

One thing this doesn't answer that maybe it was meant to is, there's no way to detect if the term has a child term, for when you want the end of the branches, which may be of different lengths, to have different styling.

Status: Fixed » Closed (fixed)
Issue tags: -content taxonomy, -Page Manager

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