7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Chance the CSS, if($Author == currentMember)
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 234 Views |
-
Chance the CSS, if($Author == currentMember)

8 January 2012 at 6:11am
Hallo guys,
I have a simple DOM-table at the frontend, where the Author of the entry is shown:
<table class="entries">
<tr id="Entry{$ID}">
<td>$Date.format(d.m.Y)</td>
<td>$Content</td>
<td>$Author.Name</td>
</tr>
</table>Now I want something like this:
if($Author == $currentMember)
{
$('table.entries tr').css('background-color', 'red');
}I really don´t know how I can do this or whether it is possible at all.
Hope somebody can help.I hope this is the right forum for this question, otherwise please replace this post.
-
Re: Chance the CSS, if($Author == currentMember)

9 January 2012 at 7:01pm
I'm pretty sure in the current template engine (2.*) it doesn't support things like Author = CurrentMember. The value must be a static value such as a 'string' or integer.
One way around this is to add a function to your dataobject which returns true if the member is author. That way you keep your logic inside the model.
function IsAuthor() {
$member = Member::currentUserID();return ($member && $member->ID == $this->AuthorID);
..
<tr id="Entry{$ID}" <% if IsAuthor %>class="authored"<% end_if %>>
..
.authored {
background: #f00;
} -
Re: Chance the CSS, if($Author == currentMember)

10 January 2012 at 6:10am
Thanks Willr, this solution works perfect! This is, what I was looking for.
| 234 Views | ||
|
Page:
1
|
Go to Top |


