Skip to content

Instantly share code, notes, and snippets.

@NickDeckerDevs
Created April 11, 2025 13:57
Show Gist options
  • Save NickDeckerDevs/5ef39963e2d1ebef7244ee353f3036c8 to your computer and use it in GitHub Desktop.
Save NickDeckerDevs/5ef39963e2d1ebef7244ee353f3036c8 to your computer and use it in GitHub Desktop.
This is an example of using a global widget to store information on the template, and then calling that global widget from a module (as well as using a macro) to give a bunch of global data to different modules to allow for some really simple way of moving data from a template file to the individual modules in a page. You can also just load this…
<!-- This is the global FAQ module -->
{% module
"global_faq"
path="../../modules/global/global-faq.module",
label="global-faq"
export_to_template_context=True
%}
<!--
this is how it looks in design manager: https://share.cleanshot.com/PxD7wBWK
It is just a repeater group with some options to fill out to make a FAQ section
The groups faq items when editing: https://share.cleanshot.com/tsnLQcXh
A single FAQ item in the editor: https://share.cleanshot.com/2NZCk4bB
-->
<!--
This is the macro I'm calling, in different modules. This isn't necessary but this is just how
I've set this up to make it easier to manage the FAQ cards.
You can see I'm passing in the widget_data.global_faq, which is the repeater group/faq global module
-->
{{ faq_card("faq-card","Frequently Asked Questions", widget_data.global_faq, "", "midnight-wave", 20) }}
<!--
here is the macro I'm calling the third param is the faqItems which is that global widget
data.faq_items is the repeater group/faq global module
This was set up to do different categories that way I could show specific FAQ cards in different places
based upon the module we call the macro from. The category is currently not being used, and I'm just using
the |shuffle filter to randomize the order of the FAQ items.
-->
{% macro faq_card(target_id, title, faqItems, category = "all", color, total = 20) %}
{% set faqs = faqItems.faq_items %}
{# {% set category = category|replace(' ', '-') %} #}
<div class="card faq-card {{ color }}"{% if target_id %}{% call target_id_macro(target_id) %}{% endcall %}{% endif %}>
<div class="header">
<h3 class="headline">{{ title|capitalize }}</h3>
</div>
<div class="content body-bigger">
<div class="faq-list">
{% for faq in faqs|shuffle %}
{% if loop.index <= total %}
<div class="pb-lg faq-item {{ loop.index % 2 == 0 ? 'even' : 'odd' }}{% if loop.first %} active{% endif %}">
<div class="pt-md pb-md faq-question color-royal-depth">
{{ faq.faq_title }}
<span class="faq-icon">
<i class="fa{{theme.advanced.icon_style}} fa-chevron-down"></i>
</span>
</div>
<div class="pt-md pb-md faq-answer color-cosmic-ink">
{{ faq.faq_details }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endmacro %}
<!-- here is the {{ widget_data.global_faq|tojson }} just put into a script tag to make it easier to read and not mess with my code editor -->
<script>
const printedJson = {
"definition_id": null,
"export_to_template_context": true,
"faq_items": [
{
"category": ["all"],
"faq_details": "They'll receive an email invitation with a unique link to set up your account. Follow the prompts to register and log in.",
"faq_title": "How does a team member login to their account?"
},
{
"category": ["submit-opportunites"],
"faq_details": "Currently the best way to submit a referral is to visit the Submit Opportunities page and copy your referral link, and email that to your referral.",
"faq_title": "How do I submit a referral?"
},
{
"category": ["dashboard"],
"faq_details": "Yes, the Dashboard page shows real-time updates on all submitted leads, their progress, and final outcomes.\n\nYou can visit your Pipeline and Commission pages to see more information relevant to the ",
"faq_title": "Can I track the status of my referrals? "
},
{
"category": ["all"],
"faq_details": "We are currently building out the Resources section and will continue to improve this when we receive feedback from partners.",
"faq_title": "Where can I find resources and training materials?"
},
{
"category": ["all", "profile", "partner-settings"],
"faq_details": "There are two places you can modify information.\n\nFor your partner details and modifying team members, visit the Partner Details page.\n\nTo modify your personal information look in the menu for your name and click on this, it will take you to your Account Settings page",
"faq_title": "How do I update my account information? "
},
{
"category": ["all", "commission"],
"faq_details": "You can check your commission history and other details on the Commission Page.",
"faq_title": "How do I view my commissions?"
},
{
"category": ["all", "commission"],
"faq_details": "Commissions are processed on a monthly basis after the all invoicing requirements are complete.",
"faq_title": "When will I receive my commission payments? "
},
{
"category": ["all", "commission"],
"faq_details": "Contact our support team via the portal's Support to resolve any discrepancies. Commission is determine by the success fee. Some success fee's will change the percentage of your commission.",
"faq_title": "What happens if there's a discrepancy in my commission? "
},
{
"category": ["all", "profile"],
"faq_details": "Click \"Forgot Password\" on the login page, and you'll receive an email to reset it.",
"faq_title": "What if I forget my password? "
},
{
"category": ["all", "submit-opportunites", "pipeline"],
"faq_details": "You can find all of the assistance for uploading images here: Resources Page",
"faq_title": "I'm having trouble uploading documents. What should I do? "
},
{
"category": ["all"],
"faq_details": "Yes, the portal is mobile-friendly and can be accessed via any browser. \n\nTables need to be scrolled through. We are currently looking for a better way to display this information and will announce when that happens.",
"faq_title": "Can I access the portal on my mobile device? "
},
{
"category": ["all"],
"faq_details": "The portal has an error reporting system that should deliver the error to our system should you attempt to update something and receive an error message.\n\nComing soon...\nThere is a \"Report Issue\" option in the sidebar. You can also use that if you would like.",
"faq_title": "What if I encounter an error in the portal? "
},
{
"category": ["all"],
"faq_details": "\nReach out to our Partner Support team via the in-portal Support page\n\n\\n\nYour Partner Support will have their email address in the team display.\n\n",
"faq_title": "Who can I contact for additional help? "
},
{
"category": ["all", "partner-details", "partner-settings"],
"faq_details": "Check the image requirements under the download button. If your image is too large, use an image resize tool to reduce size within parameters. Open tool, navigate to the bottom right corner of the interface where you'll find the \"Edit\" menu, then toggle the \"Resize\" option to access the resizing controls; here you can manually adjust the image width and height to 300 x 300 pixels or less. Review the quick tutrorial here: Video Tutorial",
"faq_title": "I'm getting an error when I upload my images. How can I upload?"
}
],
"field_types": {
"faq_items": "group"
},
"label": "global-faq",
"module_id": 185351473831,
"parent_widget_container": null,
"path": "/lendzee-theme/modules/global/global-faq",
"smart_objects": null,
"smart_type": "NOT_SMART",
"type": "module",
"wrap_field_tag": "div"
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment