ux field – Looking for better alternatives to ‘sort by ascending/descending’

I’m currently updating the sorting options for a list of items. At the moment each option can be selected as descending or ascending which really doesn’t mean anything in most cases (or is very unclear) e.g. organise by popularity (asc) or popularity (desc). Is that most popular first or last? Who knows.

This is the list in question:

enter image description here

If you look at it for long enough you can probably figure out what each option does, or else you have to just try them all out until you find one that you’re after.

My suggestion what be something more like:

Sort by

Popularity (most popular first) or
Popularity (least popular first)

Rating (highest first) or
Rating (lowest first)

But this makes the line items very long. Would it be unconventional just to write the phrase e.g.

Sort by

Most popular first or
Least popular first

Highest rated first or
Lowest rated first

Are there better options, is there some best practice that I could follow? I’ve found a real mixed bag of implementations across the web and they’re often no better.

7 – REST API and Multi value date field

I have a React native front end with D7 backend. I am populating a content type that has a multi-value Date field. I am successfully creating the content-type with all other fields except the Date field. The format I am sending via POST looks like :

"field__delivery_dates": {
        "und": [
                "value": "2020-07-23"
                "value": "2020-08-05"
                "value": "2020-08-07"

The problem is when I sent the multiple date field values it’s getting submitting but the values are not reflected in drupal.

Anyone, please help me to find out a solution for sending a multi-field date field to drupal 7

theming – How do I add CSS classes to an image field?

My goal: I’m learning drupal. I’m creating bootstrap carousel myself. Without any plugins or themes. I use default classy theme.

So far what I have done.

  1. Administration -> Configuration -> Media :: Added new image with 1000×800 with scale and crop.
  2. Administration -> Structure -> Content types :: Added new content, Has two fields banner(image) and title(text).
  3. Administration -> Structure -> Views :: I created a new view.
  4. Added this view to my template block

My Over ride:
File one: views-view-list–home-banner.html.twig

<div id="fzCarousel" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
        {% for row in rows %}
            <li data-target="#fzCarousel" data-slide-to="{{ loop.index0 }}" class="{{ loop.first ? 'active' }}"></li>
            {% endfor %}
    <div class="carousel-inner">
        {% for row in rows %}
            <div{{ row.attributes.addClass( loop.first ? 'active' ) }}>
                {{- row.content -}}
        {% endfor %}
    <a class="carousel-control-prev" href="#fzCarousel" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    <a class="carousel-control-next" href="#fzCarousel" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>

and File two: views-view-fields–home-banner.html.twig

{{ fields.field_banner_images.content }}

<div class="carousel-caption">
    {{ fields.field_banner_text.content }}

HINT 1: I checked Administration -> Structure -> Views many times, I can’t find any place to add css to img. Some places it adds to parent div, not for img tag.

HINT 2: This works good. The bootstrap carousel is running good. BUT

I’m not getting the exact html code what I wanted. < img > tag has different css. I can’t add css to img field. Need help.

What I wanted: I need to add css to img field in twig template code {{ fields.field_banner_images.content }} . So that In future, I can apply for other works. Not in .theme file.

I tried .theme file code too (Just for now), but it dose’nt worked for me. I don’t know what I have done wrong there.

function mhe_preprocess_field(&$vars) {
  if ($vars('element')('#field_name') == 'field_banner_images') {
    foreach($vars('items') as $key => $item){
      $vars('items')( $key )('content')('#item_attributes')('class')() = 'my_class';

electrum – trying to get text of a field in json rpc 2.0 response into ar PHP variable

I use json_decode to vardump a return which yields

array(3) { (“jsonrpc”)=> string(3) “2.0” (“result”)=> array(13) { (“status”)=> string(7) “Pending” (“amount (BTC)”)=> string(10) “0.05130899” (“index_url”)=> . . . . (more fields here) . . . (“address”)=> string(34) “1GHHojoC4Ai1SPMN3YoNzemLNaaj2XFHKc”

I am trying to fill a variable with the text from the “address” field and I tried

$result = json_decode($response, true);
$address = $result->address;

but a varbump of $addrwss is NULL

any other variant like $result->”address” or $result->(“address”) is improper syntax

Can someone tell me how to get at the text of the address field of a JSON PRC 2.0 response to put it in a variable in PHP

8 – Print rendered field in views-view.html.twig

I try to render a custom node field in a views-view.html.twig and it works, the only thing is that i get the machine name and not the formatted name. Please can somebody describe me what i am doing wrong?

I have tried several ways like:

{{ view.field.field_my_field.value(view.result(0)) | render }}


{{ view.field.field_my_field.value(view.result(0)) }}

Thanks for helping!

How do you map a Salesforce master detail field to a field in Drupal? I’ve tested all fields none work

I have successfully mapped all fields except company name which is a master-detail field in Salesforce. This field is required to make a record in salesforce. What field would be used to map to this type of data? Thank you

8 – How can I get translation for a field of custom date

I am using the paragraphs module. I have a field which contains a date and time e.g. for events, which is added by an author. For the output I use a paragraph-twig-file and I have this:

<div class="timeline-date">
    {{ content.field_date }}

In the backend of Drupal I created a custom time “D, d.m.Y – H:i”. The output is right e.g. “Fri, 24.08.2018 – 17:14”, but my site is in german and not english. So how, can I translate the day of week in german?
In my case this solution is not working

forms – How do you add a input and a select field with webforms?

I would like to add a select element that has an input field attached, so the user can input a value from the list without having to scroll through hundreds of options. Is this possible to do with the module webforms? I have researched it and the only thing I can find is the chosen module but I have no idea how the two integrate, and alot of people say it is incompatible in some browsers. Thank you for your help.

field of view – FOV of One Plus 6T?

I was wondering what the Field of View is for the rear Camera is for the One Plus 6T.

The information I’ve been able to gather so far.

4.25mm focal length (25mm equivalent)
fixed lens eq to 35/50mm in full frame
However I can’t figure it out for certain.


The phone has a 1/2.6” sensor size So I should be able to calculate it using a simple formula but I can’t seem to figure it out

Thanks to anyone who can help.

custom field – Multiple Select on Gutenberg Sidebar as metakey

I want to show a multiple select element in the sidebar when editing a page in admin, where I can save the selected values in a metakey. Of course also load the selected values upon load of page-edit in admin.

I manage to show the list, but I don’t know how to save it i WP.


function register_metakey_ac() {
        plugins_url( 'plugin-sidebar.js', __FILE__ ),
        plugins_url( 'plugin-sidebar.css', __FILE__ )

    $custom_fields = (

    foreach ( $custom_fields as $custom_field ) {
        register_post_meta( 'page', $custom_field, (
            'show_in_rest'      => FALSE,
            'type'              => 'array',
            'single'            => TRUE,
            'auth_callback'     => function () {
                return current_user_can( 'edit_posts' );
        ) );
add_action( 'init', 'register_metakey_ac' );


( function( wp ) {
  var registerPlugin = wp.plugins.registerPlugin;
  var PluginSidebar = wp.editPost.PluginSidebar;
  var SelectControl = wp.components.SelectControl;
  var el = wp.element.createElement;
  var withSelect = wp.data.withSelect;
  var withDispatch = wp.data.withDispatch;

  const { isResolving } = wp.data.select( 'core/data' );

  var MetaSelectControl = wp.compose.compose(
    withDispatch( function( dispatch, props ) {
      return {
        setMetaValue: function( metaValue ) {
          dispatch( 'core/editor' ).editPost(
            { meta: { ( props.metaKey ): metaValue } }
      function( select, props ) {
        const query = { per_page: 99 };

        return {
          metaValue: select( 'core/editor' ).getEditedPostAttribute( 'meta' )( props.metaKey ),
          users: wp.data.select( 'core' ).getEntityRecords( 'root', 'user', query ),
          isRequesting: isResolving( 'core', 'getEntityRecords', ( 'root', 'user', query ) )
  ( function( props ) {
    if ( props.isRequesting ) { // "loading" indicator
      return el( 'div', null, 'Loading data..' );
    var theOptions = ();

    const list = props.users.map( user => {
      let rolesArr = user.roles;
      for (var i = 0; i < rolesArr.length; i++) {
        let singleRole = user.roles(i);
        if (singleRole == "specialrole") {
          theOptions.push({label: user.name, value: user.id})
    } );

    return el( SelectControl, {
      label: 'Access Control',
      multiple: true,
      options: theOptions,
      onChange: ( value ) => {
        props.setMetaValue( value );
      value: props.metaValue

  registerPlugin( 'themeta-sidebar', {
    render: function() {
      return el( PluginSidebar,
          name: 'themeta-sidebar',
          icon: 'admin-post',
          title: 'Meta AC Example',

        el( 'div',
          { className: 'plugin-sidebar-content' },
          el( MetaSelectControl )

} )( window.wp );

enter image description here

I am new to all this Gutenberg React Components thing. I think the learning curve is very steep for beginners, and documentation with examples is close to none. I have found 0 examples using a type=’array’ in a register_post_meta function. Please help anyone.