search – Exract all node field values to json including reference entities with value

I am writing a module to export drupal’s content to another platform, the module provides a UI to manage content types and their fields to be shared on another platform via API.

So far i have managed to get node field values using this sample code

$nid = 4951;
$node = Drupal::entityTypeManager()->getStorage('node')->load($nid);
$data = ();
foreach ($node->getFields() as $name => $field) {
  $data($name)  = $field->getString();
}

the $field->getString(); however do not provides reference entity values and only provide ids.

The out of the above code is like:

{"nid":"4951","uuid":"0fae7e9b-d860-43f0-9559-a8bd6bab22b7","vid":"1272611","langcode":"en","type":"article","revision_timestamp":"1612303794","revision_uid":"1166","revision_log":"","status":"1","uid":"866","title":"xyz Chapter April Update","created":"1555961981","changed":"1612303794","promote":"0","sticky":"0","default_langcode":"1","revision_default":"1","revision_translation_affected":"1","moderation_state":"published","scheduled_transition_date":"","scheduled_transition_state":"","metatag":"","path":"/wisconsin-chapter-april-update, 17276, en","menu_link":"","body":"some this here, rich_text","field_article_author":"Wisconsin Chapter","field_article_chapter":"541","field_article_endnotes":"","field_article_questions_cta":"1","field_article_recommendation":"","field_article_recommended_link":"","field_article_related":"","field_article_related_link":"","field_article_resource_download":"","field_article_subhead":"Here's the latest news from the abc.","field_article_thumbnail":"","field_article_type":"news","field_blog_section":"","field_meta_tags":"","field_tax_article_type":"24, 28, 45","field_tax_audience":"","field_tax_breadcrumbs":"","field_tax_content_format":"50","field_tax_disease":"55, 56, 57, 58","field_tax_ga_type":"","field_tax_research_type":"","field_tax_topic":"90, 91, 92, 93, 94, 108, 109, 111"}

Scroll last and see for example field_tax_topic

Is there a direct or indirect way of automatically detecting reference entity field and extracting its values, also it should be dynamic solution and that must work with new field types as well.

Any pointer or direction to do it in the right way will help!

AcroServers.com: Spanning the Globe (37 Locations Around the World Including North America, South America, Asia, Europe, Africa, and Oceania)

Some of you may remember the ABC Wide World of Sports intro which pronounced they were “spanning the globe to bring you constant variety in sports”.  AcroServers isn’t sports programming, but they are spanning the globe to bring you a VM in your neck of the woods (or someone else’s, if that’s what you want).

  • Europe: 20 locations from Amsterdam to Zurich
  • North America: 10 locations from Atlanta to Washington
  • South America, Asia, Oceania, Africa: Yep, all covered

They’ve got 37 locations worldwide including many less-common locations so if you can’t find a provider in a geography you want, check out their locations.

AcroServers is a Polish company, registered in their homeland (NIP: 6871971968). Their Terms of Service is available on their web site. They accept PayPal, BitCoin, Credit Card.

Here’s a little about AcroServers in their own words:

We offer instant activated VPS Cloud worldwide, 1Gbit/s (37 locations), 2Gbit/s (20TB bandwitch) and VPN services. Starting from 5EUR with already 1Gb/s. Our goal is to provide secured VMs and our policy is all about your privacy.

Remember that the LEB community would love to hear about your experience in the comments section below!

Now read more to see the offers!

VPS 1

  • 1 CPU
  • 512 MB RAM
  • 10 GB SSD
  • 1 Gbps (shared)
  • 500 GB transfer
  • 5.00EUR/month
  • Cloud/KVM
  • Coupon: lowendtalk
  • (ORDER)

VPS 2

  • 1 CPU
  • 1GB RAM
  • 30 GB SSD
  • 1 Gbps (shared)
  • 1.5TB transfer
  • 10.00EUR/month
  • Cloud/KVM
  • Coupon: lowendtalk
  • (ORDER)

VPS 3

  • 2 CPU
  • 2 GB RAM
  • 40 GB SSD
  • 1 Gbps (shared)
  • 2TB transfer
  • 15.00EUR/month
  • Cloud/KVM
  • Coupon: lowendtalk
  • (ORDER)

VPS 4

  • 4 CPU
  • 2 GB RAM
  • 20 GB SSD
  • 1 Gbps (shared)
  • 2.5 TB transfer
  • 20.00EUR/month
  • Cloud/KVM
  • Coupon: lowendtalk
  • (ORDER)

VPS 5

  • 2 CPU
  • 4 GB RAM
  • 20 GB SSD
  • 1 Gbps (shared)
  • 2,5 TB transfer
  • 20.00EUR/month
  • Cloud/KVM
  • Coupon: lowendtalk
  • (ORDER)

VPS 6

  • 4 CPU
  • 4 GB RAM
  • 80 GB SSD
  • 1 Gbps (shared)
  • 4 TB transfer
  • 35.00EUR/month
  • Cloud/KVM
  • Coupon: lowendtalk
  • (ORDER)

NETWORK INFO:

  • https://acroservers.com/locations

HOST NODE INFO:

Please let us know if you have any questions/comments and enjoy!

raindog308

I’m Andrew, techno polymath and long-time LowEndTalk community Moderator. My technical interests include all things Unix, perl, python, shell scripting, and relational database systems. I enjoy writing technical articles here on LowEndBox to help people get more out of their VPSes.

How to generate Code cell including newlines

I want to programmatically create a "Code" style cell with commands separated by ; and a new line (from some list). Say for example I have a list {set(a,1),set(b,2),...} I would like to create the cell.

a=1;
b=2;
...

This can almost be done by following the answer to a similar question here, and replacing "Input" with "Code". I find that CompoundExpression@@{a,b,...} does show as a;b;..., as I would like, but I don’t know how to add the appropriate newlines.

REST API is protected by HMAC based authentication. What does including URL path in the message protect from?

I have came across a REST API for some commercial software, that checks authentication by requiring HMAC on concatenation of

  • http_method (GET, PUT, etc)
  • timestamp
  • payload (body of a POST / PUT request if any)
  • path (everything between https://domain.tld and the first question mark)

This HMAC then is passed in a request header.

What does this scheme protect against by including the path?

Does including a Konami-code triggered Easter Egg negatively impact keyboard accessibility?

On an open-source project I’m involved in, one of our devs added a mini-game for April Fools Day, which could be opened and played by pressing the Konami Code sequence on your keyboard (up, up, down, down, left, right, left, right, B, A, enter).

In a GitHub issue, we received a complaint about the game, which included this line:

… but I hope the Codidact team would have the decency to acknowledge that such “easter eggs” can be disastrous to users with mobility impairments who use the keyboard to control the mouse, and promise to not allow such “easter eggs” in the future.

A couple years ago I spent some time using the keyboard and not my mouse, and personally never had a problem with accidentally triggering something with the Konami Code, because it’s not a sequence that – in my experience – is likely to be typed accidentally. It’s hard to get such a specific sequence if you’re not trying.

However, since I’m not an expert on this topic, I figured it’d be worth it to confirm one way or the other: Is having a Konami Code Easter Egg an accessibility problem, from a keyboard-user standpoint?

user research – What’s best practice for including correct answers in tree tests?

Let’s say I’m creating a tree test to validate my IA for a grocery shopping website. When I’m creating the tree, I’m wondering if I should include the target in the tree, or stop the tree at the next highest category. For instance:

If I want the customer to locate cucumbers. My tree might look like:

Vegetables > Green vegetables > Cucumber

Should I include cucumber in the tree, or should it stop at green vegetables?

My concern with including cucumbers is the participant might just search through until word association kicks in, while stopping it at green vegetables might make them think more critically about it.

Would appreciate your thoughts!

design process – Should I cover every single user flow including error states in wireframes for web and mobile applications?

While creating wireframes, I mostly create the obvious screens and flows, and leave out all the micro flows like error states or less important screens. These are then fleshed out when creating the high-fidelity prototype. But due to this, I often end up missing screens that the developer then has to work with me on to build out. In some situations we miss out on the screen entirely resulting in users winding up in dead ends.

One way I thought to solve the problem was to create detailed task flows and then using the task flows as a reference to create wireframes that cover every single flow. But my concern is that this is going to end up being an unnecessarily time consuming effort.

Have you followed this process and seen good results?
Is it worth the extra time?
Can I just create detailed task flows and skip creating detailed wireframes and go directly to the low-fidelity mockup? (will still wireframe high-priority flows)

Any advice is appreciated. Thanks in advance.

Including point heat sources in a 2D transient PDE heat equation

I want to be sure that I included the point heat sources correctly in my PDE.
The result should be:
enter image description here

I wrote:

q0 = 1;
Subscript(Q, 0) = 
  q0*(DiracDelta(x - x1)*DiracDelta(y - y1) + 
     DiracDelta(x - x1)*DiracDelta(y - y2)*DiracDelta(x - x2)*
      DiracDelta(y - y1) + DiracDelta(x - x2)*DiracDelta(y - y2));
heqn1 = Subscript(k, 
    CLS)*(D(Subscript(T, D)(x, y, t), x, x) + 
      D(Subscript(T, D)(x, y, t), y, y)) + Subscript(Q, 0) == 
  Subscript((Rho), CLS)*Subscript(Cp, CLS)*
   D(Subscript(T, D)(x, y, t), t)

I haven’t considered the time-dependency for the heat source just yet to simplify the notation.
Thank you in advance!

posts – OrderBY meta_key_value including null value

I am trying to do a simple query in wordpress ordered by a meta_value_num of a custom field, the problem is that not all the inputs have a value so it gives me a null value and it does not show very well in the query, it only shows the ones that have value, i have this code:

 <ul class="post">
                <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
                $args = array(
                    'post_type'   => 'post',
                    'paged'       => $paged,
                    'meta_key'    => 'votes_count', 
                    'orderby'     => 'meta_value_num', 
                    'order'       => 'DESC',
                    'post_status' => 'publish'
                ); 
                $the_query = new WP_Query( $args );
                if ( $the_query->have_posts() ) :
                    while ( $the_query->have_posts() ) : $the_query->the_post();
                        get_template_part( 'public/partials/template/loop' );
                    endwhile; ?> 
                    <li class="numeration">
                        <div class="paginavi">
                             <?php YESPLEASE_Add_Theme_Support::yesplease_pagination(); ?>  
                        </div>
                    </li>
                <?php endif;?>                  
            </ul>

I would appreciate your answers

c# – MultiLingual Project including routing

One of my staff wrote this application in .netCore 3.1 about 18months ago. It works “to a certain extent” but I feel like its bloated and perhaps isn’t the best way. I work somewhere were all our applications need to be bilingual and just about every tutorial you will see localises the ui but never the routing.

The application works, as I’ve indicated but there are a number of limitations which I feel make it rather inefficient. Things like the ‘ (TranslatedRoute(“en”, “home”))’ decorator which will not allow me to use a Resource. Also, every single Action needs to be unique, ie, I cannot use List as an Action on every controller, it needs to be unique and so we’ve been doing List-Entityname for the routing but I find this limiting. It also makes stubbing out new controllers longer and more prone to errors.

Here’s an example from my startup.cs

       app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute("default", "{culture=en}/{controller=home}/{action=index}");
            endpoints.MapDynamicControllerRoute<TranslationTransformer>("{culture}/{controller=home}/{action=index}/{id?}");
        });

I put together a very, very simplistic .Sln which i have linked to below, it has some working routing on the home page and I added an ‘Admin’ section with 2 controllers. Already at this point, i lose control of the routing and the application reverts to using the action names instead of the routing I have added.

My goal is simply to develop and smart template for spinning up a new Multilingual Website whenever needed.

If I have somehow missed the one tutorial that indicates how to do all this already, in at least .NetCore 3.1, please let me know and I’ll stop trying to reinvent the wheel.

Otherwise, please see my simple project here – Link to GitHub

Note, this is my first time publishing a public Project to GitHub.