Custom module

Highlighted
New Contributor

Hi,

I have created a custom blog module that I want to use to store some aditional information about every blog post. I included this module in the header of the blog post page. Now let's say in the module I have a field called 'event_date'. I want to display this field from the module in my blog post page.

How can I do this ?

Reply
0 Upvotes
4 Replies
Advisor

Hi there!

 

When you create a field in a custom module you can click on Copy > Copy Snippet to copy the field: 

 

copy-snippet.png

 

When you paste that snippet into the HTML + HubL section of your module and preview it, you should see the data you've input into that field in the preview: 

 

date.png

 

Using that module in a template should display the same information that you can see in the preview. 

 

I hope that helps!

 


Stephanie O'Gay GarciaHubSpot Design / Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

Reply
0 Upvotes
New Contributor

Hi, 

 

Thanks for your answer, but that wasn't exctly my question. 

Inside the module I know that I can use the variable by:

{{ module.event_date }}

But if I include that module in a template, how can I use the variable inside my template ? ( not in the module itself ).

Reply
0 Upvotes
Advisor

Apologies for any confusion! If you add the module to a template and click into it, when you scroll down you should have the option to set information in the template: 

 

content.png

 

At the page level you'll also have a similar option: clicking into the module will let you update it on the left-hand side (this doesn't apply for blogs since everything is done at the template level).


Stephanie O'Gay GarciaHubSpot Design / Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

Reply
0 Upvotes
Regular Contributor

you can access any field inside the custom module through
{{ content.widgets.module_idxxxxx.body.field_name }}

Reply
0 Upvotes