CMS Development

liz_shaules_lf
Participant

How to pass images into custom modules called via HubL?

SOLVE

Hello,

 

I am trying to call a module through the following line:

{% custom_widget "orange_juice_basic_paragraph" widget_name="orange_juice_basic_paragraph" %}

 

That module has a rich_text line in it, which I would like to override through the line above:

{% rich_text "basic_paragraph" no_wrapper="True" label="Basic Paragraph" html="<p>Lorem Ipsum</p>" %}

 

Is there a way to pass content from the module call to the module itself?

 

Thanks!
Liz

0 Upvotes
1 Accepted solution
Jsum
Solution
Key Advisor

How to pass images into custom modules called via HubL?

SOLVE

If I understand you correctly then I am not sure you need to do what you are trying to do.

 

If you create a custom module, or use any module for that matter, and place it in a template, the contents of that module are editable per page. 1 template can create 100+ pages, all with different content. There is no need for trickery as this is the primary function of a template in any cms. 

 

Is this what you are going for?

 

Edit: I just saw your edit. You can't use HubL in rich text editors save for the contact tokens for some reason. that is why the markup is displaying as markup.

View solution in original post

5 Replies 5
Jsum
Key Advisor

How to pass images into custom modules called via HubL?

SOLVE

@liz_shaules_lf,

 

It might help if you shared what exactly you were wanting to accomplish. You can't overwrite the content of a custom module in your code, well you could but you would need to export it to the template and then you would have to basically build it back out in your code using the data from the module because it will no longer output it's default to the template. It would be messy. Maybe there is a better way to do what you are wanting.

liz_shaules_lf
Participant

How to pass images into custom modules called via HubL?

SOLVE

Thank you for replying :-).

 

I am basically trying to make a collection of templated modules that can be mixed and matched between different HTML templates.  The templated modules will have Lorem Ipsum in them, but the HTML templates will pass the unique filler text to those modules.  So all the emails share the same modules, just different text.  The obvious answer is to make unique modules for everything, but then we are talking about replicating code a couple hundred times.

 

I am able to make a sort of solution by doing this in the HTML email file:

{% set var_one = "Join us at your <span style=\"color:#ff6305; font-weight:bold;\"> next local user group!</span>" %}
{% custom_widget "orange_juice_basic_headline" widget_name="orange_juice_basic_headline" %}

 

and then adding this line to the module:

 {% rich_text "Headline" label="Headline" html="{% if var_one %}{{ var_one }}{% else %}Lorem ipsum dolor sit amet, <span style=\"color:#ff6305; font-weight:bold;\"> consectetur adipiscing elit!</span>{% endif %}" %}

 

But when you go to edit this as an actual email, you see this:

2017-10-03_1409.png

Rather than the text I've populated var_one with.  Any ideas?

 

Thanks!
Liz

0 Upvotes
Jsum
Solution
Key Advisor

How to pass images into custom modules called via HubL?

SOLVE

If I understand you correctly then I am not sure you need to do what you are trying to do.

 

If you create a custom module, or use any module for that matter, and place it in a template, the contents of that module are editable per page. 1 template can create 100+ pages, all with different content. There is no need for trickery as this is the primary function of a template in any cms. 

 

Is this what you are going for?

 

Edit: I just saw your edit. You can't use HubL in rich text editors save for the contact tokens for some reason. that is why the markup is displaying as markup.

liz_shaules_lf
Participant

How to pass images into custom modules called via HubL?

SOLVE

Ah. Ok, thank you for clairifying that for me.  Thats the missing piece to the puzzle.  Thank you very much for your help!  It is greatly appreciated!

0 Upvotes
Jsum
Key Advisor

How to pass images into custom modules called via HubL?

SOLVE

No Problem at all.

 

Also, I tested the code you shared. The markup showed in the rich text editor in the page editor, but the actual page showed the value of the variable. I guess the rich text editor doesn't process the Hubl for view in the editor but does still process it to the page. 

0 Upvotes