And I have also tried to instead of a CTA in the beginning created a text object and using that text object to create a new CTA directly in the code where I want my CTA. But I don't know how to nest the variables and the functions.
This is my line as I tried it: {{ cta(' {{ widget_data.cta_guid.value }}') }}
Which method is best for me? Can anyone help me with the correct code for the best method?
(Note that I have 4 different blog types, hence the if group.id)
Here are my declarations, I have tried using CTA and TEXT fieldsHow can I get the CTA and present it?
To get the module's data into the widget_data dictionary, you'll need to add the export_to_template_context=true parameter to the module tag. That parameter is documented here: https://designers.hubspot.com/docs/hubl/export-to-template-context. So in your case that would look something like this:
That will prevent the actual CTA module from being printed into the HTML. And instead the module data will be exported into the widget_data dictionary. I'd also suggest taking a look at this article about using the Developer Info tab: https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages/. That will make it easier to see how to access values in HubL, like within widget_data for example.