Skip to main content
edited title
Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

Node Display different icons depending on field identificationvalue

deleted 57 characters in body; edited title
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

Drupal 8 node Node field identification

I am (perhaps incorrectly, is there a better way?!) trying to produce a result that requires phpPHP code to evaluate whether a Drupal 8 node field is a "x", an "f", a "m", a "h", or an "l".

Thanks to some help on an earlier question, I've accomplished my task (to replace the value with a useful icon) when the value is binary: ifif it exists, show this. IfIf it's empty, show nothing. I'veI've done this via CSS.

Now I'd like to extract the actual value of the node field (I hope I'm explaining this right), and display different icons based on its value.

I am not planning to do this via a function, but rather by code on the node itself. Is there some syntax I can use within the php that will extract this? So that I can have the equivalent of:

$price = $node[field][value];

$price = $node[field][value];

then I'd do:

if $price = "m" {use icon X} else if $price = "h" {use icon Y};

if ($price == "m") { // use icon X }
else if ($price == "h") { // use icon Y };

Thank you for any and all help/suggestions!

Drupal 8 node field identification

I am (perhaps incorrectly, is there a better way?!) trying to produce a result that requires php code to evaluate whether a Drupal 8 node field is a "x", an "f", a "m", a "h", or an "l".

Thanks to some help on an earlier question, I've accomplished my task (to replace the value with a useful icon) when the value is binary: if it exists, show this. If it's empty, show nothing. I've done this via CSS.

Now I'd like to extract the actual value of the node field (I hope I'm explaining this right), and display different icons based on its value.

I am not planning to do this via a function, but rather by code on the node itself. Is there some syntax I can use within the php that will extract this? So that I can have the equivalent of:

$price = $node[field][value];

then I'd do:

if $price = "m" {use icon X} else if $price = "h" {use icon Y};

Thank you for any and all help/suggestions!

Node field identification

I am trying to produce a result that requires PHP code to evaluate whether a Drupal 8 node field is a "x", an "f", a "m", a "h", or an "l".

Thanks to some help on an earlier question, I've accomplished my task (to replace the value with a useful icon) when the value is binary: if it exists, show this. If it's empty, show nothing. I've done this via CSS.

Now I'd like to extract the actual value of the node field, and display different icons based on its value.

I am not planning to do this via a function, but rather by code on the node itself. Is there some syntax I can use within the php that will extract this? So that I can have the equivalent of:

$price = $node[field][value];

then I'd do:

if ($price == "m") { // use icon X }
else if ($price == "h") { // use icon Y };

Thank you for any and all help/suggestions!

Source Link

Drupal 8 node field identification

I am (perhaps incorrectly, is there a better way?!) trying to produce a result that requires php code to evaluate whether a Drupal 8 node field is a "x", an "f", a "m", a "h", or an "l".

Thanks to some help on an earlier question, I've accomplished my task (to replace the value with a useful icon) when the value is binary: if it exists, show this. If it's empty, show nothing. I've done this via CSS.

Now I'd like to extract the actual value of the node field (I hope I'm explaining this right), and display different icons based on its value.

I am not planning to do this via a function, but rather by code on the node itself. Is there some syntax I can use within the php that will extract this? So that I can have the equivalent of:

$price = $node[field][value];

then I'd do:

if $price = "m" {use icon X} else if $price = "h" {use icon Y};

Thank you for any and all help/suggestions!