CMS Development

MrCapp
Contributor

Need items in loop to print to separate lines?

SOLVE

Not sure if I'm wording this correctly but let me stumble through my explaination...

 

I'm creating blocks of content that display the tech specs of a peice of hardware. Each of the sub-features (the smaller bold text) can have 1 or more bits of information. I'm able to display the information from the module, it's just not displaying the way I need it to. It's also wrapping all the text in brackets []...

 

I'm a front end developer and I'm having some trouble wrapping my head around loops etc. I was hoping someone with more experienced eyes could point out where I'm going wrong.

 

I've attached an image that shows how the info is displaying VS how I need it to display.

 

Thanks!

 

compare.pngHere is the module code. Feature Description is the bit that is causing issues...

 

<div class="wrapper-specs clearfix">
{% for item in module.list_with_headings %}
<div class="specs">
<h2>{% inline_text field="feature_title" value="{{ item.feature_title }}" %}</h2>
	{% for item2 in item.feature_item %}
<strong style="display: block;">{{ item2.feature_term }}</strong>
			<em>{{ item2.feature_description }}</em>
	{% endfor %}
</div><!-- / specs -->
{% endfor %}
</div><!-- / wrapper-specs -->

 

0 Upvotes
1 Accepted solution
dsoto
Solution
Participant

Need items in loop to print to separate lines?

SOLVE

 

Hi @MrCapp,

 

Your script would just need a small tweak. 

 

Here's the desired version:

<div class="wrapper-specs clearfix">

	{% for item in module.list_with_headings %}
		<div class="specs">

			<h2>{% inline_text field="feature_title" **bleep**="{{ item.feature_title }}" %}</h2>
			{% for item2 in item.feature_item %}
			<strong style="display: block;">{{ item2.feature_term }}</strong>

			<em>{{ item2.feature_description|replace(',','<br>') }}</em>

			{% endfor %}

		</div><!-- / specs -->
	{% endfor %}

</div><!-- / wrapper-specs -->

 

I've only added this filter which replaces the comma to a break tag to add the desired line break.

<em>{{ item2.feature_description }}</em>

<em>{{ item2.feature_description|replace(',','<br>') }}</em>

 

I hope this helps you.

 

View solution in original post

2 Replies 2
dsoto
Solution
Participant

Need items in loop to print to separate lines?

SOLVE

 

Hi @MrCapp,

 

Your script would just need a small tweak. 

 

Here's the desired version:

<div class="wrapper-specs clearfix">

	{% for item in module.list_with_headings %}
		<div class="specs">

			<h2>{% inline_text field="feature_title" **bleep**="{{ item.feature_title }}" %}</h2>
			{% for item2 in item.feature_item %}
			<strong style="display: block;">{{ item2.feature_term }}</strong>

			<em>{{ item2.feature_description|replace(',','<br>') }}</em>

			{% endfor %}

		</div><!-- / specs -->
	{% endfor %}

</div><!-- / wrapper-specs -->

 

I've only added this filter which replaces the comma to a break tag to add the desired line break.

<em>{{ item2.feature_description }}</em>

<em>{{ item2.feature_description|replace(',','<br>') }}</em>

 

I hope this helps you.

 

MrCapp
Contributor

Need items in loop to print to separate lines?

SOLVE

Thanks for taking a look at this!

0 Upvotes