0

I am working on an event content type. It contains a date field that lets users input the date in which their event will take place.
But sometimes the date of the event isn't known at the time the node is created. Users just need to create the event and discuss with other users (in the comments section) then decide when to organize it and add the date then.
So the date field has no default value and I created another boolean field that controls whether the date field is displayed or not using the conditional fields module.

The boolean field has two values, TRUE = « I know the date of my event ».
FALSE = « I will pick a date later »
The field is set to TRUE « I know the date of my event » by default.
If the user picks False « I don't know the date of my event yet », then the date field is hidden and no value is input.

The problems i'm facing are : When displaying the event as a node and when listing all the events in a view :

If the user knows and inputs the date of the event :
- How to only display the date and hide the TRUE/I know the date of my event label/value of the boolean field

If the user chooses to pick a date later :
- How to display a « Date to Be Determined » message and hide the empty date field.

If you have ideas or a better way to handle this, you're welcome

  • Are you not able to exclude the boolean field in the view, under fields? Can you add a screengrab of your view? – longboardnode Nov 30 '16 at 16:04
  • Here are some screenshots of the two cases i.imgur.com/WsjcQlz.png – amstram Dec 1 '16 at 16:10
  • can you take a screenshot of the view's configuration page, ie. /admin/structure/views/view/YOUR_VIEW/edit – longboardnode Dec 1 '16 at 16:39
  • Here it is : i.imgur.com/U4wuotg.png ; (had some health issues these last few days, that's why i'm replying a little late.) – amstram Dec 6 '16 at 11:35
1

Hope youre feeling better! You should be able to achieve this by:

  1. exclude the Date field from view.
  2. in the Later Date field, under "rewrite results" check "Rewrite the output of this field. at the bottom of that fieldset expand Replacement patterns to see all the tokens available. You should see somethine like [Date] to indicate the content from the Date field. Enter that into your text.
  3. In the "no results behavior" section, enter "Date to Be Determined" in the "No results text" box. check Count the number 0 as empty (so when the box isn't checked it will show your "Later" message) and check "Hide rewriting if empty"
  4. Save view and refresh caches
  • It works for the view, thanks ! If you have an idea on how to do this when viewing the event node, your suggestion will be welcome. When a date is picked, the two fields are displayed; The date of the event & the field label "I know the date of the event" – amstram Dec 17 '16 at 2:42
  • Glad it worked! You can modify the output of specific fields by using the template file of your event node's content type. – longboardnode Dec 20 '16 at 3:37

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.