7 years ago
3
Topic

Hi.

I have added extra fields to the standard Joomla "category" type in seblod.

One of these fields is "color" which I want to use as a background color.

In a "List & Search" type which displays the categories, I have defined the item view with an image and a link, all contained in a div.

I need to change the background color of this div.

I have tried putting:

style="background-color: $cck -> getValue('color')"

as a custom attribute, but this does not retreive the color value, as required.

How do I do it?

Get a Book for SEBLOD
1283 Posts
Bucklash
7 years ago
2
Level 1

Hi 

Maybe similar to this

list-format-change-depending-on-the-value#post42922

Did you add that code in the fields config area or did you add it to the fields html (select 2 for Link + Typography)

Ordinarily, in Typography column, you would select html for the appropriate field and add your stuff ie <div class="$cck->getValue('color')"><p>etc... But I don't think you can 'html' a div field. Other fields are fair game.

Maybe, in 'html' on the first field (and is not a Div field) you can add '<div class="$ccck->getValue('color')"><p>etc... and then close it off with an 'END' div field at the end?

Bucklash

7 years ago
1
Level 2

Hi Bucklash,

Brilliant answer, thanks. The html typo works exactly as described (ie not with a div, but with all else I've tested).

One proviso though, for anyone else using this method, you must have the field you are using as part of the Item view - in this case I don't what to display the hex color value, so I've put it in the hidden part of the template. Unless there's a better way to achieve this?

Since you obviously know a lot about this, can you clarify for me - is the html typo the only place I can use $cck? I've tried using it in the template config (class field), the field config, the field markup, all to no avail...

I'm just trying to keep it simple, and avoid using position overrides, as in this case, all I wanted to do was change one color.

Thanks for your input, much appreciated :)

1283 Posts
Bucklash
7 years ago
0
Level 3

Hi 

I answer forum posts when on train etc so have to go by memory but

$cck is in joomla backend in field config ie html etc and position overides

$fields is in template 

Might elloborate with more accurate info later

Seblod recommend the Joomla extension JDump, but I don't use it as I can't work it out.

Get a VIP membership