• Resolved nipasarkerhd

    (@nipasarkerhd)


    How can i add it on template I know I can add in post or page with short code.

    But I would like to add it to the template.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    You can render a shortcode in a template like this:

    if( shortcode_exists( 'site_reviews_form' )) {
        echo do_shortcode( '[site_reviews_form id="8z2Yat13"]' );
    }
    if( shortcode_exists( 'site_reviews_summary' )) {
        echo do_shortcode( '[site_reviews_summary schema=true]' );
    }
    if( shortcode_exists( 'site_reviews' )) {
        echo do_shortcode( '[site_reviews schema=true]' );
    }

    Additionally, if you need something more advanced you can use the glsr_get_reviews() helper function in your template to get an array of reviews, loop through them, and render them however you want. See the “Site Reviews → Get Help → Documentation → Helper Function” page for more information on the available Helper functions.

    • This reply was modified 7 years, 8 months ago by Gemini Labs.
    Thread Starter nipasarkerhd

    (@nipasarkerhd)

    Thank you..It works…

    Is there any way I can hide the box once the users post reviews.

    Plugin Author Gemini Labs

    (@geminilabs)

    To hide the submission form after a submission, you can use the “site-reviews/after/submission” custom Javascript event, for example:

    document.addEventListener( 'site-reviews/after/submission', function( event ) {
        if( event.detail.errors !== false )return;
        // The review has been submitted successfully so you can now 
        // manually hide the submission form and show the success message.
    });

    The important property in the event variable in this custom event is the event.detail property. This object contains the following properties:

    event.detail.errors = This contains any form errors that were passed. You must check that this is false (event.detail.errors === false) before any redirection or “on success” logic takes place.

    event.detail.message = This contains either the success message or the error message for the form.

    event.detail.form = This contains the HTMLFormElement of the review submission form. If you want to hide the form after submission, you can use this as the target.

    You can either use jQuery to animate removing the form jQuery(event.detail.form).slideUp().parent().append('<p>' + event.detail.message + '</p>'); // something like that, or see here for tips on using vanilla JS: https://plainjs.com/javascript/effects/animate-an-element-property-44/

    • This reply was modified 7 years, 8 months ago by Gemini Labs.
    • This reply was modified 7 years, 8 months ago by Gemini Labs.
    • This reply was modified 7 years, 8 months ago by Gemini Labs.
    Plugin Author Gemini Labs

    (@geminilabs)

    Also an additional note:

    If using both the [site_reviews_summary] and the [site_reviews] shortcodes in your template, I recommend you only enable the schema option on one of them, not both (preferably the [site_reviews] shortcode as this will also include schema for each individual visible review).

    There is no harm is having duplicate schema on your page, but it is unnecessary.

    e.g.

    if( shortcode_exists( 'site_reviews_summary' )) {
        echo do_shortcode( '[site_reviews_summary]' );
    }
    if( shortcode_exists( 'site_reviews' )) {
        echo do_shortcode( '[site_reviews schema=true]' );
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How too add it to the post template’ is closed to new replies.