texts: Is it possible to modify the node edit form in a constraint validator?

texts:
Is it possible to manipulate the node edit form after it fails a constraint validation?

My scenario is  as follows if a user attempts to save a node and fails the constraint validation a validation error is displayed, but also a paragraph field in the form should expand as if I clicked the "Add paragraph" button. The paragraph contains 2 text fields which a user just needs to fill out so that when they save again the validation passes.

So far I've managed to successfully create my constraint and constraint validator then added the constraint to entity of type node. The validation is working properly and outputting the error message, but I have not found a way to append a paragraph into the field and have it displayed when the form reloads.

Here is my validate() function in my class that implements ConstraintValidator

  public function validate($value, Constraint $constraint) {
    if ($value instanceof NodeInterface) {
      $node = $value;
      if ('permitting_action' === $node->bundle()) {
        // Set last approved date.
        $last_approved_date = $this->getLastApprovedDate($node);
        $furthest_target_date = $this->projectDateOperation->getFurthestActionCurrentDate($node);
        $limit_date = (clone $last_approved_date)->add(DateInterval::createFromDateString('1 day'));
        if (!$this->approvedBefore) {
          $limit_date->add(DateInterval::createFromDateString('29 day'));
        }
        if ($furthest_target_date->getTimestamp() > $limit_date->getTimestamp()) {
          $reason_date_change_paragraph = Paragraph::create([
            'type' => 'reason_for_date_changed',
          ]);
          $reason_date_change_paragraph->isNew();
          $node->get('field_reason_for_pause')->appendItem($reason_date_change_paragraph);
          $this->context->buildViolation($constraint->failedValidationMsg, ['%date' => $furthest_target_date->format('m/d/Y')])
            ->atPath('field_reason_for_pause')
            ->addViolation();
        }
      }
    }
  }

As you can see I'm attempting to add the paragraph in this snippet

$reason_date_change_paragraph = Paragraph::create([
  'type' => 'reason_for_date_changed',
]);
$reason_date_change_paragraph->isNew();
$node->get('field_reason_for_pause')->appendItem($reason_date_change_paragraph);


texts:
I am using the modules Views data export and Views data export - JSON support to display data from View in the JSON file.

I am currently using 2 different terms in 1 View for example: View name "viewabc" and Terms name: "term1", "term2"

I want my JSON to render data similar to this:

{ "term1": [
 {
  "color":"White",
  "code":#fff
 }],
 "term2": [
 {
  "color":"Black",
  "code":#000
 }]
}

But I am getting my JSON like this:

[ {"no name":"Red<\/a>"} , {"no name":"white<\/a>"}]

Can you please help me to render my JSON similar to what I have described above?

Please see the screenshot of my view settings


texts: Is it required to define a route while calling form through formBuilder()

texts:
Is it required to define a separate route while calling form through

\Drupal::formBuilder()->getForm();


texts: How can i fetch the value from database in a simple module?

texts:
I'm working in drupal 7 and I have tried all help but not able to fetch the value from database.

    function myModule_load($node){

    $result = db_query("SELECT * FROM {uc_auction_bids} WHERE nid = :nid", array(':nid' => 258,));
$record = $result->fetch();

    // print the fields/values of $record
print('<pre>'); print_r($record); print('</pre>');

and also

    function myModule_block_view($delta) {
       if (($node = menu_get_object()) && ($node->type === 'product')) {
        $results = db_query("SELECT * FROM {uc_auction_bids} WHERE nid = :nid", array(':nid' => $node->nid));
        $records = $results->fetchAllAssoc('bid');

        $content = ... // Format records here...

        return array(
          'subject' => t('Bids'),
          'content' => $content
        );   } }

I want to fetch the value in module and in the page, but not at the top of the drupal header


texts:
I would like to exclude some of node field from loading while viewing nodes.
I can hide fields currently, but I want to exclude it completly from loading.
I have multivalued fields which have around 2000 records and I don't need to load it on node pages.


texts:
I am building a website in Hindi language. I was given a Database containing rows of title and body. I created a node for each row using this code :

$query = db_select('hindi', 'n')
      ->fields('n', array('title','body'))
      ->execute();

foreach($query as $item) {
    $title = $item->title;
    $body = $item->body_value;
    $values = array(
        'type' => 'article',
        'uid' => 1,
        'status' => 1,
        'comment' => 0,
        'promote' => 0,
        'language'  => 'hi'
    );
    $entity = entity_create ('node', $values);
    $ewrapper = entity_metadata_wrapper('node', $entity);
    $ewrapper->title->set($title);
    $ewrapper->field_body->set(array('value' => $body,'format'=>'full_html'));
    $ewrapper->save();
}

The nodes are display very well in the node view page, like this

But Ckeditor  doesn't perform the text formats (line breaks and ...). Like this

What is the problem?

More information

This is the result of Firebug when inspecting the Body value of the CKEditor


texts: How to create a table during the module installation

texts:
I'm trying to create a module for Drupal 7 and I need to create 3 tables and populate it. But first i need to create it.

In the file mymodule.install I have got

function mymodule_install() {

}

function mymodule_uninstall() {

}

function myodule_schema() {
  $schema['mymodule_table'] = array(
    'description' => t('First table'),
    'fields' => array(
      'id' => array(
        'description' => t('My unique identifier'),
        'type' => 'int',
        'unsigned' => true,
        'not null' => true,
      ),
      'list' => array(
        'description' => t('list'),
        'type' => 'varchar',
        'not null' => true,
      ),
    ),
    'primary key' => array('id'),
  );
  return $schema;
}

What am I doing wrong?
Every time I test the module, I disable it -> uninstall -> Performance clear cache -> enable it.


texts: How to translate metatag token into text?

texts:
I'm trying to get the data from meta tag using node_load and for some reason when is using the default field, which is Token it gives me this ugly array.

Instead of title and description that contain the strings.

Do you know how I can translate the Token into the actual text?


texts:
I have a content-type called content_A which has a reference field pointing at a user (ref_user) and a workflow field with three states.

I want to make a table using views that filters on workflow state_X and only show content where ref_user points at the same user who is logged in.

I can filter the content on the logged in user with contextual filter and that seems to work and I'm also using a relation to access the content that is referencing the logged in user. The problem is that I can't get the state filter to work, it only returns an empty result.

There are two fields that I can chose from in the filter section, the first lets me fill in a string that the state should be equal to but that doesn't work at all unfortunate (I have a space character in the state name, could that be the problem?). The second is "Workflow current: New state name" under "workflow current", which lets me select a decidable state from a drop down menu. But then I get the following error in my select query:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node.nid' in 'where clause'

Edit: For those who want to know, I found the solution. Turns out that you should not compare the state with its label or "state string", but instead with its state id. It sounds logical when I think about it but was not mentioned in the documentation (as well as I know)


texts: I have a view (using Views module), which displays a list of all Titles of a custom content type. What I want to do is add a CSS class to the posts that are new (posted within 24 hours for example). I am guessing I need to create a custom module to do this, but am confused where to start. Any help is appreciated.


texts: Edit button on content which users have permissions to edit, including their profile

texts: If I am logged in as an administrator, I get the contextual edit buttons an all blocks and nodes and can edit. If I am logged in as a user with less permission, but still enough to edit that content, those buttons aren't there. There are also no edit buttons on the user profile pages for any types of user, so if you are not an admin, you cannot easily edit this. I was hoping for a way to either turn on the contextual admin style pencil buttons for all users with permission to edit a specific bit of content, or at least be able to add my own buttons in the node or user template if allowed.


texts: How to apply patches that are created in core-dev

texts:
Noob here. I'm trying to apply patches to my website, but it's keeps skipping because the version of the patch is for DEV. For example, I want to apply a patch to Core like this issue: https://www.drupal.org/project/drupal/issues/2579343.
How should I apply patches that are in core-dev?
Thanks!


texts:
I am trying to enable modules via POSTing to /admin/modules in a simpletest. It works fine, except that there are dependencies (the whole reason I want to do it this way) and when it requires then "Continue" button be pressed on the module enable confirmation page, it fails, claiming it couldn't find the button. Here's the code:

    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
    $this->assertResponse('200');
    $this->drupalPost('admin/modules/list/confirm', $edit, t('Continue'));
    $this->assertResponse('200');

Not only does it fail, it also seems to skip over the first assertResponse().

How do I enable modules with lots of dependencies in simpletests?


texts: Does Page Manager redirect work on alias paths?

texts:
I am attempting to do a simple custom  page redirect using page manager following the example from NodeOne.se videos on Page Manager. While the video works, my attempt does not and I can't see the difference other that the alias path I use.

The  URL I want to intercept is specs/%spec so I have created a custom page with that URL. I have configured the page with one argument to interpret %spec as a taxonomy term ID.

Next I created a variant set to perform an HTML redirect (301) to the URL materials/%spec:name/facts (This URL will call a view). There are no selection rules so all content will pass. Thee are no contexts or relationships since the argument for the term name is already visible in the summary of contexts present.

My expectation is that a URL such as Example.com/specs/term1 should redirect the website display to the contents called by the view page /materials/%/facts using with term1 applied as a contextual filter giving me a URL of example.com/materials/term1/facts.  Since the URL is passing the context to the view,  I should not need to pass arguments through page manager/panels UI.

My result is when I enter the specs/term1 URL, the taxonomy page for that term is shown and the URL is not changed.

The only thing I can guess is that this does not work on aliases. Any ideas on why this fails anyone?


texts: Jquery Library Conflict Error in Drupal 7

texts:
I've been currently developing a module. Before it was working fine but as I started working on my module, the console throws an error every time I click a link in my Drupal admin menu.

For example:

When I click the "dashboard" link , it says:

When I click the "content" link, it says:

By the way, jquery-1.11.2.min.js is a JQuery library I added in my hook_init function to keep my module working.

function myid_init (){
    //Jquery Library
    drupal_add_js(drupal_get_path("module", "myid") . "/js/jquery-1.11.2.min.js");
}

Im using drupal 7.34. Can anyone explain me, why is this happening and how to fix it? Thanks.


texts: what is the meaning of $Id$ at the head of module files?

texts:
I have seen this line at the head of many files in Drupal modules:

; $Id$

what the meaning of it? What does it do?
Is it important ? Should I put it when I am writing my own module?


texts: Users restricted from editing own profiles

texts:
I found that non-site-admins cannot edit any of the custom fields attached to their profile. I have found the Organic Groups (fixed) feature request "Authenticated users cannot edit his custom profile fields" that appears to explain the issue, but that's not clear enough for me.

Who exactly is the Group Audience for the User (the User?) and how do I set up the settings correctly to ensure all users can access and view their custom profile fields?

Is the User a "Group" and the Custom Profile Fields "Group Content"?


texts: Views Bulk Operations with Field Collection Item tokens

texts:
I am trying to modify the values of one field in all instances of a field collection type.
I have a view listing all field collection items, that I want and an operation field with modify entity. Setting value in the field works fine, but I can't use any tokens from the current item, only site tokens are available.

Can this be done with VBO? Are there any other easy ways to do it?


texts: Twig template for custom entity not working

texts:
I created a custom entity called 'Representative' using the drupal console 'generate:entity:content' command.

The entity works correctly I added a bundle of fields to it, added some content, and can query this entity using the EntityTypeManager query.

My problem is - I can't render this entity in twig.
When I pass this entity to the render array:

    $build = [
  '#theme' => 'representatives',
  '#representative_entity' => $representative
];

I get the following error:

Exception: Object of type

  Drupal\kelk_representatives\Entity\RepresentativeEntity cannot be
  printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line
  476 of core/lib/Drupal/Core/Template/TwigExtension.php).

(I was using drupal console to automatically generate the twig files and preprocess functions)..

Can anyone help?


texts: Hide or disable field after registration

texts:
I have 1 field on user registration page that should not be changed after account registration. It needs to be hidden or disabled.
Which module can do this ?


texts: Allow user to join group during registration

texts:
I am using D7 with Organic groups and Organic groups register. I have created the groups and when viewing a group node the link to 'Request group membership' is visible and working.

I wish a user to be able to select a group to join when registering to use the site. I have been unable to get this to work despite lots of attempts.

This issue has been discussed quite a bit as a number of people have problems with it. There is a very short answer to a previous Drupal Answers question but it isn't very explicit. Judging by the lack of up-votes, I suspect other people have been unable to use the solution successfully.

This comment in a thread about the issue discusses the steps, but lots of people, myself included, have been unable to get this to work. People in another thread are also having problems with this.

I am hesitant to create a duplicate question, but there seems to be a real need for this to be documented clearly in a way that people can follow.


texts: How to create a list of untranslated content in views?

texts:
I want to create a list of all nodes that has not been translated into a specific language - how do I do that?

I'm using Drupal 8.


texts: Show right node revision for View Draft, View Publised links

texts:
I am using panels to override node template and on panels I am adding views blocks for the node content. I have workbench moderation enabled for this node. Issue is in showing the appropriate revision of node for workbench for example

When I use View published or View Draft link, I am seeing all revisions of node field instead of current revision for View Draft and published revision for View published.

The view I have created is on base table: node_revision and fields I am adding are Content (historical data). from panel I am passing Revision ID as context to view and in view I have contextual filter set as Content revision: Nid

Do I need to create two separate views display filtered by Workbench moderation : current and Workbench moderation : published and switch between them on basis of URL having draft or not?


texts:
I have made a migration module to import the full content from a legacy Drupal 6 site to my new Drupal 7 site, using the migrate d2d module. Everything works fine, but I have just discovered that there are many custom meta tags added manually for both nodes and taxonomy in the legacy site (using the Metatags module). The taxonomy meta tags I can deal with manually, but I really would need to figure out how to add the mapping for metatags in my node migration classes. Do I add code in my general migration class in node.inc (that extends DrupalNode6Migration)?

Do I use prepareRow() to fetch info from the database and add this to a mapping with a default value in the new site? As far as I can see there are no fields in the legacy site that holds the metatags (I need title, keywords and description).

If anyone knows how to do this, please help.


texts:
Got a bit of problem setting up my view filter for taxonomy term.

Here is what I want to do;
I want my view page to display a filter(drop down) where users can select a item and pictures will appear.

What I've done:
I have created a new content type with a picture field and a taxonomy term(item) and in that taxonomy term I have entered some random values. I added some random content from that content type with a number on taxonomy terms. Right so forward to my view.

In my fields area I have the content of the taxonomy term(item) and also my picture field.

In my filter criteria I have the content type itself AND the has taxonomy term. In that I have choose the taxonomy term (item) and added the operator of "is one of" and I can see all my listed taxonomy terms.

Ok so cool, my drop down appears and I can see all of my taxonomy terms I have listed before and i can then select a item. BUT the problem is that the content does not show on the taxonomy term. Everything shows on Any but when it comes to a taxonomy term it does not display. It's wired because I can see the taxonomy term displayed above the picture.

Any idea what I've missed.

Sorry for messy text, hope I explained it well enough.

Cheers


texts:
I'm pretty new at Drupal (about two weeks), but I'm starting to see the huge amount of possibilities. It is a fine piece of engineering.

I've got a content type, called Products, which is shown in a panel pane and also has a page for itself. I want to output fields differently in both situations, but tweaking the node--product.tpl.php I've realized that I modify both the node in the content pane AND the page.

Is there any way that I can template the two of them in different ways?

Thanks,
Hector


texts: How can I have the URL path (node slug) be different from the Title?

texts:
It seems like this should be super simple, but I can't seem to figure it out...

I have layouts with headings and subheadings, (shown below) where the highlighted/top heading is the page/node's title.

So the issue I'm having, is that the system then makes the slug "stay-connected-with-campus" but I want it to be "parents" and "parents" is just redirecting to "stay-connected-with-campus"

Where or how can I control that?

My URL path Settings:

And there are no redirects set:

Thanks!


texts: Deprecate multisite in 8.x for removal in 9.x

texts:
I am thinking about implementation of some sites with multi-site and idea of solution (one code-base) is perfect for me even if shared table is not supported any more (my question about shared table is here also i'm aware of domain module too).

After some search, I found this topic about plan to deprecate multi site in 8.x and removal in 9.x.

My questions  are:

How serious is deprecation in 8.x and removal plan of multi-site in drupal 9? the topic is in category of plan for two years.
Even if removal happens in 9.x, we have to expect some migration path to removal of 9.x or not? In my idea this migration didn’t happen for shared tables.
Proposed solution for removal of multisite in mentioned topic is

  The modern approach to multi-site is: git — Same code, different
  sites. Under your control. And well-maintainable.

I can’t understand it. How does it works?


texts: Use administration theme for verified users when adding or editing content

texts:
I'm having a problem with the administatration theme. I want verified users to see the administration theme when they are adding or editing content. Right now only the admin user sees the administration theme and verified users see the standard theme. Is it possible to also enable this for verified users?

Thanks!


texts: Node Preview not working for anonymous users drupal 7

texts:
I want Anonymous users to post Events on my site and moderators can moderate and publish it. I have set "Preview before Submitting" option  to "Required". Preview is not working for anonymous users. It does not display node preview on top and not giving "Save" option at the end of page.

Is this Drupal default behavior or some misconfiguration?


texts: How can I disable all the JavaScript scripts?

texts:
I am trying to disable all the JavaScript on all the pages of a Drupal 8 site for anonymous users if there is a particular header in the request object.
I tried out this code.
/**
 * Implements hook_js_alter().
 */
function MODULE_js_alter(&$javascript, AttachedAssetsInterface $assets) {
  if (MODULE_get_headers()) {
    unset($javascript);
  }
}

/**
 * Implements hook_page_attachments_alter().
 */
function MODULE_page_attachments_alter(&$attachments) {
  // This is for disabling all 3rd party libraries.
  if (MODULE_get_headers()) {
    $attachments['#attached']['library'] = [];
  }
}

It does seem to work to a certain extent. It disables most of JavaScript, but I am seeing the styles are also off (which might be expected) as the CSS libraries might also be removed.
Is there a better way to do this? Maybe Drupal has an option to turn off all the JavaScript.


texts: How do you override page.tpl.php in Omega 4?

texts:
I am using the Omega 4 base theme, and am trying to override page.tpl.php.

This file is in the base theme in sites/all/themes/omega/templates/system.  When I copy it into my theme, edit it, clear caches, I don't see my changes?

Why can't I override this template?


texts: drush inheritance, site-ssh and site-list

texts:
It's possible I'm going about this all wrong, and I should be setting up my aliases file differently.

We have a set up with 4 load-balanced production servers running the same code and accessing the same database. I want to set up a drush aliases file to access them by a short name and also allow commands to be run on all of them simultaneously. Here's what I have so far, in ~/.drush/cust.aliases.drushrc.php:

<?php
$aliases['production'] = array (
  'root' => '/var/www/cust',
  'uri' => 'www.example.com',
  'databases' => array(
    'default' => array(
      'default' => array(
        'database' => '...',
        'username' => '...',
        'password' => '...',
        'host' => '...',
        'port' => '3306',
        'driver' => 'mysql',
      ),
    ),
  ),
  'site-list' => array(
    'production.1',
    'production.2',
    'production.3',
    'production.4',
  ),
);
$aliases['production.1'] = array (
  'parent' => '@production',
  'remote-host' => '...',
  'site-list' => array(),
);
$aliases['production.2'] = array (
  'parent' => '@production',
  'remote-host' => '...',
);
$aliases['production.3'] = array (
  'parent' => '@production',
  'remote-host' => '...',
);
$aliases['production.4'] = array (
  'parent' => '@production',
  'remote-host' => '...',
);
?>

Now the problem I have is that the site-list variable is being added to the individual definitions, so the site-ssh command thinks that they are a list. I've tried a few things to sort this out, including adding 'site-list' => NULL, 'site-list' => array() and 'site-list' => '' to the the production.x definitions, but this doesn't work since site-ssh just uses isset. Neither do my attempts to use the unset function because the inheritance happens after I've tried to unset it.


texts: Prepopulate additional instances of a multivalue text field based on another existing text field?

texts:
Consider the following (newly created) form:

field_country (option select)
field_phonenumber number (multivalue text field)

When the user chooses from field_country, then the user can add unlimited instances of field_phonenumber fields, which should be pre-populated with the selected country code.

I was able to prepopulate the first instance of field_phonenumber with AJAX, but not the additional instances.

$form_state->getValue(field_country) was empty for the additional instances of field_phonenumber.

Any thoughts are much appreciated.

Edit: the code I tried so far:

function testmodule_entity_type_alter(array &$entity_types) {
  $handlers = $entity_types['node']->get('handlers');
  $handlers['form']['edit']     =
    'Drupal\testmodule\Form\CompanyContactInfoForm';
  $handlers['form']['default']  =
    'Drupal\testmodule\Form\CompanyContactInfoForm';
  $entity_types['node']->set('handlers', $handlers);
}

namespace Drupal\testmodule\Form;

use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeForm;

/**
 * @ingroup testmodule
 */
class CompanyContactInfoForm extends NodeForm {

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form = parent::buildForm($form, $form_state);

    $form['#attributes']['id'] = 'form-fixed-id';

    $form['field_country']["widget"]['#ajax'] = array(
      'callback' => '::addCountryCode',
      'wrapper' => $form['#attributes']['id'],
      'event' => 'change',
      'method' => 'replace',
      'progress' => ['type' => 'throbber', 'message' => t('Adding country calling code..')],
    );

    return $form;
  }

  public function addCountryCode (array $form, FormStateInterface $form_state){
    foreach (array_keys($form['field_phonenumber']['widget']) as $key) {
        if (is_numeric($key)) {
            $form['field_phonenumber']['widget'][$key]['value']['#value'] = static::getCountryCode($form_state->getValue('field_country')[0]['value']);
        }
    }
    return $form;
  }

  public static function getCountryCode ($country) {
    $codes = array(
        "Belgium"     => "+32",
        "France"      => "+33",
        "Greece"      => "+30"
    );
    return $codes[$country];
  }
}


texts: How do I check Organic Groups group permissions from a custom module?

texts:
I'm trying to show or hide a button based on if a user has permission to post content to a group or not, but I don't seem to be able to call the og_user_access function from my custom module.

I've tried calling it directly while loading the module file:

module_load_include('module', 'og');
$allowed = og_user_access('group', $group->nid, 'create resource content');

Doing this crashes the page with no Apache error just a watchdog error of:

  Error: Class name must be a valid object or a string in entity_get_controller() (line 8066 of /data/home/rsdev/www/content/lnsres.rsdev.ca/web/includes/common.inc).

I've also tried using module_invoke like so:

$allowed = module_invoke('og', 'og_user_access', 'group', $group->nid, 'create resource content');

Calling the module like this doesn't crash the page, but it also doesn't return anything and if I add some dpm() calls in the contrib module function I notice it's not even being called. Doing some reading about module_invoke appears like it's mostly used to call hooks, which I don't think og_user_access is, so I'm not sure if that's even the correct path to take.

How should I check group permissions in OG from my custom module's code ?

EDIT: This is not a duplicate of Display data basing on the group permission
because I'm not trying to use a permission I created. Also the only answer in that question doesn't work for me because as I explained, I can't call og_user_access without an error.


texts:
I installed Drupal 8 today, the release candidate 3. I had not done any modifications to it. When I edit my first article, I can't insert images. I clicked on the image button, but it keeps loading forever. I saw other people clicking the image button and a pop-up appearing.

Do I have to install a module?


texts: How do I display individual date display nodes of a commerce event with recurring dates?

texts: I have created a commerce product type for a class that occurs every Monday for 10 weeks. I have the 10 dates displaying in a Calendar view using a start date and a repeat rule. What I can't figure out is how to create display nodes for the individual dates so I can add a recording of the class after it has occurred...possibly required reading beforehand; anyway, is there a way to display individual nodes in this context?


texts: Multiple condition in Conditional Field doesn't work

texts:
I am using Conditional Fields Module to show and hide fields according to the condition selected.

At first, I have a Select List with 3 Values (Mind, Body, Soul)

When I select Body the two fields (Body, What are your diet Plans?) shows up, like in Picture:

When I select Soul another Two fields Show up:

But When I select Mind, I get only one field, even though I have configured it to show two fields.

My Conditional Field Configuration is:

The issue here is, What are your prayers? field is configured to show when either Mind or Soul is selected from that Select List

I have configured it correctly using OR in the field condition but it(what are your prayers?) only shows while selecting Soul from the select list.

Any ideas what is wrong here?


texts:
I am trying to write a custom relationship between two tables for Views, and it doesn't seem to be working. The code for my relationship is this:

  $data['gov_data_bill']['sponsor'] = array(
    'title' => t('Sponsor'),
    'help' => t('The ID of the sponsor to this bill.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'relationship' => array(
      'base' => 'gov_data_person',
      'base field' => 'id',
      'handler' => 'views_handler_relationship',
      'label' => t('Cosponsor'),
    ),
  );

I would think that this would make the column gov_data_bill.sponsor and gov_data_person.id be the keys for the join, however that's not what I'm seeing. For some reason, Drupal still thinks that I want to use the id key on both tables.

What am I doing wrong here?


texts: How to create Taxonomy Terms child views

texts:
I want to display taxonomy terms list.

I have a taxonomy named "Categories", I want to make a views page where all terms displays which has no childs. If user clicks on any listed terms then next level of respective terms displays and so on. If a term doesn't have any child terms then it should displays post of related term. My content type posts will be attached to last level of taxonomy.

Is it possible using Drupal 7 Views? Help me please.


texts: Media module - CKEditor embed not working - jQuery is not defined

texts:
I'm trying to use the media module along with CKEditor in a Drupal7 build.
I've enabled the modules, added the embed media button to the editor's toolbar and it works to a point - the image uploads, and styles/variations created. But I can't actually embed it as the final screen of the overlay (type in alt text, choose size etc) the buttons stay as 'fake' buttons.

Looking in console the error is Jquery is not defined.

Anyone have a fix for this?


texts: Metatags module not rendering tokens in content

texts:
We created custom tokens for a site and they are included in things like titles and summaries, so are picked up by the metatag module. However, when I look at search results in Google, I see the variable [token] and not the rendered value in the search results.

Is there a way to fix this?


texts:
In D7 is used to log using Watchdog function. In D8, I see its gone and I should use something called the logging API.

What I a trying to do:

I have created a menu/route, mysite.com/logmessage
When user opens that url in browser, I want to log "hello" to the dblog.

Where should I register the service that D8 documentation says to do? Is it in the services.yml file in sites/default folder?

Can I just load the said class in my controller/module file and call the function for logging? Or should I explicitly extend the class first in my module before using the function?


texts:
Command variable-get requires Drupal core version 6 or 7 to run.
The drush command 'variable-get' could not be executed.

drush st
 Drupal version                  :  8.7.3
 Site URI                        :  http://default

How do I get to change variables with a fresh install
** I did not upgrade - I'm a newbie to Drupal

I have looked at the drush/commands/core/variable.drush.inc
I can see that
    'core' => array(6,7),
    'core' => array(6,7),
    'core' => array(6,7),
but changing any of it is just breaking it further and weirder ;-)

any suggestion ?
I like to be able to update user's attribute email password from the CLI


texts: Adding Pagination to to custom form block results

texts:
I have created a custom block that has a form which has a list of result and I wanted to know how to add pagination to the results

Thanks for any help on this

Colin


texts:
I'm using:

Drupal 7
CKEditor 7.x-1.18
Jquery Update 7.x-3.0  (running jquery version 1.10)

I don't understand how to make the 'Font' & 'Size' dropdowns appear on the CkEditor interface.

The first image shows the settings for the "Full HTML" profile.
The second image shows the CkEditor in action.  You can see that there are lots of buttons missing, but at the moment, I'm only interested in making the 'Font' & 'Size' dropdowns appear.  You'll also notice that even though "Styles" hasn't been selected on the "Full" profile - it still appears here !?!?

I have been to the CKEditor site and downloaded the full package from here: http://ckeditor.com/download

The existing CKEditor install says to download, "Then
uncompress the contents of the "ckeditor" directory of the downloaded file to
this folder (modules/ckeditor/ckeditor)."

I appreciate similar questions have been asked before, but none of the solutions offered have worked for me.

pic 1 (above) Editing the Full HTML profile for CkEditor

pic 2 (above) Buttons are missing, and Styles has appeared !?


texts: How can I prevent some configuration settings getting overwritten?

texts:
I tell drush this:
drush @live cim --skip-modules=system,swiftmailer

and Drush replies with this:
  Collection  Config                 Operation
              swiftmailer.transport  update
              system.performance     update
  Import the listed configuration changes? (y/n)

and, if I reply "y", the settings in the live Drupal site are overwritten from settings previously exported from the dev system.
What do I have to do to avoid importing selected parts of an exported configuration?


texts: How to show drupal error messages in batch scripts?

texts:
I'm using a few scripts for one-time data checking and scrubbing. They load the Drupal bootstrap but not the UI:

require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

How can I display any error messages that they generate?


texts:
We are working on drupal 6.26, Our requirement is as follows.

In the admin/cms section we will assign country to a node.
In the front end when visitor visits web site according visitor, respective country node will be displayed.

I searched some modules but I am bit confused.

Please advice us some good module.


texts: What's the "Drupal" way of creating image links?

texts: I know that the correct way to create links in Drupal is to use l($text, $path, array $options = array()). But that only allows for text links. Is there a similar function for creating images that link, or is it OK to just write out the HTML?


texts:
I recently faced a need of reusing some content, creating content templates (not in the usual meaning of the word).

I have content that is created periodically, a product for instance, which differs from another by one or two fields, all of the rest stays the same, so I thought of reusing content.
Have you ever seen a module that would accomplish that?


texts: How to prevent users (except for admin / editors) from viewing canonical page for content type?

texts:
For a certain content type, if you want most users to be able to view the content type (node bundle) when it's loaded on landing pages or on other node pages, but you don't want them to be able to access the route entity.node.canonical for the content type, unless they have an explicit permissions (which would be given to admin role and editor role), what is the best way to do this in Drupal 8?

As an example, let's say a site has a "video" content type, when it's loaded in a block, such as a related videos block, you want everyone to be able to view it, but if a user tries to go to that video's canonical page, they get a 404, unless they have the role with the permission to view it.

This would be for certain bundles of content or media entities that I want to only allow access to in a block, but the canonical page should 404 if the user doesn't have the correct permission.

What is the best strategy to set this up in Drupal 8?


texts: Linking to jQuery in block breaks Gallery formatter

texts:
At the top of my block, is this line:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

This is the reason why the Gallery formatter does not display correctly.

The entire block contains the following:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript" src="http://localhost/nes/sites/all/themes/nesvesti/js/facebook/fb-traffic-pop.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){
    $().facebookTrafficPop({
        timeout: 10,
        delay: 0,
        title: "Support Us...",
        message: 'Like the page...',
        url: "http://google.com",
        closeable: false,
        opacity: 90
    });

});

</script>

My question is, is there any way to resolve this conflict?


texts:
Problem

I'm setting up Authcache to work with Varnish as a backend.

It comes with an excellent default.vcl which is very well documented. It has the following section on cookies. Varnish skips the cache if cookies are enabled, so the following example would appear to remove all cookies so it can cache.

However I've found if I un-comment this section Authcache stops caching. If I leave it commented out then it continues to cache and cookie functionality seems to work. (e.g. I have cookies which remember the state of facets across page refreshes and they continue to work).

Isn't this the wrong way around?

(I'm using Authcache debug to test for caching).

// * Example 2: Remove all but
  // * - the session cookie (SESSxxx, SSESSxxx)
  // * - the cache invalidation cookie for authcache p13n (aucp13n)
  // * - the NO_CACHE cookie from the Bypass Advanced module
  // * - the nocache cookie from authcache
  // *
  // * Note: Please also add the has_js cookie to the list if Authcache Ajax
  // * is also enabled in the backend. Also if you have Authcache Debug enabled,
  // * you should let through the aucdbg cookie.
  // *
  // * More information on:
  // * https://www.varnish-cache.org/docs/3.0/tutorial/cookies.html
  // */
  //if (req.http.Cookie) {
  // set req.http.Cookie = ";" + req.http.Cookie;
  // set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
  // set req.http.Cookie = regsuball(req.http.Cookie, ";(S?SESS[a-z0-9]+|aucp13n|NO_CACHE|nocache|aucdbg)=", "; \1=");
  // set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
  // set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
  //  if (req.http.Cookie == "") {
  //   unset req.http.Cookie;
  //  }
 //}


texts: Add multilingual support to Drupal 8 Hello World module

texts:
Today we already can upgrade contrib projects to Drupal 8 (#D8CX) and there are more and more “Hello World” code examples for Drupal 8. Some of them:

Drupal 8: Writing a Hello World Module
Drupal 8: Hello OOP, Hello world!
Drupal 8: Hello, Configuration Management
Drupal 8 module development #3 - adding a settings page - revision
Drupal 8 isn't Scary, Pt. 1: Introduction & Creating a Hello World Module

Can we add multilingual support to such simple modules?


texts: What is correct selector for radios to determine if ANY radio is selected?

texts:
Using #states to change form element visibility, I would like a 2nd element to be visible only if the 1st element is filled in. The first element is a pair of radio buttons, so I tried:

  '#states' => array('visible' => array(
  ':input[name="radio-id"]' => array('value' => '0', 'value' => '1'),
    ),),

However that doesn't work, the 2nd value condition clobbers the first, so the other element only appears if the 2nd radio ('1') is checked. So then I tried:

    :input[name="radio-id"]' => array('checked' => TRUE),

Nope, that doesn't work either.

What is the correct syntax to use for this, and which documentation page is it on? (drupal.org or other site?) I've looked and looked but can't find it.


texts: How to have different style files in multilingual website using Drupal?

texts:
I have been developing a multilingual website using Drupal 6. The languages are English and Spanish. I want to have some different backgrounds and css for them. But both use just style.css.

How can I create different style.css file for them? For example style-sp.css for Spanish one and en-style.css for English one ?

Is it possible ?


texts: How to clean up multiple Drush Composer installs?

texts:
I've been setting up a new Ubuntu 16.04 laptop for Drupal development. I had trouble installing Drush using Composer, but eventually got things working. Today, while setting up Drush tab completion, I discovered five instances of drush.complete.sh:

$ locate drush.complete.sh
/home/monkey/.composer/global/drush/drush/vendor/drush/drush/drush.complete.sh
/home/monkey/.composer/vendor/bin/drush.complete.sh
/home/monkey/.composer/vendor/drush/drush/drush.complete.sh
/home/monkey/.config/composer/vendor/bin/drush.complete.sh
/home/monkey/.config/composer/vendor/drush/drush/drush.complete.sh

*cough* I think I need to clean things up and start from scratch. How can I correctly uninstall all these Drush instances?


texts:
I am sending a link for a survey (webform 3.x) to users.  Based on a variety of information, they receive a link in the format http://www.domain.com/group/userid.  I'm able to retrieve the /group easily and process this into a hidden field on my webform.  However, the page "/group/userid" does not exist.  I need to find a way to rewrite the URL to go to /group?i=userid.  I'm currently using clean URLs, but am open to changing.  When I attempted the rewrite via htaccess, I lost the theme of my site (likely a path issue).

Is there a module for this sort of thing?  Any suggestions?

KMT


texts: Not able to log in to Drupal site as other user

texts:
I am a site admin (Drupal 7 - all updates are current) and am able to log in with my own credentials.  I'm working an issue and need to log in as another non-admin user.  No matter what I try, I'm not able to log in as this particular other user though I have verified their user email address and password.  I have copied and pasted their email address directly from their user account.  I have also reset their password so I know it is correct.  I have tried turning off clean url's (as suggested by another forum), but that didn't help.  I have cleared the site cache.  I contacted the user and she is able to log in/out and back in with the exact same credentials I'm attempting to use.  We have had this problem with another non-admin user on this particular site but it hasn't happened in quite a while and never with this user.  I have logged in as this user prior to this happening but it has been a few months.

I saw another post on this site about the same thing but didn't really see a solution (Cannot log in to Drupal site).

Does anyone have any ideas?  This is quite an inconvenience.


texts: How to migrate Link Fields ('title' and 'url') involving local variables?

texts:
I have performed the following query:

$query = db_select('sage.USER', 'USER')
  ->fields('USER', array('USER_ID', 'OFFICE_ID', 'USER_PASSWORD'))
  ->range(0, 1);
$result = $query->execute();
...
$url = '/sage/office-' . $result->office_id;
$arguments = MigrateLinkFieldHandler::arguments(array('source_field' => 'office_id'));
$this->addFieldMapping('field_office_id', $url);
  ->arguments($arguments);

However, the above is not working. I would like to manipulate the 'office_id' field to be used as the 'title' and the variable $url to be used as the URL that was linked. I have followed what's on this post

Could someone please point out my mistakes?

EDIT: Updated question to reflect jdu's answer.


texts: How to add an image field to a programmatically created form?

texts:
Basically I want to create a block with my module which's edit page has a few content fields and two image upload fields. When visiting the node where this block is rendered, I want to render the images with a certain image style, while on the edit form it would be cool to show the images as a thumbnail preview.

I am adding a field like described here: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#managed_file but this makes me curious:

  New files are uploaded with a status of 0 and are treated as temporary
  files which are removed after 6 hours via cron. Your module is
  responsible for changing the $file objects status to
  FILE_STATUS_PERMANENT and saving the new status to the database.

Also, what is the difference of managed_file and file when I want to provide an image upload field?

Currently I have in hook_block_configure:

$form['left']['image'] = array(
        '#type' => 'managed_file',
        '#title' => 'test',
    );

Where do I define how this image shall be rendered (image style)? Do I have to set that permanent flag?

Thanks


texts: How to assign a rendered view result to a variable without displaying it on the screen?

texts:
I am working  on a module to collect the results from several views, to be concatenated and then displayed. The views are returning JSON data using the views_datasource module.
To do this, I tried to set a variable to be the output of a view like so:
$my_view = views_get_view('drupalgap_content');
$my_view->set_display('getlatestdigest');
$output = $my_view->render();

Then I could concatenate the $output to another views output etc.
The problem lies in the fact that as soon as I call $view->render() it renders the view results to the screen (I presume with a print() function) somewhere deep in the views core module.
After a ton of googling, I found that in the past, $view->render() used to return a value, and this method was correct.  However, somewhere along the line, they changed it so $view->render() it renders the view results to the screen, making it impossible to concatenate the view output to another view output.
Other options I've looked into that don’t work:

$view_result = views_get_view_result('drupalgap_content','getlatestdigest');
This gets the view result, but it does not get the rendered JSON output that I need from the views_datasource module.  So, it’s no good.

$view-execute(),$view->preview('getlatestdigest'); $view->execute_display('getlatestdigest', array());
All of these three functions do the same thing as view->render(), i.e. they output the nicely formatted results I want to the screen instead of assigning them to a variable.

views_embed_view('drupalgap_content',  ‘getlatestdigest');
does the same thing as view->render(), i.e. outputs the nicely formatted results I want to the screen instead of assigning them to a variable.

I should also mention that I am calling this module’s function using an AJAX call from a mobile app to the menu_hook for this page_callback.  So I can not have it outputting anything to the “screen” until it is ready since AJAX will return the data to the client as soon as the output to the screen is called.


texts: Relative date in grouped filter does not show textfield for data

texts:
I have a problem with grouped filters. I want to specify a relative date but a textfield does not appear. My result was

I want to achieve something like this below.

Credits to the owner of the pic.


texts:
How can I include body content on a dynamically generated page?

The page in question is defined in hook_menu(). I have successfully given it a title but I don't know how to give the page text content.


texts: Alter create content form when logged in as admin

texts:
Can I alter the form where you add content (logged in as administrator, so in the overlay)? I know how I can alter the form when logged in as a user like this:

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

}

But how can I do this for administrator in the overlay?

UPDATE:

when I do hook_form_alter in my template.php of my subtheme and dump the form variable nothing happens when I open form in overlay... Also tried this in a custom module. NOTHING shows.


texts: How to redirect before page processing along with all the sent data?

texts:
I have a link on my Drupal page. This link points to the page "\node\23423". When user clicks on this link, the user should get redirect to another path "\node\45644".

But this should happen before Drupal starts processing the original path. Also any POST data that is being sent to the original page should be passed to the next redirect page.

Is there a possible way to do this?


texts: MySQL query for getting blog records/content Drupal7?

texts:
I want to customize the and limit the content from the blog entry. If I want hook the sql query output for blog entry, How can i do it?
Please help me.


texts: Is every image style I have for each image upload auto-created?

texts:
I believe I understand this about Drupal 8: every image uploaded will automatically be created in each of the image styles I have set up (or the default 3 that come with core).

This incentivizes me NOT to create very many image styles, because then I'll end up with a bunch of different copies of my original image, whether they will ever be used in that particular style or not.

Is that correct?

On the other hand, Molot's answer over here mentions that "styled image files are supposed to be created on first access". That gives me hope that if I upload an image, it will only be created in an image style the first time it is requested in that image style. That means I could have as many custom image styles as I need and not worry that an image will be created for each one of those every time.

For example, if I have 12 custom image styles, but I only call a certain image in one style, will I end up with only 2 copies of the image, one as the original upload and one in the only style I called? This is what I would love to be true.

Thanks for any insight.


texts:
I am trying to add a body class to my site in template.php based on whether or not a node is published or not. I had a look around here and on drupal.org and pieced together some code but I am getting an error. Here is what I have tried so far:

function responsive_process_html(&$variables) {

 if ($node->status == 1){
        //$variables['#attributes']['class'][] = 'pub';
        $variables['classes_array'][] = 'published';
    }

    else {
        $variables['classes_array'][] = 'not-published';
    }
}

... but I am getting this error:

Notice: Undefined variable: node in responsive_process_html() (line 37 of /sites/all/themes/responsive/template.php).
Notice: Trying to get property of non-object in responsive_process_html() (line 37 of /sites/all/themes/responsive/template.php).

I also tried $variables['#attributes']['class'][] = 'published'; instead of $variables['classes_array'][] = 'published'; but it made no difference.


texts: Content Access exclusive permissions per node

texts:
I'm playing around with content_access module, and I have a question. For my use-case, I need particular nodes to limit editing by role. This means that the content type will allow role_x to edit by default, but a particular node of that content type will not.

The way it's behaving is inclusive from the top down? If the role has permission on the content type, then they have permission on all nodes of that content type. It's only editable on the individual nodes if they DON'T have that particular permission.

Can someone tell me for sure if that's the proper behavior, or if there's a way around it? And yes, I DO have "Enable per content node access control settings" checked for the content type.


texts:
I am using a custom module (copied from a site where it is working)

The module's .info file is as follows:

name = jCarousel Rotator
description = An image rotator implementing the jCarousel jQuery plugin
package = mymodules
core = 7.x

stylesheets[all][] = css/jcarousel_rotator.css
scripts[] = js/jquery.jcarousel.min.js
scripts[] = js/jcarousel_rotator.js

But none of these files are loading.  The theme I'm in is made from scratch.. is there something that needs to be added to the template.php for those include hooks to work?

I searched all the code of the old site and the files are not being explicitly loaded elsewhere.

I have been able to load the files by adding the code manually to the footer, but this is not a great way to have a module integrated.

As requested, my html.tpl.php is as follows:

<?php include 'header.php'; ?>
<?php echo $page; ?>
<?php include 'footer.php'; ?>


texts: Need Ability to Override Default text field

texts:
When the textfield is left blank, a default value populates. But when a value is placed into the text field, that value should show on the front end. It currently does not.

I have  admin rights to edit,view any pages. I have enabled everything for adminstartor roles under User Management->roles. Even then am unable to update a new value to that field. It is populating the default value.


texts: I'd like to be able to notify a fellow publisher within the drupal permissions group that a new piece of content relevant to their page has been published. NOT an end-user alert, but just an internal alert on Drupal.


texts: How to get value properly from form field?

texts:
I search the best way to get value from  form field, and I would like to know if my code section below it's the only way to get value from field ($value = $var[0]['value']) or if it's possible to write this better:

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, FormStateInterface $form_state, $form_id){
  if ($form_id == 'node_bibliographie_form') {

    $form['#validate'][] = 'node_bibliographie_form_validate';

    foreach (array_keys($form['actions']) as $action) {
      if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
       $form['actions'][$action]['#submit'][] = 'my_module_bibliographie_form_submit';
      }
    }
  }
}

function my_module_bibliographie_form_submit(&$form, FormStateInterface $form_state){
  // Get the submitted entity.
  $key        = $form_state->getValue('field_key');
  $id_dossier = $form_state->getValue('field_dossier_reference');

  if (isset($id_dossier) && isset($key) &&  !empty($key) && !empty($id_dossier)) {
    kint($id_dossier[0]['target_id']);
    //ugly ?
    $collection_key = $key[0]['value'];
   }
}


texts:
I use restful between Drupal 7 and Android app.
I logged in  successful and got 3 variable session_id, session_name and token
When I use POST method to create node. I getting error : "node type is required"
This is my code :

private class addArticleTask extends AsyncTask<String, Integer, Integer> {

    protected Integer doInBackground(String... params) {

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://mysite/endpoint/node");

        try {

            //get title and body UI elements
            TextView txtTitle = (TextView) findViewById(R.id.editTitle);
            TextView txtBody = (TextView) findViewById(R.id.editBody);

            //extract text from UI elements and remove extra spaces
            JSONObject json = new JSONObject();
            String title=txtTitle.getText().toString().trim();
            String body=txtBody.getText().toString().trim();

            //add raw json to be sent along with the HTTP POST request
            StringEntity se = new StringEntity("{ \"title\" : \"Sample post\" , \"type\" : \"article\" , \"body\" : { \"und\" :[{ \"value\" : \"comments about something\" }]} }");
            se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
            se.setContentType(new BasicHeader("Cookie",session_name+"="+session_id));
            se.setContentType(new BasicHeader("X-CSRF-Token",token));
            httppost.setEntity(se);

            HttpResponse response = httpclient.execute(httppost);
            Log.v("Return add article", EntityUtils.toString(response.getEntity()));

            return 0;

        }catch (Exception e) {
            Log.v("Error adding article",e.getMessage());
        }

        return 0;
    }

In Logcat : Return add article : ["node type is required"]
any one help me.


texts: using {{ twig variables }} inside external jquery

texts:
Developing a D8 theme, I am loading an external .js file containing some jQuery code (so it is not inside the TWIG template).

Is it possible to access and modify TWIG variables like {{ myvariable }} inside the external jQuery?


texts: Download file one time only for auth user (Suggestion needed)

texts:
I have a website has a books & categorize each book to unites, each units has a download link..

when user have a role, he can download file just 1 time .. no more for each unit ..

for example:

Book1 --> unit1 --> download --> if(user NOT download) else { Remove Link }

Book1 --> unit2 --> download --> this link was removed since you download a file

Book1 --> unit3 --> download --> if(user NOT download) else { Remove Link }

Book2 --> unit1 --> download --> if(user NOT download) else { Remove Link }

Book2 --> unit2 --> download --> if(user NOT download) else { Remove Link }

Note: books & unit is term, units are child in books.

my idea for solve this issue is create a normal text field and set user id if he click on download link..

Any suggestion for solve a problem, way, or module, field setting ...
thanks every body


texts: Plugin Derivatives For Queue and Migration Plugins

texts:
I've created a custom Content Entity and a custom Content Entity Type, basically I'm mirroring the Node module but the purpose of this is to have external data to be synced with this setup(not using node and the content types because I want the content not to have any canonical pages, and at the same time, I am supposed to have content with landing pages).

Content Sync - this link provides a good example of setting up a sync process using the Migrate module. I would need a set of plugins to define the migration process for a custom entity, but since I have multiple types of my custom entity, can it be possible to use derivatives for any types of plugins(Migrate module - source, process, destination and Queue plugins like QueueWorker) to handle each type of custom entity dynamically?

This might be a huge question to dig into, but I'm more interested in a yes/no type of answer, because I can do the investigation myself afterwards, just need to know if it's worth it.


texts: How do I display a block on an edit form for particular content types?

texts:
It's fairly simple to display a block on the node add form for a particular content type. Simply restrict visibility to a URL path like node/add/article and you're good to go.

I would like to know how to display a block on the edit form for a particular content type. For instance, when editing an article, the URL path is node/NID/edit.

Is there an easy way to display a block for edits of a given content type?


texts:
I've got a theme setup, and this theme has a header region (region--header.tpl.php). There are some small ui elements in this template that require translation, but are not tied to blocks, views or nodes. My understanding is that when using something like <?php print t('Select a topic'); ?> it should become available to the translation backend. But it does not for me? I have the I18N module and Multilingual Variables module installed.

What am I missing?


texts: Display summary + read more links if body content is long, otherwise display body alone

texts:
We have a content type which has a customized template. In general, the body content of these nodes is short -- one to two sentences at most.

In some cases, however, the body content is a paragraph or more.

If the body content is shorter than 200 words, we would like to display the body field as-is.

If the body content is longer than 200 words, we would like to display the summary with a customized "read more" link.

Besides digging into the content array and counting words in the template, is there a graceful way to do this with view modes or field templates?

At the moment our clunky solution is to render both display types and swap between them with javascript, but this displays the "read more" link even when the body content is short enough to be displayed without the need for a summary.

node--custom.tpl.php

<?php
// Other fields above..

$summary = field_view_field('node', $node, 'body', [
    'label' => 'hidden',
    'type' => 'text_summary_or_trimmed',
]);

// Render summary of body, which is visible by default
print render($summary);

// Render full body as hidden with 'element-invisible' class (see field--body--timeline.tpl.php)
print render($content['body']);

?>

field--body--custom.php

<?php if($element['#view_mode'] !== 'full'): // Display trimmed version ?>
    <div class="<?= $classes; ?>">

        <?php foreach($items as $delta => $item):
            print render($item);
        endforeach; ?>
        Read More&hellip;

<?php else:
    // Display full body text with the element-invisible class and hidden by default ?>
    <div class="element-invisible <?= $classes; ?>">

        <?php foreach($items as $delta => $item):
            print render($item);
        endforeach; ?>
        &hellip;Read Less

<?php endif; ?>

Resulting HTML on render

Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.

    Read More…

Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.

Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.

    …Read Less


texts: Sort predefined list of items in node form

texts:
I got a tasks I am unsure how to solve the best way.

I need a list of items in my node add/edit forms, that should be able to be sorted, enabled/disabled on each node.

Eg.
Task 1
Task 2
Task 3
Task 4.

NID 1 may have it sorted
Task 1, Task 4, Task 2, Task 3

NID may have it sorted
Task 3, Task 4 (and disabled Task 1 and Task 2)

And so on..

The best solution I came up with so far, is using the Multiple Selects module. Creating a list of the tasks and lets users select and sort them this way. However it is not the best/most user friendly way.

Is there a module I have missed that can handle this a better way? Or is a custom module development needed.

The most beautiful way would be a UI like the "Manage display" in content type editing - since is it easy to see what is disabled and the order of the elements.


texts: How do I explain the large difference between page execution time and reasonable query execution time?

texts:
I believe that one of my websites is running rather slowly.  I have done nothing different than I have on other Drupal websites that I have done that are running on different servers and that are running much faster.

Would this "slowness" be somehow described by the fact that the page takes 4 times longer to load than it does to actually execute the SQL queries?

  Page execution time was 2251.03 ms. Executed 342 queries in 477.02 milliseconds.

If you see above, you can see that it takes more than 4 times longer to execute the page than it does to actually get the data it needs to show on the page.

I have another site that is nearly identical and I have much faster load times:

  Executed 241 queries in 108.32 milliseconds. Page execution time was 1065.35 ms.

What explains the difference between the two sites, and how could I go about fixing the slow site?


texts: How do you use the Drupal 7 overlay on the node/edit screens for your popups when it's already being used?

texts:
I'm writing a module that adds a button to node/edit forms. This button needs to popup a DIV/IFRAME in a light box. I notice that Drupal 7 uses the new Overlay module for administrative and node/edit pages.

So my question is as my button is on a node/edit page I need to overlay the overlay. Is there a way to access the overlay and change or z-index or do I just write my own overlay code to create a light box effect (overlaying the node/edit overlay)?


texts: How do I use and show a vocabulary with multiple fields?

texts:
When I create a new vocabulary, I can create it in such a way that there are multiple fields. However, when I then create a content type with a field a term reference to that vocabulary, I only can see the name field from the vocabulary and not the other fields.

This regardless of the method I use, whether be radio buttons, check list, select list, autocomplete, autocomplete deluxe. I want to show those other fields so I can discriminate between two very similar, but with distinct values in the vocabulary.

For example, if it is a vocabulary of names, to add a date of birth which gets at least shown (and preferably is editable when adding a new term using autocomplete deluxe) when I fill in the form when adding an item of that content type.


texts: Restrict content to a user role in a template file

texts:
I want to restrict a single node to anonymous users in Drupal 8. I don't want to use any module for it as its useless for single restriction as per me.

I know that I can do it with something like this.

{% if user.hasPermission('myPermission') %}
     //my template HTML
{% else %}
    //some login for the customer
{% endif %}

I don't want to restrict the content via permission, instead I want to restrict it with something like

{% if user.hasRole('authenticated') %}

Is this possible with a theme hook or do I have to use a module?


texts:
My company received a maintenance contract for a website developed in Drupal 7. The Drupal 7 website uses the Quiz contrib module, ver. 7.x-4.0-rc10. The module is used to implement a feature where authenticated users answer questions to tests.

When an authenticated user completes the test and views his result, the following notice errors are displayed on the results page,

Notice: Undefined index: nid in quiz_take_quiz() (line 2078 of C:\wamp64\www\........\modules\contrib\quiz\quiz.module).
Notice: Undefined index: vid in quiz_take_quiz() (line 2078 of C:\wamp64\www\........\modules\contrib\quiz\quiz.module).
Notice: Trying to get property 'type' of non-object in quiz_take_quiz() (line 2082 of C:\wamp64\www\........\modules\contrib\quiz\quiz.module).
Notice: Undefined index: in quiz_take_quiz() (line 2082 of C:\wamp64\www\........\modules\contrib\quiz\quiz.module).
Notice: Trying to get property 'is_valid' of non-object in quiz_take_quiz() (line 2084 of C:\wamp64\www\........\modules\contrib\quiz\quiz.module).

The Quiz module has a function, quiz_take_quiz($quiz).

As part of contract signed by my company, I have to resolve all notices. Therefore, what I intend to do is override this function and modify the exact line which is responsible for throwing the above notices (line no. 2078) and add a variable validation there.

However being a newbie to Drupal development I don't know where to start and what to do. I do know that modifying the code in a contrib module is not the best practice. I have hidden the path to the .module file with ........ to maintain privacy.

Can anyone please provide me the solution to this?


texts: How do I create field collection of/in another field collection programmatically?

texts:
How can I create field collection in another field collection using Drupal 7 Entity?

The field structure is given below;

Content type: Properties

field_1
field_2
field_collection_1 (I can create this field collection with the below fields)

    - field_1

    - field_2

    - field_collection_2 (But I cannot create/edit this field)

Code which I'm using to create the field_collection_1.

$fc_item = entity_create('field_collection_item', ['field_name' => 'field_property_options_col']);
$fc_item->setHostEntity('node', $property);
$fc_wrapper = entity_metadata_wrapper('field_collection_item', $fc_item);
$fc_wrapper->field_room_name->set($roomName);

Any idea?


texts:
I am creating the following pseudo field in hook_node_view:

function user_guides_node_view($node, $view_mode, $langcode) {
    $node->content['field_mytest'] = array('#markup' => '
This is my test

[current-page:title]
');
}

This is the rendered result:

This is my test
[current-page:title]

How can I get the value of the token to be displayed instead of the token itself?


texts:
I created a view that is a block.  I then wanted to create another block for that view but with different criteria.  When creating the second block, it was identical to the first block created and when I lets say change the fields, the first original block gets changed as well.  So it seems anything I do to the new block changes the first block as well.

What is the purpose of being able to create a second block but it is the exact same as the first?  I think the only difference it can have is a display name?  Can anyone explain this to me or give me an example of the purpose of this functionality?


texts: How to convert a webform into an ordered list?

texts:
I've tried to preprocess a webform in order to convert the form items into an ordered list. My webform is composed of questions, and I want each question to be a enumerated list element.

The problem is that I cannot find where to convert the <div> following the <form> into an <ol>, and the next nested <div> into an <li>. After navigating webform's source code I could not find a function that says "give me all the webform elements", for example. It all seems to work in the following order:

implement hook node load (load webform components)
implement hook node view (order webform components into a structure that is hard to modify?)
create form
render form using some theming functions

When I use the node preprocessor to alter the components (and attempt to insert a #type = item_list somewhere), it doesn't work. And when using one of the webform theming functions, the data structure comes in a way that is hard to modify. Example:

That variable that I tried to modify was the $variables['elements']['webform']['#form']['submitted'] in a hook_preprocess_node.


texts:
I got a site where we got pages tagged with several taxonomy terms. We also got several Contactblocks (added as Content Type & displayed by Views) that are tagged with the same set of taxonomy terms.

The Content Type "Contactblock" has the fields E-Mail, Phone & Room. Those Fields may vary from page to page. The reason behind this is some employees have different positions and those have to be displayed on different pages with different information. May way to go atm was to add multiple Contactblocks but its not clean enough for me.

My idea was to display for each tagged term a specific field of E-Mail, Phone & Room. But idk how the system can associate it then..

Atm its like page<->taxonomy term<->contactblock but it should be like page<->taxonomy term, for each tax term<->create fields: mail, phone & room

Any idea how I can solve this? Any better idea is apreciated


texts: The node form will not submit,if the word 'exit' is put in the title field

texts:
I am using Drupal7, if the word 'exit' is entered into the text field, and the user submits/saves/previews the page, then the data is not submitted, saved, or previewed. The node edit page reloads and all changes are lost.

Is the word 'exit' a blacklisted word in node add/edit form?How can i over ride this prob?

Thanks in advance, Prem


texts: Programmatically place image field as default value in form plugin

texts:
I have a content type that has an image field that allows you to upload up to 4 photos. I'm creating a form for users to use that will allow them to edit existing items of this content type. The form fields need to be filled with the existing node field values by default. Retrieving fields such as textfields and supplying the default value works just fine, like so:

class EquipmentEditForm extends ConfigFormBase {
    private $imageNum = 4;

    protected function getEditableConfigNames() {
        return array(
            'equipment.form',
        );
    }
    public function buildForm(array $form, FormStateInterface $form_state) {
        $equipment_id = 10306;
        $node = NODE::load($equipment_id);

        $contact        = $node->get('field_contact')->value;
        $description    = $node->get('field_description')->value;

        $form = [
            'container'    => [
                '#type'       => 'container',
                '#attributes' => [
                    'class'      => ['equipment-entry'],
                ],
                'contact'      => [
                    '#type'       => 'textfield',
                    '#title'      => t('Contact Person'),
                    '#attributes' => [
                        'name'       => 'contact',
                    ],
                    '#default_value' => $contact,
                ],
                'description'    => [
                    '#type'       => 'textfield',
                    '#title'      => t('Description'),
                    '#attributes' => [
                        'name'       => 'description',
                    ],
                    '#default_value' => $description,
                ],
           ],
        ];
    }
}

This generates the form and populated the fields from the node just fine. However I'm not sure how to populate the image field.
I've attempted the following with no luck.

    if ($node->get('field_equipment_photo')->entity != null) {
        $photos = $node->get('field_equipment_photo');
    }
    for ($i = 1; $i <= $this->imageNum; $i += 1) {

        $title = ($i == 1)?'Image '.$i:'Image '.$i.' (extra)';

        $form['image'.$i] = [
            '#type'            => 'managed_file',
            '#upload_location' => 'public://images/',
            '#title'           => t($title),
            '#name'            => 'image'.$i,
            '#default_value'   => $photos[$i],
        ];
    }

It just provides an error

  Recoverable fatal error: Object of class
  Drupal\Core\TypedData\Plugin\DataType\IntegerData could not be
  converted to string in
  Drupal\Core\Entity\ContentEntityStorageBase->buildCacheId() (line 659
  of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).

I know I'm retrieving the images because if I perform a statement like this:

die(print_r($photos[1]->entity));

I do get a list of the information contained in the 2 uploaded image. Including the filename.

How would I programmatically retrieve the values of an image field array of a node and place them into the default values of a form field?

UPDATE: I'm able to discover the fid using

die(print_r($photos[0]->entity->fid->value));

but using $photos[0]->entity->fid->value as the default value leads to this error

  Warning: Invalid argument supplied for foreach() in
  Drupal\file\Element\ManagedFile::valueCallback()


texts: Does storing my database as a .sql file in my site git repository cause problems?

texts:
I have been saving a series of database export files each time I do a git commit of my Drupal site.  I have a nice git repository for my site files and a messy folder for my database backups.  Because the database file is related to a commit, should the database file be included with the Drupal site files (in a temporary folder of some kind?)  It seems helpful to bind these files together in a single commit.  However, this practice does not seem commonplace, so there may be a problem with it.  Have I overlooked a major issue?

If so, would it be better to create another repository for my database backups?


texts:
I want to create a new token form the selected item in the list box of currently submited node and set it as url alias of the node.

unfortunately, I need keys of select box as token but default tokens do not have this item(it just has labels of listboxes). so I decided to create it's token programmatically.

this is the code but I do not know how to set selected item of list box in $value

function cool_token_token_info() {

  $info['tokens']['node']['key1'] = array(
    'name' => t('My cool token'),
    'description' => t('A token I use to show that I am cool.'),
  );
  return $info;
}

function cool_token_tokens($type, $tokens, array $data = array(), array $options = array(),$node=array()) {
  $replacements = array();
  $sanitize = !empty($options['sanitize']);
  if ($type == 'node') {
    // Loop through the available tokens.
    foreach ($tokens as $name => $original) {
      // Find our custom tokens by name.
      switch ($name) {
        case 'key1':
          // Work out the value of our token.
          if (isset($node)){
                $value= "here I want to have key of the selected item in the listbox of current node";
          }else{
              $value="not working";
          }
          // Give our token it's value!
          $replacements[$original] = $value;
          break;
      }
    }
  }

  return $replacements;
}

I tried

field_get_items('node', $node, 'field_parent')

and many many other ways but it does not print anything


texts: URL variable getting lost when using upload button on a managed file

texts:
I have a D7 form that I made using the form API. The URL to the form contains a URL variable like so www.mysite.com/myform?id=123456. (I know it would be better to do www.mysite.com/myform/123456, but that is another issue and I can't do that right now for an unrelated reason).

Anyway, I am first checking for the existence of that id variable in the URL and if it exists, I am putting it into a hidden form field so that it gets submitted with the form. This works great until someone uses the managed file form element that I have for someone to upload a file with. If they choose their file and then click the submit button at the bottom of the form, the id exists in the hidden field just fine and gets submitted and is available in the form submit function. However, if the user chooses their file and clicks the upload button next to the managed file form element and THEN clicks the submit button, the id is lost. I'm assuming it's because the upload button is doing an AJAX submit and then rebuilding the form except when it's getting rebuilt, that URL variable for ID no longer exists in the URL that's being used, so the hidden form field does not get set again.

Is there a better way to go about this?

THANKS

Here is the code I am using:

function apex_onboard_form($form_state) {

  $form['#attributes'] = array('enctype' => "multipart/form-data");

  if (isset($_GET['orderId'])) {
    $form['orderId'] = array(
      '#type' => 'hidden',
      '#default_value' => $_GET['orderId'],
    );
  }

  $form['resume_file'] = array(
    '#type' => 'managed_file',
    '#title' => 'Resume Upload',
    '#required' => TRUE,
    '#upload_location' => "public://resume_tmp/",
    '#upload_validators'=>  array(
      'file_validate_extensions' => array(variable_get('resume_allowed_extensions', 'doc docx pdf txt rtf')),
      'file_validate_size' => array(variable_get('resume_max_upload_size', '2') * 1024 * 1024),
    ),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  return $form;
}

If the user clicks the "Upload" button next to the file field and then clicks submit, the orderId field does not get passed to the submit function. If the user chooses a file and then clicks submit without clicking upload first, the orderId comes across fine.


texts:
I'm building a membership site and I'm trying to find the best way to tease content that's only available to subscribers but show it in the same view as content available to all.

I'm currently using the content access module and while I'm able to generate the view that includes both open and restricted content I need a way to attach a lock icon to the rows who have restricted access. My thought was to have the view output the content access permission as a field but content access doesn't appear to have anything currently exposed to views.

Has anyone done something like this before? I'm open to using a different access control module as long as I can set permissions on a per-node basis.


texts: How to apply image style in a views-view-fields--[view]--[machine-name].html.twig

texts:
In a views-view-fields--[view]--[machine-name].html.twig, I have

{% set images = row._entity.field_image %}

{% for image  in images %}

{% endfor %}

I have tried with "|image_style('style')" like so

src="{{ file_url(image.entity.fileuri)|image_style('style') }}

This doesn't work, so what am I doing wrong?


texts: How to disable form.js for the add comment form?

texts:
I have a node content type with comments enabled, and the "Add comment" form is configured to be displayed on each node page.
Embedding the add comment form causes JQuery and all its dependencies to get pulled in, but since the form works without Javascript, I want to  improve performance by disabling form.js.
However, I haven't been able to figure out how to do this using the tools core provides.
The JS is getting loaded from the drupal.form library in core.libraries.yml:
drupal.form:
  version: VERSION
  js:
    misc/form.js: {}
  dependencies:
    - core/jquery
    - core/drupal
    - core/drupal.debounce
    - core/jquery.once

I looked at using hook_js_alter(), but that hook doesn't provide a way to get the form ID.
I also thought of using hook_form_alter(), but I couldn't find a way to modify the JS there, either.


texts:
All the sites I have seen that build on drupal looks like it's hit by div soup. There are so many unused divs produced by the content and some templates I have looked on contribute more by adding even more terrible markup.

I know most people with some knowledge about drupal know about this issue. For instance, here is a dump from drupal.org:

So why does Drupal need all these divs? Is there any rational behind them or is it just a flawed design?

Is there anything that could be done with this issue or are there some plans to improve on all these divs? Maybe a module that remove the divs that are not required and append the class statements so that markup will look better?

Are there some modules or solution that tries to address this annoying issue?


texts: OG Malinglist rejecting basic email sent to Organic Group

texts:
I am using OG Mailinglist 7.x-1.1-alpha2.
We have been using this module for years now.
We have a new user who is attempting to send emails to a couple of our lists which are the email part of Organic Groups which the module OG Mailinglist turns into listservs.
This new user is sending basic emails with no inline images or attachments and is getting each email sent rejected with the rejection response saying the emails could not be read properly.
Usually when this happens this is because of a bug with the library used to decode the emails in that the library malfunctions when you have both an attachment and an inline image in the body of the email, but the person having the issue is just sending text emails.
We would appreciate any insight.
Thank you!


texts:
I have site that has multiple external links. I need a way to edit them all at once.
For example: I have a site www.example.com that has multiple external links like SOME-IP/getaccess, SOME-IP/getaccess/todolist etc.
As the number of these external links is large, its extremely difficult to move a site to a new setup.

I am looking for a way to edit these external links at one place. like i want to change base url of external links. Something like to change SOME-IP/getaccess, SOME-IP/getaccess/todolist etc. TO SOME-OTHER-IP/getaccess, SOME-OTHER-IP/getaccess/todolist etc. so that all external links will work in a new setup.

I know this is something that many have experienced in websites with multiple external links.

I read read and read, only thing i come up with global variables in settingg.php but how to use these variables in existing modules.
Or Is there a module that allow to edit all external links at once.

Thanks for all the support.


texts: How to print uc-auction-bid-table-form seperately in product node template using ubercart?

texts:
I am trying to print uc-auction bid table separately in product node template. I have printed the add-to-cart button separately like this in the node--product.tpl.php.

<?php
 print drupal_render(drupal_get_form('uc_product_add_to_cart_form_'.$node->nid, $node));
?>

Similarly how can i print uc_auction form(uc-auction-bid-table-form) separately. I can't able to print like above for uc-auction because it doesn't have any nids associated it. Any help will be really appreciated.

Thanks in advance.


texts: What is this operator:content value mean?

texts:
What is this operator:content mean?

1) Under Content:Title

2) Click on Content:Title, under Configure filter criterion: Content: Title, there is a operator:content. What does value mean?


texts: custom entity admin page integrity constraints violation of managed_file in 'remove' process

texts:
I am developing a custom entity administrative page. The custom entity makes use of managed files. This is by storing a foreign key of file_id that references the file id in "file_managed" table. We've used the "managed_file" field for the form as it all matches up. It was developed that way round so we may now be paying the price for not finding a Drupal-specific implementation and instead choosing the custom FK route.

I am supplying the default_value in the recommended way:

$form['managed_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('A CSV file that is managed'),
    '#upload_location' => variable_get('managed_file'),
    '#upload_validators' => array(
        'file_validate_extensions' => array('csv'),
    ),
    '#prefix' => '
',
    '#suffix' => '
',
    '#default_value' => $entity->file_id,
);

But because of the integrity constraint we're getting this error when "Remove" is clicked:

Integrity constraint violation: 1451 Cannot delete or update a parent row:
a foreign key constraint fails ("drupal_development"."custom_entity",
CONSTRAINT "fk_ce_fm_fid" FOREIGN KEY ("file_id") REFERENCES "file_managed"
("fid")): DELETE FROM {file_managed}
WHERE  (fid = :db_condition_placeholder_0) ; Array
(
[:db_condition_placeholder_0] =&gt; 804
)
in file_delete()

So I worry we're at a crossroads here.

Do we do some pre or post hooks and remove the file_id from the custom entity before we let the "managed_file" field remove callback do its stuff?

Or do we restructure things more deep in our custom work to play it the Drupal way?

Either way, optional solutions would be a great help and if you could offer recommendations on which way to go that would also be great - responsibility free of course :)


texts: How can I programmatically create a block type?

texts:
I want to create a block type that has a couple of fields, a template and attached JavaScript.
I want that the user in my site will be able to create blocks of this type just like they create a custom block: through /block/add/myBlockType.
I would like ideally to have it all done programmatically but I dont mind manually creating my block type though "admin/structure/block/block-content/types" or with configuration files.
The thing is I have been scraping google for two days already and I don't manage to figure out how to programmatically create a block type
And this that the information is not easily found on Google makes me think that instead I need to create my type with configuration and then apply my plugin on creation of a new block but im still not sure how to do that and what my plugin needs to extend.
How can I do that?


texts: Contact form: recipient from node's Email field

texts:
Use case: Business Directory.
Description: I need to create a dynamic contact form that will use each node's (business listing content type) individual Email field as the contact form's main recipient, or at least as a carbon copy ('CC').

I have spent 2 days looking for modules as well as various coding suggestions from around the web with no success.
Example: Contact for per node in Drupal 8?

This was easily accomplished in D7 with

  Views Contact Form

module. However, it doesn't yet work with D8.

I'm using a clean installation of Drupal 8.1.
I don't know yet how to create a custom module, but will learn if needed. Ideally, a .theme file based solution would be easy for me to implement.
Any help would be greatly appreciated!


texts: Inserting the value from Datetime field form

texts:
I have a form where the user can input datetime and then I want to store it in the database. Here's my schema :

  'start' => array(
          'type' => 'varchar', 'mysql_type' => 'datetime',
          'not null' => FALSE,
        ),

The form :

  $form['add']['start'] = array(
        '#type' => 'datetime',
  '#default_value' => $date,
      );

When I hit submit button, it shows me :

  db_insert failed. Message = SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value:...

What I got out of it was that the DateTime in Drupal is incompatible with MySQL's. Any suggestions or how should I process the value from the form so I can insert it into the db?

Alternatively, any way to convert DrupalDatetime into string?

(For what it's worth I also tried 'timestamp' as the MySQL type but it throws me the same error).


texts: Is there any way to add the css class to tinymce inside wysiwyg editor

texts:
I have several classes defined inside style.css, I want tinymce to recognize these classes. Below is the popup to configure hyperlinks. It also provide a way to use css styles defined already.

I am looking for a way to add the css class to tinymce inside wysiwyg editor in Drupal 7.


texts: Dissagregate a field in a aggregated View

texts: I have a View which uses agreggation. But when I try to list the taxonomy terms, because of the aggregation, I have only one term listed for each row, instead of all taxonomy terms (multiple terms) listed separated by commas. How can I dissagretate a field, so it displays all the values?


texts:
I am creating a content type for events.  One of the parts of data I want to have is for speakers.  With the speakers I want to have their name, image, company, and bio.  I want to be able to more than one speaker similar to a multivalue text field where you can simply click add another item.

Can this be done in Drupal 7, and if so how?


texts: Drupal 7 Faceted Search: Always show Facets

texts:
I have a faceted search working that uses searchapi, facetapi, and entityapi. I was not the one who developed this, but I have some experience with Drupal.  As of now the navigation uses links for selection and looks like below (first level of bullet points aren't links).  When mixing is selected sound design and composition disappear as expected.

What the client wants is for all items to still stay visible and selectable as the user drills down (even if it returns nothing). Only one item per category will be selectable at a time, but the user should be able to do it without having to 'go back'.
Any advice is greatly appreciated.

What We Do_

Mixing (18)
Sound Design(11)
Composition (6)

Who We Are_

Joe Schmoe (17)
Jeff Bleck (14)
David Berry (4)

Affiliated Composers_

Jim Carey (3)
Tony Maroni (2)


texts: Views: Display number of nodes published by author on profile

texts:
Using Views, I can create a list of authors, and show the number of nodes that they have published. I've done this using aggregation. The part I can't figure out is how to filter the output based on the user profile that you're viewing. For example, if you're viewing user/1, I want you to see the number of nodes that user 1 has published.

I've tried using different uid contextual filters. In this example, I'm using "User: Uid" as the filter, and I'm trying to pull the uid from the URL by selecting "'Provide default value' > 'Use ID from URL'" in the filter's options. Since aggregation settings are on, you have to apply an aggregation type to the filter, and I'm not sure what that should be set on.

Any feedback would be appreciated. By the way, I'm using Display Suite to build the profile layout, so if there's an easier way to get want I need, I'm open for suggestions. Thanks in advance.

EDIT: For anyone attempting to do this, keep in mind that your output will not show up in the Views preview. I was forced to navigate to a user profile in order to test this. This issue seems to sprout from the combination of aggregation and contextual filters.


texts: How can I add JavaScript only on the front page?

texts:
I created a custom Theme: filhos_do_porto using Bartik as a subtheme and I would like to add JS code only to the Front Page.

Can someone help me? (I didn’t find anything specific of D8 clear enough for someone new in Drupal)


texts:
How to group facets (Facet API) by day for date fields?
Currently I have a custom date field indexed by Search API Solr.

I want to group this values by day, for example:

Friday 26 june
-08:30
-08:45
Saturday 27 june
-08:30
Sunday 28 june
-08:30


texts: How to hide profile2 field label and captcha label in registration form

texts:
I've tried using 2 different functions, where both successfully sets the value to 'invisible' with a dsm($form) check. However, the label is still being displayed.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
          case 'user_register_form':
              $form['profile_users']['field_username']['#title_display'] = 'invisible';
              $form['captcha']['#title_display'] = "invisible";
   break;
  }
}

and:

function MYMODULE_form_profile2_edit_PROFILETYPE_form_alter(&$form, &$form_state){

     $form['profile_PROFILETYPE']['field_username']['#title_display'] = 'invisible';

}

I do not encounter this problem for the username, password and email fields.

Edit: I've also tried:

$form['profile_users']['field_username']['und']['#title'] = '';
$form['profile_users']['field_username']['und']['#title_display'] = "invisible";


texts:
i have made a custom module for form in drupal using dupal API,and made a table in my database...now What i want is to save the value of drop down box instead of it's index into database...my .module file is:

<?php
function form_test_menu() {
$items['formtest'] = array(
'title' => 'Form Test',
'page callback' => 'drupal_get_form',
'page arguments' => array('form_test_form'),
'access callback' => TRUE,
);
return $items;
}
function form_test_form($form,&$form_submit) {
$form['name'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#required' => TRUE,
);
$form['college'] = array(
'#title' => t('College/University'),
'#type' => 'textfield',
'#required' => TRUE,
);
$form['education'] = array(
'#title' => t('Education'),
'#type' => 'select',
'#description' => 'Select your higher education .',
'#options' => array(t('--- SELECT ---'), t('B.tech'), t('MCA'), t('MBA'),t('Graduate')),
'#required' => TRUE,
);
$form['percentage'] = array(
'#title' => t('Percentage/CGPA'),
'#type' => 'textfield',
'#required' => TRUE,
);
$form['application'] = array(
'#title' => t('Job Applied'),
'#type' => 'select',
'#options' => array(t('---select---'),t('Web Developer'),t('Web Designer'),t('SEO'),t('Marketing')),
'#required' => TRUE,
);
$form['submit'] = array(
'#value' => 'Submit',
'#type' => 'submit',
);
return $form;
}
function form_test_form_submit($form, $form_state) {
global $user;
db_insert('drupal')
->fields(array(
'name' => $form_state['values']['name'],
    'college' => $form_state['values']['college'],
    'education' => $form_state['values']['education'],
    'percentage' => $form_state['values']['percentage'],
    'application' => $form_state['values']['application'],

))->execute();
drupal_set_message("successfully saved data");
} ?>

any help will be appreciated. Thank you.