• Resolved PBenz

    (@pbenz)


    Hello,

    I’ve implemented a custom Upcoming Events section on the home page of my website (https://suncoastpca.org/), and I’ve added a color-coded icon to each event in the list that corresponds to the color of the event’s category. Unfortunately, to meet a deadline, I’ve hard-coded the colors into my stylesheet, and I’d like to eventually replace this with code that can determine the appropriate color programmatically. I know this is technically possible, but I’m not sure how. Is there any code within the plugin itself that I could use as a reference? It’s probably right in front of me and I’m just missing it.

    https://www.ads-software.com/plugins/the-events-calendar-category-colors/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Andy Fragen

    (@afragen)

    Have you tried checking the setting to colorize widgets? It won’t add color to the date but will colorize the event title.

    Thread Starter PBenz

    (@pbenz)

    Yep – tried that, but it didn’t work on the home page (although it does work on the widget itself). To be honest, I’d much rather have the colored icons like I have now.

    I understand that retrieving the category color is probably non-trivial, but I’m not afraid to get my hands dirty. I see where the data is stored in the database but I’m just not sure how to get at it. (In fact I could be going about this all wrong – I’m not quite sure how you’re implementing the colored widgets but it almost looks as if you’re generating a stylesheet on the fly.)

    Plugin Author Andy Fragen

    (@afragen)

    The plugin doesn’t color the date as you currently have it because there’s no clear concept of how to handle multiple event days. Also, the color belongs to the event and not the date.

    It doe not appear that you have widget coloring set in prefs as the home page event listing is from the widget.

    Yes, CSS for everything is generated on the fly.

    Thread Starter PBenz

    (@pbenz)

    I fully understand that the color belongs to the event – in fact I was hoping there was some function to retrieve the color for a given event. But this is the wrong way to think about it as you’ve pointed out.

    I also know that I do not have widget coloring set in the prefs. I tried that and have since disabled it since I’m using the original widget elsewhere on the website and I do not wish the colors to appear there.

    So it sounds like the key to this is to get that CSS generated for the home page, and then make my custom widget template work with those styles. That’s very helpful, thank you!

    Plugin Author Andy Fragen

    (@afragen)

    I’m not understanding, you do have the events list widget enabled on the home page.

    Plugin Author Andy Fragen

    (@afragen)

    Sorry the widget coloring is all or none.

    The problem with what you’re thinking about is that the CSS doesn’t show on the home page unless it’s coloring an element on that page.

    Thread Starter PBenz

    (@pbenz)

    The home page is using a custom widget template and some custom code in my home.php. (Bear with me – I pulled that code from somewhere but I can’t remember where, and it’s probably outdated. I created it before you had the option to colorize widgets, I think).

    No worries – I’ll figure out how to do this. Thanks very much for your help, Andy.

    Plugin Author Andy Fragen

    (@afragen)

    Sorry I couldn’t be of more help. If you have any other thoughts or questions let me know.

    Thread Starter PBenz

    (@pbenz)

    No you were very helpful – you pointed me in the right direction. ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Retrieving category color for the current event’ is closed to new replies.