I'm afraid my question is a bit to general because I don't quite know where to start. I still really don't have my head wrapped around the drupal 7 theming system.
I have two content types:
Type secondary(this type has a required entity reference field, referencing
The display on
Type main has a set of 2 horizontal tabs htabs group named
What I would like to happen is, if an entity of
Type secondary has been added referencing this node; add a third horizontal tab containing the
Type secondary node and make it the default.
These are the steps I thought through that should probably happen on page load for a node of
- Look for a
Type secondarynode referencing this node, return if not found
- If found, build up a new render array for the
Type secondarynode htab. I was thinking it would be easiest to build this display in views, and load in the view, but doing it in a template file would probably work too.
- Once the variable has been for the new htab, insert it in the htabs render array and modify the render array to remove the open by default indicator on the old default tab.
So far I have used hook_preprocess_page to grab the
$variables['page']['content']['system_main']['nodes'][nid]['#fieldgroups']['group_expandables'] and add a new group name to its children, clone one of the htab field groups and append it to the
['#fieldgroups'] array, and modify the elements that referenced the old htab and replace them with the name for the new tab. Once I figured out that I needed an entry in
#group_children too, I actually got the tab to appear in the group, but I haven't had any luck getting content to show up in it yet.
Here are the places I'm really hung up:
- Is hook_preprocess_page the best place to start this?
- Is my general strategy for how to go about this sound?
- How would I build my desired content into the new htab?
I'm sorry for the broad nature of the question, any pointers would be greatly appreciated.