magento2 – How to add inline css to the Transaction Emails

I need to update existing email header. There for I have to modify some styles.but doesn’t define in specific style in app/design/frontend/{themename}/{namespace}/Magento_Email/email/header.html

app/design/frontend/{themename}/{namespace}/Magento_Email/email/header.html

 <!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<!--@subject Header @-->
<!--@vars {
"var logo_height":"Email Logo Image Height",
"var logo_width":"Email Logo Image Width",
"var template_styles|raw":"Template CSS"
} @-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, width=device-width" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <style type="text/css">
        {{var template_styles|raw}}

        {{css file="css/email.css"}}
    </style>
</head>
<body>
{{inlinecss file="css/email-inline.css"}}

<!-- Begin wrapper table -->
<table class="wrapper" width="100%">
    <tr>
        <td class="wrapper-inner" align="center">
            <table class="main" align="center">
                <tr>
                    <td class="header">
                        <a class="logo" href="{{store url=""}}">
                            <img
                                {{if logo_width}}
                                    width="{{var logo_width}}"
                                {{else}}
                                    width="180"
                                {{/if}}

                                {{if logo_height}}
                                    height="{{var logo_height}}"
                                {{else}}
                                    height="52"
                                {{/if}}

                                src="https://magento.stackexchange.com/{{var logo_url}}"
                                alt="{{var logo_alt}}"
                                border="0"
                            />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td class="main-content">
                    <!-- Begin Content -->

but after preview the Email template in admin panel it show as below.
Check below image

enter image description here

I need to change background color and padding and width of the highlighted element (<td>)

How change the style in element ?

8 – Custom Submit Button On Inline Entity Form Triggers Gives Wrong Triggering Element

I have implemented hook_field_widget_form_alter() to add a new #process array item.
E.g.

 hook_field_widget_form_alter() {
   $element('#process')() = ('custom_process_function');
 }

This part works fine to add in a new submit button that will save the contents of the current form send the user off to another page.
E.g.

custom_process_function(&$element) {
  $element('new_button') = (
      '#type'                   => 'submit',
      '#value'                  => t('Upload new'),
      '#submit'                 => (
        (
          "Drupalinline_entity_formElementSubmit",
          "trigger",
        ),
        (
          AddNewSubmitHandler::class,
          'handle',
        ),
      ),
      '#trigger'                => $this->fieldName,
      '#name'                   => $this->fieldName . '_add_new' . '_' . md5(json_encode($this->fieldParents)),
      '#ief_submit_trigger'     => TRUE,
      '#ief_submit_trigger_all' => TRUE,
      '#referenceType'          => $this->fieldReferenceType,
      '#referenceBundles'       => $this->fieldReferenceBundles,
      '#referenceEntityType'    => $this->entityType,
      '#referenceEntityBundle'  => $this->bundle,
      '#allowedFileTypes'       => $this->allowedFileTypes,
      '#validate'               => ('_custom_validate_function'),
    ); 
} 

However, the problem lies when it is loaded into Inline Entity Form field and then an ajax event is triggered.
In my case, I am using an Entity Browser field within this form and when I click the Remove button and then click my custom button, the $formState->getTriggeringElement() is set to the next submit button that was on the original form, not even the next one in the Inline Entity Form.

Can anyone shed any light on why this is happening or how to fix it?

2016 – How to call a JavaScript inline of Item display template?

I am editing an Item Display Template (for a content search webpart) on SP2016 enterprise.

In the display template (Item_LargePicture.html), I inserted a JavaScript function to randomly return a image tag (e.g. <img src="https://sharepoint.stackexchange.com/sites/os/PublishingImages/thumbs/01.jpg" alt=""> ). The function named getImageTag().

In the main html part of template I call my JS function like below syntax:

    <span style="display: table-cell;width: 50%">
<article id="_#= containerId =#_" data-displaytemplate="ItemLargePicture"> 

            <a class="image fit thumb" href="_#= linkURL =#_" title="_#= $htmlEncode(line1) =#_" id="_#= pictureLinkId =#_">
                
                <!--#_
                     document.write(getImageTag());
                 _#-->

            </a>
            <span class="text-block" id="_#= dataContainerId =#_">
                <a href="_#= linkURL =#_" title="_#= $htmlEncode(line1) =#_" id="_#= line1LinkId =#_">
                    <h3 id="_#= line1Id =#_"> _#= line1 =#_</h3>
                </a>
            </span>
</article></span>

When I load the sharepoint page with display template, all I got is “Display Error: The display template had an error. You can correct it by fixing the template or by changing the display template used in either the Web Part properties or Result Types.” I cannot debug with above error. Could you advise the correct syntax?

interaction design – Subsequent editing of inline “click to enter text” fields

I’m iterating on a SaaS platform where there is a notes functionality on certain elements which are shared between all users of the platform.

Currently, it’s handled via the notes section starting out with a “Click to enter text” empty state.

Clicking note text is also the only way to launch into editing once a user has written a note.

While the means of editing that field may be clear for the first user who see’s the empty state, I worry that losing that signifier could hurt visibility for subsequent users reading the note who may want to edit.

I plan on examining this (among other things) to a certain extent in some user tests/interviews, but I’d appreciate insight any of you may have as well!

enter image description here

php – How to create a custom config file and get data using inline JS in a wordpress page

I’m totally new in WordPress as well as in PHP and making my first application with it.

Currently, I use ‘HTML block Element’ to add content with custom HTML and inline Javascript code on blank WordPress pages (using Elementor). I want to create a new config file(or add data on an existing one) on which I can define some variables which I then will be getting using Js and work accordingly.

I tried adding defines in the wp-config file and accessing them with Js but it didn’t work.

wp-config

define('PERSONAL_KEY', 'VALUE');

In custom HTML code element of WP Page

<script>   
   var data = "<?php echo PERSONAL_KEY; ?>";
   // Didn't worked
</script>

Is there any way to achieve getting variables inside inline JS code from an external config file?

7 – Inline Javascript throws an error on drupal_add_js() within an AJAX callback

I am trying to get JavaScript to measure a text field and auto submit at a character limit for an Ajax callback to be validated against a Luhn Algorithm and errors out on failure to validate.

I found this code in Firing ajax_callback on textfield after a minimum number of character.

// Trigger ajax event on myitem only after 5th character typed.
$('.myitem-class').on('keyup', function() {
  if ($(this).val().length == 5) {
    $(this).trigger('change');
  }
});

The JavaScript can allegedly be put inline in a wrapper like this to be used in an Ajax callback in a form. See drupal_add_js within AJAX callback.

function my_module_form($form, &$form_state) {
  drupal_add_js('Drupal.ajax.prototype.commands.myFunction = function(ajax, response, status) {
    // …
    }',
    'inline'
  );

  return $form;
}

I got to run replacing function(ajax, response, status) with function($, Drupal).

When I put in the code, it throws a PHP error at ).on(. I wasn’t able to get the inline wrapper recommended in Converting 6.x modules to 7.x / JavaScript should be compatible with libraries other than jQuery to work because it fails seeing the $ as a variable.

(function ($) {
  // (…)
}(jQuery));

Right now, I am stopped by syntax errors.

Does anyone know how to get this JavaScript code work?

forms – Drupal 7 inline Javascript throws error on drupal_add_js within AJAX callback

I am trying to get Javascript to measure a text field and auto submit at a character limit for an Ajax callback to be validated against a Luhn Algorithm and error out on failure to validate.

I found this code and checked the syntax in jsfiddle

  // Trigger ajax event on myitem only after 5th character typed.
     $('.myitem-class').on('keyup', function() {
       if ($(this).val().length == 5) {
      $(this).trigger('change');
     }
   });

From Firing ajax_callback on textfield after a minimum number of character

The Javascript can allegedly be run inline in a wrapper like this to be able to be used in an Ajax callback in a form.:

    function my_module_form($form, &$form_state) {
    // (...)
      drupal_add_js(
       'Drupal.ajax.prototype.commands.myFunction = function(ajax, response, status) {
     // Whatever you want to do.
      }',
      'inline'
      );
     // (...)
    return $form;
  }

From drupal_add_js within AJAX callback

Which I got to run changing function(ajax, response, status) { to function($, Drupal ) {

But when I put in the code it looks like it throws a PHP error at “).on(“

I was not able to get the inline wrapper recommended in the Drupal 6 to 7 docs to work as it fails seeing the $ as a variable

    (function ($) {
       //your code here
    }(jQuery));

According to https://www.drupal.org/docs/7/converting-drupal-6-modules-to-drupal-7/converting-6x-modules-to-7x#javascript_compatibility

Stating that JavaScript should be made compatible with libraries other than jQuery by adding a small wrapper around your existing code:

Right now I am stopped by the syntax errors

Does anyone know how to get this javascript inline code setup working??

8 – How to programmatically require a field using Inline Entity Form

I have a node form using an inline entity form widget for either selecting or creating taxonomy terms to be referenced from the node. The field should be required at a certain moderation state, but in the early stages of moderation the field does not need to be required. I’m trying to make this change in hook_form_alter

I tried comparing the values of $form in the alter function when the field had been set to required, and when it hadn’t. The only differences were within $form('field_name')('widget'):

$form('field_name')('widget')('#required') => 0

vs.

$form('field_name')('widget')('#required') => 1

and

$form('field_name')('widget')(#element_validate) => Array
                (
                    (0) => Array
                        (
                            (0) => Drupalinline_entity_formPluginFieldFieldWidgetInlineEntityFormComplex
                            (1) => updateRowWeights
                        )

                )

vs.

$form('field_name')('widget')(#element_validate) => Array
                (
                    (0) => Array
                        (
                            (0) => Drupalinline_entity_formPluginFieldFieldWidgetInlineEntityFormComplex
                            (1) => updateRowWeights
                        )

                    (1) => Array
                        (
                            (0) => Drupalinline_entity_formPluginFieldFieldWidgetInlineEntityFormComplex
                            (1) => requiredField
                        )

                )

Just adding $form("field_name")("widget")("#required") = TRUE; to the alter didn’t change anything, and trying to add the #element_validate bit lead to an error:

User error: “0” is an invalid render array key in DrupalCoreRenderElement::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).

How can I programmatically require an inline entity form field in a hook form alter?

c++ – Is it bad practice to make get and set methods inline?

I use this class to pass around information. Is it a bad practice if the getter and setter are inline? they are the only method of the class.

#define DEVICEINFORMATION_H

#include "DateInformation.h"
#include "TimeInformation.h"

enum class DEVICEMODE
{
  SLEEP,
  CLOCK,
  STOPWATCH
};

class DeviceInformation
{
private:
  DEVICEMODE mode;
  TimeInformation time;
  DateInformation date;

public:
  DeviceInformation();
  ~DeviceInformation();
  inline DEVICEMODE GetMode()
  {
    return mode;
  }
  inline DEVICEMODE SetMode(DEVICEMODE newMode)
  {
    mode = newMode;
  }
  inline TimeInformation GetTime()
  {
    return time;
  }
  inline TimeInformation SetTime(TimeInformation newTime)
  {
    time = newTime;
  }
  inline DateInformation GetDate()
  {
    return date;
  }
  inline DateInformation SetDate(DateInformation newDate)
  {
    date = newDate;
  }
};

#endif ```