I can only add fields to data sources, not to views.
I have the situation that a composition of fields (for display) depends on some other field value.
This is not a data issue, just a display (view) issue. So i don't want this persisting in my database.
I found a way that's
almost what i want. I'll illustrate by means of an example.
My data source has a field "Color", which is a group field. Values are:
In the "Content prepare" section i have added:
switch ($items["Color"]["value"])
{ case 1: $color = 'Red'; break;
case 2: $color = 'Green'; break;
case 3: $color = 'Blue';
}
$coloritem = array("label"=>"ColorTekst", "id"=>"474001", "value"=>$color);
$items["ColorText"] = $coloritem;
(It needs to have an ID, to not be skipped entirely.
Now i can use "{ColorText:value}" in my template without actually having a colortext field, which was the initial goal.
Why almost?
In the contentbuiler.php code the "Content prepare" is processed at a point where the {hide} tags no longer work. Maybe that's something Crosstec can fix some time.
A good alternative is to test before adding the field, but that would still not enable multiple {hide-if-matches} with different values to test. I don't think that would bother many.
Hope this helps.