Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Chance the CSS, if($Author == currentMember)

Go to End

3 Posts   718 Views


Community Member, 96 Posts

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}">

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.


Forum Moderator, 5523 Posts

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;


Community Member, 96 Posts

10 January 2012 at 6:10am

Thanks Willr, this solution works perfect! This is, what I was looking for.