favicon – In , is the sizes attribute required or optional?

I note that in the WHAT-WG section on:

link rel="icon"

Every icon referenced includes a sizes attribute:

<link rel=icon href=favicon.png sizes="16x16" type="image/png">
<link rel=icon href=windows.ico sizes="32x32 48x48" type="image/vnd.microsoft.icon">
<link rel=icon href=mac.icns sizes="128x128 512x512 8192x8192 32768x32768">
<link rel=icon href=iphone.png sizes="57x57" type="image/png">
<link rel=icon href=gnome.svg sizes="any" type="image/svg+xml">
<link rel=stylesheet href=lsforums.css>

Source: https://html.spec.whatwg.org/dev/links.html#rel-icon

But, to my knowledge, the sizes attribute has never been compulsory.

However, now that I’m trying to find an authoritative source confirming the sizes attribute is optional, I cannot.

In <link rel="icon">, is the sizes attribute required or optional?

I am specifically looking for an authoritative source – thanks.

Magento2: How to display product attribute in frontend

I use this code to display one attribute in frontend:

                            <?php 
                                $optionText = '';
                                $attr = $_product->getResource()->getAttribute('newbrand_name');
    
                                if ($attr->usesSource()) {
                                   $optionText = $attr->getSource()->getOptionText($_product->getNewbrandName());
                                }
                            ?>
                            <?php if($optionText){ ?>
                                <div class="attributes-list"><?php echo "Producent: " ?><?php echo $optionText ?></div>
                            <?php } ?>

Working correct.

Can anyone help me modify this code to display two additional attributes? Color and Gender from attribute code:

8 – Form API placeholder attribute rendered as “- Select -“

In a custom Drupal 8 module, I have a couple of Form API fields of '#type' => 'select':

<?
    $form('form-right')('field_role') = (
      '#type' => 'select',
      '#title' => $this->t('Role'),
      '#title_display' => 'invisible',
      '#required' => TRUE,
      '#options' => (
        'foo' => $this->t('Role Foo'),
        'bar' => $this->t('Role Bar'),
        'baz' => $this->t('Role Baz'),
        'quux' => $this->t('Role Quux'),
        'plugh' => $this->t('Role Plugh'),
        'xyzzy' => $this->t('Role Xyzzy'),
      ),
      '#attributes' => (
        'placeholder' => $this->t('Role'),
      ),
    );

    $form('form-right')('field_contact_reason') = (
      '#type' => 'select',
      '#title' => $this->t('Contact Reason'),
      '#title_display' => 'invisible',
      '#required' => TRUE,
      '#options' => (
        'foo' => $this->t('Contact Reason Foo'),
        'bar' => $this->t('Contact Reason Bar'),
        'baz' => $this->t('Contact Reason Baz'),
        'other' => $this->t('Other'),
      ),
      '#attributes' => (
        'placeholder' => $this->t('Contact Reason'),
      ),
    );

Before a value is selected, the dropdown select picklists display the string '- Select -':

Form API placeholder attribute rendered as "- Select -"

The client would like them to display the value in the placeholder attribute instead.

Have I done something wrong?

In which table in database Magento 2 product will insert with image and custom attribute?

What are the basic tables which need to use, so Product data will be inserted with image and custom attribute.

Which is visible both in frontend and admin.

Please Any one point out the table name for the products entry.

Any help is appreciated.

sharepoint online – Data-Ms-Options is not a valid attribute of element ‘div’

I am using VS 2019 to develop a sharepoint add-on for sp online. When I hover over ‘data-ms-control’ and ‘data-ms-options’, I get the error “Validation(XHTML 1.0 tRANSITION): Attribute ‘data-ms-control’ is not a valid attribute of element ‘div’, which appears to be the reason why my top bar does not work. How do I fix this?

The relevant code in question is shown below.

<head>...</head>
<body style="margin:10px;">

    <!-- Chrome control placeholder. Options are declared inline.  -->
    <div>Test div!</div>
<div 
    id="chrome_ctrl_container"
    data-ms-control="SP.UI.Controls.Navigation"  
    data-ms-options=
        '{  
            "appHelpPageUrl" : "Help.aspx",
            "appIconUrl" : "/Images/AppIcon.png",
            "appTitle" : "Chain Store",
            "settingsLinks" : (
                {
                    "linkUrl" : "Account.aspx",
                    "displayName" : "Account settings"
                },
                {
                    "linkUrl" : "Contact.aspx",
                    "displayName" : "Contact us"
                }
            )
         }'>
</div>
 .....

More info: I am following the microsoft tutorial https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/give-your-provider-hosted-add-in-the-sharepoint-look-and-feel and the sharepoint top bar does not show up, which I have concluded to be because of this error message as the div tags are what displays the sharepoint top bar.

magento2 – Magento 2 Output Custom Category Attribute

I created a custom category attribute attribute – Category Heading – That I want to display on Category pages (specifically taking the place of the category H1s in title.phtml). The new attribute shows in the admin and it saves in the database, but I am not sure how to call it on a category page.

Attribute is saved in the catalog_category_entity_varchar table, but doesn’t seem to be associated with category data – $category->getData()

I have tried to get the attribute with the below code, but it has not been successful:

$objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $category = $objectManager->get('MagentoFrameworkRegistry')->registry('current_category');
        $categoryHeading = $category->getData('category_heading');

Here is my Setup/InstallData.php

<?php
namespace WeekendsOnlyCategoryNameSetup;

use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface
{
 private $eavSetupFactory;
    
 public function __construct(EavSetupFactory $eavSetupFactory) {
     $this->eavSetupFactory = $eavSetupFactory;
 }
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
    $setup->startSetup();
    $eavSetup = $this->eavSetupFactory->create(('setup' => $setup));

   $eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'category_heading', (
            'type' => 'varchar',
            'label' => 'Category Heading',
            'input' => 'text',
            'source' => '',
            'visible'  => true,
            'sort_order' => 40,
            'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
            'required' => false,
            'group' => 'General Information',
        )
    );
     $setup->endSetup();
 }
}

And here is my category_form.xml

<?xml version="1.0" ?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="general">
        <field name="category_heading">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="required" xsi:type="boolean">false</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">false</item>
                    </item>
                    <item name="sortOrder" xsi:type="number">40</item>
                    <item name="dataType" xsi:type="string">string</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="label" translate="true" xsi:type="string">Category Heading</item>
                </item>
            </argument>
        </field>
    </fieldset>
</form>

How to filter products as per custom attribute value in Magento 2

I am trying to sort products as per the custom attribute value “new_sort_by” but unfortunately I could not filter. please check my code

  1. Create a product attribute “new_sort_by”

  2. add the below code for filter products.

     $productCollection = $block->getProductCollection();
     $productCollectionnewproducts = $productCollection->addAttributeToSort("new_sort_by","ASC")
                                     ->addAttributeToSort('name', 'ASC');
     echo $productCollectionnewproducts->getSelect()->__toString();
     $itemsnewproducts = $productCollectionnewproducts->getItems();
    
  3. Used for Sorting in Product Listing = Yes

save the attribute and clear the cache.

also re-index the data.

I am saving products with attribute (new_sort_by) value in number (1,2,3,4,5) and want to sort products with the attribute value in ASC order.

woocommerce variable product attribute filter

I have two types of products: 1. Simple Product 2. Variable Product

I have created an attribute called “Colors” (values: Black, White)

For the Simple Product type, I have both Black, White for “colors” attributes

For the Variable Product type, I have both Black, White for “colors” attributes as well and I used them both to create the variations.

Now the problem is the Attribute Filter Widget that comes with Woocommerce does not pick the attributes for the variable product type item. In the Category/Shop Page the widget is showing:

Black 1

White 1

Instead of showing

Black 2

White 2

If I delete the attributes for the simple product type, the widget does not even display the Attribute Filter

Could you please help me with what could possibly go wrong?

Radio buttons for product attribute

Is it possible to have a product attribute and to have the input type as radio buttons?

entities – Drupal 8: Change $form attribute in callback

I have a form and a field model. In a hook alter, I add ajax callback to a function getMobileorFixed that does some taxonomy computation. Here is the hook_alter

function THEME_form_FORM_ID_alter(&$form, &$form_state) {
    $form('elements')('system_information')('model')('#ajax') = (
        'callback' => 'getMobileorFixed',
        'event' => 'change',
        'progress' => (
          'type' => 'throbber',
          'message' => t('Loading...'),
        )
      );
}

it works. and when I wrote getMobileorFixed it also computes the value:

function getMobileorFixed(array &$form, FormStateInterface $formState){
  $equipment_id = $term_obj->get('field_equipment_type')->target_id;
  $equipment_taxonomy = Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($equipment_id);
  $equipment_type = $equipment_taxonomy->get('name')->value;
   
    //these 2 lines temporarily add the value to `equipment_type` (#value / #default_value) attributes
  $form('elements')('system_information')('equipment_type')('#value') = $equipment_type . " (" . $equipment_id . ")";
  $form('elements')('system_information')('equipment_type')('#default_value') = $equipment_type . " (" . $equipment_id . ")";
   
  //calls a `myAjaxCallback` in my javascript file
  $response = new AjaxResponse();
  $response->addCommand(new InvokeCommand(NULL, 'myAjaxCallback', ()));
  return $response;
}

However, later on submission the:

$form('elements')('system_information')('equipment_type')('#value')
$form('elements')('system_information')('equipment_type')('#default_value')

are empty. I am having trouble understanding how to permanently set values even inside callbacks. I thought perhaps passing in the reference variable array &form would change the values once the function returns, but that does not seem to be the case. Any help would be appreciated. thank you.