Hi,

I use a function in my module which overrides a template (phptemplate_content_field).
But it should only do this for a special content type.
If the content type is one of the normal types like story, I would like to switch back to using the template to guarantee normal behavior.
The Problem is that I have no idea on how to get the template file output, once the corresponding function is called.
First I thought I might just cunstruct the template's output inside the function, but I can not access the variables added by the preprocess functions, can I? And it would be hard to even emulate the preprocess functions.
From what I understand this is not an trivial task. Is there a trick to do it?

Thanks in advance,
hama.

Comments

justageek’s picture

are you trying to theme a specific cck field? I'm not exactly sure what you are trying to do.

Also, it always helps to post code

hamakabula’s picture

Yes, exactly. I override cck/theme/content-field.tpl.php with my function. But it should only be themed for a special node type. Otherwise it should look as described in content-field.tpl.php.

My.module:

//...
function phptemplate_content_field($param){
  if( specialContentType() ){
    return myThemedOutput(); //returns my form of the field, which is just a bit of html with description and link
  }
  else{
    return templateOutput(); //here I would like to use the output of content-field.tpl.php
  }
}

//EDIT: the theming I do can not be done via css

justageek’s picture

all you have to is create a template like this:

content-field-CONTENT_TYPE.tpl.php is used to theme all CCK field in that content type.

and that temple will be used to theme your field output only for your special content type, so if your content type is called article, then you would create

content-field-article.tpl.php is used to theme all CCK field in that content type.

you should read this blog post

http://hddigitalworks.com/theming-cck-content-type

hamakabula’s picture

Thank you very much. This is a great idea :D