This is a request for a core function which does something like this:

show_value_field($field_name, $entity, $value_set, $amount, $display_type, $value_type)

Where:
$field_name = the field name | Required
$entity = entity type (multiple values allowed) | Optional (defaults to show all)
$value_set = set values (1), non set values (2), all values (3) | Optional (defaults to 1)
$amount = show single value (1), specify number of values (2), all values (3) | Optional (defaults to 1)
$display_type = use a (custom) field.tpl.php (1), use plain value (2) | Optional (defaults to 1)
$value_type = plain text (1), int (2), url (3), img (4), etc(?) | Optional (defaults to 1)

I have searched the interwebs, as well as the fields issue cue. Could not find a similar solution or issue in the cue, but may have overlooked something of course. I feel this function could enhance interaction with fields. I would really like to keep the function simple on the user end, to keep it easy for entry level people to use while powerful enough to use in most use cases.

What do other people think?

Comments

Anonymous’s picture

Issue summary: View changes

Revised

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Revised text

Anonymous’s picture

Issue summary: View changes

Text revision

Anonymous’s picture

Issue summary: View changes

Rewrote function

swentel’s picture

Version: 7.x-dev » 8.x-dev
effulgentsia’s picture

Can you give some example use cases of calling this function for different field types with different values for each of the parameters? Also, who do you envision as the primary audience for this function (someone editing a template, someone writing a preprocess function, someone else)?

Anonymous’s picture

Primary adience:
At a theme level, but when I think about your question. I see it could possibly come in handy for some modules as well.

Example cases:

1. I want to print the plain text of a field value, to further process this, for example make sure all the first letters are capitalized, or to transform the value e.g. date notation.
2. I want a dynamic call in the theme where I load the url of a picture, and an img tag with custom markup, while filling the title with info from a different field.
3. I have multipe values in a field, and want to show them easily, as a menu with links.
4. I want to quickly add or change a field.tpl.php for a field.
5. I want to use the field for conditional statements, based on multiple values, to make a choice whether to show a block or view in a template.

Basically, I want the feeling that if I have field, I can do everything that I run into on a regular basis, without having to worry about a bunch of complicated code in template.php.

Hope I have been able to clarify a bit more. Please feel free to post further comments or suggestions on this.

Anonymous’s picture

Issue summary: View changes

Text revision

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ghost of drupal past’s picture

Issue summary: View changes
Status: Active » Closed (outdated)