texts: How can I change item->quantity in rule (Commerce Kickstart)

texts:
I would like to evaluate line_item -> quantity before line_item is saved.

I've created a rule firing on "before line item saved" event.

I've added 2 actions:

Action variable_add (evaluating desired quantity of line item)
Action data_set. Setting data to commerce-line-item:quantity from variable, created in the first action

I'm always getting Rules evaluating log. This is an excerpt:

  0 ms Rule Evaluate quantity fires.

  0.497 ms Evaluating the action variable_add. [edit]

  0.736 ms Added the provided variable variable_added of type decimal [edit]

  1.968 ms Evaluating the action data_set. [edit]
     69.962 **ms *Unable to modify data "commerce-line-item:quantity": Invalid      data value given. Be
  sure it matches the required data type and format*.

  72.107 ms Unable to evaluate action data_set. [edit]**

  72.286 ms Rule Evaluating quantity has fired.

How to fix this error?

May I use substitutions (e.g. [commerce-line-item:quantity] etc) in PHP evaluation in 1, 2 actions? May I call functions (e.g. drupal_set_message() etc)?


texts: How to set default form fields value from controller

texts:
How to setup default form fields value from a form created in a controller?

I tryed to set the $form_state param but it does not work.

...
$form_state = new FormState();
$form_state->set('myfield_1', 'car');
$form_state->set('myfield_2', 'bus');
$form = $this->formBuilder->buildForm('Drupal\mymodule\Form\MyForm', $form_state);
return $form;


texts: Getting the logged in username and email in a view

texts: Im trying to get the logged in users username and email adress to display in a view is that possible?


texts: menu_get_active_trail returns page not found

texts:
I want to add a meta description to a custom module 'mymodule', but this doesn't load as expected.
The problem is in the active trail, when menu_get_active_trail is called inside array 1 the router_path = node/% and the title is page not found.
How can the active trail be fixed?
This works on other sites.

function mymodule_html_head_alter(&$head_elements) {
// menu_get_object with load function at position 2

if ($myentity = menu_get_object('myentity', 2)) {
  dpm(menu_get_active_trail());

  $head_elements['meta_description'] = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'description',
      'content' => $myentity->name,
      ),
    );
  }
}


texts: How to work with caching and conditional rendering in a template?

texts:
I've added a custom module function to allow the is_front conditional to work inside of a block template. The purpose is to display the site slogan on the homepage, but not across the rest of the site. The rule works correctly, but the site's cache is causing it to render incorrectly. If I clear the cache from the front page, the slogan displays sitewide. If I clear the cache from another site page, then the slogan doesn't display on the front page.

I'm presuming it is because the block's display is being cached in some way. Is there a simple way around this other than adding a second instance of the block?


texts: How do I use a contextual filter to find all nodes with field_abc that has a null value?


texts: How to list members in a group using views Drupal 7?

texts:
I am using Profiles 2 and Organic groups.

I was successful in listing users via views > Users.

I am using "profiles 2" module to collect and store details of users rather than the core drupal user management.

I have created few groups using "organic groups" module.

My question is how to list all the "PROFILES" (created via profile2 module) of members belonging to a group using views ?


texts: How do I use PathMatcher::matchPath() for a wildcard path?

texts:
I am trying to use PathMatcher::matchPath() to match a string of paths using a wildcard pattern.

I'd like to match any path containing /topic* so if the path matches, I'd like to add a body class for pages that have /topic, /topic/foo, /topic/bar, etc..

The code I am using is the following.

function mytheme_preprocess_html(array &$vars) {
  // Define the current path.
  $current_path = \Drupal::service('path.current')->getPath();
  // Define the pattern using a string.
  $patterns = "/topic/*";
  // If the path matches the pattern.
  if (\Drupal::service('path.matcher')->matchPath($current_path, $patterns)) {
    $vars['attributes']['class'][] = 'is-topic';
  }
}

The code doesn't work to match this pattern so no class is added when I am on any of these pages.

My Xdebug info is as follows for the page that has the path topic/review-procedures

$current_path = /node/62
$path_alias = topic/review-procedures

Note that some pages with /topic/ in the path will not be nodes however, that is why I am trying to do the path matching.

Am I correctly using PathMatcher::matchPath()?


texts: How to increase the maximum upload size?

texts:
I'd like to increase the maximum upload size from 2MB to 5MB on my website (I'm using WAMP). My first attempt to do this was to set Content types > MY CONTENT TYPE > Manage fields > MY IMAGE FIELD > Maximum upload size to 5 MB, but that didn't work. Next, (after reading this question and this article) I added

ini_set('post_max_size', '5M');
ini_set('upload_max_filesize', '5M');

to my sites/default/settings.php file, but that didn't solve the problem either.

What am I doing wrong? Why didn't my first approach work?


texts: Get domain logo in views (using Domain Access module)

texts:
I'm using Domain Access module and I have different logo for each domain. I have setup logo for each domain in domain theme settings.

I have view which lists all the domains (over relationship with user profiles, because each user has it's own domain), but I'm not able to display the logos for each domain.

Is it possible to get the domain logo in views?


texts: grouped paragraphs by field not filtering to current language

texts:
I have a D8.9 multilingual site. I need to group paragraph elements, as well as filter them by page language and Content ID. But my language filter don't seem to work.
I have content type "services."
"services" contains a paragraph field, "components" with 3 fields inside.
One of the fields in "components" is a taxonomy reference "types" -  this is what I need to group the paragraphs by (sometimes)
I've created a View of 'Services', placed as a block on any "services" page.
The view has a contextual filter of Content:ID, pulled from URL.
It also has a relationship "field_components: Paragraph" so that I can access the specific paragraph fields.
It also has a filter "Content: Translation language (= Content language selected for page)" - because we have 5 translations of the site. (and translation is set within paragraph fields - not on larger paragraph field within "services" content type)
But when I view the service page, it pulls every single translated version paragraph - despite the translation filter.
Let me know if there are further details needed, and I'll edit the question accordingly.


texts: I have a feature that I copied from site A to site B. Site B is created using a profile install based on site A. Now I have to enabled a feature that I copied from A to B but whenever I enable this feature I always "overrides". I revert to the feature but it's always overriding. It's usually the field_base portion that has overrides. I have more than one feature that does this.  I dont want to recreate using DB settings. I want the feature settings. Any help would be appreciated. Thanks.


texts:
I'm trying to create boolean field that displayed as checkbox:

function createBooleanField($name, $label, $bundle, $required=FALSE, $defaltVal=0){
    if(!isValidField($name)){
        return;
    }

    // Create the field base.
    $field = array(
        'field_name' => $name,
        'type' => 'list_boolean',
    );
    field_create_field($field);

    $instance = array(
        'field_name' => $name,
        'cardinality' => 1,
        'entity_type' => 'node',
        'type' => 'list_boolean',
        'label' => $label,
        'bundle' => $bundle,
        'required' => $required,
        'widget' => array(
            'type' => 'options_onoff',
            'settings' => array(
                'display_label' => true
            ),
        ),
        'settings' => array(
            'allowed_values' => array(
                '0' => 'No',
                '1' => 'Yes',
            ),
        ),
    );

    $instance['default_value'] = array(
        0 => array(
            'value' => $defaltVal,
        ),
    );

    field_create_instance($instance);
}

After I create a content type (of type $bundle) and display it in view in a table I see the values as 0-1 instead of 'Yes' - 'No'.

After I'm goign to  admin/structure/types/manage/MY_CONTENT_TYPE/fields/MY_BOOLEAN_FIELD
and insert it manualy :

Only there it works.
What I'm doing wrong in my code?


texts:
I'm new to drupal, I'm trying to change the link structure and still did not get.

For example, when I create a basic page, it uses a standard link "node/drux"

but I want the link to be the title of the page, without having to create an alternative URL.

How can I change this structure?


texts: How can I remove the "edit" link on this page on the manage menu page (Structure > Menus > My menu > List links)?


texts: How to show "Log in or register to post comments" message when no comments on content?

texts:
The "Log in or register to post comments" message does not display when there are no comments on a piece of content.

However, it does show when there is at least one comment.

Looking in the comment module code, the "Log in or register to post comments" message is in the code that only runs when there are already one or more comments!

How dumb is that?! Is there a module or an existing approach to making this display when there are no comments?

I can write a hook in my own module to override this but it might be re-inventing the wheel if it's already been done.


texts: Installed TCPDF and encountering PHP Fatal error: Cannot use object of type REPORT_PDF as array

texts:
I am using Drupal version 7.18 and have installed TCPDF package in my library under /var/www/html/drupal-sites/all/libraries

Everything is working well for my generated pdf report.

However, when i open /var/log/php.log on my server, i found errors which was generated everytime i click to generate the PDF report on my site:

  PHP Fatal error: Cannot use object of type REPORT_PDF as array in /var/www/html/drupal-7.18/includes/form.inc on line 799

I am not sure what is happening. It has flooded my log file.

REPORT_PDF was an object in the function:

$pdf = new REPORT_PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

NEW INFO AFTER CHANGING hook_menu() TO REMOVE drupal_get_form():

  PHP Fatal error: Cannot use object of type REPORT_PDF as array in /var/www/html/drupal-7.18/modules/block/block.module on line 269

I am not sure what is happening. It has flooded my log file.

In my .module file:

$items['report/download/nih_pdf/%'] = array(
  'title' => NIH PDF',
  'page callback' => 'nih_pdf',
  'page arguments' => array(3),
  'file' => 'staffreport_pdf.inc',
  'access callback' => 'nih_login_access',
);

and in my .inc file:

function nih_pdf($arg1) {

if (!class_exists('TCPDF')) {

include_once(libraries_get_path('tcpdf') . '/tcpdf.php');
}

$pdf = new REPORT_PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('FP System');
$pdf->SetTitle('NIH Report');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array('freesans', '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array('freesans', '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$pdf->SetFont('freesans', '', 10);

$pdf->AddPage();
$pdf->setPrintHeader(false);

$txt = <<

//HTML data displayed as string

EOD;
$pdf->writeHTML($txt, true, false, false, false, '');

ob_end_clean();
//Close and output PDF document
$pdf->Output($staff_num.'_NIH.pdf', 'D');

$pdf->Close();

return $pdf;
}

class REPORT_PDF extends TCPDF {

//Page header
 public function Header() {
 $this->SetY(15); //use in place of logo
 $this->SetFont('freesans', 'B', 16);
 $this->Cell(0, 15, 'NIH REPORT', 0, false, 'C', 0, '', 0, false, 'M', 'M');
 }

// Page footer
public function Footer() {
$this->SetY(-15);
$this->SetFont('freesans', 'I', 8);
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().' of '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
 }
}

Hope somebody can assist.
Thanks!


texts: Using php command to pass custom php.ini values into drush phar

texts:
I'm struggling with adding php values into drush.phar. Last time I installed drush I used composer and for that method I could add the php.ini values into the drush.ini, but with the new way to install the drush.phar, the drush.ini doesn't seem to be supported. I've been trying to use the new method of adding php values into the drush.phar, but either it doesn't work or I am doing it wrong. Here's an example of what I tried:

php -d memory_limit=256M /usr/local/bin/drush --php-options=memory_limit=256M

When I try something like that it just gives me the drush help so I'm assuming I've got something wrong.

Here's the example from the drush docs:

php -d foo=bar drush.phar --php-options=foo=bar

I'm not familiar with using the php command, but I guess I can just go back to using composer if I am not able add a few php values to the drush.phar this way. I also need to add open_basedir with an empty value since I need my php.ini to use open_basedir. I'm not sure how this php command is suppose to handle empty values.

Hoping someone has been able to do this.


texts: Error : No eligible views were found. Create a view with an Entity Reference display, or add such a display to an existing view

texts:
I cannot work out some basic stuff ... what do I not correct?
Using D8, distribution varbase.

I  would like to create a reference from one content type to antoher in D8 so a user is able to use a select box by module chosen (https://www.drupal.org/project/chosen)

I looked up different post but cannot find the problem. The latest QA is followed is: How to create a select box field to select from a filtered list of articles?
or also this post How to create a view type of Entity reference display?

So I did I create a view

- Add Display Entity Reference
- Format:Entity Reference list | Settings with content: title
- Show:Entity Reference inline fields | Settings with content title.

Then I add some fields as well. The result is a list of education
Clear cache, did drush CR.

I goto to the content type I would like to have the reference (e.g. student).
Add a field and would like to add this view a a selectbox to object student.

I should be entity reference the in the reference field I select Views with a filter reference. But every time I get the message here...

No eligible views were found. Create a view with an Entity Reference display, or add such a display to an existing view.

The view list displays:
Nascholingsactiviteit voor leden  - Entity Reference Source

I made another view for testing purposes but no result of that as well.

I tried other fields but i cannot get it working. I though this is all in D8 core now... Any suggestions?


texts: Guard/LiveReload/Sass/Compass CSS Caching Issue

texts:
Here is a quick primer on my setup.
Running an aurora sub theme that utilizes guard, guard compass, guard livereload.
Basically what is happening is I make a change in a sass file, the files compile and the style change is shown right away on the browser. Great.
The problem arises when I click a link to go to another page, the CSS that is on the newly visited page is from the previous state. So my test cases are.. change the background color from blue to red. Background changes to red on the screen. Click a link to another node, background remains blue. Simple browser refresh, background turns to red.
I've been trying to find some info on this specifically, but having a heck of a time.
Things I've tried so far

Turn off sass caching in my config.rb file, so no .sass-cache generation {:cache => false}.

Reference my stylesheet via a hard coded entry in the html.tpl.php template instead of via the info file.

Tried a basic 2 .html page test case, nothing to do with drupal, and I get the results I wanted (no css cached).

I've even looked at Chrome settings before really deciding I felt this is a Drupal thing.

I made a color change, watched the result in my browser, went into the sites/default/files/css/ directory and deleted all the css files, went back to my browser and clicked on a link to another node, and the same result happened, previous CSS rendering.

Did the same thing above except instead of deleting CSS files from the folder, I just ran a drush cc css-js in terminal, then went and visited the second node link, and still old CSS renders.

I have not implemented this, but I know I can run drush commands via guard shell and was wondering if I can do the above in 6, just automate it.

Messed around with config.rb settings such as debug, line_comments, environment or production variables, etc.

I am running out of ideas on how to get this to work a bit better.
Any suggestions?


texts: What is the difference between core.entity_form_mode and core.entity_form_display?

texts:
I'm trying to learn how to configure content types and form modes programmatically in Drupal 8. I've created the following using the UI:

A content type named book
A form mode for content, named foo
A view mode for content, named bar

When I run drush cget, I get this list:

...
[36] core.entity_form_display.node.book.default
[37] core.entity_form_mode.node.foo
[38] core.entity_form_mode.user.register
[39] core.entity_view_display.node.book.default
[40] core.entity_view_display.node.book.teaser
[41] core.entity_view_mode.node.bar
[42] core.entity_view_mode.node.full
[43] core.entity_view_mode.node.rss
[44] core.entity_view_mode.node.search_index
[45] core.entity_view_mode.node.search_result
[46] core.entity_view_mode.node.teaser
[47] core.entity_view_mode.user.compact
[48] core.entity_view_mode.user.full
...

What is the difference between the entity_form_display configuration (36) and the entity_form_mode configurations (37, 38)?


texts: Change user roles based on profile field

texts:
I have an field role_type with values - 0,1,2...

And I need to add role X to all users who have role_type = 2?

How can I do that? Rules? SQL?

Thanks for your help.


texts: Add cardinality_unlimited taxonomy reference to custom entity

texts:
Okay, so I'm getting an error that I think may be a Views bug, but I don't have enough knowledge about Views & SQL right now to be sure about that.

Here's the hook I'm using to install the new field into the poll entity, using drush entity-updates:

/**
 * Implements hook_entity_base_field_info().
 */
function mymodule_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'poll') {
    $fields['cat'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Category'))
      ->setDescription(t('Category of poll'))
      ->setSetting('target_type', 'taxonomy_term')
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
      ->setDisplayOptions('form', array(
        'type' => 'entity_reference_autocomplete',
        'weight' => -10,
        'settings' => array(
          'match_operator' => 'CONTAINS',
          'size' => '60',
          'autocomplete_type' => 'tags',
          'placeholder' => '',
        ),
      ))
      ->setTranslatable(TRUE);
    return $fields;
  }
}

Then, I make a view that would like to use this taxonomy term as a Contextual Filter.  I want to use the taxonomy term name rather than the ID, so I need to add a relationship.  I add relationship in the view and look for the Taxonomy Term relationship that has my description, "Category of poll" and select it.  The view complains about a SQL error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'poll__cat.cat' in 'on clause': SELECT poll_field_data.id AS id, taxonomy_term_field_data_poll__cat.tid AS taxonomy_term_field_data_poll__cat_tid FROM {poll_field_data} poll_field_data LEFT JOIN {poll__cat} poll__cat ON poll_field_data.id = poll__cat.entity_id AND poll__cat.deleted = :views_join_condition_0 LEFT JOIN {taxonomy_term_field_data} taxonomy_term_field_data_poll__cat ON poll__cat.cat = taxonomy_term_field_data_poll__cat.tid LIMIT 5 OFFSET 0; Array ( [:views_join_condition_0] => 0 )

The reason for the error in the above query is that the poll__cat.cat column does not exist, but it rather SHOULD be poll__cat.cat_target_id.

My question is: is this a views bug or a bug with the way I'm adding the field to the poll entity, and if it is a views bug:

How do I debug it? Where does views set the column name it's looking for?
Is there a hook I can use to change it,  and/or should I submit this odd case to the views project?

EDIT: I'm trying to use hook_views_query_alter and hook_views_pre_execute to try and modify the broken query to do what I want it to do, but it is incredibly frustrating, because all of the things are protected, and it is very inconvenient to access anything, considering the purpose of these hooks is to modify data.  I'm trying to look through the functions for ViewExecutable and the views Sql class, but I don't see anything that will help me change the column to what it should be!  Anyone who can help in any way, I will be so grateful.

Edit 2: It seems like this guy: Views doesn't like multiple entity references in my entity has had a similar problem.  I feel like this is a bug somewhere, or at the very least an issue with CARDINALITY_UNLIMITED being confusing to implement with entity references.


texts: 7 - Attachments are not showing in search results for non admins when using apache solr attachments

texts:
I am using apache solr search module in my site, and using local Tika extraction for indexing attachments.

When I logged in as admin I can able to search attachments as well as nodes, but if I logged in as other user attachments are not showing up in search results, only nodes are showing.

Do I need to do any settings for this? I have provided Seach permissions for all the users in people tab.

Any help will be appreciated, Thanks.


texts:
I'm creating a module for Drupal 8 that will auto fill some content in a add content page. Now I need to have a way to group different contents in one group. I found the Group module that does the job, but I cannot find a way to hook into it. Can someone help me with this?

I want to have a few check boxes, for every group, in my add content page. When the user select a group and create the content it will be added to that group. How can I create the checkboxes for the groups where the users has access for. Also how can I auto add the content to the selected groups?


texts:
Hello Every body I have an SQL Query to DB

function darkSiteContent($delta){
     switch ($delta) {
     //SQL Query to find the title , nid of the node and its body
     case 'popup_dark_screen':
      $result = db_query("
        SELECT n.title , n.nid , b.body_value
        FROM {dot_node} as n , {dot_field_revision_body} as b , {dot_node_type} as t
        WHERE t.type = 'dark_sit' AND n.type = t.type and b.bundle = t.type
        order by n.title desc LIMIT 1
        ");
        $items = array();
        foreach ($result as $row) {
        print_r($row);
        $items[] = l(t($row->title, 'node/' . $row->nid )).''.$row->body_value;
        }
      return array('#markup' => theme('item_list', array('items' => $items)));
      break;
    }

}

But it show this error

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'APIG01JO2012039.dot_dot_node' doesn't exist: SELECT n.title , n.nid , b.body_value FROM {dot_node} as n , {dot_field_revision_body} as b , {dot_node_type} as t WHERE t.type = 'dark_sit' AND n.type = t.type and b.bundle = t.type order by n.title desc LIMIT 1 ; Array ( ) in darkSiteContent() (line 71 of C:\AppServ\www\APIG01JO2012039\sites\all\modules\darksite\darksite.module).

I am sure of my table name but it still show this error


texts: Image style scale and crop not formatting right

texts:
I had a scale and crop image style created, but I had to move it to code.  So, to re-create it, my code is:

function mymodule_image_default_styles() {
    $styles = array();

    $styles['mymodule_thumb'] = array(
        'label' => 'MyModule Thumbnail',
        'effects' => array(
            array(
                'name' => 'image_scale_and_crop',
                'data' => array(
                    'width' => 210,
                    'height' => 210

                ),
            )
        ),
        'name' => 'mymodule_thumb',
        'storage' => IMAGE_STORAGE_NORMAL

    );

    return $styles;
}

It's scaling to the 210px width, but it doesn't seem to be cropping right.

Am I missing something?  Before this, I tried separate scale and crop effects, but got the same result.

EDIT: If it matters, I'm calling image_style_url() and passing the style.


texts:
Hi I'm trying to setup a View with the following criteria.

Select style: 1) Yellow 2) Green 3) Blue

I created an exposed filter for that. Easy so far.

I have created a Color content type that contains each color style in a different View Mode. Let's say the user picks Yellow. Now i want all the Color nodes to be displayed with only the Yellow View Mode.

It's probably a simple solution but i can't figure it out. Thanks in advance!


texts: What is the entity ID for private messages?

texts:
I want to access some private messages using entity_load() but I don't know what the entity ID is to call them by.  I have the message ID (mid) but that doesn't appear to work.

I'm attempting to load an individual message like this:

      $message_entity = entity_load('privatemsg_message', array($row['mid']));

And this is how Private Message declares hook_entity_property_info().

/**
 * Implements hook_entity_property_info().
 */
function privatemsg_entity_property_info() {
  $info = array();
  // Add meta-data about the basic node properties.
  $properties = &$info['privatemsg_message']['properties'];
  $properties = array(
    'mid' => array(
      'type'  => 'integer',
      'label' => t('Private message ID'),
      'description' => t('Private message ID'),
    ),
    'thread_id' => array(
      'type'  => 'integer',
      'label' => t('Private message thread ID'),
      'description' => t('Private message thread ID'),
      'getter callback' => 'entity_property_verbatim_get',
    ),
    'author' => array(
      'type'  => 'user',
      'label' => t('Private message author'),
      'description' => t('Private message author'),
      'setter callback' => 'entity_property_verbatim_set',
    ),
    'subject' => array(
      'type'  => 'text',
      'label' => t('Private message subject'),
      'description' => t('Private message subject'),
      'setter callback' => 'entity_property_verbatim_set',
    ),
    'body' => array(
      'type'  => 'text',
      'label' => t('Private message body'),
      'description' => t('Private message body'),
      'setter callback' => 'entity_property_verbatim_set',
    ),
    'timestamp' => array(
      'type' => 'date',
      'label' => t('Private message sent date'),
      'description' => t('Private message sent date'),
    ),
  );
  return $info;
}

How do I get the entity ID for private messages?  Is that different than the message ID (mid) or thread ID (thread_id)?


texts: I'm using JCarousel with Views. I've been able to get my content working fine and linked properly to their nodes in a modal window using colorbox-load. I'd like to be able to open up only the teaser content in the window. How can I do this?


texts: Get Location module Block : how to show map markers for particular taxonomy term - exposed to user

texts:
I am using the Get Location module for building store locator functionality in my site. I have made a content type with field = address and field type = Geolocations Fields with widget = Geocoder.

I also added one another field of term reference. I created nodes and enable getlocation search block. Markers for given locations are successfully displayed on "getlocations" block map but I need to filter taxonomy term data and need to use expose filter, So when user choose one term, it gives the results marker of corresponding term reference node.

I can't use view, because in this module, block is directly a module, it is not coming from any view. How can I use exposed filter that filter my nodes by taxonomy terms and displayed corresponding markers on map.


texts:
I'm using modal form in drupal7.26 with WEBFORM module and is working fine when I click  a link the form opens in new modal.

What I want is to open the same WEBFORM with out clicking any link instead it should be open on page/body load event.

I'm using modal form with CTOOLS and WEBFORM modules.

Any help would be appreciated.

Cheers
-Zafar


texts:
I've created a view that displays the node count values for taxonomy terms. After implementing it into my Drupal site, I found that I cannot access the taxonomy term page from the links provided, all it does is redirect me to the home page.

My settings are as follows:

It produces the following view, and I click the links I cannot access the taxonomy term page:

I've tested the links manually and they work, they are:

/?q=tags/expansion
/?q=tags/opportunity
/?q=tags/press
/?q=tags/product-update

Any reasons why this isn't working as expected? I'd greatly appreciate your help.

UPDATE #1 - rendered output

expansion
              (2)

opportunity
              (4)

press
              (1)

product update
              (1)

UPDATE 2 - Configure field: Taxonomy term: Name

UPDATE 3 - Configure contextual filter: Taxonomy term: Name


texts: Search a URL list, return JSON values into a dynamically generated table

texts:
I am looking for a Drupal Service or a Module (or a link to a working example) of this arrangement:

There's a Search form. Placing and submitting the search will make a REST call for certain values to a URL which is a JSON list, generated by an API, then - return those JSON values and display them in a generated table.

I hope that I have explained this well enough. So, which Drupal Service/Module can do the job described above? I just need a nudge in the right direction.

Thank you for looking at this Post and I appreciate your help in pointing me in the right direction!


texts:
using the search API module I highlighted the search text. Key words take the whole width of the block, how to insert them in the text? my current setup is:

Highlighting prefix : <p class="views-highlight">
Highlighting suffix : </p>

CSS:  .views-highlight {color: black; background-color: yellow;}

my search results


texts:
I want to use a native SQL query for my source migration class, but I can't find a way. I've tried to use the $this->database->query() but in that case, it will fail because there's no countQuery() method defined. And for some reason, I not really want to convert every time the queries between the two formats especially when there are 6 joins and 8-9 subqueries in it. Is there a way to use the SQL query instead of the Drupal select?

This:

/**
 * Custom source from a database.
 *
 * @MigrateSource(
 *   id = "custom_source",
 *   source_module = "custom"
 * )
 */
class CustomSourceMigratePlugin extends SqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->database->query("SELECT ... FROM table t
     INNER JOIN table2 t2 on ...
     INNER JOIN table3 t3 on ...
     INNER JOIN table4 t4 on ...
     INNER JOIN table5 t5 ON ...
     ...
    ");
  }
  ...
}

Will fail with Error:

  Call to undefined method Drupal\Core\Database\Statement::countQuery() in Drupal\migrate\Plugin\migrate\source\SqlBase->count() (line 389 of /home/ec2-user/environment/ecif-reference/web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php).
  If I return back $this->select('table'); then it works, but I want to supply raw SQL because I don't want to write every time drupal queries...


texts:
How do you alter or remove a form error produced by Drupal or another module on node insert/save, for a particular content type. I'm looking for a method which I can use in a module.

I've tried hook_node_validate(), but all I was able to do is to get errors and set errors.


texts: How do I override Webform::getDefaultSettings(), changing the default Webform setttings?

texts: In Drupal 7, I could use hook_webform_node_defaults_alter() to override the default settings for new Webforms. In Drupal 8, defaults are set in Webform::getDefaultSettings(). How can I override these?


texts: Show form message only on initial load, but not after submit

texts:
I'm often using Drupal::messenger() to show status/warning messages before I submit the form. But those messages are usually counter-intuitive once the form has been submitted. How can I add a message to a form that is only rendered before the form has been submitted.
My typical code looks like this:
function buildForm() {
  /**
   * ...build form...
   */
  $showWarning = $this->doSomeChecks();

  /**
   * tried to use isSubmitted() to prevent the message after submitting, but does not work
   */
  if ($showWarning  && !$form_state->isSubmitted()) {
    $this->messenger()->addWarning('Some info you should know before submitting this form.');
  }
}

function submitForm(array &$form, FormStateInterface $form_state) {
  /**
   * ...do stuff...
   */
  $this->messenger()->addMessage('Successfully done something');

  /**
   * tried to use deleteByType() to remove message from buildForm after submitting, but does not work
   */
  $this->messenger()->deleteByType($this->messenger()::TYPE_WARNING);
}

I know I could use $form_state->setRedirect($customPage) in submitForm(), but I don't want the overhead of creating a new page just to hide a simple warning message.
Is there no simple way to show a message only once on the initial form load, but not after submit?


texts:
In my Drupal site I am using Webform module Modal forms (with ctools) module.

When I place file field (to get opportunity attach files) on the form, form save data twice. But when I delete file field, form work perfect, e.g. save data once. Maybe someone has already faced this problem. Any help will appreciate.

Image-1

Image-2


texts:
I have taxonomy term with 2 fields: a and b. I have two taxonomy terms.

term1: a1 and b1
term2: a2 and b2

I have a content type with 3 fields; the first one is from a selected list from the taxonomy terms (term reference). When I choose the first field, I need that the related taxonomy terms appear on the second and third fields.
For example, if I choose term2, I need that the terms a2 and b2 appear automatically in the other fields.

Is it possible?


texts:
I want a module to load in pop-up window. Ex. i have a module where the page callback will be a form. when user clicks on a link in my website. only the form has to load in the popup window like the lightbox 2 functionality.

i will generate a form in my custom module and i want the form to be displayed in the front-end of the site in a light box.. without other regions(header,footer,right,left) of the page.


texts: The developer stages need their user names and email address anonymised. I did not find anything googling the subject matter. Maybe somebody developed a Drush extension for this? Any other suggestions are welcome too.


texts:
I think I must be missing something basic. I have a template that is usually called via a URL but I also want to be able to call it manually using theme()

/**
 * Implements hook_menu().
 */
function signup_menu() {
  $items = array();

  $items['list/signup/success/%'] = array(
    'title' => 'Sign-up Successful',
    'page callback' => 'theme',
    'page arguments' => array(3),
    'page arguments' => array('signup_success'),
  );

  return $items;
}

/**
 * Implements hook_theme().
 */
function signup_theme() {
  return array(
      'signup_success' => array(
      'arguments' => array('node' => NULL),
      'template' => 'signup-success',
    )
  );
}

function signup_preprocess_signup_success(&$variables) {
  $signup = signup_record(arg(3));
  $variables['signup'] = $signup;
}

How do I override the argument that is usually passed through the URL? So I can call it like this:

theme('signup_success', $signup-id);

The preprocess function only ever takes the argument that comes from the current URL which is incorrect.


texts: Migrate a multiple date-range field from CSV using Migrate Source CSV-module

texts:
I need to migrate data from a csv file to Drupal 9 (using $ as delimiter for fields). The field csv_date_options can contain multiple date ranges with | as delimiter. The CSV-file looks like this:
id$title$body$csv_date_options
1$Drupal workshop$some body text$13.01.2021-15.01.2021|23.03.2021-25.03.2021|04.11.2021-06.11.2021
2$Another workshop$again some body text$25.04.2021-30.04.2021

My Drupal 9 site has a content type workshops with 3 field: title, body and field_date_options. field_date_options is a date-range-field with unlimited entries.
Tried to apply this solution which has a similar logic: Possible to extract multiple key/value pairs (links) from string in CSV and migrate into multiple link field
But my migration fails. Here is my migration-yml:
id: workshops-5
label: Import workshops
migration_group: default

source:
  plugin: 'csv'
  # Full path to the file.
  path: '/my-path-to-csv/workshops.csv'
  delimiter: '$'
  enclosure: '"'
  header_row_count: 1
  ids:
    - id
  fields:
    0:
      name: id
      label: 'Unique Id'
    1:
      name: title
      label: 'Titel'
    2:
      name: body
      label: 'Workshop Description'
    3:
      name: field_date_options
      label: 'Date options'

process:
  title: title
  body: body

  all_dates:
   -
     source: csv_date_options
     plugin: explode
     limit: 30
     delimiter: '|'
   -
     plugin: explode
     delimiter: '-'

  field_date_options:
    -
      plugin: sub_process
      source: '@all_dates'
      process:
        value: #try to set the field_date_options/value
          -
            plugin: extract
            index:
              -'0'
          -
            plugin: format_date
            from_format: 'd.m.Y'
            to_format: 'Y-m-d'

        end_value: #try to set the field_date_options/end_value
          -
            plugin: extract
            index:
              -'1'
          -
            plugin: format_date
            from_format: 'd.m.Y'
            to_format: 'Y.m.d'

  type:
    plugin: default_value
    default_value: workshops

destination:
  plugin: entity:node

What am I missing? Any hints appreciated.


texts:
I'm trying to use the http://drupal.org/project/galleria module in conjunction with its fullscreen theme, but I get the error I pasted below, I tried many fixes but not working.

Is there another module to show a gallery similar to this one: http://galleria.io/themes/fullscreen/

Could not extract width/height from image: http://localhost/mysite.com/sites/default/files/styles/thumbnail/public/images-fullscreen/slide-1.jpg. Traced measures: width:0px, height: 0px.


texts: Tag every value of a single multi-value field

texts:
I have a photo contest website where every participant can upload up to 3 photos. I created a participant node type with a multiple file upload with max 3 entries.

How can I tag/edit/flag individual photos to filter/choose the best ones while they belong to a single node? How can I accomplish this? Is there any contributed module to help me, or do I need to change the logic?
I thought that a solution could be that every photo needs to be a separate node linked to participant's node through entity reference, but how do I create 3 separate photo nodes on a single form submit?

Thanx


texts: Give user empty form on form validation error

texts: I'm using braintree.js with a custom form.  For those not familiar, braintree.js does client side encryption of the form fields before submission to the server.  On my end I get a bunch of gibberish (this is expected).  If a form validation error occurs, I want the form displayed again alerting the user of the error but I don't want any of the fields pre-populated because the pre-populated values are now the client side encrypted gibberish.  Is there a method of doing this in the _validate function?


texts: Forms : How to add elements on the client without a (ajax) round trip to the server

texts:
I have been playing with the ajax examples from the examples module http://drupalexamples.info/examples/ajax_example/add_more

What i'd like to do is have elements added to the form without requiring a round trip to the server. I guess drupal requires this to rebuild the form with the new elements. But is it possible to do this without calling back drupal ?


texts:
I copied the user twig file into my theme.

How to display the information of the following user:

  Account updated on: ???
  Account status: ???
  Roles: ???
  Member since: ???
  Last connection on: ???

I tried {{ user.role }} and {{ content.role }} to display the role, but it does not work.

{#
/**
 * @file
 * Default theme implementation to present all user data.
 *
 * This template is used when viewing a registered user's page,
 * e.g., example.com/user/123. 123 being the user's ID.
 *
 * Available variables:
 * - content: A list of content items. Use 'content' to print all content, or
 *   print a subset such as 'content.field_example'. Fields attached to a user
 *   such as 'user_picture' are available as 'content.user_picture'.
 * - attributes: HTML attributes for the container element.
 * - user: A Drupal User entity.
 *
 * @see template_preprocess_user()
 *
 * @ingroup themeable
 */
#}

      Compte mise à jour le : ???
      Compte : ???
      Rôles : ???
      Membre depuis : ???
      Dernière connexion le : ???

      {{ drupal_view('utilisateur_offre', 'block_1') }}

    {{ drupal_view('utilisateur_offre_detail', 'block_1') }}


texts: (Field type) Link autocompletion for media entities

texts:
How can I enable autocompletion for media entities in Link fields? The Link field seems to "know" only nodes, but no media entities.
Use case:
I've got a paragraph for a "card style" link consisting of 4 fields for an image, a title, a short description and a link. The paragraph must work for internal and external links, so I'm using a Link field and not an entity reference.
A common task is that editors upload a PDF to the media library, and provide a nice download link to the PDF on multiple nodes, using the paragraph mentioned above.
Tried this, doesn't work good enough:
I know that it technically would be possible to manually enter a path like /media/<media_entity_id>.  But this so bad UX that I need to find a better solution.
I also have LinkIt installed, but sadly I can't use LinkIt for Link/URL fields.
(I'm using Drupal v8.4 core media)


texts:
I want to update with composer (running the drupal composer drupal project), and already succesfully updated 8.2.6 - 8.2.7, but now it doesnt update to 8.3.0

$ composer update drupal/core --with-dependencies
Package "drupal/core" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files


texts: Field within content type does not publish

texts:
this is possibly a terribly stupid question, but I just cannot find the solution:
I am trying to make small changes to a Drupal 6.26 site and, although the field is there within the list in the content type and I have copied all settings I could find from similar field that is working fine, it just would not publish on the site.

where do I need to look, what am I missing???

A pointer would be so much appreciated!

Many thanks


texts: How does the internal entity cache work?

texts:
The internal entity cache is interfering with display modes on my site.  I have a view that is displaying a node with a custom display mode, 'slideshow'.  When I look at the view from a page that displays the entity in a different display mode along side the slideshow block, the node is rendered as that mode and not slideshow, but the other nodes in the block display using 'slideshow'.

hacking core, and rewriting node.module:

node_load_multiple($nids = array(), $conditions = array(), $reset = FALSE)

to

node_load_multiple($nids = array(), $conditions = array(), $reset = TRUE)

resolves the issue.  Under performance, caching is on for anonymous users.  This is occurring while logged in.  I've tried entitycache in the past, but it is not installed.  Drush cc all does nothing.  I'm open to any ideas that may help.

Here is the offending part of a backtrace that I managed to pull up:

It looks like somewhere in theme.inc the wrong template is being chosen:

10 (Array, 4 elements) file (String, 52 characters )
/home/mysite/git/mysite/includes/them...
/home/mysite/git/mysite/includes/theme.inc line (Integer) 1185
function (String, 21 characters ) theme_render_template | (Callback)
theme_render_template();
args (Array, 2 elements)
0 (String, 70 characters ) sites/all/themes/mysite/templates/ds/ds-...
  sites/all/themes/mysite/templates/ds/ds-1col--node-post.tpl.php
1 (Array, 86 elements)

It only affects the node being rendered currently, which isn't a post and shouldn't be using that template when it shows up in the slideshow block.  I've grepped around for theme_hook_suggestions but haven't found any.

---EDIT---
I've tracked it down to this code in views:

 function pre_render($values) {
    $nids = array();
    foreach ($values as $row) {
      $nids[] = $row->{$this->field_alias};
    }
    $this->nodes = node_load_multiple($nids);
  }

  function render($row) {
    if (isset($this->nodes[$row->{$this->field_alias}])) {
      $node = $this->nodes[$row->{$this->field_alias}];
      $node->view = $this->view;
      $build = node_view($node, $this->options['view_mode']);

      return drupal_render($build);
    }

For what ever reason, node_load_multiple is returning the current node being viewed with the type set to 'post', instead of the correct content type.  Why would there be malformed nodes in the site's internal cache?


texts: Can you link an image field to a link field by 'Manage display'?

texts: I have a content type with two fields: image and link. I'd like the image to display linked to the link field. I'm happy to do that myself programmatically, I'm just wondering if there's a module that lets you do this directly from the Manage display screen (ie zero code).


texts: Create content of different entity by user programatically

texts:
I am using an OpenSocial site, and writing a custom code that will create a post content by specific user. The post was created but assigning user is not working. How to properly assign userID to a post entity type?

use Drupal\social_post\Entity\Post;
...
    $node = Post::create([
      // The node entity bundle.
      'type' => 'post',
      'field_post' => $post,
      'field_visibility' => 1,
      'uid' => 2, // user = John
    ]);
    $node->save();

Actual result:

POST ID  POST   AUTHOR  CREATED                   OPERATIONS
1        Test   admin   Wed, 04/18/2018 - 10:19   Edit

Expected result:

POST ID  POST   AUTHOR  CREATED                   OPERATIONS
1        Test   john    Wed, 04/18/2018 - 10:19   Edit


texts:
I have 2 autocomplete (autocomplete1 and autocomplete2) field in a content type. I need to make one of them depend on the other one
I make a hook_form_alter to change the path of the autocomplete2

I used Ajax when changing autocomplete1 and return autocomplete2 by change the autocomplete_path but it did not work.

This is my code

function myhook_form_alter(&$form, &$form_state, $form_id){
if($form_id == 'x'){
    $form['field_sub_news_name']['#prefix'] = '
';
    $form['field_sub_news_name']['#suffix'] = '
';

    $form['field_main_news_name']['und'][0]['nid']['#ajax'] = array(
      'callback' => 'ajax_change_autocomplete_subnews_field',
      'wrapper' => 'subnews_autocomplete',
      'method' => 'html',
      'effect' => 'fade'
    );
}

}

function ajax_change_autocomplete_subnews_field($form, $form_state) {
$nid = $form_state['values']['field_tadwena_main_news_name']['und'][0]['nid'];
$form['field_tadwena_sub_news_name']['und'][0]['nid']['#autocomplete_path'] = "/ajax/autocomplete_subnews_field_path/$nid";
return $form['field_tadwena_sub_news_name'];

}

I tried to use $form['field_tadwena_sub_news_name']['und'][0]['nid']['#autocomplete_input']['#url_value'] = "ajax/autocomplete_subnews_field_path/$nid";  but it gives me a JavaScript error

I hope someone can help me


texts:
I use bootstrap theme, and I want to open messages in bootstrap modal; after searching, I found the Bootstrap Modal Messages module, which is not available for Drupal 8.

Is there any way for Drupal messages to appear in a Bootstrap modal?


texts: Display content not updated from specific date

texts:
I can generate a views with provides a list of content has been updated from an specific date (by adding field "Content: Updated date" in Filter criteria). However, I cannot find the opposite option, I mean built a list from a specific date which has not been moderated or updated. How can I get it?

Thanks a lot!


texts: Ubercart Coupon - only allow one coupon per order, but always apply the most recently entered one

texts:
Currently when someone adds a coupon to a cart which already has a coupon applied, we get the message "This coupon combination is not allowed", leaving the original coupon on the order.

How do we change that behavior so that newly added coupons get applied to the order, while the previous one gets deleted?  There is never a case in which two coupons would be allowed on an order.


texts: Which permission should I use for a role to see a shortcut to Custom Block Library?

texts:
I have a custom block that is a site-wide announcement. I have a role, "Announcement Editor", for those people who I want to edit that message.

Most of our users have restricted permissions, and don't have access to the "Structure" menu, etc. We use shortcuts to allow them to see items they can't navigate to through menus. This was set up by a developer who is no longer here.

I want to add a shortcut, "Blocks", linking to /admin/structure/block/block-content to these users' menu. I have added it to the default shortcuts for the site. It shows up for Admin users:

However it doesn't show up for other users:

What permission(s) do I need to add for users to see this shortcut?

Edit Authenticated users have the permission use shortcuts already:


texts: How can I generate a list of the numbers of users with Roles B, C, and D that have Role A?

texts:
My site has a large number of user roles.  To generate a list that shows the number of users with each role, I created a view of users and set a Contextual Filter to User: Roles and then Display as Summary.  This gives me a list like this:

Role A (23)
Role B (10)
Role C (15)
Role D (7)
Role E (4)

What I would like to do now is to create a new view that shows how many users that have Role A have Role B, C, or D like this:

Role B (4)
Role C (6)
Role D (3)

However, I don't know how to get Display a summary to work in this way.  If I add Filter Criteria such as User: Role, then only the count for that role will be shown.  However, I want to show the count of users for all roles given that the user has Role A.

Use case: On my site, users get roles based on their interests.  They also get roles based on how involved they are on the site (like here on SE).  I want to generate statistics on the role choices of my most active users.


texts: Change the front page value for logged in users

texts:
On my site I have two front pages:

node/31, for anonymous users
calendar-node-field-journal-date/month, for logged in users

When a users clicks on the front page (which is rendered as $front_page in my page.tpl.php file), I want them to be taken to the appropriate front page.

However, if a logged in user goes to node/31 directly (e.g. by not clicking on the front page link) they should still be able to see the node (and not be re-directed).

After researching, I've found Rules is the best way to do this and there are instructions here.
However, this re-directs logged in users when they visit node/31. How can I get the Rule to only run when the user clicks on the $front_page link and not on the direct node/31 link?

I don't want to set it up via my theme, as I am sharing the theme on a multi-site. I also don't really want to install other modules, as I am already using Rules for other things.


texts: how to provide security to user Profile?

texts:
I want to provide security to user profile, so that purpose am adding two check boxes

Account Settings

List item Make my profile only visible to members of my website members only.
Make my profile private

above two options are check box but how can i apply the functionality to this check boxes otherwise

please suggest me to any module are available


texts:
I am planning to integrate unit testing in CI/CD. I wonder what would be the good practice for running.

Should I run tests for the entire core and contributed modules, or only for the codes I wrote?


texts: Spam filter options for unregistered user to registered user email service

texts:
I would like to give unregistered visitors the chance to send emails to node authors through a contact form. What would be the best and most efficient way to filter out spam?

1) Simply add a CAPTCHA to the contact form. However, I experienced CAPTCHA module to be not very reliable and I won't be able to afford Mollom.

2) Involve an external Gmail account and make use of their sophisticated spam filters. For example, when user A submits a contact form on a node created by user B, the email is first sent to an external Gmail account, filtered, and then - if spam free - forwarded to user B.


texts: Form select option results in "Illegal Choice has been detected"

texts:
I have a form where a user picks a date for their submission(s) to appear on the website. I am populating a 'date' field like so:

function mymodule_get_date_options($type = 'start') {
  $options = array();

  $start_week = time();

  if (date('w', $start_week) == 3) {
    $start_week = strtotime('+1 week', $start_week);
  }

  while (date('w', $start_week) != 3) {
    $start_week = strtotime('+1 day', $start_week);
  }

  if ($type == 'end') {
    $start_week = strtotime('+1 week', $start_week);
  }

  for ($x = 0; $x < 24; $x++) {
    $options[date('U', $start_week)] = date('M d, Y', $start_week);
    $start_week = strtotime('+1 week', $start_week);
  }

  return $options;
}

And the element:

$form['start_date'] = array(
    '#title' => t('Start Date'),
    '#type' => 'select',
    '#options' => mymodule_get_date_options('start'),
    '#default_value' => $mymodule_form_object->start_date,
  );

The generated HTML:

// a chunk of the option elements
<option value="1313615248">Aug 17, 2011</option>
<option value="1314220048">Aug 24, 2011</option>
<option value="1314824848">Aug 31, 2011</option>
<option value="1315429648">Sep 07, 2011</option>
<option value="1316034448">Sep 14, 2011</option>
<option value="1316639248">Sep 21, 2011</option>
<option value="1317244048">Sep 28, 2011</option>
<option value="1317848848">Oct 05, 2011</option>
<option value="1318453648">Oct 12, 2011</option>

So, everything looks okay, except when the form is submitted it says 'An Illegal Choice has been detected" with the date selects highlighted.


texts: Change site logo for an specific content type

texts:
I'm building a really simple site and I came into this question now. The site has a few content types and one of them acts as a moderated wiki (only users with a certain role may create/edit that content). When viewing lists of these nodes or when viewing any node of that content type in full-mode I would like the site logo to be different. Say, instead of «My site», something like «My site [[wiki]]».

My first thought was tweaking context to change theme settings based on context. Too bad, I didnt find how to get that :/

I've been diving in the available answers here, but I dont seem to have an answer, though a couple of similar question tackle this subject through different systems:

One attempts to show different logo for different languages and relies and i18n and variable modules. see thread on i18n and variable
Second one adds a variable (though it is not clear if they put it directly in the node--type.tpl file (and i wouldnt like that :-/), by hand-writing the path to the desired image... see thread on tpl "abusing" :D

Any ideas on what is the best approach to get this custom logo for an specific content type?

Thanks :)

The code provided in the answer wasn't working properly, but I adapted the code and got it to work:

function YOURTHEMENAME_preprocess_page(&$vars, $hook) {
  if (isset($vars['node'])) {
  // If the node type is "blog" the template suggestion will be "page--node--blog.tpl.php".
   $vars['theme_hook_suggestions'][] = 'page__node__' . str_replace('_', '--', $vars['node']->type);
   }
}

With this function I got a tweakable and customized page.tpl.php. Now I only need to change the $logo value for this content type or add extra settings to the theme, as hard-coding the url path for the alternative logo seems inelegant :)


texts: Alter a form in a block only if it is in a certain region

texts:
In my template.php I'm trying to alter a form in a views exposed block, but I only want to do this if that block is in a certain region in my theme.

I'm using Drupal 7.

Is that possible? What php code would I use?

Here is what I'm using now:

function cmfzen_form_alter(&$form, &$form_state, $form_id) {

  // change the main search form
  // see http://drupal.stackexchange.com/questions/28404/easiest-way-to-add-x-webkit-speech-to-the-search-blocks-input-element
  // see http://adaptivethemes.com/html5-placeholder-text-for-your-drupal-7-search-field
  if ($form_id == "views_exposed_form" && $form['#id'] == "views-exposed-form-site-search-page"){

    $form['site-search']['#type'] = 'searchfield';
    $form['site-search']['#attributes'] = array(
      'class' => array('search-site'),
      'placeholder' => t("I'm looking for..."),
      'speech x-webkit-speech spellcheck' => 'false',
      );
    // change form submit button

    $form['submit']['#attributes'] = array('class' => array('search-button'));
  }
}


texts: Populating file fields with an http-request with the Services module and a REST Server (Drupal 7)

texts: I need to add content trough a node.create and one of the fields in the content type I am adding is a file field.  So far I have been able to get my Services module set up with REST server to accept user and node resources and I have been able to make http-requests to  add content containing text fields.  Now I need to expand on this to work with a file field but I have not been able to find any resources about creating nodes that contain file fields.  I am wondering how would this be done?  Would it be done in one pass or two?  Would I upload the file with a first post then do the association next?  Does anyone have any good resources related to this topic?


texts: Is custom token module sustainable for masive use?

texts:
Is the Custom Token module sustainable for massive use or should I create custom module?

Custom Token will be used for generating URL path, "massive use" means hundreds or thousands of nodes created per day.


texts: How to know how many elements are processed in the finish callback?

texts:
I followed Smack My Batch Up : Batch Processing In Drupal 8 article to create a batch job and all works fine. But in the finish callback I can't get the total number of processed elements.

This is my code:

$operations = [];
foreach ($lines as $line) {
/*
Here I have an array of operations and each element have the name of
the operation callback function and the line that should be processed.
Maybe this is the problem.
*/
  $operations[] = ['process_line_saint_du_jour', [$line]];
}

$batch = array(
  'title' => t('Migrating Saint of the Day'),
  'operations' => $operations,
  'finished' => 'process_line_saint_du_jour_batch_finished',
  'init_message' => t('Saint of the Day migration is starting.'),
  'progress_message' => t('Processed @current out of @total. Estimated time: @estimate.'),
  'error_message' => t('The migration process has encountered an error.'),
  'file' => drupal_get_path('module', 'diocese_migrate') . '/diocese_migrate.batch.inc',
);

batch_set($batch);

This is my finish callback function:

function process_line_saint_du_jour_batch_finished($success, $results, $operations) {
  // The 'success' parameter means no fatal PHP errors were detected. All
  // other error management should be handled using 'results'.
  if ($success) {
    $message = \Drupal::translation()->formatPlural(
      count($results),
      'One Saint of the Day processed.', '@count Saint of the Day processed.'
    );
  }
  else {
    $message = t('Finished with an error.');
  }
  drupal_set_message($message);
}

The problem here is that I have only one element in the $results array and I have processed 366 elements, all works fine but at the end of the batch I have the following message:

  One Saint of the Day processed.


texts: Adding Node to Entity Reference List (Via Rules) Throws EntityMalformedException

texts:
I'm using rules and I'm trying to add a reference to an updated node to an entity reference on another node. I am getting the following exception.

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7633 of /var/www/html/mysite/includes/common.inc).

I found another post that states - "EntityMalformedException: Missing bundle property on entity of type node." means that Drupal does not recognize your entity as a valid one. In the entity info listing, there is a mapping from "bundle" to "type", for nodes.

Either your $node doesn't have a ->type, or Drupal no longer has the type registered. The type could have been removed, either from the UI, or by disabling a feature, and possibly in more interesting ways as well.

My question is - How can I go about debugging this and correcting the problem. I have Devel installed and I have debugged issues before I just need a little guidance to help me get to the bottom of this / or post the issue to whatever module has caused the error so the maintainers know about it.

Thanks very much and have a great day!


texts:
I just want to do somthing without using module like profile2, so here is my requirement.

=> theme user registration form for e.g. I already have a beautiful user registration form as static html template which use bootstrap classes for css so how can I implement this html template in my drupal registration form..

=> In login form I want to remove tabs LIKE create new account and request new password and enstand of these tab I want to give like just before login button.

let me know if anything not clear.


texts: Add value to field using Entity Metadata Wrapper

texts:
I'm trying to accomplish the seemingly simple task to add a value to a multi-value file field in Drupal 7. I have been trying for hours, but none of the answers I found would solve my problem.

My field is called field_video_ext. Using the Remote Stream Wrapper module, I would like to add values like this (using some of the module's code):

<?php

// My videos and their respective nodes.
$videos = array(
  array(
    'nid' => '1903',
    'uri' => 'http://example.com/movie.flv',
  ),
  array(
    'nid' => '3172',
    'uri' => 'http://example.com/movie2.flv',
  ),
);

foreach ($videos as $video) {
  // From the Remote Stream Wrapper module.
  try {
    $file = remote_stream_wrapper_file_load_by_uri($video['uri']);
    if (!$file) {
      $file = remote_stream_wrapper_file_create_by_uri($video['uri']);
      file_save($file);
    }
  }
  catch (Exception $e) {
    drupal_set_message($e->getMessage());
  }

  if (empty($file->fid)) {
    drupal_set_message(t('Unable to add file from URL %file.', array('%file' => $video['uri'])));
    exit;
  }
  // Display needs to be set.
  $file->display = 1;

  // Get Entity Metadata Wrapper
  $wrapper = entity_metadata_wrapper('node', $video['nid']);

  // Write information into fields.
  $wrapper->field_video_ext->set(get_object_vars($file));

  // Save wrapper.
  $wrapper->save();

}

?>

Now the problem is that this doesn't work if the field accepts multiple values. It throws the error

  EntityMetadataWrapperException: Invalid data value given for wrapper
  chain

I then tried using $wrapper->field_video_ext[] = get_object_vars($file);, but that doesn't work either. I think it was this error I got:

  Fatal error: Cannot use object of type Project as array

I also tried the following instead of get_object_vars($file):

$file = (array) $file;
$items = array($file);

And then saving that array using set() or the [] way. But to no avail. Can anybody tell me what I am doing wrong?


texts: Adding pre built create-react-app to D8 block

texts:
I want to know how to add a create-react-app to a block, created with `npx create-react-app in Drupal 8. I'm currently getting a React error. I followed a tuturial I found, but I'm not sure if this is the best solution.

What I all-ready do know:

How to create custom modules & blocks in Drupal 8
How to add custom javascript libraries to Drupal 8
Strong understanding of React and Drupal integrations
I've had success doing similar things in the past, but I'm having trouble this time. The problem might be related to newer version of React, but I'm not sure.

Steps:

Created a default react app with create-react-app (did not touch anything .. just defaults works see the default sinning logo / done this many many times before)
Created a custom block module in Drupal.
Tried to include React's build scripts into the mymodule.libary.yml file, but found that React adds hashes to the filenames after each build. So the standard way to include JS into Drupal 8 wouldn't work as ideally as I'd like. Forcing me to update the library each time a performed a new build.
I searched for solution that would allow me to keep the mymodule.libary.yml unchanged. I found a tutorial that provided a solution to this dilemma on: https://www.appnovation.com/blog/using-react-library-drupal. I followed the tutorial and installed "react-app-rewired" and created a "config-overrides.js" file with:

module.exports = function override(config, env) {
  config.optimization.runtimeChunk = false;
  config.optimization.splitChunks = {
    cacheGroups: { default: false }
  };
  return config;
}

Updated package.json file to use app rewind

"scripts": {
  "start": "react-app-rewired start",
  "test": "react-scripts test",
  "eject": "react-scripts eject",
  "build": "react-app-rewired build && yarn run build:dist",
  "build:dist": "cd build && cp static/js/*.js main.js && cp static/css/*.css main.css"
 },

Updated mymodule.libary.yml file with:

mymodule.block.component:
  version: VERSION
  js:
    assets/js/build/main.js: {scope: footer}
  css:
    component:
      assets/js/build/main.css: {}
    dependencies:
      - core/drupal

I ran: "npm run-script build" which builds the static build dir with the correct "main.js" & "main.css" and moved the build folder to "MYMODULE/assets/js/".
Called the library in my block:

public function build() {
    $build = [];
    $build['#cache']['max-age'] = 0;

$build['something']['#markup'] = '

';
$build['#attached']['library'] = [
  'mymodule/mymodule.block.component',
];
return $build;

}
I got this error (https://reactjs.org/docs/error-decoder.html/?invariant=200), which means "Target container is not a DOM element."

Does anyone know why I'm getting this error? Does anyone know if this is the best solution to include a create-react-app in a custom Drupal 8 block?


texts:
This is something I don't even think Drupal has built-in features for. I'm trying to theme taxonomy term page's nodes. The actual major problem is, I want to theme them per item. This for the actual HTML hierarchy (this is only a representation of the semantics I want, this is not to be interpreted as a visual representation):

+------ DIV ------+
|+----- DIV -----+|
||     node 1    ||
|+---------------+|
|+----- DIV -----+|
||     node 2    ||
|+---------------+|
+-----------------+

+------ DIV ------+
|+----- DIV -----+|
||     node 1    ||
|+---------------+|
|+----- DIV -----+|
||     node 1    ||
|+---------------+|
+-----------------+

+------ DIV ------+
|+----- DIV -----+|
||     node 1    ||
|+---------------+|
|+----- DIV -----+|
||     node 1    ||
|+---------------+|
+-----------------+

I really need this setup and can't be bothered with using complex CSS selectors (eg. :nth-child(odd)) this due to browser compatibility.

The only way I can imagine (and read on some places on the interwebs) is creating views as a workaround and theme that. But I would like not to make these excessive measurements just to workaround the lack of theming abilities of the taxonomy module.

Any thoughts? I thank you in advance!


texts: How do I get Captcha to reappear in my registration form if an error was detected after submission?

texts: I'm using Drupal 7 and have added an image Captcha as part of the registration process. The Captcha works just fine but if the form is submitted with an error, it no longer appears with the rest of the form when the registration page reloads. How do I make sure it always reappears? Thanks.


texts: How can you remove the edit lock on a node?

texts:
When I try to save a node I am working on I get this error message.

  The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.

What is causing that issue and how can I remove the lock?


texts: For Drupal 7 sub-domain installation is sites.php the same as 6's use of symbolic link folder?

texts:
I have a working Drupal 6 using a shared Drupal install on a shared Linux server. I've just installed D7. I'm not sure if sites.php is set up correctly (see below). And I can't find good information on this sites.php file to be sure I set it up correctly. This Drupal.org page describes the correct installation situation, but sadly does not mention sites.php (>_<) This Drupal forum poster has the same "Server Not Found" error, but shows completely wrong sites.php example--the set up is not clear.

Is sites.php do the same thing that a symbolic link folder did in Drupal 6. Can I ignore this file?

My sites.php file,

 $sites['mondo7'] = 'mondo7.mydomain.com';

and I tried it the other way,

 $sites['mondo7.mydomain.com'] = 'mondo7';

Both show up "Server Not Found".


texts: How to set URL alias automatically for a content type WITHOUT using Pathauto? Which hook to implement?

texts:
Pathauto can do the job easily for all content types, but in my case I only have one content type URL that needs to be customized, and I would prefer to not install Pathauto and Token.

Can anyone advise me how to do?


texts: How to select state on country bases in drupal webform

texts: How to select the state on country bases in drupal.I have different country and states now I want to select the state on the country bases. I have installed the webform module and webform conditional field module. How I can do this task.


texts: Improving Site Speed and Cache for Authenticated Users

texts:
I am building an intranet site. I have the site set up with single sign on via the server authentication module meaning there are no anonymous users. This means large parts of the cache are worthless.

The site is now set up how I want, however it's running extremely slowly for the first couple of page loads if the site hasn't been visited in a couple of hours. The speed picks backup once you've looked at a couple of pages.

We now have cron set up running every two hours with a scheduled task, so I now know cron isn't slowing the site down. I have the Devel module enabled, and some of the queries are clearly slowing things down and a lot of these seem to be cache related.

Below are all of the queries ran that took over 100ms when I visited the site's home page first thing this morning. (Speed in ms followed by task)

421.91 system_list
890.69 DrupalDatabaseCache::set
171.89 DrupalDatabaseCache::getMultiple
125.01 DrupalDatabaseCache::getMultiple
125.01 PagerDefault::execute
125.01 DrupalDatabaseCache::getMultiple
109.38 comment_num_new
390.65 DrupalDatabaseCache::getMultiple
140.64 ctools_export_load_object
187.51 DrupalDatabaseCache::set
328.15 DrupalDatabaseCache::getMultiple
421.91 admin_menu_tree_dynamic
390.65 admin_menu_tree_dynamic
1000.07 DrupalDatabaseCache::getMultiple
421.91 DrupalDatabaseCache::getMultiple
578.17 DrupalDatabaseCache::set
281.27 menu_get_item
343.77 statistics_exit
140.64 _drupal_session_write

Clearly there's enough here to slow the site down. However truth be told I don't have much of a clue how to a) decode what all the above really mean and b) what to do about any of it.

I would be grateful for any advice or pointing in the right direction anyone can give me.


texts:
I am using the Calendar and Services Views modules.

What I am trying to achieve is a service view (JSON) that only lists available times for that day (hours list). It would be nice if, when a new event is created from 9:00am to 9:30am, that event is NOT included in the JSON, but only its available time.

Has anyone accomplished something similar before? I'm having difficulty getting started.


texts: How to get the mock of current user in PHPUnit test?

texts:
I'm trying to get a mock of current user.

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

For this I extend UnitTestCase class and loading the methods of class User.

$methods = get_class_methods('\Drupal\user\Entity\User');

Now, as load function also exists in this User class, I have created a mock of this User class and disabling its constructor and setting all methods of this class including load method which I actually need.

$user = $this->getMockBuilder('\Drupal\user\Entity\User')
      ->disableOriginalConstructor()
      ->setMethods($methods)
      ->getMock();

Since the method is set now, I'm trying to call this method once and not sure what it will return exactly.

$user->expects($this->once())
      ->method('load')
      ->will($this->returnValue('admin'));

Now, while running this test, I got 1 error:

  Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
  You have requested a non-existent service "entity.manager".

Now, my question of interest is what's the need of injecting service entity.manager?? Although load is a method of entity storage interface and also it exists in User class too. Then why this error coming up?

Can I load current user without mocking entity.manager class or entity storage interface?

Actual function for which I'm doing unit testing is:

public static function get_ctype_field_value($field) {

    $user = user_load(\Drupal::currentUser()->id());
    $ulm = get_type_id($user); // another function in some class, return value 445
    $local_market = \Drupal\node\Entity\Node::load($ulm);
    $llf = '';
    if ($local_market) {
      // Get the field value from the LM.
      if ($local_market->hasField($field)) {
        $localmarket_field = $local_market->$field->value;
      }
    }
    return $localmarket_field;
  }


texts:
Inside a block plugin I'm creating a table (in Drupal8). Like so

            $header = [
                t('Name'),
                t('Number'),
                t('Rank'),
            ];
            $nids = \Drupal::entityQuery('node')
                ->extend('Drupal\Core\Database\Query\TableSortExtender')
                ->orderByHeader($header)
                ->condition('type', 'my_content_type')
                ->condition('status', 1)
                ->pager(5)
                ->execute();
            foreach ($nids as $nid) {
                $node            = \Drupal\node\Entity\NODE::load($nid);
                $row = [
                    'data' => [
                        $node->title->value,
                        $node->field_number->value,
                        $node->field_rank->value,
                    ],
                ];
                $rows[] = $row;
              }
            $render = [
                'table'           => [
                    '#prefix'        => '
Entries
',
                    '#theme'         => 'table',
                    '#attributes'    => [
                        'data-striping' => 0
                    ],
                    '#header' => $header,
                    '#rows'   => $rows,
                ],
            ];
            return $render;

Without the code below

 ->extend('Drupal\Core\Database\Query\TableSortExtender')
 ->orderByHeader($header)

the table renders just fine, but if I do include it I get the error

  Call to undefined method Drupal\Core\Entity\Query\Sql\Query::extend()

I'm guessing that it ->extend does not work on EntityQueries, but if that's the case how can I add table sorting to my table?

UPDATE: I've changed my $header array to include 'field' like so

            $header = [
                [
                    'data'  => t('Title'),
                    'field' => 'title'
                ],
                [
                    'data'  => t('Race'),
                    'field' => 'field_number'
                ],
                [
                    'data'  => t('Time'),
                    'field' => 'field_rank',
                ],
            ];

and tried adding

 ->tableSort($header)

to the query and removing extend and orderByHeader from the query but then I receive the following error

  Drupal\Core\Entity\Query\QueryException: '' not found in
  Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable()

UPDATE 2:
I tried changing the $header array to use a specifier and type property like so.

                    'data'      => t('Name'),
                    'type'      => 'field',
                    'specifier' => [
                        'field'    => 'title',
                        'column'   => 'value',
                    ],

But I end up with the same error and get an additional error

  Undefined index: specifier in
  Drupal\Core\Entity\Query\QueryBase->tableSort()


texts:
I have a select list in my registration form here. The user can select 3 options to register for the event. For now the user has the ability to choose an early bird registration. After the periode they shouldn't be able to select that option. Is there a way to disable that option?

I have the following options:

EARLY BIRD REGISTRATION (now - Nov 1)
REGULAR REGISTRATION (Nov 1 - Mar 1)
LATE REGISTRATION Mar (1 - to conference)
SPEAKERS REGISTRATION ( now to Apr 2)
STUDENT REGISTRATION (breaks only)

After the 1nov I should be able to disable the early bird registration in the select list.


texts: Compine the author id's of two nodes in views and display block if equal

texts:
I know the title is really bad and not descriptive at all, but here is the case :

On a Drupal 7 site, each user has a "profile" page, which is a node of a certain content type, created upon registration (Content Type A).
So far , so good. I want to let each user create nodes of a Content Type B, and display their preview on their "profile" page.

For Example, let's say each user is a musician and each user has a profile page presenting themselves with several blocks and views. The purpose is to let them create content concerning their gigs, and display the resulting block with the list of the upcoming gigs.

The problem is, that trying to create a view achieving it, i cannot use as a filter the ideal, which would be something in the form [Content_Type_A][nid][authorid] = [Content_Type_B][nid][authorid], so as to display the nodes of content type B that are created only by the same author.. I tried with contextual filters (author id), but this refers only to the node that is displayed in the view (in this case Content_Type_B), so, it has no result.
Maybe it is something really really simple, but i'm stuck, since i have to declare the two types of nodes in the view in order to compare their author's ids.

Any help would be very useful.


texts:
I am uploading my Drupal Commerce Kickstart website to the host from my local computer, and I seem to be facing issues at every turn. I have not edited any of the code (trying to avoid it) or moved around any folders except in themes so it's likely something to do with that.

It does not seem to be affecting the functionality of the website but clearly I've moved (or not properly uploaded via FTP) something important. I searched through as best I could and haven't found anyone else who has broken Drupal like this so I'm feeling pretty special.

Why are modules showing up as themes?


texts:
I am getting this error

Notice: Undefined index: allowed_values_function in list_allowed_values() (line 239 of /var/www/html/drupal/modules/field/modules/list/list.module).
Notice: Undefined index: allowed_values in list_allowed_values() (line 248 of /var/www/html/drupal/modules/field/modules/list/list.module).
Notice: Undefined index: allowed_values_function in list_allowed_values() (line 239 of /var/www/html/drupal/modules/field/modules/list/list.module).
Notice: Undefined index: allowed_values in list_allowed_values() (line 248 of /var/www/html/drupal/modules/field/modules/list/list.module).

In my view I have added filters "a" and "b".

In content type "a" is list(text) with default value none. and "b" is also list(text) with default value none.

If default value is not none then I am not getting the notice.

I want the default value to be none for the fields.

What should be done so that these "Notice" do not appear.


texts: Drupal 7. Replacing core links with their aliases in theme templates

texts:
I want to check all templates before rendering and replace links
node/1 node/3 ect to their aliases

For example, i have main landing page template
page--front.tpl.php
and there are some links in this template:
Contact
I want drupal to dynamically change such links to their aliases:
Contact
So, if i change alias for specific page, all urls will remain correct

Is it possible?


texts: How to load node bypassing domain access?

texts:
I'm using the Domain Access module. One of its features is the 'Domain access option', which lets you can specify witch node is publish where.

I wrote drush script and I'm trying to load bunch of nodes from different domains. If I run drush script with site alias @X then only nodes from X domain will loaded, otherwise node_load() return FALSE.

How can I load node bypassing domain access settings?


texts:
I have a list field for a custom block type that looks like this:

left|Align left
right|Align right

I can access the key in Twig by doing something like this:

{% block content %}
  {{ content.field_align }}  {# outputs 'right' #}
{% endblock %}

However, if I do a simple comparison, it outputs FALSE.

{{ kint(content.field_align == 'right') }}

The following code returns TRUE.

{{ kint(content.field_align['#items'].getValue()|first.value == 'right') }}

Is there a shorter version for getting the "real" string so I can use Twigs string filters and keep it tidy?


texts:
I have created a view for a content type called "events," and in the view there are 2 contextual filters (by category and years).

what I want to do is to be able to view the result in 3 conditions:

only the year:  http://example.com/events/2010
only the category ID:  http://example.com/events/4
year and category ID together:  http://example.com/events/2010/4

Now the problem is that in the second case, as the argument is considered a year.

How can I set the view to be able to use a URL as in the second case?


texts: Drupal 7 Views 3 Contextual Filter - preview works as expected, the actual page not, why?

texts:
Background:

Drupal 7.2, Views 7.x-3.0-rc1

I have a view with a single Contextual Filter, 'User: Full Name'. ('User: Full Name' is a field added to the user, stores the full name of the user, like 'Peter Jackson Junior'.) In this filter's settings, under 'More', 'Case in path' is set to 'Lower' and 'Transform spaces to dashes in URL' is enabled, because the format of the path would be like this: 'site/team/peter-jackson-junior'. 'No results behavior' is set to 'Global: Text', contains 'No such user'. So the result of the view would be the profile of the user that has full name equals to argument in url.

Problem:

On the view settings page, when I test it through the preview, it works perfectly, I enter 'peter-jackson-junior' and it returns the profile of 'Peter Jackson Junior'. But, when I would like to see it in practice, and enter the url 'site/team/peter-jackson-junior' (this is actually also shown on the view preview area) in the browser url bar, I get back
'The requested page could not be found.'.

Actually, if I 'provide default value' 'when the filter value is not in the url' that is 'fixed', like 'another-full-name' it works on both the preview and the actual page (so 'site/team' gives back the profile of 'Another Full Name'), but 'site/team/another-full-name' gives back 'The requested page could not be found.' again.

Question:

What could be the problem? Could this be a bug?


texts:
Visiting my Drupal 7 site just now with IE 11, I get this message:

  Windows Defender blocked content on this website   lx7pyv.dofeqilr.com

  Hosted by: mysite.com
       Recommended icon Go to my home page instead     Windows Defender blocked this site because it might contain threats to your PC or your
  privacy.

What's up? I get no hits when I search for "lx7pyv.dofeqilr.com". I also have not issues in Chrome or FF. Is my site infected?


texts:
Is there a list of best practices (or anything on drupal.org) for maintaining Drupal versions after end-of-life, specifically, when upgrading isn't an option? The best solution, of course, is to upgrade, but some organizations do not have the resources to make that happen.

I'd like to know some good practices here, especially when it deals with financial or private data.

The Drupal LTS project looks to be dead. I do my best to monitor info problems through things like CVE, but those sources seem to only mention exploits on the currently maintained branches.


texts:
How do I configure meta tags for a panel page? I want to change title, keywords and description.

Ideally I want to use Yoast.


texts: How do I store a custom field type settings for checkboxes?

texts:
I have already created my field_type,field_widget, field_formatter  using Drupal console and also a set of checkboxes options to appear in field settings, I get this all working but when I select few options and save the settings it isn't storing those values , so when I go back again to field_settings I see the previously checked options are empty.

 public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
$elements = [];

$elements['cars'] = array(
  '#type' => 'checkboxes',
  '#title' => t('Types of cars?'),
  '#options' => array('ferari' => t('Ferari'), 'prius' => t('Prius'), 'jaguar' => t('Jaguar'), 'lamborghini' => t('Lamborghini')),
  '#default_value' => $this->getSetting('cars'),
);
return $elements;}

This is a sample piece of code of mine, I need a way of storing the values that I check on the options.


texts: Sticky at top of lists node at certain time

texts:
I would like to sticky node at certain time and update time of publishing. I tried with module Scheduler but it unpublishes content I need published content it is more like republishing and put that content at the top.

I tried some with Rules module but no success. Is it possible to that somehow?


texts: Change Omega4 Layout Based on Content Type via template.php

texts:
I want to set Omega4 Layout defaults based on Content Type. I am trying to use the following code, but the hook_omega_layout_alter doesn't seem to use the $node variable. What am I missing?

I have already referenced Omega override simple-layout.tpl.php for content types but, once I try and and a switch statement based of $node->type it stops working.

What can I do to set the default Omega4 Layout based on Content Type using the hook_omega_layout_alter function?

function THEME_omega_layout_alter(&$vars, &$layout) {
  $node = $vars['node'];
  switch ($node->type) {
    case "article":
        $layout = 'article';
        break;
    case "blog":
        $layout = 'blog';
        break;
    case "market":
        $layout = 'market';
        break;
    case "merchant":
        $layout = 'merchant';
        break;
    case "product":
        $layout = 'product';
        break;
    case "update":
        $layout = 'update';
        break;
  }

}


texts:
I am setting up a site in Drupal 7 for a photographer which includes uploading a large number of photos to the server. My problem is that image upload is extremely unstable. Sometimes it works, sometimes it does not. It seems I am hitting some kind of memory or bandwidth limit, but I don't get any errors.

I created a custom content type for photo albums, with each category (e.g. "portrait", "wedding" etc.) as a node with a number of attached images that I display using views slideshow. Everything works on the front end.

Image upload is handled by an image field and the Media file selector widget. The problem is that sometimes during upload the page will just refresh and the image does not show up in the list of attached images.

I also tried using the Plupload widget that allows uploading several images at once. With this I get a slightly different behavior. The images will "break" after two or three images meaning that they show up as corrupted images with part of the image missing. Sometimes refreshing the page or clearing all Drupal caches will allow me to upload maybe four images at once.

It looks like this

What is strange is that the same exact image file will sometimes upload, and sometimes not.

I am not uploading huge images. They are all manually resized to less than 1600x1600px before uploading, with file sizes between 200 and 600 KB.

Drupal 7.14

Media 7.x-1.2

Plupload library 1.5.4

Plupload integration module 7.x-1.0

Plupload widget 7.x-1.0-alpha1

PHP settings:

PHP version 5.3.10

Max upload size: 5M

Memory limit: 1024M (increased from 128M using ini_set() in settings.php)

Any help will be greatly appreciated! I have been googling for days trying to solve this

:::UPDATE:::
I found a temporary workaround. The module Multiupload Imagefield Widget allows multiple image uploads that seem to work for me apart from a few error messages. At least this makes it possible to load my images on to the server effortlessly.

However, this module does not show thumbnails for uploaded images which is crucial for this particular project.


texts: Can I remove Zen Default Regions if Im not using them

texts: I want to remove regions such as 'navigation' & 'highlighted' from structure/blocks just so I can visually see what is in use, and not have a list of Blocks im not using sitting there.


texts: How can authenticated users of a site join a group implemented using Groups module?

texts:
Pre-requisite knowledge:
I am using Group module to implement "Group" functionality on my drupal site similar to what Organic Groups module implements. I have a user role community-leader whose users have been granted the permission (under People > Permissions) - Technology : Create New Group so that they can create new groups of type Technology, but normal authenticated users have not been granted this permission so they cannot create groups.
Group module provides separate permissions on its configuration/overview page under Group Roles. These group roles are for users involved in a particular group. In my case, users who create the group (essentially of Community-leader role or a user-role with higher permissions) are assigned Group-leader role and then there is a Group-member role supposed to be assigned to users who will join the group created thereafter.
For these roles (both Group-leader and Group-member), permissions like Join Group, Request Group Membership, etc. are disabled (no checkbox available instead a 'x' sign is present). I believe this is because since a Group-leader created a group, he automatically joined the group and there is no meaning of these permissions for him.
Note: The above roles (both Group-leader and Group-member) are global group roles, not group-type specific roles.
Problem Statement
An authenticated user on my site is unable to access a particular group's page and thus has no way available to join the group. There is no granular(specific) permission available for this purpose.
Moreover, even Group-leader or Group-member role users cannot access groups other then their own group. How to allow that?
Could someone please guide me on Group Access Control for a better understanding?


texts: Views Data Export: How can you include a raw database column?

texts:
I'm running a data export (using Views Data Export) on some comments and I'd like to include the thread column in the result. The only thing I can see is a Depth field, which doesn't contain the detailed thread information needed to re-render the comments in the correct order. Is it possible to include the thread database column in the results?

Many thanks


texts: Can the Flag module be used to lock content while editing to prevent concurrent edits?

texts:
We are trying to figure out a way to use the Flag module to prevent concurrent editing. In our research, we found the Content locking (anti-concurrent editing) module, but we thought since we are already using the flag module, that we could also use it for content locking.

The scenario would be if a user (person a) is already editing content A, and then another user (person b) tries to edit content A, then person b should not be allowed to edit content A until person a is done editing the content.

What is the best way to do this because we are having trouble trying to find the right combination to get this done? We were thinking once a content is being edited, a flag is set to lock the content and whenever another user tries to edit the content, they are prompted with a message "person a is already editing the content. please wait until they are done".

Is this possible with the Flag module? Would I need to use the Rules modules as well?


texts: The best way to implement custom variables with Google Analytics

texts:
I need to use Google Analytics custom variables , but I want to give a different variable value depending of the urls.

I'm checking the G.A module, but I don't see how to define the variables to say when to use one token or other depending of the url.

The only way I see is build a token that checks the url and gives me back the value.

I'm thinking in something more close to Paths Breadcrumbs where you can define context and choose a token/value depending of the context.


texts: No delete button for a content reference

texts:
I have a custom block type in Drupal 8 where I reference an unlimited amount of content nodes. Now that I want to delete a reference, there’s no delete button available or label that mentions any kind of operation at all.

If you look at the "image reference field" there’s an operation to delete one image reference after another:

Where can I find this delete option for content references? Simply leaving the field blank and pressing save will raise a validation error.


texts: How to save validated third party API data if form validation fails

texts:
Here's my issue.  During user register I'm adding fields via form_alter and creating a stripe account.  When validation fails $form_state gets wiped out and when the user passes through validation again a second account gets created.

I'm thinking about using cache_set to hang on to the account info until the user gets through the registration process error free but is there a better way to do this?


texts:
I wanted to associate a file to a node. so far so good. create a cck type file, and the problem was solved. but I can not do this, I do not want the user to choose the file. the file in question is already in the system.
I have tried to place the file as # default_value field and hide it with the hook_form_FORM_ID_alter, but failed.

function my_module_form_node_form_alter(&$form, $form_state, $form_id) {
    if(isset($form['type']) && isset($form['#node'])) {
        $type = $form['#node']->type;

        if(stripos($type, 'node-type') === FALSE)
            return;

        switch($type) :
            case 'node-type_xyz':
                $fid = arg(3);
                $file = file_load($fid);

                // make a cck field_invoice a hidden field
                $form['field_invoice']['#prefix'] = '
';
                $form['field_invoice']['#suffix'] = '
';

                $form['field_company']['und'][0]['value']['#default_value'] = 'ABC';
                $form['field_account_number']['und'][0]['value']['#default_value'] = '09879';
                break;
        endswitch;
    }
}

anyone have any suggestions?


texts: What’s the right way to create a Webform node when adding a webform?

texts:
I am new to Drupal. I want to create a Webform node when adding a webform. I used the code snippet in https://www.drupal.org/docs/8/modules/webform/webform-cookbook/how-to-automatically-create-a-webform-node-when-adding-a in my .module file. After I submitted a submission, it looks like this hook code snippet didn’t execute, the Webform node didn’t be created. Any thing wrong? What’s the right way to do this?
Here is the code in my mytrymodule.module file:
/**
 * Implements hook_webform_insert().
 */
function mytrymodule_webform_insert(\Drupal\webform\WebformInterface $webform)
{

  $node = \Drupal\node\entity\Node::create([
    'type' => 'webform',
    'title' => $webform->label(),
    'webform' => ['target_id' => $webform->id()],
  ]);
  $node->save();

}


texts: getting the value of line item entity field in CommerceLicenseRemoteBase class

texts:
I am extending CommerceLicenseRemoteBase class for remote synchronization. I have added a custom line item and require that value in

CommerceLicenseSynchronizableInterface::synchronize().

How can i fetch the value of custom line item. I have tried

$license = entity_load_single('commerce_license', $id);
entity_metadata_wrapper('commerce_license', $license)

but that did not work.

Thank you