I want to use XML in a lot of my content types mainly in the node body, and I check for that presence of an XSLT cck node reference and apply it to the body only only if it is not nil.
It seems that the by the time it gets to the output stage the $content variable contains formatted output for the CCK fields besides the $node->content['body']['#value'], so when I adjust the theme to display $node->content['body']['#value'] alone a lot of other stuff gets missed out.
Is there some way to ensure that the XSLT is applied to the content of the $node->content['body']['#value'] before it gets to the output stage? I'd prefer to do that before any output filters get applied.
I'd like to know where the theme system first retrieves the body content for processing and intercept there, hoping that no further processing down the chain will override it.
There is an article here - http://www.advantagelabs.com/drupal-colonoscopy-or-how-theme-cck-field-d... which describes how to theme an individual CCK field, but I need something for the node body that works across all themes if possible.
/voipfc
Comments
You could write a module that
You could write a module that implement hook_nodeapi and the case where $op is 'view' and modify $node->content['body'] at that point.
After doing some extra
After doing some extra research tt seems to be like:
$node->body contains the raw text stored in the database.
$content in the *.tpl.php contains the text that the template will output unless it is modified.
$node->content['body']['#value'] contains the html that will be printed as the body text, so if any other routine modifies the $node->content['body']['#value'] again, that is what will be printed, but if that change is made after $content variable has been generated, those changes will not be used if the template prints the $content variable. Is that right?
If I don't want to write a module but implement it in themeing alone, where is the last place I can do it before the $content variable is created? I guess this approach may not work in all situations, but it may be good enough for my needs. In the case of themeing would it be possible to do it for a particular theme engine only?
Your suggestion may be what I need if it has to work across all themes,
Thanks
/voipfc
If you want it to work
If you want it to work across all themes a module is the way to go. Any thing at the theme layer would be theme specific.
How can I know where my theme
How can I know where my theme generates the $content variable - if it does at all?
Does this also mean that my theme customisations can also recreate the $content variable by adding all the $node->content[xxx][#value] variables again after resetting the $node->content['body']['#value'] variable?
Does the value of $content change between node.tpl.php and page.tpl.php?
I'm new to this...
...but I think the $content variable is generated before any of the tpl.php 's. Template.php is the only place in a theme that you can code before variables are generated. You might look at the template_preprocess() function.
--Marshall
--Marshall
I tried your approach and here is the code , please critique
I tried your approach and it is working well initially (fingers crossed).
I am not quite sure if it will handle teaser's properly, I think in case of teasers, it may be better to present a notices stating that it is xml, as the xslt will break on the truncated xml. I am looking to do a module, which forces the user to use a separate summary for the xml if it is less than the teaser cut off length
field_xslt_body is a node reference pointing to the node which contains the xslt transform in the 'sourcecode' field.
Thanks,
Frank
/voipfc
some sample code?
Is there a simple module or some snippet that implements this method I can look at?
/voipfc