Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Checking variables of a chlid

$
0
0

Hello,

I am trying to achieve few things. I have a TeamHolder Page and then children of TeamHolder are TeamPlayer. I would like to write a method in TeamHolder that is going to check if TeamPlayer has a facebook field filled out, if it does it will display the facebook icon.

Here is what I have:

<ul id="team-list">
<% loop $Children %>
<li>
<div class="player">
<div class="player-left">
<div class="player-image">
<a href="$Link"><img src="$PlayerPhoto.Link" alt="/" /></a>
</div>
<div class="player-social">
<% if MySocialClass() %>
<ul class="social4">
<% else %>
<ul class="social1">
<% end_if %>
<% if $Facebook %>
<li><a title="Facebook" href="$Facebook" target="_blank">Facebook</a></li>
<% else %>
<li></li>
<% end_if %>
</ul>
</div>
</div>
</div>
</li>
<% end_loop %>
</ul>

In my TeamHolder.php I have

class TeamHolder_Controller extends Page_Controller{
public function MySocialClass(){
return "social4";
}
}

For some reason my ul has class of social1 instead of social4 and I can't figure out why.

The second portion to this problem is, how would I check in MySocialClass() if the child I am currently on has facebook filled out?

I am guessing that I have to pass the child through parameters somehow and then check the $Facebook value, but how do I do this in silverstripe?


Posted to: Checking variables of a chlid | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles