texts: How do I use node_load() with an array as first parameter?

texts:
In Drupal 6, I would use the following code.

$nodes = node_load(array('title' => $vcenter_name, 'type' => 'vcenter'));

What is the equivalent code for Drupal 8? I could use node_load($nid), but not node_load(array('title' => $vcenter_name, 'type' => 'vcenter')).

UPDATE

As per the answer , am getting the the $nodes array as

Array
(
    [1147] => Drupal\node\Entity\Node Object
        (
            [in_preview] =>
            [values:protected] => Array
                (
                    [vid] => Array
                        (
                            [x-default] => 9272
                        )

                    [langcode] => Array
                        (
                            [x-default] => und
                        )

                    [revision_timestamp] => Array
                        (
                            [x-default] => 1452106357
                        )

                    [revision_uid] => Array
                        (
                            [x-default] => 0
                        )

                    [revision_log] => Array
                        (
                            [x-default] =>
                        )

                    [nid] => Array
                        (
                            [x-default] => 1147
                        )

and i can't access the fields like $nodes->field_name[0]->value;

But how i get like this :

Drupal\node\Entity\Node Object
(
    [in_preview] =>
    [values:protected] => Array
        (
            [vid] => Array
                (
                    [x-default] => 9173
                )

            [langcode] => Array
                (
                    [x-default] => und
                )

            [revision_timestamp] => Array
                (
                    [x-default] => 1448312269
                )

            [revision_uid] => Array
                (
                    [x-default] => 0
                )

            [revision_log] => Array
                (
                    [x-default] =>
                )

            [nid] => Array
                (
                    [x-default] => 1107
                )


texts: Need to sort views block by current node first

texts:
So what I'm doing is setting up a block with images that link to it's corresponding testimonial page.  Each testimonials has it's own node, and I want to sort the block so that the first image in the block is the one that links to the current testimonial page that the user is on. For example:

I have testimonials from:

Student A
Student B
Student C
Student D

If I'm on the page for Student C then the order of the block should be:

Student C
Student A
Student B
Student D

Anyone have a good way to do this?


texts:
I was using it for a long time in the install script and today it stopped working and I don't remember changing anything related.

  The drush command 'language-add' could not be found.

Was it part of l10n_update (I have it enabled), drush itself or something else?

This https://drupal.org/project/drush_language is not what I'm looking for. It doesn't work and I've never seen it before.


texts: How do I set cURL options in a custom migration?

texts:
I have a custom migration that needs to get JSON data from a remote URL. This works fine in a beta environment outside of ddev, but I'm having trouble in a ddev test environment because of SSL on the other end.
It seems the cURL option SSL_VERIFYHOST is set to false, but that's clearly not happening when the migration tries to run. I'm using the Migrate, the Migrate Tools, and the Migrate Plus modules; I saw that another module, Migration Tools, might allow me to set the cURL options, but I get a dependency error when trying to enable it. Core and modules are all updated.


texts: How to append a new form element to a form via AJAX not triggered inside the form?

texts:
Suppose I have a form only with a submit button.
After an AJAX response (not an #ajax form callback) I need to insert/append a new form element into this form.(it's not declared in the form-building function)

How will I initialize this new form element in the PHP callback function, in order to populate it with the data i am getting through ajax?

I could have initialize the form with a dummy element and copy its array to a new one?How will I hide this dummy element in the initial state of the form (before ajax)?

In the "Add more" examples out there, the initial form carries the first of these elements from the beginning... what if there is not from the beginning in the form?

In other words how can I get anywhere in the code a fresh-empty form element ready to be rendered?


texts: What's the usage difference between element_validate and validate hook?

texts:
From what i've learned today, there are two ways one can go about validating input.

One is the #element_validate field which is passed along the form hook, and the other is the validate hook.

Why use the validate hook if input can be validated with the #element_validate field? Is it a necessity to implement the validate hook in this case?

Or is it a method that should be implemented for complex validation while all simple validation(is number, is date, is url) can be done via the #element_validate option?


texts:
Is there a way to add a  Show All Link on my view pager.

I have a Block View.

I would like to be able to add an All Link button when the number of Items reach 5. I do not need the pager "Next, last 1,2,3" only the All Link button.

Thanks a lot


texts: How might I have Webforms save files to private file system or as a database blob?

texts:
In Drupal 7, I have the file system configured as

In the code for the Webforms' file component located at sites/all/modules/webform/components/file.inc, it appears that one could easily change it so that Webform file uploads are moved to the private file system by changing 'scheme' => 'public' to 'scheme' => 'private'. But I also know the pitfalls of hacking (changing) anything that could easily be overwritten with drush upc.

 /**
 * Implements _webform_defaults_component().
 */
function _webform_defaults_file() {
  return array(
    'name' => '',
    'form_key' => NULL,
    'required' => 0,
    'pid' => 0,
    'weight' => 0,
    'extra' => array(
      'filtering' => array(
        'types' => array('gif', 'jpg', 'png'),
        'addextensions' => '',
        'size' => '2 MB',
      ),
      'scheme' => 'public',
      'directory' => '',
      'progress_indicator' => 'throbber',
      'title_display' => 0,
      'description' => '',
      'attributes' => array(),
      'private' => FALSE,
      'analysis' => FALSE,
    ),
  );
}

Given that all file uploads are stored referenced in the file_managed table

mysql> describe file_managed;
+-----------+---------------------+------+-----+---------+----------------+
| Field     | Type                | Null | Key | Default | Extra          |
+-----------+---------------------+------+-----+---------+----------------+
| fid       | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| uid       | int(10) unsigned    | NO   | MUL | 0       |                |
| filename  | varchar(255)        | NO   |     |         |                |
| uri       | varchar(255)        | NO   | UNI |         |                |
| filemime  | varchar(255)        | NO   |     |         |                |
| filesize  | bigint(20) unsigned | NO   |     | 0       |                |
| status    | tinyint(4)          | NO   | MUL | 0       |                |
| timestamp | int(10) unsigned    | NO   | MUL | 0       |                |
+-----------+---------------------+------+-----+---------+----------------+

Is it feasible to do a post operation to a file upload that manually moves a file from public:// to private:// and updates the database entry? Would hook_file_presave or hook_file_insert be good tools to accomplish this?

Update

Based on the suggestion of using hook_webform_component_info_alter(), I implemented the following

/**
 * Implements hook_webform_component_info_alter().
 */
function  MYMOD_webform_component_info_alter(&$components) {
   $components['file']['extra']['scheme'] = 'private';
   dsm($components['file']);
}

/**
 * Implements hook_file_insert().
 */
function MYMOD_file_insert($file) {
  dsm($file);
}

After the output of the DSM() shows the component array seems to be altered but the DSM from hook_file_insert() still shows that the file was deposited into the public area:


texts:
This is the line:

$row = db_fetch_object($result);

While $result is valid but $row is getting a null value which I've checked with is_null.

As per this function's @return value, it can only return FALSE in failure.

Also mysql_db_object states the same.

What could be the reason it is returning null?


texts: Drupal Commerce Stock Availability or Out of Stock

texts:
I am working on Drupal Commerce website. Using Commerce Stock I am able to manage the inventory but on product details page I want to print the following.

Availability: In Stock

or

Availability: Out of Stock

Also if possible

Availability: Limited Stock

If I am displaying stock filed its showing number of items available in stock, which I don't want to display.

Is there any way in Drupal I can acheive this task?


texts: How do I get information about the payment method from the order object programmatically?

texts:
I'm trying to do some different processing after an order is placed depending on which payment method a customer uses.

In my EventSubscriber, I have the following code:

 public static function getSubscribedEvents() {
    $events = [
      'commerce_order.place.post_transition' => 'onPlaceTransition'
    ];
    return $events;
  }

  public function onPlaceTransition(WorkflowTransitionEvent $event) {
    $order = $event->getEntity();

Now I want to get the name or id of the payment method that was used from the order, but when I used kint($order) I couldn't find a way to access the payment method.

How do I access the payment method given an $order object?


texts: How can I let anonymous users view user profiles by role?

texts:
I have 2 different roles like A and B.

I want anonymous users (everyone) can view user profiles from A role but can't view user profiles from B role.

In summary, A role profiles is open for everyone but B is not.

Access user profiles permission or View profiles permissions module is not enough for that.

Thanks in advance.


texts: Code to output individual fields in a Theme view

texts:
I know this question seems to have been half answered a few times but I'm finding it difficult to apply a working solution. I have created a new theme from scratch to use for a view I have created. I can get the view content to display in the Theme by using:

  print render($page['content']);

However because of the complexity of my theme layout I need to display the fields in the view individually.

I understand that I need to create a file in the theme folder called something like:
views-view-field--viewname.tpl.php and add some php, then add some code to this but I just can't seem to find the correct code that is needed plus the correct syntax I add to the theme page.tpl.php to show the individual fields. Could anyone please help?
Thanks.


texts:
I have a menu item in my module like this

$item['imageuploadsuccess'] = array(
    'title' => 'Upload Image Success',
    'page callback' => 'image_success',
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM
);

and the callback looks like this

function image_success(){
$page = '<p>'.t('You successfully uploaded your image.').'</p>';
return $page;

}

When I go to /imageuploadsuccess, I get told that the page doesn't exist. I've tried clearing my cache completely and I still get nothing. Any idea what could be wrong?


texts: Environment dependend workflow with configuration management

texts:
When using Drupal 7 with larger projects, we used a Custom module together with Features, Environment and Environment Indicator modules to keep special environment settings apart. We had at least one feature module for each environment containing something like this:

Production

no dblog module active
no devel modules
all sorts of caching enabled
red coloring on Environment Indicator

Staging / Testing

dblog module active
no devel modules
some caching disabled
yellow coloring on Environment Indicator

Staging / Testing

dblog module active
all sorts of devel modules active
caching disabled
green coloring on Environment Indicator

When developing we used to push new code to production when it was finished and tested. After successful deployment, we cloned the database down to staging and development environments to be sync with the state of production in terms of new content. After that we would run commands like drush env-switch staging to tell Drupal to set environment to Staging and run some custom hooks that would enable the Staging feature module and its settings and dependencies. This way Production, Staging and Develop had different sets of modules and configuration but the same state of content.

After reading and testing into Configuration Management, i fail to see how i could accomplish such a workflow. When using drush config-export staging it exports all current settings into staging directory, which i can check into git and deploy it on my server. Features for D8 lacks of some things that have been in D7. I miss a settings we had in D7 and i am not able to add a dependency without additional settings. I don't depend on Features if there is another way of doing things like this in D8.

What am i missing in D8? What would be the current workflow to get such environment dependent settings and modules active and different environments in Drupal 8?

Thanks for you help!


texts: Add a non-base field to a content entity form

texts:
What is the proper way to add a non-base textarea field to the entity form of a custom content entity?

comment and user modules have non-base fields that display in their entity form (comment_body and picture), but it appears these fields are added to the form somewhere besides the main entity form method they use.

In my module, I've created a field and instance inside hook_install like this:

<?php
function mymodule_install() {
  $field = array(
    'name' => 'myfield',
    'entity_type' => 'myentitytype',
    'type' => 'text_long',
    'module' => 'text',
    'settings' => array(),
    'cardinality' => 1,
    'locked' => FALSE,
    'indexes' => array(),
  );
  entity_create('field_entity', $field)->save();

  $instance = array(
    'field_name' => 'myfield',
    'entity_type' => 'myentitytype',
    'bundle' => 'myentitytype',
    'label' => 'Field title',
    'description' => t('Field description.'),
    'required' => TRUE,
    'default_value' => array(),
    'settings' => array(
      'text_processing' => '0'
    ),
  );
  entity_create('field_instance', $instance)->save();
}

I think if I could be pointed to how comment_body gets added to the comment entity form, or picture to the user entity form, I'd be able to resolve this.


texts: I want to create a 'mark as offensive' flag for my site. However, I have no idea how to go about it. Is there a tutorial on the web that will guide me through the process?


texts:
I noticed that, while I am able to build taxonomy into my feature, it doesn't seem to include the list of terms within the taxonomy. When I go to create a feature, the uuid_term section does list a few, but not many, actual terms for me to select. What am I missing? It's worth mentioning that I am starting with a Demo build and customizing from there. The only terms that are actually listed are not showing up in Structure > Taxonomy.

I tried upgrading UUID to no avail.

Drupal 7.54
UUID 7.x-1.0
Features 7.x-2.10


texts: How would you programmatically create an OG group? I have tried node_save() but to no joy.


texts: How to use nodereference_select in custom form (set default value) D6

texts:
I am building a custom form using the Form API. I want to show a nodereference_select in my form. However I have some difficulties setting the default value and the list of values.

//Create array of values
$items['6039']="MT";

// add field
$field = content_fields('field_nodereference_select');
$form['#field_info']['field_nodereference_select'] = $field;
$form += content_field_form($form, $form_state, $field);
$form['field_nodereference_select']['#weight'] = 6;
$form['field_nodereference_select']['#default_value']=$items;
$form['field_nodereference_select']['#options']=$items;

When I render the form I see the widget but without any values.
When I am able to render the $items array, my next step would be to executing a view (because the nodereference_select is using a view to select certain values). and fill the $items array with the values.

Any help on this one?


texts: Print array of imagefield fields for node type

texts: I need to get an array of imagefields for a specific node type or even just all imagefields or all fields for a node type.


texts: Error entries in Watchdog duplicated dozen and hundreds of times

texts: I have seen that the table watchdog in my MySQL database is growing enormously, and after TRUNCATE, I see that for each visit to a single page, it generates hundreds of inserts, and when seeing them, they appear to repeat dozen and dozen of times. How can I trace where the error is, because I would bet this is a misconfiguration or something. I am worry that Drupal is making thousand of redirections, I have no other explanation, the pages load fast but the machine has a lot of RAM and hardware, so maybe I am loosing performance somewhere.


texts: List those nodes which are not referenced through a reference field in other nodes?

texts:
I have content type which has a node reference field of the same content type.

I want to list only those nodes which are not referenced through this node reference field in any other node.

Is it possible with views?


texts: Im using Switchtheme to allow users to switch the theme of my site. Im also using Context and id like to create a new context depending on what theme has been chosen, but I cant see any options for this in the UI.


texts:
I've a simple tableselect with 4 columns, in the 3 last columns a want to populate all the columns with checkboxes, anyone can help me to do that ?

here is my actual code :

function liste_sections($form, &$form_state){
$form = array();

$header = array(
        'sections' => t('Sections'),
        'affichable'=>t('Affichable'),
        'new'=>t('New'),
        'online'=>t('Online'),
);

$resultat = db_select('taxonomy_term_data','tax');
$resultat->fields('tax',array('tid','name'));
$res = $resultat->execute();

$rows = array();
    foreach($res as $sql){
        $rows [] = array(
            'sections' => $sql-> name,
          // Time to put checkboxes for other columns
            );
    }

$form['liste_sec'] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $rows,
        '#empty' => t('empty ! '),
);

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

Thank you all


texts:
Possible Duplicate:
  Block not showing up in drupal

For some odd reason, This very simple module block does not show up in structure
under the list of viable blocks. Am I doing something wrong here?

[quick_links.info]

name= Quick Links
description = Simple block with links
package = Mpackage
core = 7.x
files[] = quick_links.module

[quick_links.module]

function quick_links_block_info() {
  $blocks['quick_links_staff'] = array(
    'info' => t('Quick Link'),
    'status' => 1,
  );
  return $blocks;
}//TODO add caching option

function quick_links_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'quick_links_staff' :
      $block['subject'] = t('Quick Link');
      $block['content'] = t('links go here');
      break;
  }
  return $block;
}


texts: When/where to include my own function library (like common.inc)?

texts:
When, hence where, should I include my own library of functions that I will use throughout my whole project.

Drupal has it's common.inc that is included in drupal_bootstrap during the fase DRUPAL_BOOTSTRAP_FULL. I also have a common.inc with functions that I use all the time, in different modules. I want to include this file once so I can use it everywhere without having to include it in each file separatlely.

So what is the right location/hook to do it?


texts: How do I know when another contributed module deletes a block?

texts:
I have written a Drupal 7 module that adds about ten fields to the block administration configuration form and saves the values for those fields in its own database table. My module does not create blocks, but rather extends the functionality of any block, regardless of what module created it.

My module should delete the data in its own table when any module deletes a block from the block table. However, how would my module know when this happens? Is there a hook or other "universal" method available to know when a block has been deleted?

There isn't a hook_block_delete(), even though there are hook_node_delete() and hook_entity_delete().
I've looked at development guides about creating blocks for some clues, but none of the ones I've found give examples of how they should be deleted. I've also looked at the source code of modules that create/delete blocks, like the Views module, but I can't tell how, or if, they send a notice that they have deleted a block.


texts: How to hide set up database step in a installation profile?

texts:
In a installation profile, how do I fill values for Set up database step programmatically and hide it so user doesn't need to fill the form?

How to do the above action for the Select language step?


texts: How to generate my own patches to update core for security when fuerstnet.de's "Drupal upgrade the easy way" page is out of date?

texts:
For Drupal 7, under the current host I'm using (which doesn't provide things like drush), I've found that patching is the easiest approach to updating core. However, the commonly-referenced page which provides the .patch files for doing this ("Drupal upgrade the easy way") has not updated for 7.67, which contains a security-fix.

Rather than go back to the old way of doing things by following all the steps found within UPGRADE.txt, what process can I use to generate a patch for upgrading my own site?


texts: How to enable IMCE in a field of a custom block

texts:
I have module that generates a plugin block with a field of type managed_file.

public function blockForm($form, FormStateInterface $form_state){
    $config = $this->getConfiguration();
    // todo make this IMCE
    $form['background'] = array(
      '#type' => 'managed_file',
      '#title' => $this->t('Background'),
      '#description' => $this->t('Enter background image'),
      '#default_value' => isset($config['background'])?$config['background']:'',
      '#upload_location' => 'public://backgrounds',
      '#weight' => '2',
    );
}

I guess I have to create a module.schema.yml file to do that but I don't know how to enable the IMCE.

block.settings.stingray_basic_block:
  type: block_settings
  label: 'Stingray basic block'
  mapping:
    body:
      type: text
      label: 'Body'
      translatable: true
    background:
      type: managed_file
      labe: 'Background'
      ??? MAKE IT IMCE ???

Usually this boolean appears in the core.entity_form_display...yml file as a third party settings structure:

content:
  field_background:
    weight: 1
    settings:
      preview_image_style: thumbnail
      progress_indicator: throbber
    third_party_settings:
      imce:
        enabled: true
    type: image_image

...but I don't know if it can be set in the schema.yml file nor how.

Anyone has info on this?

ref: https://www.drupal.org/node/2821710


texts:
In our production server, we wrongly set page_cache_maximum_age a long value,

$conf['page_cache_maximum_age'] = 12960000;

Now viewers are complaining they are seeing old contents in there homepage.

I am able to see new contents with a force reload (CTRL + F5).

Is there any way to force the client side to refresh the pages in this stage?

We have our architecture Drupal+Nginx+Varnish and CloudFlare on top of it.


texts: Hide formatting options from a CCK field in Drupal 6

texts:
I have a custom module in which I am using hook_form_alter to remove the formatting options/help text for the body and comment fields:-

function mymodule_form_alter(&$form, &$form_state, $form_id) {
// We don't want the format options displaying
if (isset($form['body_field']['format'])) {
    $form['body_field']['format']['#access'] = false;
}
if (isset($form['comment_filter']['format'])) {
    $form['comment_filter']['format']['#access'] = false;
}
}

This works fine. However, I also need to remove the same formatting options/help from a CCK field. I've tried to use the same technique but can't isolate where in $form the formatting options are being included. Is it not possible to removed them using the same method as above?

We want to remove this information as it is not relevant to the user as the WYSIWYG editor provides them with all the tools they need and nothing more. We don't want to hide these with CSS, they need removing from the output.


texts: Drupal 7 Form API file field - not recognizing the imported file

texts:
function test_data_import_form($form, &$form_state) {
    $form = array();

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

    $form['import_data'] = array(
        '#type' => 'file',
        '#title' => t('Upload data file'),
        '#size' => 22,
        '#required' => TRUE,
    );

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

    return $form;
}

Please see my form code above. I am trying to import a file through this form, but the file I am trying to import is not recognized as it is throwing "Required field error". Please help me with this.


texts: How can I prevent user data being cached and showing the wrong username?

texts:
I have built a Drupal 8 site, we are showing the user name and last name on a block, this is my code on preprocess from .theme file:

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

$firstname = $user->get('field_firstname')->value;

$firstname = $firstname;
$variables['firstname'] = $firstname;

Then in the block im doing: Hello {{ firstname }}

And it shows the last user, not mine. When I do drush cr then I get the correct name, why? How can I fix this and already display the right username?


texts: Custom module with custom theme/template

texts:
I have tried to get this question answered in the past, but I was never given a satisfactory response.

I am building a custom module. I do not want the module to inherit the current theme being used by Drupal core; it should have its own themes/templates. This is the code I have written.

myApp.module

// $Id$
require_once ('myApp.theme.inc');
function myApp_menu()
{
 $result = array();
 $result['myApp'] = array(
    'title' => "My App",
    'page callback' => "myApp_home",
    'access callback' => true,
    'type' => MENU_NORMAL_ITEM,
    'weight' => 1,
  );

 return $result;
}

function myApp_home(){
    $output = theme('myApp_home', array('data'=> ''));
    return $output;
}

myApp.theme.inc

function myApp_theme() {
    $path_to_theme = drupal_get_path('module', 'myApp')."/theme/";

    $themes = array();
    $themes['myApp_home'] = array(
    'template' => 'myApp_home',
    'path' => $path_to_theme ,
    );
    return $themes;
}

myApp_home.tpl.inc

Hello World

The problem is that the module still resides within the Drupal core. I want to have it be a full page web application.

I am new to this, so if anyone could provide an explanation of the best practice, and example code, I would really appreciate it.


texts:
Are there any issues I should know about using a pre/process function and, simultaneously, a template file?

For example, I have some logic I would like to apply to a field and at the same time, I would also like to customize the HTML output for that field as well.

Can I create a pre/process function and create a template file specific for that field?


texts: Problem with showing custom html.twig content

texts: im making a custom menu for the homepage. My issue is that whenever I change block--system-menu-block.html.twig to something else that it suggest in the debugging like for example: block--system-menu-block--main.html.twig or block--hoofdnavigatie.html.twig it's not showing up anymore. I've cleared cache, switched themes, but nothing works. It does show up in the dubugging tool that firefox has but theres 0 content in it.. Am I doing something wrong >?


texts: Update drupal modules without updating core in one drush command

texts:
Is there a way to update all contrib modules without updating core in one drush command.  For example:

drush up updates all modules and core.  Is there a way to ignore core and just update the modules without having to list out each module name?


texts:
I created a block-view which shows me the titles of the newest content. By default drupal simply lists the titles. I would like that the list appears with bullet points. Is this only possible to do in CSS? Is there no way to format it in the view module?

Thanks for any feedback


texts:
I am working on a custom module (based on Model project) with a file field attached to my custom entities, now I would like to save files in certain directories according to entity id eg:

public://files/my_custom_entity_ID/filename

I've tried with hook_file_insert but can't get the entity id in order to use it later in file_move.

Which hook (if any) should I use? Or I am missing the whole approach?


texts:
I, like other people on here it seems, have been trying to build a multi-step form using this tutorial about how to use the Ctools wizard to do so. My ultimate goal is to replace the registration form with my own multi-step sign up. The problem I am having is that at the moment I am mostly just 'regurgitating' the information on that tutorial link, without truly understanding how the data is passed between the forms, or the manner in which it is stored.

I've read some of the comments on that page and it seems to indicate that the cache object is overwritten after passing through each step, which is no good to me.

The tutorial never really touches upon the submit process and how you access the form items you've created throughout the steps. I know what I want to do with all the information when it's collected and ready, but I think I'm still a little fuzzy on how you retrieve the information.

If anyone has any knowledge about how to use the Ctools multistep wizard so that I can understand and process the user inputs, that would be great

Thanks


texts: Drush doesn't detect drupal installation under sites sub-directory

texts:
I have been using  Drush 4 and 5 with no problem. Now that I have downloaded and installed new Drush 7.0-dev using composer, I am having problem i.e  it doesn't by-default detect drupal installation when I am on sites sub-folder,

Drush running on sites-root directory,

drupal7/sites/example.com/modules/views$ drush status

 Drupal version                  :  7.30
 Site URI                        :  http://example.com
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database port                   :
 Database username               :  example_user
 Database name                   :  example_db
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  bartik
 Administration theme            :  seven
 PHP executable                  :  /usr/bin/php
 PHP configuration               :  /etc/php5/cli/php.ini
 PHP OS                          :  Linux
 Drush version                   :  7.0-dev
 Drush temp directory            :  /tmp
 Drush configuration             :
 Drush alias files               :
 Drupal root                     :  drupal7
 Site path                       :  sites/example.com
 File directory path             :  sites/example.com/files
 Temporary file directory path   :  /tmp

Drush running under sites-subdirectory,

drupal7/sites/example.com/modules/views$ drush status

 Drupal version         :  7.30
 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php5/cli/php.ini
 PHP OS                 :  Linux
 Drush version          :  7.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  drupal7

So, how do I configure Drush, is there anything I can do to make it work, I don't want to use --uri  or -l flag or any other options everytime.

Update

Also when I download modules it get downloaded on sites/all/modules directory

drupal7/sites/example.com/modules$ drush dl webform
Project webform (7.x-3.20) downloaded to drupal7/sites/all/modules/webform.                                     [success]

But if I am on sites-root directory it works fine,

drupal7/sites/example.com$ drush dl webform
Project webform (7.x-3.20) downloaded to /home/sysop/project/drupal7/htdocs/sites/heisenberg.com/modules/webform.                          [success]


texts: form button redirecting to .inc module file

texts:
I'm building a custom module and I would like to add some buttons that redirect the user to other .inc files on click.

My idea was something like this, in my mymod.user.inc file :

if ($form_state['storage']['step'] === 1) {

 $form['button']['addnew_form'] = array(
    '#type' => 'submit',
    '#value' => 'new form',
    '#submit' => array('mymod_form_user_newform_form'),
            );

$form['button']['addnew_form2'] = array(
    '#type' => 'submit',
    '#value' => 'new form 2',
    '#submit' => array('mymod_form_user_newformtwo_form'),
            );

 return $form;

}

I added a hook_menu in my myform.module file :

function myform_menu(){
$items = array();

$items['myform/forms/newform'] = array(
    'title' => 'New form 1',
    'description' => 'New form 1',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('mymod_form_user_newform_form'),
    'file' => 'myform.newform.inc',
    'access callback' => TRUE
);

When I click on my button, it doesn't redirect to the new form page.
Am I totaly wrong using this method ?


texts: What is the most sustainable way to obtain aggregate information on fields?

texts:
EntityFieldQuery is not intended to be used to run aggregate functions (SUM, AVG, etc.) on field data because it is SQL-agnostic. That said, such operations legitimately need to be run from time to time. According to SQL function with EntityFieldQuery and especially EntityFieldQuery and how to use aggregate functions SUM, ARG and MAX, SQL queries need to be used, and that approach fits my use case the best. I was speaking with @chx yesterday and he recommended using a couple of internal functions to find the field name and column name. I'm just wondering if this is sustainable and if it's appropriate to do in a codebase that I might release to otehrs.

If it's the best way, then it's the best way. I just don't want to do it before I'm absolutely sure because it feels messy.


texts: How to create custom menus with different path

texts:
I want to create custom menus.

I created dashboard named menu,
now i want to provide links under dashboard menu,

i created one link named myprofile.

and it is asking for path. i want to link it with user edit page who is logged in.

I have no idea regarding this.

Does anybody have idea regarding this.

Thanks


texts: Get nodes by content type when type key is not in root of nodes array

texts:
I am trying to get all nodes by content type. When the key is in the root of nodes array, like [type] I can easily retrieve it by, for example:

$nodes = node_load_multiple(array(), array('type' => 'page'));

But how do I do it when the key is not in the root, like:

    [title] => Test 1
    [status] => 1
    [comment] => 0
    [promote] => 0
    [sticky] => 0
    [nid] => 24
    [type] => page
    ...
    [field_worktype] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [value] => some_value
                            )

                    )

            )
   ...

So, in the above example, how do I get nodes which [field_worktype][und][0][value] equals "some_value"?


texts: How to auto-insert a sequence number in a Webform?

texts: Is there a way to add a Webform field that serves a unique sequence number? Hopefully the number can be sequentially counted for each Webform type.


texts: Memcache module is working but with a strange error

texts:
I have Memcache enabled both on Drupal and the server... It seems to be configured fine on the server-end (both by port & Settings.php).

If am being accurate, PSI grades even went up in about 4-5 points... So seemingly my site does use Memcache... And yet, Cron gives a strange error:

  PECL Memcache version 2.2.5 is unsupported. Please update to 3.0.6 or
  newer.

Tried to Google the error (or part of it) and found just nothing... I've also spoke with the server's support team and one of them told me to ignore this error... I'm not sure if this is the right thing to do... Will glad for the advice of Veteran drupal developers...


texts: Why are some of my modules reporting missing inter-module dependencies after migration?

texts:
I'm troubleshooting modules after a host migration--did I miss something? Before I changed my host I backed up MySQL database, made a list of all my used modules and burned a dvd of the Drupal root directory. Now, after I've successfully restored the database of 5/6 sites, three modules report missing inter-module dependencies within their module groups:

Event- Calendar Signup   - 6.x-2.x-dev - Depends on: Signup
(missing)
Rules- Rules Simpletest - 6.x-1.4 - Depends on: Simpletest
(missing)
Services -

servers - REST Server - 6.x-3.0-rc1    - Depends on:
Autoload (missing)
authentication - OAuth Authentication  6.x-3.0-rc1 - Depends on: Oauth_common (missing)

How can these other modules be missing if they were there before the migration? The folders are still the same. Do some modules "make" other modules in the database? Something like cTools 'makes' the css directory.

All of my sites are in the sites directory and share the same modules, though they each have their own database. Each is missing the same module dependencies.


texts: Show Field Collection fields together in same field item

texts:
I have a field collection with two fields - Image and Caption. How do I get the two fields to display in the same field item? Right now the HTML is:

I need the HTML to be more like:


texts: How to alter the welcome message after successfull registration

texts:
A message is shown upon successful registration, with the following contents:

  A welcome message with further instructions has been sent to your e-mail address

I would like to change the content of that message and use a different HTML structure, e.g.:

Thanks for registering

 continue

How can I do that?


texts: Unable to find my newly added locations in map?

texts:
I'm unable to find newly added locations in map. Make sure I have enabled below modules:

->GMAP

->GMAP Location

->Node Locations

->Location CCK

Currently display 14 map points only. But actually I have created 20 locations and can't see all those. Look at below screen shot:

Please advice,
Thanks.


texts: How I can delete all node/field revisions?

texts:
I have a drupal 7 sites, where it keeps node and field revisions. I keep revisions for the case where by mistake a new faulty version is saved and I want to revert back.

But, now I want to clean and optimize the database so to take less space in hard disk.

What are some methods of deleting all the revisions except the current one, for all nodes/fields of the site?


texts: How can I display a view title with 'No Results Behaviour'?

texts:
Using Drupal V 7.34 and Views 7.x.38

On the front page I have a view that lists news articles based on publish date being in the last 2 weeks. This works fine.

What I am now wanting is to insert a new view to pull images from Flickr when there are no news articles to show.

So, I created a new view for the Flickr feed, and adjusted the paging as I wanted. I set up the No Results Behaviour to show my new view in the Global View Area.

This works, but the title of the view is not displayed.

How can I show the title of the NRB view?

Many thanks


texts:
I have downloaded Drupal 8.x-dev at https://drupal.org/node/572834 to test on my local PC (Xubuntu 14.04 Beta 1).

I have successfully installed but when I try to access Admin menu is giving me "Not Found" pages, though on a simplytest.me sandbox it working ok.

What am I doing wrong?


texts:
We're running Drupal 7.65 and Alfresco 5.2.4. We've the ability to display CMIS content (hosted in Alfresco) by fetching a URI like: https://domain.com/cmis/browser?id=<node_ID>. Doing so allow users who doesn't have access to Alfresco to download a file (if node_ID refers to a file) or browse the content of a directory (if node_ID refers to a directory).
Issue: sharing a directory via this method allow users to navigate the whole content of Alfresco by navigating the breadcrumb.

We'd like to remove this breadcrumb, could you recommend ways to do it ?
Here's what we've been thiking at:

Ideally, find a Drupal/Alfresco setting that allow us to restrict display
Comment out the line(s) responsible of displaying this breadcrumb inside Drupal' source code
less ideally, filter the DOM through JS (document.getElementById('cmis-breadcrumb').innerHTML = '')

Apologies for my English and the lack of knowledge about CMIS and Drupal

edit 19/01/2021: I believe I've found the module & the function responsible for the breadcrumb: https://git.drupalcode.org/project/cmis/-/blob/7.x-1.x/cmis_browser/cmis_browser.theme.inc#L125


texts: "Unable to send e-mail" Error in drupal 7

texts:
Just now I migrated my website to server machine. I noticed that website is not able to send any email. It is showing "Unable to send e-mail" error.

Below is the screenshot of the error-

I can see some directory permissions error in status report at admin/reports/status. Are these related to each other?


texts: Adding JS to a Drupal 8 theme (replacement for drupal_add_js)

texts:
In Drupal 7, I can use drupal_add_js within a theme's template.php file as a theme_preprocess_html(&$vars) function:

   drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/scripts.js',
        array(
          'group' => JS_THEME,
          'preprocess' => TRUE,
          'weight' => '999',
        ));

  $vars['scripts'] = drupal_get_js();

In Drupal 8, I've tried converting this using attached in my theme's .theme file as such:

  $vars['#attached']['js'] = array(
    array(
      'data' => drupal_get_path('theme', 'mytheme') . '/js/scripts.js',
      'options' => array(
        'group' => JS_THEME,
        'preprocess' => TRUE,
        'every_page' => TRUE,
      ),
    ),
  );

... but that did not work and there were no errors in watchdog / console or otherwise.

According to the D8 API page for drupal_add_js:

  Deprecated - as of Drupal 8.0. Use the #attached key in render arrays
  instead.

There was not much more info that that however. It seems that drupal_add_css will also use this method. I know it's still early days for Drupal 8 but I was hoping to get a jump on this.


texts: Using Ajax, how can I populate a div with Database Content from a form select?

texts:
This is what I have so far. I can populate the select field just fine, however when another option is selected I can not get the data to populate in the ajax callback div.

function product_comparison_menu(){
  $items = array();
  $items['design_product_comparison'] = array(
    'title'            => t('Product Comparison'),
    'menu_name' => 'menu-main-menu',
    'page callback'    => 'drupal_get_form',
    'access arguments' => array('access content'),
    'page arguments' => array('product_comparison_form'),
  );

  return $items;
}

/*
* Display output
*/
function product_comparison_form($form, &$form_state) {

  //Query DB for Rows
$query = db_select('product_comparison');
$query->fields('product_comparison', array('id', 'OtherCombo',));
$query->condition('DropdownCategory', 'Exit Devices');
$query->orderBy('OtherCombo', 'ASC');
$results = $query->execute();

    //define rows
$options = array();
foreach ($results as $result) {
    $options[$result->id] = $result->OtherCombo;
}

$form['Exit Devices']['OtherCombo'] = array(
    '#type' => 'select',
    '#title' => t('Exit Devices'),
    '#options' => $options,
    '#ajax' => array(
      'wrapper' => 'product_comparison_ajax_wrapper',
      'callback' => 'product_comparison_form_ajax'
    ),
);

$form['results'] = array(
  '#type' => 'markup',
  '#prefix' => '
',
  '#suffix' => '
',
 );

 // If the form has been submitted, build up your results and display them
 if (isset($form_state['Exit Devices']['OtherCombo'])) {
   $row = db_select('product_comparison')
     ->fields('product_comparison', array('DesignHardware', 'DesignImg','DesignURL'))
 ->condition('OtherCombo', $form_state['Exit Devices']['OtherCombo'])
     ->execute();

   $header = array();

   $form['results']['#markup'] = theme('table', array('header' => $header,'rows' => $rows));
  }
  else {
    $form['results']['#markup'] = '
The results will appear here when you change the dropdown option.
';
  }

 return $form;
}

function product_comparison_form_ajax($form, $form_state) {
  return $form['results'];
}


texts: Adding field to entity via .install file doesn't add field to table

texts:
Attempting to add a field to a commerce_promotion_coupon with the following in commerce_promotion.install:

function commerce_promotion_update_8204() {
  $entity_definition_update = \Drupal::entityDefinitionUpdateManager();

  $storage_definition = BaseFieldDefinition::create('boolean')
    ->setLabel(t('Bulk'))
    ->setDescription(t('Indicates if coupon is bulk.'))
    ->setDefaultValue(0);
  $entity_definition_update->installFieldStorageDefinition('bulk', 'commerce_promotion_coupon', 'commerce_promotion', $storage_definition);
}

Running drush updb completes successfully, but the field isn't in the database - what am I doing wrong?


texts: drupal_static and cache_set combo , is this overkill?

texts:
I have been using this snippet lately here and there, but after re-thinking , it seems like it could be a good example of over-engineered code:

<?php
function my_module_function() {
  $my_data = &drupal_static(__FUNCTION__);
   if (!isset($my_data)) {
    if ($cache = cache_get('my_module_data')) {
      $my_data = $cache->data;
    }
    else {
      // Do your expensive calculations here, and populate $my_data
      // with the correct stuff..
      cache_set('my_module_data', $my_data, 'cache');
    }
  }
  return $my_data;
}
?>

Is this truly an optimal way to cache things? I am not clear on the low-ends of it all but it seems the drupal_static call is overhead since the static call would get only called once before the data would be cached. Maybe I am seeing it wrong, and rather the cached variable would be set static for the whole request, and static access is faster than cache access?

I am also not clear if the cache is global for all users or on a  per user basis. I would imagine the cache is global, but please correct me if I am wrong!.


texts: Drupal Commerce: Can I have product list and checkout in the same page?

texts:
I have a D7 site and I´m trying to implement Drupal Commerce.

I just need a page where the user can select the product from a list, and give some information about himself (billing information). And at the bottom it should be the "buy" button.

I don´t want a cart, the possibility of "continue shopping" and stuff like that.

How may I do that with Drupal Commerce? I´ve watched all day the videos and read some documentation, but it really seems over complicated when you just want a simple thing (opposed to a big ecommerce site).

Any guidance, tip or help will be very much appreciated. Thanks!


texts: Creating a view from multiple content types where one is optional

texts:
Is it possible to display multiple content types within a view that may or may not have a related secondary content type?

I have two content types (A - which contains a title and body field, and B - which contains a title and body field). In this view, content type A will always exist - and I would like to have any related B content types display underneath the appropriate object. It is possible that no content B types will exist for that title, so if that's the case it can move on and display the next content A type info:

(A) Title = New York, body = "Something"
(A) Title = Ohio, body = "Something"
     (B) Title = Ohio, body = "An interesting tidbit about Ohio"
(A) Title = Virginia, body = "Something"
...etc...

Any idea how I may go about accomplishing this? I have heard about a References module to explore, but it seems like that would only pull data where that relationship exists, right? And that in my above example, although I would be anticipating three states in my view, references would only show me the Ohio one because that's the only one that also contains a content B type.

Is that correct? Or is my understanding incorrect?


texts: I have a view that I need to filter alphabetically. How is this done? I need to also add a list item for each letter of the alphabet, with an ID of that letter for a quick anchor scroll-to script. Can anyone help me getting this done?


texts: How do I override a function from a module?

texts:
Firstly, sorry if this answer is covered elsewhere. I've done a lot of searching and can only find info on overring theme functions and hooks.

I am using a module that builds a price table for Drupal Commerce items. There is a function that formats the table headers:

/**
 * Helper function that takes care of the quantity displayed in the headers of
 * the price table.
 */
function commerce_price_table_display_quantity_headers($item) {
  // Set the quantity text to unlimited if it's -1.
  $max_qty = $item['max_qty'] == -1 ? t('Unlimited') : $item['max_qty'];
  // If max and min qtys are the same, only show one.
  if ($item['min_qty'] == $max_qty) {
    $quantity_text = $item['min_qty'];
  }
  else {
    $quantity_text = $item['min_qty'] . ' - ' . $max_qty;
  }
  return $quantity_text;
}

As you can see, this is not a theme function where I can override it in template.php but I can to tweak some of the output.

Obviously I don't want to edit the module itself in case it gets updated in the future, so, how can I redefine this function so I can chop and change a few things?

My work so far...

So far, I have tried to create it as a seperate module with a few subtle changes to show if it's working or not, but it's not overriding any of the output.

Info file

; $id$
name = Price Table: Tweaked Display
description = A different layout for the price table as shown on the product display nodes
package = Commerce (contrib)
core = 7.x

dependencies[] = commerce_product
dependencies[] = commerce_price
dependencies[] = commerce_price_table

Module File

 /**
 * Override of the helper function that takes care of the quantity displayed in the headers of
 * the price table.
 */
function commerce_table_tweak_display_quantity_headers($item) {
  // Set the quantity text to unlimited if it's -1.
  $max_qty = $item['max_qty'] == -1 ? t('Unlimited gnhh') : $item['max_qty'];
  // If max and min qtys are the same, only show one.
  if ($item['min_qty'] == $max_qty) {
    $quantity_text = $item['min_qty'];
  }
  else {
    $quantity_text = $item['min_qty'] . ' - this is working - ' . $max_qty;
  }
  return $quantity_text;
}


texts: hook_form_alter() to make multiple fields as required

texts:
I am trying to make field(s) of Entity Form as required. The field(s) that I want to make required works fine when its one field but when I mention that a field(s) can accept unlimited values the required field(s) doesn't work. In other words only first field becomes required and not all other fields which user adds after pressing "Add another Item" button.

I am trying to hook_form_alter() but still I am not able to achieve where all additional fields become required when user presses add new item button.
Below is the code that I wrote.

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

print_r($form_id);

if ($form_id == 'my_form_name') {

drupal_set_message('<pre>' . print_r($form, true) . '</pre>');

$form['my_field_name']['und']['0']['#required'] = TRUE;

}

}


texts: How to apply flags retrospectively for group subscriptions using Organic Groups?

texts:
We've a large site running Drupal 7 with OG, Flag, Rules, etc.

OG uses a subscription model where you have to confirm you want to join a group (or leave a group) so we've decided to move to a Flag system that then uses rules to add (or remove) that user from the group.

All works great, except the site is already live and we have a lot of members in groups already, which obviously Flag doesn't recognise.

Is there a way to force Flag to check if a group subscription exists already?


texts: Rendering vote / up down counts in custom node template drupal up down votes module

texts:
I'm using Voting API and Vote Up / Down module for drupal 6. I'm trying to render the total upvotes - downvotes ( points ) with in the node template.

according to the module readme -

<?php
// save the rendered value of the widget
$vud_widget = $node->content['vud_node_widget_display']['#value'];
// avoid show it twice
unset($node->content['vud_node_widget_display']);

// render each value inside $content
print $node->content['body']['#value'];

// print vud widget, here is the place where we want to show it
print $vud_widget;

But its returning the whole custom widget template as a string. also the widget is getting rendered two times.

any thoughts ?


texts: Problem with Search: I can do everything locally and I can't do anything on the server

texts:
Production site

FreeBSD 8.2-RELEASE-p9
mysql  Ver 14.12 Distrib 5.0.95, for portbld-freebsd8.2 (amd64) using
5.2
nginx version: nginx/1.0.14

Local copy of the site

Ubuntu 12.04 LTS
mysql  Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64)
Apache/2.2.22 (Ubuntu)

Drupal version 6.19

When I use search locally, it functions properly. When I use search on the production server it fails with the response: Your search yielded no results.

I truncated and imported all of the search tables from the working copy to the non-working copy.

I tried to run a re-index on the production site and it errors out with this message: An HTTP error 500 occurred. /vacation/batch/?id=2&op=do

Is the MySQL database the issue here? What other troubleshooting techniques can help me nail this down?


texts: Multiple Contextual filters, taxonomy and date, on one content type

texts:
I have an event content type. I want two jump menus on the primary view page: one to filter by date (month) and one to filter by taxonomy (category).

I have used views with contextual filters to build the page and jump menus (as attachments). If I only use one filter/jump menu attachment on the view, either one works perfectly. If I put both attachments on the view page, there is some sort of conflict and they stop working.

Is it possible to have two contextual filters on one view page? If so, what do I need to do to make the work together?


texts:
I have created a "Customer" node-type. In that, I have a multi-valued field "Addresses" for taking customer's address.

I have another node-type "Order". While creating a new "Order", I want to select the customer from my existing customers. I can do this using entity or node reference. Now, while selecting the customer, I also want to select the customer's address which is present in the "Customer" node-type.

So, how do I do this? How do I reference another node's field values?

Or, is there any other way for this use-case?


texts: How does Drupal not rely on Foreign Indexes for matching table row information?

texts: I am so confused right now in creating a custom table within Drupal 7. My db schema builds a table with three fields one of which is a uid field. I don't have much experience with databases and I was confused as to how to match, relationally, the uid field of my table with the users->uid field. I am told that the foreign key operation within the D7 appear to do this but that they are only there as documentation, the foreign key operation doesn't actually do anything.  Is there a way, within the D7 schema, to link two table row items such as uid -- if so how?


texts:
I need to create a custom field widget that is actually a 2 input fields group. I also need to save these values (I guess this is done through hook_field_schema())

The main problem is that I'm a little bit confused about how to use hook_field_widget_info() and hook_field_widget_form() and how are these connected with the hook_field_schema()

Any insights / links about this? Thanks


texts: How can I create a very simple entity definition for Webform submissions?

texts:
I make extensive use of the Webform module and often use Views for managing the webform submissions.

I'm fairly new to the Actions/Rules/Triggers backend of Views Bulk Operations (VBO), but I'd really like to be able to use it in my submission management views.

I've written a module that accepts submission IDs from the URL like so: mymodule/form/314/submissions/201+202+203 and generates a page with information from all the listed submissions (in this case, submissions 201, 202, and 203).

I want to use the VBO "Pass ids as arguments to a page" operation to select submissions in a my Views table, and pass their IDs to my custom page.

As far as I can tell, this isn't possible since webform submissions are not entities. So what I'm wondering is, how can I define a very simple entity type for webform submissions, so that I can use VBO on them?

I assume I should implement hook_entity_info(). I think the entity really only needs to include the submission ID in my case (the sid column in the webform_submissions db table).

I've read through the docs on defining custom entities, but can't figure out how to apply that stuff where I'm not actually wanting to create an entity type from scratch. Thanks!


texts:
I tried to use brilliant_gallery, its working but not showing images. instead thats showing only black background.

I am writing what exactly I did..

I installed lightbox2 as dependency of brilliant_gallery
then I installed brilliant_gallery
then I created albums in sites/default/files
then I created images in sites/default/files/album; and copied some images in that
then I went to Input format and enabled Full HTML format to recognize Brilliant Gallery Tag
in admin/config/brilliant_gallery/settings i added "albums" in Main gallery folder
added a new text field to basic content type to add the path of image folder. in display option i set brilliant gallery option for display
while create new node i am putting path of image directory as "images"

Could anyone tell me where I have missed something? I am not able to see images but instead I am seeing black background.

thanks in advance


texts:
I have set the 'Body field settings' > 'Number of values' to 'Unlimited'; so the user can add as many 'body' fields as they like.

I have then added the following piece of code to my themes 'node.tpl.php' file:

<?php $i=0;
while ($i<=10) : ?>
<section class="box page-box">
<?php print render($content['body'][$i]);
$i++; ?>
</section>
<?php endwhile; ?>

This code outputs each of the 'body' fields in a section/div and then adds a number of blank sections/divs until it hits 10!

How would I find out the total number of 'body' fields so that it only outputs the available number and not all 10? I was trying to use 'foreach' but couldn't seem to get it working.


texts: Problem in sending mail with attachement

texts:
I'm coding a small module allowing to send mail to new users with an attachement file as pdf. This pdf include all subscription details of the user.

I generated the pdf file using FPDF and I put it (temporary) in DRUPAL_ROOT and I used two ways to send the mail:

1) Using the hook_mail_alter:

function aos_user_pdf_mail_alter(&$message) {
  if($message['id']=='user_register_pending_approval') {
    $attachment = array(
     'filecontent' => file_get_contents(DRUPAL_ROOT . '/' . 'yourfilename.pdf'),
     'filename' => 'yourfilename.pdf',
     'filemime' => 'application/pdf'
    );
    $message['params']['attachments'][] = $attachment;
  }
}

2) Or creating a custom function:

function aos_user_pdf_send_mail ($mail, $uid) {
  $user = user_load($uid);
  $to = $mail;//gets the current user's mail address
  $from = variable_get('site_mail', ''); //admin's mail address
  $body = 'This is a test mail';
  $subject = 'Your pdf';
  $attachment = array(
    'filecontent' => file_get_contents(DRUPAL_ROOT . '/' . 'yourfilename.pdf'),
    'filename' => 'FILE',
    'filemime' => 'application/pdf',
  );
  $message = drupal_mail('aos_user_pdf', 'message_key', $to,
    user_preferred_language($user),
    array(
      'body' => $body,
      'subject' => $subject,
      'attachment' => $attachment),
      $from,
      TRUE
    );
}

Unfortunately the mail is sent, but without the attachement, Please can you show me where's my mistake or an alternative way to do the job.


texts:
I'm trying to create a custom views access plugin, so I can perform my conditions for accessing a view.

I read several tutorials and checked the source of existing modules, but I must be coding/doing something wrong because this never works properly.

Here's the code:

File: sample.module:

function sample_views_api() {
  return array(
    'api' => 3,
  );
}

File: sample.views.inc:

function sample_views_plugins() {
  $plugins = array(
    'access' => array(
      'test' => array(
        'title' => t('Custom access check'),
        'help' => t('This is a custom access plugin.'),
        'handler' => 'sample_access_plugin',
      ),
    ),
  );
  return $plugins;
}

class sample_access_plugin extends views_plugin_access {
  function summary_title() {
    return t('Custom acces plugin');
  }
  function access($account) {
    return sample_access($account);
  }
  function get_access_callback() {
    return array('sample_access', array());
  }
}

function sample_access($account = NULL) {
  return TRUE;
}

I can see the access plugin in views, and I can select it. However, no matter what I do, the access to the view will always be forbidden (access denied). There are no messages in the error log.

Any ideas what's wrong here?

Thanks!


texts: I would like to implement a client side javascript action using the Rules module. Has anybody been able to do this?


texts: Keeping old site live while testing new site?

texts:
I'm helping my university department upgrade their Drupal website from 6 to 7 (university doesn't support 8 yet).  So far, I've been able to install and test the new site on my local machine, but now it's time to move it to the actual host so that users (mainly the department secretary) can start to populate pages with content.  Can I have a Drupal 7 site live on a subdomain like test.dept.university.edu while keeping the Drupal 6 version live on dept.university.edu?

Apologies if this is a naive question - I've read a lot about creating clones of existing sites for testing, but this assumes that one is upgrading within the same Drupal version.


texts: How to avoid missing status for Workflow access module permission just after node creation?

texts:
I am using Workflow 7.x-2.8 to manage peer-reviewing publication.

When an authenticated user (an author) creates a post, he can choose a first workflow state transition from creation (by default) to draft. This draft is visible only for author and admin. This draft can be edited only by the author.

The sub-module Workflow Access allows me to manage permissions for each workflow state, which is really great. But, apparently, I have a problem with the first status assignment with Workflow Access (priority = 1).

Indeed, according to Devel Node Access module (DNA) debug mode, the status is not in node_access table and I need to rebuild permissions to clear the issue (which is OK for dev website but of course, it is not OK for production website).

When the permissions are rebuilt, everything is fine and the node_access table seems to be OK. Further, when the author decides to change the post to another workflow state (draft TO submitted), the permissions are correctly modified and the author can not edit the post anymore (pending approval).

Last detail : the content type related to this workflow is not published, by default.

I add a DNA screenshot and I hope everything is clear.


texts:
My client wants the only login url to be /user/login
So I need to redirect /user to /user/login

any idea how to accomplish this?


texts: How to display all users except current user?

texts:
How to display all users in a view except the current login user?

I try to write some php code in contextual filter, but that not work. I think there is an easy way but I don't know it.


texts: Send email notifications to Users who have flagged a node

texts:
For a site, I 'Events' which have a datetime field for the start time of the event. We also have 'Flags' to allow Users to add specific events to their calendar.
Now, we would like to send Users email notifications when an event that they have 'flagged' is about to start (that is, 30 minutes before it starts).
If this best achieved with Rules module, or is another method more appropriate?


texts: "Notice: Undefined index: #tag in Drupal\Core\Render\Element\HtmlTag::preRenderHtmlTag()"

texts:
I keep getting the following error on a Drupal 8 site:

  Notice: Undefined index: #tag in Drupal\Core\Render\Element\HtmlTag::preRenderHtmlTag()

I have it from anonymous users, and I have it when I refresh admin/reports/dblog.

I usually get 4 messages in a minute.
That is followed from this message:

  Notice: Undefined offset: 1 in Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processHtmlHead()

What can be wrong on the site?

Drupal: 8.3.0

Theme: Mayo

Modules:

Add To Head 8.x-1.x-dev
Better Exposed Filters 8.x-3.0-alpha2
Blazy 8.x-1.0-rc1
Calendar 8.x-1.x-dev
CAPTCHA 8.x-1.0-beta1
Chaos tool suite (ctools) 8.x-3.0-beta1
Colorbox 8.x-1.3
Display Suite 8.x-2.6
DraggableViews 8.x-1.0
Easy Breadcrumb 8.x-1.6
Entity Reference Revisions 8.x-1.2+2-dev
Google AdSense integration 8.x-1.0-beta3
Google Analytics 8.x-2.1
Layout plugin 8.x-1.0-alpha23
Metatag 8.x-1.0
Page Manager 8.x-1.0-alpha24
Paragraphs 8.x-1.1
Pathauto 8.x-1.0-rc1
Redirect 8.x-1.0-alpha4
scroll to top 8.x-0.x-dev
Search API 8.x-1.0-rc2
Simple XML sitemap 8.x-2.9
– Sitemap 8.x-1.3
Slick Carousel 8.x-1.0-rc3
Slick Views 8.x-1.0-rc2
Tagadelic 8.x-3.0-alpha2
Taxonomy menu 8.x-3.3
Taxonomy Views Integrator 8.x-1.0-beta1
Token 8.x-1.0-rc1
Views Accordion 8.x-1.0-beta2
Views Autocomplete Filters 8.x-1.1
Views breadcrumb 8.x-1.0
Views Slideshow 8.x-4.4
Views Templates 8.x-1.0-alpha1


texts: "Fetch entity by property" for multi-value term reference field

texts:
Node A and user both have a term reference field which referenced to the same vocabulary,  the term reference field of Node A is single-value, but that of user is multi-value.

I created a rule: after saving a new Node A , Fetch entity by property, the Entity type is User, the Property is the multi-value term reference field, but I cannot select the single-value field in the node, the page hints the property value should be "Data types: Select data of the type List of taxonomy term items." When I select "node:field-problem-category" (the single-value term reference field) and save, the page shows error: The data type of the configured argument does not match the parameter's value requirement. I have to select node:field-problem-category:parent. But thus no entity can be fetched.

I followed the instruction here, but no luck.

Any help would be appreciated!

BTW:It will be best that the "Fetch entity by property" can provide an operator like PHP function in_array.


texts: Custom PHP vs Drupal Workflow for a Web Application not Websites

texts:
This question can be too ambiguous but i think many new drupal users face this difficulty like me.

There are many blogs which says that Drupal is a CMF and we can use it for making Web Application rather then using it like Wordpress for articles and pages.

For the sake of example lets say i have to make a task management system with a specific Application style UI and features. If i would have to make it by custom programming i would be making tables for tasks, users, task_attachments, clients and so on and will make relations accordingy.

My question is how we can do all this stuff in Drupal? Nodes are for content and i would not go for nodes to achieve this. The other thing is Entity but How one can properly utilize Entities. If i have to list all tasks for a specific user, If a user want to update a status of his task or attach some file, If its a team and other team members should also be allowd to post updates on tasks. These are the common application scenarios that we usually make in this kind of application.

If someone provide a brief workflow then it would be a great effort for helping beginners like me to use Drupal as a developer rather than doing a data entry job by installing modules and copying content , images.

There is a good example erpal.info but its too advanced for me at this level to jump into it. but a mini erpal would be great.

Thanks Alot.


texts: how to set a webform field value in my custom module

texts:
drupal 7 webform 7-3.18

My webform has a hidden field used to store an unique id. This id is generate from custom logic.

my code is to set this field value.
'webform_client_form_1' is my webform id

function webform_custom_form_webform_client_form_1_alter($form, $form_state, $form_id) {
  $form['submitted']['test_id']['#value'] = 'COURSE_ID-123456';
}

When the form is submitted and view the submission result and this hidden field value is empty


texts: I created a view for node titles only. I have inserted this view in simplenews newsletter using the Insert view module. The node title in newsletter emails are relative and broken. How do I configure my view so that absolute URls are used?


texts: how to add newsletter subscription during registration?

texts: Here what I want to do. I loaded a checkbox list of taxonomy term on the registration form. Also I have a check box for "subscribe newsletter". so the user can check the his favourit taxonomy and "subscribe newsletter". I want to know how can I alter the submission of register form to gather this data?


texts:
How Can i control the way the tabels in the admin panel build?
i want to make the system more comfortable for the people how will be doing all the content edit in my site.

Like change the way this build -

Matan


texts: Which hook to use to detect new members added to group?

texts:
What is the best way to make a hook that only fires when new members are added to a group?
I have a function that exports group memberships to moodle course enrolments. Right now I have it bound to _user_presave:
function mymodule_user_presave (User $user) {

  // Gather data.
  $userid = $user->id();
  $group_memberships = \Drupal::service('group.membership_loader')->loadByUser($user);
  foreach ($group_memberships as $group_membership) {
    $group = $group_membership->getGroup();
    $groupid = $group->id->value;
    $roles = $group_membership->getRoles();
    // Get roles.
    foreach ($roles as $rolename => $value) {

I bound it to user_presave after I realized that adding members to a group also calls this hook. But this seems unnecessarily inefficient, since it always returns all group memberships of the user, instead of just the latest one.
Is there a way to detect a new GroupMembership directly and hook into that?


texts: How to enable Clean URL's in Drupal 7 running on Nginx server?

texts:
I would like to enable clean urls in drupal 7 running under nginx server.

I have tried alot of suggestions from the internet, but none worked.

Here is my /etc/nginx/sites-available/default code

server {
listen   80;
server_name  default;
access_log  /var/log/nginx/localhost.access.log;
error_log /var/log/nginx/error.log;

root /usr/share/nginx/html;
index index.php;

 ## serve imagecache files directly or redirect to drupal if they do not exist.
location ~* files/styles {
  access_log off;
  expires 30d;
  try_files $uri @drupal;
}

## serve imagecache files directly or redirect to drupal if they do not exist.
location ~* ^.+.(xsl|xml)$ {
  access_log off;
  expires 1d;
  try_files $uri @drupal;
}

## Default location
location / {
    try_files $uri $uri/ @drupal;
    index index.php;
}

location @drupal {
    rewrite ^/(.*)$ /index.php?q=$1 last;
}

## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
  access_log        off;
  expires           30d;
}

## Parse all .php file in the /usr/share/nginx/html directory
location ~ .php$ {
    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(.*)$;

    # Gives 503 Bad Gateway
    #fastcgi_pass   backend;

    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;
    fastcgi_param  QUERY_STRING     $query_string;
    fastcgi_param  REQUEST_METHOD   $request_method;
    fastcgi_param  CONTENT_TYPE     $content_type;
    fastcgi_param  CONTENT_LENGTH   $content_length;
    fastcgi_intercept_errors        on;
    fastcgi_ignore_client_abort     off;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
}

## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
    deny  all;
  }
}

upstream backend {
    server 127.0.0.1:9000;
}

I am running the above server on my local machine on Ubuntu 14.04


texts: Profile picture with a border color depending of the role

texts:
Is there any way to set a border color to every profile picture displayed all over the website depending on the role of the user?

I was trying to do it at least on the user profile image and on the User picture block module image following this instructions Custom node color from role but I ended in nothing.

Note: I display the profile pictures in a user search view, in the forums and in a block that display the latest forum comments.


texts: routing.yml for a custom form not working

texts:
I have a form I'd like to use as a standalone page, which I'm defining in a module I've called "SREvent". I have created modules/srevent/src/Form/SREventListForm.php:

<?php
/**
 * @file
 * Contains Drupal\srevent\Form\SREventListForm.
 */
namespace Drupal\srevent\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\srevent\Entity\SREvent;
use Drupal\field_collection\Entity\FieldCollectionItem;
use Drupal\field_collection\Entity\FieldCollection;

class SREventListForm extends FormBase {
    public function getFormId() {
        return 'srevent_list_form';
    }

    //used in getEvents()
    public $inactive = [];
    public $active = [];

    //function to get all appropriate entities
    function getEvents() {
        //....
    }

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

        getEvents();

        //form builder logic

        return $form;
    }

    /**
     * {@inheritdoc}
     */
    public function validateForm(array &$form, FormStateInterface $form_state) {
        return;
    }

    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
        return;
    }
}

In routing.yml, the route is as follows:

srevent.list_form:
  path: '/srevent/listform'
  defaults:
    _form: '\Drupal\srevent\Form\SREventListForm'
    _title: 'SREvent List'
  requirements:
    _access: 'TRUE'

There are other routing entries in this file as well, but none of those are giving me errors. I double checked for typos in the routing file as well as to make sure all indents are spaces and not tabs.

After flushing the cache repeatedly, /srevent/listform is still a 404.

This is how I set up all of my forms and have never seen this issue before, and every post I see on the topic tells me to set up exactly like this.

Is there something I'm missing? This is driving me crazy...


texts: How to build my SQL statement to export all webform submissions using Forena?

texts:
I am using Drupal 7.54. and my users are grouped together through a custom user field.

I want to export all webform's submissions for a given group of users in one CSV.

So as suggested in the post How do I programmatically export all webform submissions into a single csv?, I plan to use a custom datablock that fits my need.

I am new to Drupal and don't have much knowledge about how it works and how Drupal stores custom fields in the database.

I couldn't build the right SQL.

What would be the appropriate sql statement in this context?


texts: Webform, rename files to a constant name and bypass validation

texts:
I have a webform where users can upload one pdf file. I'd like to have this pdf file always the same name foo.pdf.

To avoid conflicts I save each upload to a different directory with the pattern foo/[random:hash:md5].

When trying to save these settings I get the error message To create unique file names, use at least one token in the file name pattern. I understand that this error makes sense to avoid naming conflicts but the conflicts should be avoided with the custom directory.

Is there a way to bypass the validation check?

Edit: For clarification. I need to bypass the validation check in the settings page for the field of the file upload not the validation for the form submission itself


texts: Panels don't render views in separate blocks

texts:
Steps:

I have a view, it has 4 different blocks.
I wanted to have one page that would include those 4 view blocks.
So I created custom Panels page, added views.

Problem I ran into is that for some reason Panels shows all 4 view blocks inside one view instance, so views content from different views blocks are all smashed into views row inside same one view.

I expected it would show view blocks as separate blocks in their own separate containers, so I could wrap them up and give each view different title, but now all of them are smashed into one view and I don't understand why.

4 separate view blocks in the panels layout (so should render in separate wrappers/containers each?):

Under view-content from multiple views blocks, the content is all smashed into each view-row that fall under one same wrapper. Why are they not separate? Why each view block doesn't have separate container/view? Why all of them fall under view-display-id-block_2? Block_2 is just one of the view blocks of that same view, it also has block_3 and block_4, why and how all of them fall inside block_2?


texts: Copy contents from an field entity reference

texts:
I have 2 content type

1-Parent Product
Title
Fabric Type
Product Type
Product Description

2-Child Product
ParentProduct (Node Reference to Parent Product Content Type)
Title
Fabric Type
Product Type
Product Description
Product Code
Product Size
Product Color

Here is the use case.
1-I Create all my Parent Product

2-I Create a child
The first field I need to filled is ParentProduct (Node Reference)
By choosing the ParentProduct, I would like  this parent act as the default value for Title, Fabric Type, Product Type and Product description of this child.

Is there any module that could help me for that?

Thanks a lot


texts:
I am receiving a payload with blob files.

I would like to store them as files and create a media entity.

Here's the code I have to create the Media object

 if (!empty($payload['blobFile'])) {
  $name = str_replace(' ', '_', $payload['fileName']);
  $file = file_save_data($payload['blobFile'], 'public://' . $name, FILE_EXISTS_REPLACE);
  $content['field_media_file'] = ['target_id' => $file->id()];
}
$this->entityTypeManager->getStorage(....

It successfully creates the media content and attach a file to it.

Unfortunately the file is still blob I don't see a pdf or similar.


texts: arg() dependent hidden field in AJAX form

texts:
Basically, I have a hidden field I set using arg().

$form['slideid'] = array(
  '#type' => 'hidden',
  '#value' => arg(2)
);

$form['fid'] = array(
    '#type' => 'managed_file',
    '#title' => t('Image'),
    '#default_value' => "",
    '#size' => 40,
    '#description' => t("Image should be less than xxxxxxxxxxxx."),
    '#upload_location' => 'public://',
    '#prefix' => '
',
    '#suffix' => '
',
);

This value is set correctly once the form loads, but after a call to a AJAX field (managed_file), the form is refreshed and I get the wrong value in arg(2).

I have found arg(1) changed when doing AJAX, which doesn't give me any solution.

Is there any alternative that can be used, or can we skip the hidden field in the AJAX re-build? Is it possible to use a managed_file element without the AJAX submit?


texts: Changing the From Address with the Printer, email, and PDF versions module

texts:
I'm using the Printer, email, and PDF versions module. On all my 'resource' nodes (resource content type) I have a link now that says 'Send by Email'. Great. But when it sends the email it's sending it with a'from' address as MY email (the site admin). I'd rather it be the email of the person who's sending the resource. There is an email field on that form they have to fill out to send the resource to someone else.

Anyone know how to make the email they use for THEIR email in the form be the 'from' email to whomever they are sending this resource?


texts: Assign User Points in existing website which already contains content

texts:
Question specific to "User Points" module, backcopy of question from here due to no response: https://www.drupal.org/node/2492933

Drupal 7 -

I have a website which is already running for more than 2 years. Many users have been adding content to it and now I have a requirement where I need to assign points to the user. I came across this great module but this does not let me assign values to the user based on the content they have already contributed, revisions already worked on and also the comments provided already.

I have tried to google and also checked the module thoroughly but there is no way to do what I want to achieve. Is there a way to achieve this?


texts: postSave not able to print submission element data

texts:
Using Webforms, I have been using postSave() instead of submitForm() but I am not able to print form element data. For example, I would like to print the element type and element value. Back then I could do this with submitForm() by using  $form['elements'] and $form['elements']['#default_value'][0]. What would be the best possible way?
Thanks


texts:
Does Drupal 7's DB API support SQL's CAST function? I have a varchar with numbers in it that I'm trying to convert to integers for proper sorting. Here's my statement:

$images = db_query('SELECT filename, caption FROM {iha_captions}
WHERE uid = :uid ORDER BY CAST(weight AS INT) ASC', array(':uid' => $userid));

And here is the error I get:

  PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT) ASC' at line 1: SELECT filename, caption FROM {iha_captions} WHERE uid = :uid ORDER BY CAST(weight AS INT) ASC; Array ( [:uid] => 2814 ) in iha_search_profile()

It then causes a cascade of SQL failures in Drupal's session and cache queries. Is CAST supported, or am I doing it wrong?


texts: Filtering video embed text out of search result text while using Search API

texts: I'm using the Search API module to improve my Drupal 8 site's search functionality, and I'm using the Video Embed Media module for the purposes of embedding YouTube and Vimeo content. I have created a view that renders my search results, but I'm running in to a problem with the raw video embed text appearing in the results. I can eliminate this problem if I use entity field rendering in the view settings for the body field, but if I do that I give up the ability to highlight the original search term(s) in the results. This looks like an either/or situation. I want both! Anyone have a solution to this problem?


texts:
Can anybody tell me how I add an image field of a taxonomy term to a view of nodes with reference to the vocabolary?

I have a content type called "Product" and one called "Distributors". And then a have a vocabolary called "Product categories", where a term has two fields: a title field and an image field.

I am using the NAT module to add a term to the "Product categories" vocabulary every time a product is created, so that the title and image of the product becomes a new term with the value of these two fields.

When I create a distributor I am using these terms as term reference to which products the distributor sells.

The problem I am facing now is that I want a view of distributors, and I cant seem to get the image of the terms associated with each distributor-node. I can only get the titles. I assume that I might have to make some kind of relasionship, but I cant seem to figure it out.

I hope someone can help me.


texts:
Typically grants are deleted by $nid whenever new grants are added.  In fact this function is baked into node_access_write_grants() (when $delete = TRUE).

I have been using custom GID's to represent different users's Address IDs ($aid).  When a user edits his/her address I want all the old grants with that GID/AID to be deleted but leave the grants on the particular node to be untouched.


texts: How to automatically generate multiple aliases for one node?

texts:
I'm using Drupal 7.22. I'm running four site versions in same Drupal installation.

eg:-

example.com/site1
example.com/site1

and its mobile versions:

example.com/mobilesite1
example.com/mobilesite2

I'm using URL aliases to meet the conditions. I have created patterns for each content type.
Suppose I have content type called site1_projects and  site2_projects, and created aliases for each site content type like site1/site1_projects and site2/site2_projects.

How can I automatically set an aliasing for these content type for mobile, like mobilesite1/site1_projects and mobilesite2/site2_projects?


texts:
I have a few data tables on my site. If I login as the admin and go to the page where the view of the table is located, I can click Edit Item and change that one entry. However, I can't find how to add new or delete entries that are there.

When I'm looking at my data table screen I can see this:

TITLE         - NAME         - NUMBER OF ROWS
Example Title - Example Name - 41             - View

However, when I click View, it basically just refreshes the page and doesn't let me view the table. This happens for all my tables. If I'm at the Data Table Management page, I can do everything that is listed there (edit the table itself, claim/disown, schema, etc), but there's no option on this page to edit the data in the table. It says I should be able to do that from the Data Table Content Page. I realize I can edit these entries directly from the database, but the hope is to give an admin user of the website the ability to manage this data table without giving them access to directly edit the database itself.

Any suggestions or possible alternative solutions that I could use?


texts: Random path for CCK fields inside form array

texts:
I have created a custom entity and i'm using CCK fields. Each bundle has it's own fields. For example:

function MYMODULE_install() {
  // Check if our field is not already created.
  if (!field_info_field('field_myField')) {
    $field = array(
        'field_name' => 'date_field',
        'type' => 'list_text',
    );
    field_create_field($field);
}

//Enable is executed only once.

function bundle_callback_enable() {

  // Create the instance on the bundle.
  $instance = array(
    'field_name' => 'date_field',
    'entity_type' => 'payment_method',
    'label' => 'Expiration Date',
    'bundle' => 'card',
    'required' => TRUE,
    'settings' => array();

  field_create_instance($instance);
}

My bundles are created from individual modules, so in each install file i am creating the respective fields.

Yesterday i tried to add validation callback functions in those fields and i saw something weird inside form array. Fields with type="text" had the path:

$form[field_name]['und'][0][value] // expectable

but fields with type='list_text' had only the path:

$form[field_name]['und'] // unexpectable

I couldn't find any solution and i've solved it with this way:

function &get_cck_path_value( $field_name, &$form_path) {

  $field = null
  if ( isset( $form_path[$field_name][LANGUAGE_NONE] )) {
     $field = &$form_path[$field_name][LANGUAGE_NONE]
  }
  elseif(isset($form_path[$field_name][LANGUAGE_NONE][0])) {
    $field =  &$form_path[$field_name][LANGUAGE_NONE][0]['value'];
  }
  return $field;
}

I don't like this approach. Is too hucky. Can you tell me if that is a cck feature or bug? I can't understand when it decides where to put the values( All the process is fulfilled through the "field_attach_form( ... )" )?

Have you faced any problem like this?

Thanks.


texts:
I'm wandering how and when the JPEG quality ratio (75% by default in admin/config/media/image-toolkit) is applied to the images.
1/ I suppose it is used a first time when the image is upload and scaled to feat the max width/height set up in the content type field. So, in case the original uploaded image already feats the max width/height, is it processed and compressed anyway or not?
2/ Then, I suppose this ratio is applied a second time when generating image styles at page load.
So this means that the resulting displayed image has been compressed two times with 75% quality loss (resulting ±56%). Is that it?
Thanks for your help.


texts: Drupal-to-Drupal data migration Taxonomy issues

texts:
I'm wondering if there is something special I need to do within the UI when using Drupal-to-Drupal data migration to actually get taxonomy terms to port over with all my nodes. I get an error that reads

  No matching taxonomy term found for source value '144' in vocabulary Topics.

I've created first level terms and ported over each term correctly, but what is the special thing I need to do to actually map the terms with the nodes? I've mapped the TID and yet it still doesn't work. Is there something special Im missing?


texts: How to list all available reviews for coder?

texts:
I am using drush with Coder (7.x-2.x) and I would like to know what are available options for reviews:

$ drush help coder
...
--reviews Run the specified review(s), "all" runs all reviews, also accepts a comma separated list (no spaces).

Where I can find them?


texts: Panels in-place editor shortcut won't appear from gear wheel

texts:
I use Drupal 7.34, and Panels module suit version 3.4.7.

The Panels in-place editor shortcut refuses to show up after I click on the gear wheel of a Mini-Panel...

Tried to reinstall, didn't help.
Tried to change Render mode from Default to "In-place editor" in the settings page. Didn't help.
Tried to clear cache afterwards. Didn't help.
No serious solution appeared in a Google search...

Is it bug?... What else can cause it not to appear?


texts:
I've uploaded a file in a custom form and I can retrieve the file instance like this:

  $fid = $form_state->getValue('file')[0];
  $file = File::load($fid);

How can I get the contents of the file?

kint(file_get_contents($file->url()));

Returns false. If I visit the link manually, it gets downloaded.


texts: Uploading changed Drupal content from production to server

texts:
I haven't yet setup version control (GIT) for my development and production environments as a result I am facing trouble syncing everything. My site is powered by Drupal 7.

For example, for a Content type that I created, what exactly is the folder on my development site that I should be uploading. And as far as the content type I created, what folder should I be uploading to the live server?

Another case is where I make changes to 'Text formats' found in admin -> configuration and a couple of other places in admin -> configuration, well, Not sure what folder I should be uploading either.


texts:
Actually this is first time to implement Ajax in drupal.
I would like to implement a user name validation using Ajax in user register section. When a user enter his name and filling another field, then validation is  running and if the user name already existing in the system, then a error message  shows, the user name is already taken.  I used to call the Validation function on "blur" event of Jquery.  The Jquery cod is below

$("#edit-name").blur(function()
{
$.post(Drupal.settings.basePath + "username_checking",{user_name:$(this).val()} ,function(data)
    {
if(data=='no') //if username not avaiable
      {
        $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
        {
          //add message and change the class of the box and start fading
           $(this).removeClass();
          $(this).addClass('messageboxerror');
          $(this).html('<img align="absmiddle" src="images/Error.png" /> Username Not Available...').show().fadeTo(1900,1);
          disable();
        });
      }
 }
    });
 }
});

and I implemented the function in a hook menu as below,

    $items['username_checking'] = array(
'title' => 'username_availability',
'page callback' => 'username_availability',
'access arguments' => array('access caubo_registration content'),
'type' => MENU_CALLBACK
);

and function is here

function username_availability() {
$user_name = $_POST['user_name'];
$select = "SELECT name FROM name WHERE user_name='%s' LIMIT '%d'";
$result = db_query($select,$user_name,1);
$node = db_fetch_object($result);
if($node->name = $user_name){
  return "yes";
}
else{
  return "no";
}
}

It shows the error in Firebud
POST http://localhost/WC/drupal_website/username_checking
403 Forbidden

I want to confirm is my method is right or not ? If right please solve the problem, or give the exact way to do.


texts: Overwrite the title for a particular taxonomy page

texts:
Can anyone help me on how to overwrite the particular taxonomy page title in Drupal 7?

Let us say I have 4 or more taxonomy page. I need the page title to for 3 pages and not for 1 page. If my url is http://localhost/drupal/companies/* the title should be overwritten as "Hello"; if the url is http://localhost/drupal/technology/* the default page title should  appear.


texts: Fivestar widget default on new comment field?

texts:
The Comment View admin panel allows me to set which of the Fivestar widget styles to use as the default to display for ratings in comments on a particular node, but the "new comment" form seems to not pick up that preference. Where can I set the display style for the "new comment" form field when it's being auto-inserted into a node?

Is this a bug in Fivestar that I should report (or a feature request to allow this customization)?


texts: Correct way of passing variables between hook and tpl.php

texts:
I asked a similar question a few months ago, but the truth is that there is very little information about the correct way of doing this.

The simplest way is to use the arg() function, but as the docs clearly state, that is the wrong way of doing it. While trying to follow the correct steps, this is what I have so far:

A menu with the necessary paths:

$items['products/search/%/%'] = array(
        'title'             => 'Products search filtering',
        'description'       => 'Show review categories.',
        'page callback'     => 'ThemeSearchProducts',
        'page arguments'    => array(2,3),
        'access callback'   => 'user_access',
        'access arguments'  => array('access content'),
        'type'              => MENU_NORMAL_ITEM,
        'file'              => 'includes/mymodule_reviews.inc',
);

These arguments are sent via ... arguments (sorry for the joke). to the themesearchproducts function

/**
 * THEME List of reviewable products
 *
 */
function ThemeSearchProducts($arg1, $arg2){

//  $output = theme('search_products', $arg1);
  $output = theme('search_products', 'test');

  echo 'args in theme: ' . $arg1 . $arg2 . ' || ';

  return $output . theme('pager', 10);
}

The echo works fine, but now the question becomes how do I send this variable to the hook_theme of the module, and from there to the tpl.php? I have something like the following:

function MYMODULE_theme ($existing, $type, $theme, $path) {
    $path = drupal_get_path('module', 'MYMODULE'); // . '/templates';
    // ADD THE templates DIRECTORY
    $path = $path . '/templates';

    return array(
            // as in 'theme('verbose_method',...)
            'main_reviews' => array(
            'template' => 'MYMODULE-main_page_reviews',
            'path' => $path,
            'variables' => array('forums' => NULL, 'topics' => NULL),
            ),

as you can see, the module now calls the tpl in templates/MYMODULE-main_page_reviews.tpl.php, but I cannot find the correct way to send a variable from  the previous callback to the hook_theme. Adding a new argument to the MYMODULE_theme throws an error, and I cannot get rid of it, not even by adding (for example) this new argument in ThemeSearchProducts, like this:

 $output = theme('search_products', 'test');

Is using variable_set also incorrect? I'm trying to follow the "Drupal Standard Practices" as much as possible, but this last step is eluding me.


texts:
I have been using ckeditor, with ckeditor drupal module with ckeditor 4.4.3 full edition. Previously, it was working fine and suddenly it was not working and it was showing blank text area in the body field as shown below.

I tried to re-install ckeditor module and library fields, but no change in the result. It appears empty, I couldn't trace the reason. How can I get to work with ckeditor.
Previously, my ckeditor was inserting span elements with a line-height of 1.6em in my paragraphs of text and I have no idea why.
The bottom shows body > p > span span span.  Spans with 1.6em line heights.
How can I resolve the issue??