texts: No wysiwyg filter present in text format

texts:
I keep reading you select the wysiwyg filter in configuration->content authoring-> text formats but it doesn't exist for me.

How can I get that filter to appear in list?

I have the wysiwyg module correctly installed and enabled.


texts: How to monitor several sites for updates from one central site?

texts:
I have several Drupal sites and wish to have one site list all of their "status" and available updates. So to start with I am trying to find how to get the available updates.

The central site has access to the databases of all of the others so I am hoping to pull info direct from there but I have no clue where to look.

Is there a table with such information that is auto updated on cron etc?


texts: When should field_attach_load be called manually?

texts:
I'm trying to use the module ClosedQuestion together with EntityCache.
When I enable EntityCache, then the fields on my CQ nodes becomes duplicated. I believe the cause is that both EntityCache, and ClosedQuestion, calls field_attach_load on the nodes.

There's a specific issue here, about this problem, but I'm looking for more general information, about what is the intended usage of field_attach_load? I've never seen a module doing it manually before, and don't think it's supposed to be used like this.


texts:
My View has a " Global: Custom text"- Field that contains Integers (1,3, ..). The field is overwritten by a php-Template.

I want to add this field to "Sort criteria", so the view can be sorted - but how can I do this? the custom field does not show under "Sort criteria", how do i make it sortable?


texts:
How to create a list of webform submissions for a particular webform. I have multiple Webforms on my site. I want to display list of Webform submissions for a particular webform only.
Tried to Use View module  but it shows all Webform submissions


texts: Is it possible to login to Drupal with a custom user field, instead of username/pass?

texts:
I have two websites - One of them is Drupal 7, and the other is a different site (Site #2). In Site #2, within the user tables, is a field called "customid". Each user on Site #2 has a unique, randomly generated 30 character alphanumeric string within their respective "customid" field.

I can pull the value of the "customid" field for the user on Site #2, and use it as an input value in a form post to the Drupal 7 site.

In the Drupal 7 site, I created a custom user field "customid" as well.

Is it possible to make a form post from Site #2 to Drupal 7 - with the "customid" value as an input, and if it matches the "customid" field in the Drupal user table, log them in, else - redirect to the registration page?

We're essentially bypassing the username/password to log them in - I'm trying to log them in via custom user field.

I searched everywhere, and just couldn't find anything where something like this had been discussed. Thanks anyone for your time and help!

UPDATE:
I've tried implementing W.M.'s solution below, however upon attempting to enable the module, I get the white screen of death. Nothing shows up in the logs for the error.

For my custom module, I have two files:
ra_login.module
ra_login.info

Info file:

name = RA Login
description = Check ID and Login if there is a match, else go to Registration Page.
core = 7.x

; Information added by Drupal.org packaging script on 2013-12-16
version = "7.x-1.0"
core = "7.x"
project = "ra_login"
datestamp = "1387203506"

Module File:

<?php

function ra_login_menu()
{
    $items['authenticate-by'] = array( // or any other custom path you choose
        'title' => 'Login by SSO',
        'access callback' => true, // no point in authenticating at this point in code execution
        'page callback' => 'ra_login_function',
        'type' => MENU_CALLBACK,
        );
    return $items;
}

function ra_login_function($CONTACTID)
{
    // post the data to /authenticate-by as json with a parameter / property named CONTACTID holding the CONTACTID
    $postData = file_get_contents('php://input');

    $Data = json_decode($postData);

    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'user')
        ->propertyCondition('uid', 1, '<>')
        // User number 1 should not be able to log in using this method
        ->fieldCondition('field_contactid', 'value', $Data->CONTACTID, '=')
        ->range(0,1);

    $result = $query->execute();

    if (isset($result['user'])) {
        $uid = array_keys($result['user'])[0];
        $account = user_load($uid);
        global $user;
        $user->uid = $uid;
        $user->name = $account->name;
        $user->timezone = $account->timezone;
        user_login_finalize(); // Log user in
        drupal_goto('/user'); // or any other path to redirect logged in users to
    } else {
        drupal_goto('/user/register');
    }

}

Again, for some reason when I try to enable the module, I get a white screen.
Thanks for anyone who can help!
UPDATE:
I turned on errors in php.ini - now instead of the white screen, it shows me the following error:

Parse error: syntax error, unexpected '[' in C:\inetpub\wwwroot\sites\all\modules\ra_login\ra_login.module on line 31

Line 31 is:

$uid = array_keys($result['user'])[0];

Any help is greatly appreciated!


texts: Using workflow with webform for moderation

texts:
I'm working with a Drupal7 site, it currently has both webforms and workflow modules. I need to move a webform from request to approve stages.

I defined the stages, & Created a trigger for the workflow. Asigned permissions and mapped workflow to content type.

I'm sending myself approval requests for testing, and once I get the email with the request link I open it but can't edit the workflow state ( It's shown as Workflow current state: none ) , no "change state" link or button... Is it possible to get these two modules working as I intended? If so, what am I missing?


texts: generate a coupon automatically after checkout

texts:
I have a gift store, customers buy a gift cards. I want to generate a gift code after checkout based on the giftcard they bought (I have gift cards from £25 to £200). they can also buy a gift (product) directly. so the cart might be a mixture of giftcard and products. how can I create a coupon after checkout? I will email them this code after successful checkout

there is no action for creating coupon automatically in rules.


texts: Is there a module for showing only posts in some defined date?

texts: I would like to make a calendar addon for my website, which would look something similiar to http://www.nikerigarun.lv/ this (scroll it a bit downwards, on the right side). The funcionality would be to show only posts from some selected date, is there such a module for that and if there is, could you please recommend me one?


texts: Setting up the ideal multiple repository Drupal Site version control with a DVCS

texts:
I have an upcoming project that will use Drupal, and I've been toying around with repository setup ideas in my head for a bit now and while I've come up with a wishlist, I don't know how to actually set up a source control repository this way. While I'm using Drupal for this, hopefully this setup could be extensible to other CMS systems.

Ideally, I'd be using Mercurial/Kiln since that's what my shop uses, but I'd rather have an ideal workflow than use that particular too.

Here are the features I think are important

Drupal core should be a working copy from their repository, so that I can update it easily
Site specific configuration will be exported from the Drupal DB to files using Features/Strongarm, so the repository should have a sub repository that controls all of the configuration that is not part of Drupal Core
Part of this project might involve writing custom modules. These should also have a separate repository or sub-repository so that they can be managed without interfering with site-specific configuration
I'd like to avoid storing code from Drupal Core in my own VCS, since it's already managed by the initial checkout used for item 1.

Is there some combination of ignore settings, submodules/subrepositories, or other configurations that can yield a setup like this? If not, what are my best alternatives? Or perhaps am I approaching the problem wrong, and there is some well-known workflow that solves these kinds of problems?


texts: How to get hook_form_FORM_ID_alter field value in hook_ENTITY_TYPE_presave

texts:
I am adding one field dynamically by using hook_form_FORM_ID_alter.

/**
 * Implement hook_form_FORM_ID_alter
 * @param $form
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 * @param $form_id
 */
function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    // Modification for the form with the given form ID goes here. For example, if
    // FORM_ID is "user_register_form" this code would run only on the user
    // registration form.

    $form['platforms'] = array(
        '#type' => 'textfield',
        '#title' => 'Add Platforms',
        '#required'=>True,
    );
}

"platform" field is added dynamically here, now I want this field value in hook_ENTITY_TYPE_presave.

/**
 * Implement hook_ENTITY_TYPE_presave
 *
 * @param \Drupal\node\NodeInterface $node
 */
function hook_ENTITY_TYPE_presave(\Drupal\node\NodeInterface $node){
    if($node->bundle()=='platform'){
        $field_platforms = $node->get('platforms')->getValue();// Here how to get platform field value.
   }
}

I am not getting any idea how do this any help very appriciate.


texts:
I am currently constructing a form using an Ajax handler. The problem is that since i used Ajax, the submitting part is run without returning any error message. It is only when I clear the cache that all the errors appear (and the form disappear).

function My_Modile_form($form, $form_state, $arg){
     //constructing the form with REQUIREDfields
  $form ['submit'] = array (
      '#type' => 'submit',
      '#ajax' => array (
          'callback' => 'mymodule_form_ajax_callback',
          'wrapper' => 'result-div'
      ),
      '#value' => t ( 'Lancer la simulation' ),
      '#weight' => 10000
  );
}

function My_Module_form_validate($form_id, $form) {

  $form_numbers = array (
      'field_one',
      'field_two'
  );
  foreach ( $form_numbers as $form_number ) {
    $numb = $form ['input'] [$form_number];
    if (! is_numeric ( $numb )) {
      form_set_error ( $form ['complete form'] [$form_number] ['#title'], 'ERROR !' );
    }
  }
}

function mymodule_form_ajax_callback($form, $form_state) {
  $form ['simul_message_retour'] += mymodule_form_submit ( $form, $form_state );
  return $form ['simul_message_retour'];
}

function mymodule_form_submit($form, $form_state) {
    // Submitting part
}

Has anyone met this issue before with Ajax forms ?

Thank you,

EDIT: I just found that  the hook_form_submit is called BEFORE the hook_form_validate


texts: Where in the database does fieldset and field instance info live?

texts:
Background: I'm writing a module that will hopefully make reverse-engineering specs for site audits easier. (If you're interested, you can see the Topograph module-in-progress on my Github account.)

Basically it's a bunch of byzantine views that use custom handlers to pull things like serialized data out of the DB to display stuff like nodetype settings to the admin user.

I'm having a lot of trouble finding certain things, though. Fieldset info is a major one, as well as settings like whether the field is required. I'm not finding it in the blob of data pulled from the {field_config_instance} table (though I might be overlooking it). Can someone point me to where this info can be retrieved per nodetype/field instance?


texts:
I have a view to show post teasers. Inside the view I go to 'translate view' and change the values for tags, date, etc. accordingly. Everything translates fine except the text for 'first' and 'last', which stay in the default language (Spanish) no matter if I switch to English (they stay as 'primera' and 'última'). Every other label works so I'm at a loss here.

Can someone point out if I'm doing something wrong? Maybe I should enable another module but I don't think so. Every other node, block, page and menu works fine in both languages. The problem is just with the mentioned labels.

I'd appreciate any pointers.


texts:
I use the following snippet in template.php to access user profile fields on comment.tpl.php. $persianName works fine when the user is administrator, and returns nothing for the anonymous users. Actually, when I use dsm($variables) in anonymous viewing, I see that all UIDs are set to 0.

function apblog_preprocess_comment(&$variables) {
  $user = $variables['user'];
  $user = user_load($user->uid);
  $persianName = field_get_items('user', $user, 'field_user_pname');
  if ($persianName) {
    $variables['persianName'] = $persianName[0]['safe_value'];
  }
  else {
    $variables['persianName'] ='';
  }

  // …
}


texts: if i have no right use the flag "Accepted",please hide it

texts:
when user have no permission use flag "Accepted",how to hide it instead of when clicking and tell them "you have no permission"?

I found a function on flag.module: function template_preprocess_flag(&$variables) ,

but it seems not a hook to reuse...


texts: Only create taxonomy terms on node approval?

texts: Right now nodes on my site are unpublished by default because I want to manually approve user submitted content. How can I make it so that user submitted taxonomy terms are not created until I manually approve the corresponding node?


texts:
I am using the following code to get the URL of the image associated to a user.

$user=\Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$picture=$user->get('user_picture')->entity->url();

If the user didn't upload a picture, this code doesn't return anything useful.

How can I get the URL for the default image?


texts: Why doesn't Page Title pull [node:title] in to all pages

texts:
In the Metatags section of each page, the [node:title] field is supposed to pull the data into the Page Title. This works for many articles on our site, but doesn't for and many seemingly random others that are formatted exactly the same.

There really doesn’t seem to be any rhyme or reason.


texts: How do I return an SQL query result as custom variable in a template?

texts: Is there any way to pass a SQL result with using hook in .theme file? My scenario is following: I have a paragraphs module's view in which I've need of all nodes from content type News to iterate and show by taxonomy term.


texts: ApacheSolr Search results with AJAX (D7)

texts:
I've been searching the web for ways to display my search results directly in a block after submitting the input form with AJAX.

Unfortunatly, i haven't found alot of good information on this subject. Can anyone here point me in the right direction? I'm using Drupal 7.

Thanks in advance! :)


texts: Image Styles Not Generating Thumbnails/Previews

texts:
I have File Browser installed on my website.  The module info can be found here:
https://www.drupal.org/project/file_browser

When I go to browse for pictures, there are no images. You can see what I see below:

Below, you can see "WHY" it is not loading.

It seems to think that the system should have generated thumbnails and it is trying to reference those thumbnails.  However, the files have not been created.

/sites/default/files/styles/file_entity_browser_thumbnail/public/md-slider-image/slide-corporate-3.jpg?itok=O25-iC4D

My next thought was that maybe the GD manipulation tool was not enabled and the system needed that to generate the thumbnails.  I checked using command line and that program is installed.

GD Support => enabled
GD headers Version => 2.2.4
GD library Version > => 2.2.4

After further review, I went ahead and discovered that the "image style" functionality of Drupal is what is supposed to be generating the images. So, I went and just tried to use the "normal" image style functionality by adding an image field to a node and attempting to apply a style in "display settings."  When I did this, it did not work.  So, it seems the issue lies with "Image styles."

The most obvious solution would seem to be that I do not have the permissions set correctly.

I went to /sites/default/files/ and the owner is www-data (apache) and the "octal" is 0777. I also made sure to apply these permissions "recursively" so it would copy down to any sub directories.  Nothing seemed to change after doing that.  I also am not getting any errors that I can find.

Does anyone have any suggestions on how to fix or where an error might be generated that could point me in the right direction?


texts:
I have a custom table in the Drupal DB, which I need to retrive and use on a few places on the site I'm creating. And I don't like to run soo much PHP in blocks, so I thought that I could get the table value I need, using PHP in template.php in the theme-dir and then just call the variable from a block, using PHP.

That didn't work.. Why and how should it be done?

template.php:

$sub_count = db_query("SELECT count FROM {sub_count}")->fetchField();

block:

<?php $sub_count; ?>


texts:
I'm using Umami profile and choose Spanish is default language. Almost of the interface has been translated into Spanish. But some places did not translate like user page.

I'm going to admin/config/regional/translate to check. But This text already translated, but UI still show English text.

I try debug to find the reason. I was break point at line 340 of line drupal/core/modules/views/src/Plugin/views/field/BulkForm.php and found that $action->label() return English string.

Because at line 116 $this->actionStorage->loadMultiple() return all actions. In this some actions return English string, some actions return Spanish string (example install module pathauto, this action return Spanish). All actions when install profile will using English text and module install after will be translate.

I don't know why. And How to can translate label of actions?


texts:
I am using the Charts module for displaying charts in my Drupal project.
When I took the chart API example module page, it's not displaying any. It throws me this error (in the console):

  Uncaught TypeError: $(...).highcharts is not a function

Any idea on how to resolve this issue? Or is there anything additional to do after installing the module?

I enabled all the sub-modules of the Chart module:

And I selected Highcharts as the Charting library option:

Notes:

I added the chart js file inside charts/modules/charts_api_example and referenced the charts_highcharts.js file in the charts_api_example.libraries.yml file.
I think the issue may be because jQuery must be loaded before Highcharts when checked the view source on the API examples page the jQuery is loaded at last after the Highcharts library. Not sure though that's the issue.


texts: Code for view, and module name in path besides node id

texts:
I am using this snip Stefan Lehmann gave me here to have a different image based on node, problem is it works fine with the id, but a couple of the nodes are views, and one is contact, how do I declare those?

<?php
$node = menu_get_object();
$menu_image = 'arrow_home.png';
if (!empty($node)) {
  $images = array(2 => 'arrow_home.png', 3 => 'arrow_formazione.png', 4 => 'arrow_workshop.png', 5 => 'arrow_raccontabito.png');
  $menu_image = isset($images[$node->nid]) ? $images[$node->nid] : $menu_image;
}
?>

<img src="/sites/all/themes/business/images/fz/<?php print $menu_image; ?>" />

This is the structure:

example.com/node/2 <<< snip ok
example.com/node/3 <<< snip ok
example.com/node/4 <<< snip ok
example.com/node/gallery <<< view name/path - what code do I need
example.com/node/contact <<< contact module - what code do I need

Thank you


texts:
With the Rules module, I collect a list of row (text value) from a view, then iterate the list (variable list_item) and add this action:

Create new entity of type xxxx, (variable entity_created);

I add a PHP action that extracts a substring from list_item, convert the substring in a Unix timestamp, and set a field "date" of entity_created.

The rule create only one entity, and not one entity for each item in list_item.

Does anybody know how to create one entity for each item in list_item?


texts: Using the Rules module, is it possible to access the fields of a referenced entity of an entity?

texts:
I've got this scheme:
entity person, bundle person, entity health, bundle health. Bundle health has field energy.

Bundle person has an entity reference of type health.

In Rules data selector, I want to access to person:health:energy. Is that possible?


texts: How to programatically convert nodes from draft to saved

texts:
Is there a way I can convert all my imported nodes into "saved " status instead of "Draft" programmatically? Can this be done in a hook and what would the code for doing this be? If it can be done with Rules how exactly would this rule be created?  This has to be something that is done without any user interaction, so Views Bulk operations is not the answer.

I am using workflow module, and it has two states, the first one is draft, the second one is "Done"

Thanks,


texts: How to add content programmatically to a field collection that it's in an entity (build with eck)

texts:
I'm trying to save information into an entity build with eck, this entity has a field_collection with more fields.

I have take a look around internet, and I only find examples that works with node entity and user entity, but when I try to use the same code with my entity, it doesn't works.

This is my code:

<?php
$idform = 1;
$entity = entity_load('formulario',array($idform));
//dpm($entity);

$newfield_collection = entity_create('field_collection_item', array('field_name' => 'field_form_field'));
$newfield_collection->setHostEntity('formulario',$entity);
$newfield_collection->field_name[LANGUAGE_NONE][0]='name3';
$newfield_collection->field_form_id[LANGUAGE_NONE]['0']['value']=3;
$newfield_collection->field_sff_name[LANGUAGE_NONE]['0']['value'] = 'value name 3';
$newfield_collection->field_field_id[LANGUAGE_NONE]['0']['value'] = '13434';
$newfield_collection->field_field_type[LANGUAGE_NONE]['0']['value'] = 'value type 3';
$newfield_collection->save(FALSE);

?>

And this is my error message:

  EntityMalformedException: Missing bundle property on entity of type
  formulario. in entity_extract_ids() (line 7633 of
  /home/oscar/webapps/www/drupal/drupal7/includes/common.inc).

I have debuging the code and seems that the problem is with setHostEntity But I don't know if it's because I build the entity with eck module.

Thanks

Oskar


texts: How can I define a selection rule to use for Panels variants in code?

texts:
I have some custom PHP code that I would like to use as a selection rule for about 30 different variants.  In the future, I may need to update this code, so rather than add the code 30 times, once for each variant, I would rather add it in code via a custom module so that I can more easily maintain it.

Is there a hook, etc. for adding Panels selection rules?


texts: SelectQuery::fields and Drupal's naming conventions - how to make it all match?

texts:
Convention for database column names is underscore_notation. Convention for class properties is camelCaseNotation. But when I'm using SelectQuery::fields('t') and then fetchObject(), fetched object's properties are in underscore_notation.

I know I can use code like:

foreach($fields as $field)
    $query->addField($table_name, $field, to_camel_case($field));

That's a solution when I know fields I'm supposed to get. What if I don't? If all I want is good old SELECT * FROM {table}? Is there a simple way to fetch object compatible with Drupal's naming convention?

I know that formally, as written, convention does not apply to objects generated dynamically and returned from PDO. I want to avoid mixed namings none the less. It feels wrong to make user input $object->camelCase and give him $output->underscored_answer back. Bad as in causing errors and confusion.


texts: May I use Bootstrap-CDN on Subtheme for production site?

texts:
Follow up of my other question with less files ;-)

As I don't need de less files on production site, could I then switch to BootstrapCDN for js files? Or would it overrule style.css too?

Thx for your support guys!!


texts: How to get all node entities tagged with a specific term?

texts: For a given taxonomy term in D8, is there any API function/method that returns all node entities that reference it?


texts: Where should I add the unique identifier cookie code?

texts: I want to add a unique identifier in a cookie when the user (anonymous or logged) visits the website. Where should I call this code. I tried calling the code in hook_init but that doesn't work on cached pages. Any help would be greatly appreciated. Thanks.


texts: How to dive deeper into the hierarchy using views

texts:
I am really bad at explaining things so I will just use images to best illustrate what I am trying to do.

To summarize, I am learning Drupal 8 and I thought my pet project would be to create a grocery list application. In simple terms, you add ingredients with there cost, quantity, and store, ect. From there, you combine the ingredients to create a meal. Finally, you select all the meals you want to buy for the week, and it will generate a grocery list with all the ingredients, with cost and quantity.

The issue i'm running into with views is that I can only go 1 level deep down the hierarchy chain. Let me demonstrate with pictures.

Here is my grocery list:

Next, I can dive into 1 of the meals, ex: Salad.

From there, I can dive even deeper and view the cost or quanity of a ingredient, ex: cheese.

Now what I am trying to achieve with my view is getting the cost or quantity (either is preferable at this point), to display. However, I can only go down to meal ingredients and it stops there.

I am already using a relationship to display the meal_ingredients, but there is no option or relationship to reference ingredients. If I change the filter to CT = meal or ingredient, the cost value is displayed, but on other lines.

How do I dive 1 step further and get my table to display the cost / quanity without changing the filter? Can views go only 1 level deep?


texts:
I have a hook_menu:

$items['node/%/tokens/%api_token'] = array(
    'title' => 'View an API Call',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('api_token_edit', 1, 3),
    'access arguments' => array('edit own profile'),
    'type' => MENU_LOCAL_TASK,
);

When visiting url: node/1229/tokens/1, it works as expected.

When visiting the friendly alias: mypage/tokens/1, it gives me a 404.

Why is this? I thought hook_menu used the internal arguments?


texts: How to print taxonomy id of the current taxonomy term

texts: I have custom taxonomy term pages which I'm using to override forum pages and I want to emulate advanced forum node/add/forum/tid button so I have to get tid but don't know how, I can only find examples on how to print tid of the current node.


texts: Views: greater than a date expose filter

texts:
How can I only show the nodes that are greater or equal to the selected date from expose filter on views?

I'd like to have a dropdown/expose filter which allows me to select the nodes that their post dates are greater or equal to (past week, past month, past six month)


texts: Geshi does not detect libraries on Drupal 7

texts:
I have installed the Geshi Filter and Field modules, but Drupal does not detect the GeShi Libraries.

I got the Geshi Libraries from sourceforge. To be sure, I put it in:
/sites/all/libraries/ ,  /sites/all/modules/libraries/ and /sites/all/modules/geshifilter/
I am using 7.x-1.x-dev

Yet, it cannot find the libraries. How can I get it to work? Please do not suggest syntaxhighlighter. I have tried it and I would prefer a server side solution.

From the Status Report


texts: Get User's other field instead of Username,in the View?

texts:
I have one content type called "Test".In that content type i have Entity Reference field Referencing to Users called "field_authors"[can have more than one user] . I have created a view of this type.Here while showing 'field_authors' , it is showing User username, but Instead of username ,i want to show other field value of the User.
How can i achieve this? Can anybody please help me?
Drupal version:8.2.0
Details:
Currently View table column Output is: CC111,CC112,CC113 [which are the usernames of different users in the site]
I need user's other fields like "First name" instead of username in above Case.
I tried adding Relationship '(author) field_authors' and Added field in view Table 'field_authors'[selected use relationship] , But still output is CC111,CC112,CC113 etc instead of comma separated names.
I Got partial output after adding Relationship to that field,but since it is a multi field,output is coming in 3 different rows.Instead of it I need output in one row comma separated values.[Ex:Name1,Name2,Name3]


texts:
I was using the tagging module as my tagging widget until its status changed to Maintenance status: Unsupported. Now I'm looking for a replacement. After searching drupal.org I figured out there is not stable tagging widget module for D7:

nice_tags only D6
tag_editor only D6
active_tags dev version and not works as expected
community_tags tagging content in view mode not in add/edit
form

Is there any other tagging widget which I overlooked?


texts: Better code to output a pdf downloaded by the browser

texts:
In a submit function of a custom form, I would like to output a pdf which can be downloaded by the user/browser when clicking on 'Get PDF'.
The following code is doing the job only once, because after clicking on the 'Get PDF' button, all the buttons of the form does not work anymore. Clicking on any of them doesn't produce any effect.
Any Idea?
  static public function submitPdf(array &$form, FormStateInterface $form_state) {
    if ($pdf_content = my_function_to_output_a_pdf_as_string()) {
      $response = new Response($pdf_content);
      $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'my_pdf.pdf');
      $response->headers->set('Content-type', "application/pdf");
      $response->headers->set('Content-Disposition', $disposition);
      //$response->headers->set('Content-Transfer-Encoding', 'binary');
      $response->headers->set('Content-length', strlen($pdf_content));
      $form_state->setResponse($response);
      //Thanks to kiamlaluno, it is working slighty better if I remove the following line (setRebuild())
      //$form_state->setRebuild(TRUE);
    }
  }

Edit to add in order to provide more context: The form is made of +/- 30 numeric fields and the user can play with them to produce some calculated results. If he wants, he can click at any time on the "get pdf" button to generate a pdf which will contains all his inputs and the calculated result. In other words, he can fill the form->get the pdf->continue to fill->get another pdf-> etc


texts: How to automatically deliver Drupal 7's static contents using CDNs?

texts: I use "Rackspace Cloud Files" service as my CDN (Content Delivery Network). This service provides nice API for many CDN-related automation. Please, help me to integrate Drupal with Rackspace Cloud Files. I even don't want to copy static contents to CDN manually.


texts: I have a form in pager, so user can enter page he want's to view. But I can't figure out how to go to that page number in form submit.


texts: The update manager module makes admin pages very slow, what might be the causes and how could I solve this problem?

texts: All of a sudden, my admin navigation started being slow, very slow. It takes between one and two minutes to load a single page (with very little content). When I unable the update manager module, the problem vanishes. Any hint on what causes this malfunction and how I could solve it? Thanks!


texts:
We are running a Drupal 8 site with 400 or so pages of content.

We have a number of "resource pages" were views generate links to content by topic area. Here is an example of one of those pages.

In general everything is working as intended, however, sporadically we have an issue with clean URLs and the link to content in those views. Specifically, index.php is added to the link presented only to anonymous users. For example, website/mypage becomes website/index.php/mypage, or even website/index.php/index.php/mypage.

This problem never occurs for logged in users, only anonymous users. It is also not consistent. It may happen to 2-3 of the links in a single view, or several across the views on the same page but generally will not affect the entire site or page. It may not happen for weeks and then 4-5 times in 24 hours. In the last few days it appears to be happening every few hours.

It appears to mostly only happen on resource pages (they are a content type) like the one I linked above. We have also some times observed it occurring on other menu links. These links usually still work however...

We have been unable to find a reason for it. Clearing the site cache a few times does fix the issue but it is somewhat unacceptable that this happens regularly.

The views on those specific pages do make use of relationships and aggregation  to generate their content. Several also use re-write rules to generate custom link text. The issue appears to affect both types of views on those pages.

Can anyone suggest what the cause of such an issue could be or give any ideas as to how to stop it occurring?


texts: When to add an extra "helper" table rather than running complex query

texts:
I'm trying to build a "notification" feature into my site similar to Facebook:

I would show a little graphic with a number indicating the number of new comments to nodes a user created or commented on.

The query will probably look like this, assuming uid=1 (haven't tested yet):

SELECT count(node.nid) as new_comments
FROM {node} node
INNER JOIN {node_comment_statistics} ncs ON node.nid = ncs.nid
INNER JOIN {history} h ON h.nid = node.nid
WHERE ( (h.uid = 1) AND (h.timestamp < ncs.last_comment_timestamp)
AND ((node.uid = 1) OR (0 < (SELECT COUNT(*) FROM comment c WHERE c.uid = 1 AND c.nid = node.nid)) )))

This query would run with every page request for all logged in users which could impact performance.
I could create a "helper" table where I keep a "new_comments" counter for each uid. For every comment added or updated I would then check which users need their "new_comments" counter incremented.

My question:

Is there a rule of thumb when to use such a "helper" table instead of running complex queries. Or do I need to create say a million records in Devel and test the performance of above query under full load?


texts: How to programmatically remove a field from a node?

texts:
How does one remove a field from a node programmatically? I have a migration in hook_update_N that moves the contents from a a field into a custom table. After that migration, I want to remove the field in that same function.

Are there any field API's that cater removing fields?

Edit, Solution: Because the answers lack actual code, here is what I did to move fields from the $users into my own records and subsequently remove the field from the database;

function my_module_update_7005(&$sandbox) {
  $slice = 100;
  //Fetch users from database;
  if (!isset($sandbox['progress'])) {
    $sandbox['progress'] = 0;
    $sandbox['current_uid'] = 0;
    // We'll -1 to disregard the uid 0...
    $sandbox['max'] = db_query('SELECT COUNT(DISTINCT uid) FROM {users}')->fetchField() - 1;
  }
  if (empty($users)) {
    $sandbox["current_uid"] += $slice;
  }
  $users = db_select('users', 'u')
    ->fields('u', array('uid', 'name'))
    ->condition('uid', $sandbox['current_uid'], '>')
    ->range(0, $slice)
    ->orderBy('uid', 'ASC')
    ->execute();
  //Loop trough users;
  foreach ($users as $user) {
    $foo = new Foo();
    // Warning: drupal's fields return mixed values; e.g. NULL versus an int.
    $foo->debits = (int) $user->user()->field_credits["und"][0]["value"];
    $foo->save();

    $sandbox['progress']++;
    $sandbox['current_uid'] = $user->uid;
  }

  $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);

  // Remove the field.
  field_delete_field("field_credits"); //note that the name for Foo is field_foo
  field_purge_batch($sandbox['max']+1);//Drupal seems to have an offbyone problem.
}


texts: Filtering the terms of a specific vocabulary

texts: How do I get all the taxonomy terms of a specific vocabulary? If a page has terms coming from 2 vocabularies (e.g. "Software" and "Hardware"), how do I display the terms coming only from the vocabulary "Software," and not from "Hardware"?


texts: List members visable in any organic group

texts:
I am working on a Drupal 7 & OG & Views site, and I am trying to write a view that shows what users another user can 'see' through any group he's a member of.

ie:
User A - Member of Group A, Group AB, Group AC
User B - Member of Group B, Group AB
User C - Member of Group C, Group AC

Output of View for ..
User A - User A, B, C
User B - User A, B
User C - User A, C

Thanks..


texts: How do I add a template suggestion for a node based on the current view?

texts:
I have a view that lists a bunch of nodes of a certain content type. I want to style this list of nodes in a way that I can't do easily with the standard node.tpl.php that they're being rendered with. I'm trying to override my themename_preprocess_node function to add a template suggestion depending on what view the nodes were called from. I tried this:

<?php
  function themename_preprocess_node(&$variables)
  {
    // Add theming based on view name. If the view is named
    // 'featurefront' one of the template suggestions will be
    // 'node-view--featurefront.tpl.php'.
    if (isset($variables['view']))
    {
       $variables['theme_hook_suggestions'][] = 'node_view__'.
            str_replace('_', '--', $variables['view']->name);
    }
  }
?>

but it doesn't work because $variables['view'] isn't ever set anywhere. Basically my question comes down to this:

What variable can theme_preprocess_node use that will tell it the name of the current view or whether it was called from a view at all?


texts: Counting the number of rows returned from db_query() with the "SELECT" statement

texts:
How do I find the total number of rows returned in db_query() for the SELECT statement, or the equivalent of mysql_num_rows()?

I'm using MySQL.


texts:
I want to automatically run a PHP script every 3 hours or so. The script is pretty heavy. It pulls XML data from another website then encodes it into a JSON file to be imported by feeds.  The resulting JSON file is around 250 KB.  I'm trying to set it up with the Elysia CRON module but it keeps saying that I have invalid lines.

3 * * * * php https://dev-smwdb.pantheonsite.io/sites/all/gen-job-bank/gen-job-bank.php

What do I need to change? Is this even possible with Elysia? Is there a better solution?

Drupal 7 site built on the Pantheon platform.  No backend access to CRON and PHP execution time limited to 120.

Thanks.


texts: Imce file/image browser not showing any buttons tab

texts:
I am using imce as image browser. I installed imce for filefield module to select files from imce repository and i have given all permissions as in below image

When it will go to imce repository those buttons are not showing, see the below image

I followed this link but that is not working for me.
Please help me regarding this.


texts: how to get the bid ( id from multi-instances of block )?

texts:
is it possible to get and render the bid from a plugin block class build method ?

class HalPublicationBlock extends BlockBase implements BlockPluginInterface
{

  /**
   * {@inheritdoc}
   */
  public function build()
  {
        //do contain id but not bid
        $config = $this->getConfiguration();
        //$bid=$this->get->?

EDIT : i'd like to pass the bid (or values that will be used by drupal as block css indentifier) to JS object and or twig templates , along with the same bloc instance configuration values


texts: How do I work with a Detail page in a master/detail scenario using Panels?

texts:
This has me stumped.  I'm using panels and have created a view for my 10 classic cars.  This works perfectly, but in your view, you click on the title and in my case, the image/car also, and that takes you to the main/rest/full content.  I am stuck here,

I need to create another panel to display this "detail page", but I will want this same page/panel called when someone clicks on any of the ten cars. Just the new car and new related datail appearing

I don't want to create a panel for each car and I know I don't have to but I can't figure out how I would accomplish this using panels.

So in short, I have a view, that I have placed in a panel, and it displays a small image of my 10 cars, and the corresponding title and teaser text for each.  When user clicks on the title, it should open the detail page which is a new panel page I have created displaying the info/data related to the car that was clicked.

I am sure this is going to be one of those "duh" moments, because I think I know it is pretty basic functionality, but I just can't pull it together.


texts:
Hide the term id on autocomplete widget

How can I hide the term id on autocomplete widget ?

I use drupal 8.


texts:
Is there an api to use to get data from https://www.drupal.org/security?
I'm looking to get for example all vulnerabilities for older versions of a module.


texts: Hook_form_alter in Views header PHP code

texts:
I have a content type called 'Checklist' which I bring forward using Views, in it's node-edit form.

I wrote PHP code within the header in order to do this, here it is:

<?php

    $view = views_get_current_view();
    $arg0 = $view->args[0];

    $nodeToLoad = $view->result[0]->nid; //I get the node to load from Fields within my view
    module_load_include('inc', 'node', 'node.pages');

    $node = node_load($nodeToLoad);
    dsm($nodeToLoad);
    $edit_page = drupal_get_form('page_node_form', $node);

    $edit_page['additional_settings']['#access'] = FALSE;
    $edit_page['buttons']['submit']['#submit'][] = 'redirect_submit';
    print drupal_render($edit_page );

    function redirect_submit($form, &$form_state){
        $form_state['redirect'] = 'www.google.com';
    }
?>

I'd like to remove the 'Delete' button of this form(which normally deletes the content).
I have read that this is easily done with hook_form_alter() but my code resides within the header of a View and I'd like to keep it that way.

Is there a way to do this?


texts: Prevent a user from viewing another user's profile based on a field value

texts:
I'm a Drupal veteran, but this one has me stumped . . .

I have two Profile2 profiles, one for a company and one for a job seeker. In the job seeker profile, there is an entity reference field where they add companies they don't want to view their profile. The way companies finds people is by searching via Search API. Another way, would be by browsing. I need to block both ways. Basically, the job seeker should be invisible to the companies that they've blocked.

I have Panels, Panelizer, Rules, and Views all at my disposal and know how to use them, just not in this case. Or am I better going with my own custom module?

I saw this answer Hide Profile2 fields depending on it's value when viewing user profile and that's only for specific fields, I want to block the whole profile.

This question is along the same lines of mine, but I don't see a complete answer -How to filter a view based for the current user based the value of custom fields in his profile and fields in the list of items viewed


texts: How do I get link the files in libraries.yml with absolute url path

texts:
In my libraries.yml files the css files are linked with the relative url paths.

  Eg : /css/mycss.html

So when in the page source the linked url shows as relative. How do I link those files with absolute URL path?


texts: Drupal Feeds XPath Parser html parsing form IMDB

texts:
i have a movie site , i need import movie data from IMDB,
for doing this i installed Feeds and Feeds XPath Parser for scrapping.
i created a content type for movie wiht some field (poster,actors,...)

after that i create a feeds importer called "Movie importer" .
i set Parser to "XPath HTML parser".

in the mapping i added xpathparser:0 ,xpathparser:1 and... for field i created for Movie content type.

in the XPath HTML parser settings i added Xpath like this

context: //div[@id='overview-top']
title:  /h1/span[1]
poster:  /div/a/img
Genre:  /div[1]/a/span
Story:  /p[2]
stars:  /div[3]/a/span
movie rate:  /div[2]/div[3]/strong/span

It's not  working , and i don't know why.

one more thing i am newbie with XPath :(

Here Sample IMDB Page :
http://www.imdb.com/title/tt0773262/


texts: How can I print usernames in order using entity_load function?

texts:
I'm using drupal 7.28, and I have fetched user id using entity_load('user'), so I need descending sorting on usernames using this way of logic, let me know if anyone has an idea.Here is my code that I have written in my file.

$users = entity_load('user',$sort);
$usersIds = array_keys($users);
foreach($usersIds as $usrId)
{
   $user = user_load($usrId);
   $user_load_name = array($user->name);
   echo "<pre>";
   print_r($user_load_name);
}


texts: How to load a contributed module load before a custom module?

texts:
I have a custom module which is having dependency on contributed module.

How can i make sure that contributed module will be loaded before custom module ?


texts:
How can I pass data to hook_entity_insert() given that the arguments it takes are fixed?

I'm writing to the database during entity save, and need to be able to pass some data in this hook.


texts:
We have a Question and Answer setup on Drupal. Question is a node. The answer is a comment.

What we are trying to do is to order Questions by either the latest asked question or by the latest commented question.

So when a new comment it posted, that questions moves on top. I can do it for Question or comments. But can't combine the two together.

Is there any way to achieve this?


texts: use different layouts for different pages

texts:
I developed the layout of the first page in page.tpl.php.
Here I've created some regions, to put the blocks.
The problem is that these blocks reflect my "content type",
and it has a link that when i do to click, don't happens the linking.

I would like to link to a page with a different layout but I do not know where to set the second layout and how to redirect the link to this page.
thank you!

EDIT

the layout of the content type is level node (node.tpl.php), while the layout of the first page I set it at page (page.tpl.php). Going on the first page, I find a link within the block that should bring to the page of the node, but does nothing ...

As you can see, the title is my link to the node:

EDIT

in the layout of my first page I removed the "content", this may be the error?


texts: Features - Will I lose work if I decide to remove a feature from my dev site

texts:
I have a feature on my site that covers several content types and views.  I want to change the configuration of my feature, but I am afraid that I will lose the work that I have done.  I recently learned that, when you remove a feature, it reverts that database back to the state it was in before the feature was added (for the configurations that the feature covers.)  Does this happen to the configurations on a site that a feature has be created to include, or configurations on a site that a feature has been used to add?  In other words, will removing a feature that I created on my development site erase all of the configurations that I just changed (which are included in that feature?)

Please note that this post is referring to a Development site (where features are created) and not a live site (where features are employed.)


texts: Getting taxonomy terms selected in node as objects not index

texts:
I have a custom module in place to get details of a node after the node has been submitted. I am trying to collect all the taxonomy terms associated with that node. The taxonomy terms are selected by multiple check boxes on the node creation page.

$items = $form['field_content_type_list']['und']['#value'];

and then go through them in a for loop:

foreach ($items as $item)

The problem is that $item is the index in the taxonomy list rather than the name of the object itself as a string.

Is there a way of getting the string value rather than the index of the term?

Thanks


texts: How to retain a form's checkbox values while using a pager

texts:
I am generating a checklist form after a database query. In the database query I am using ->extend('PagerDefault')->limit(50), and when I render the form, I use .theme('pager').

But after selecting certain items (checkboxes) on page 1 and then when I navigate to page 2 and make some selections, and then when I navigate back to page 1, my selections on page 2 as well as page 1 that I had previously made are lost.

Please suggest any means to retain the checklist selections.


texts: Imagecache preset is missing in field configuration

texts:
I have all the modules that could have to do with imagecache enabled.
It's the user: picture field that I want to use an imagecache preset on. Normally if you want to configure that field in views, there should be a drop-down list at the very bottom of the configuration form right under the 'link to user's its profile'-checkbox.

I remember I had it there but now it's gone and I can't find out why.


texts: hook_form_alter() only firing after cache clear

texts:
I have a custom module that I'm using to add a Java applet to some of my admin forms. The applet is necessary to get details about the product being entered.

I'm noticing that after 15 minutes (or more) of site inactivity, my hook stops firing. If I clear the cache, the hook begins firing once again. However, this only seems to last 15 minutes or so.

Is it possible there is some admin form caching happening?

Possibly salient details:

I'm using Seven as the admin theme
I'm using D7 with Commerce Kickstart install profile (commerce_kickstart-7.x-1.8)


texts: Configuring Aegir to Set Custom File Paths

texts:
What is the best way to modify the file paths for a site deployed using Aegir?

Aegir installs sites with the file paths pointing in this format:

sites/<sitename>/files

(This path being relative to the site's platform)

What is the best way to change it to a NAS mount, mounted at, say, /var/nasmount ? For e.g., for a site called firstsite.com, the file paths would be:

/var/nasmount/firstsite.com/files
/var/nasmount/firstsite.com/files/tmp

and so on, along with the the corresponding entries in the site's apache conf file.

These lines appear in /var/aegir/.drush/provision/platform/provision_drupal_settings.tpl.php, but I am reluctant to change here as this is from 'core' Aegir (if you will):

  $conf['file_directory_path'] = 'sites/<?php print $this->uri ?>/files';
  $conf['file_directory_temp'] = 'sites/<?php print $this->uri ?>/files/tmp';

Should this be done in:

provision_drupal_settings.tpl.php file above?
Somewhere else?

Ideally, this change would be done once so all sites deployed via Aegir have this in place, and these changes survive the re-verify process of a site and/or platform.

Thanks!


texts:
I built a Drupal 7 site using the Views module and I am using the "comment count" field.

If I choose the format plural checkbox, with a comment, it will output "1 comment", and when there are zero comments, 2 or more comments, it will output the number of comments followed by comments. If I want to output "no comments yet" when the comment count is 0, I can use the "No result  behavior (Count the number 0 as empty)" option.

The problem is that the format plural option is not working together with the "No result  behavior" option. When I use both of them, I get "0 comments" instead of "no comments yet."

How can I achieve my goal?


texts: Configuring Drupal for Upstream Deployment

texts:
I'm trying to help a co-worker configure a Drupal site so that we can deploy the same site upstream without making database changes. We're having trouble with file paths. Here's what I have:

A Nginx webroot pointing to the root of my Drupal 7 (in this case) install (/opt/frameworks/drupal-7).
The content for this site is in /opt/www/my-site.
A symlink exists in /opt/frameworks/drupal-7/sites: dev-my-site -> /opt/www/dev-my-site

Because of some sharing that's going on, there are multiple versions of my-site on the box, so they have to have different symlink names. Right now, the "file system path" is set to sites/dev-my-site/files which breaks when moved upstream.

We're both inexperienced with Drupal and trying to help out a client. Upstream we get this:

Fatal error: require_once() [function.require]: Failed opening required '/opt/frameworks/drupal-7.15/sites/www.productionurl.com/modules/entity/includes/entity.inc' (include_path='.:/usr/share/php:/usr/share/pear') in /opt/frameworks/drupal-7.15/includes/bootstrap.inc on line 3084

At each point in the deployment process (dev, staging, production), the path will be slightly different. For example, .../sites/dev.myclient.com/modules/..., .../sites/stg.myclient.com/modules/... and .../sites/myclient.com/modules/.... When I deploy, what do I need to change to ensure that this works?

In Drupal 6, I was able to set the file_directory_path variable in settings.php, but that doesn't seem to be an option in Drupal 7. What's the alternative? Is there one?


texts: Placing content in different regions using a controller

texts:
I've defined a route to a custom controller, which returns a render array to define its content. By default, this content gets rendered entirely inside the main content region of the page: what I want is to have different parts of it rendered to different regions.

I've tried specifying the region (e.g. '#region' => 'content_intro') in the relevant sub-arrays for different elements, but they are still output to my main content region.

I've also then tried adding the following to the base definition of the returned render array:

$content = array(
  '#type' => 'page',
);

This does then allow me to successfully specify the region for placing individual elements. However, other standard elements placed in page regions - specifically, a navigation menu block - are then not output.

How would I best go about having my controller add its content to regions, while still retaining elements placed by other systems?


texts: How to use the D3.JS library for data visualization?

texts:
What are the available options for using the D3.js library in Drupal for creating data visualizations?

D3.js (Data-Driven Documents) appears to be a charting engine with an ever growing popularity. So I wonder how to somehow use D3.JS as a charting engine.


texts: How to add placeholder to all Drupal 7 text forms in node page?

texts:
I'm trying to add the placeholders from field description to all Drupal 7 text forms only in node page using Drupal API

I've created a module that overrides hook_form_alter

  <?php
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
    if (isset($form['#node_edit_form']) && $form['#node_edit_form'] == TRUE) {
        foreach ($form as $key => $value) {
            if ($value == "textfield") {
            $form['type'][$value]['#attributes']['placeholder'] = $form['#description'];
            unset($form['#description']);
            }
        }
    }
}

?>

How to do it using Drupal Api without using JavaScript?


texts:
I've got a form, which when I use normally works perfectly fine, but when I load the form in phpunit I get the following error :

Drupal\digest\tests\DigestSubscriptionFormTest::testFormDisplay
Exception: Warning: array_flip(): Can only flip STRING and INTEGER values!
Drupal\Core\Entity\EntityStorageBase->loadMultiple()() (Line: 261)

Within buildForm I have something like this :
    $digest_storage = $this->entityTypeManager->getStorage('digest');
    $digests = $digest_storage->loadMultiple();
    $subscription_storage = $this->entityTypeManager->getStorage('subscription');

    /** @var \Drupal\digest\Entity\DigestInterface $digest */
    foreach ($digests as $digest) {

      $query = $subscription_storage->getQuery();
      // There should never be more than one ID returned.
      $subscription_id = $query->condition('digest', $digest->id())
        ->condition('uid', $this->currentUser->id())
        ->execute();

      /** @var \Drupal\digest\Entity\SubscriptionInterface $subscription_entity */
      $subscription_entity = $subscription_storage->load(current($subscription_id));
      $entity_exists = isset($subscription_entity);

Now when I am using this on my own it works just fine. No errors or warnings at all.
As soon as I get the page from phpunit I get the above error. Here's the test
  public function testFormDisplay() {

    $this->drupalLogin($this->adminUser);

    // Create some basic digests to view.
    $digest_storage = \Drupal::entityTypeManager()->getStorage('digest');
    $digest_storage->create([
      'id' => 'viewOne',
      'label' => 'View One',
      'enabled' => TRUE,
      'title' => 'Custom Title',
      'description' => 'Custom description',
      'send_at' => 'Monday',
    ])->save();
    $digest_storage->create([
      'id' => 'viewTwo',
      'label' => 'View Two',
      'enabled' => FALSE,
      'title' => 'Ghost',
      'description' => 'I\'m invisible',
      'send_at' => 'Friday',
    ])->save();

    // Load the subscription form.
    $this->drupalGet(Url::fromRoute('digest.digest_subscriptions'));

Adding the drupalGet line makes the test fail. If I remove the creation of the entities it works.
I'm not only wondering how to fix this but also why? This is a functional test so it should have a full site meaning I should be able to use the entityTypeManager as normal correct? Mocking is only needed for unit and some kernel tests right?


texts: Adding Content to the top of a form Page

texts:
I just want to add an easily editable block of content to the top of a Form page in Drupal 8.

This can either be adding text to the form or adding the form to a content item, I don't mind.

What's the most straight forward way of doing this?


texts: Auto node redirct depending on a cck field's content

texts: When a visitor goes node/123, I need them to be redirected to the url that is specified in that node's cck field.  I know there are plenty of modules that do redirects, but I need this specific type of automation.  What would be the best way to go abut this?


texts: Get the number of followers and following in user relationship

texts:
I have created a relationship Followers which can be reciprocated using the user relationship module. Now user A's relationship is something like:
Followers(Them to you):  User B, User C, User D
Followers(You to them): User D

Now i want to create a view which only shows the number of followers and following:
Follower: 3
Following: 1

I went about to create the view (Views 3, Drupal7) but was not able to do. Didnt get any filters or relationships regarding this. Also, tried using the Views Cal but am not clear. Would appreciate any help.

Thanks

Edit:

Apologies for not being clear.

I created a view of type Users. Then i added a relationship (this is the part where i am not sure if i am correct or not). I tried with all the available relationships pertaining to this such as User relationships:

 User relationships: Requestee user
 User relationships: Requestee user is current user
 User relationships: Requester user
 User relationships: Requester user is current user
 User relationships: RTID

(i tried individually all of them and various combinations of them as well)

Then under Others i clicked yes for Use Aggregates and when asked for the grouping function ("Group type"), i selected "Count and unchecked the label in the configure field screen, so that it only shows the number.

I also added a filter that the user is logged in. However, it just shows me the number of relationships of different users who have requested the current one.

Edit 2:

Found this thread: http://drupal.org/node/809476. However its for Drupal 6..., am trying to implement it for 7. lets see...if you have any pointers i would be grateful...will keep you posted

Edit 3:

Based on the above thread i wrote the following code into a custom block.

<?php
global $user;
$user_id = $user->uid;
$params = array("requestee_id" => $user_id, 'rtid' => 3);
$count = user_relationships_load($params, array("count" => TRUE));
echo $user_id;
echo $count;
?>

I just printed out the user id to check if correct user or not and it prints the correct user. However, count prints 0. Why is that?

Edit 4:

I think i am on the right way using http://drupal.org/node/203396. However there are some fixes there. The correct code is:

<?php
global $user;
$requests = user_relationships_load($param = array("approved" => 1, "user" => $user->uid), $options = array(), $reset = FALSE);
$requestcount = count($requests);
echo  $requestcount;
?>

This displays the total number of approved relationships. Now i want only the followers type relationship number. Looking into that. If anyone has any suggestions would appreciate them. Will keep you all posted

Edit5:

And now i am stuck. Whatever i try to do i am only getting the total number of relationships. I just want the number of followers(them to you) in one block and then using that, i hope, i will be able to get number of following(you to them). Would appreciate any help.

Thanks


texts: Best way to update/upgrade things in the drupal database

texts:
I know this is a broad topic, but maybe there is a good way/module doing this. I want to make "automated" updates to a drupal installation. This includes updates of nearly everthing (contenttypes, user-permissions, content itself, views, module-settings).

I would love to have the "update-information" outside the db (e.g. php-code). I could imagine doing that via an own update_module that implements MYUPDATEMODULE_update_xxx() functions for every update. But I fear coding complicated updates (views, large contentypes) "by hand".

I've never used the Features module and don't know if this really fits my needs. Are there any other modules or workflows for something like that? Perfect would be something that lets me trigger the update via the console (e.g. using drush).


texts: How to hit an endpoint (menu route) with the session intact

texts:
I'm trying to hit an endpoint which shows different data when logged in/out. I am trying to write a unit test, but can't seem to figure out how to hit the end point with user context. How can I do this?

Here is my code so far:

/**
* Tests to make sure logged out users cant access file ajax.
*/
 public function testAccessDeniedLoggedOut() {
 $response = file_get_contents($this->fileAjaxUrl);
 $this->assertTrue(strpos($response, $this->accessDeniedMessage) !== FALSE);
 }

/**
* Tests to make sure a logged user can access file ajax.
*/
public function testAccessAllowedLoggedIn() {
 $form_state = array('uid' => 1);
 user_login_submit(array(), $form_state);

 global $user;
 $response = file_get_contents($this->fileAjaxUrl);
 $response = drupal_http_request($this->fileAjaxUrl);
 $this->assertTrue(strpos($response, $this->accessAllowedMessage) !== FALSE);
}


texts: Can I use Views query in my custom code or not?

texts:
Through views I am getting result perfectly in update preview. But when I use the same query in my custom code, its not working as expected. Do I need to do any modification in code or do I need to do any configuration in views so that I can get a query which should be executed through code also. Any help will be appreciated.
For example code is here:

SELECT node.nid AS nid,
   node_uc_product_kits.nid AS node_uc_product_kits_nid,
   node_uc_product_kits.language AS node_uc_product_kits_language
 FROM node node
 LEFT JOIN uc_product_kits uc_product_kits ON node.nid = uc_product_kits.product_id
 LEFT JOIN node node_uc_product_kits ON uc_product_kits.nid = node_uc_product_kits.nid
 WHERE (node_uc_product_kits.status = 1) AND (node.nid = 1 )

In code:

$ord_weight = db_result(db_query("SELECT node.nid AS nid,
   node_uc_product_kits.nid AS node_uc_product_kits_nid,
   node_uc_product_kits.language AS node_uc_product_kits_language
 FROM node node
 LEFT JOIN uc_product_kits uc_product_kits ON node.nid = uc_product_kits.product_id
 LEFT JOIN node node_uc_product_kits ON uc_product_kits.nid = node_uc_product_kits.nid
 WHERE (node_uc_product_kits.status = 1) AND (node.nid = 1 )"));
print_r ($ord_weight->num_rows);


texts: i have configured captcha module in my drupal 7 site.. but can't understand how to show a captcha in content type, so that while adding content user will have to complete the captcha.


texts: How do I link to the homepage from a node?

texts:
I used to had a logo provided by a theme which automatically linked to the home page. But now I replaced this with a custom block. How do I link to the homepage from that custom content type?

Using php in the block code is not an option because of caching.


texts: How to create a confirm popup when delete item with field collection?

texts:
I have configured a field collection field (unlimited items) for a content type and I want create a confirm popup when user delete an item.
For this, i found that i can directly go and modify 2 functions in the field_collection.pages.inc file. They are:

1. field_collection_item_delete_confirm

2. field_collection_item_delete_confirm_submit

I'm a newbie in drupal so I don't know how to use these function from the field_collection.pages.inc file, I tried to hook these function in template.tpl file but it's didn't work. Can someone help me ? Sorry about my English.


texts: Forms display label elements as placeholder

texts:
Do you have any solution for this?

I know I can hide labels via template.php but how to add placeholders to some inputs?


texts: How to check if block is empty in page.html.twig

texts:
In my page.html.twig I have

{{ 'Block title'|t }}

  {{ drupal_block('leftblock') }}
  {{ drupal_block('rightblock') }}

I want to display Block title only if my custom leftblock and rightblock are filled.

Thanks.

I tried

If I do in my my_module.module

function my_module_preprocess_page(&$variables) {
  $block = Block::load('leftblock');
  if ($block) {
    $variables['leftblock'] = \Drupal::entityTypeManager()
      ->getViewBuilder('block')
      ->view($block);
  }
  $block = Block::load('rightblock');
  if ($block) {
    $variables['rightblock'] = \Drupal::entityTypeManager()
      ->getViewBuilder('block')
      ->view($block);
  }
}

and in my page.html.twig

{% if leftblock or rightblock %}

{{ 'Block title'|t }}

{% endif %}

  {{ leftblock }}
  {{ rightblock }}

This {{ rightblock }} display the real content of the block in twig( when is filled ), but
It always display Block title because the block have always something

if I do  {{  dump(rightblock) }} i got this when the block is empty or filled.

array(3) { ["#cache"]=> array(4) { ["keys"]=> array(3) { [0]=> string(11) "entity_view" [1]=> string(5) "block" [2]=> string(22) "rightblock" } ["contexts"]=> array(2) { [0]=> string(28) "languages:language_interface" [1]=> string(8) "url.site" } ["tags"]=> array(2) { [0]=> string(10) "block_view" [1]=> string(41) "config:block.block.rightblock" } ["max-age"]=> int(-1) } ["#weight"]=> int(0) ["#lazy_builder"]=> array(2) { [0]=> string(42) "Drupal\block\BlockViewBuilder::lazyBuilder" [1]=> array(3) { [0]=> string(22) "rightblock" [1]=> string(4) "full" [2]=> NULL } } }

I have two themes :

block-myLeft.html.twig

block-myRight.html.twig


texts: how to overide prvatemsg url 'messages' to 'something'?

texts:
function _MY_MODULE_custom_submit($form, &$form_state) {
    $form_state['redirect'] = url('thank-you', array('absolute' => true));
}


texts: “admin/people” filters not available anymore

texts: I have Drupal 8.7.3 so at admin side on people listing page I can't see the filter to find a particular user.


texts: Aggregated CSS & JS files revert to old version

texts:
I'm troubleshooting an odd issue on my Drupal 7 site where it seems that old versions of our aggregated CSS & JS files are used some amount of time after a cache clear. How this is playing out is that I'll make some update to our CSS or JS, then clear the cache via drush cc all (I've also used the UI to manually clear the cache). I get an updated version of the CSS / JS for a while. At some point (typically I've noticed it a few hours later), the page serves the old version of the aggregated file.

I've pulled mysqldumps of the site, and can see that the values in the variable table for drupal_css_cache_files, for example, contain a reference to the old aggregate rather than the new.

I found this issue on drupal.org (and I'm not sure it's exactly the same thing), but one of the suggestions involves deleting all files in <root>/cache, which I don't have. Would this be the same as deleting the files in sites/default/files/js/?

Another part of this that may or may not be related is that I see in my site logs "page not found" requests for old aggregated files that don't exist anymore.

I'm hitting a wall in troubleshooting, since it seems like the actual database value for the new aggregated file is being reverted. Anyone know what might be going on here?


texts: Include referenced term's custom fields in node view with content display

texts:
I have a taxonomy term reference field in a node (D8).

I have a content (node) view that needs to use a content display rather than fields.

The term is selected, but not the custom fields that have been added to the vocabulary (see the query, below).

The display settings for the vocabulary have all the fields being displayed.

I thought perhaps there was a relationship that I could add that would result in the fields being selected. The only applicable option is for Taxonomy term, which I have added. It results in the taxonomy_term_field_data being joined, but not the custom fields.

Do I actually need to hook the query before execution to add joins for the additional fields?

SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, taxonomy_term_field_data_node__field_tags.tid AS taxonomy_term_field_data_node__field_tags_tid
FROM
{node_field_data} node_field_data
LEFT JOIN {node__field_tags} node__field_tags ON node_field_data.nid = node__field_tags.entity_id AND (node__field_tags.deleted = '0' AND node__field_tags.langcode = node_field_data.langcode)
LEFT JOIN {taxonomy_term_field_data} taxonomy_term_field_data_node__field_tags ON node__field_tags.field_tags_target_id = taxonomy_term_field_data_node__field_tags.tid
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('article'))
ORDER BY node_field_data_created DESC
LIMIT 1 OFFSET 0


texts:
Generally, implementations of hook_requirements() don't use any Drupal function, when they are invoked during installation. node_requirements() uses some Drupal functions for whatever phase it is invoked.

  $requirements = array();
  // Ensure translations don't break at install time
  $t = get_t();
  // Only show rebuild button if there are either 0, or 2 or more, rows
  // in the {node_access} table, or if there are modules that
  // implement hook_node_grants().
  $grant_count = db_query('SELECT COUNT(*) FROM {node_access}')->fetchField();
  if ($grant_count != 1 || count(module_implements('node_grants')) > 0) {
    $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count));
  }
  else {
    $value = $t('Disabled');
  }

Which Drupal functions can be called in hook_requirements('install')?


texts: Node Reference Argument In loadByProperties() while Creating API

texts:
I have a custom module which generates an API, I want the API to filter content based on a node reference field. How do I pass the field field_author(Entity Reference from another content type) field as an argument to loadByProperties?

public function get() {

$entities = \Drupal::entityTypeManager()->getStorage('node')-
>loadByProperties(['field_author' => 'Holmes']);

}


texts:
I am building a configuration form with a few sortable elements. I know, you can build a table using builtin Drupal draggable functionality (drupal_attach_tabledrag), but it's a bit too complicated for my task.

I am saving new order of elements inside a hidden input field value using Jquery UI Sortable function and dynamically set #weights in form elements:

    $weights = $config->get('sort_order');
    parse_str($weights, $weights);

    $form['el1'] = [
        '#type' => 'checkbox',
        '#title' => 'Title1',
        '#default_value' => $config->get('el1'),
        '#weight' => $weights['el1']
    ];

    $form['el2'] = [
        '#type' => 'checkbox',
        '#title' => 'Title2',
        '#default_value' => $config->get('el2'),
        '#weight' => $weights['el2']
    ];

Elements are draggable and sorting works fine. The only difficulty I have is prepending an icon to each element so that others could use that icon to drag elements up and down (just like Drupal does in a lot of configuration UIs).

I know you can create custom elements using #markup with an image tag inside it, or some div with image background. But adding custom markup to each element is problematic for several reasons:

I'll have to write different names for each markup separately. For example if I have a markup element:

$form['drag-icon'] = [
    '#type' => '#markup',
    '#markup'=> '

'
];

its name is drag-icon and to prepend it to another element, I'd have to use a different name each time (this is horrible).

Although it can be aligned well with the element using css, dragging on that icon, breaks the line while moving it up/down.
Would have to write this mark up manually for each element.

I also tried using a template file for this form, but among other things, I couldn't keep track of sort order inside it so easily as in buildForm() function using #weight.

I wrote a lot of explanations to show what I have tried.

I just want a simple method to append an icon to each element of the form to achieve something like this:


texts: "View private files" permission not effective

texts:
I have 3 users, an administrator, an uploader, and a viewer. The uploader has a file field attached to his profile and the destination folder of the uploaded (in my case .pdf) file is set to the private directory.

The administrator can certainly view all files and when I enter the absolute URL of the private file (MySite.com/system/files/File.pdf), it gets displayed on my screen as expected.

I want the viewer to be able to view all files as well, while not having all the permissions that an administrator would have. Hence, I gave the viewer permission to "View private files" and to "Document: Download any files" (I am running File Entity 7.x-2.0-alpha3+30-dev, which gives me these options). However, when I enter the absolute URL of the private file while being logged in as the viewer, I get an "Access denied" error.

Can anyone confirm this issue and advise me how to resolve it?


texts: Webform css stylesheet overriding my css file

texts:
I am using drupal 6.25 with webforms 6.17 and conditional stylesheets 6.12 and am noticing that the webform style.css file is overriding my IE7style.css file even though the IE7style.css file appears after the webform stylesheet when I view the source in IE7.

It makes no difference if I have css caching turned on or off - the result is the same.

Here is the relevant line in IE7style.css

.webform-container-inline .form-item {
    display: block;
}

Here is the line in webform's sytel.css it should be overriding

.webform-container-inline DIV.form-item {
    display: block;
 }

How is this possible and more importantly how do I fix it???


texts: Access by role based on term referenced in the node

texts:
I'd like to restrict access to content based on a term referenced in the node.

For example, I have a content type 'submission' and I want users with the role 'curator' to be only able to view nodes that have the taxonomy term 'art'.

Any pointers towards a sustainable solution to this?


texts:
I have a talent for finding the hard issues.  I have a custom migration class importing taxonomy terms.  The class is an in-house customization, and we have it working happily on other sites.  On my site, it is not working.  There is a chance this is related to the data, which is coming from the client and possibly not clean.  Here is my issue.  I am implementing the public function prepareRow($current_row) with the intent of skipping some rows that I know will cause trouble.  Specifically, anything with a non-numeric id value.

I know the function is called, I see "Gojira!" appear
I know the value that is causing an error
The function is not being respected by the system.

Here is my function:

public function prepareRow($current_row) {
  $safe = FALSE;
  if(is_numeric($current_row->id)){
    $safe = TRUE;
    // problem value is $current_row->id == 'n'
  }
  if(!$safe) {
    print('Gojira!'); // this is seen in the migration ui
    //die();  // this is ignored
    return FALSE; // this is ignored
  }

  // allow parent to skip a row
  if (parent::prepareRow($current_row) === FALSE) {
    return FALSE;
  }
}

Here is the error I see on the migration ui page:

Migration failed ... General error: 1366 Incorrect integer value: 'n' for column 'sourceid1' at row 1

Please help.


texts: Benefit of loading JavaScript in template.php rather than the theme info file?

texts:
The title says it all really. Whats the benefit of loading JavaScript files in the template.php file over the theme info file?

For the sake of simplicity lets assume there is no condition to them being loaded. As a themer my instinct is to want to load things with the info file, but this isnt the standard practice on my current project.


texts: How does Drupal 7 page/block cache work?

texts:
I have a few questions about drupal 7 page/block cache.

If I enable the cache and set the expiration time for 15min., and the content in page A is updated within next 10min., will the cached version be updated? or will it only update every 15min.?

Does same apply to blocks?


texts: View uses language SQL condition for untranslatable fields

texts:
I have got an issue with views. The problem is that a view uses the SQL WHERE condition while retrieving data from DB.

Here is the example to explain the problem.

I have a custom node type - work. It has a custom field field_work_sort_order  with the Users may translate this field flag unchecked.

But the view`s SQL query is following

SELECT node__field_work_sort_order.field_work_sort_order_value AS node__field_work_sort_order_field_work_sort_order_value, node_field_data.nid AS nid
FROM
{node_field_data} node_field_data
LEFT JOIN {node__field_work_sort_order} node__field_work_sort_order ON node_field_data.nid = node__field_work_sort_order.entity_id AND (node__field_work_sort_order.deleted = '0' AND node__field_work_sort_order.langcode = node_field_data.langcode)
WHERE (( (node_field_data.status = '1') AND (node_field_data.type IN  ('', '', '', 'work')) AND (node_field_data.langcode IN  ('en', 'en')) ))
ORDER BY node__field_work_sort_order_field_work_sort_order_value ASC
LIMIT 11 OFFSET 0

Here is the interesting part

 AND node__field_work_sort_order.langcode = node_field_data.langcode)

As you can see it compares if the field has the same language as node_field_data but as I have already mentioned it is not translatable field.

As a result I have different order of nodes for different languages.

How can I solve the problem ? Is there any solution ? Or maybe this is my fault.

I would be grateful for any help.

UPDATE

Here is my full view

And my enabled language modules

P.S I have been facing with the language problems for the whole development process. I have asked a lot of questions related to the language problems (@Oleg Videnov you have helped me several times so far) But I found just ways that don't solve problems but just hide them. So all in all language modules and some parts of the Drupal core seem very buggy, and I am wondering if only I have these problems. As far as I am using the latest version and haven't modified any core files.


texts:
I have a site with a tremendous number of nodes of various content types. I want to set them all to unpublished, and I don't see a way to do that easily without going through page after page after page of content pieces.

I was thinking of doing a query directly on the database: UPDATE node SET published = 0; -- but will this correctly unpublish all content?

Edit: We're dealing with several thousand nodes, and as I understand, there's a hard-coded limit of 50 nodes displayed on the bulk edit page. So I am trying to avoid flipping through dozens of pages.


texts: Drupal 8 Ajax Form Submit works only once?

texts:
I am trying to create a simple form in D8 that submits with a submit button and then replaces the entire form content via ajax.

For some reason, my AJAX submit works perfectly on the first click but then kicks in a normal submit handler.

This Works

  public function getFormId() {
    return 'my_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {

  $form['#prefix'] = '
';
  $form['#suffix'] = '
';
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit ').time(),
    '#ajax' => [
      'callback' => [$this, 'loadStep'],
      'wrapper' => 'form-test',
      'effect' => 'fade',
    ],
  );

return $form;
}

public function loadStep(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$form['submit']['#value'] = time();

$response->addCommand(new HtmlCommand('#form-test', $form));
return $response;

}

public function validateForm(array &$form, FormStateInterface $form_state) {

}

public function submitForm(array &$form, FormStateInterface $form_state) {
// TODO: Implement submitForm() method.
}

This Does NOT work

  public function getFormId() {
return 'my_form';
}

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#prefix'] = '
';
  $form['#suffix'] = '
';
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit ').time(),
    '#ajax' => [
      'callback' => [$this, 'loadStep'],
      'wrapper' => 'form-test',
      'effect' => 'fade',
    ],
  );

return $form;
}

public function loadStep(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$form['#prefix'] = '
';
$form['#suffix'] = '
';
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Title'),
  '#required' => TRUE,
);
$form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Submit ').time(),
  '#ajax' => [
    'callback' => [$this, 'loadStep'],
    'wrapper' => 'form-test',
    'effect' => 'fade',
  ],
);
$response->addCommand(new HtmlCommand('#form-test', $form));
return $response;

}

public function validateForm(array &$form, FormStateInterface $form_state) {

}

public function submitForm(array &$form, FormStateInterface $form_state) {
// TODO: Implement submitForm() method.
}

It seem like as soon as I add something more substantially than just changing the label on the submit button, it seems to fail from the second submit where it just invokes a regular submit.

I want to replace the entire form on every submit (basically creating a multistep form).

I am running 8.3.2 btw

Many thanks for all help.


texts: Pre-select a role on user register form and hide from display?

texts:
I have this scenario that I am trying to walk through. I am new to creating custom modules, but I'm working on it (only way to learn...right?)

How would I go about doing this as I'm currently getting an error when trying. I have a role: 'venue admin' that will be responsible for adding other users with the role of 'customer'. I already am using the module: Role Delegation to handle the permissions side of things. But on the User Registration screen, I would like the customer role to be pre-selected and hidden from display.

This is what I have so far:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 */

function mandatory_role_form_user_register_form_alter(&$form, &$form_state,   &$form_id) {
global $user;

if(in_array('venue admin', $user->roles)) {
// by default notify user of new account is checked
    $form['account']['notify']['#default_value'] = TRUE;
// the only role the venue admin role can create is a customer so this is checked and hidden.
    $form['account']['roles']['#access'] = FALSE;
  }
}

obviously, this is not complete and missing the ability to set the role. Any suggestions?


texts:
I have added pages, webform, and views to my site to customize the User profile experience. I can access mysite.org/user and it shows my user profile page as customized. I have a link on that page to Edit the user profile which is formatted as mysite.org/user/1/edit this works fine. I also have realname module installed so the Edit button on the User profile tabs has the url mysite.org/user/my-real-name/edit This link does not work. It gives an access denied when used even from the User 1 account. I have researched this over and over and over. I can't find the cause or the fix. Any ideas?

I've checked permissions, I've gone through the panel page, the view. I've disabled things and tried it and still issues. I'm at a total loss on what to do.


texts:
I have a local site and a development site. I want to replace my development site with my local site. I used the Backup and Migrate module to backup the development site into a .gz file. All good. But when I did the same again with the local environment, it came back as a .tar file, no matter which compression option I chose.

When I tried to restore onto the development site using the local site's tarball, it specified it needs a .gz or .zip file. So I ran:

  tar -cvzf 127.0.1.1-2015-01-12T17-23-50.sitearchive.tar.gz
  127.0.1.1-2015-01-12T17-23-50.sitearchive.tar

This time, it came back with this error:

  Unable to restore from file
  /tmp/backup_migrate_vbDBRs.0.1.1-2015-01-12t17-23-50.sitearchive.tar
  because a tar file can't be restored to this database.

How can I correctly restore a backup from my local site onto the development site. Or is this method completely wrong and I should be doing something else, like creating a new site from scratch and restoring that?


texts: Send user a reminder email after x-number of days if Profile2 field is empty and user has specific role

texts:
I have a multi-step user signup process. When the user creates their account, they are assigned role "A" and are redirected to a Profile2 form with various fields. If they complete and save their Profile2 form, they are assigned role "B" and role "A" is removed from their account.

I need to send an automated reminder email to the new user 5 days after their account was created, if they are still assigned user role "A". The email's purpose would be to remind them to log in and complete their Profile2 form. How can I accomplish that kind of time delay using Rules? If not rules, are there any other modules that would accomplish this?

Thanks!


texts: Commerce - PayPal WPS - Two orders created

texts:
I have a weird problem when using PayPal WPS with Drupal Commerce. Everything seems to work fine from a client perspective, except that the order gets status pending. The problem is that two orders are created. One pending order for the user with the PayPal transaction and for the right amount, and one completed order for a guest user for $0.

Does anyone know what might cause this problem?


texts: Drupal Commerce Kickstart 2 Adding Attrubutes to SPECIFIC Products

texts:
I have a product type and I sell a number of different items within that category, where most of them have the same 3 options (color, type, voltage).  However, I have a couple of products of this type that don't conform to the same option set in that they have an one additional option for the customer to select.

The way I see it, I have two workarounds here, and neither of them seem like it's the "right" way to do it.  Either I create a separate product/ variation type with all of the existing options, plus the additional option, or I add the additional option to ALL of my variations, even the ones that don't come with that option and just leave it blank for those products.  Neither of these solutions are ideal in that it separates these products from others of their "type" or it creates the possibility for options to become available to the end user that are not possible.

Perhaps this is just me coming from an ubercart background, but I feel that I should be able to create an option that is specific to an individual product.  I've scoured the internet and I'm not finding a way to do this, nor am I finding anyone else asking this question and getting an answer.  What am I missing here?


texts: How to programmatically stop a migration?

texts:
Say I want to stop a migration that I'd like to stop on preImport under similar circumstances as a dependency not being fulfilled, is there a way to do this?

I would like to stop the migration and prevent postImport from running, preferably from preImport().

public function preImport() {
  parent::preImport();
  if($this->externalDependency == 0){
  // Stop the migration, and maybe even throw an error.
  }
}


texts:
I need a method of changing users passwords which doesn't require email, as such the best solution I can come up with is providing "manager" roles the ability to reset passwords. However we do not want to provide these users with "administer users" permission.

I am thinking the best way of doing this is a view which displays "my team" (uses a user reference on that managers direct reports.) and uses views bulk operations however I can not find anywhere documentation on how to reset users passwords.

Ideally the VBO action would allow managers to select members on their team and reset passwords to a string, then update the user in person.


texts: Dynamic Taxonomy Filter dropdown with childs in Drupal 7

texts:
For a while I'm trying to sort this but no luck

I need exact same filter like here http://www.pets4homes.co.uk/

I have pet types as taxonomy terms and breeds as child`s. I want to accomplish same thing like on that website, when I select dogs I want just dogs breed to be on second dropdown. Location is not needed but if you know the way to add it even better, but now I'm focusing on dropdowns.

Already I tried with Simple Hierarchical Select module and Hierarchical Select but I just can't set it up to work like I want, or I don't know how to set up it properly.

With SHS module  I have one dropdown with pet type and when I select it than other dropdown shows up, but I need it to be all the time there, and that is not possible with this module as I read it in issues of that module.


texts: How to attach a field to an entity programmatically?

texts:
Is it possible to attach a field to an entity programmatically?

I want to create a new entity, say vehicle, which has radio buttons defined for the brand of the vehicle. I would like this field to not be able to be deleted or modified via the UI.


texts:
I have a view page with url user/%/plans.Which listing contents by a particular user.But listing can be seen only for the administrator when visit their dashboard(from admin/people)(screenshot 1).
But logged in user(content author) cannot see the list(screenshot2).

I gave all the permission to the author to view his content.But it is not working.Can any one give suggestions to solve this issue?
This is my views(screenshots 3 & 4)


texts: Programmatically save file into profile2 entity

texts:
I'm trying to save a file into my Profile2 entity, I've taken the user through a multi-step form, I've saved all the data and at the point I want to input my data into my profile object, I have a variable which 'holds' the file object which has already been uploaded before this point.

However, I can't find out what code I need to run to tell my profile2 entity (in pseudo terms)

field_cover_letter = $file

I've tried opening up a profile object of an existing account to see what it saves it as, which it seems to just be an array of the file object as well, but I tried typecasting my object to an array and using those values, but it throws a PDO. There must be a simple command to add a file to the profile2 object?

Cheers


texts: How can I import and create multiple images from CSV file using Migrate Plus API?

texts:
I've done a lot of research but none of the examples seem to fit our use case.

I have a migrate plus YML file that creates images from a CSV file that will then be used on Commerce products migrate imports. This import YML works great for single images but we now need to expand it to allow for multiple images.

I've put some test images in the CSV separated by a pipe delimiter "|". But I can not get the import to properly explode or iterate through the multiple images.

The CSV file has a column called "Product Image" with a value of:

test.jpg|test2.jpg|test3.jpg

The current YML file that works with a single (non-delimited value) is below. How can we expand this YML to properly explode and create multiple images?

id: products_variation_photos
label: Photos associated to product variations
migration_group: my_module
migration_tags:
  - CSV
# Source.
source:
  plugin: csv
  path: modules/custom/my_module/assets/csv/products.csv
  header_row_count: 1
  keys:
    - Product Image
  fields:
    Product Image: Name of the image file associated with the product.
  constants:
    file_source_uri: public://import/catalog_images
    file_dest_uri: 'public://product_images'
destination:
  plugin: 'entity:file'
process:
  filename: Product Image
  file_source:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/file_source_uri
        - Product Image
    # Make sure we don't have any url-unfriendly characters.
    -
      plugin: urlencode
  file_dest:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/file_dest_uri
        - Product Image
    # Make sure we don't have any url-unfriendly characters.
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - '@file_source'
      - '@file_dest'
# Dependencies.


texts:
I have a Drupal 7 installation on Linux with Tomcat 6 and Apache Solr.

Drupal can connect to Apache Solr, but the search only works for the "database service" class, even though I used the same settings when I created the server with "Solr Service" class.

Is there any way to troubleshoot the Solr index directly from linux box or Tomcat?


texts:
I can't figure out how to configure Mailhandler with an IMAP Gmail account locally with MAMP.

I've been following the recommendation at http://drupal.org/node/207366#gmail and it is never working fine. The test mbox that ships with the module works just fine.

My settings are:

Protocol: IMAP
Folder: INBOX
Domain: imap.gmail.com
Port: 993
Username: username@gmail.com
Password: mypassword
Extra commands: /ssl

I've tested different combinations like:

Switch imap.gmail.com to gmail-imap.l.google.com
Changed port to 995 or 587
Trimmed username to "username" only (w/o @gmail.com)
Switched /ssl by /ssl/novalidate-cert, /tls, /notls...

Most of these attempts were without any conviction and only because the default config wouldn't work and return the following error when saving:

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/ssl/novalidate-cert}INBOX in MailhandlerPhpImapRetrieve->open_mailbox() (line 118 of /docroot/sites/all/modules/mailhandler/modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php).

And this error when hitting "Test connection":

Mailhandler could not access the mailbox using these settings

Any idea what I'm missing to make this work ok?

P.S. : I can ping imap.gmail.com or telnet on port 993 just fine.


texts: I have created a view which displays all the posts of an author. I need to set the title as - "(Author Name)'s Posts" or "Posts by (Author Name)" where Author Name will change depending on the profile the reader is visiting. Can someone please help me with it...


texts:
From Drupal 8, I'm looking for create a very sample CKEditor plugin (CKEditor version 4.8). This plugin allows the user (me) to add quickly specifics tag in the text.

After some google search, I find how add a simple button in the CKEditor pannel, but I don't find any example for add a dropdown list in the CKEditor pannel.

Below, my code for add a simple button :

CKEDITOR.plugins.add( 'addtime', {
    icons: 'addtime',
    init: function( editor ) {

        editor.addCommand( 'insertTimestamp', {
            exec: function( editor ) {
                var now = new Date();
                editor.insertHtml( 'The current date and time is: <em>' + now.toString() + '</em>' );
            }
        });
        editor.ui.addButton( 'addtime', {
            label: 'Insert Timestamp',
            command: 'insertTimestamp',
            toolbar: 'insert'
        });
    }
});

Now I want add a dropdown list instead the sample button "addtime". By example, a dropdown list with theses options "add <a>" / "add <b>" / "add <c>" and when I click on the option "add <b>" then the text "<b>" is added to the text.


texts:
The hosting provider I user for my site disabled the phpinfo() function and, as consequence, the link that would normally appear in the status report page is not anymore shown, replaced by a warning message.

I would like to create a custom module to remove that message, and show a link to a page that, similarly to the page shown by phpinfo(), reports information about PHP and the enabled extensions.
Is there a way to alter the information about PHP system_requirements() normally shows in that page?