Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default templates #4

Open
SGSSSDTP opened this issue Dec 11, 2020 · 4 comments
Open

Default templates #4

SGSSSDTP opened this issue Dec 11, 2020 · 4 comments

Comments

@SGSSSDTP
Copy link

Apolgoies if this is the wrong place to ask, but I was hoping there were some example templates for use with archive-gf-pages-form.phpand single-gf-pages-form.php. I've managed to install these within my theme but have no idea what to put in them or where to get the content from for elsewhere. Gravity forms based on shortcodes or styled fine, but those generated by this plug in do not style at all.

Example: https://social.sgsss.ac.uk/forms/test-2/

@lmoffereins
Copy link
Owner

Hi @SGSSSDTP, glad you find the plugin useful! Thank you for your question.

The plugin does not come with default styling, because the markup of the forms are identical to their shortcode counterparts. In fact, the plugin just uses do_shortcode() under the hood to generate the forms. Therefore, the theme should handle the form styling the same way as when shortcodes are used.

The point of custom templates is to provide options for when you do not want the plugin to apply Theme Compatibility. Theme Compatibility is a technique that relies on a standard theme template file (like page.php or similar) for displaying the plugin page(s) while it replaces the post's content. As you can see in includes/template.php on line 379 and onwards, the plugin first looks for any dedicated template file for the plugin. If the theme does not support this, the plugin will eventually in gf_pages_get_theme_compat_template() fallback to index.php when none of the other template files are found and then it does its content replacement magic. It might be perceived as hacky, but it is a common way to do custom content pages in both bbPress and BuddyPress.

So in short, if there are no apparent side effects, you would generally not use custom templates in your theme, but leave the content replacement up to the plugin. The theme itself should apply the styling as it would with the usual form shortcodes.

If you however do decide to use custom templates, you should refer to gf_pages_the_form_content() and other template tags for the current form's content and other details. Admittedly the documentation could benefit from an update on this part. When I get to it, the readme will be updated to include a more clear description of the templating mechanics.

I hope this answers your question. Let me know if there's anything else I could help with.

@lmoffereins
Copy link
Owner

The following update is considered for the Theme Compatibility readme section. @SGSSSDTP Would you find this change helpful and clear enough?


Theme Compatibility

By default, the plugin generates the pages of both the form archive and single forms using template files from your theme. This theme-compat logic is similar to the ones featured in plugins like bbPress and BuddyPress. If your theme contains a single.php or page.php template file, this plugin will handle the content insertion automagically. See gf_pages_get_theme_compat_template() for the full stack of queried template files.

When desired, the templates used for displaying both the form archive and single forms can be overridden in your theme. Use the following file names in your theme's gravityforms template folder:

  • archive-gf-pages-form.php for the form archive page. See gf_pages_get_form_archive_template() for all options.
  • single-gf-pages-form.php for a single form page. See gf_pages_get_form_template() for all options.

Refer to the includes/form.php file for the form archive and single form template tags. See the templates/default/gravityforms/content-archive-form.php template part for an example of how to structure the form archive's content.

@SGSSSDTP
Copy link
Author

SGSSSDTP commented Nov 5, 2021

Thank for this information, it does make sense. When I use the shortcode the forms are styled perfectly, but on the pages generated by the plugin the forms come out like so:
pagesexample
I've tried with other themes and it works just fine, so this seems to be specific to the theme I'm using (BuddyBoss) and nothing to do with plugin itself. I don't have the knowledge to investigate why so I'll do some digging with the guys at BuddyBoss.

Thanks again for your help.

@lmoffereins
Copy link
Owner

Glad you could confirm the plugin works with other themes. I don't have a copy of the BuddyBoss theme to debug the issue. If you find anything that might suggest a fix is needed in the plugin, let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants