Bruce Gust
asked on
How would I pull this for loop off in Symfony?
Here's a screenshot of the way things look currently:
Here's what things need to look like:
The variable that represents the "Campaign Name." - that's the heading for each of the Challenges listed immediately afterward -is "challenge.campName"
If was coding this in vanilla PHP, I would do something like this:
<?php
$the_challenge_name="";
<for loop>
if($the_challenge_name<>$c hallenge.c ampName) {
echo $challenge.campName;
}
---continue loop and then at the very end of the loop, do this:
$the_challenge_name=$chall enge.campN ame;
<end for loop>
I know what needs to be done, but I don't know how to code it in the context of a Symfony dynamic.
Can you help a brother out?
Here's the actual code:
Here's what things need to look like:
The variable that represents the "Campaign Name." - that's the heading for each of the Challenges listed immediately afterward -is "challenge.campName"
If was coding this in vanilla PHP, I would do something like this:
<?php
$the_challenge_name="";
<for loop>
if($the_challenge_name<>$c
echo $challenge.campName;
}
---continue loop and then at the very end of the loop, do this:
$the_challenge_name=$chall
<end for loop>
I know what needs to be done, but I don't know how to code it in the context of a Symfony dynamic.
Can you help a brother out?
Here's the actual code:
{% if profile.participation is not empty and ((profile.usrEngageIsPublic == 1) or profile.usrID == member.usrID) %}
{% for challenge in profile.participation %}
{% if challenge.challenge.campEngageIsPublic or profile.usrID == member.usrID %}
<li>
<div class="collapsible-header">
<ul class="user-team-list team-list list">
<li class="user-team-list-item team-list-item list-item item" style="border: 0;">
<div class="team-body-wrapper list-body-wrapper" style="width: 70%; height: 135px;">
<span class="icon list-icon team-icon">
<img src="{% if challenge.challenge.icon is not empty %}{{ challenge.challenge.icon }}{% else %}/assets/images/icons/gamification/icon_winning.svg{% endif %}" width="75" height="75" class="circle" />
</span>
{% if challenge.challenge.campEndDate > ("now"|date("Y-m-d H:i:s")) %}
<h3 class="team-body-title list-body-title">{{ challenge.challenge.campName|length > 40 ? challenge.challenge.campName|slice(0, 40) ~ '...' : challenge.challenge.campName }} </h3>
{% else %}
<h3 class="team-body-title list-body-title">{{ challenge.challenge.campName|length > 40 ? challenge.challenge.campName|slice(0, 40) ~ '...' : challenge.challenge.campName }} (inactive)</h3>
{% endif %}
<h4 class="team-body-campaign list-campaign"><b>{{ challenge.points|round(0, 'ceil') }} points</b></h4>
<div><i class="fa fa-angle-double-down" style="width: auto; float: none;" aria-hidden="true"></i></div>
</div>
</li>
</ul>
</div>
<div class="collapsible-body">
<ul class="user-activity-list activity-list list">
{% for activity in challenge.participation %}
{% if activity.challenge.campName is not empty and ((activity.challenge.campEngageIsPublic == 1 and activity.type.hrEngageIsPublic == 1) or profile.usrID == member.usrID) %}
<li class="member-activity-list-item activity-list-item list-item item">
<span class="list-icon activity-icon">
<img class="circle" src="{% if activity.challenge.icon is not empty %}{{ activity.challenge.icon }}{% else %}/assets/images/icons/gamification/icon_winning.svg{% endif %}" width="60" height="60" />
</span>
<div class="activity-body-wrapper list-body-wrapper" style="width: 70%;">
{% if activity.challenge.campEndDate > ("now"|date("Y-m-d H:i:s")) %}
<h3 class="activity-body-title list-body-title">{{ activity.challenge.campName }}</h3>
{% else %}
<h3 class="activity-body-title list-body-title">{{ activity.challenge.campName }} (inactive)</h3>
{% endif %}
<h4 class="activity-body-date list-body-date">{{ activity.particDate|date('m/d/Y') }}</h4>
<h4>{{ activity.particValue }} {{ activity.challenge.campParticUnits }} - {{ activity.points|round(0, 'ceil') }} {{ translate('GAMIFICATION_USER_POINTS') }}</h4>
{% if activity.particSrcUser %}
<h4><b>Reported By: {{ activity.particSrcUser }} (admin)</b></h4>
{% endif %}
</div>
{% if activity.challenge.campAllowSelfReporting == 1 and activity.particSrcUser is empty and profile.usrID == member.usrID and not activity.particPreventUsrDelete %}
<div class="buttons pull-right" style="display: inline;">
<a href="/games/user/activity/{{ activity.particID }}/edit" class="btn-floating white-text"><i class="fa fa-pencil"></i></a>
<button type="button" data-href="/games/user/activity/{{ activity.particID }}/delete?ajax=1" data-challenge-id="{{ activity.challenge.campID }}" class="btn-floating danger white-text participation-item-delete"><i class="fa fa-trash"></i></button>
</div>
{% endif %}
<!--
<div class="activity-like-wrapper">
{% if member.usrID != profile.usrID %}
<a href="#" class="activity-like no-async" data-id="{{ activity.particID }}">{{ translate('GAMIFICATION_TEAMS_LIKE') }}</a>
{% endif %}
<span class="activity-likes">{{ activity.likes }}</span>
</div>
-->
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</li>
{% endif %}
{% endfor %}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.