texts: Add AJAX to form that was loaded through AJAX

texts:
I may be missing something really basic here but it has been bothering me for a couple of days now.

I have a page that basically contains a link which loads another page through AJAX. The page that is loaded is basically a simple node/add form for articles. The problem is that the form that is loaded does not contain any AJAX behavior (I even installed the AJAX example module and the simple ajax checkbox that it is adding does not work). I do not know if it relevant but the fieldsets in the node add form are not working either.

I did some research and I am suspecting that I need to do something on the AJAX callback that loads the form. I read about Drupal.attachBehaviors which I tried attaching to the element where I'm loading my form but it does not seem to be working.

I'd be happy to edit my question to add some code but I was wondering if I'm missing something really basic.

Edit (my current code):

PHP:

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

  $items['aforms/article'] = array(
    'page callback' => 'aforms_get_form',
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
    'delivery callback' => 'aforms_ajax_callback',
  );

  return $items;
}

function aforms_get_form() {

  global $user;

  module_load_include('inc', 'node', 'node.pages');
  drupal_add_library('system', 'drupal.ajax');

  $node = (object) array(
    'uid' => $user->uid,
    'name' => (isset($user->name) ? $user->name : ''),
    'type' => 'article',
    'language' => LANGUAGE_NONE,
  );

  $form = drupal_get_form('article_node_form', $node);

  return $form;

}

function aforms_ajax_callback($form) {

  print drupal_render($form);

  drupal_page_footer();

}

JS:

(function ($) {

Drupal.behaviors.aforms = {
    attach: function(context, settings) {
        $('body').on("click", "#load-me-up", function() {

            $('#target-container').load('/aforms/article', function() {
                console.log('Before attach behaviors executed');
                console.log(context);
                console.log(settings);
                Drupal.attachBehaviors();
                console.log('After attach behaviors executed');
                console.log('Drupal object:');
                console.log(Drupal);
            });

        });
    }
}

})(jQuery);


texts: I'd like to provide a form where anyone can submit a new job opening.  The goal is to allow anyone to submit a subset of fields for a jobs content type.  Once submitted, the site admin would come in and fill in the rest and publish the new node.  I've played with allowing anonymous access to create new nodes of the content type, but I just don't like the way the form looks and I don't want the user to see all the fields.  Is there a way to hide some fields and set the published marker to unpublished for anonymous users and protect the form with a captcha or is creating a custom form the way to go?


texts: Set default title by content type in Panelizer

texts:
Is there a way to set a default title per content type using Panelizer?  I see that you can use substitutions and change the title after you've created the content, but I would like it to use a specific substitution by default.

I know that I could use the autonode titles module, but I'd rather not add on more modules.  Any ideas?
-JB

EDIT:
Just to clarify, I want to use a substitution for the title (a field from the content type), and the reason I want to set the default is so my admins don't need to change it themselves.


texts: Sending multiple attachment files by email

texts:
I am trying to send multiple files attached to an email, but I can only make it work when only one file is attached. I am using mandrill mailer, btw.

Here is the code I have on a form submit:

    $attachments = [];
    if ($files) {
      foreach ($files as $key => $value) {
        $file = File::load($value['target_id']);
        $attachments[] = [
          'filepath' => $file->getFileUri(),
          'filename' => $file->getFileName(),
          'filemime' => $file->getMimeType(),
        ];
      }
    }

    $mailManager = \Drupal::service('plugin.manager.mail');
    $module = 'mymodule';
    $langcode = \Drupal::currentUser()->getPreferredLangcode();
    $params = [
      'subject' => 'Application from ' . $applying_user->get('field_first_name')->value . ' ' . $applying_user->get('field_last_name')->value,
      'candidate_name' => $applying_user->get('field_first_name')->value . ' ' . $applying_user->get('field_last_name')->value,
      'attachments' => $attachments,
    ];
    $mailManager->mail($module, 'email_application', $user_email, $langcode, $params);

Then using hook_mail():

 case 'email_application':
      $message['from'] = \Drupal::config('system.site')->get('mail');
      $message['subject'] = $params['subject'];
      $message['body'][] = buildBodyMail($params);
      $message['attachments'] = $params['attachments'];
      break;

The email I receive does not have any attachment, even though there are 4 files in this particular example meant to be attached.

If I change the code to:

    if ($files) {
      foreach ($files as $key => $value) {
        $file = File::load($value['target_id']);
        $attachments = [
          'filepath' => $file->getFileUri(),
          'filename' => $file->getFileName(),
          'filemime' => $file->getMimeType(),
        ];
      }
    }

...then it attaches only the last file of the set. It seems that

$message['attachments']

does not allow a multidimensional array. I've seen examples with

$message['params']['attachments'] = $params['attachments'];

and have tried but to no avail.

How can multiple files be attached to an email? Thanks in advance.


texts:
Our webshop (built in Drupal 7 and Drupal Commerce) gets bullied by a SPAMBOT which creates about 4000 orders a day. These orders are getting registered as created by 'Anonymous' (unchecked) and stay stuck in the 'Shopping Cart'
Apparently, the Spambot creates these orders by adding a product to the shopping cart on the product overview page (a custom built view with all products and for every product item  an Add to cart button).
Under each 'Add to cart' button, there's a hyperlink. We've already attributed a 'NOFOLLOW' link to those hyperlinks, but the issue still persists.

Our initial set-up for the 'add to cart' button for each product on the Product Overview Page was that people could instantly add a product to the shopping cart without first having to visit the product page.
On the other hand, we chose to offer customers the opportunity to pay as a guest. This, as well, to rule out as many stumbling blocks as possible during the ordering process, which may discourage customers.

Does anyone have a possible solution, preferably a solution that does not compromise the user experience (or has as little impact as possible on the UX?).


texts:
I work on D7, and create form from custom modules. Create a field upload images by
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['image'] = array(

'#type' => 'file',

'#title' => t('Upload picture'),

'#description' => t('Select a picture of at least @dimensionspx and maximum @filesize.', array(

  '@dimensions' => '1000x1000',

  '@filesize' => format_size(file_upload_max_size()),

)),

);

Show form correct.

and submit form by hook_form_submit();
print $form_state, upload images not find.
How to get values of upload image.

Write Also

$file = file_save_upload('image', array(
    'file_validate_is_image' => array(),
    'file_validate_image_resolution' => array('500x500', '100x100'),
  ), 'public://uploaded_images/', FILE_EXISTS_RENAME);

Not find of upload image.


texts: How do I create custom layouts for Panelizer?

texts:
I was wondering how do you create custom layouts for Panelizer in D8? In D7, I can easily create my layouts, and just add a couple of lines on my .info file to let Drupal know where my layouts are.
I created a custom module following a "How to create custom layouts using Layout Builder tutorial". Can I just change the dependencies in the info.yml file that's inside my custom layout module like this:
name: 'Custom Layout'
type: module
description: 'Provides a way for layout'
core: 8.x
package: 'Custom'
dependencies:
  - panelizer:panelizer

Thanks!


texts: Domain Access: Edit admin/domain/content/ display settings, filters etc

texts:
I am using Drupal Commerce and Domain Access module and I wonder where I could be able to edit how page admin/domain/content is displayed. I would expect to find a View page which is utilised by this module to show content and to allow to add filters and fields.

I have got a multi-domain site with thousands of products and I need to filter content by manufacturer or other field and to assign all products with desirable keywoord to selected domains.

Am I missing anything? I have not found any corresponding View.
Thank you for an answer


texts: How to test an exception have been logged instead of thrown?

texts:
I have the following code that throws catch an exption:

  public function deliverPrintable(array $entities, PrintEngineInterface $print_engine, $force_download = FALSE, $use_default_css = TRUE) {
    try {
      $renderer = $this->prepareRenderer($entities, $print_engine, $use_default_css);
    } catch (\InvalidArgumentException $e) {
      watchdog_exception('entity_print', $e);
      return FALSE;
    }
  }

The test below will fail because it's expecting an exception to be thrown:

  /**
   * Test that you must pass at least 1 entity.
   *
   * @covers ::deliverPrintable
   * @expectedException \InvalidArgumentException
   * @expectedExceptionMessage You must pass at least 1 entity
   */
  public function testNoEntities() {
    $print_engine = $this->container->get('plugin.manager.entity_print.print_engine')->createInstance('testprintengine');
    $this->container->get('entity_print.print_builder')->deliverPrintable([], $print_engine, TRUE);
  }

I took out the exception part of the method and left and just tested the returned value. But I would like to test that an exception have been logged is this possible?

  /**
   * Test that you must pass at least 1 entity.
   *
   * @covers ::deliverPrintable
   */
  public function testNoEntities() {
    $print_engine = $this->container->get('plugin.manager.entity_print.print_engine')->createInstance('testprintengine');
    $return = $this->container->get('entity_print.print_builder')->deliverPrintable([], $print_engine, TRUE);
    $this->assertFalse($return);
    // @TODO test that an exception have been logged?
  }


texts: Filter and display all commerce product sales by date in a block?

texts:
In my Commerce Order settings I have created a custom select list field with the following Allowed values.
Allowed values list

1|01/03/2013
2|02/03/2013
3|03/03/2013
4|04/03/2013
5|05/03/2013

Currently I can choose a date from a select list and that filters all sold products and gives me the result for that date.
I am able to separately filter all products sold for each date using views but
is there a way I can list the results of each date separately in a block?
Is this possible or do I have to add the field for each date and set the operator Is equal to the date for each date in my select list?
I would like the output to be something like this.
Event Date Sales

01/03/2013 Total: 210
02/03/2013 Total: 150
03/03/2013 Total: 621
04/03/2013 Total: 500
05/03/2013 Total: 142


texts: Is it possible to add PHP code in Global: Custom Text?

texts:
I have two links to redirect based on if a field is empty or not. Now I use the Global text setting to create a link for redirection with A basic <a> tag.

How can I add PHP code in a view to verify the field is empty?


texts: Is there a built-in "None of the above" checkbox option in webform? and how to create one?

texts:
I may be mistaken but I recall seeing such option in webform somewhere before and I don't seem to find it now (in case I'm right). (please see last edit)
I have several questions with big lists of checkboxes and if there's such option buil-in webform it would be great and better than having to do it via a custom jQuery code.
Thank you
EDIT:
This is a sample question with a
  mywfq:
    '#type': checkboxes
    '#title': 'Please chcek all that applies'
    '#options':
      q1: '....'
      q2: '....'
      q3: '....'
      q4: '.....'
      q5: '.....'
    '#attributes':
      class:
        - mywfq
    '#format_items': ol
  mwwfqnota:
    '#type': checkbox
    '#title': 'None of the above'
    '#attributes':
      class:
        - nota

In the above, I created a separate single checkbox element after the multi one and tried to use jQuery to uncheck all the above if this is checked but it's not working yet.
This is my code:
 $("input.mywfq).change(function() {
 $("input.nota").not(this).prop('checked', false);
  });

$("input.nota).on('change', function() {
$("input.mywfq").not(this).prop('checked', false);
 });

I'm still wondering if no already such built-in option!
EDIT: the great Webform team seems to have added the "none of the above" option to the module (x6 but not sure about prev versions).


texts: Why do only some of my hooks get called?

texts:
I made a test module and only a few of my hooks seem to get called. I get the Javascript console messages for the block_view, form_alter and form_user_login_alter hook functions when I do the corresponding actions. However, when I login, logout, view a node, create a node or delete a node I get nothing in the console. Shouldn't these hooks get called when I do those things? I reset my cache, disabled and enabled my module multiple times.
Here is the code for test_module.module:

<?php

function console_log ($stringIn) {
    print "<script>console.log('" . $stringIn . "');</script>";
}
function test_module_help ($path, $arg) {
    switch($path) {
        case "admin/help#test_module":
            return '<p>' . t("This is just a test module right now.") . '</p>';
            break;
    }
}
function test_module_insert ($node) {
    console_log("node inserted");
}
function test_module_user_login_submit (&$form, &$form_state) {
    console_log("login submitted");
}
function test_module_block_view ($delta = '') {
    console_log("block viewed");
}
function test_module_user_login (&$edit, $account) {
    console_log("user logged in");
}
function test_module_user_logout ($account) {
    console_log("user logged out");
}
function test_module_view ($node, $view_mode) {
    console_log("node viewed");
}
function test_module_form_alter (&$form, $form_state, $form_id) {
    console_log("form altered");
}
function test_module_delete ($node) {
    console_log("node deleted");
}
function test_module_form_user_login_alter(&$form, &$form_state, $form_id) {
    console_log("user login form altered");
}

Here is the test_module.info file:

name = Test Module
description = just a test module
package = ZZ Test category
core = 7.x

Those two files are in sites/all/modules/test_module/

What am I doing wrong?


texts: How to provide a custom option for an exposed filter in Views?

texts:
I have a site in which members can upload pictures of themselves (imagine a personals site).  Users can upload up to five pictures, and each time they upload a picture, a rule increases the value of a custom field, Number of pictures.

Members can search for other members using a view.  This view has a number of exposed filters.

What I would like to do is add another option, Show members with pictures only.  Ideally, this would be a checkbox.  However, I have no idea how to add such a thing to a view.  I could add the Number of pictures field as an exposed filter, but since this is an integer, users would have to type "1", which is ugly and unintuitive.  How might I start to go about this?


texts: Does views load all nodes in a result or just the ones in each page of results?

texts:
I am trying to determine if I am going to see a performance impact. I have a view that can possibly return thousands of results but only displays 50 per page. Each node in the result determines it's proximity to the current user using geofield. I want to know if it's going to try and do it for every node in the result, or just the ones in the current page.

So, does Drupal load all of the nodes in the results or just the ones in the current page?


texts: Entity reference in a content type for a taxonomy. Limit it to a single value

texts:
I have a content type. Lets' call it Events. For said content type I have a field(event_type) set as an entity reference to a taxonomy named Event Type.

I've set the limit on the field(event_type) to a single value.

However, visually, I can add more than one value as a comma separated list of values.

As far as I can tell the last taxonomy term is kept as the value.

This raises the problem that at some point in time somebody may very well add more than one thinking that all of them will be kept.

Is there a way I can visually limit the values entered? Perhaps a dropdown or radio buttons or something?

If anybody can point me in the right direction I'd be grateful.

Also, I've searched in the Drupal 8 know bug list, but quite frankly the list is huge and I can't find it.


texts: What is causing "Object of class stdClass could not be converted to string"

texts:
I'm receiving the following error:

Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2227 of includes/database/database.inc).

I've narrowed it down to this code but I am still able see what is wrong with the code, it worked before but now I am getting this recurring error.

case 'field_home' :
$tids =  field_get_items('node', $node, $key, $node->language);
$terms = taxonomy_term_load_multiple(array(), array('tid' => $tids));
// Gets Field Array Based on Term IDs
$name = array();
foreach($terms as $term){
$name[] = $term->name;}
$return[$key_clean] = $name;


texts: Create node and photo gallery during installation of Drupal 6

texts:
I want multiples Node installation with Primary and secondary links, and also want to create Photo Gallery While Installing Drupal.

Is it possible to install and create nodes during installation?


texts:
I have a project that I need to display some help text to the user if an autocomplete text comes back empty.

Right now, the autocomplete is on a custom form, and I'm using an autocomplete like:

function autocomplete($string) {
  $result = autocomplete_lookup($string);
  $matches = array();
  // Save the query.
  foreach ($result as $row) {
    // Perfom my logic rows here.
  }

  drupal_json_output($matches);
}

Is there a way I can run a check at some point in the process to display a pop up or something if the autocomplete doesn't return anything?


texts:
I have recently inherited a Drupal 7 site running on Pantheon.io
I have set up a local Drupal 7 server for a dev/test environment that is working flawlessly as a fresh install.
However, once I put the code, files, and database backups in place, my content appears, but there is no theme or CSS present, none of my links work, etc.

I have a feeling there is a simple fix for this, but I have exhausted my limited knowledge of this platform.


texts: Programmatically created nodes are not appearing under table 'nodes'

texts:
I have written a PHP script for the programmatic creation of nodes:

<?php

define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = "localhost";
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// Get a list of Office ID's
$office_ids = db_query('SELECT OFFICE_ID FROM sage.OFFICE');

// Loop through and edit each user
foreach($office_ids as $office) {

  // Create a new node object
  $node = new stdClass();

  // Set our new node content type
  $node->type = "office";

  // Set the node title
  $node->title = "Office " . $office->office_id;

  // Set the language
  $node->language = LANGUAGE_NONE;

  // Set the UID of the author of the node; or use $node->name
  $node->uid = 1;

  // Set node details
  $node->body[$node->language][0]['value'] = $bodytext;
  $node->body[$node->language][0]['summary'] = text_summary($bodytext);
  $node->body[$node->language][0]['format'] = 'filtered_html';

  $path = 'office-' . $office->office_id;
  $node->path = array('alias' => $path);

  if($node = node_submit($node)) {
    node_save($node);
    echo "Node with nid" . $node->nid . " saved!\n";
  }
}

When I run the above script, I can see my NIDs incrementing (and I assume this means my nodes are created), however when I go and check in the 'nodes' table in the database, I see nothing added.

Does anything know what could be wrong?


texts: Allowing users to choose between two sort options in a view

texts:
I have a view of user accounts.

I want to allow visitors to the site to choose to sortthis view by login date or by account creation date in a view (Views 3, Drupal 7).

It's easy to expose the sort operator to users, but is there a way to let users select which sort is applied first (creation date or login date)?

I thought about just cloning the view, and then changing the sort on the second view and linking them together, but if possible I would like to avoid duplication.


texts:
I have a view with an exposed "sort by" form.

I don't know how to skip this sort if the user did not chose any sort mode.

My view has this exposed sort widget and the second sort criteria (not exposed) is by node sticky property.
The problem is the view sorts the content by the first criteria, even though the user didn't chose something.

How can I change that?
Thanks


texts: Location module incorrect continent and country mapping?

texts:
I have a view listing the shops by geographical location. The shops content type is using location CCK field and the same is used in view to filter by continent and country as below, with a custom js script I have altered the view filters, continent and country to behave like a hierarchical select. This is working fine

However the continent and country mapping in location tables seem to be wrong. The country Cyprus and Turkey is expected to be in continent Europe but location module has preferred to have it under Asia. I ran the following query to find their relation in db.

SELECT * FROM location_continent_name cn,
  location_continent_country cc,
  countries_api_countries cac
   WHERE cc.continent = cn.code
    AND cc.country = lower( iso2 )
   LIMIT 0 , 250

When I looked at Wikipedia for Cyprus and Turkey, it says the countries in discussion belongs to Eurasian island country. I don't have much idea about this. I would like to have Cyprus and Turkey under Asia. I am afraid to edit the table rows as it might break any references. I would appreciate any help in this regard.

Thanks in advance.


texts:
What is the correct way to add a link to a menu? I am using Drupal 7 and admin menu module. I would like to add a link to the content menu item so it would be
Content

  Content
  Add Content
  Comments

I created a custom module and in the menu hook I put:

$items['admin/content/add'] = null;

Then in the menu_alter hook I put:

$items['admin/content/add'] = $items['node/add'];

Now the menu link appears where I want and when I click browser takes me to the admin/content/add but instead of showing the different options for creating node there's a text saying:
You have not created any content types yet. Go to the content type creation page to add a new content type.

If I go to node/add I can see the different options to add different nodes.

So my approach seems to be wrong. What would be the correct way of adding a link to existing path into admin menu?


texts:
When I have a Link title field populated with '&' it will be displayed as '&' when rendered.

I have done a fair share of google searching but haven't quite nailed it down.

I was thinking this was a start in the right direction https://stackoverflow.com/a/5019423

Drupal 7.19 with a zen subtheme

visual -

rendered http://imgur.com/JrBVRAx

on form http://imgur.com/nL0Xz6H

Any hints?


texts:
I am creating a Drupal Commerce website in which I have created 4 Product Types and 4 Product Displays as following

Health
Eye / Sunglasses
Contact Lenses
Sports

To classify the products I have created several vocabularies, some vocabularies are common in all product display types and some are available in one or two product display types.

Now I want to use default Taxonomy Term view provided by the views module and add those vocabularies as exposed filter in that but in the way that if Health Taxonomy page is being viewed it must show the vocabularies as exposed filter related to Health Only and so on


texts:
I have a content type Project with an entityreference user field field_project_team where you can assign users to the project.

I also have a content type Task with an entityreference field field_parent_project pointing to its parent Project and an entityreference user field field_responsible where you can choose one of users to be responsible for this Task.

I want the Task field options to include only those users who are mentioned in field_project_team of the parent node.

I've created a user type view  with entityreference display for this, where I want to filter users by their belonging to field_project_team of the project with nid from field_parent_project, but can't configure it correctly.

What i'm actually trying to do:
1) When you create a Project node, you can select users who will be a working team for this very project. I've already done it with a field_project_team - an entityreference user select list, which selects users with the role I need via user view with entityreference display.
2) You can create Task nodes for each Project. Each Task node should be connected to its parent Project. I'm doing it like this: on a Project node page I have a button "Add task" which opens Task node add page via the link like node/add/task/[xxx] (where [xxx] is a nid of the parent Project node). Then in the Task content type i have an entityreference field field_parent_project which is prepopulated from URL, so I can get the parent node reference filled automaticly when adding a new task.

All above mantioned works fine, but i try to achive one more thing:
3) When adding/etiting a Task node you should be able to assing this very task to some users to make them responsible for performing this task. In the Task content type I have an entityreference user select field called field_responsible where you can select users. But I want to see in this field not all site users, but only those who are already selected as a Project team - in the field_project_team of the parent Project. To get such a filtered user list I've changed the field_responsible settings ENTITY SELECTION mode to Views: filter by an entity reference view and created a user view with Entity Reference display called "Project team users" to filter users.

My problem is that I can't configure the display in a right way to get only those users I need, i.e. those who are already selected to be a Project team of a parent Project referenced from a Task via field_parent_project field.

This is my View display:

And some explaination:
1. A bridge to the Content entity that is referencing User via field_responsible
2. A bridge to the Content entity that is referenced via field_parent_project (relationship with Content referencing User via field_responsible)
3. Context filter via Content:Nid (relationship with Content referenced via field_parent_project)to get the Nid of parent Project
4. Was trying to add Content:Nid filter related with Content referenced via field_parent_project to filter by the Nid of parent Project.
5) "5" is a Nid of a test Parent project. The Project node with such a Nid exists on the site and some test Taks have reference to it as to parent Project.

In final, it doesn't work. I think I'm missing smth very simple with this but can't realize what... Will be very thankful for any help.


texts: How do you add fields to a user in Drupal 7 for say, first and last name? I see that Profile is deprecated, is there an easy way to do this without using Content Profile?


texts:
I'm using an Entityform to create a survey for a client, however one of the types of question they have is to rank a number of options in terms of importance to the user.

Similar to how the draggableviews module work would be the ideal, but I know that draggableviews changes the global setting for that list, rather than a per-user response.

Is there any way to achieve something like this?


texts:
This is the code:

$number->field_max['und'][0]['value'];

$array = array(
    "7mm Shorty over 7mm Jump" => 10,
    "7mm Shorty over 5mm Jump" => 14,
    "7mm Jump" => 13,
    "5mm Shorty over 5mm Jump" => 16,
    "5mm Shorty over 3mm Jump or 7mm Shorty over 3mm Jump" => 19,
    "5mm Jump" => 19,
    "3mm Shorty over 3mm Jump" => 20,
    "3mm Shorty over 2mm jump" => 24,
    "3mm Jump" => 24,
    "2mm Jump" => 27,
);

foreach ($array as $i) {
    $smallest[$i] = abs($i - $number);
}
asort($smallest);

$closest = key($smallest);

$suit = array_search($closest, $array);

$entity_field[0]['value'] = $suit;

$display_output = $entity_field_item['value'];

I want it to display the value closest to the number entered in the field_max field.


texts: PHP snippet won´t work: unset() a commerce checkout pane with custom module

texts:
This D7 snippet won´t do anything in my code and I don´t know why:

<?php
function mymodulename_commerce_checkout_pane_info_alter(&$checkout_pane) {
    foreach ($checkout_pane as $pane_name => & $pane_data) {
        if ($pane_name == 'commerce_p2cp_profile') {
            $order = commerce_cart_order_load($user->uid);
            if ($user->uid > 0) {
                    unset($checkout_pane['commerce_p2cp_profile']);
}}}}
?>

I´m trying to hide for registered users a specific drupal commerce checkout pane, created by the Commerce Profile2 Checkout Pane module, and this snippet won´t do anything.

I´ve created a module and enabled it.
After checking the module, I´m pretty sure that th pane is named commerce_p2cp_profile. And at the checkout configuration page the link is named that way, so I think that´s the correct name.

Maybe the problem is with $user->uid? Maybe it doesn´t take the current logged in user because global $user; is missing? Where should I add thet in that case? Inside the if(), or right after the function name?


texts: Drupal Views: Taxonomy Stripes for Calendar

texts:
I've got a bit of an issue with taxonomy stripes on Calendar.
If I wanted to define colour stripes for Content Types, I get this choice:

Simple. I just choose the type and add a colour.
However, I want to do it for Taxonomy. So I choose Taxonomy in the Stripes menu:

I successfully link it to the relevant taxonomy field, but I see no option for colour choice?

I'm using the most recent stable version of the calendar and the views modules.

How do I do this?
Is there another way?


texts: Can you create a view to display all files within a certain directory?

texts:
I have a Node Type A that is referred to by a bunch of other nodes. Within the nodes that are referring to Node Type A, there are various and separate CCK file fields. I have configured all of these files to be saved in a directory that is named with the title of each Node Type A (with the FileField Paths module)...so all of the corresponding files for a Type A node are in one place. I need to create a view that displays all of the files from the referring nodes in a sortable table. The problem that I'm running into, is that I have to add each separate CCK file field from an assortment of different node types to the view, which generates empty fields in the rows ouput.

So can I build a view that pulls the files from a specific directory on the server?


texts: How to get user data by providing user name or user profile field

texts:
I am using postman. I want to provide the username or a user profile field say roll no and fetch the user's information. What should be the URL.

I am able to fetch the user information when I provide the uid using the following URL :

http://[yourdomain]/[endpoint]/user/[uid]


texts: How do I conditionally load a png or a svg image?

texts:
We have two sprite images (svg and png) and one compressed CSS file. The compressed CSS files are added to the page as a library (see below) in our sub theme. Default behavior is to always load the sprite-svg CSS class on page load and use the Drupal Behavior to swap the sprite-svg CSS class with the sprite-png CSS class if the Browser is IE.

Are there any modules or alternatives to achieving the same functionality?

mytheme.info.yml (simplified version)

name: mytheme
type: theme
base theme: classy
package: Custom
core: 8.x
libraries:
  - netscout/sprite-css

mytheme.libraries.yml

sprite-css:
  version: 1.x
  css:
    theme:
      css/sprite-png.css
      css/sprite-svg.css
  js:
    js/sprite.js

sprite-png.css

.sprite-png {
  background-image: url('path/to/sprite.png');
}

sprite-svg.css

.sprite-svg {
  background-image: url('path/to/spring.svg');
}

sprite.js

(function($) {
  Drupal.behaviors.loadSpriteImage = {
    attach: function(context, settings) {
      var ua = window.navigator.userAgent;
      var msie = ua.indexOf("MSIE");
      if(msie > 0) {
        // If IE, then load PNG CSS class.
        $("body").switchClass("sprite-svg", "sprite-png");
      }
    }
  };
});


texts:
I want to print [entityInfo:protected] present in below image.

I am able to print all element except [entityInfo:protected] and [entityType:protected]


texts: form jquery events fired multiple times after using AJAX

texts:
Does anybody know how to avoid jQuery firing events multiple times after ajax has returned a form.

I have tried with .once() and i am still getting 3 click events from one click.

EDIT: this was my starting point

jQuery('.node_form .form-radio').live('click', function(event) {
  console.log(jQuery(this).attr('id'));
});


texts: How to checkout 2 carts at once like Etsy does on Commerce 2.x?

texts:
There are 2 stores, products from each store are added to cart, therefor there are two carts:

But how to checkout these 2 carts at once:

For example Etsy, clicking 'Proceed to checkout' will checkout the 2 carts at once.

maciej.zgadzaj's Commerce Marketplace module introduced a concept of order group for Commerce 1.x, so that multiple order can be processed together.

http://zgadzaj.com/commerce-marketplace-installation-and-use-cases:

  Marketplace introduces concept of an order group (adding a property of the same name to the order object),so that it knows which multiple orders need to be processed together:

Is there any idea or suggestion to process multiple orders at once for Commerce 2.x?


texts:
Is form date cached? I have an interesting bug on my site. There is a form for logged in users and it is used very frequently. Sometimes, after long time usage, some data doesn't change when it should (another node..). It looks like it is cached.

How can i disable this "form cache" or force form on creation to load new data, not cached (old)?

thanks


texts: How can I get links in Views Slideshow to link to different URLs than just one as defined in views?

texts:
I think I am a little closer to getting my links to work, but I am running into an issue that makes my link point to something like: /content/statshttp://lacrosse.college.edu/content/stats
I am trying to make it so that the maintainer of the website can just enter in the relative URL they want the link to point to.
I have included screen shots of two areas that I think may be causing this.

Thanks!


texts: Re-render current form in submit-hook under certain conditions

texts:
I have a form:

function _scratch_tests_for_users() {
  $current_user_number = current_user_number_from_session();
  $form = drupal_get_form("_scratch_forms_test_for_user", $current_user_number);
  return drupal_render($form);
}

With the form callback:

function _scratch_forms_test_for_user($form, &$form_values, $current_user_number) {
  $form["user"] = array(
    "#type" => "value",
    "#value" => $current_user_number,
  );
  $form["submit"] = array(
    "#type" => "markup",
    "#markup" => "Play number {$current_user_number}",
  );
  return $form;
}

And a submit callback:

function _scratch_forms_test_for_user_submit($form, &$form_values) {
  if ($form_values["values"]["user"]) > 3) {
    _store_some_stuff();
    return "ready";
  }
  else {
    //...re-render the form.
  }
}

In above example code, I would want to render that form three times, the fourth time, values should be stored.

Note that my actual code is a lot more complex and has more complex criteria then simply "the first three times"; just to avoid answers like "just copy-paste the form three times" :).


texts: How to load a node title of different language?

texts:
In my case the noads are stored in three different languages. How can add a condition, where I specify the language for the title that need to be loaded?

foreach($references as $reference){
    if($node = Node::load($reference->nid)){
      $url = Url::fromRoute('entity.node.canonical', array('node' => $node->id()))->toString();
      $link = ''.$this->t($node->getTitle()).'';
      $render .= '
'.$link.'
';
    }

Where $references is an array of nids.


texts: Conditional Fields Module works for 1 day then errors out

texts:
I installed Conditional Fields - version 7.x-3.0-alpha1 and everything was working fine. I left for the day and came back the next day to these errors showing on any of the conditional fields pages:

Notice: Undefined index: conditional_fields_dependency_add_form_comment_comment_node_page in drupal_retrieve_form() (line 765 of /var/www/vhosts/drupaldev/httpdocs/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'conditional_fields_dependency_add_form_comment_comment_node_page' not found or invalid function name in drupal_retrieve_form() (line 800 of /var/www/vhosts/drupaldev/httpdocs/includes/form.inc).
(The error log was too long to paste, see the full thing here: http://pastebin.com/ufY8U5by )

Now, the odd part is if I just disable and re-enable the module, the errors go away and I am able to edit the settings fine for about 1 day. Every time I leave work and come back, the errors have returned the next day.

I have also deleted the mod and re-installed which had the same temporary effect of working for 1 day. I also re-applied the permissions to the module folder which also made it work for 1 day.

Now, this site I have recently taken over and it has a lot of custom code spread all over the place already so I am not even sure where to begin to look. Something each night (I am guessing) is running on the site and causing this module to break. Some kind of nightly maintenance thing or such? Does anyone have any clue where I should be looking first to try and get this fixed?

Thanks!


texts: Views Megarows - Strange resizing in Internet Explorer

texts:
Recently I've encountered a strange error with using views megarows and internet explorer. If I click the link that displays the megarow content, in IE at least all of the sudden the webpage has lost half the browser window area. This is only being seen in IE, and not Chrome or Firefox.

I'm not sure what could be causing it. Here is a link to a screenshot of the visual error.

Any assistence in this would be appreciated, even if it is what to disable or enable.


texts:
I have a block module that looks like this:

Created in the following way:

function VL_newsletter_signup_block_info() {
  $blocks['my-block-id'] = array(
    'info' => t('Enjoy Stories? - Newsletter Signup'),
  );
  return $blocks;
}

/**
 * Implementation of hook_block_view().
 */
function VL_newsletter_signup_block_view($delta='') {
  $block = array();
  switch ($delta) {
    case 'my-block-id':
      //$block['subject'] = t('Block Name');
      $block['content'] = VL_newsletter_signup_contents();
      break;
  }
  return $block;
}

/**
 * custom html block
 * @return string
 */
function VL_newsletter_signup_contents() {
  return '

Enjoy stories?

Sign up to recieve regular news

    <form>
        <input type="text" name="first" placeholder="First name">
        <input type="text" name="last" placeholder="Last name">
        <input type="email" name="email" placeholder="Email" >
        <input class="send" type="submit" name="submit">
    </form>

';
}

At the moment my form is static HTML as can be seen, but I plan to use Drupal Form API to render it. My question is: on pressing send, how can I email the form data to a designated admin email address. Can I use triggers somehow or is there another function in Drupal API that could achieve this?


texts: One view per taxonomy vocabulary without a contrib module?

texts: What do I need to set in a D8 view, to have one view per taxonomy vocabulary without any contrib module?


texts: How to allow the banner to be editable via front end?

texts:
In the BlueMasters 6.x theme, the banner is hard-coded inside page-front-tpl.php:

  <?php //print $banner;?>

 Event One

 Event Two

 Event Three

      1
      2
      3

How can I expose the above banner div such that it reads from a particular page's (Full-HTML) content, instead of hard-coded. Such that the user can change the banner without FTP/SSH access.


texts: How to turn a menu tree into an associative array?

texts: I've dig into Drupal menu core to find out a way to build an associative array from a menu tree(eg,the account menu) so that I can output the data as json format. But it seems not possible to do this with Drupal 8. The info I need from a menu tree include title, description, url, and I also need to know whether it has sub menu and if it's enabled. All this can be easily achieved using menu_build_tree() function in Drupal 7. Please understand I tried the so-called Drupal 8 equivalent of menu_build_tree() (\Drupal::menuTree();) but it just gives me large object using which I don't know how to extract the data I need.


texts: Assign unique IDs to HTML elements via twig file

texts:
I have a "block--system-menu-block.html.twig" file, which prints the menu content into the menu.
{# Menu. #}
{% block content %}
  {{ content }}
{% endblock %}

However, I would like each menu item (the resulting
 elements) to get a unique ID.
For example:

abc

abc

...
The idea is that I can use that in my css to have different colors or hover colors for my menu items.
I have already achieved this with JavaScript on the front end, but I would rather have it done in the backend, in the twig files.
Is that possible?
If so, any ideas?


texts: EntityFieldQuery fieldCondition Date not working as expected

texts:
No matter what i try i cant get EntityFieldQuery to work i have a date and i need to check if it is between the start date and end date of a date field that is set to unlimited values.. it should be at least between any one.. here is what i got.. can anybody help me?

UPDATE 10/26/2016:
So from what I found doing some more googling to do what I want I need to use delta_group so I added it to the code below but it doesn't seem to be working. Anybody have any idea what I'm doing wrong?

    $myDate = date('Y-m-d H:i:s');
    $query = new EntityFieldQuery;
    $query->entityCondition('entity_type', 'node')
          ->entityCondition('bundle', 'caregiver_db')
          ->propertyCondition('status', 1)
          ->fieldCondition('field_available_dates', 'value', $myDate, '>=', 0)
          ->fieldCondition('field_available_dates', 'value2', $myDate, '<=', 0);

    $results = $query->execute();


texts: 403 Error - Unable to create Paragraphs via REST with ?_format=hal_json

texts:
Trying to add paragraphs via REST to the earlier created node.
I've installed the Paragraphs Type Permissions module, enabled the following permissions for my REST user's role

Text: Create content
Video: Create content

See: https://www.drupal.org/project/paragraphs/issues/3012600#comment-12851834
but still getting an error 403 and {"message":""} in response while trying to add some paragraphs to the node created earlier.
Error log:
Type        access denied
Date        Monday, December 28, 2020 - 20:40
User        restadmin
Location    https://drupal-8.site/entity/paragraph?_format=hal_json
Referrer
Message     Path: /entity/paragraph?_format=hal_json. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 120 of /var/www/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).
Severity    Warning
Hostname    77.139.170.139
Operations

Here JSON for the Text Paragraph:
   {
        "field_text": [
            {
                "value": text,
                "format": "full_html",
                "processed": text
            }
        ],
        "parent_id": [
            {
                "value": str(parent_id)
            }
        ],
        "parent_type": [
            {
                "value": "node"
            }
        ],
        "parent_field_name": [
            {
                "value": "field_paragraphs"
            }
        ],
        "type": [
            {
                "target_id": "text"
            }
        ],
        "_links": {
            "type": {
                "href": base_url + REST_TYPE_PARAGRAPH_TEXT
            }
        }
    }

Here JSON for the Video paragraph:
{
        "field_video": {
            "value": "video:" + str(video_id)
        },
        "parent_id": [
            {
                "value": str(parent_id)
            }
        ],
        "parent_type": [
            {
                "value": "node"
            }
        ],
        "parent_field_name": [
            {
                "value": "field_paragraphs"
            }
        ],
        "type": [
            {
                "target_id": "video"
            }
        ],
        "_links": {
            "type": {
                "href": base_url + REST_TYPE_PARAGRAPH_VIDEO
            }
        }
    }

What permission am I missing here?


texts:
I can't seem to get views attach to work in the theme I've created... is there maybe a line of code I'm missing that needs to be included in page.tpl.php for it to work?

Thanks!


texts: Can anyone please tell me, using very simple terms, how to add an image to the right sidebar?


texts: Custom Pricing based on anonymous customer input

texts:
Hi gurus and fellows,

I am a newbie at DrupalCommerce, though I have been designing website for a while using Drupal.

For our new project, we need to provide some custom pricing rules, based on user input. Anomymous user fills in a form, and, based on his input, we compute some special 'discount' (sort of).  Let me emphasize that user is not connected (registered), and its data is kept in session only.

As far as I know, we need to set up some "Pricing Rules", but to tackle my problem, I can only see "User has role" / "User is blocked" in the possible conditions, which address only logged-on users.

How you would you do that ?
Do I need to write up a custom rule ?

Any hints much appreciated.

Thank you.


texts: Node view mode in page template suggestions

texts:
I would like page template suggestions when a node is using a custom view mode.

I think this would happen in hook_theme_suggestions_page_alter().

I have already been able to get page-level template suggestions based on the node's content type, so it seems like I should be able to snag the name of the custom view mode?

I'm not good at this part of Drupal at all, so any help would be appreciated.


texts: How can I deploy an existing local site to Pantheon?

texts:
I have an existing local site that I've developed. In most "normal" instances, I would simply FTP the everything to the external host server, upload and install the database, and life would be good.

With Pantheon, it is frustratingly restricted. There appears to be no control over defining where Apache is configured to serve from. There are restrictions over file structure. And we can not SSH onto the server.

Pantheon appears to be a popular choice - but it appears that there is an assumption that a developer initiates the Drupal instance from Pantheon with all of its inherent configurations

Any experience actually creating a new instance of Drupal on Pantheon from an existing local environment?

BTW - their answer is to use drush ard to "archive the site".. unfortunately, ard is no longer supported (Drush 9.x).


texts: Use drush to download drupal core files directly into directory rather than subdirectory

texts:
When you use drush dl normally, it will download drupal into a subdirectory ie: drupal-7.16

I would like to skip creating the subdirectory and just install the drupal root directory files into the pwd or destination directory.  ie: /var/www/install.php

Can this be done with drush commands?

Other shell workarounds also welcome and will be considered for answer status if this is impossible with drush.


texts: Getting current node paragraphs content from block

texts:
I'm trying to build a block to insert on the side of the page that would list all "paragraphs" titles (from paragraph module) and link to them via an anchor (a little bit like the book module does but inside the same page)

For now i managed to get the list of paragraphs :

$node = \Drupal::routeMatch()->getParameter('node');
$paras = $node->field_paragraphes;

but can't get to the list of fields and their values inside that paragraph.
When i loop over them all i seem to get is an EntityReferenceRevisionsItem or at best an array like :

array (size=2)
  'target_id' => string '8' (length=1)
  'target_revision_id' => string '12' (length=2)

But i can't find their fields and values ?

Thanks a lot !


texts:
I have a menu in the original language English. Spanish is active in admin/config/regional/language . Custom menu link is active in admin/config/regional/content-language . I now have a Translation tab in admin/structure/menu/manage/mymenu/translate. I click Add in the Spanish row, change the label and Description (only Description is sufficient). Then what?
How do I add menu items to the now supposedly created Spanish version? I tried several things but could not figure out where this new (empty?) Spanish menu is? It would be logical and consistent when now an "Add link" button would also appear in admin/structure/menu/manage/mymenu/translate/es/edit like in admin/structure/menu/manage/mymenu.

What is missing is some simple help text right in the forms that guide our thoughts in the right direction. For instance what is the purpose of the "Menu language" select box? Is that to change the language of the whole menu? But wasn't the language fixed already at creation (the default language)? I could not find a decent explanation so I resort to the help of somebody who managed to got it working.


texts:
I've already looked at this answer and tried to change the search index view so that when I ran a search, I could type in a word appearing in a summary it would appear in my search results. I also ran cron to get the site reindexed but still, nothing appears when I type in a word that only appears in a summary.
How do I make the summaries in content searchable?


texts: Ok, I'm building a custom module that has content type that is webform enabled. When creating a node of this type, I need to automatically create one webform select field when node gets saved. How can I achieve this? The goal is that all webforms have this field when they're created, rest are user created.


texts: Showing Error while insertion of data in database, Drupal 7

texts:
I am new to drupal, and i am trying to insert data in database from form using Database API.
But its showing an error. That error is given below:

PDOException: SQLSTATE[HY000]: General error: 1364 Field 'x1' doesn't have a default value: INSERT INTO {members} (first_name, last_name, email, username, password, country) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => Ravneet [:db_insert_placeholder_1] => Singh [:db_insert_placeholder_2] => rvtsingh@gmail.com [:db_insert_placeholder_3] => rvtsingh [:db_insert_placeholder_4] => 123456 [:db_insert_placeholder_5] => India ) in form_test_form_submit() (line 63 of C:\wamp\www\Biding\sites\all\modules\own\form_test\form_test.module).

The code I used in module file to create code and insert in database is :

<?php
function form_test_menu() {
  $items['formtest'] = array(
    'title' => 'Sign up',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('form_test_form'),
    'access callback' => TRUE,
    );
  return $items;
}

function form_test_form($form, &$form_submit) {
  $form['firstname'] = array(
    '#title' => t('Firstname'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );
  $form['lastname'] = array(
    '#title' => t('Lastname'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );
  $form['email'] = array(
    '#title' => t('Email'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );
  $form['username'] = array(
    '#title' => t('Username'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );
  $form['password'] = array(
    '#title' => t('Password'),
    '#type' => 'password',
    '#required' => TRUE,
  );
  $form['country'] = array(
    '#title' => t('Country'),
    '#type' => 'select',
    '#options' => array('India' => 'India', 'Pakistan' => 'Pakistan', 'USA' => 'USA', 'UK' => 'UK', 'China' => 'China'),
    '#required' => TRUE,
  );
  $form['submit'] = array(
    '#value' => 'Submit',
    '#type' => 'submit',
    );
  return $form;
}

function form_test_form_submit($form, $form_submit) {

  global $user;
    $user = db_insert('members')
    ->fields(array(
        'first_name' => $form_submit['values']['firstname'],
        'last_name' => $form_submit['values']['lastname'],
        'email' => $form_submit['values']['email'],
        'username' => $form_submit['values']['username'],
        'password' => $form_submit['values']['password'],
        'country' => $form_submit['values']['country'],
    ))
    ->execute();

    drupal_set_message("You have registered successfully.");

}

Please help me to resolve this error. Thanks in advance.


texts: How to not show a comments field if user logged in

texts:
I have a field called 'email' I added to my node comments form. However I don't want this to display to users who are logged in. What's the best way to hide this field for logged in users?

I created a module 'hideemail.module' (and info file) with the following code, and flushed caches multiple times...but it's still not working. Note: I double-checked the form name with Firebug and the field name in the resource content type > comments fields.

From hideemail.module (and yes its enabled):

 <?php
 /**
 * Implements hook_form_alter().
 */
function hideemail_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  if ($form_id == 'comment-form' && $user->uid != 0) {
    $form['field_email']['#access'] = FALSE;
  }
}
?>


texts:
Using this tutorial Drupal Console's drupal gprr command, I've created a custom REST resource in Drupal 8. I'm able to use this resource to retrieve a simple JSON object that says hello to the current user by doing a GET on:

http://localhost/example/hello?_format=json

The JSON returned then looks like this:

{ "hello": "tyler" }

This is to be expected, as I'm logged in. But when I logout, and do another GET on the resource, the same result is returned:

{ "hello": "tyler" }

Doing a full Drupal cache clear fixes this issue, but I'd like to specifically disable caching on this resource. How can I do that?

As a workaround, I thought adding a time stamp to the query string would work:

http://localhost/example/hello?_format=json&time=123456789

But that also returns the exact same result, no matter what time stamp value is in the query string.

For brevity, here's the skeleton code for building the GET resource:

class ExampleHello extends ResourceBase {

  /**
   * {@inheritdoc}
   */
  public static function create(/* ... */) {
    return new static(/* ... */);
  }

  /**
   * Constructs a Drupal\rest\Plugin\ResourceBase object.
   */
  public function __construct(/* ... */) {
    parent::__construct(/* ... */);
    // ...
  }

  /*
   * Responds to GET requests.
   */
  public function get() {

    $account = \Drupal::currentUser()->getAccount();
    if (!$account->id()) {
      return new ResourceResponse(array(
        'welcome' => 'visitor'
      ));
    }
    return new ResourceResponse(array(
      'hello' => $account->getAccountName()
    ));
  }

}

Is there a configuration/setting I need to set on this plugin to disable caching on GET requests?


texts: Hiding an image field based on theme in Drupal 7

texts:
I want to hide an image field(field_image) of a node when a different theme is selected.

How can I do it?

I'm not able to find any sample code in internet but I know it can be done both in tpl.php and template.php files.


texts: How to display webform multiple results in a table rather than a list

texts:
On the webform page itself (data entry), it's possible to instruct a composite element that allows multiple values to "Display elements in table columns" (under Build » Advanced » Multiple Settings).
What is the best way to do the equivalent on the preview or results output pages?


texts: How can I limit views results based on the value of two fields?

texts: I may have to do this programmatically, but I was wondering if there's another way in the UI. Basically, I have a list of articles with Volume and Issue fields. I want the view to only show articles that are in the latest Issue of the latest Volume. I've been trying with aggregation settings and sorting, I can get the articles grouped, but I can't limit to just the latest. To complicate things, I'd also like to group the results by a Type field.


texts: How to share session variables across Drupal sites?

texts:
On my main Drupal site, users need to be able to select a display preference (e.g. 'high visibility'). This will be available to registered and anonymous users but only for their session, so I plan to store their preference in a session variable:

$_SESSION['display'] = $my_preference;

Another Drupal site runs on a subdomain of the main site, and needs the same functionality. And if the user visits both sites, it would be great to remember their preference.

I think that if I uncomment this line in both site's settings.php, session variables can be accessed across sites on the same domain?

$cookie_domain = 'maindomain.com';

So then I could set $_SESSION['display'] on one site, and retrieve $_SESSION['display'] on the other?

Also, one site is D6 and the other D7 - will this be a problem? Is caching for anonymous users going to cause problems?

Am I on the right lines, or is this plan flawed? Thanks


texts: States don't work for a block rendering a form

texts:
I created a block in which I called a form inside the build() function.
The form class has elements like radio button, input field type number, and submit button. I added a state condition to make the number field and submit button only visible on a certain condition of radio button.
The submission button is working correctly based on state condition, but not the number input field.
Does anyone has any idea?
$form['age'] = [
  '#type' => 'number',
  '#min' => 0,
  '#title' => $this->t('age'),
  '#default_value' =>'',
  '#states' => [
    'visible' => [
      [':input[name="marital_status"]' => [['value' => 'single'],['value'=>'couple']]],
    ]
  ],
];

$form['mybutton'] = [
  '#type' => 'submit',
  '#value' => $this->t('button'),
  '#states' => [
    'visible' => [
      [':input[name="marital_status"]' => [['value' => 'single'],['value'=>'couple']]],
    ]
  ],
];

$form['marital_status'] = [
  '#type' => 'radios',
  '#title' => $this->t('Marital status'),
  '#options' => [
    'single' => $this->t('single'),
    'couple' => $this->t('couple')
  ]
];


texts:
pls I want to control a file access to download, a user will download the file only if a test condition is true. .... there is going to be an execution of a callback url from an external site, and my site will receive a signal then will unlock the file, so I use my site IP address as a test condition... if Server_remote address of my site is = the $external callback IP address, then....unlock the file, how do I proceed on that?

if you have a better idea of implementing this, let me know too.

cheers,


texts: in views, how to get the replacement pattern of the URL of the link field

texts:
using the Link module, i have created a view of content fields:

Link
Title
Body

And i want the Title to be a clickable link to the URL of the Link field.
In D7 the links field provided for a replacement pattern for the URL as raw value but in D8 that is not available.
How can I make the Title field a clickable link with the Link URL?


texts: D7 forms: select values from a select list when a checkbox is checked using ajax

texts:
In a node form I have 2 fields, the first one consisting in a list of regions, the second one consisting in a list of countries.

The needed behaviour is that when I click (let's say) "Africa" from the first list, all the countries belonging to Africa in the second list have to be selected.

This is the code in the hook_form_alter():

//add wrapper to the countries field
$form['field__country_multi']['#prefix'] = '
';
$form['field__country_multi']['#suffix'] = '
';

//add ajax behaviour to the regions field
$form['field__region_multi'][LANGUAGE_NONE]['#ajax'] = array(
    'callback' => 'preselect_countries_callback',
    'wrapper' => 'multicountries',
);

This is the callback function:

function preselect_countries_callback($form, $form_state) {
    //this returns an array of keys, I'm sure its structure is correct because
    //if I put it directly in the form_alter the values are pre-selected correctly
    $africa = get_african_countries();

    //setting the #default value to the countries field. I tried even without
    //the LANGUAGE_NONE just because I ran out of ideas
    $form['field__country_multi'][LANGUAGE_NONE]['#default_value'] = $africa;

    //I tried even without the render() function wrapping the field object.
    return render($form['field__country_multi']);
}

What happens is that the wrapper is refreshed, but I noticed by inspecting the output that drupal is changing the id of the countries select list (from 'edit-field-country-multi-und' to 'edit-field-country-multi-und--2') and I guess that's why the values aren't being selected.

Any help would be very much appreciated.
Thanks!


texts: Is there a way to add a hashed link in the menu under drupal menu to just make a menu item that jumps down to an anchor or id on the page?


texts:
I am developing an e-learning portal for a client; the client wants to be able to create quizzes and view the results of individual students, and probably draw a graph to give an overview of student performance. I am using the Quiz module to create quizzes.

The "quiz score" is not available if you use node as the view base or quiz.

I am able to list username, level, and quiz.


texts: Outbound url query token is breaking AJAX callbacks

texts:
I am running into a strange situation that I don't really understand. I am appending a query token to all outbound url query strings using hook_url_outbound_alter().

function mymodule_url_outbound_alter(&$path, &$options, $original_path) {
  $options['query']['token'] = 'sometoken';
}

It is my understanding that $options is passed by reference and can be modified in place. According to the url() documentation, the query option should be a key/value-pair. So I believe I am doing this right.

The strange thing I am noticing is that I am seeing this in my logs.

  REFERRING PAGE:
  http://example.com/node/1?token=sometoken

  LOCATION: http://example.com/?q=masquerade/autocomplete&token=sometoken/b

I somehow get the idea the b (my input in the ajax field) should have been appended to the q and not to the token query parameter.

So I have thought of two possible solutions, but have so far failed to implement any of them:

Remove the url token on AJAX links (but there is no way to tell if a link is an AJAX link).
Change the order of the query parameters in hook_url_outbound_alter by removing and re-adding the q query token.

if (isset($options['query']['q'])) {
  $q = $options['query']['q'];
  unset($options['query']['q']);
  $options['query']['q'] = $q;
}

Does anyone have another idea on how to fix this?

Update

In fact I think this cannot be fixed with method 2 due to the following code from the url() function.

// Without Clean URLs.
  else {
    $path = $prefix . $path;
    $query = array();
    if (!empty($path)) {
      $query['q'] = $path;
    }
    if ($options['query']) {
      // We do not use array_merge() here to prevent overriding $path via query
      // parameters.
      $query += $options['query'];
    }
    $query = $query ? ('?' . drupal_http_build_query($query)) : '';
    $script = isset($options['script']) ? $options['script'] : '';
    return $base . $script . $query . $options['fragment'];
  }

So any other ideas?


texts: How to add a new line item to existing recurring order?

texts:
I've managed to get new line items added to a recurring order using hook_commerce_license_billing_order_refresh_alter() and the code is:

$product = commerce_product_load_by_sku($sku);
$li = commerce_product_line_item_new($product, '1');
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_needs_save = TRUE;
commerce_line_item_save($li);
$line_items[$li->line_item_id] = $li;

It adds line items and correctly calculates new total and shows on the recurring order page. However, since this is a refresh hook it keeps creating new products, line items and licenses on every refresh. So I tried to attach already created line items the order's data array:

// Add line item objects to order data.
$order->data['lis'][] = $li;
// Add sku to order data.
$order->data['skus'][] = $sku;

and then re-use it with:

if (!empty($order->data['lis'])) {
        foreach ($order->data['lis'] as $key => $li) {
          $wrapper = entity_metadata_wrapper('commerce_order', $order);
          $order_needs_save = TRUE;
          $line_items[$li->line_item_id] = $li;
        }
      }

but, unfortunately, the new line items do not show on the recurring order. If I add commerce_line_item_save($li); line, then the website crashes giving:

EntityMetadataWrapperException: Unable to get the data property line_item_id as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 457 of /home/username/public_html/sites/all/modules/entity/includes/entity.wrapper.inc).

So my question is: how I should properly add new line items to existing recurring order?


texts:
i have a certain problem regarding a content type and a "supervisor" role for it.

For the content type (which unfortunately did not create it myself but found it on an ongoing project), i have created a certain role (lets say "Supervisor" ) which shall give access to each user to "editing own content". Since all the content in this content type are created by the admin, for test purposes, i changed the author of a node from "Admin" to "user_1", and then later loged-in as "user_1" to edit the node, but no luck.

I tried several other alternatives, such as "content access" module, "create new content" permission, flexi-acces module, but nothing worked.

Whenever i try ../node/xxx/edit, it displays the node and not the edit screen.

Any ideas why this happens?

** i gave the "edit all content" permissions to the role, and the user could edit all the profiles (obviously) - i just wanted to check if everything works ok with the roles **


texts:
I've created a module that adds custom content to a node; I'd like to display this custom content in the node view. I think hook_node_view() is the right hook to use, but my content doesn't get displayed.

what I got so far is the following code:

function mymodule_node_view($node, $view_mode = 'full', $langcode = NULL) {
$node->content['mymodule']['#items'][0] = array(
    'value' => theme('mymodule_output', array('mymodule_cid' => $node->mymodule_cid)),
    'summary' => '',
    'format' => 'full_html',
    'safe_value' => theme('mymodule_output', array('mymodule_cid' => $node->mymodule_cid)),
    'safe_summary' => '',
);
$node->content['mymodule']['#weight'] = 12;
}

Can anybody help?


texts: Can nodes created using Feeds be updated automatically?

texts:
The Feeds documentation mentions that it's possible to import a CSV feed and create nodes from it, assigning column values as CCK fields, but it doesn't mention if it's possible to update nodes when those values change in an updated feed. Is this possible to do using Feeds or an additional module?

For example, a feed is downloaded in week1, creating a node for a Red Widget. Its price is £10.

In week2, the feed is updated with a new price of £12 for the Red Widget.

Can the node initially created be updated with that new price without importing a new or duplicate node?


texts:
I'm trying to automatically add prefixes to uploaded file names so they can later be processed by non-drupal scripts. I want to do that while the user is uploading files during creation/editing of a node.

To do that I am using hook_file_validate($field) where I check if the file is correct and then using $field->destination I define a new file name.

Surprisingly my issue lies in getting context to generate the proper file name (nid of the node,nid of the parent group, or info from other fields). When I upload a file, only part of the website is reloaded by javascript and hook_file_validate is triggered before hook_form_alter . Whene it is triggered I have no access to any data that would tell me where am I.

So far I have tried:

$_REQUEST['destination']

while defined (not a typo) when the whole form is loaded, it is undefined when the file field of the form is reloaded

$_GET['nid']

again - undefined

arg(0); arg(1); arg(2);

returns file ajax field_quest_file
which is not very usefull

I can access uid but it is not enough for me to create unique file names.


texts: Civicrm membership expiration date after renewal

texts:
I'm using D7, with CiviCRM 4.4.6. I had created a contribution page, with membership form included.

By now after renewal membership, the expiration date extend according to the end date. Eg:

Start Date: 1 Nov 2014
End date: 5 Nov 2014
Status: Expired

If renewal payment made on 11 Nov, for one month, the expiry date is changed to 5 Dec 2014.

But I want the expiry date to be one month after payment date, which is 11 Dec 2014.

Is there any way I can configure it to get the above result?

If not in configuration, any way I can change it in codes?


texts: Copy data of Email in registration to the username not showing in the registration page

texts: I want to copy the value of email to the username, which is not showing in the registration page, but it is showing in the /user/edit page as Display Name, which is randomly generated such that my username is my email, giving more flexibility to the user.


texts:
I have a problem in Boost module
I have a dynamic site that Allow user to logged in to edit his content

after log into the site the login links disappear and another links loaded that contain user links (I use a custom block that check if user_is_logged_in echo you content else echo sign in)

but after installing boost the menu of login still appear after registration (still read the caching page)

is there any option that  make pages to anonymous user only

This is my code

function login_block_info() {
    $blocks = array();
    $blocks['mylogin'] = array(
        'info' => t('Custom Login'),
    );
    return $blocks;
}
function login_block_view($block_name = '') {
    if ($block_name == 'mylogin')
    {
        $output ="";
        if(user_is_logged_in())
        {
            global $user;
            $query = "select nid from node where uid = " . $user->uid;
            $result =db_query($query);
            $nodes = array();
            $output ='
';
            if(count($result)>0)
            {
                foreach ($result as $node) {
                    $alias = drupal_get_path_alias('node/'.$node->nid);
                    $output .= '
'.l($node->title,'node/'.$node->nid.'/edit').'
';
                }
            }
            $output .= '
'.l(t('Change password'),'user/'.$user->uid.'/edit').'
';
            $output .= '
'.l(t('log out'),'user/logout').'
';
            $output .= "
";
        }
        else
        {
            $output .='

log in

sign up

';
            $output .= render(drupal_get_form('user_register_form'));
            $output .= '
';
        }
        return array(
            'subject' => t(''),
            'content' => $output,
        );
    }
}

thanks


texts: Repository module code completely different from downloaded file

texts:
Using the Drupal Soundmanager2 module that hasn't been updated in about three years. Added a little functionality and want to submit a patch.

I think this can be done via git:

git clone --branch master http://git.drupal.org/project/soundmanager2.git

but the files shown in the tree that are in the download zip file are completely different from what's in the git repository.

Am I missing something here?


texts: Drupal 7 UberCart Volume Pricing with Role Based Pricing Support

texts:
I have scenario where the default UberCart  Volume Pricing should support user role based pricing.

Fox example : If I have a product, it pricing has to configured in such a way that

For  user role 1 - with minimum of 'x' quantity - its price has to be some '$a'.

For user role 2 - with minimum of 'y' quantity - its price has to be some '$b'.

In short, I am satisfied with the functionalities of these both modules (Ubercart Volume Pricing, Ubercart Price Per Role) individually and would like to combine the functionalities of these both.

If anyone have solution for this, can you please share it?


texts: How to add a translation to an existing node/entity using REST?

texts:
I have a headless Drupal 8 and want to create a translation for an existing NODE using a POST request but cannot figure how to.
I know how to create, edit and delete a node but am unsure on how to add a translation to an existing node. If I add the langcode it creates a new node in that specified language but I want a translation for an existing node ID.
Please advise.


texts:
I just installed Drupal 7 again on my cheap shared host. The installation went fine... I copied the 1098 files via FTP and installed it within 2 minutes. The standard installation (with all modules in the core) took about 5-10 seconds. After installing, the site runs well. It's a cheap hosting, so sometimes it's a little slow, but it's acceptable.

Yesterday, I've installed the new Drupal 8 (which is why I installed Drupal 7 today to compare). The first thing I noticed are the number of files: 12327. I understand modules like Views are included in the core now, but an increase of the number of files of over 10 times seems a little odd to me.Is there another reason for this?

Once I copied all files, I've tried to install Drupal 8. What a nightmare. The installation page takes up to 20 seconds to load. When I want to start the installation, I'm getting a notice OPcache is not enabled in PHP. Is this the reason for the slowness? Is there an alternative available?

Continuing the installation, I'm getting random errors. Searching for them on Google doesn't help getting me more information. Something about a fixed bug months ago, that's all I could find. I had to restart 3 times before the installation succeeded.

The biggest issue is the performance. Installing all these modules during the default installation took about 5-10 seconds in Drupal 7. It took about 20-30 minutes in Drupal 8. Okay, some more modules are included now, but this seems very odd. As I had to retry 3 times, it took me about 2 hours just to install Drupal 8. After installation, it was unusable slow, so I had to remove the whole installation.

I'm wondering if someone knows more about this issue. Does Drupal 8 require like 20 times more resources than Drupal 7 to run properly? Or is all of this because of the missing OPcache? Am I the only one with this issue?

Any advice would be welcome as I'd like to try the new features. Drupal 7 runs perfect on my cheap hosting, but Drupal 8 is a real nightmare.

I'm not sure what other technical information might to relevant to find/resolve this issue.


texts: An error which appears in Autocomplete taxonomy fields

texts:
Did someone ever note this annoying D7 taxonomy error? It jumps out when I seem to "pass" a certain amount of terms or characters. The error is as follows:

  An AJAX HTTP request terminated abnormally. Debugging information
  follows. Path:
  http://pancherim.co.il/taxonomy/autocomplete/field_engines StatusText:
  ResponseText:  ReadyState: 4


texts: Attached view ajax call (lazy load) with exposed filters

texts:
I'm using views with a main view and an attachment to put 2 views on a single page. Each view is in it's own Bootstrap togglable tab. Because I don't know how many people will actually switch to the non-default tab, I'd like to wait to load that view until it's needed, then load it via ajax.

Is there any way to do this within the Views UI, or is it time for custom coding? This post is kind of old, but is that the best method for executing an ajax call to render a view?

Edit: A complicating factor is that I need to include exposed filters, which also need to fetch the data via Ajax. Right now, the filters work with the second tab, but not the first. I believe this is because Quicktabs creates multiple sections with .view-dom-id-<settings.view_dom_id>, which is the selector used in Views js/ajax_view.js.

Any solutions that work with exposed filters and Ajax?


texts: Create a new Menu in Drupal 8 programmatically

texts:
Is it possible to create a new Menu in Drupal 8 programmatically using a custom module?

I am creating a custom module, and one of the requirements of the module is that it creates a new menu under Structure > Menus.

Most of the tutorials teach how to add a menu link to an existing menu. For example, Creating menu links, Add a menu link, etc.

In short, I need a way so that the end result is a menu below "User Account Menu" in the image, and then I can add my menu links to it, using above tutorials.

Thanks.


texts: Best practice for language key for "und" in hook_form_alter

texts:
I'm modifying in a form in my custom module. Code looks like:

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

    if ($form_id == "someID") {

        $form['field_charity_author']['und'][0]['value']['#value'] = arg(3);
        //$form['field_charity_author']['#type'] = 'hidden';

    }

}

However, I think hard-coding und is bad. What should be the proper way to modify form fields properly in this case?


texts: FAQ page access denied for anonymous users

texts:
I've installed the FAQ module and created some FAQ content. The FAQ page is found here: http://www.inadaydevelopment.com/faq-page

I have given Anonymous users the "View FAQ pages" permission, but anonymous users still cannot view the FAQ content of the above page. It shows the header block which I configured to appear only on that page, but the body of the page shows Access Denied.

What am I missing?


texts: Multi step form with click and state logging in Drupal 7?

texts:
I need to create two separate forms flows. Essentially the one case has 3 pages (intro, questions, thank you), while the other has 4 pages (intro, questions, questions, thank you). I want to be able to:

Log the states of each "step" as the user proceeds
Keep track of where the user clicks and in what sequence

I am thinking of doing the second part with Google Analytics, as I know it has ways to do this. However, I am not sure what is the best way to go with the multi step form process.

So far it sounds like I would have to create content types for each step and use rules to "guide" the user as he creates the different content types. However, this sounds like a nightmare when it comes to "back" and 'next" functions.

Can anyone please tell me what is the best way to implement a form like this, keeping in mind how important it is that the logging works perfectly.


texts: View: Link to content is always rendering in the default language

texts:
I have a View that is list of a content type using fields. (I am also using a Relationship and a Contextual Filter, btw.)

One of those fields is "link to content".

The content type is translatable. The View is filtered by Translation language (= Interface text language selected for page). In my secondary language (German) only nodes with a translation are shown. So far, so good.

The rendering language is set to: Interface text language selected for page.

However, the rendered rows always link to the default language (/en), even when the rest of the page is rendered in the secondary language (de).

What can I do to get the rows to render the links in the correct language?


texts: How do I handle a site with subdomain using the Domain Access module?

texts:
I have a site which as a federal level and a subdomain by state. I'm using Domain Access module which works great for some basic things such as contents by domains. But I've got other challenge to solve and I didn't find any solution for it.
I would like :

The states to be able to have their own menu. I tried the Domain Menu Access module but it didn't fit my needs since it does not enable each state to fill his own entries of the menu.
For example the federal menu could be : Presentation, Federal item 1, Federal Item 2 whereas state menu would be Presentation (same page as Federal menu), State item 1, State item 2.
The states to be able to enrich some kind of content written by the federal site. Let's say I've got a content type name Presentation Page. I would like, for a given Presentation Page content, each state to be able to add a text field to complete the content of the base material.
The domain access checkboxes to be prefilled with the current domain AND the main domain on some content types. Some content should be presented on the federal site but filled by states and I would be great to avoid having to check the main site checkbox for each content created.

I didn't find any modules or any way to achieve those goals. Do you have any solution ?


texts:
I am using a subtheme from the Neato theme (in Drupal 8) and I am customizing page.html.twig.

Yesterday I performed a logout, and now I want to log in again, but the login form has disappeared.

How do I add the login form in page.html.twig? Do I need another html.twig file?


texts: How add a paragraph field to a form programmatically?

texts:
I'm on Drupal 9. I am creating a custom block programmatically with some fields in the configuration form.
However, I need to add a paragraph field and I've found no documentation\working way to do so.
Anyone knows how to do that?  I'd also need to limit the types of entity referenced: e.g. content type "node", bundles "author" and "article".
      public function blockForm($form, FormStateInterface $form_state) {
        $form['foo'] = [
          '#type' => 'textarea',
          '#title' => $this->t('Foo'),
          '#default_value' => $this->configuration['foo'],
        ];

        // how add a paragraph field?

        return $form;
      }


texts: Show the view result only when users enter a value for the exposed fields

texts:
I want that a view shows its result only when users enter a value in the exposed form fields. Is there a way I can get this done?

I am using AJAX, and the view is displayed as block. Most of the options I tried don't work because of this.


texts: Some info missing on Drupal 7 ckeditor accordion instructions

texts:
Trying go to get this working:

https://www.drupal.org/project/ckeditor_accordion

But it's not working, step 5 and 6 don't exist or I can't find them in Drupal 7, are these instructions for Drupal 8 only?

 5.Scroll down to the bottom to the input Allowed HTML tags
 6.Find and replace <dl> with <dl class>

Can't find 5 and 6 in the backend


texts:
is there anyway, we can disable payment of specific payment option via custom module? I Have done some research that payment in drupal commerce is setup via rules, so is there an option we can create custom module and hit the current payment rules and disable it?

and is there a way via custom module, we can get the list of available or activated payment?

some references would be great.

thank you!


texts:
what is the right sql query for drupal 7 if the query like this

SELECT MAX(nopeserta)
FROM `1_jp_peserta`
WHERE jpke=$q1 AND lomba=$q2 AND kelamin=$q3

i have tried in drupal like this

$q4 = db_query("SELECT MAX(nopeserta) AS nopeserta FROM {1_jp_peserta}
WHERE jpke=:q1 AND lomba=:q2 AND kelamin=:q3",
array(':q1'=>'$q1',':q2'=>'$q2',':q3'=>'$q3'))->execute()->fetchAssoc();

but the result is

PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters
were bound in jpeserta_form_submit()


texts:
I'm having an issue where node_save() (inserting new node) ignores some fields in my JSON node.  This happens with several content/widget types.
I've posted this to Drupal services with no response.

I followed Tyler's post here recommending to do a GET to observe and mimic the JSON format returned - unfortunately I'm finding the format returned in a GET is not always the same format as expected in a node_save() POST.
https://github.com/signalpoint/DrupalGap/issues/418

I also saved a node on our Drupal website and captured the format of the POST
body, trying to translate that format to analogous JSON.  No luck.

Date time field, with start and end date, using Date (Unix timestamp) field
type and pop-up calendar widget.
Formats recommended in the post below does not save, only default value (now)
is saved.  Example is field_when_available below.
Services module update date field
Integer field types with Text field widget will not save.
I've tried over 20 permutations of formats, posted here, no response.
htt ps://www.dru pal.org/node/2870095
field_scrap_weight is an example below.
Reference to another node will not save.
Same link above describes using target_id, tried that, no success.

What will save are are term reference and List(text) content types from
Radio button widgets.   field_surplus_type and field_unprepared_or_prepared
are examples.

I am posting to
http://127.0.0.1:8083/?q=drupalgap/node.json

Below is one example, but I've tried literally hundreds of permutations
with and without array brackets, with/without the "und" element,
with/without quotes in the data value, etc.

I'm beginning to think there's a more global/systematic issue like a content-type setting.

{
  "type": "donation",
  "form_id": "donation_node_form",
  "language":"und",
  "field_unprepared_or_prepared": {    // saves OK (List text, checkbox/radio)
    "und": {
      "value": "unprepared"
    }
  },
  "field_surplus_type": {        // saves OK (Term ref, checkbox/radio)
    "und": [ 1, 3  ]
  },
  "field_scrap_weight": {        // NOT saved (integer, text field)
    "und": {"value": "1"}
  },
  "field_when_available": {      // NOT saved (Unix timestamp), popup calendar
    "und":[
      {
        "value": {
            "date": "05/29/2017",
            "time":"09:00pm"
        },
        "value2": {
            "date": "05/29/2017",
            "time":"09:00pm"
        },
        "timezone": "America\/New_York",
        "timezone_db": "UTC",
        "date_type": "datestamp"
      }]
  },
  "field_surplus_location": {     // NOT saved - node reference
    "und": {"target_id":"256"}
  },
  "body": {           // NOT saved (long text w/summary, text area widget)
    "und": {
      "value": "dd"
    }
  }
}


texts:
i want to create a gallery where users can comment on each image. I've seen approaches for Drupal 7, for example:

Node gallery Module
This is currently not supported in Drupal 8.
Gallery / Image Content Type with references
Is this a suitable approach for more than 1000 pictures?

Is there a better way to make this work in Drupal 8? Am I missing improvements on Drupal 7/8?


texts: How to programmatically add links to the links variable

texts: I am using Drupal 6 and would like to modify the $links variable to include other links programmatically. I have searched high and low on Google on how to do this to no avail. Does someone know how to do this?


texts: How can I immediately flush the php output buffer to the browser in Drupal hook_menu, flush & ob_flush not working?

texts:
I'm trying to immediately send the php output buffer to the browser while in a Drupal hook_menu but it doesn't seem to be working.  I use the following code on a non-Drupal php page on the same Apache site and it works perfectly (prints each line to the browser when flush is called), I put it in a hook_menu function and it waits until the end of the routine and then shows everything at once.

header( 'Content-type: text/html; charset=utf-8' );
echo 'Begin ...
';
for( $i = 0 ; $i < 10 ; $i++ )
{
    echo $i . '
';
    flush();
    ob_flush();
    sleep(1);
}
echo 'End ...
';


texts:
I have a site running on Drupal. There is a production site, publicly seen online and a development version on a private machine.

When migrating from a devel to a production server I'd like to disable the display of error messages. This could be done in Home » Administration » Configuration » Development (D7). However I'd like to automate that; put a proper SQL query in my migration script (that packs, transfers and 'installs' the page on a production server)

Can anyone help me with that?
Thanks!


texts:
I am attempting to add a file to a node.  I am using the following code which is saving the file to the file_managed table in Drupal without issue:

//query old DB for the pieces of the file I need happens above this

foreach($result as $r) {
  echo "Processing nid: " . $r->nid . "\r\n";

  //update nodes with the thumbnails
  if ($node = node_load($r->nid)) { //make sure there is a node to load
    $file_temp = file_get_contents('http://www.example.org/' . str_replace(' ', '%20', $r->filepath));
    $file_temp = file_save_data($file_temp, 'public://' . str_replace(' ', '_', $r->filename), FILE_EXISTS_REPLACE);
    $node->field_thumbail['und'][0] = array (
      'uid' => 1,
      'fid' => $file_temp->fid,
      'uri' => $file_temp->filename,
      'filemime' => $file_temp->filemime,
      'status' => 1,
      'display' => 1,
    );
    print_r($file_temp);
    node_save($node);
  }
}

That saves the file just fine, and appears to save node with the correct information too.  However, Drupal renders it like this:

The file exists at the URL, and entering the file URL in the browser renders the file.  There is an entry in the {file_managed} table and the data is saved to the node.  That is, if I do a:

drush php-eval 'print_r(node_load($nid))'

replacing $nid with my node id, the field_thumbnail looks to be properly populated.

There is not, however, an entry in the files table for this fid.

I'm wondering what the difference between files_managed and files tables are?  Do I need to also save it to the files table for Drupal to render it properly?


texts: Dynamic select list in the form (dependent dropdown)

texts:
I'm using Drupal seven. I want to make the options in a select list be dependent on the value chosen in another select list in a form.  I'm sure this has been asked many times before, but I am having difficulty finding a clear answer for how to do this.

The form is for users to enter a work history.  They need to select a squadron which is a node reference to the squadron field type, and this is in a drop-down list.  However, the squadron, is dependent upon a city drop-down list.  Users first need to select a city which will then filter the options for the squadron.  In the squadron content type, I created a taxonomy for city which gets tagged to the squadron.

I would be very grateful for any pointers as to the best way (simplest?) to go about this, or for any useful resources online which would help.


texts: D7 Views: Rewrite multiple field into one with custom separators

texts:
This is a follow-up to a recent question of mine, that was solved easily. The construct is very similar, but this time I need to add conjunction characters (in my case a comma and a space: ", ") when rewriting the field.

Here's the setup: In a node type, I have three fields: (1) methods, (2) geography, (3) keywords. All three fields are textareas where comma-separated values are entered. These fields are hidden on normal node view (node type -> manage display), but there is a views block showing these values.

Now, I want all of the fields' content to appear as a single field with a label with additional commas between.

An example: a node has the following values (1) methods: "evaluation, regeneration" (2) geography: "Denmark, Germany" and (3) keywords: "rivers, restoration".

If all (or at least keywords) fields are filled, the desired result is easy to achieve in the block:

Methods: no label; exclude from display; no result behaviour: hide if empty, hide rewriting if empty; rewrite results: ", [methods]"
Geography: no label; exclude from display; no result behaviour: hide if empty, hide rewriting if empty, no result output: "[methods]"; rewrite results: ", [geography][methods]"
Keywords: label "Keywords"; no result behaviour: hide if empty, hide rewriting if empty, no result output: "[geography]"; rewrite results: "[keywords][geography]"

For the above example this produces

Keywords: rivers, restoration, Denmark, Germany, evaluation, regeneration

Thus, the required commas (between restoration and Denmark as well as between Germany and evaluation) are added correctly. This also works, if either methods or geography are empty or even both, output looks like:

Keywords: rivers, restoration, evaluation, regeneration
Keywords: rivers, restoration, Denmark, Germany
Keywords: rivers, restoration

Now the culprit. If keywords' field is empty, there are two scenarios.

Both geography and methods are empty, also. Then the whole (rewritten keywords) value is also empty and label is not displayed.
Either or both geography and method have values. Then there is a superfluous comma at the start of the value like

Keywords: , Denmark, Germany
Keywords: , evaluation, regeneration
Keywords: , Denmark, Germany, evaluation, regeneration

The actual question:
How should I setup the view to avoid this starting comma if keywords' field is empty?

The only easy way I found is to make the keywords' field required so there is always a value present. But I'd like to set it up without marking fields mandatory and without changing the fields' types or widgets.


texts: File force compatibilty with download count module

texts: I am using File Force Download 7.x-1.2+0-dev module with Download Count module. If when i set manage display for file field as File Force: Generic file then it is counting download twice but if i set Generic file with download count then it works fine.how to avoid counting download twice with generic file.


texts:
My hosting provider has problems. I put Drupal on a sub-domain of my site. When I try logging in or clicking a link it comes to a Internal server error. But if I navigate to the actual directory it works fine. What should I do?

Examples:

Works: sld.tld/subdomainroot/Y

Fails subdomain.sld.tld/Y


texts: Adding a delete button to node edit form

texts:
I need to add a delete button to a node edit form, so in case I open a edit form of the node I want to have a possibility to delete it as well.
This edit node form is genereted from a view using Link to edit Content and displayed in modal window, which adds the following markup to the page.

Link to edit node

How can I programmatically achieve this in Drupal 8?


texts:
Apologies if there is a good documentation out there, I searched and read other topics for over 30 minutes now, could not figure it multiple things with theming a field.
My objective is to customize a field inside a views called  field_calendly_url. I found the following field template. I have several questions;

Would I need to make changes with set classes, for example change field--name- to field--calendly--url?
How can print my field value, I tried {{ field.calendly.url }} and {{ fields.calendly.url }} but neither worked.
Do I have to keep the if statement for label even if I am not using a label?

`
{%
set classes = [
'field',
'field--name-' ~ field_name|clean_class,
'field--type-' ~ field_type|clean_class,
'field--label-' ~ label_display,
]
%}
{%
set title_classes = [
'field--label',
label_display == 'visually_hidden' ? 'sr-only',
]
%}
{% if label_hidden %}
  {% if multiple %}

      {% for item in items %}

{{ item.content }}

      {% endfor %}

  {% else %}
    {% for item in items %}

{{ item.content }}

    {% endfor %}
  {% endif %}
{% else %}

{{ label }}

    {% if multiple %}

    {% endif %}
    {% for item in items %}

{{ item.content }}

      hello...
    {% endfor %}
    {% if multiple %}

    {% endif %}

{% endif %}

<a href="javascript:void jQuery.colorbox({html:''})" class="btn-box">Request Meeting

`


texts: Optional multiselect field, hide the - None- option

texts:
I am working on a form made mostly of multi-select fields, which are optional for the user to choose.

The multi-select fields work fine in general; however I really need to hide the -None- option in the multi-select fields which are not required for user to select. I can override it and change the text but thats not the point, since user can still select the -None- value in the process of selection, even tho it wont show after node is saved.

It just looks a bit confusing, even though it works as it should; users can select both the -None- option along with other options available and that makes the whole form different from what I want.

Here is an image of an example field showing what I mean.

I tried searching through the CCK module, but I couldn't really find anything.


texts:
I noticed that some of the queries to retrieve data from cache tables is really slow (> 100ms). For example:

SELECT cid, data, created, expire, serialized FROM cache_views WHERE cid IN ('views_data:en')

SELECT cid, data, created, expire, serialized FROM cache_field WHERE cid IN ('field_info_fields')

SELECT cid, data, created, expire, serialized FROM cache_bootstrap WHERE cid IN ('system_list')

SELECT cid, data, created, expire, serialized FROM cache WHERE cid IN ('entity_info:en')

Most of those tables only have 10-100 records total. Why would they be so slow?