The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Display Before After Content with No Entries

Labels

This Discussion is public

Notifications

Hello,

I would like to still show the before / after content of a view even when there are no entries.

I looked at the available hooks to modify the behaviour, but none seem suitable.

Does anyone know how to do this?

Thanks 🙂

If you want to do before/after comparison, then the before values have to be saved someplace. You can either save values in the database or the in the browser.

There is no way to save before values in the database unless you use custom tables. I had to work something like that out to keep a historical audit trail of all record changes for a University as part of their reporting function to the Department of Education. Since you mentioned a view and not a form, this is the method you may have limited yourself to.

If you only want to display the before/after values for a single session while the user is on the form, then you use the browser's built-in local storage or cookies if the browser is so old that local storage isn't supported. You have to be careful with cookies however because of some data privacy laws. You may not be able to use them in some countries. I use this method for creating a persistent state for a complex search form on an architect's site.

Whatever the case, none of this is native to Formidable and requires custom programming, sometimes very complex custom programming depending on the data and requirements. Hope this helps.

Thanks vfontjr - I appreciate your response and understand what you are saying.

I'm not sure if I haven't explained myself properly, all I want is for the code entered into the 'Before Content' box of the view to show regardless of whether there are entries or not.

In other words, the view is not displayed at all if there are no listings, as soon as I add one entry the 'before content' and 'after content' of the view show up. What I am looking to do is simply show the 'before content' and 'after content' even if there are not any actual listings.

Hope this is clearer?

Kind of a hack but...

Add an admin-viewable-only field to your form called "Do not display", create a dummy entry and set the "Do not display" field to anything, then filter your view body so that it only displays an entry if "Do not display" equals blank (which all your other entries won't set). Do not use the view's filter, rather use

[if dnd equals=""]entry to display[/if dnd]

in the body of your view ('dnd' is the field key for the "Do not display" field). If you allow your users to edit entries, you will need to make sure they cannot edit/delete the "dummy" entry. Alternatively, depending on what your before & after sections contain, you could possibly put your before & after sections in separate views. Your page content would look like:

[display-frm-data beforeview]

[display-frm-data actualdataview]

[display-frm-data afterview]

The before and after sections of your actualdataview view would be blank.

Thank you roja,

The hack approach is really hacky :D Not sure I can get away with that.

...but the multiple views approach is probably going to work. Good thinking! Now you mentioned this approach, I seem to remember having seen similar things in the documentation.

When I get back to it I will check and report here on how it works out.

Thanks again!

There is an easy way.

Copy your view's before and after contents to "No entries" message settings at your view - https://formidableforms.com/knowledgebase/display-your-form-data/#kb-no-entries-message

While copying your before & after content to the no entries field is the easiest way to get the desired result, the developer will need to remember to make identical changes in two places instead of one.

I have had the need to do what S is looking to do. Bottom line, all of these solutions are far more difficult to implement and maintain that what should be necessary. I would love for Formidable to simply show the before & after content if the no entries message is left blank or a "Show before & after even if no entries exist" settings checkbox is added.

Discussion closed.