8 – Option to set comments to Hidden on an individual piece of content (node), even when it has no comments

Drupal 8 and Drupal 9 comment fields provide three settings for the default, as configured at for example /admin/structure/types/manage/article/fields/node.article.comment:

The default value for this field, used when creating new content.

Comments

Open Users with the “Post comments” permission can post comments.

Closed Users cannot post comments, but existing comments will be displayed.

Hidden Comments are hidden from view.

But when creating or editing a node, the only options for comments are “Open” or “Closed”.

Oh. Oh. Ok.

If there are comments on a given node, only then is the hidden option shown when editing that node.

Unfortunately, ‘Hidden’ also hides the “Comments” title, but ‘Closed’ does not— they do not have identical effect on content without comments.

OK so 99% of the time setting comments to ‘Hidden’ by default going to work great (neither ‘Closed’ nor ‘Open’ radio button are selected in the node’s Comment settings), but then someone will hit the radio button to mark comments as ‘Closed’ for that content type, and then the heading “Comments” will appear, and there is no way to fix this through the UI.

The programmatic problems caused by this were addressed in Removal of “Hidden” option in comment settings form may break programmatic form submissions (#1181750) | Drupal.org.

The fact that having both hidden and closed on the default field form sets an incorrect expectation for the individual piece of content settings form was at least mentioned in Make comment settings form more usable (#989452) | Drupal.org.

But the fact that different options can and do behave differently when, even when there are no comments, has not been brought up.

Before i create or update an issue on drupal.org, am i missing something? Is there a way to ensure that ‘hidden’ and ‘closed’ truly do work exactly the same when there are no comments yet?

numbers – How to color code individual data points in line chart

This is a question about using charts in Numbers and color coding individual data points in a series.

I have two series of data (blood pressure readings) that I plot in a chart. The series may contain multiple readings made at different times on a day, or there may be a single reading.

Is there a way to color code the data points in each series to indicate which part of the day the reading was taken? e.g. 6am-10am = purple, 10am-2pm = orange, 2pm-6pm = blue, etc.

The reason I want to do this is to distinguish between readings taken before and after taking medication.

Here's the chart

Relationship between an existing Household and a new Individual not added using civicrm webform

When trying to add a new CiviCRM Contact of type Individual through a webform to a existing Household, the required Relationship is not created, although it is set up on the CiviCRM setting of the webform.
enter image description here

The existing Household is selected using the “Existing Contact” field of the civicrm webform.

When trying for the second time, the relationship between the Household and the Individual is correctly added.

Any idea what might be happening? I’m working with Drupal 7.80 and CiviCRM 5.36.1.

Thanks in advance.

postgresql – Why is my database 5 times larger in size than all the individual files combined?

I have 1000 csv files that have a total size of 200 MB.

When I import these files into a new database table, the final size is 1 GB.

Why is this happening, and how do I reduce the size of my database?

I’ve tried using data type constraints to the columns such as using integers instead of varchar where possible, but it doesn’t seem to reduce the size to anywhere near 200 MB.

I’m using Postgres 10.

Adding individual users to a chat channel in Odoo

I use Odoo 14.0 .

I created a chat channel for all my Odoo users.

Still, not all user can see this channel, and I do not find an add user button in the channel administration.

https://www.odoo.com/forum/help-1/chat-in-channel-not-displayed-158887

says that with some SQL magic I could solve this but I do not have access to the database. And at all, this should be an easy thing to manage the users of a channel.

How can I do this in Odoo?

Individual bit access in C

Im not that good at C, so go easy on me, but I wanted to be able to have individual bit access in C without using a ton of functions to do bit manipulation on a uint8_t. Tell me where I could improve upon it

#include <stdio.h>

#pragma pack(1)
union bit_array {
    struct {
        unsigned char b8:1, b7:1, b6:1, b5:1, b4:1, b3:1, b2:1, b1:1;
    } bits;
    unsigned char value;
};

int main() {
    // Creates char with binary value 11111111
    union bit_array test = { 1, 1, 1, 1, 1, 1, 1, 1 };

    // Displays 11111111 (255)
    printf("%un", test.value);

    // Sets 8th bit of binary value to 0
    // 11111111 (255) -> 11111110 (254)
    test.bits.b8 = 0;

    // Displays 11111110 (254)
    printf("%un", test.value);
    
    return 0;
}

Cognito Forms: Selecting Individual Items From an Array

I have created an array, using the .Split() functionality, I would like to now reference each item (it I believe) in that array, specifically.

How do I achieve that?


The rest of this you don’t need to read, but I’ll try to provide more information.

I am now going to use an example of something that I might like to do, this is not literally all I want to do.

So. Let’s say a user has input the following data in to the ‘Inputta‘ field:

aaa#bbb#ccc#ddd#eee#fff

Now, in the ‘Arraya‘ field, I have:

Inputta.Split("https://webapps.stackexchange.com/#")

Let’s say I would like to select the “ddd” entry in that array, how would I do that?

I’ve tried using the .Where() functionality, eg: “.Where(ItemNumber = 4)“, but even if that did work (it doesn’t), it would be no use for if I need to be iterative.

I’ve tried to play with the .Select() functionality, but that’s not helpful, either, as I can’t find decent information on how it even works.


So, on to that iterative tip, to build on this example, I have a secondary requirement of the form, which is to pick an item from the array from an incremented integer.

We’ll imagine I know how to increment an integer, and have that information already, either in a separately generated .Split() field, or as an integer calculation in a Repeating Section.

How would I use the integer to find the array entry in the ‘Arraya‘ field?

Basically, how would I select item 1 (from the second array), then item 2, etc?

This isn’t a separate question, I’m just explaining further the requirement.


As an addendum, I’d love to know how to create an array of incremental integers leading to a pre-determined max number. 😉


For the record, I have StartPaged this thoroughly.

  1. I can’t find a full reference chart for the functions available anywhere online.
  2. The list on CF only lists a subset of the available functions (for example, the .Select() array functionality is not listed)
  3. Everywhere else appears to handle other specific functions.

None of that is stated to cast any disdain anywhere, purely to indicate that I have looked, perhaps my StartPage Fu is just not that strong. Either way, apologies for asking here.

magento2 – Css files for individual pages(home/product/category/user profile/login)

I’m looking to create a theme from scratch and what I want to do is create .css files individually for each individual page and only load them specifically for that given page.

I believe this is the best option to optimize a page rendering’s speed, correct me if I’m wrong.

What is the correct way of including each of these files for the given pages?

home/product/category/user profile/login/checkout

home.css | product.css | category.css | etc..

If I missed a component please let me know.

Thank you!

plugins – CMB2 repeatable individual field data to array

I have a single repeatable text field with the tag 'repeatable' => true, which works in the backend. This is the field and the box:

/**
 * Initiate the metabox
 */
$details = new_cmb2_box( array(
    'id'            => 'details_box',
    'title'         => __( 'Details', 'cmb2' ),
    'object_types'  => array( 'packages', ), // Post type
    'context'       => 'normal',
    'priority'      => 'high',
    'show_names'    => true, // Show field names on the left
    // 'cmb_styles' => false, // false to disable the CMB stylesheet
    // 'closed'     => true, // Keep the metabox closed by default
));

$details->add_field( array(
  'name'    => 'Bug Fixes',
    'id'      => 'bug_fixes',
  'desc' => '<ul class="instructions-list"><li>Add bug fixes here.</li></ul>',
    'default' => '',
    'type'    => 'text',
  'options' => array(
    'add_row_text' => 'Add',
  ),
  'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
));

However, the metakey bug_fixes save some very weird data. In the database it looks something like this:

a:3:{i:0;s:14:"Fixed some bug";i:1;s:32:"Fixed bug causing incorrect data";i:2;s:25:"Did not fix this sadly ;(";}

What is this 😅? This is no normal JSON for some reason… I need to get a PHP array out of this, but couldn’t find any documentation.

8 – How to control placement of individual fields when theming content type node add / edit form in Twig?

I am trying to theme out the node add/edit form for a custom content type (ex. ‘album’). I have created a form_alter hook in my theme

function mytheme_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {

  switch ($form_id) {
    case "node_album_form":
      $form('#theme') = ('node_album_edit_form');
      break;
  

that correctly intercepts the node add/edit form and passes it to my theme hook which also finds the correct twig template.

function mytheme_theme() {
  return array(
    'node_album_form' => array(
    'template' => 'node_album_edit_form',
      'path' => Drupal::theme()->getActiveTheme()->getPath() . '/scss/templates/album',
      'render element' => 'form'
    ),
  };
}

in my twig file, ‘node_album_edit_form.html.twig’, I can confirm that changes here alter only the album add/edit form and that I can remove elements, ex:

{{ form|without('advanced', 'footer', 'actions') }} 

What I cannot do but would like to is place the form fields where I want them, ex:

<div class='myfancydiv album-title-field'>{{ field_album_title }}</div>
<div class='myfancydiv album-artist-field'>{{ field_artist }}</div>

because I’m not using the right reference to the field. I’ve tried:

{{ field_album_title }}
{{ form.field_album_title }}
{{ album_title }}

to no effect. Anyone have a working example of this?