fbpx
Welcome, Guest
Username: Password: Remember me

TOPIC: How can I add styling to list items?

How can I add styling to list items? 10 months 3 weeks ago #25474

  • hakana
  • hakana's Avatar
  • Offline
  • Junior Member
  • Posts: 27
  • Thank you received: 1
  • Karma: 0
Hello Chetan and Akash,

I want to add a styling to listbox items like this:
From this to:
<option value="VALUE">TEXT</option>

This:
<option value="VALUE" style="color:gray" >TEXT</option>

In the helper file the code is like this:
$array[] = ['text' => $option, 'value' => $option];

I want to make it work like this:
$array[] = ['text' => $option, 'value' => $option, 'style' => $option];

Please tell me which code should I modify on which file to render styling like above.
Last Edit: 10 months 3 weeks ago by hakana.
The administrator has disabled public write access.

How can I add styling to list items? 10 months 3 weeks ago #25495

  • akash
  • akash's Avatar
  • Offline
  • Moderator
  • Posts: 202
  • Thank you received: 27
  • Karma: 2
Hi Hakana,

To implement this, you need to change two files:

1. Helper.php

On line no. 38, change this
$array[] = ['text' => $option, 'value' => $option];

to this,
$array[] = [ 'text' => $option, 'value' => $option, 'style' => 'color: red; font-size: 23px;' ];

2. List.php in Layouts/fields
<option value="<?php echo $option['value']; ?>"><?php echo $option['text']; ?></option>

to this,
<option style="<?php echo $option['style']; ?>" value="<?php echo $option['value']; ?>"><?php echo $option['text']; ?></option>

It'll change the styling accordingly, let me know how it goes.

Thanks.
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.
Moderators: akash, chandandeep
Time to create page: 0.294 seconds
Cron Job Starts