Dynamically render custom attribute visibility based on another custom attribute

i want to override admin->catalog->product->save page, it can be possible dynamic render changing custom attribute visibility ?

example: switch control Enable RMA,

first
after

thanks for helping

2016 – CSR: how to default value render

Tell me how to set the default display of an element? Didn’t find any good example anywhere on how to return the style and value of a list item to its default?

(function () { 
    var linkFilenameFiledContext = {}; 
    linkFilenameFiledContext.Templates = {}; 
    linkFilenameFiledContext.Templates.Fields = { 
        "LinkFilename": { "View": linkFilenameFiledTemplate } 
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(linkFilenameFiledContext); 
})(); 

function linkFilenameFiledTemplate(ctx) {
    var fileRef = ctx.CurrentItem.FileRef;
    var encoded = encodeURIComponent(fileRef);
    var url = "http://sp-test/sites/test";
    var FileLeafRef = ctx.CurrentItem.FileLeafRef;
    var type = ctx.CurrentItem.File_x0020_Type;
    var LinkFilename = ctx.LinkFilename;
    var Project = ctx.CurrentItem.Project;
    if(Project == "Active" && ctx.CurrentItem.File_x0020_Type == ""){
      return "<b><span><a href=" + url + encoded + ">" + FileLeafRef + "</a></span></b>";
    } else {
      return //value and item style default?????
    }
}

xss – Safely render HTML template with inline CSS from trusted domain (it forces the use of “style-src: unsafe-inline” in CSP)

I am working with a form that a user can fill out to send an e-mail. As part of the form, there is a preview button that shows the user a preview of how the mail will look in a new tab in the browser. The e-mail template itself is defined in a 3rd party service. The site the form is on is protected with a log-in.

When the user clicks the preview button, this happens:

  1. The template is fetched from the 3rd party service on the web server.
  2. Information from the form is HTML encoded and added to the template on the web server.
  3. The template is returned as HTML to the user’s browser, where it is displayed in a new tab. The new tab contains only the e-mail template, since the template has it’s own complete markup.

The challenge with this is that the template comes with inline styling, which violates the CSP, but which we need to show a correct preview of the template. To mitigate the risks of specifying style-src 'unsafe-inline'; in the CSP header, I’ve added that rule only to the URL serving the template. This is the complete CSP header for the template preview page:

Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; img-src 'self' https://some-domain-we-load-images.from;

Since it might be possible to execute JavaScript from CSS, exfiltrate data with CSS, as well as perform other exploits, I still feel uneasy about this. Maybe an option could be to generate nonces for the CSS, but I am not sure if that works for inline CSS attributes. I’ve done some testing, and it seems that default-src blocks a lot of attack vectors, but my knowledge in this area is incomplete. Also, according to Google, there’s a few CSP resource directives that doesn’t use default-src as a fallback, and it’s these:

  • base-uri
  • form-action
  • frame-ancestors
  • plugin-types
  • report-uri
  • sandbox

I’m unsure if not specifying these will cause any real implications, give that the e-email template preview page is very limited in what it does.

The way I see it, an attacker could inject CSS in one of the following ways:

  • From the form fields. They are all HTML encoded before added to the HTML.
  • In the 3rd party service, but they would need the login credentials, or exploit some vulnerability with the service.

Is there any way to safely render inline styling in HTML from a trusted 3rd party domain? I am starting to lean towards not rendering the template as a preview, but instead sending an actual e-mail to the user so they can preview it that way.

Since the preview page contains only the previewed template, there isn’t sensitive information on the page (unless the user enters some in the form, which is not quite what this form is intended for). An attacker might be able to get away with cookies, but there’s probably sides to this I don’t know about.

And of course, there’s also the cost/benefit aspect of this.

latex – “Render mathematics” is inactive in Inkscape

I recently installed Inkscape on Ubuntu 20 LTS, and I’d like to use the builtin latex support, but when I go to Extensions > Render > Mathematics > pdflatex, the button is grey, so clicking triggers no event.
I installed texlive using the ctan installer and not via apt.

theming – Fatal error: “isEven” is an invalid render array key /web/core/lib/Drupal/Core/Render/Element.php

we have this code in template.theme but when we go to view the web, the page show a error as this: “isEven” is an invalid render array key /web/core/lib/Drupal/Core/Render/Element.php . I dont understand very good Drupal and as works it.

function fcjc_bootstrap_preprocess_paragraph(&$variables)
{
  /** @var DrupalparagraphsEntityParagraph $paragraph */
  $paragraph = $variables('paragraph');
  if ($paragraph->getType() === 'image_text_full_width' || $paragraph->getType() === 'imaxe_texto_biografia_') {
    $variables('isEven') = $variables('elements')('isEven');
  }
}


function fcjc_bootstrap_preprocess_field__field_image_text_section(&$vars)
{
  foreach ($vars('items') as $delta => &$item) {
    $classname = ($delta % 2 == 0 ? 'even' : 'odd');
    $item('attributes')->setAttribute('class', $classname);
    $item('content')('isEven') = ($delta % 2 == 0);
    }
}

In paragraph.twig I have this:
<div class=" image col-sm-4 col-xs-12 {% if isEven %}right-shadow{% else %}left-shadow col-sm-push-8{% endif %}">

Can Somebody can help me? please. Thx

theming – Render Twig Template instead of standard node fields

Right now my custom module creates a new content type. When an admin creates a node of that content type and save it they see the standard form elements displayed. However the custom module creates a controller/route: path: '/directory/{name}' and if the admin sets a URL alias on the node here is what happens:

  • if directory is prepended in the URL path before the URL alias
  • the controller is called, it finds the node via the alias
  • and makes a couple API calls based on the values in the node
  • And renders out a twig template with all the data is got from the API calls

What I want to happen is have the controller be called whenever a node of that content type is requested and my twig template to be rendered. So if a admin user created this content type and didn’t set and alias, when they save and the browser directs them to /node/123 it will still call my controller and render my twig template. Or if an admin does set a URL alias, it will still call my controller and render my twig template.

Is there a way to complete this is Drupal?

8 – Can’t render webform submissions programmatically

I am creating a custom module and try to render a webform submissions data in custom function. when I try to call my custom function it’s giving me error like “The website encountered an unexpected error. Please try again later.

TypeError: Argument 1 passed to
DrupalCoreRoutingCurrentRouteMatch::getRouteMatch() must be an
instance of SymfonyComponentHttpFoundationRequest, null given,
called in
D:xampphtdocsxxxxappcorelibDrupalCoreRoutingCurrentRouteMatch.php
on line 87 in DrupalCoreRoutingCurrentRouteMatch->getRouteMatch()
(line 99 of corelibDrupalCoreRoutingCurrentRouteMatch.php).”

/**
 * Fetch submission.
 */
function get_subscribers() {
 $webform = DrupalwebformEntityWebform::load('webform_6406');
if ($webform->hasSubmissions()) {
  $query = Drupal::entityQuery('webform_submission')
    ->condition('webform_id', 'webform_6406');
  $result = $query->execute();
  $submission_data = ();
  foreach ($result as $item) {
    $submission = DrupalwebformEntityWebformSubmission::load($item);
    $submission_data() = $submission->getData();
  }
 }
 print_r($submission_data);
 return $submission_data;
}

get_subscribers();

8 – Can you render a custom block in a view without adding it to the admin blocks page?

I made a custom block in my custom module. I now want to show that block in the “No results” area of a view, but I can’t get it to render (I don’t see any error message, and I don’t see any output).

Here is the block definition:

/**
 * Provides an 'New User' Block.
 *
 * @Block(
 *   id = "newuser_block",
 *   admin_label = @Translation("New user block"),
 *   category = @Translation("MYMODULE"),
 * )
 *

In my view, in the “No results” section, I added Rendered entity – Block, and set the Block ID to newuser_block.

However, the block does not get rendered.

This is because I did not add the block on the block admin page at /admin/structure/block. When I add the block on the admin page and use the admin page block ID (not the block machine name), the block is rendered correctly.

However, I don’t want to add the block to the admin page because I only need this block in a few places on my site, so I was using Layout Builder to inject the block where necessary.

So, is there a way to inject a block by machine name (instead of by the ID used on the block admin page) in Views?

plotting – 3D Plot does not render if function is long

I have a long function (r(x,y)) that I need to plot. This function is the product of a number of other subfunctions having different parameters.

r(dX_,dY_)=
(f((Sqrt((1659.9-dX)^2+(204.9-dY)^2))/g(56.4887500002818),b(56.4887500002818))/g(56.4887500002818))*
                                                   ...*
(f((Sqrt((1311.3-dX)^2+(47.1-dY)^2))/g(63.024550000498756),b(63.024550000498756))/g(63.024550000498756))

model = Plot3D(
r(x,y), {x, -1101.5,3659.9}, {y, -1961.3,2218.1},
PlotPoints -> {300, 300},
PlotStyle->Opacity(1),
PlotRange -> Full, 
ClippingStyle -> None);

Show(model)

My problem is that when the number of subfunctions is very big (i.e. 30..), the plot does not render at all (i.e. empty space).
Most probably the problem is related to the size of the produced values because it can be very very small (for example 1e-120).

Can I increase something to be able to generate the plot (I do not mind saving it as an image and looking at it in a non-interactive way)?

opengl – Render DFF, TXD with OpengGL or DirectX?

Thanks for contributing an answer to Game Development Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.