Need assistance...wanting to modify Chris' greyHiddenRecords to redSoldRecords

6 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 18, 2017   (RSS)

By ross - January 31, 2017

Hi equinox

Thanks for posting.

This will be a conversation we can have through consulting.

You can email me via consulting@interactivetools.com to continue it there.

In the meantime, let's leave the thread going though and see if anyone in the community has any suggestions.

Thanks.

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By wizzle - July 15, 2017 - edited: July 15, 2017

Any luck equinox?

I found myself trying to do the same thing.  What I realized is that both the greyHiddenRecords and and redSoldRecords plugins where altering the same Core Plugin Hook called listRow_trStyle

What it seems like to me is that with the updated plugin, you can now add additonal conditions such as 

$GLOBALS['greyRecordFieldNamesToOptions']['date'] = [
                                            'value'      => date("Y-m-d H:i:s"), // date today
                                            'comparator' => '<', // compare if this is a date in the past
                                            'tableName'  => 'sample_table', // grey-out the record only on this table/section list page
                                          ];

but there is not a separate text formatting for those conditions.  Basically any record meeting any of the conditions will change the listRow_trStyle to the same thing.

Looking at the file   /cmsb/lib/menus/default/list_functions.php you will see this at line 139

 $trStyle = applyFilters('listRow_trStyle', '', $tableName, $record);

and then this just a few lines down

print "<tr class='$trClass' style='$trStyle'>\n";
displayListColumns($listFields, $record, $options);
print "</tr>\n";

So it would appear that there is a single listRow_trSyle hook that is Global and both of your plugins were modifying it.  I suppose whichever plugin is processed 2nd wins.

Greg Williams

By Dave - July 18, 2017

Hi Guys, 

I'd recommend just making a custom plugin for what you want to do.  This is one of those cases where the pre-made plugin doesn't really make it much simpler than the custom code.  Here's some custom plugin code for setting the text color:

addFilter('listRow_trStyle', 'v203_highlightAdminUsers', null, 3);

// admin record lists: update style of <tr> rows
function v203_highlightAdminUsers($trStyle, $tableName, $record) {

  // accounts: add style to <tr> rows if record has 'isAdmin' checked
  if ($tableName == 'accounts' && $record['isAdmin']) {
    $trStyle = "color: red;";
  }

  return $trStyle;
}

You just want an if, elseif chain so that you can control which one goes first.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Codee - July 18, 2017

Hi Wizzle,

Not until the next post by Dave. ;-)

By Codee - July 18, 2017

Hi Dave,

Thank you for providing that info and also for the explanation and insight so I could learn better.

Cheers!