PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

find out is gravityforms were called on page

  1. obvio
    Member

    I want to know if it's possible to know if there's a call to gravity form through FUNCTION in my template and not through shortcode so I can then include the script/style files and not not do it on every page.

    I cant use is_catgory() or the likes of those, think of page template that may be used randomly (cant use is_page or is_single either).

    Posted 14 years ago on Tuesday September 14, 2010 | Permalink
  2. Yes, you can embed a form via the short code or via a function call in your theme template file itself. You can read more on this here:

    http://www.gravityhelp.com/documentation/embedding-a-form/

    The function and parameters are listed on that page.

    Posted 14 years ago on Tuesday September 14, 2010 | Permalink
  3. If you're embedding a form via the shortcode or the new forms widget, the scripts and CSS should only load on the pages that have forms and not on pages where forms don't exist.

    When using a Gravity Form in a third party sidebar widget or embedding it anywhere using the function call, you need to manually enqueue the scripts and CSS by placing a short script block in your theme's functions.php file.

    wp_enqueue_script("gforms_ui_datepicker", WP_PLUGIN_URL . "/gravityforms/js/jquery-ui/ui.datepicker.js", array("jquery"), "1.3.9", true);
    
    wp_enqueue_script("gforms_datepicker", WP_PLUGIN_URL . "/gravityforms/js/datepicker.js", array("gforms_ui_datepicker"), "1.3.9", true);
    
    wp_enqueue_script("gforms_conditional_logic_lib", WP_PLUGIN_URL . "/gravityforms/js/conditional_logic.js", array("gforms_ui_datepicker"), "1.3.9", true);
    
    wp_enqueue_style("gforms_css", WP_PLUGIN_URL . "/gravityforms/css/forms.css");

    Just like using the shortcode, the conditional logic scripts, datepicker script, form CSS and other elements needed for the full form functionality will be loaded only on pages with a form present.

    You can find more information at the URL below

    http://www.gravityhelp.com/documentation/embedding-a-form/

    Posted 14 years ago on Tuesday September 14, 2010 | Permalink
  4. obvio
    Member

    i know those. this is how i already do it.. what i was looking for is some kind of a conditional to put in functions.php so the extra file won't get included on any page, but without using in_category or something similar. i need something like $_GET['gravityforms'] = form_id or something similar.

    Posted 14 years ago on Tuesday September 14, 2010 | Permalink
  5. obvio
    Member

    bump()?

    Posted 14 years ago on Sunday September 19, 2010 | Permalink
  6. What extra file is being included? I guess I'm missing something here.. if everything is enqueued properly, then the files should only be loaded on pages that actually have forms.

    Posted 14 years ago on Sunday September 19, 2010 | Permalink
  7. obvio
    Member

    if i put those in my functions.php they are enqueued and echoed to the footer *on any page view* (any unique url), even if the page doesn't have any shortcode or function call to a gravity-form.

    code in functions.php just runs any time.. i'm looking to know if there's an early stage -just after the query was made- and before starting the file output so then then to enqueue those files.

    ps.
    email notifications for topic don't work.

    Posted 14 years ago on Tuesday September 21, 2010 | Permalink