By Pav-2 on
Hi there all,
I've just started using Taxonomy more for the site I'm building and it's great. However here is the problem I'm having:
I'm using Zen and when I add a Term,e.g. 'Hunting' to a page that term appears at the top of the content on that page. The problem is that I don't want it to appear there. I would like it to appear elsewhere and only for a particular permission group, e.g. Administrators - so I can't use styles for that (as styles would only let me control it for logged-in - not logged-in).
How do I do this - create user template? If so - I can't find the part I'd have to move? How can I do this?
I'm using Themer info.
Any suggestions will be much appreciated,
Pav
Comments
_
I can think of a couple of options-- use template_preprocess_node to remove the term from the appropriate roles or edit the node.tpl.php file for your theme and put the logic there. The first method is the 'proper' way to do it imo, but the second might be easier.
how to correctly use preprocess_node - it doesn't work?
Learning how to use preprocess_node is the first time I'm playing with variables in Drupal and having a problem to make it work.
So following WorldFallz advice I decided not to put the logic in node.tpl.php - I can be new to Drupal but this just would be wrong from devel point of view - nevertheless I tried it just to see:
if (!$is_admin):$terms = FALSE;endif;This would do the tick but how to do the same using the preprocess? I tied this and can't get it to work:
in Template.php
function purple_frog_zen_preprocess_node(&$vars) {
if (!$vars['is_admin']){
$vars['terms'] = FALSE;
}
}
This doesn't do anything - do I need to call it anywhere? I thought I didn't.
I tied the same in
node.php :
function template_preprocess_node()(&$vars) {
if (!$vars['is_admin']){
$vars['terms'] = FALSE;
}
}
I've found somewhere that the (&$vars) should be ($vars) - my PHP version is: 5.2.4-2ubuntu5.7
My question would be:
1. Am I putting this function in the correct place?
2. Should it be in template.php or in node.php -
3. If in node should it be called template_preprocess_node() or should I replace the 'template' part?
4. Is the &$vars correct for the PHP version I'm using?
5. Once this functions are defined do I need to call them anywhere?
Any help will be much appreciated,
Pav
_
Yep-- you're correct in putting the function in the template.php file (be sure to clear the cache).
Assuming the name of your theme is "purple_frog_zen" then try:
Note-- if you already have a _preprocess_node function in your template.php you'll have to integrate them-- you can only have one function by that name.
Drupal picks up Zen/template.php instead of ZEN_SUB_THEME/tem...
Great thanks for the unset - that's the right way to do this definitely!
However my problem seemed to be that Drupal was picking up Template.php from Zen/ rather than my customised theme (purple-frog-zen/) - this is why I couldn't pick up the changed variable - your advice really helped to track this down!
When I first set the sub theme I followed the instructions so I never have to change Zen theme but override it with the sub theme (purple-frog-zen) - this is the first time that I would have to make changes in Zen - where can I make the change so it uses the purple-frog-zen/Template.php ?
Furthermore even if I do apply the changes to purple-frog-zen/Template.php should I really do it there - what if I change the Theme then I will loose the logic with it - maybe I should put it in a module ?
Thank you Worldfallz
Pav
_
Is it 'purple-frog-zen' or 'purple_frog_zen' -- afaik, they are not interchangible. And iirc, you should be able to have your own template.php file for your zen subtheme.
How to override the template.php when using a subtheme?
name of the folder is purple-frog-zen/ but the names of the functions are purple_frog_zen these were created following the instructions from zen is (or in the case of the template.tpl - auto created).
The problem is well described in the post I mentioned below but sadly the guy didn't get his answer either.
I will continue this posting under here to avoid a dupe http://drupal.org/comment/reply/451104/1713744
I really appreciate your help :) ... Worldfallz :)
Pav
_
Not sure if it truly makes a difference, but just change the '-' to '_' everywhere-- it can't hurt to have it all consistent and eliminates a potential issue when trying to troubleshoot.
Ok, based on that thread, it seems both template files will be detected but that functions that appear in both will use the subtheme version-- which is the behavior I would expect. Is this not what you're experiencing?
The moral of the story is to NEVER use '-' in theme names!
Though to be honest I tried renaming them all before - folders and all function names, etc. and it didn't work. What I did this time to solve it was I recreated the sub theme without '-'.
The moral of the story is to NEVER use '-' in theme names anywhere - even if it's just the folder name!
Thanks for your help Worldfallz