1. If you update to Joomla 3.8.10, please make sure that you either do a full GitHub update of Fabrik, or disable caching for your lists (in the Advanced settings) or turn off Joomla's System Cache setting. A change in Joomla's cache code in 3.8.10 required a fix in Fabrik, which will be rolled in to the next release, but is currently only available in GitHub.
    Dismiss Notice
  2. We will be performing an update of XenForo (the forum software use on this site) this afternoon, Fri 8/17/2018. The forums will be unavailable for a (hopefully!) short time.
    Dismiss Notice

How to change the color of a list row if the related view count is zero?

Discussion in 'Community' started by xycofryx, Mar 8, 2018.

  1. xycofryx

    xycofryx Member

    Level: Community
    Joomla: 3.8.1
    Fabrik 3.8

    How to change the color of a list row if the "related data count" is zero? [​IMG]
     

    Attached Files:

  2. Sophist

    Sophist Well-Known Member

    Level: Community
    IMO there are two potential ways you could do this.

    1. Using the PHP Events list plugin onLoadData event. The wiki has an example of changing the cell colour - you would need to examine the data to see where the related data count is stored and examine the HTML to see how to add the colour (which I would do by adding a class to the <tr> element and providing some custom CSS). Given that there is an example, this should not be difficult to achieve providing that you have sufficient PHP skills to tweak existing code.

    2. Using Javascript via the Javascript List plugin to examine the HTML after it is loaded in the browser and adding a class as above. Using jQuery or DOM HTML this would not be difficult providing you have the appropriate Javascript / jQuery / HTML / CSS skills to write new code.

    If you need a more detailed steer on how to achieve either of these please ask.
     
  3. xycofryx

    xycofryx Member

    Level: Community
    Sorry for the late update Sophist. Well anyway my solution was to create a custom.js and add this lines. Thanks for the clue.

    $('td:contains("(0)")').closest('tr').css('background-color','#F2DEDE');
     
  4. Sophist

    Sophist Well-Known Member

    Level: Community
    This is a pretty broad selector. You should probably change `td:...` to include some higher level class selectors that identify the specific list.
     
    xycofryx likes this.
  5. xycofryx

    xycofryx Member

    Level: Community
    You mean this:

    $('td a span:contains("(0)")').closest('tr').css('background-color','#F2DEDE');
     
  6. Sophist

    Sophist Well-Known Member

    Level: Community
    Well - somewhere in a higher level div will be your list name as a class. So I meant:
    Code (Text):
    $('.listname td a span:contains("(0)")').closest('tr').css('background-color','#F2DEDE');
    Otherwise ANY list containing (0) will get coloured not just this particular list.
     
    xycofryx likes this.

Share This Page