8 – Custom content entity packages: how to override class methods?

In the code, you can only cancel globally, but each instance of the feature class would be for a specific package, this is the only mandatory field when you create a content entity with packages, so the package is always set and you can add a condition a The voided method.

For example, if you had a getTitle () method, you could modify the title of a specific package:

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    if ($this->bundle() == 'foo') {
      return 'bar';
    }

    return parent::getTitle();
  }

Coding or design of website or homepage or simply some custom code functionality for $ 20

Here I work as a software developer and anyone needs help or any project done in a short time with professional level work, contact me

by: Joshi0505
Created: –
Category: Programming
Viewed: 71


.

types of custom posts: problem removing columns from administration table

I am trying to remove the thumbnails from the columns and they appear in an administration table. At the same time, I am adding an additional column. The type of publication is property. I would like to do it through the code instead of using the add-on, since I would need to make some additional customizations.

None of the hooks I tried seem to work.
manage_property_posts_columns
manage_posts_columns
manage_property_posts_custom_column

The interesting thing is that the same code works on different types of publications.

What could be the problem?

add_filter( 'manage_property_posts_columns', 'remove_property_columns' );

function remove_property_columns( $columns ) {
    unset($columns('thumbnail'));
    unset($columns('featured'));
    $columns('test') =  'Test' ;
    return $columns;
}

categories: display custom field data on a specific category page

I created custom fields on my functions.php page and use the values ​​of these fields on a template parts page (for activities). This works well. I would like to have a page for each category that shows all the activities for that category. I successfully loaded my template into category.php, which shows my HTML template on the homepage / category / category-name.

However, when I try to load the values ​​of the same custom fields that I use on my general activities page (in template parts), this does not work. I did some tests, I printed the category ID to make sure I am on the right page. Print all the HTML well but only the values ​​of the custom fields are missing.

PHP on the category.php page

            $categories = get_the_category();
            $id = $categories(0)->cat_ID;
            $cat_id = get_query_var('cat');

            $category_id = get_cat_ID('Seasonal Events');
            //print($category_id);
            //print($cat_id);
    if($category_id == $cat_id){    
             $value_title = get_post_meta($post -> ID, '_activities_title', true);
             $value_description = get_post_meta($post -> ID, '_activities_description', true);

             print($value_title);
             print($value_description);


        }

The category ID with which I am testing (which has multiple posts) is 3 and $ category_id and $ cat_id return 3 as well.

Any help would be greatly appreciated, I have been trying to find a solution for a while, but I am stuck in this!

Thanks in advance. 🙂

entities – How to get all the values ​​of a particular custom field of a user entity using EnitityQuery?

I have added a custom field to the user's entity called "customer_no".

In the user registration form, I want to verify if customer_no already exists.

For that, now I want to retrieve all user values ​​from customer_no.

I tried the following code but it doesn't work:

if(isset($cust_no)) {
    $ids = Drupal::entityQuery('user')
      ->condition('field_customer_number_reseller_i','','<>')
      ->execute();
    $users = User::loadMultiple($ids);
    print_r($users); exit;
  }

Please help me here.

Types of custom posts: trying to make the "title" show

In WordPress you can echo or easily display the title or name of a category like this:


However, I have noticed that it is NOT shown when I am in a Custom Publication Type. I am using a popular add-on called "Custom Publication Type UI"

Is anyone familiar with how to address this, that is, how the "category name" of the type of personalized publication is displayed?

Thank you

google sheets – Autocomplete cells with custom script – impose call suspension

I have a custom script that calculates the distance between two directions. The script uses the Google Maps API call. I have my addresses in one column (approximately 4000 addresses), the other address is fixed. If I abuse the API calls and fill all 4000 cells, the API crashes for 24 hours. Is there a way to impose a suspension call between subsequent cell fills?
I got the web script, here it is:

/**
* Get Distance between 2 different addresses.
* @param start_address Address as string Ex. "300 N LaSalles St, Chicago, IL"
* @param end_address Address as string Ex. "900 N LaSalles St, Chicago, IL"
* @param return_type Return type as string Ex. "miles" or "kilometers" or "minutes" or "hours"
* @customfunction
*/   
function GOOGLEMAPS(start_address,end_address,return_type) {
    // https://www.chicagocomputerclasses.com/   // Nov 2017   // improvements needed
     var mapObj = Maps.newDirectionFinder();   mapObj.setOrigin(start_address);   mapObj.setDestination(end_address); var directions = mapObj.getDirections();
     var getTheLeg = directions("routes")(0)("legs")(0);
     var meters = getTheLeg("distance")("value");
     switch(return_type){
    case "miles":
      return meters * 0.000621371;
      break;
    case "minutes":
        // get duration in seconds
        var duration = getTheLeg("duration")("value");
        //convert to minutes and return
        return duration / 60;
      break;
    case "hours":
        // get duration in seconds
        var duration = getTheLeg("duration")("value");
        //convert to hours and return
        return duration / 60 / 60;
      break;      
    case "kilometers":
      return meters / 1000;
      break;
    default:
      return "Error: Wrong Unit Type";    }    }

flow – Custom forms solution for SharePoint Online

Battery exchange network

The Stack Exchange network consists of 175 question and answer communities, including Stack Overflow, the largest and most reliable online community for developers to learn, share their knowledge and develop their careers.

Visit Stack Exchange