I'm very new to Drupal so please bear with me.

I added fields under a content type. When I edit this particular content type, it displays the fields I created, and I can input content. When I hit preview, I can see the content I inputted into those fields. However, when I save the changes and view the page, the content of those new fields is not showing.

Can anyone tell me what is going on?

Thanks.

Comments

jclaussen’s picture

Can you check and see if your custom content type has the field display set correctly?

It should be a tab next to manage fields when you are adding fields to your content type.

admin/content/node-type/**your-content-type**/display

Springs’s picture

The text field I created shows the following under display:

Label - Above
Teaser - Default
Exclude - unchecked
Full node - Default
Exclude - Unchecked

It doesn't seem like anything is incorrect. Still, I cannot see any of the text from the field displayed on the page after saving it.

jclaussen’s picture

I don't think this will solve your problem but can you change your 'Full Node' setting to plain text.

Do you have any field permissions set?

You can also contact me through the contact tab and I could take a quick look at it for you.

Springs’s picture

Unfortunately that didn't work. I don't think I have any field permissions set. I talked to the developers who said that adding fields to content types must be done by also changing the code in the template file. They didn't say how this is done, however. Is this the usual process?

I'll let you know if I need you take a look. Thanks a lot for your help.

WillHall’s picture

Do you have a node template for that node type?

In your node template add this to the bottom and see if your fields are there.

<pre><?php print_r($node); ?></pre>

Springs’s picture

Can you explain where I can find/access these node templates? Thanks.

WillHall’s picture

in your theme folder.

For example:
sites/all/themes/acquia_prosper/node.tpl.php
sites/all/themes/acquia_propser/node-story.tpl.php

Springs’s picture

Ok, I tried what you suggested and was able to see my fields at the very bottom where it gives a preview of the blocks. However, the data is long and convoluted so I don't know if the fields are appearing in the places they should - I don't know what I'm supposed to be checking for, basically.

Looking at the .tpl.php, however, I can only see the field names that actually work shown in the code; the names of the fields that aren't working are not in the php.

I suppose that the logical thing to do is to write a command in the php to print the new fields. Is this correct? I don't have any php experience, so what do I need to input to make this work? Also, shouldn't drupal automatically edit this template when I create the fields in the CMS?

WillHall’s picture

Ya, that would do it. Node templating is pretty easy.

<?php print $node->field_name[0]['value'] ?>

However - I need to ask if you are looking at a template for your content type - or the basic node template.

What is the name of the file?

ideally you should customize a node for the content type instead of hacking the base node template.

so if your custom content type was "popcorn" then the name of your template would be node-popcorn.tpl.php in which you might have.

<div class="popcorn">
     <h2><?php print $node->title; ?></h2>
     <span>Is there butter?: <?php print $node->field_buttered[0]['value']; ?></span>
     <div class="description"><?php print $node->content ['body']['#value']?></div>
</div>
Springs’s picture

I can't believe it - it works! Yes, it is a custom content type template I was editing.

Thanks for your help!

Springs’s picture

I've run into a new issue. I have "content type 1" (A) pulling info from "content type 2" (B) through views.

I've added a new text field for (B) through "manage fields".
I then added the field in /admin/build/views/edit/content type 2 --> Default --> Fields
Then I added the markup in the view-view-fields-content type 2.tpl.php

Below are the last 3 lines in the php. Note the last line is the one I added.

<div class="description"><?php print $fields['body']->content; ?></div>
<div class="files"><?php print $fields['field_p_files_fid']->content; ?></div>
<div class="text"><?php print $fields['new_field_name']->content; ?></div>

For some reason, the first two existing fields appear on (A), but my new field does not. Seems I did everything correctly... if I print a random string like 'hello' instead of the $field the text will show up on. Again, if I preview (B), the content in the field will display.

Any clues? Thanks.

WillHall’s picture

custom fields in views always start with the field prefix and usually end in value - or fid - or something.

You can see what the id is of the field by clicking on theme information in the views ui.

<div class="text"><?php print $fields['field_new_field_name_value']->content; ?></div>

Springs’s picture

Thanks so much!