views – Change booking end-date in iCal Feeds import

I have an D9 site for a villa that can be rented. To show availability, I import the iCal calendar of bookings from a booking site, using the Feeds and Feeds iCal modules (the last one I updated the .info so it works in D9).

The import works fine, it collects the .ics file at regular intervals, turns each into a node, and I display all booking-nodes through Fullcalendar View. So far brilliant.

The bookings are displayed technically correct, from 00:00 midnight at the start of the first booked day until 00:00 at the end of the last booked day.

However, as this concerns overnight bookings, people are allowed to stay until the next morning, in availability calendars usually shown by a ‘triangle’ covering half that day.

Is there any way to change the end date given in the iCal file to the next day, on import (a module or hook or rule), or maybe in views where the fullcalendar is created from the booking nodes? All advice would be very much appreciated!

Xander

Notes: Drupal used to have an availability calendar which did this perfectly, but that wasn’t ported to D8 nor 9. Similarly the rooms module is not compatible, and the vastly complicated BAT project can’t be fully used in D9. I also looked at the Feeds Tamper module but that doesn’t seem to allow changes to the dates imported.

How do you display social media feeds in a unified design?

Our designer has asked us to create a section for the home page that will display the Twitter, Facebook, and Instagram feeds side-by-side. From her design and the discussions that followed, she would like the feed displays to all look similar. She brought up Smash Balloon for WordPress. One, we’re on Drupal and not on WordPress and that does not exist for Drupal. Two, it’s a paid plugin so I can’t even see what it’s doing. Three, if it’s at all like ShareThis that ends up gathering data from end users, we can’t do that. Am I purely looking at creating a custom solution with the providers’ APIs or is there an existing Drupal solution? This is the requested design: enter image description here

9 – Specify the theme when creating content / importing content via Feeds

I want to force all content to be created using my primary site theme. I want to do this because I am using a renderer in MYMODULE_node_presave() like this:

function MYMODULE_node_presave(NodeInterface $node) {
  $renderer = Drupal::service('renderer');

  $content_type = $node->getType();
  if ($content_type == 'page') {
    $viewmode_render = $node->get('field_text_main_to_render')
      ->view('rendered_output');
    $processed_display = $renderer->renderPlain($viewmode_render);
    $node->set('field_text_main_display', "$processed_display");
    $node->field_text_main_display->format = 'processed';
}

My site uses Bartik as the main theme and Seven as the admin theme.

Under Appearance settings (/admin/appearance), I have checked the preference Use the administration theme when editing or creating content. This ensures that nodes are rendered in Bartik upon creation in the UI.

However, when I resave nodes on /admin/content, the nodes are re-saved with Seven, instead of Bartik. So I added a ThemeNegotiator:

/**
 * Select the correct theme for various routes.
 */
class ThemeNegotiator implements ThemeNegotiatorInterface {

  /**
   * {@inheritDoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return $this->negotiateRoute($route_match) ? TRUE : FALSE;
  }

  /**
   * {@inheritDoc}
   */
  public function determineActiveTheme(RouteMatchInterface $route_match) {
    return $this->negotiateRoute($route_match) ?: NULL;
  }

  /**
   * Select the theme for special cases.
   *
   * @param DrupalCoreRoutingRouteMatchInterface $route_match
   *   The currently matched route.
   *
   * @return bool|string
   *   The theme name to use (string) or false (bool).
   */
  private function negotiateRoute(RouteMatchInterface $route_match) {
    $route_name = $route_match->getRouteName();
    // Admin content page must use node render theme.
    // Why: "Save content" action will use the theme of this page.
    if ($route_name === 'system.admin_content') {
      return 'bartik';
    }
    else {
      return FALSE;
    }
  }

}

Now, when I run a bulk node resave on /admin/content, nodes are rendered correctly with Bartik.

Next, I installed the Feeds module. Now, when I import nodes via CSV using Feeds, they are rendered using Seven, not Bartik. I want to force these nodes to also be rendered using Bartik, but I don’t know how to do that. (For example, if there was a way to use negotiateRoute in the ThemeNegotiator, that would be fine, but I don’t know how to set that up.) Any ideas?

Feeds event subscriber stopped working

For some reason my feeds event subscribers have just stopped working.

My code looks like this, the dpm for debugging never gets fired so I think the function isn’t being run.

I can’t work out what’s changed.


namespace Drupalpartshub_feeds_modificationsEventSubscriber;

use DrupalfeedsEventEntityEvent;
use DrupalfeedsEventFeedsEvents;
use SymfonyComponentEventDispatcherEventSubscriberInterface;

/**
 * Reacts to feeds events to modify feed properties.
 */
class FeedsSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events = ();
    $events(FeedsEvents::PROCESS_ENTITY_PRESAVE)() = 'presave';
    $events(FeedsEvents::PROCESS_ENTITY_POSTSAVE)() = 'postsave';

    return $events;
  }

  /**
   * Acts on presaving an entity.
   *
   * @param DrupalfeedsEventEntityEvent $event
   *   The feed event.
   */
  public function presave(EntityEvent $event) {
    dpm($event);
    // Get the feed object.
    $feed = $event->getFeed();
    // Get the entity being operated on.
    if ($feed->type->entity->id() === 'parts') {
      $entity = $event->getEntity();
      // Get the unchanged entity.
      $unchanged_entity = Drupal::entityTypeManager()
        ->getStorage('node')
        ->loadUnchanged($entity->id());
      // Check if the entity is new.
      if (!$entity->isNew()) {
        // Only if part is not new check values.
        if ($feed->type->entity->label() === 'Parts') {
          if ($entity->get('title')->value === 'empty') {
            $entity->get('title')->value = $unchanged_entity->get('title')->value;
          }

          // Part fitment/makes field.
          if ($entity->get('field_make')->isEmpty()) {
            $makes = $unchanged_entity->get('field_make')->referencedEntities();
            foreach ($makes as $index => $term) {
              $tid = $term->id();
              if ($index == 0) {
                $entity->set('field_make', $tid);
              }
              else {
                $entity->get('field_make')->appendItem((
                  'target_id' => $tid,
                ));
              }
            }
          }


          // Part group code.
          if ($entity->get('field_group_code')->isEmpty()) {
            $codes = $unchanged_entity->get('field_group_code')
              ->referencedEntities();
            foreach ($codes as $index => $code) {
              $code_id = $code->id();
              if ($index == 0) {
                $entity->set('field_group_code', $code_id);
              }
              else {
                $entity->get('field_group_code')->appendItem((
                  'target_id' => $code_id,
                ));
              }
            }
          }

          // Cross references.
          if ($entity->get('field_cross_references')->isEmpty()) {
            $references = $unchanged_entity->get('field_cross_references')
              ->referencedEntities();
            foreach ($references as $index => $reference) {
              $reference_id = $reference->id();
              if ($index == 0) {
                $entity->set('field_cross_references', $reference_id);
              }
              else {
                $entity->get('field_cross_references')->appendItem((
                  'target_id' => $reference_id,
                ));
              }
            }
          }
        }
        elseif ($feed->type->entity->label() === 'Physical attributes') {
          if ($entity->get('title')->value === 'empty') {
            $entity->get('title')->value = $unchanged_entity->get('title')->value;
          }
          // Part weight.
          if ($entity->get('field_weight')->isEmpty()) {
            $entity->get('field_weight')->value = $unchanged_entity->get('field_weight')->value;
          }
          // Part Height.
          if ($entity->get('field_height')->isEmpty()) {
            $entity->get('field_height')->value = $unchanged_entity->get('field_height')->value;
          }
          // Part Width.
          if ($entity->get('field_width')->isEmpty()) {
            $entity->get('field_width')->value = $unchanged_entity->get('field_width')->value;
          }
          // Part Depth.
          if ($entity->get('field_depth')->isEmpty()) {
            $entity->get('field_depth')->value = $unchanged_entity->get('field_depth')->value;
          }
        }
      }
    }
  }

  /**
   * Acts on presaving an entity.
   *
   * @param DrupalfeedsEventEntityEvent $event
   *   The feed event.
   */
  public function postsave(EntityEvent $event) {
    $feed = $event->getFeed();
    $feeds = ('oe_references', 'sub_components', 'dimensions');
    $id = $feed->type->entity->id();
    if (in_array($id, $feeds)) {
      $entity = $event->getEntity();
      $parent_field_name = $entity->parent_field_name->value;
      $parent_id = $entity->parent_id->value;
      $vid = Drupal::entityTypeManager()->getStorage('node')->getLatestRevisionId($parent_id);
      $part = Drupal::entityTypeManager()->getStorage('node')->loadRevision($vid);
      $paragraph_references = $part->get($parent_field_name)->referencedEntities();
      $paragraph_references_id = ();
      if ($paragraph_references) {
        foreach ($paragraph_references as $paragraph_reference) {
          $paragraph_references_id() = $paragraph_reference->id();
        }
      }
      if (!in_array($entity->id(), $paragraph_references_id)) {
        $fields = (
          'field_oe_references', 'field_sub_components_', 'field_dimensions'
        );
        if (in_array($parent_field_name, $fields)) {
          if ($part) {
            $part->{$parent_field_name}() = $entity;
            $part->save();
          }
        }
      }
    }
  }

}

I also have a service definition as follows.

services:
  # Name of this service.
  parthsub_feeds_modifications_events_subscriber:
    # Event subscriber class that will listen for the events.
    class: Drupalpartshub_feeds_modificationsEventSubscriberFeedsSubscriber
    # Tagged as an event_subscriber to register this subscriber with the event_dispatch service.
    tags:
      - { name: event_subscriber }

8 – How to import Json file from Feeds module

I am using Feeds import module with Feeds extensible parsers module, I am getting following error. I am not getting what is wrong with the json and settings. Can anyone help me to resolve this issue.

Thanks in advance,

enter image description here

My json look like,

[
{
“lcia_id”: ,
“name”: “”,
“company_name”: “”,
“company_id”: ,
“net_weight”: ,
“country”: “”,
“address”: “–“,
“serving_size”: “-“,
“composition”: [],
“type”: “”,
“field_ingredientimpactcarboningm”: ,
“field_ingredientaggimpactbiosli”: ,
“field_ingredientaggimpactwaterle”: ,
“field_ingredientaggimpactwaterpo”: ,
“field_processingimpactcarboningm”:
},
]

and in Feeds setting I have used,

enter image description here

enter image description here

Does something prevent two thunderbolt3 displays from connecting into a port replicator that feeds into 1 thunderbolt 3 port?

Does something prevent two thunderbolt3 displays from connecting into a port replicator that feeds into 1 thunderbolt 3 port? – Ask Different

9 – How to automatically title entities imported with feeds?

I have a site with a lot of audio files (using core’s Media audio media type).

On the Manage form display admin page (/admin/structure/media/manage/audio/form-fields), I have set the Name field to Disabled.

This way, when I add a media audio entity in the UI (at /media/add/audio), then I don’t have to add the title, and the entity name will automatically be set to the file name.

Now I want to automate media audio entity creation with the Feeds module. I configured a feed type + a feed for my media audio entities. I’m importing CSV files from a directory.

I used the following mappings:

  • File ID + File Description for the media field field_media_audio_file
  • Code for the text field field_import_id (for which I set the unique option to keep track of imports)

However, when I try to import the feed, I get this error:

Name (name): This value should not be null.

How can I disable this validation (checking for the Name field) by the Feeds module for media audio entities?

As a workaround, I can create a column in the CSV file and list all the file names, but this results in duplicate information and presents the risk of typos.

9 – Importing prices from CSV during Feeds Import

So I have a content type with several taxonomy reference fields. One of my taxonomies is a header in my CSV sheet. Under each of these headers in the CSV, I have several prices, and I’d like for these prices to automatically show up when I do a Feeds Import.

The problem, of course, is that the prices themselves aren’t listed as taxonomy terms, so when I do the Feeds Import, Drupal doesn’t recognize them.

Would there be any way to keep my header as a taxonomy reference field, but still show the data associated with it? I can’t change it to ‘Text (plain)’ because I need it as a taxonomy for my view. Thank you.

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies