I have a content type with 2 CCK text area fields.
The first field is always filled.
The second fields is optional.
Now: I have 2 Views.
In the first View the first field is always displayed.
In the second View the first 2 lines of the first field are displayed. However if the second field is filled, the first field should be ignored.
How can I make this. I need an option in the content type specifying if I should use the second field rather than the first one ? (For the second view)
I hope it is clear. Thanks
Create a template for the view and use if and else statements to only show what you want to be shown.
Related
I have added an extra field to a field group, which already contained 4 fields, this field group is used on the form: smmBusRelTable.
The 4 existings fields are appearing without problems, the new field isn't showing up in the form.
The field is visible.
The field exists in the field group on the form.
I have resetted my personalise screen on that form.
I can add the field through personalise, but it won't show up.
It has no CountryCode filled in.
Any ideas?
Some things to try:
Right clicking on the form and click restore.
Go to the control (group, grid, etc) you're expecting to see the fields in, and verify the DataGroup property has the correct Field Group selected. Try clearing this property, saving, then adding it back again.
The init method on the form, set the visible parameter of the field on false. That is why the field showed when i added the field group on a new form.
I'd like to ask a tricky question to you about Drupal.
I created a new content type which includes lots of fields.
I want to find a module that adds a 'Add another' link to the adding content screen which will duplicate certain fields.
Example:
I have fields named Panel1 Photo, Panel1 Info, Panel2 Photo, Panel2 Info...
When adding a new content of this type, if I want to enter 3 panels, I want this module to create 3 fields of Photo and Info for me, and maybe 4 or 5 at other times.
I hope you will understand what I ask.
Thank you in advance.
You could have each field set to allow multiple values which would put the add another button you talk about. If you make a field collection with the field collection module you will be able to group those fields together and you can allow multiple values for the field collection. Let me know if you haven't found the add another button.
Install the field collection module then in the content type create a field collection with panel and photo fields.
When you create your first content page you will start with one panel and photo and a + button. The + button gives you the ability to create ever more panels and photos grouped together.
I have a content type that contains an image field and uses image_image widget. When editing the node I'd like to add an extra text input for each image. This text is not part of the node, I'd use it to generate a translation. I know how to do tweak other parts of the form, but here I'm lost between hook_form_alter() and hook_field_widget_form_alter(). How does one do this?
For now, I use hook_form_alter and an after_build function to twist the image's alt field into what I need to see in the node edit form. Then I move the submitted value to where I want it and copy the image's title field value into its alt field value. I don't mind them being the same. But I'm sad.
You can use Field collection to bundle your image field with an extra text field that goes with it.
In a node creation form, which is a custom content type, I want to add a text, not a text input field, but just a text line, as a remark or an NB, I search for long time in vain.
How can I do that?
Are you using the FieldGroup (http://drupal.org/project/field_group) module? If so, when creating a field-group for a content type's fields, select Vertical Tab as the type of fieldgroup and once you've placed the fields you want to include 'under' that group, save the page. You will then see a gear icon listed under the Operations menu within the row for your newly created field-group. Clicking on this gear icon will give you some additional options, including a Description area where you can write in instructions or whatever you like that will display on the node creation page within that particular tab and at the top of all the fields you have in that tab.
You should be able to add text using the markup form element.
Description: Generate generic markup for display inside forms.
Example from the documentation:
$form['contact_information'] = array('#markup' => variable_get('contact_form_information',
t('You can leave us a message using the contact form below.')),
);
This will work to give you overall instructions for the node creation form:
Create a new block.
Don't give the block a title.
Set block body to whatever you want the instructions for the node form to be.
Under the "Pages" option of the block creation set "Only the listed pages". Then add "node/add/[custom-content-type]" for whatever type of content it is.
Drag the new block to the top of your content section of your active theme.
I've created a views of node and I've selected the "fields" option in order to select which fields to display and in which order.
Is there a way to group such fields ? It would be very useful to have parent divs in my html code.
thanks
There's a simpler way to do it: http://www.arsnova.cc/web-development-articles/2012-07-27/grouping-fields-together-drupal-views
Let's say you want to group fields 1-3 together within a div.
First, exclude fields 1 and 2 from display. (By "exclude", I do not mean to delete them from the views display; rather, click on the "exclude from display" button within each field's options.) The fields you exclude from display must come before the other field for this to work. If they don't, rearrange them so they do.
Go to field 3, and rewrite the results, inserting the token for each of fields 1-3.
That's all you need to do. Fields 1, 2, and 3 will now appear within field 3's div. If you want, you can also add additional markup within the "rewrite results" area.
Recently found the best way for my needs and apparently for the needs of many people:
Use views_fieldsets module https://drupal.org/project/views_fieldsets, it allows yo to create a grouping div to put fields inside.
Grouping is built into Drupal 8 Views. So no need for any extra modules. Here's how:
Edit your view (be sure it has fields)
Click Format's Settings
A box will pop up with all your selected fields
Look right underneath all the field names, there should be "Grouping field Nr.1"
Select the field you'd like to group by
Click Apply
If you want to subgroup with a second field, just go back to 2 then you'll see "Grouping field Nr.2"
That's it.
Yes, click on the gear next to the Style option (under Basic Settings) and set the Grouping field. Keep in mind, the grouping field needs to be added to the view, but you can check the Exclude from display option to hide it, if needed.
I'm pretty sure that would give you a parent div. If not, you could add the parent div, by overriding the default templates (look to the Theme: Information section, under Basic Settings, for more information).