8 – Placing a block on an entity

I am aiming to place a block on an entity.

It seems like this should be simple as entity integration in D8 is well-developed and (in parts) user-friendly.

I can get the view block working fine and can ‘Place Block’ on different content types successfully.

However when it comes to entities there are no options in the ‘Configure Block: Visibility’ tabs.

Perhaps there is some standard documentation on customising the appearance of entities in this way that I just cant seem to find?

D8 seems to have integrated entities quite well with Views etc. But somehow simply placing a block on an entity remains a challenge.

I expect other relatively less experienced users would be experiencing the same challenges.

Perhaps I am missing something very obvious. If so perhaps someone could let me know! 🙂

Thoughts and guidance welcome.

magento2 – Where in the code is validation being requested for customAttributes when placing order

Setup: Customer has an account and is logged in, but there are no default billing and shipping addresses assigned. A custom attribute has been added and isrequired when defining in setup module. The Customer is presented with an address form. This form presents and validates the custom attribute. Customer clicks next, place order screen appears showing address form with all fields, including custom attribute. Customer clicks place order, error appears stating naming the custom attribute and informing that it is a required field.

The error is created in the magento eav/model within the validateValue function of text.php Ive tried to trace starting from the Magento_Checkout js/model and action place.order modules and ending in the service urls pointing to fuction getPaymentInformation in checkout/model/PaymentInformationManagement.php but cant seem to find the line of code that is responsible for requesting this validation. The attribute is validated upon entry in all the address forms, so I dont really need it to be validated at place order. This custom attribute works fine in other cases such as guest user, or logged in user that has entered default addresses. Its just this one case. It seems to be a Magento problem, during my troubleshooting I have been able to print out the class and my coustom attribute with its values are present.

I would like this line of code where I can just ignore the validation in this particular case.

overlay – Placing text over a rectangle using graphics

I need to add some text to rectangles that I am using as a scale bar. I want the text right above the rectangle and centered. Here’s my code:

Show[{Graphics[{Red, Rectangle[{0, 0}, {45, 15}]}, ImageSize -> 48], 
  Graphics[Text[Style["TEXT", 12, "TR", Black, Bold]]]}]

enter image description here

Desired result:

enter image description here

How can I do that?

Edit: Ideally it should also work if the text is longer than the scale bar, like so:

Graphics[{Red, Rectangle[{0, 0}, {19, 15}], 
  Text[Style["TEXT", 14, "TR", Black, Bold], {10, 22}]}, 
 ImageSize -> 19]

The bar crops some of the text:
enter image description here

magento2 – issue in placing an order through Amazon pay in magento 2.3.5 version

When i place an order through amazon pay I got below error of getAmazonOrderReferenceId null.

Fatal error:  Uncaught Error: Call to a member function getAmazonOrderReferenceId() on null in /vendor/amzn/amazon-pay-module/Plugin/ConfirmOrderReference.php:106

anyone have an idea about this please let me konw.

unity – Placing Zones in Cities Skylines

I’m trying to build a mod that places zones on a keypress. How would I accomplish this?

So far I’ve detected the keypress. But when I modify m_blocks in ZoneManager by calling block.setZone(x,y,zone) The block appears to have changed, but only for the moment. When I run the keycommand again, the data appears to have been reset. I never see the zone change in game, only when I print it to the console.

string outtext = "";
            uint blockCount = Singleton<ZoneManager>.instance.m_blocks.m_size;
            outtext += "start{n";
            for (int index = 0; index < blockCount; index++) {
                var block = Singleton<ZoneManager>.instance.m_blocks.m_buffer(index);
                if (block.m_valid != 0) {
                    block.SetZone(1, 1, ItemClass.Zone.Industrial);
                    block.RefreshZoning(0);
                    outtext += " valid:" + block.m_valid + " position:" + block.m_position.ToString() + " zone:" + block.GetZone(1, 1) + " n ";
                }
            }
            outtext += "}";
            Debug.Log("OUTTEXT " + outtext);

I’ve tried calling block.refreshZoning() as well, but I’m not sure how to calculate the blockid :(.

time complexity – Minimize shadows placing light sources on a diagram of a room

I’m a CS student and came upon this problem:

Given a diagram of a room with obstacles in it (like walls or furniture), find the 4 best places to put light sources in it so the room has the most light possible, or you can think of, minimizing the amount of shadow in the room.

In other words, if you have 4 sources of light, which are the best places to put them so your room has maximum light (or minimum shadow).

I’ll append an example of a diagram so the problem can be better understood: example of a diagram

The solution I thought was to find the spot with most light and from there find the second one and so on. But something makes me think that it may exist a configuration which is better that doesn’t need to be the best from the beginning, kinda feels like a special case of the knapsack problem, if so I’d think of implementing a greedy algorithm or using genetic algorithms to give an approximation of the best places.

I’m not sure if it’s a math or a CS problem. I’d be grateful if at least someone points me in the right direction so I can do a better research, thank you very much!

blocks – Placing a programatically created menu

I’m creating a menu programatically using this code

$this->menu = $this->entityTypeManager->getStorage('menu')->create(
    (
      'id' => $properties('id'),
      'label' => $properties('label'),
      'langcode' => $properties('language'),
      'status' => TRUE,
    )
  );
  // Save the menu.
  $this->menu->save();

When visiting the block ui I see the block is already created. It appears that I do not have responsibility for creating this block, although I don’t seem to be able to load the block straight after creation of the menu. I need to place this block in a specific region programatically. What would be the preferred method of doing this be?

website design – Placing CTA in left or right side?

A research conducted by the Nielsen Norman Group in 2017, used eye-tracking to examine where do people focus their attention most frequently when carrying out web-based tasks on a 1920×1080 monitor. There were more than 120 participants and their findings showed that 80% fixated on the left half of the screen.

Those findings were in agreement with a similar study of theirs done in 2010 for a 1024×768 monitor.

Keep in mind the above relates to the reading patterns in the western world, in which case aim for the most important content that you want your users to take action on to be located on the left half of your website, and secondary or non-priority content (e.g. the image) on the right.

enter image description here
This figure was reproduced from the Nielsen Norman Group study in 2017.

dnd 5e – Can I make misty step before placing bag of holding inside another bag of holding opens the gate to the Astral Plane?

The question is if placing bag of holding inside another bag of holding opens the gate to the Astral Plane (which was discussed here: Is it possible to stuff a Bag of Holding inside another Bag of Holding?),
then – can I make misty step before the gate has opened? For example a character runs toward the monster, puts bag of holding inside bag of holding and makes misty step before being sucked through this gate?

Here we assume that bag of holding is “similar item” from its description (as suggested in the answer above).