2

I have a custom content type in Drupal 7. It consists of a fixed number of images. I would like to make it so that when its viewed, it comes up as a form. Each image would have a text area underneath, and when a user hits 'submit', the text they entered are displayed below each image.

We're not going to store the text that they enter for the nodes. It's just going live for that form submission.

What hooks can I use to alter the display and functionality of my content type?

4

It looks like the best solution is hook_node_view(). Unfortunately it gets called on all node renderings, so I'm putting in a check for my content type. The hook hook_view() also exists, but that's only for content types that are completely defined within the module.

0

I'm not 100% sure this is going to work, but the first thing I would try is to create a custom field formatter for image fields. The formatter should check if form data has been posted. If so, it displays the image with the posted text (using check_plain(), of course). If not, it displays the image with the form field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.