CMS Development

SAU
Participant

Adding Background images

I have created a series of landing pages and have an editable text block with a background hero image which I have styled in css.

 

Is there a background module or what is the best way I can have the user edit the text and select a background image?

0 Upvotes
5 Replies 5
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Adding Background images

Go to Belch and publish a page and checkout the source code of the template after you publish.

You will see a lot of different ways we created that functionality along with other built in module functionality.

0 Upvotes
stefen
Key Advisor | Partner
Key Advisor | Partner

Adding Background images

@SAU I'd recommend creating a custom module, call it something like "Hero", then you can add text and image fields so they are editable. The code would look something like this:

<div class="hero"{% if module.bg_image %} style="background-image: url({{ module.bg_image }});"{% endif %}>
  <div class="hero-text">
    {{ module.text }}
  </div>
</div>
Stefen Phelps, Community Champion, Kelp Web Developer
nmoore
Member

Adding Background images

Can you show us what the fields.json file would look like for this module? Including a default background image?

0 Upvotes
SAU
Participant

Adding Background images

Thanks, I can't create a custom module if I use coded templates though? Only in Drag and Drop

0 Upvotes
stefen
Key Advisor | Partner
Key Advisor | Partner

Adding Background images

@SAU you can use custom modules in coded templates you'll just need to copy and paste the code in the bottom right of the module editor.

Stefen Phelps, Community Champion, Kelp Web Developer
0 Upvotes