Hi there, am using your module successfully in my website for a lot of different things. It eases formatting incredibly almost making WYSIWYG editors redundant to an extent. I am using CCK to store information and from what I gather, the way to display CCK content in custom phptemplate templates is to call out each field.

For example: In node-cckcontenttype.tpl.php I have a certain field which is to be displayed via the use of <?php print $node->field_X[view]; ?> where field_X is the field name in the CCK node type.

I am able to get output in my templates. However, all of my reptags are not parsed properly. They are just output wholesale without it being parsed through the reptag process. I can verify that the content in each of my fields is parsed through the filters. HTML filter is working and so is PHP filter so CCK seems to be functioning correctly here.

I had a look at the code and it seems that reptag is not using hook_filter after all and instead is using hook_nodeapi to call the reptag_process(). I am totally noob when it comes to the inner workings of drupal. All I know is that the reptag_process() must be called to do the actual conversions. However, I am not sure how I should call it. And whether it could even be done in that way.

Please help. Thanks!

Comments

profix898’s picture

Hi Faj!

I haven't tried reptag with cck yet, but I definitely will AFTER the Easter Weekend ;)

- Reptag doesn't use hook_filter because of some characteristics of Drupal's filter system (there are other 'filters' which are not filters actually). Most important reason is that you don't have access to $node object using filters. hook_filter only passes the content/text/code. But without node object you cant have per-node (nid needed) or per-user (uid = author needed) operations/replacements. The second reason is that you can't have dynamic' content using filters, what means, you cant have content that changes everytime you view a node. Drupal's filter system runs when you save your node, reptag runs on every page view.
- You are right about reptag_process() - its the heard of reptag ... and it must be called on page view. I will need a deeper look into CCK to understand how it handles content. Maybe you can try to call reptag_process() directly for the moment.

reptag_process($node);
print $node->field_X[view];
print $node->field_Y[view];
...

Happy Easter! Thilo

Fajan’s picture

Tried adding reptag_process() directly to the template tpl.php file but there is no change in output behaviour. I added a <?php print $content; ?> snippet to the template out of curiousity and lo and behold, reptags are parsed beautifully in $content. However that is not what I want as in the end of the day I would like to custom arrange each individual field wrt page layout (i.e. printing each field out individually) instead of sticking to $content which just outputs everything as one unformatted mess. I am not sure whether the problem lies with CCK as it outputs quite well through $content. Looks like manually extracting each field data via print $node->field for the template bypasses a certain function in CCK. Not too sure where it is though. The views hook in CCK seems to be referencing to the various hooks in each of the individual data type submodules (e.g. text submodule) but as for where is the function which does the processing, I'm stumped.

profix898’s picture

Sorry, my fault! Calling reptag_process directly() cant work, it only parses $node->teaser or $node->body. So individual fields are not touched. I will look at this issue as soon as possible. I'm not sure you should use cck fields directly. If you run reptag on a field the content is replaced with 'reptaged' version and the original content (how it shows up on node edit page) is lost (we dont want that, right?). One solution might be to put out all fields directly without calling _process before into .tpl and run reptag on the generated page (for example using ob_get_contents). However I will need to look into cck code ...

Fajan’s picture

Hmm... I am not too sure unfortunately what you are trying to tell me with regards to the ob_get_contents. Will have a look into the API. I did try doing a reptag on an individual field and like you said, the input is passed into reptag_process() only to have no output available. Thanks for your prompt replies anyway! I think I would now instead use normal html for the time being and patiently wait for your solution to this problem.

From what I see on the CCK side, it seems that there has just recently been discussions with regards to individual formatting of fields before they are sent to the views module for table display. You can see it here....

http://drupal.org/node/58429

profix898’s picture

From what I see in CCK, you need to modify the field.modules (e.g. text.module, number.module, ...). Output is generated by hook_field() during 'view'. There are discussion on how to make the output themable. Look at 'Simple Templating for CCK' (http://drupal.org/node/56298) and the patches suggested by KarenS. I think atm this issue is more related to cck than to reptag. Maybe you can discuss this with cck guys! (But we can discuss other possibilities, as well.)

profix898’s picture

Status: Active » Closed (fixed)
Summit’s picture

I open this issue again, because I just can't figure out how to theme the node title?
Do you may be have a theming example with node.tpl.php?

Thanks a lot in advance for considering.

greetings,
Martijn

Summit’s picture

Version: master » 5.x-1.x-dev

Closing again.
Duplicate of: http://drupal.org/node/338365#comment-1131284
Greetings,
Martijn

abramo’s picture

For some applications, maybe it is simpler to use a php include directly in the content/theme template as follows:

<?php  require_once($_SERVER['DOCUMENT_ROOT'].'/directory1/directory2/file.html'); ?>