Sprocket Rocket
  • Sprocket Rocket Design System
  • Initial Setup
    • Setup HubL Local Server
    • Setup SR App Locally
    • Clone LaunchPad Starter
  • Create a New Module
    • Design
    • Code
    • Implementation
    • Create a Pull Request
    • Fields JSON
  • Code Patterns
    • Design Settings
    • Headings
    • Responsive Images
    • Implementing Forms
    • Typography
    • CTA/Button
    • Spacers
  • PR Review
    • Design / Code Review
    • Implementation Review
  • Handoff Relay Checklist
    • Client Request - Handoff
    • Page/Template Design - Handoff
    • Module Design - Handoff
    • Page/Template Development - Handoff
    • Module Development - Handoff
    • Review & Delivery - Handoff
  • Guides and Tutorials
    • Code Snippets
    • Lazy Loading
    • How to setup the blog subscription notification emails
    • 404 Error Tracking Event with Google Analytics and Google Tag Manager
    • How to setup a form to be used with SR Conversational Form 01
    • Upgrading Bootstrap to Latest Version
  • HS Page Launch (QC)
  • SR Agency Website Review Checklist (QC)
Powered by GitBook
On this page
  • Load more
  • URL Parameters
  • Sending data to a hidden form field
  • Check if a contact is in a list
  • Check if there is a contact
  1. Guides and Tutorials

Code Snippets

Load more

{# HTML #}
{% if module.faq|length > module.show_of_default %}
<div id="{{name}}loadMore" class="text-right">
	<a href="#" class="btn btn-outline-primary">View All</a>
</div>
{% endif %}
										
{# CSS #}
{% if module.faq|length > module.show_of_default %}
.sr-faq-01 .faq-item:nth-child(n+{{ module.show_of_default + 1}}) {
	display: none;  
}
{% endif %}

{# JS #}
{% if module.faq|length > module.show_of_default %}	
$(".{{name}} #{{name}}loadMore").on('click', function (e) {
	e.preventDefault();
	$(".{{name}} .faq-item").slice(0, 99).show();
	$(this).remove();
});
{% endif %}

URL Parameters

{# http://www.example.com?name=John #}

{% if request.query_dict.name%}

    {{request.query_dict.name}}

{% endif %}

Sending data to a hidden form field

hbspt.forms.create({
	target: '.hs-form-embed', {# Optional, create form in the target #}
	portalId: "{{hub_id}}",
	formId: "{{ module.step_4.form.form.form_id }}",

	{# Send all the data to the hidden field #}
	onFormReady: function($form) {	
		$('input[name="hidden_field"]').val('Hello World').change();
	}
});

Check if a contact is in a list

{% set list = [] %}

{% if request_contact.list_memberships is iterable %}
	{% for list_id in request_contact.list_memberships %}
		{% if list_id == module.step_4.list_ID %}
			{% if list.append(1) %} {% endif %}
		{% endif %}
	{% endfor %}
{% endif %}

{% if list|length == 0 %}
	
{% endif %}

Check if there is a contact

{% if !contact_without_defaults.firstname %}

{% endif %}
PreviousReview & Delivery - HandoffNextLazy Loading

Last updated 4 years ago