bootstrap_barrio subtheme breaks ckeditor’s media insert in custom block

I’m facing this problem (seems to be producible) in a contrib theme that breaks the ckeditor media insert button on custom blocks in the layout builder of individual nodes…
The javascript error says it’s typically caused by the theme neglecting to include proper html attributes for that entity type, but the theme’s block.html.twig is identical to that template in Bartik. This is a custom subtheme of bootstrap_barrio created with the shell script provided by bootstrap_sass (Barrio highly recommends subtheming that way). Error has been repeated on new D8 and D9 installations, and the full message on page load is:

Uncaught Error: Quick Edit could not associate the rendered entity field markup (with (data-quickedit-field-id="block_content/1/body/en/full")) with the corresponding rendered entity markup: no parent DOM node found with (data-quickedit-entity-id="block_content/1"). This is typically caused by the theme's template for this entity type forgetting to print the attributes.

and while editing a block in the layout builder, clicking ckeditor’s media insert button results in the following error (and the media dialog never opens, the “Loading…” message appears but nothing loads):

Object { message: "nAn AJAX HTTP error occurred.nHTTP Result Code: 500nDebugging information follows.nPath: /media-library?media_library_opener_id=media_library.opener.editor&media_library_allowed_types%5B0%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfilter_format_id%5D=basic_html&hash=Ul_KDXiNyg8Mw95OeXpaIZUYieACO4FlRCUQkle_TCsnStatusText: Internal Server ErrornResponseText: The website encountered an unexpected error. Please try again later.", name: "AjaxError", stack: "@https://atn.ddev.site/core/misc/ajax.js?v=8.9.3:100:32n@https://atn.ddev.site/core/misc/ajax.js?v=8.9.3:643:3n" }

I was very excited about the bootstrap_barrio’s subtheme with sass, gulp, browsersync all configured with bootstrap, but maybe I should switch to radix? I’d much prefer to solve this error though, if anyone has any insight? I don’t know where to begin with javascript debugging 🙁

magento2 – How to create my custom visual swatch color attribute in my own module Vendor/Module/Setup/Patch/Data/MyOwnColorAttribute?

I take from https://github.com/magento/magento2/blob/2.3/dev/tests/integration/testsuite/Magento/Swatches/_files/product_visual_swatch_attribute.php like example, but my own color attribute patch didn’t create any options if I add those parameters. This is my code:

<?php 
namespace VendorModuleSetupPatchData;

use MagentoCatalogModelProduct;
use MagentoEavModelEntityAttributeScopedAttributeInterface;
use MagentoEavModelEntityAttributeSourceTable;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupPatchDataPatchInterface;
use VendorModuleModelAttributeBackendColor as Backend;
use VendorModuleModelAttributeFrontendColor as Frontend;

class AddColorAttribute implements DataPatchInterface
{
    /**
     * @var ModuleDataSetupInterface
     */
    private $moduleDataSetup;

    /**
     * @var EavSetupFactory
     */
    private $eavSetupFactory;

    /**
     * @param ModuleDataSetupInterface $moduleDataSetup
     * @param EavSetupFactory $eavSetupFactory
     */
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory,
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavSetupFactory = $eavSetupFactory;
    }

    /**
     * @inheritdoc
     */
    public function apply()
    {
        $this->moduleDataSetup->startSetup();
        $eavSetup = $this->eavSetupFactory->create();
        $eavSetup->addAttribute(Product::ENTITY, 'visual_swatch_color_attribute', (
            'type' => 'int',
            'label' => 'Visual Swatch Color Attribute',
            'input' => 'select',
            'frontend' => Frontend::class,
            'backend' => Backend::class,
            'source' => Table::class,
            'required' => false,
            'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
            'visible' => true,
            'is_used_in_grid' => true,
            'is_visible_in_grid' => true,
            'is_filterable_in_grid' => true,
            'user_defined' => true,
            'searchable' => true,
            'filterable' => true,
            'comparable' => true,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'is_html_alowed_on_front' => true,
            'unique' => false,
            'swatch_input_type' => 'visual',
            'swatchvisual' => (
                'value' => (
                    'Obsidian' => '#3a322d',
                    'Pure' => '#0000ff',
                    'Crimson' => '#dc143c',
                    'Emerald' => '#50c878',
                    'Ametyst' => '#9966cc',
                ),
            ),
            'optionvisual' => (
                'values' => (
                    'Obsidian' => ('Obsidian'),
                    'Pure' => ('Pure'),
                    'Crimson' => ('Crimson'),
                    'Emerald' => ('Emerald'),
                    'Ametyst' => ('Ametyst'),
                ),
            ),
            'default' => '1'
        ));

        $eavSetup->addAttributeToGroup(
            MagentoCatalogModelProduct::ENTITY,
            'Default',
            'Product Details',
            'visual_swatch_color_attribute',
            18
        );
        $this->moduleDataSetup->endSetup();
    }

    /**
     * @inheritdoc
     */
    public static function getDependencies(): array
    {
        return ();
    }

    /**
     * @inheritdoc
     */
    public function getAliases(): array
    {
        return ();
    }
}

conditional formatting – Using a custom formula on a sheet that is constantly expanding

A custom formula for 5 possible colors, by day is used to highlight entries by DayOfWeek

Is it possible to use a format like A2:A instead of manually editing it as the sheet grows bigger?

Formula works fine, just don’t want to be editing it continuously

Example for rows A2 to A641 – can this be $A$2:$A ?

=and(isblank($A$2:$A$641)=false,OR(weekday($A$2:$A$641)=7))

Wpbakery pagebuilder: How to create dropdown with custom taxonomy terms?

I have custom post type and custom taxonomy with it.
Trying to create wpbakery pagebuilder’s element with a dropdown of terms.
Here is my vc_map function:

vc_map( 
    array(
        'name'                      => __('All category posts', 'text-domain'),
        'base'                      => 'company_category_products',
        'category'                  => __('Company', 'text-domain'),
        'description'               => __('A list of post for choosen category', 'text-domain'),
        "show_settings_on_create"   => true,
        "is_container"              => false,
        "icon"                      => 'custom_icon',
        "params"                    => array(
            array(
                "type"          => "dropdown",
                "heading"       => __("Post category", 'text-domain'),
                'value'         => company_get_terms_array(),
                "param_name"    => "post_category",
                "description"   => __("Choose category with posts", 'text-domain')
            ),
        )
    
    ) 
); 

company_get_terms_array() is a function in my functions.php file, which returns an assoc array of terms’ ids as key and terms’ as values.

function company_get_terms_array($taxonomy = 'product-category'){

    $args = array(
        'taxonomy'  => $taxonomy,
        'parent'    => 0
    ); 

    $terms = get_terms( $args ); 
    $result = array(); 

    if( !empty($terms) && !is_wp_error($terms) ):

        foreach( $terms as $term) { 
           $result( $term->term_id ) = $term->name . ' (' . $term->count . ')'; 
        }

    endif;

    return !empty($result) ? $result : array(); 

}

The function by it self works fine, I can print it in custom post edit page’s metabox for example and get a result as I expect. Like this

Array
(
    (30) => Temp1 (3)
    (31) => Temp2 (2)
    (27) => Temp3 (3)
    (29) => Temp4 (2)
    (28) => Temp5 (4)
    (5)  => Temp6 (2)
    (32) => Temp7 (4)
)

But on settings window of wpbakery pagebuilder’s element I see an empty dropdown, which I return in a function if get_terms() returns wp_error object. Custom post type and custom taxonomy registered with ‘init’ hook and maybe wpbakery pagebuilder call this function earlier?
I have also the second wpbakery element with a dropdown, where I show custom posts. I use almost the same function, but with get_posts instead of get_terms. It works fine.

function company_get_posts_array($post_type = 'custom-posts'){

    $args = array( 'posts_per_page' => -1, 'post_type' => $post_type ); 
    $posts = get_posts( $args ); 
    $result = array(); 

    if( $posts ):

        foreach( $posts as $post) { 
           $result( $post->ID ) = get_the_title( $post->ID ); 
        }

    endif;

    return !empty($result) ? $result : array(); 

} 

How to dynamically list document library titles onto a custom SharePoint page

With SharePoint Online, if I have 7 document libraries within a site, titled like so…

food
keys
cars-2019
cars-2020
cars-2021
pets
family

…Is there a way I can dynamically list and link all my cars_x document library titles onto a custom SharePoint page, whenever a cars_x document library is created?

Or

On that custom SharePoint page, can I create a dynamic navigation menu that picks up and displays what I am trying to query…?

8 – jQuery dependency on a custom theme is not adding jQuery?

I know that this question has been asked previously many times but any of the solutions are not working in my case so please, I request if anyone can help me with this situation please provide me assistance.
I have added dependency of the core jQuery(along with other core libraries) in my theme.libraries.yml but only core jQuery is not loading in my drupal frontend and the console is showing the error of jQuery is not defined.
Also other drupal core libraries as working fine only jQuery is not loading.

My code of various files is as follows

theme.libraries.yml

global-styling:   
  version: 1.x   
  css:
    theme:
      css/bootstrap.css: {}
      css/custom.css: {}
      css/owl.carousel.min.css: {}
      css/owl.theme.default.min.css: {}
      css/responsive.css: {}
      css/style.css: {}
      fonts/fonts.css: {}   
  js:
    js/bootstrap.js: {}
    js/owl.carousel.min.js: {}
    js/popper.js: {}
    js/scripts.js: {}   
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/drupal

theme.info.yml

name: wcsb
type: theme
description: 'Another outstanding WebCube Theme'
package: Core
version: '0.1.2'
core: '8.x'
base theme: classy

libraries:
  - wcsb/global-styling

regions:
  header_bar_1: 'Header Bar 1'
  header_bar_2: 'Header Bar 2'
  header_bar_3: 'Header Bar 3'
  header_bar_4: 'Header Bar 4'
  mobile_header_1: 'Mobile Header 1'
  mobile_header_2: 'Mobile Header 2'
  slider_images: 'Slider Images'
  breadcrumb: Breadcrumb
  featured_top: 'Featured top'
  above_content: 'Above Content'
  content: Content
  below_content: 'Below Content'
  sidebar_first: 'Sidebar first'
  sidebar_second: 'Sidebar second'
  featured_bottom_first: 'Featured bottom first'
  featured_bottom_second: 'Featured bottom second'
  featured_bottom_third: 'Featured bottom third'
  footer_first: 'Footer first'
  footer_second: 'Footer second'
  footer_third: 'Footer third'
  footer_fourth: 'Footer fourth'
  footer_fifth: 'Footer fifth'

list of scripts loading

<body class="path-frontpage page-node-type-page" data-new-gr-c-s-check-loaded="14.1002.0" data-gr-ext-installed=""
cz-shortcut-listen="true">

<script type="application/json" data-drupal-selector="drupal-settings-json">
    {
        "path": {
            "baseUrl": "/",
            "scriptPath": null,
            "pathPrefix": "",
            "currentPath": "node/1",
            "currentPathIsAdmin": false,
            "isFront": true,
            "currentLanguage": "en"
        },
        "pluralDelimiter": "u0003",
        "suppressDeprecationErrors": true,
        "ajaxTrustedUrl": {
            "form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM": true
        },
        "user": {
            "uid": 0,
            "permissionsHash": "508c848d9cf616f3b3735479b8cad945e128b7dbb0a534206170c7d3643afe05"
        }
    }
</script>
<script src="https://drupal.stackexchange.com/core/assets/vendor/jquery-once/jquery.once.min.js?v=2.2.3"></script>
<script src="/core/misc/drupalSettingsLoader.js?v=8.9.13"></script>
<script src="/core/misc/drupal.js?v=8.9.13"></script>
<script src="/core/misc/drupal.init.js?v=8.9.13"></script>
<script src="/themes/custom/wcsb/js/bootstrap.js?v=8.9.13"></script>
<script src="/themes/custom/wcsb/js/owl.carousel.min.js?v=8.9.13"></script>
<script src="/themes/custom/wcsb/js/popper.js?v=8.9.13"></script>
<script src="/themes/custom/wcsb/js/scripts.js?v=8.9.13"></script>
<script src="/modules/contrib/commerce/modules/cart/js/commerce_cart.js?v=8.9.13"></script>

console errors
console showing jquery is not defined errors.

Custom shortcode render problem with return ”

I hope you all having a great day. I’m developing a video player plugin with custom shortcodes and stuff but I’m having a problem with the shortcode render. Currently, my shortcode content is rendered with echo which works fine but it doesn’t render inside the page content so I have to change it to return method somehow but it has foreach loops and if else statements inside it so I can’t just do return '<ul> '.foreach($x as $s){}.' </ul> '; and stuff, do you guys know a workaround for this? I’ve also tried to place everything inside a function and tried to render it inside return like this: return "http://wordpress.stackexchange.com/".renderdata()."http://wordpress.stackexchange.com/"; which works but again it doesn’t render inside the content.

Here’s my complete shortcode function

function vc_playlist_shortcode( $atts = array() ) {

    // add_action('wp_head', 'deregister_scripts');
    // add_action('wp_enqueue_scripts', 'deregister_scripts');
    // add_action('wp_footer', 'deregister_scripts');
   
    // get the shortcode attribute value
    extract(shortcode_atts(array(
     'id' => "http://wordpress.stackexchange.com/"
    ), $atts));

    $playlistdata = get_post_meta( $id, 'vc_playlist_data', true );
    

    // Filter the urls in playlist data and assign it to an array
    $playlisturls = array_filter($playlistdata, function($val){
        return filter_var($val, FILTER_VALIDATE_URL);  
    });
    // rebase the assigned array
    $counter = 0;
    $rebasedurls = array();

    foreach ($playlisturls as $key => $value) {
        $rebasedurls($counter) = $value;
        $counter++;
    }
    // trim the 'https://vimeo.com/' from the values and keep the ID only
    //$videoIDs = preg_replace('/(^0-9)/', "http://wordpress.stackexchange.com/", $rebasedurls);

   
    function videostatuschecker($x){
        $unlockedvideos = get_user_meta(wp_get_current_user()->ID, 'vc_unlocked_videos', false);

        if (in_array($x, $unlockedvideos)){
            return 'unlocked';  
        }
        else{
            return 'locked';
        }
    }
    // Serve the first video URL to browser so we can access it in our JS function
    echo '<script type="text/javascript">var vc_firstvideo = "http://wordpress.stackexchange.com/".$rebasedurls(0)."http://wordpress.stackexchange.com/"</script>';
    
    echo '<div class="vc-video-container">';
    //echo '<div class="vc-plyr" data-plyr-provider="vimeo" data-plyr-embed-id="http://wordpress.stackexchange.com/".$rebasedurls(0)."http://wordpress.stackexchange.com/"></div>';
    echo '<div id="vc-player"></div>';
    echo '<div class="plyr-playlist-wrapper">';
    echo '<ul class="plyr-playlist">';

    foreach($playlistdata as $data){
        
        if(! filter_var($data, FILTER_VALIDATE_URL)){   
            echo '<span class="plyr-playlist-chapter-title">'.$data.'</span>'; 
        }
        else{
            echo '<li class="http://wordpress.stackexchange.com/">';
            echo '<a class="plyr-playlist-link" href="javascript:void(0);" data-video-url="http://wordpress.stackexchange.com/". $data ."http://wordpress.stackexchange.com/" data-status="http://wordpress.stackexchange.com/".videostatuschecker($data)."http://wordpress.stackexchange.com/">';
            echo '<div class="plyr-playlist-thumbnail skeleton"><img class="plyr-miniposter" src="https://wordpress.stackexchange.com/" alt="thumbnail"></div>';
            echo '<span class="plyr-playlist-title skeleton"><span></span></span>';
            echo '</a>';
            echo '</li>';
        }               
    }

    echo '</ul>';
    echo '</div>';
    echo '</div>';
    echo '<div class="vc-meta-container">'; 
        echo '<button class="fav-video-button" data-video-url="http://wordpress.stackexchange.com/".$rebasedurls(0)."http://wordpress.stackexchange.com/">Zu Favoriten hinzufügen</button>';
        echo '<div class="autoplay-container"><span class="autoplay-title">Auto Play</span> <div class="toggly-container"> <input type="checkbox" id="autoplay-toggle"> <label class="toggly-label" for="autoplay-toggle"><i class="toggly"></i></label> </div></div>';
    echo '</div>';
    

    return "http://wordpress.stackexchange.com/";
    
}
add_shortcode('vc_playlist', 'vc_playlist_shortcode'); 

Any help is much appreciated, thank you.

I built a custom .NET Core distributed system with Docker, React, Consul and RabbitMQ. Would anyone

Advertising

y u no do it?

Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

Starts at just $1 per CPM or $0.10 per CPC.

8 – Views custom relationship joined by plain text field

Let’s say I have a node type named ‘Book’.
‘Book’ nodes have ‘publisher’ field.
I want to create a node view which displays these two columns:

  • book title
  • title of a book published by the same publisher

enter image description here

Desired results is like this.
book view

The problem is I cannot use entity reverse relationship which is normally used to connect entities because ‘publisher’ field is not entity reference field.

So I added the code to my_module.views.inc.

funciton my_module_views_data() {
  // it seems first node's 'node__field_publisher' is already loaded, so join second node's node_field_data directly. 
  $data('node__field_publisher')('node_field_data') = (
    'title' => t('Same publisher books'),
    'help' => t('Get books sharing publisher'),
    'relationship' => (
      'id' => 'standard',
      'label' => 'Same publisher books',
      'left_table' => 'node__field_publisher',
      'field' => 'entity_id',
      'base' => 'node_field_data',
      'base field' => 'nid',
    ),
  );
}

It created join and relationship ‘Same publisher books’ became available.

LEFT JOIN {node_field_data} node_field_data_node__field_publisher ON node__field_publisher.entity_id = node_field_data_node__field_publisher.nid

If I click ‘Add’ in ‘field section’, select ‘Title’, set ‘Same publisher books’ as ‘relationship’, it adds query to SELECT statement like this

node_field_data_node__field_publisher.nid AS node_field_data_node__field_publisher_nid

But no titles.

I thought if I make a relationship to other node, it automatically loads field values belonging to the node(e.g. title), but is it a misconception?
How to get titles in this case?