texts: Drush: Wrong PHP version when trying to sql-sync with SSH

texts:
I'm trying to upload a database on the server with SSH by using sql-sync, but I'm getting the following error:

  PHP Parse error: syntax error, unexpected '{' in /home/luken/programs/drush/includes/environment.inc on line 517 X-Powered-By: PHP/4.4.7 Content-type: text/html [...]

As you see from the error message, it is using PHP 4.4.7, while I want to use PHP 5.4.

I tried adding the following line to .bash_profile.

export DRUSH_PHP=php54 (that is php version I wanted to use, and it works when I normally log in)

I also tried with PATH=/home/luken/programs/drush:${PATH}.

What else can I do?

phpinfo() gives this path to PHP: /usr/local/php54/.

Breaking news:

Ok, now I'm totally confused, it appeared that the whole database WAS copied, regardless of error that sql-sync has been producing (suggesting that nothing has been accomplished). I hope that anyone who will get this error will check now if it really didn't do anything, and now the winner will be the one who can explain that O_o.


texts: Is there a reason I need to unset CSS files provided by contrib modules if I have CSS aggregation enabled?

texts: As this question makes clear, stylesheets provided by modules can be unset.  Some themes, such as Adaptivetheme 3.x, also provide a GUI for unsetting the stylesheets provided by modules.  My question is this: if I have CSS aggregation enabled, is there any benefit to unsetting CSS files of modules I do not use?  Or is Drupal's CSS aggregation sufficiently efficient that I do not need to bother with unsetting any files?


texts: Output ctools_modal_form_wrapper() with translatable items in the form

texts:
i have translation strings already for this form.
if i output it with:

  return drupal_get_form('user_login');

then the translation works

but if i render it for the modal form then the translation doesn't work.

return ctools_modal_form_wrapper('user_login', $form_state); with translatable items

so how can i enable the tranlation for the ctools_modal_form_wrapper also?


texts: Node form with fields loaded from another node or other entity

texts:
I am stuck on this problem, I was making a 'field' to be available on many content types, but this field has itself many fields, so i decided making an entity to have those fields seperate. I choose an entity because i don't these information to be accessible in the searchs etc, and I don't need revisions. Now on the node form submission i would like to have both the fields of the node and the fields of the entity showing up on the same form, as if this entity was a field.  How can i do that ?

If I use form_alter: ok i understood how to add widgets to the form, but then that means i have to re-write all the validation code etc from all fields ? Is it possible to load fields so that they will keep all their properties? (validation, submission etc)
Would it be possible to create a field module that would load other fields from a node/entity type on each hook ?
Any other solution ?

Idealy i would to find or make an 'entity-reference' module that does that job! (load field from one in the other when creating, editing, loading a node) !!

any help welcom, thanks !

dylan


texts: how to programming save a node with tags

texts:
I want to use drupal as my webservices, so I develop a module to implement hook_services_resources.

I use postman (chrome's extension) to post data to drupal.

var data={"uid":"1","title":"xxx","type":"bookmark","field_tags":{"und":[{"tid","4"},{"tid","5"}]}};

implement in services

function _bookmark_helper_resource_create($data){
  $entity_type="node";
  $entity=entity_create($entity_type,$data);
  if(!entity_save($entity_type,$data)){
    services_error("Error saving entity."406);
  }
  return $entity->id;
}

There is 3 questions:

1.it seems that node created successed,I can see the node in drupal,but I receive 406 error.

2.There is two tag in the node,but once I click one tag(path taxonomy/term/5), I can't see the node I just add.

3.How can I add new tag to node?

Can someone help me out? Thanks very much!!


texts: Rules module doesn't send emails to user roles once conditions are met

texts:
I'm working in drupal 7 and I've configured the rules module to send emails you specific user roles when content is created. For some reason I'm getting inconsistent results, sometimes not receiving any emails. Any insight to why rules isn't generating emails would be helpful.

Here's my Rule:

{ "rules_announcements" : {
    "LABEL" : "Announcements",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "10",
    "OWNER" : "rules",
    "TAGS" : [ "announcements" ],
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert--announcements" : { "bundle" : "announcements" } },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "announcements" : "announcements" } }
        }
      }
    ],
    "DO" : [
      { "mail_to_users_of_role" : {
          "roles" : { "value" : { "5" : "5", "4" : "4" } },
          "subject" : "Announcements: [node:title]",
          "message" : "\u003Cp\u003E[node:title]\u003C\/p\u003E\r\n\u003Cp\u003E[node:field_announcement]\u003C\/p\u003E\r\n\u003Cp\u003E[node:body]\u003C\/p\u003E\r\n\u003Cp\u003E[node:url]\u003C\/p\u003E",
          "from" : "[site:mail]"
        }
      }
    ]
  }
}


texts: "InvalidArgumentException: Field field_participant_email is unknown" although it exists

texts:
We're working on a custom module where we are creating participant content types programatically. We then have some queries to check for where a participant exists.

However although the field field_participant_email exists and is defined, the below code results in the error InvalidArgumentException: Field field_participant_email is unknown.

$query = \Drupal::entityQuery('node');
$query->condition('type', 'participant');
$query->condition('field_participant_meeting', $meeting_id);
$query->condition('field_participant_email', $email);
$ids = $query->execute();

We've tried clearing cache, deleting and re-adding the field to no avail.

Does anyone have any suggestions or experiencing with this type of issue?

Much appreciated.

Update 1

For clarity, I've also checked the following:

checked the spelling of the field
deleted all the content types and reinstalled them through features
tried $query->condition('field_participant_email_value', $email);
tried $query->condition('field_participant_email.value', $email);

Update 2

Looking into the core/lib/Drupal/Core/Entity/Query/QueryInterface.php interface documentation, it seems that adding a condition against a custom field is not supported. This would explain why the error occurs. However I'm yet to find an alternative. I've also experienced the same error when trying to set the value of the field $node->set('field_participant_email', 'name@domain.com');.


texts: How to change Solution Name display on authorize.net under Transaction Source useing Drupal commerce

texts:
I am using Drupal commerce Authorize.Net module for transaction.

When I review Transaction Detail on https://sandbox.authorize.net/ site, it display Solution Name:    Commerce Guys under Transaction Source.

How can I change it with my custom one?


texts: Update command won't work for multisites

texts:
I have a Drupal 7 site with a half-dozen multisites/subsites and I am trying to setup Drush so that I can run my modules updates from the command line for the subsites. Running Drush for the main site works fine. Running Drush for ONE of the sub sites works fine. However for about 5 of the subsites I can run commands like

drush @subsite status

or

drush @subsite updb

but if I try to run

drush @subsite update

or

drush @subsite ups

I get an error:

Command pm-updatestatus needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.

So I don't understand what makes all the other sites different from the one, or why some commands would work and others not. I am running these commands from my main Drupal install path:

/var/www/html

What am I doing wrong, and how can I get update to work for my subsites?

It's worth noting that the majority of these subsites were setup at a time when I didn't necessarily know what I was doing, so I can only describe their configuration as "wacky". One of the affected sites is setup in a fairly standard way and the working subsite is of the "wacky" variety, however, so I don't expect that's the problem.

EDIT:
Because it is working for one site and not others, I'm wondering if it's a file permission issue. What user does Drush run as, and what level of access does it needs to which files? In my case, I am working on Ubuntu.


texts: Create table query gives me "table does not exists" error

texts:
My local Drupal site is crashed, and it shows this error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal722.semaphore' doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( [:name] => variable_init ) in lock_may_be_available() (line 167 of D:\Projects\wamp\www\drupal\includes\lock.inc).
Uncaught exception thrown in shutdown function.
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal722.semaphore' doesn't exist: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 573260675528605a31630a6.23576489 ) in lock_release_all() (line 269 of D:\Projects\wamp\www\drupal\includes\lock.inc).

I googled about how to solve this error, and I found that I need to create a table. So I used the following query to create a table.
CREATE TABLE IF NOT EXISTS `semaphore` (
    `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique name.',
    `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'A value for the semaphore.',
    `expire` double NOT NULL COMMENT 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
    PRIMARY KEY (`name`),
    KEY `value` (`value`),
    KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Table for holding semaphores, locks, flags, etc. that...';`

With my surprise, it is giving the following error. (drupal722 is my database name.)

1146 - Table 'drupal722.semaphore' doesn't exist

Why is the create table query giving me the "table does not exists" error? It is much obvious that i know that table does not exists and so i want to create table and so i am firing a query of Create table.

How do I resolve the above mentioned error related to Drupal, and get my site back to work?


texts: Where is the logic located which determines the tpl file for the front page?

texts:
We are using Drupal 6. When accessing http://www.mysite.com/, the tpl file which is displayed is named page-front_page.tpl.php. I cannot figure out where the logic is which decides that page-front_page.tpl.php will be used for the front page.

I created a second file, named page-front.tpl.php, and this will display instead of page-front_page.tpl.php, seemingly bypassing page-front_page.tpl.php.

Does anybody know how page-front_page.tpl.php is defined as a front page? Or is there some sort of automatic URL parsing happening here?

Edit 1.0: Please read my comments to answers below for more information.


texts: How to put a custom message in the message module template?

texts:
I am using the Message module with Drupal 8 to log information.

I was able to get the date and time in the messages produced by adding a token of the date and time , but I want to add a customized message that is different each time.  How can I do this? this is the code I am using:

 $message = Message::create(['template' => 'sfbu_progress']);
 $message->save();

How can I add a customized message to each message created?  For Example I want it to say "This file 444.pdf was successfully uploaded" or "this file 888.pdf was missing ".


texts:
I'm very new to drupal. I'm using drupal 7 with ckeditor. I've created one block with 3 views (Link, Image, Link) in it and I've wrote jQuery on 2 links. Then, I've developed second block with same type of views and wrote same jQuery for 2 links in this new block.

But I found (in FireFox using FireBug addon) that all links have same node id. views-field-view-node for 1st link and views-field-view-node-1 for second link for both blocks. So when I click on 1 block's 1st link, action fires in both blocks because drupal received same link id for another block also.

How can I change/modify this node id of view? So I can give separate action.

Used jQuery:

drupal_add_js("jQuery(document).ready(function() {
    // change slideshow with your view name
    jQuery('.view-slideshow .view-content').cycle({
        fx: 'fade',
        speed:  'fast',
        timeout: 3000,
        next:   '.views-field-view-node-1', // problem is here. This id is same for both block's link
        prev:   '.views-field-view-node'
    });
});", 'inline');

Thanks in advance....


texts: Custom ckeditor.styles.js possible to specify for any/all elements?

texts:
In the ckeditor.styles.js can you leave the element blank or specify multiple elements in a single line? Ex. if the class .red could apply to any element, do I actually have to write out a line for every possible element?

{ name : 'Red' , element : 'p', attributes  : { 'class' : 'red' } },
{ name : 'Red' , element : 'h1', attributes  : { 'class' : 'red' } },
{ name : 'Red' , element : 'h2', attributes  : { 'class' : 'red' } },

etc...

Or is there an easier way?


texts: Custom Block from module not showing on front-end?

texts:
I have created a custom block in a custom module. Sometimes the block appears correctly, and sometimes the block doesn't appear. The same happens when I clear the cache.

The build() method returns the following value.

return [
  '#markup' => $html,
  '#cache' => array('max-age' => 0)
];

I also tried with the following code.

return (array(
  '#type' => 'markup',
  '#cache' => array('max-age' => 0),
  '#markup' => $html,
));

These are the other methods of the block.

protected function blockAccess(AccountInterface $account) {
  return AccessResult::allowedIfHasPermission($account, 'access content');
}

public function blockForm($form, FormStateInterface $form_state) {
  $config = $this->getConfiguration();

  return $form;
}

public function blockSubmit($form, FormStateInterface $form_state) {
  $this->configuration['custom_block_settings'] = $form_state->getValue('custom_block_settings');
}


texts: Count the number of times a value is used

texts:
I have a situation where I have five columns in an external database I am accessing using the Views database connector module. Each column in the table contains a value between 1 and 5.

I need to count the number of times each value is used in all those five columns.

For example, the database contains these values.

c|c|c|c|c
0|1|1|2|4
1|2|4|1|5

The output I want is:

For the value 1, 4
For 2, 2
For 3, 0
For 4, 2
For 5, 1

Is it possible to do this directly through the Views module, or do I need an additional module? Can I do it using custom code?


texts:
What would be the best way to store JSON content with a node? Can I just use a text field for this or will this destroy the data?

I do not need to query this data, only load it occasionally.

I'm using Drupal 7 and MySQL 5.5.


texts: user deletion : user_cancel_reassign not working when user has more than 10 associated contents

texts:
I am attempting to suppress Users with no permissions/roles from our sites.
The user associated contents should be kept on user deletion.
This code below works when the user has a few associated content.
On deletion the content becomes of anonymous author.
It does not work anymore when the user is the author of more than 10 contents.
All associated contents are deleted when the user is deleted.
Another method is invoked , i suppose.
How can i solve this?
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use \Drupal\user\Entity\User;

function hook_preprocess_page(&$variables, $hook) {
  $route_name = \Drupal::routeMatch()->getRouteName();
  $user = \Drupal::currentUser();
  if (count($user->getRoles()) == 1 && ($route_name != "system.401" && $route_name != "user.login")) {
    $userWithoutRole = User::load($user->id());
    if ($userWithoutRole !== null){
      $method='user_cancel_reassign';
      user_cancel([], $user->id(), $method);
      $userWithoutRole->delete();
    }
    throw new UnauthorizedHttpException('insufficient permissions');
  }
}

NB: The same issue is remaining on the "auto purge users" module


texts:
One of the content types I have defined has a file-field set up with a destination to public folder.

The field is supposed to have private settings, but as some data has been saved on the server I can not change it any more.

How can I fix it without deleting all the content of the server?


texts: How to display content tagged with child terms in views?

texts:
I have a taxonomy vocabulary general in which I have a reference field to user roles allowed_roles.
I have two taxonomy terms. A and B where A is the parent of B.
Now I selected test_role in the A taxonomy term in allowed roles.
in the views I have added a relationship on Taxonomy term referenced from general.
In the contextual filter, I have added the allowed_roles with the above relationship and provided the test_role as value.
Now when I logged in with the user with role test_role, I can only see those content which are tagged with A. Which is default behaviour of the views and correct.
But I want that I should see all content of A and also those content which are tagged with the children of A.
is it possible with views? or I have to write a custom views relationship? Any idea?


texts: How to change password via REST when validating email address (first login link)

texts:
Is there a REST api way to allow the user to set a new password on email confirmation / first time login?

I tried the same code as for changing the password when you're already logged in and adding the pass-reset-token as a GET param but without any luck. Server always returns the following message:

{"message":"Users can only update their own account, unless they have the \u0027administer users\u0027 permission."}

Does anyone have any idea? If not, I will write some custom code inspired from the core module but I hoped that the rest api should handle such things.


texts: How can I access raw field values in a view template?

texts:
I am writing a template for a views field in Drupal 8.
How can I access the raw values of a multi-value field in views? I tried this but it doesn't work.

{% for i in 0.. row.field_color['#items']|length - 1 %}
{{ row.field_color[i] }}
{% endfor %}


texts: problem with printing multiple cck value inside node-type.tpl.php

texts:
I am printing out this thing inside node-mytype.tpl.php (D6):

$dots = '';
$i = 0;
foreach($node->field_authors as $item) {
    $i = $i + 1;
    if ($i < count($node->field_authors)) { $dots = ',  '; } else { $dots = '.  '; };
    print '<span>'. $item['view'].$dots.'</span>';
}

Can somebody explain to me, why in this case printing $item['view'] == succesfully printing cck field values? Shouldn't it be like $item[i]['view']?

When i'm printing cck multiple values im usually do it this way:

print $node->field_authors[0]['view'];
print $node->field_authors[1]['view']; // if 2 values

Explain to me please, i would really appreciate it...


texts:
There is already a lot of links displaying videos inside my site (in node content) that are using:

http://example.com/clips/2017/01/11/51706, http://www.example.com/clips/2017/01/11/51706, https://example.com/clips/2017/01/11/51706, https://www.example.com/clips/2017/01/11/51706

So I want to standardize (make it uniform) all the my links to :

https://example.com/clips/2017/01/11/51706, https://www.example.com/clips/2017/01/11/51706

Redirecting the main URL works using .htaccess but the videos in the body of my articles that are HTTP are not affected so not displaying (I have a blank space instead )...

How can I make the internals links (the videos in the body of my articles) that are HTTP to redirect to HTTPS too?

Update
Videos are included using this embed code:

.htaccess

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


texts:
I need to put some custom html tags and code inside the form elements am creating using form api .  I defined a fieldset and need to come the html under this fieldset , code sample :

  $general_wb_vars = array(
        'wb_debug'=>array('type'=>'select','values'=>'ERR,OFF','default_value'=>'OFF','label'=>'Debug','description'=>''),
        'wb_cache'=>array('type'=>'radio','values'=>'Yes,No','default_value'=>'No','label'=>'Cache','description'=>''),
        'wb_ip'=>array('type'=>'textfield','values'=>'','default_value'=>'192.168.1.1','label'=>'IP','description'=>'')
        );
        $numofrepeat = 4;
        if($form_id=='my-form-id'){
                $form['fieldsetm'] = array('#type' => 'fieldset',
                                         '#title' => t('Weblogic configurations'),
                                         '#weight' => 10,
                                );

                for($i=1;$i<=$numofrepeat;$i++){
                foreach($general_wb_vars as $id => $setts){
                   $form['fieldsetm']['field_p_'.$id.'['.$i.'][value]'] = array('#type' => $setts['type'],
                                        '#title' => t($setts['label']),
                                        '#default_value' => $setts['default_value'],
                                        '#description' => t($setts['description']),
                                        '#attributes' => array('id'=>$id.$i),

                                  );
                                if($setts['type']=='select'){
                                        $form['fieldsetm']['field_p_'.$id.'['.$i.'][value]']['#options'] = explode(',',$setts['values']);                                      }
                                if($setts['type']=='radio')
                                        $form['filedsetm']['field_p_'.$id.'['.$i.'][value]']['#values'] = explode(',',$setts['values']);
                                        $form['fieldsetm']['some_markup'] = array(
                                           '#type' => 'item',
                                           '#markup' => '---------------------------------------------------------------------',
                                         );
                                }
                }


texts: Views display product attributes with prices

texts:
How do I create something like this with Views ?
This is my version in the making:

this is my view set-up:


texts:
I have migrated a site from one host to another and I now get the following warning:

  warning: number_format() expects parameter 1 to be double, string given in /var/www/vhosts/vinylletters.biz/httpdocs/modules/uc_font_attribute/uc_font_attribute.module on line 74.

Line 74 is the following.

$html .= '
'.$fontValue->fontValue.''.str_replace('.ttf','.png',$fontValue->fontValue).''.number_format($fontValue->price,2,'.','').'
';

I am not sure what I need to do to get this line working.


texts: How can I translate the field group description?

texts:
I have created two field groups on the manage form display tab for a content type. I have added some description also.

On the interface translation, I can translate the field group labels but there I can't translate the description of a field group. As when I search the description there I can't find any results.

I also checked it in the config translation but field group is not present on that page.

Is there any way I can translate the field group translation?


texts: hook_form_alter selecting a default value in a node reference select list

texts:
I am trying to add some logic to auto select a node reference option on a select list on my content type. I am trying to set it with the following.

$form['field_my_field']['#default_value'][0]['nid'] = 5;

Where 5 is a nid. The value is set correctly in the form but when it is rendered to the page the option in the select list is not selected.

What am I doing wrong?


texts: Show panel content only if current user has purchased it

texts:
(Panels, Drupal Commerce, Flag, Rules)

I'm looking for a way to show a premium content type in a panel to users if they have purchased it (using Commerce). If they have not purchased it, the product display ('add to cart' button) is shown instead.

My current idea is to use Flag & Rules to automatically set a flag on content when purchased. However, I'm not sure if this is a sensible method, or whether it would work at all.

Any thoughts on this much appreciated!


texts: i18n + views, getting localized version of node

texts:
I have a view, lets call this View A, which only shows nodes - that are referenced as the 'hero' node to a taxononmy (one to one relationship). Additionally, I have another view, lets call this View B which does the opposite: only shows those nodes that do not have the hero relationship with a taxonomy.

Now I have translated all these nodes with the i18n module into two languages. But when I change language on the site the following happens:

View A stays the same, only showing the content in its original languages (in the language of which the relationships were created).

View B has the same content as it had, plus the translated 'hero nodes' that are supposed to be in View A.

I kinda gather this has to do with the relationship of node ids that is being filtered. However, how can I make this work that both View A and View B will show the appropriate localized content?


texts:
I have a form that works fine outside of drupal where it called a script  ..../default.js However this does not work inside drupal 6 when i copy the code from ym html/php file.

I have seen this line

 drupal_add_js('globals/default.js');

Is this all I need to add to get the JS read? I have the php filter in Drupal 6 set to allow pretty much all tags for the administrator.


texts:
In many cases we're using a view of content using the summary or trimmed text of a body field. Clients sometimes remark that, if there's nothing in the summary, nothing should be displayed at all, so no trimmed text of the full content either (which Views does by default).

Instinctively I went looking in the Behaviour when no results options of that body field in the View, but couldn't find anything there that would hide the summary if the summary is empty, disregarding what's in the full content.

What would be the recommended approach to achieve this?


texts: Legal module password reset workflow is broken

texts:
I'm having trouble with the legal module, version 7.x-1.5.

When a user is sent a one-time login link, using the default user module in Drupal 7.34 the workflow doesn't work properly.

User follows the link to page informing them that they can login & change password.
They are asked to accept the site's Terms & Conditions.
They are redirected to /user/$uid.

If they want to change their password, they can't, because the user module checks for values in the URL query string.

I'm new to Drupal, so I'm looking for a way to either bypass this module for password reset and one-time login links, or to actually redirect to the proper page.

module_invoke_all('user_logout', $user);
drupal_session_regenerate();

// We have to use $GLOBALS to unset a global variable.
$user = drupal_anonymous_user();

$query = NULL;

// Deal with destination from password reset one time login link,
// by creating a new one time login link and setting it as the destination
// after the T&Cs have been accepted.
if (arg(0) == 'user' && arg(1) == 'reset') {
  $token = drupal_hash_base64(drupal_random_bytes(55));
  // This is a new, anonymous-user session.
  $_SESSION['pass_reset_' . $uid] = $token;
  $query = array('destination' => "user/$uid/edit?pass-reset-token=$token");
}

if (!empty($_REQUEST['destination'])) {
  $query = array('destination' => $_REQUEST['destination']);
}

unset($_GET['destination']);

$result    = db_select('users', 'u')
  ->fields('u')
  ->condition('uid', $uid)
  ->range(0, 1)
  ->execute()
  ->fetchAllAssoc('uid');
$signatory = array_pop($result);

drupal_goto('legal_accept/' . $signatory->uid . '/' . md5($signatory->name . $signatory->pass . $signatory->login), array('query' => $query));

I tried setting the redirect up properly with an array, like this:

$query = array(
  'destination'        => 'user/$uid/edit',
  'query'              => array(
    'pass-reset-token' => $token,
  ),
);

It doesn't work.

I've been banging my head against this for a while, but I just can't afford to spend anymore time on it right now, so I'm hoping someone has encountered this before and knows how to get around it.

Thanks for your help.


texts: How to move block from a region inside of hook_preprocess_node?

texts:
I have added mycustomblock to the header region in our settings (/admin/structure/block). We are using the standard content block and displaying that in the Content region, which is displayed below the Header region.

For just our Basic Page content type, we would like to move the mycustomblock to display below another field. We tried using the mymodule_preprocess_node hook to move the block below one of the fields (i.e. field_categories). However, we don't know how to move the block.

How would we move the block inside the hook_preprocess_node?

Setup:

Basic Page content type

Title
Categories (field_categories)
Tags (field_tags)
Image (field_image)

node--page--full.html.twig

{{ label }}
{{ content.field_image }}

/* I want to display the block here, using some variable */
{{ mycustomblock_variable }}

{{ content.field_categories }}
{{ content.field_tags }}

Regions (order displayed: top down)

header
content
footer

We tried the following but it didn't work

function mymodule_preprocess_node($variables) {
  $node = $variables['elements']['#node'];

  if($node->bundle() == 'page') {
    $block_entity = Drupal\block_content\Entity\BlockContent::load(123456);// BLOCK_ID
    $block_view = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity, 'mycustomblock');
    $variables['mycustomblock_variable'] = $block_view;
  }
}


texts: Adding a new content type programmatically in .install file or .module file?

texts:
There are 2 different ways to create a new content type programmatically.

First one, which I also use, is to create it in your custom module's .install file in hook_install() using node_type_save() and attaching the fields also in hook_install() with field_create_field() and field_create_instance() .
The second one, which in Node Example module is used, is to create it in your custom module's .module file using hook_node_info() and creating and attaching the field instances in hook_node_type_insert()

I am preferring the first method, since my feelings say that is better to maintain (i.e. adding/updating new fields via hook_update_N()) and it suits better in .install file. But, I keep myself asking why it is done other way in Node Example module.

Does anyone know the CONs and PROs of using both methods to create a new content type in code?


texts:
I've created couple of blocks from the Drupal UI.

These blocks has unsorted list with links to the other pages.

They act like a sub menus located into the sidebar region and visible to specific pages.

Here's an example for a block called fruits that have a couple of links:

Apple
Orange
Mango

The Drupal menu system or Superfish module generates active class on the links based on the URL location. How can I do that with these blocks, so let's say a user clicks on the link Apple and when the new page loads, the Apple link will have a active class, so it will look like this:

Apple

I want this, so I can set a CSS for active link.


texts: How to render a ctools content type programmatically?

texts: I have a ctools plugin aka. content-type aka. panel pane. How does one render it programmatically ?


texts: Select an image from a list to an image field

texts:
I'd like to achieve the following:

When the user creates new content, instead of uploading an image to an image field every time, I would like to make an opportunity for the user to select from 8 pre-uploaded images and if none of those are appropriate, allow her/him to upload a custom image as well.

Is there any way I can achieve this with contrib modules?

Thank you.


texts:
I have 2 custom views(block types) 'view_A' and 'view_B', one shows content the other shows orders. I need to cobmine them in a single page displaying in 2 different tables. Really dosen't make sense to bundle events and orders in one table.

I tried creating a page, but I can't select 'block' for the context type. I can only select nodes. What's the best way using the UI in Drupal 7 to do this?


texts: Entity wrapper save using db_transaction()?

texts:
I am using a db_transaction() for some data updates. I am using some EntityMetadataWrappers, modify some data, then save.

The thing is, the wrapper ->save() function doesn't have a parameter for $transaction like the entity controller does: entity_get_controller($entity_type)->save($entity, $transaction).

If I don't pass in a transaction, it will call db_transaction() when one already exists.

What will happen in this case during commit or rollback of the outer transaction?
If a new transaction is created, does this commit the one that already existed?
If a rollback of the outer one won't rollback the inner one, or if it messes up stuff when a new one is created, then is there a way to do it all in one transaction?

Note: I'm using MariaDB.


texts: Getting exception 1003 when importing images via feeds module

texts:
I'm importing images via the feeds module from a csv file. In the field for images, I've added the public url like so:
public://path/to/my/image.jpg

I've verified that the image exists and is available. When I try importing the feed, everything imports fine but I get the following two db errors for every image:
First error:

exception 'Exception' with message 'Download of
public://path/to/my/image.jpg failed
with code -1003.' in
/srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/plugins/FeedsParser.inc:424
Stack trace:
0 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/plugins/FeedsParser.inc(483):
FeedsEnclosure->getContent()
1 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/mappers/file.inc(127):
FeedsEnclosure->getFile('public://images...')
2 [internal function]: file_feeds_set_target(Object(FeedsSource), Object(stdClass), 'field_y1_rankin...', Array, Array)
3 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc(800):
call_user_func('file_feeds_set_...', Object(FeedsSource),
Object(stdClass), 'field_y1_rankin...', Array, Array)
4 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc(746):
FeedsProcessor->mapToTarget(Object(FeedsSource), 'field_y1_rankin...',
Object(stdClass), 'public://images...', Array)
5 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/plugins/FeedsProcessor.inc(296):
FeedsProcessor->map(Object(FeedsSource), Object(FeedsParserResult),
Object(stdClass))
6 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/includes/FeedsSource.inc(399):
FeedsProcessor->process(Object(FeedsSource),
Object(FeedsParserResult))
7 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/sites/all/modules/contrib/feeds/feeds.module(191):
FeedsSource->import()
8 [internal function]: feeds_batch('import', 'y1_rankings_pro...', '109600', Array)
9 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/includes/batch.inc(284):
call_user_func_array('feeds_batch', Array)
10 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/includes/batch.inc(161):
_batch_process()
11 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/includes/batch.inc(80):
_batch_do()
12 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/modules/system/system.admin.inc(2384):
_batch_page()
13 [internal function]: system_batch_page()
14 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/includes/menu.inc(527):
call_user_func_array('system_batch_pa...', Array)
15 /srv/bindings/c09f123e774147dcaf40119f13d240c3/code/index.php(21): menu_execute_active_handler()
16 {main}

Second error:

Invalid enclosure public://path/to/my/image.jpg

The feed used to work, and I don't think I've changed anything to break the import. What could be going wrong?


texts: How can I prepare a database statement and execute it many times with different input?

texts:
I have a situation where I need to update a Drupal module's query to run a SELECT query [and based on the results] an INSERT for a data set of ~a million items.

Outside of Drupal I would accomplish this by first preparing my SELECT and INSERT statements, then executing them once for each item:

$db = new PDO(...);
$check = $db->prepare('SELECT COUNT(*) FROM other_tablename WHERE colname = :value');
$insert = $db->prepare('INSERT INTO tablename (colname) VALUES (:value)');
foreach ($my_many_items as $item) {
  $check->execute(array(':value' => $item));
  if ($check->fetchColumn() < 1) {
    $insert->execute(array(':value' => $item));
  }
}

With the Drupal 7 DB-API however, there seems to be no way to get a prepared statement without executing it first using db_query($query, array(':value' => $item), array('return' => Database::RETURN_STATEMENT)).

The only option I've found is to run db_query() / db_select() / db_insert() in a loop for each item which ends up requiring the query string to be re-parsed for every single iteration.

How can I prepare a database statement (with Drupal doing its table-name rewriting) and then execute it many times with different input?

Background:

The existing implementation uses db_select() to build a query using a giant SELECT ... IN clause, filters the items in PHP, then uses db_insert() to save all of the values at once. While this implementation only runs two queries, it unfortunately blows up the memory usage when handling large numbers of items:

...
$result = db_select('other_tablename', 'o')
  ->fields('o', array('colname'))
  ->condition('colname', array($my_many_items),'IN')
  ->execute()
  ->fetchAll();
$existing = array();
foreach ($result as $r) {
  $existing[] = $r->colname;
}
$insert = db_insert('tablename')->fields(array('colname'));
foreach ($my_many_items as $item) {
  if (!in_array($item, $existing)) {
    $insert->values(array('colname' => $value));
  }
}
$insert->execute();


texts: How do I coordinate versioned signature blocks with an article?

texts:
I have users who write articles and need to show the appropriate bio content when viewing their published page.

I could add the signature field to their user account, however, I need this info to be version aware so that previous published pages are not affected by revised bios.

For example:

An article published between 2010-2012 uses the User's bio #1
An article published in 2013+ uses signature bio #2 and so
on

How do I make the joins needed to go from article->userid->user's appropriate bio node?

I've tried entity prepopulate, but it can't automatically lookup and embed the user's latest bio node as a hidden field in an a new article.

Basically, I just want someway to look up another content type made by this user and automatically tie it to the article he's creating.

How do you handle that process?


texts:
maybe the solution to my problem is quite simple but I can not find a way on the taxonomy term page to show a menu block!

I use drupal 8 with bartik theme and have a menu based on taxonomic terms (Module: Taxonomy Menu + Menu Block). This menu is also always displayed everywhere (with the set content types). Just not on the taxonomy term page (the page where all entries are displayed from a taxonomy item in a teaser view).

if I look under Structure> Block Layout> Navigation> Configuration: is there "page" there I tried to enter URL of the taxonomy terms or also / * but both remains without effect.


texts: Drush sql-sync failing with Ubuntu 14.04

texts:
I'm having no luck with sql-sync, there's two seemingly unrelated errors it's throwing at me which I'll detail below.

I've been successfully sql-sync'ing the same site to another server, so I'm pretty sure it's the remote server, not the local server, that is causing the problems. The remote server MySQL version is: 5.6.19-0ubuntu0.14.04.1 (Ubuntu)

1) Adding the --create-db switch gives me:

ERROR 1044 (42000) at line 1: Access denied for user 'user'@'localhost' to database 'database'

2) Regardless of whether or not I use the --create-db switch, I always get this:

ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: '��T'.

Any ideas?


texts:
I am building a Drupal 7 site. These are some of the modules I use: Adaptivetheme (theme), Views and Content Panes, Panels, Mini panels, Panels everywhere, Page manager, Superfish for menus, Addthis, Chosen (drop down).

For improving my site performance and the dealing with the CSS and JS files I am using the Advagg module.

When running the Pagespeed test of Google I am getting the following error as "Should Fix":

  Eliminate render-blocking JavaScript and CSS in above-the-fold
  content Your page has 6 blocking script resources and 8 blocking CSS resources. This causes a delay in rendering your page.  None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.

This is the info Google supplies:

Remove render-blocking JavaScript
Optimize CSS Delivery

Is there a way I can change the settings of the Advagg module or Drupal core, and solve this issue?

Is there another way to achieve this goal?

Update - after implementing changes according to mikeytown2 answer I got the following message on the Pagespeed test of Google:

  Eliminate render-blocking JavaScript and CSS in above-the-fold content
  Your page has 6 blocking script resources and 4 blocking CSS resources. This causes a delay in rendering your page.
  None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.


texts: Is there a module that saves Twitter posts in a custom table?

texts:
I need to save Twitter posts in Drupal 7, but I don't want to create a node for each tweet.

Is there a module that can save them in a custom table?

Thanks.


texts: Links to Wordpress shop from Drupal menu add Base URL twice

texts:
I'm working on a site that has the main site built in Drupal and the shop is built in Wordpress/Woocommerce (messy I know - not my choice).

The problem is that when I link to a product in wordpress from the Drupal main menu, it adds the base URL twice. For example, the URL should be http://www.example.com/shop/product but when I try to add the link Drupal creates it as www.example.com/http://www.example.com/shop/product

I have tried to use the relative URL instead, but Drupal won't let me.


texts: Adding Contextual Links Menu to Views table header cells

texts: I'm looking for a way to add a custom contextual links menu to the header row cells in a Views generated table. Has anybody done this? I've looked all over and I can't find a way to do it.


texts: How can I restart the PHP environment installed with Drush for Windows?

texts: I have installed Drush for Windows, works great, but it installs its own version of PHP in a subdir of the install directory.  I've increased the memory limit and execution times in that ini but how can I restart that PHP environment (if in fact that is even the correct PHP environment).  Short of restarting my machine (which is fine) just wondering what would be the way to do this?


texts: Distribution Commerce Kickstart 1.x - is possbile run Drupal Core 7.61 / PHP 7.2 ? And how

texts:
I have small and very simple  Drupal 7 site based on Commerce Kickstart 1.x distribution (originally instalation profile, now "distribution").

The version of distribution is 7.x-1.53. It is last released one.
Further, I have PHP 5.6.39. Website is on common shared hosting. There is not shell e.g.
MySQL is 5.5.62. Server is apache.

Some particular info regard my site: small multisite (3 sites with the same template and the same modules and with 3 different domains), some 90 modules, every site have approximately 1000 content items.

There is core drupal version 7.60 in this actual Commerce Kickstart 7.x-1.53 (released 18 October 2018)

But I would need the actual drupal core 7.61. It is because I must switch to PHP 7.2 (or 7.3). I would like as soon as possible, because PHP 5.x is not supported from first of January of this year (2019). I can not switch to PHP 7.0 as it is not supported by Drupal, and similarly I can not switch to 7.1 (problems/hosting).

As you can know, there is not a Commerce Kickstart 1.x profile with the Drupal core 7.61 till now. And there is no simple migration from Kickstart 1.x to Kickstart 2.x.

So, what to do now? How make for me to have Drupal compatible with some officially supported PHP version?

I am thinking about following solution:

I could try upgrade only core alone to 7.61 and let Kickstart distribution as it is.
I would update modules, what need updating, of course.

Could I? Or is there any type of problem in this way?

Notice: I am thinking a bit about "unpicking" the Commerce Kickstart instalation profile from my website completly, but I only found similar thing for another kind of distribution (Community Media Starter Kit), than I have. So I dont now, if it would work?

Thank you

P.S. Problem is not hosting. Hosting is able to give me PHP 7.2 or better. Problem is Kickstart 1.x, what officially is not compatible with 7.2 (regardless Drupal Core now is)


texts: How to record how much time user has spent on my node?

texts:
I want to record the time a user has spent on my particular node so I could show a pop up to the user to register once the user has read 3 article. But the user must have spent at least 30 seconds on each node.

There is the Time Spent module available, but I wonder if I can merge it with another (custom) module I have created (which records the number of nodes user have visited)?


texts: manage multiple sites with a single login

texts:
My client wants urls site1.com and site2.com that share the same codebase for everything but the theme. They want different node content on each site.

They also want the ability to login to one location site1/user, and be able to update content from both sites there.

Is this possible with a multi-site install or Aegir?

If there are two different databases, it seems that you could not update content from both sites in one Drupal admin panel.


texts: Is it possible to disable the Node module?

texts:
Is it possible to disable the Node module in Drupal 7?

As I understand from the interface, it is not possible. Why is the Node module is so important? What if I'm going to use only custom entities?


texts: Configuring Node Reference URL to auto populate with outbound (internal) link (node title)

texts:
I have this Node Type called "Services", and I have a Node Type called "Booking". The latter is a form to request a booking of one of the Services. So by default, every "Services" node has a link to this form. I have Installed Node Reference and Node Reference URL and in the form (because of the configuration of  the mentioned modules) I have a Select List where the client can choose all "Services" available (It's the titles of the nodes of the Type "Services")

How could I achieve that, instead of the client having to manually select the Service from the list, it is already marked the title of the node corresponding to the URL the user is accessing the form, from. (meaning where they were at when they clicked the link to the form)

THANK YOU in advance.


texts: using hook_form_alter on a same form from 2 different modules

texts:
How will a predefined form behave if we have two different forms that implement hook_form_alter?

I would explain my question by an example, because currently I got a crash on it:

I have a predefined user_login form in user.module

I created two new blocks called author_login and creator_login. Each of these module using the form user_login and adding new validating properties for each form by using function hook_form_alter().

The new validating properties are:

For author_login block: if user doesn't have author role, user will not be logged into system, error: "you don't have author role"

For creator_login block: if user doesn't have creator role, user will not be logged into system, error: "you don't have creator role"

But the problem is: the new login block I created works fine if only one of two modules is enable. If I enable both modules, no user cannot log in to the system through these module.

For example, I have both modules enabled, I go to author_login block and log an user named Mark, who has role Author, to the system, an error message displayed: "the user Mark doesn't have creator role". And similar to creator_login block.

Why does this happen? I thought that the hook_form_alter will alter different properties to each new module we created, make each new form works separately. But from this case I encountered, it seem like the user_login form validate all new properties that I added by using hook_form_alter. And how can I avoid this as I want these two form to work separately?

Notes: I am really sorry to post this question here because I posted the question on drupal.stackexchange but there was only one answer that couldn't help me much in finding the solution. I really need help on this question. Many thanks!


texts: How to export the contents of nodes in a view

texts: I have a view that displays content based on some criteria. I would like to export all of the content of the results of the view into a text document or Excel spreadsheet, as I am intending to edit them for a book. Any idea how to do this?


texts: How do I configure the Google TMGMT Translator module with the correct api key?

texts:
I want to insert an API key for the Drupal TMGMT Translator Google module. I’m using a Google Cloud Platform Service Account to generate the key. Instead of being presented with a key code to copy and paste, for security, the key was saved in a JSON file to download.
The API key text field in the Drupal interface accepts about 40 characters but when I open the file I find that the code labeled as the key is more like 1500 characters long.
If someone could help me to decipher the correct code from this JSON file that would be great?
I’m on Drupal 8.9.15 with the latest TMGMT Translator module installed.


texts: I'm getting mixed up in my terminology.  If I created an Entity named "Students," via .yml that has its own table.  Is that a Content type but a Custom Content Type?


texts: Why are the titles are lost for translations when posting nodes?

texts:
I'm currently prototyping a project in Drupal 8. I'm posting HAL json to /entity/node with the relevant headers to create nodes. I'm including translations as per this example:

{

"_links":{ "type":{"href":"https://localtest/rest/type/node/page"} },

"title":[{"value":"posted title en","lang":"en"},
         {"value":"posted title de","lang":"de"},
         {"value":"posted title fr","lang":"fr"}],

"body":[{"value":"posted body en","lang":"en"},
         {"value":"posted body de","lang":"de"},
         {"value":"posted body fr","lang":"fr"}]

}

This creates the node and the 2 translations. However, only the english version gets the title and body. Any other language just get the relevant language's body and a blank title. I have tried this with an admin account to rule out permissions problems. I have manually added the translations to make sure titles are translatable and work.

Does anybody know why the titles are lost for translations when posting nodes?


texts: How to obtain raw View result for Drupal 5?

texts: How do I get a raw result from a view similar to this $view->result for Drupal 5 ? I would like to get results from the database and run calculations before displaying to the user. I really need to gain access to the the raw data before it's themed by the Drupal engine.


texts: D7 : Upload to a folder outside of "files" folder?

texts:
Specifically outside of the Drupal installation folder...

I have a folder in my WWW folder that I'd like place files into through Drupal. However, it looks like, by default Drupal prefers to only upload into the "files" folder.

Has anyone encountered something like this?

I have tried making a custom upload field point to "/var/www/uploads" and the FilePath module, but neither work.

Any suggestions. Is this a case of creating a custom module that points to that folder? If anyone has come across a tutorial regarding custom upload paths that would be awesome.

Thanks for any help.


texts: 8 - Views: list pages that are child menu items to the current node

texts:
I have three nodes:

Node A
Node B
Node C

In the main menu, these nodes are organized with Node B and C as children of Node A's menu item, like so:

Node A

Node B
Node C

When Node A is viewed, I would like to display/list Node B and C in a block under Node A's content.

I would like to do this without using the Book module. I would also like to do this without adding an extra step to the user (i.e. using entity reference on Node A).

Is there a way to do this views? i.e. to create a relationship to the menu structure?

Here's a drawing of what I'm trying to achieve:

Any insight is greatly appreciated.


texts: How to fetch field revision history for each change, username, created and delta value?

texts: I would like to fetch and display the revision history for each change for each field attached to an entity.  I notice in each field revision table the username and created are not there. Only the delta value. Is there a way I can display to the user (in a popup over each field) the revision history including the previous values, date changed, and user who changed value.  Possibly using the entity revision itself with a join?


texts: How to set the default value of an entity reference to an entityform type

texts:
I'm using the module EntityForm to create a couple of different forms.

Each form should be attached to a different content type as an entity reference field.

I can create an entity reference field that shows a select list of "EntityForm Type" from which the user can choose when creating content.
I would like to set a default value however (and will hide the field so it can't be changed), since there shouldn't be choice as it's always the same kind of form that needs to be attached.

I know this is possible with nodes by loading a specific node, but in this case they're entityform types and not nodes.


texts:
Node compare is awesome plugin but it's just only in D7.

I'm using Drupal 8.

I have a views page which integrated with flag(compare it) and flipped table module  to compare contents. It has limit to show max. 4 content. Everything works until this point.

But how can  limit user to flagging max. 4 times. Flag limit is nice in D7 but it's not ported in D8.And I couldn't achieved it via rules integration.
Any help with this would be awesome . Thanks


texts: Filtering view by content author OR referenced field

texts:
I have a user that is author and is referenced on a certain content type, I want to be able to filter a view to show all nodes where the user is referenced, example field_user and where the user is the author.

I can have access to the current user from my view and I did had a group with the OR operator so it can be filter to content author and from referenced field.

When I do things separately both work, I mean, I can get the nodes where the user is author and then I can get the nodes where he is referenced but when I add the two filters simultaneously with the OR operand this does not work, any idea?

In the image below are my settings to the view, I think that you may understand what I am doing.

Thank you.


texts: Cannot install Composer because it doesn't contain any .info.yml files

texts:
Newbie using clean Drupal 8 install on a server.  Installed module "International Telephone," but got error.  Then I read that I needed to also install Composer.  When I tried to install Composer, I received the error that there were .info.yml files.

I've spent hours researching without luck...


texts: How to position javascript file as the last one to load?

texts:
In Drupal 8 the weight for javascript files in libraries is not supported, or at least only negative values are allowed, which means I am only able to position them at the top of the list (i.e. load it first) but not at the end of the list.

I have a library for the Zurb Foundation and its initialization has to be loaded last. It is a requirement for my theme and I don't want to override a template to fix this problem.

How is one supposed to do this?


texts: How can translations 'inherit' CCK values of the node in the default language

texts:
I've got a CCK content type called 'projects' with about 10 fields, including an ImageField that allows for multiple images.

There are two languages defined for the site: English (the default), and Chinese.

The projects have been created in English by the client.

Now, they want to add translations for all the projects into Chinese. So, I've:

enabled content translation
created a new 'project' node (e.g., node/234) and populated just the title and body fields (all the other values are the same between both nodes)
gone back to the original English node and added node/234 as the translation

The problem of course is that when I go into the Chinese translation for the page, the field values for the original node aren't there, so at the moment, the site editors would have to re-add the values all over again.

Is there a module or Drupal setting for addressing this issue, or would it be better to, say, create a module to run a query that populates the fields in Chinese translations with the values from its sister English node? I'm not adverse to writing such a module, but if there's a solution already, of course that would be better.


texts: How to just show front page and message when search api search was queried with blank input

texts:
How can I just show front page when no letters were printed in search input, but it was submitted?

And optionally maybe show message 'please enter the terms of the search'

I thought of doing this with Rules, but no rules considering searches are present(


texts: Display Suite: how can I generate a render array for a field that is not being displayed

texts:
What I'm doing is complicated, and there is likely to be a much better way to do it, so I'll try to go into some detail, and edit the question after the fact to tailor more closely to the final answer I get if the answer is to do something different.

Right now for my teaser view for nodes I generate a generated_cover field in code to allow me to fallback through a couple of potential sources of cover image.  First there is a cover image field.  If a user has uploaded a cover image for the node we use that.  Second is a cover generated by the pdfpreview module, finally if neither of those are found, it returns a blank, which I then use with field formatter conditions in display suite to replace with a placeholder image.  As you'll note from the code used for generating the fields below you'll note that they rely on `$field['build'] to get the generated field.

/**
 * Implements hook_ds_fields_info().
 */
function MY_MODULE_ds_fields_info($entity_type) {
    if ($entity_type == 'node') {
        $fields = array();
        $fields['generated_cover'] = array(
            'title' => 'Generated Cover',
            'field_type' => DS_FIELD_TYPE_FUNCTION,
            'function' => '_MY_MODULE_ds_field_generated_cover',
            'formatters' => array(
                'standard' => 'Standard output',
            ),
        );
        return array('node' => $fields,);
    }
}

/*
 * Generate the output for the generated cover image field
 */
function _MY_MODULE_ds_field_generated_cover($field) {

    // Get information about the entity being rated and the formatter we're using.
    $entity = $field['entity'];
    $formatter = $field['formatter'];

    if (!empty($entity->field_doc_cover)) {
//        $output = "cover";
        $output = render($field['build']['field_doc_cover']);
    //    $output = render(entity_view('doc_publication_files', $entity->field_doc_cover, 'teaser', $entity->language));
    } else if (!empty($entity->field_doc_pub_files)) {
//        $output = "preview";
        $output = render($field['build']['field_doc_pub_files'][0]);
    } else {
        $output = "";
    }
    return $output;
}

This has worked fine for the teaser view, though the build variable is never populated if the field is disabled for the display, so I need to include the fields in the display and use field formatter conditions to hide them.  Now I need to use the same fallback on the full display, and am running into an issue:  I need to display the file field using a different formatter AND have the pdfpreview version as an option for the cover fallback.  I used a dynamic field to bring a copy of the file field in and set up the formatter as I needed it to be, while still keeping the original file field as a hidden field set up to the pdfpreview format, but now no matter how I try to hide the original file field (with the pdfpreview formatter) and display the dynamic field, if the pdfpreview version is not completely disabled, the dynamic version will not show up.

I'm trying to fix this by not relying on the presence of the original field in my generated form anymore.  I'd like _MY_MODULE_ds_field_generated_cover to produce and render an appropriate render array for the cover image if it exists (image at medium style linking to nothing) and produce and render an appropriate pdf preview for the first file if it exists and is a pdf file (again medium style).  Otherwise it should return nothing.  That way I'll be able to use my original file field in my displays without concern that they'll interfere with each other.


texts:
I am attempting to override a node field value in Drupal 8 (on output) using template_preprocess_node. Specifically, I am attempting to override the text of a long text field. I am currently using this:

function THEMENAME_preprocess_node(&$variables) {
  $variables['content']['field_content'] = array(
    '#type' => 'markup',
    '#markup' => '
Testing 123
',
  );
}

And that works, but it totally overrides the field, removing the classes I added to the field wrapper, etc.

Does anyone know how to just set the value only, without replacing the entire field theming, etc? I do not want to manually add the field wrapper classes to #markup.


texts: How to delete node of a content type if having millions of node

texts:
I have a content type in my Drupal 8 instance and having more than 2 millions (20 lakhs) node and want to delete those node, tried many things but nothing helps, either HTTP 500 error occur or Website encounter an error message came. Need help please suggest some workable solution. Methods I have tried so far are :-

Using module - Delete All
Devel generate and delete method Article.
Using query

 $result = \Drupal::entityQuery('node')
  ->condition('type', 'my_content_type_name')
  ->execute();
entity_delete_multiple('node', $result);

Please Help!!!


texts: How to use the Charts module for creating charts using Views?

texts:
I am using Drupal 6 and trying to setup the Charts module to work with Views.

On the Charts project pages it says

  Views integration: Display the Views results as charts

so views is supported. However I had no luck at all so far. Even though the module seems very well written, it lacks documentation.

My question: How to set this up?


texts: Appears the same orders in the admin/commerce/orders and in the admin/commerce/orders/carts

texts:
In admin/commerce/orders appears the orders that order status is: Checkout:Payment,Checkout:Checkout,Shopping cart (these orders that appear in admin/commerce/orders/carts).Ι would like to appear only orders tha order status is:pending.
How could I do it?

Thank you very much.


texts: Policy Question: Can I Use a Submodule that Does Not Follow Drupal Code Guidelines?

texts:
I have a fairly extensive plugin system that I wrote.

It uses an MVVM pattern, where the lions' share of the code is in a cross-CMS class.

I haven't submitted the Drupal plugin to the Drupal repo, because it does not follow their coding conventions.

It has extremely rigorous coding conventions; just not the ones prescribed by Drupal.

Fair enough. They have every right to dictate coding standards. That's a good idea, and I support it.

However, I can't rewrite the MVVM library to make just one of the targets happy.

Since the MVVM library is actually a submodule, can I submit the plugin to the Drupal repository if the Drupal-specific parts (just a couple of files) are set up to use Drupal standards?

For that matter, since Git is so horrible with submodules, I wonder if the Drupal repository can even handle submodules.


texts: How do I pass an organic groups GID to a view in a pane?

texts:
I have a drupal 7 site using Organic Groups, for each group I have list pages - so for instance if i have the group mygroup I have a page which lists all posts - (www.mysite.com/groups/mygroup/posts). This page has a groups audiance field (og_group_ref) which has the correct gid..

I have the list page set up with panes one of which is a view showing all posts with the contextual filter set to GID.

The view works on its own if I pass in the GID of the group I want, however, I cannot get this to cooperate with the list page, probably something to do with the pane, or panels, or a relationship I need to add to the view?

I've tried inserting the view into the pane as a content pane and as a block, but I'm having no joy...

What do I need to do to get this to work?

I have since found this post:

How do you display a pane in an organic group?

this seems to be the answer to what I'm looking to do, however, the settings shown in that post are not available to me. Maybe because panels/views/og have been updated and the settings are a little different now? Either way I still don't have this working. Does anyone have any pointers?


texts: Field Collection vs. Entity View Modes with Field Group

texts:
I have been using Entity View Modes to organize my fields, have different display types, and use Field Groups to add bootstrap-style wrappers around my content.

As often as humanly possible, I have views and panels render nodes with these view modes to keep a consistent look throughout the site.

I keep hearing about Drupal Field Collections, and have a basic understanding that it goes further and makes an Entity out of the grouped fields.  Seems like a different approach to achieve similar results. It has a lot more uses, but also a lot more open issues, and needs other modules to integrate with Views and Features.

I'd love to hear some thoughts on this.

Thanks,

Ji


texts: How do you load a node inside of another node?

texts:
A node has several text links or thumbnails loaded from a view. For the purpose of this question, lets suppose they're thumbnails and the area with the thumbnails lets call it the "head" of the node.

Those thumbnails link to other nodes. To be able to understand the scenario am trying place here. Lets call the nodes that the thumbnails link to "Subnodes". The Area under the thumbnails, is a area where you want to load a "subnode" from the thumbnail clicked. Lets call this area the "footer".

The goal here is keep the original node with the thumbnails or text links ("Header") at the top of the page AND load the subnode in the "footer". The ideal method would involve some AJAX to keep the page load away from the end user. Although this is not required because a solution with a page load is acceptable.

Extra consideration to anyone who purposes a solution using AJAX.


texts: Multiple fields that are generated dynamically in forms

texts:
In a particular section of my form, some of fields are iterated over n number of times whenever we click add button n times.

I want to add below details of each student by click add button and remove the details by remove button.

Help would be greatly appreciated :)
Drupal version  is 8.

  $form['reg']= array(
          '#type' => 'textfield',
          '#title' => 'Registration Number',
          '#validated' => TRUE,
      );
 $form['fname']= array(
          '#type' => 'textfield',
          '#title' => 'First Name',
          '#validated' => TRUE,
 );
  $form['lname']= array(
          '#type' => 'textfield',
          '#title' => 'last Name',
          '#validated' => TRUE,
  );
 $form['email'] = array(
       '#type' => 'textfield',
       '#title' => 'Email',
       '#validated' => TRUE
 );


texts:
I would like to set up OpenSearch so it works in Drupal 7 so the search experience can be integrated with the user browser the way it is done on drupal.stackexchange.com.

I found the following contrib modules (none ported for D7):

http://drupal.org/project/opensearchplugin - D5, D6
http://drupal.org/project/opensearch - D6
http://drupal.org/project/opensearch_aggregator - D5, D6

What is the current solution for this for D7 ?


texts: Drupal Commerce - Persistent Data Storage within the Cart

texts:
My objective is to build an commerce site that attributes 'tokens' (integer values) to products and than keeps a running total of the complete token value within the cart. The idea is to check against how many tokens the user has before allowing a purchase, allowing a product to be added to cart, etc. etc. So far my strategy has been to do this:

Hook_entity_info_alter on the line item product type 'token-based-products' to add a persistent data field for the token value which is required and accessible within views. This seems pretty straight forward.
My Question. How do I keep persistent data storage about tokens within the cart for validation? The objective for this is to create a few hooks that check the running total token value of the cart before allowing/disallowing a product being added AND before allowing products to be checked out.


texts: User warning: The following module is missing from the file system: content

texts:
I don't know why but I'm getting this PHP error in drupal log. I've reviewed drupal system table but there isn't a content module. The next part of the message is:

_drupal_trigger_error_with_delayed_logging() (line 1156 of ..public_html/includes/bootstrap.inc).

I'm using Drupal 7.65. Is there anyway I could trace it in order to search for the problem?


texts: multisite: only changing name of the website

texts:
I have a multisite up and running, which has completely different domain names but absolutely the same content (I'm using filters to filter the content by domain).

Everything works splendid with almost no redundancy. However, the only thing keeping me from rejoicing, is that I cannot change the name of the website domain-wise.

So basically, my question is where I can set this up, or rather:
Is there a way to override the page's name on drupal load?
And if there's not, can anyone tell me which table the site's name is getting stored, so I can domain-prefix it?


texts: How do I programmatically create forum container?

texts:
I'm trying to programmatically create a forum container in Drupal 7. I found http://www.unibia.com/unibianet/drupal/how-create-drupal-forums-and-containers-programmatically, but it only works for Drupal 6.

What is the equivalent code for Drupal 7?


texts: Do we have another solution for the "After cloning a node" event for the Node clone module?

texts:
I would like to use the event in Rules "After cloning a node" but unfortunality this does not work. (see Event "After cloning a node" by node clone module is not working).

I tried to patch the module but did not succeed.

I would like to solve this with rules with :

Event - "Node Edit on type foo"
and then add some conditions.

Does anybody knows a good condition for this? What can I compare?

Are there other solution possible?

I need it for the folowing situation: the user has two options for a node:
(1) Edit
(2) Clone

(1) The edit option is just going to the edit form. Normal editing should be done.

(2) The clone option makes a copy of the Content Type and then starts editing in this node. Before the user is starting this editing two fields in the content type should be empty.

--- Patch log (#8)
$ patch -p1 <2212039-8.patch
patching file clone.pages.inc
Hunk #1 FAILED at 160 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file clone.pages.inc.rej

--- Patch log (#8) With option --ignore-whitespace
$ patch -p1 --ignore-whitespace <2212039-8.patch
patching file clone.pages.inc
Hunk #1 FAILED at 160 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file clone.pages.inc.rej


texts: I have a relation type with arity 3. i.e. Book, Publisher and Author. I'm trying to create a view where, given the publisher id as argument, it lists all the other end points of the relation type. I am able to do this for binary relations, but not able to do so for arity > 2. For now, I am doing a relation_query() to accomplish the same.


texts: Load entity reference value for multi referenced content types

texts:
I have three content types, two of them have an entity reference field referencing the others in some hierarchical manner, that explained as follow:

  -----------------------------------------------------------------------------------
  | content type | Country   | State                | City                          |
  -----------------------------------------------------------------------------------
  | reference    | none      | reference to Country | reference to Country and State|
  -----------------------------------------------------------------------------------

Normally, while adding content for City, both entity reference fields will show all its contents as values.

So, how to limit values in second entity reference field (State) to only values based of each choice of first reference field (Country)?

I assume Conditional Fields can do that, but I had no chance to figure it out.


texts: Nodes they have reference to the nodes of current user

texts:
I use node reference and want to display with views to the user only the nodes they have reference to its nodes :

A*<----B

^----C

E**<-----D

*: node created by the current user.

**: node created by an other user.

The views for current user will only show : B,C.


texts:
I am trying to understand Views SQL, and am using a query of some Commerce data to increase my understanding.  Here is the start of a query:

SELECT commerce_order.order_id AS order_id,
commerce_customer_profile_field_data_commerce_customer_billing.profile_id
AS commerce_customer_profile_field_data_commerce_customer_billi, ...

The first part of this is straightforward enough, it is just picking up the order_id from the commerce_order table. The second item, though is puzzling: the first part, commerce_customer_profile is just a table, but then the second part field_data_commerce_custom_billing is another table, and the two are connected by an underscore.

In other words, the construct looks like this: SELECT table1_table2.field. I have searched at length for an explanation of this syntax, but cannot find anything


texts: Block taxonomy list count with filter by search term?

texts:
Currently I have setup a view to display custom search results based on search terms (exposed filter):

/blog/search?keys=user+entered+term

On the page I am looking to show a list of tags with counts based on that search term, for example:

Code (x)
Tutorial (x)
Help (x)

A block has already been created in the view with the following:

CONTEXTUAL FILTERS
(term) Taxonomy term: Name (-> display summary with count)
RELATIONSHIPS
Content: Taxonomy terms on node
FIELDS
(term) Taxonomy term: Name

While the above does output the taxonomy terms, it displays the counts for all of the taxonomy, rather than filtering it based on the search term.

Seems like I am most of the way there, but would appreciate any thoughts/suggestions anyone could offer.


texts: How to enable menu link when creating a new node?

texts:
I try to enable the menu link programmatically, here is how I do it:

function create_menu_link() {
    $node = new stdClass();
    $node->type = 'mytype';
    node_object_prepare($node);

    $node->menu['link-title'] = $menu_title;

    node_save($node);
}

But setting only the title is not working. In $node->menu there is some other variables like mlid and plid which are set to 0 it has to do with this ? The menu_name is set to main-menu:0, module is set to menu.


texts: I need to add some fields than can take numeric values and enable Drupal to calculate it. I chose an integer field, tried to do some simple math, but Drupal 7 treats values of integer field as text. Moreover, integer field type widget can be only set up as text. Can anybody help me, and tell me how to add field with number values?


texts:
I'm using Drupal 6 on a website and trying to configure SSL for it.

I installed the Secure Pages module. However I can't figure out the following things:

How to give secure pages to all anonymous users and admin.
How to secure all pages of my site in the settings.

The documentation is not extensive.

Please help as I've spent half the day trying to fix this.


texts:
We all know php's variables(array, integer,string) would be taking large memory. So PHP recommend to unset the variables to optimize the memory.

Should I do that in Drupal too ? or Is Drupal internally handling such a things ?


texts:
I have view that shows articles. It works fine if user selects one image but if she selects multiple images to article, it will duplicate the article on my view X amount time (x = number of images that article has). I have tried using distinct but that doesn't do any difference. Why would this image amount effect on this?

I'm using Drupal 6, with Views Version 3.

Here is the query if it helps:

 SELECT DISTINCT(node.nid) AS nid_1, users.uid AS users_uid,
 node_data_field_article_image.field_article_image_fid AS
 node_data_field_article_image_field_article_image_fid,
 node_data_field_article_image.field_article_image_list AS
 node_data_field_article_image_field_article_image_list,
 node_data_field_article_image.field_article_image_data AS
 node_data_field_article_image_field_article_image_data,
 node_data_field_article_image.delta AS node_data_field_article_image_delta,
 node.type AS node_type, node.nid AS nid, node.vid AS node_vid,
 node_data_field_article_color.field_article_color_value AS
 node_data_field_article_color_field_article_color_value,
 node_data_field_article_numbers.field_article_numbers_value AS
 node_data_field_article_numbers_field_article_numbers_value, node.created AS
 node_created, users.name AS users_name, node.title AS node_title,
 node_revisions.body AS node_revisions_body, node_revisions.format AS
 node_revisions_format, feeds_node_item.url AS feeds_node_item_url FROM node node
 INNER JOIN users users ON node.uid = users.uid LEFT JOIN
 content_field_article_image node_data_field_article_image ON node.vid =
 node_data_field_article_image.vid LEFT JOIN content_type_blog
 node_data_field_article_color ON node.vid = node_data_field_article_color.vid LEFT
 JOIN content_field_article_numbers node_data_field_article_numbers ON
 node.vid =
 node_data_field_blog_font.vid LEFT JOIN node_revisions node_revisions ON
 node.vid = node_revisions.vid LEFT JOIN feeds_node_item feeds_node_item ON
 node.nid = feeds_node_item.nid WHERE (node.type in ('blog', 'feed_item')) AND
 (node.status = 1) ORDER BY node_created DESC


texts:
When a visitor registers on my site, I have a set of rules that create several nodes. One of those nodes is a photo gallery.

The rule for the creation of the gallery title, includes the following: [account:name]'s Photo Gallery and that works fine.

But if the user changes his name later on, the name on the photo gallery is not updated.

I have been struggling with the creation of a rule to do just that but I haven't found the option or configuration that allows me to update the node title.

Any help on this would be greatly appreciated.

Thanks. :)


texts: How can I export the raw body of a node?

texts:
I set up a CSV view with views_data_export. I'd like to export the raw body of nodes. So I want to keep both the raw markdown and the raw HTML in the CSV.

Is there a way to do this that I have overlooked? Should I add a formatter that does nothing? If so, how can I do that?

I thought I had solved it by checking "Rewrite the output of this field" and using [body-value], which is the raw value.

And this gives me the raw markdown but still doesn't give me the raw HTML.


texts:
I'd like to post alot of Google Analytics info about a page(node) on the page itself(visits, new visits, bounce rate, maybe even time series). What's the best module for this?

In particular, the info is for users that create their own pages and need to see analytics for their pages.

Any hints?

Thanks.


texts: Drupal7 - How to display both summary and body on full view?

texts:
It probably has an easy solution, but I couldn't figure out how. I have the original "Article" content type with an image and a summary field. Summary is readily displayed on front page, but in full view, only the body is displayed, but I want to display both the summary and the body. I will have articles where the summary is an eye-catch for the article, but I want to display and style it differently on the full view page too. I am free to edit templates or modify drupal settings so any method vill be fine with me.

Edit: I managed to print the summary with

print render($content['body']['#items'][0]['safe_summary']);

Is this a good way to print the summary?


texts: Drupal 7: Permissions when Apache is running as user account

texts:
My current host has it set up so that Apache runs as the same account that I use to manipulate files on the file system and, subsequently, the same user that I used to install Drupal 7.

I'm trying to pass the checks in the Security Review module, but it keeps complaining that (pretty much all) files and directories are accessible. I've looked at the handbook page and tried applying the script, but to no success.

Can anyone suggest the proper permissions for my files and directories?


texts: When should I not use Views for listing content?

texts:
Views is the most popular module of Drupal 7. I don't doubt it's the best solution for listing content on Drupal, as one of the Drupal strengths.

However, Views is not used everywhere. For example, this video shows how to create a product catalog in Drupal Commerce using Taxonomies and Menus.

This question is to ask for the cases where Views shouldn't be used, and why.


texts: List of nodes limited by last node created from each user

texts:
I am using Drupal 7, and I want to create a views which lists all the nodes that match the following criteria:

Only the nodes whose content type is A, B, C
The latest nodes of those content types created by all the users, one node for each user

How do I create it?


texts: Create node upon form submit rendered by block plugin

texts:
I'm attempting to create a block plugin that displays a form that allows users to enter information and create a node with that information.
I understand I can easily create a form plugin that accomplishes this task but I'd like this to be inside a block plugin so that I can place it on existing pages instead of it being on it's own dedicated page. I'm building the form like so

<?php

/**
 * @file
 * Contains \Drupal\my_plugin\Plugin\Block\EquipmentEntry.
 */

namespace Drupal\my_plugin\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * @Block(
 * id = "equipmententry",
 * admin_label = @Translation("Equipment Entry"),
 *  )
 */

class EquipmentEntry extends BlockBase {
    public function blockForm($form, FormStateInterface $form_state) {
        return $form;
    }
    public function blockSubmit($form, FormStateInterface $form_state) {

    }
    public function build(){
                $content = [
            'container'    => [
                '#type'       => 'container',
                '#attributes' => [
                    'class'      => ['equipment-entry'],
                ],
                'form'         => [
                    '#type'       => 'form',
                    '#attributes' => [
                        'name'       => 'equipment-entry',
                        'id'         => 'test',
                    ],
                    'title'   => [
                        '#type'  => 'html_tag',
                        '#tag'   => 'h1',
                        '#value' => $title,
                    ],
                    'contact'      => [
                        '#type'       => 'textfield',
                        '#title'      => t('Contact Person'),
                        '#attributes' => [
                            'name'       => 'contact',
                        ],
                    ],
                    'Telephone'    => [
                        '#type'       => 'textfield',
                        '#title'      => t('Telephone'),
                        '#attributes' => [
                            'name'       => 'phone',
                        ],
                    ],
                ],
             ];
          return $content;
    }
}

However I'm not sure how to perform any action upon submitting the form. I understand there's a blockSubmit() function but I believe that's only when you save a block.

I tried intercepting the form with a form_alter hook like so

function my_plugin_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
        die($form_id);
}

but the function never fired. Is there a way to programmatically create a node when someone submits a form that was created to be displayed inside a block plugin? Or is there a way to create a form plugin and embed it inside a block?


texts: Why is view field output different for anonymous users?

texts:
I got this html when user is Logged in :

        cook

and got this when user is logged out :

    cook

Additional notes (from comments):

Taxonomy view
Tried clearing caches
No server side caching set up


texts: How to resolve the error "Base table or view not found"?

texts:
When I connect my custom module with database external

$database = array(
  'host' => 'localhost',
  'database' => 'DATABASE1',
  'username' => 'root',
  'password' => 'root',
  'driver' => 'mysql',
);
Database::addConnectionInfo('mykey', 'default', $database);
   db_set_active('mykey');

it gives error on running the module

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
  Table 'DATABASE1.filter_format' doesn't exist: SELECT
  ff.* FROM {filter_format} ff WHERE (status =
  :db_condition_placeholder_0) ORDER BY weight ASC; Array (
  [:db_condition_placeholder_0] => 1 ) in filter_formats() (line 434
  of /var/www/html/drupalprac/modules/filter/filter.module).

  Uncaught exception thrown in shutdown function.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
  Table 'DATABASE1.semaphore' doesn't exist: DELETE FROM
  {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array (
  [:db_condition_placeholder_0] => 1595456215ac3545f2ff1c3.60338979 )
  in lock_release_all() (line 269 of
  /var/www/html/drupalprac/includes/lock.inc). Uncaught exception thrown
  in session handler.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
  Table 'DATABASE1.sessions' doesn't exist: SELECT 1 AS
  expression FROM {sessions} sessions WHERE ( (sid =
  :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1)
  ); Array ( [:db_condition_placeholder_0] =>
  gSAxKMpfVXzf2EVP4EWBtuF2klcg0RZie30ztTTUjKc
  [:db_condition_placeholder_1] => ) in _drupal_session_write() (line
  209 of /var/www/html/drupalprac/includes/session.inc).


texts:
I am trying to run the cron job in a drupal website that my client gave me then I tried to update the cron job for search and after the cron jobs finished then my drupal installation turn into this error.

  Fatal error: Call to undefined function _ds_inception_get_overrides() in C:\Apache24\htdocs\sites\uqsport.com.au\modules\ds_inception\includes\ds_inception.pages.inc on line 37

I have searched everywhere in google but it seems other people don't have this kind of problem before so it kind of make me perplexed as to how this error came upon me?
I just need to know how the above error happened? and what is the solution.
any help would be greatly appreciated. thanks though.

update.

this is what ds_inception.info contains.

 name = Display Suite Inception
description = Create flexible layout pages (Drupal within Drupal) on top of Display Suite.
package = "Display Suite"
core = 7.x
files[] = ds_inception.class.inc
files[] = ds_inception.module
dependencies[] = "ds_inception_fields"
dependencies[] = "ds"
dependencies[] = "ds_extras"
dependencies[] = "views"
dependencies[] = "ctools"
dependencies[] = "entity"
dependencies[] = "list"
configure = admin/config/user-interface/inception

; Information added by cms-build component-build on October 24 2016
version = "7.x-1.0"
core = "7.x"
project = "ds_inception"
datestamp = "201610241316"


texts: Drupal 8, entityQuery with operand "AND" for a multiple values field

texts:
I have 2 contents who contains a field 'field-test'. The 'field-test' contains an array of taxonomies (its a simple multiple values taxonomy field) :

Node A :

  field_test : '1','2','3,'4' // where 1,2,3 and 4 are tids

Node B :

  field_test : '4','5','6,'7'

With the entityQuery api, I can get nodes who contains the taxonomy '4' OR '5' with :

$test = \Drupal::entityQuery('node')
  ->condition('field_test', array('4','5'),'IN')
  ->execute();
// get nodes A and B in an array

But I want get only the node B (only the node who contains taxonomies 4 AND 5)
How can I do that ?

Thank you :)


texts: Why is BaseFieldDefinition::getDisplayOptions($display_context) returning NULL

texts:
I'm trying to get the weight of each field (of a form) in its display.

$fields = $entityManager->getFieldDefinitions($entity_type, $bundle);

foreach ($fields as $field_name => $field_definition) {
  $field_definition->getDisplayOptions('form'); //returns NULL
}

This returns NULL. $field_definition definitely has stuff inside of it. any ideas?


texts:
Im breaking my head around getting the breadcrumbs set properly on views page.

my views' page address is "teachers/%" where % is a term-id.

I have a content type called 'program' with a field taxonomy term reference field "field_department"

I want to set my breadcrumb for the page  'teachers/%' to be the breadcrumbs of the program associated with % + the program itself.

my site is using also menu_breadcrumb which gives the rule for my program breadcrumbs.

I want the the breadcrumb of 'teachers/7' will behave as if it is the menu child of node/22.

I tried both hook altering the breadcrumbs or adding the pages to the menu dynamically but I dont manage.

Can this be done? and how?


texts: How do I create an instance of a search plugin?

texts:
I created a custom search plugin to index and search a sub-set of taxonomy terms and their fields, as these are used as landing pages. In addition, we are using the node search. This gives us two search pages, which both work.

However, taking inspiration from the Drupal 7 search_combine module, we want to create a page with the combined search result.

So we set out to create another search plugin in a custom module. This gets all active search pages and their IDs. So far so good. Now the idea is that this plugins execute method goes through all active search pages, creates an instance of the respective search plugin, gets the results of that search using plugin->execute(), and combines the result arrays and then returns the combined search results (pretty much as search_combine does for Drupal 7).

However, we are having problems following the instructions here.

Here are the steps to follow to perform a task that involves plugins:
- Locate the machine name of the plugin manager service, and instantiate the service. See the Services topic for more information on how to do this.
- On the plugin manager class, use methods like getDefinition(), getDefinitions(), or other methods specific to particular plugin managers to retrieve information about either specific plugins or the entire list of defined plugins.
- Call the createInstance() method on the plugin manager to instantiate individual plugin objects.
- Call methods on the plugin objects to perform the desired tasks.

Our service is "plugin.manager.search", if I am not mistaken.

However, I am a bit puzzled by the rest. How do we now use this to get the respective plugin definitions and then create an instance of that plugin?


texts: How to restrict a view to display only 2 content types?

texts:
I have created a view (/page_view), which displays two content types.

This view contains a contextual filter for user to be able to see only one particular content type (/page_view/content_type_1 and /page_view/content_type_2).

But in my case the user by typing for example /page_view/content_type_3  is able to see other content types which should not be included into the current view.

How can I restrict a view to display only 2 content types?


texts: Using Views to filter images based on taxonomy of page node

texts:
I have many image files with taxonomy associated with them. I have page nodes using the same taxonomy vocabulary. I want to create a Views block that filters the images displayed based on what that page uses for that vocabulary.

Fake example:

I have a page that is tagged with carrots and broccoli.
I have image files tagged with the same terms. I want to place a Views block on the page and have that view only show images tagged with the same terms.

How do I do that?


texts: How to set paths where to load administration theme?

texts:
E.g. administration themes are used only on paths that start with /admin/, what if I want to use administration theme on paths like /user/, /users/* or user/login?

There is a module for that where you can set paths where to load your admin theme https://www.drupal.org/project/admin_theme, but my question is for Drupal 8.


texts: How to run a Drush command in interactive mode

texts:
I want Drush to actively output messages instead of putting them into a buffer and then outputting them when it is done running. Now Drush has an interactive mode that I think will do this. However I can't seem to figure out how to get it to work.

I can modify either Drush or my Drupal module (that contains Drush commands) to do this. I just need to know what to do to accomplish this.

I am running Drush 4.4 against Drupal 6.22.

Any thoughts or ideas?


texts: Is Node a superclass of all content type?

texts:
I have been trying to understand drupal 7 internals. It seems to me that the concept of node is like a superclass in OO languages. All other content types are the derived classes of Node.

Please let me know if this wrong.
Thanks.
DB


texts: What is the mechanism behind class comments?

texts:
* @QueueWorker(
 *   id = "my_module_image_style",
 *   title = @Translation("Generate image styles"),
 *   cron = {"time" = 60}
 * )

And more specifically what is the effect of

 cron = {"time" = 60}


texts: How to check whether content entered by a user in a custom form is valid HTML?

texts:
I am trying to write a custom form in Drupal 6 which will check whether the content submitted by a user is valid HTML.

If the content is valid I need to generate a txt file with HTML markup based on the content without a DTD.


texts:
I am interested in having one view filter for two separate fields.

Example:
In a staff directory I am working on, users have both a "First Name" and "Nickname" field.

The output results show both, but in order to keep it user-friendly, I would like to have a "First Name" filter that sorts by both "First Name" and "Nickname" based on the input.

I found this question on here and it seems like it gives the proper direction of what I am looking for but I am not quite sure how to execute this solution.

3 separate fields,one views exposed filter

The suggestion based on the question above would be to expose both the "First Name" and "Nickname" filters but to hide the "Nickname" filter with CSS.

Following that, if a user typed a name such as "John" into the "First Name" filter and then clicked "Submit", before the query is executed, the input value "John" would also be automatically input into the CSS-hidden "Nickname" filter.

The concept makes sense to me but I am confused as to how to execute it.

Are there any detailed guides that could explain how I could make that happen?
With the PHP code given in the question linked above, would I have to modify a core file? Would it be in a template file? Would it have to be in a module file?

Or is there an even simpler solution to this that I am not thinking about?

Any help is appreciated.
Thank you!


texts: How to have a combined search view that shows both users and content on search terms?

texts:
I've looked at multiple modules (Faceted Search, Custom Search, an abandoned project named search_all) but I haven't been able to find anything that works with 7.x.

What I'm looking for is just a way to let users search on a search term and then get a page of results from all content, including other users in the system.

Any ideas?