Add CSS class feature to fields

More
14 years 11 months ago #1337 by dyvel
I would like the ability to style different fields with different css. Example: I have created a select:

Closed::Closed %% Open::Open

Now, I would like the "status" text, to be red when closed is selected, but I can't do that now...

So what I'm asking for, is a way to define a css class for the types, and e.g. on select fields it could be done by another parameter for each item like: Closed::Closed::cssClass %% [NEXT ITEM]

It this something you would consider?

Thanks

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #1354 by vistamedia
Hi and first of all welcome on or forum,
The answer is no for a simple reason, if I do that, it may have effects on existing live sites. That means, many users started to use this syntax (that is far to be perfect) and data are now saved and processed this way.
It always dangerous to change an existing syntax ;)
I will think about that to see if there is another solution. (I have to think about that anyway to allow to render values a list for multiselect)
Cheers,
Emmanuel.

FLEXIcontent lead developer.
www.vistamedia.fr web agency and custom development.
www.joomla.fr co-administrator.
Please no PM for support request, use the forum for that!!!

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #1361 by dyvel
Thanks for your reply.
I understand your concern, but I believe there could be ways to avoid problems with existing sites.

If I understand the current logic correct for select field, it is:

Label :: Value :: Image %% [next item]

Could you not work around the issue with existing sites, by "wrapping" the css or other param in a new "container" like

Label :: Value :: Image :: | cssClass :: Value, param1 :: Value, param2 :: Value | %%

or

Label :: Value :: Image :: [cssClass :: Value, param1 :: Value, param2 :: Value] %%

I believe there could be many ways to work around the "problem" - this i just a suggestion.

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #1363 by vistamedia
I do not say it's not possible :) I say it's dangerous and wont take the risk.
What I'll probaly do is to add a span with an automatical class to each element.
But I do not want to complicate the syntax too much and there are so many prioritary things to do... :(
If you need that for you project, it's quite easy to duplicate a field plugin, rename it and adapt it to your needs.
Emmanuel.

FLEXIcontent lead developer.
www.vistamedia.fr web agency and custom development.
www.joomla.fr co-administrator.
Please no PM for support request, use the forum for that!!!

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #1371 by dyvel
Hi again

I fixed my issue in a simple way.
I added a prefix and suffix to my field like this:

prefix:<span class="cssClass">
suffix:</span>

Then in the file /plugins/flexicontent_fields/select.php around line 212

I replaced the if statement
Code:
if ($values[0] == $listarray[0]) { $display = $pretext . $listarray[1] . $posttext; }

with
Code:
if ($values[0] == $listarray[0]) { // Added by Daniel Duvald $cssClass = $listarray[0]; $pretext = str_replace('cssClass', $cssClass, $pretext); // end $display = $pretext . $listarray[1] . $posttext; }

You can see an example here solar7group.com/aktuelle-projekter.html (the red and green text)

It will use the elements value to create a css class you can style

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #1372 by vistamedia
Tricky solution ;-)
That was this kind of thing I was thinking about. To be sure the value is usable as class you could modify it like that:
Code:
if ($values[0] == $listarray[0]) { // Added by Daniel Duvald $cssClass = JFilterOutput::stringURLSafe($listarray[0]); $pretext = str_replace('cssClass', $cssClass, $pretext); // end $display = $pretext . $listarray[1] . $posttext; }

Of course you don't need it for your own use, but it will ensure that there won't be spaces inside your class.

Thanks for sharing,
Emmanuel.

FLEXIcontent lead developer.
www.vistamedia.fr web agency and custom development.
www.joomla.fr co-administrator.
Please no PM for support request, use the forum for that!!!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.399 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline