texts: How to store second dropdown value in database

texts:
function YOUR_FUNCTION_THAT_DISPLAYS_FORM(&$form, &$form_state) {
  $query_state=db_select('state', 's');
  $query_state->fields('s',array('State_code','State_name'));
  $query_state->orderBy('State_name','ASC');
  $state_results = $query_state->execute();

  $options_state = array();

  // Using fetchAll() you can iterate through a result set.
  while ($state_record = $state_results->fetchAll()) {
    // You want state code as key, not state name as key.
    $options_state[$state_record->State_code]=t($state_record->State_name);
  }

  // State form element.
  $form['state1']= array(
    '#type' => 'select',
    '#title' => t('State'),
    '#options' =>$options_state,
    '#required' => TRUE,
    '#ajax' => array(
      'callback' => '_ajaxfunction',
      'wrapper' => 'divaroundseconddropdown'
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );

  // City wrapper form element.
  $form['city_element_wrapper'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );

  return $form;
}

// AJAX callback function.
function _ajaxfunction(&$form, &$form_state) {
  $key = !empty($form_state['values']['state1']) ? $form_state['values']['state1'] : 1;

  $query_city=db_select('city', 'c');
  $query_city->fields('c',array('District_Code','District_Name','State_Code'));
  $query_city->condition('State_Code', $key, '=');

  $query_city->orderBy('District_Name','ASC');
  $city_results = $query_city->execute();
  $options_city = array();

  while ($city_record = $city_results->fetchAll()) {
    // This is correct.
    $options_city[$city_record->District_Code]=t($city_record->District_Name);
  }

  // Render city setting.
  $form['city_element_wrapper']['city']= array(
    '#type' => 'select',
    '#title' => t('District'),
    '#options' => $options_city,
    '#required' => TRUE,
  );

  return $form['city_element_wrapper'];
}

I have tried to get city value like this 'city_element_wrapper' => $form_state['values']['city_element_wrapper']['city'], but error is coming like

  Notice: Undefined index: city_element_wrapper in
  form_test_custom_form_submit()

How to solve it?

function form_test_custom_form_submit($form, $form_state) {
  $prog_id =1;

  db_insert('tot_prog')->fields(array('state1' => $form_state['values']['state1'],
'city_element_wrapper' => $form_state['values']['city_element_wrapper']['city'],) // i have metioned like this,  is correct???? but its shows error, how to get the select city value???
        ->execute();
 drupal_set_message("successfully saved Settings");
}


texts:
I am looking for a concrete way to only allow logging in with email address only in Drupal 8.

I have seen Login Email and Login EmailUsername modules, but both still allow for username login as well as email.

I am looking only for email.

So far, I have come up with this in the interim - but something is not quite right. While I can trigger a form error, the form still submits and authentication is called. It should not submit if the entered value does not resemble an email address:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_user_login_form_alter(&$form, FormStateInterface $form_state) {
  $form['name']['#type'] = 'email';
  $form['name']['#title'] = t('Email Address');
  $form['name']['#description'] = t('Enter your email address.');
  $form['name']['#element_validate'][] = 'mymodule_login_validate_user';
  $form['pass']['#description'] = t('Enter the password that accompanies your email address.');
}

/**
 * Custom validation handler for the form login.
 *
 * @param $form
 * @param $form_state
 * @return bool
 */
function mymodule_login_validate_user(&$element, FormStateInterface $form_state) {
  $email_input = $form_state->getValue('name');

  if (!\Drupal::service('email.validator')->isValid($email_input)) {
    $form_state->setError($element, 'Please enter a valid email address.');
  }
}

I am also overriding the core user.auth service with my own - I will be generating usernames based on factors about the user (fetching information from a remote AMS).

Is there any way to avoid username in Drupal 8?

edit: Users cannot register on the Drupal site, and forgot password will be replaced with a link to the external AMS system.


texts:
I have installed/enabled the Filebrowser (v 7.24) module and set permissions...

It is said to provide ftp style file browsing capabilities, but I can't find any way of invoking it.

I am used to installing and getting modules working, and I have read the sparse documentation which refers to it as a node, but I can find no way to create a node or navigate to a page that is anything like the screenshot.

There are no new content types, nothing changed on creating new content, nothing new appears under any of the admin menus, appending filebrowser and variations to my site's URL does nothing.

How to open file browsing window?


texts: Order receipt e-mail language for guest checkout

texts:
Is there a way to have the order receipt e-mail be in the language of the site version that was used for placing the order?

The order receipt e-mail that gets sent out (content of commerce-order-receipt.html.twig) for a guest is currently always in the default language. That means a user would order items from the French site, and get an English confirmation. It appears that no language data is saved for an order, so I guess there's no built-in way to do this.

Does anyone have any ideas?


texts:
I have created a new CCK field and am trying to show it in a JSON view. It shows in the preview however when I go to the path I created for it the field won't show. I've turned off caching on views and done everything else I can think of but it won't work. When I run the SQL on the DB it does show the column and the entered data, and it shows in places that I"m using it on my site.

One really weird thing is that it shows here:

http://metrotrains.com.au/lines/network_stations.json

but not here:

http://www.metrotrains.com.au/lines/network_stations.json

The field I'm talking about is called "facilitiesparking" under the first node.

Any help would be great. :)


texts: acquia/solr/D7: indexing additional files outside of a node

texts:
I'm trying to set up a way to index uploaded PDFs in such a way that a user can search for a term (foo) and get a list of all the nodes with fields that contain foo somewhere; and once they've clicked through to a page, they should be able to search for bar within the attached PDF and see a list of snippets along with a link to jump to that page in the PDF. In my research, I decided the best way to do this would be to write a module that splits the PDFs into individual pages with filenames that include the page number, index those new documents (along with the parent document), and build my "snippet" results from those new documents. So, for example, when I upload sample.pdf, I get the following folder structure:

content
 |
 +-- sample.pdf
 |
 +-- sample.pdf_src
 |  |
 |  +-- sample.pdf_1.pdf
 |  +-- sample.pdf_2.pdf
 |  \-- sample.pdf_3.pdf
...

That works fine, but where I'm getting stuck is indexing those extra files. For background, I'm using Acquia's Solr module (apachesolr_search) with the extra attachments module (apachesolr_attachments). Is it even possible to manually index those additional files I broke out? If not, are there any other ways I can get those files into the index? Maybe attach them to the original node where the user uploaded the original PDF? I just don't want to get into a situation where I have 800 attachments to a single node because the one PDF the user uploaded contained 800 pages.

If it were possible to get page numbers out of the original upload when searching for content, that would be the most ideal situation; however, my research indicates it's not possible. I'd be happy to be proven wrong, though.


texts: Editing user submission of user registration form with hook_user_insert() and $edit

texts:
I recognize there is a similar question here:

drupal.stackexchange.com/questions/38124/hook-user-insert-get-form-values

but I've got Eclipse and XDebugger setup so I can see the variables and I am still stuck.

I provide the variables below, please note field_foo is a field the system has taken care of properly without my interfering, after the user submits it, field_bar is a field I want to change the submitted value of, it has the value 303031 when the system handles it from form submission, where the variables show "value 300501 " is my attempt to edit that value - clearly I'm editing something wrong)

$edit   Array [37]
[0...30]
    uid 63
    field_foo   Array [1]
        und Array [1]
            0   Array [1]
                value   asdasd
                    length  6
                    0   61
                    1   73
                    2   64
                    3   61
                    4   73
                    5   64
    field_bar   Array [2]
        und Array [1]
            0   Array [1]
                value   303031
        value   300501

Here is my code to try and set it...

function MY_MODULE_user_insert(&$edit, $account, $category) {

    $newBarValue = 300501;
    $edit[field_bar][value] = $newBarValue;

}

PLEASE NOTE:

I don't know if this is the case for all field_data_field Core fields but I had to use the following to get it to work:

$edit[field_bar][und][0][value] = $newBarValue;

This might be unique as I am working on someone else's work atm.


texts: Entity reference view filter from node data text to exposed as check box

texts:
I have a content type ‘protocol’, with a field ‘participants’ an entity reference view widget field which gets its view list from the users. ‘protocol’ also has a text field ‘Class’ with a single value entered.

In the user_profile I use the same text field ‘Class’, this time multiple values, comma separated.

What I would like is to expose a filter in the entity reference view that is a check box with the value from the class field data in the ‘protocol’ node.

The idea is to check a box to optionally filter the participants view for users that contain that class as specified in the protocol node. Any ideas?


texts:
I am trying to set a default value using hook_form_alter on an entity form, and the usual thing I do is not working, can anyone see why?

Here is the dsm($form) ...

My module is called "pinboard" and the form ID is "pinboard_entityform_edit_form" which is in the array and I used dsm($form_id);

function pinboard_form_alter(&$form, &$form_state, $form_id){
  if($form_id == "pinboard_entityform_edit_form"){
        dsm($form);

        $form['actions']['submit']['#value'] = t('Send Enquiry');
        $form['field_your_name']['und']['#default_value'] = t('Joe Bloggs');
  }
}

This is just a simple example, I am well aware I can set a default value through the UI, I will be replacing "Joe Bloggs" with my own variable once I get this working.

The first line works perfectly and changes the submit button text, but the second line does not set a default value on the your name field.

What am I missing?


texts: How to get node title using this query on template?

texts:
Im building a custom filter in Drupal 8 based on some queries.

I got this already, here im filtering by values on body:

$query = db_select('node__body', 'n')
                            ->fields('n')
                            ->condition('n.body_value', "%" . $searchWord . "%", 'LIKE')
                            ->condition('n.bundle', 'mycontenttype');
     $getList = $query->execute()->fetchAll();

Then i pass the variable to the Twig:

return [
            '#filters' => $getList,

In the twig im doing:

{% for oneItem in filters %}

But im unable to get the title of the node here, what im missing?


texts: Redirect to last page after saving new content with rules

texts:
Drupal goes normally to the new node after creating or editing it. How to redirect to the last page where the user clicked on the node/add link using rules?
I tried different tokens with no success. Here is the rule:
Let's say we are on url: sitname/node/133
a user clicks on node/add/announcement
Rules: after saving, I need to go back to sitename/node/133
Rules:
After saving new content type:announcement

Action: Redirect to page sitename/node/ (token) not sure what to do here


texts: How to pass taxonomy reference field data into a views reference contextual filter arguement with PHP code?

texts: My content type has a taxonomy reference and a view reference field. I currently want to pass the Term ID as an argument into my referenced View via a Contextual filter Taxonomy Term. If someone can provide me with an example of how to write the PHP code in the contextual section of my view that would be great.


texts:
I have some text I'd like to alter in the custom output of a view field.  For example, if the output contains pancakes, I'd like to replace it with waffles.
The following code doesn't work.
{{ field_recipe_prep__value | replace({'pancakes': "waffles"}) }}

How do I replace a string when altering the output of a view field?


texts: Send Email using rules or other module depending on a field value?

texts:
What I'm trying to do is when a user creates a node on content type "Sample" with the field "Priority" set to "High" that said user will receive an email notification containing the field values of the node and a link.

I tried using rules but I can't seem to find a condition that supports a field containing value. I'm thinking into creating a hook function when the user creates a node. But the problem is I'm very new to drupal and I still don't know where to start. Can anyone enlighten me on what to do?


texts: Load a Module versus JavaScript embedded in Theme

texts:
I am new to theming Drupal and I am trying to create a responsive website based on Bootstrap with an image slider at the top.

I know that there are modules like Views Slideshow and FlexSlider.  However, I don't want to install a module when I don't have to.  I would like to just create a content type specific to the slider with just the fields that I need and have the slider that is "embedded" in the theme simply load the content depending on whether it was published or not.

Can this be done?  Are there benefits/drawbacks to what I am attempting to do here?

I am not fluent in the Drupal theming lingo yet so I don't know if I am asking the question the right way.


texts:
So, this is my first question on Stack Exchange! So, I'm currently working on a project in which users of my Drupal site are playing a game as art collectors, and have a collection of artworks, which they can trade and sell during the game. Since my users will need to be able to reassign ownership of works (which would be stored in a database, as each work has several fields attached to it (artist, date, value, material, size, etc.)

And while I want them to be able to change ownership, it'd be preferable if I could let them do this in some kind of GUI, where I could limit control of what fields they could edit. In an idyllic scenario, they would have a drop-down menu they could select from to choose the new owner of the work, but I'm not sure how realistic that is.

Any modules that could assist in this would be fantastic, or if you have a different approach (other than a database), I'm more than happy to hear. This Drupal site is currently running on Ubuntu 16.04 LTS with the latest Drupal 7.5 installed.

I hope I was concise enough in my first question, and that somebody can help!


texts: Drupal Commerce: View that displays orders with discontinued products

texts:
I've been working on this issue for most of the day and haven't found a solution. Has anyone ever set up a View in Drupal Commerce to display the orders that contain discontinued products?

I need a way to display the orders that have discontinued products, and also display which product in the order is discontinued.

I tried several Views plugins but I'm only able to look at orders, or discounted products. Not both at the same time.

Thoughts?


texts: How-to display a product variation field twice (or more)?

texts:
I want simply display a field of a product variation type (commerce) two times with different render settings.

I have tried with a dynamic field (display_suite) but it not working... I would prefer to know a programmatically solution to accomplish this task and I want use the (Drupal core) Display Manager for designate my layout (not a template file) :)

Note: This product field do automatically refresh (ajax) like other when a different product variation is selected.

See this related "issue": https://www.drupal.org/node/1494192#comment-7031370


texts: I cannot create a directory when installing a module

texts:
I have a clean install of Drupal 8 on a new Centos 7 server. This is the first module I have attempted to install. I'm using the built in update manager. I get the following error.

  File Transfer failed, reason: Cannot create directory /var/www/html/modules/somemodule

This seems like a common enough permissions problem but no answers I've found on similar questions have worked. The webserver user is apache (not www-data) and it owns the modules directory. I have confirmed this with ps aux | grep -i 'www\|apache\|nginx'.

These are the current permissions.

drwxr-xr-x.  2 apache apache    24 Jan  3 13:27 modules

I have chowned and chmodded until I'm blue in face, but it hasn't changed anything since the apache user already owns the directory and should be able to write it.

/admin/reports/status shows all green including FILE SYSTEM Writable (public download method).

What could be wrong? How can I further troubleshoot?

I am using PHP 7.1.14, Apache httpd-2.4.6-67.el7.centos.6.x86_64, and Drupal 8.4.4.

Update:

I have tried chmod -R 777 as a test and receive the same error. I have also tried creating the directory for the module manually but the update manager is still unable to copy files to it.

Update 2:

I have downgraded to php 7.1 to be fully compliant with Drupal 8 requirements but this has not solved the issue or changed the behavior.


texts: How to provide content type in module for Drupal 8?

texts: How do I write a module that provides a content type in Drupal 8?


texts:
I have two very basic vanilla installation of Drupal 8. One I have installed a few months back, and one I installed today.
I have an identical datetime range field in both of them. But I noticed that the older installation (8.8.4) saves the datetime after converting it to UTC format. However, the new installation (8.9.2) saves the date time as is entered in the form.
Is there a configuration or something which is controlling this? This is creating problem using the "Date all day" module I guess.
Any help?


texts: Rendering plain text instead of formatted data

texts:
In my custom module (in Drupal 8), I am using a form field (in a custom form) to use CKEDITOR with the following code which loads the editor fine.

$form['full_detail_text'] = array(
  '#type' => 'text_format',
  '#format' => 'full_html',
  '#title' => t('Full Detail'),
  '#rows' => 5,
);

The following code saves the posted data in the database.

$query = db_insert('my_table')
  ->fields(array(
    'full_detail_text' => $form_state->getValue('english_copy_text')[value],
    'date' => REQUEST_TIME,
  ))
  ->execute();

I am using a view page display to render this output, but the output for this field is displaying data as plain text (no formatting) along with HTML code instead of formatted data same as in the editor.

Is there a configuration setting I need to adjust or perhaps hook_views_pre_render() to transform this field's data from plain text to HTML markup?


texts: Use a contextual filter value in a view referencing a node name/path rather than id

texts:
I would like to create a views that has a contextual filter with a node reference.

I'm able to view the contextual filter working when I use the node's id value, but I need to be able to use the alias or name value of that content type. I have people categorized by office (the office is also a content type because it has much more content than a taxonomy would allow). Then using the office location as a contextual filter I'm trying to show the "team" listed for each office.

/office/atlanta/team rather than /office/6/team


texts:
datetime object is

[start_time] => Array
                (
                    [0] => Array
                        (
                            [value] => Drupal\Core\Datetime\DrupalDateTime Object
                                (
                                    [formatTranslationCache:protected] =>
                                    [inputTimeRaw:protected] =>
                                    [inputTimeAdjusted:protected] =>
                                    [inputTimeZoneRaw:protected] =>
                                    [inputTimeZoneAdjusted:protected] =>
                                    [inputFormatRaw:protected] =>
                                    [inputFormatAdjusted:protected] =>
                                    [langcode:protected] => en
                                    [errors:protected] => Array
                                        (
                                        )

                                    [dateTimeObject:protected] => DateTime Object
                                        (
                                            [date] => 2017-03-17 02:04:03.000000
                                            [timezone_type] => 3
                                            [timezone] => UTC
                                        )

                                    [stringTranslation:protected] =>
                                )

How to get [date] => 2017-03-17 02:04:03.000000 ??????

I have tried using print_r($ruleContentNew[0]['start_time'][0]['value']->getValue());die;
But it is giving me error.


texts: How to show the edit form of a page just below the page itself in the frontend?

texts:
Just wondering if is there a way to expose the edit form of a page just below the page itself in the frontend.

Let's say I have the page Services, if you click a the edit tab you go to the admin page where you have the fields title and body for this page, here you can change its values and save.

I need to show the edit form (fields title, body and the button save) in the frontpage, just at the bottom of the page.

UPDATE: base in neok's answer: But I can not use $output var in utilities_block_view($delta = '') {

    function utilities_preprocess_page(&$variables, $arg, $delta=0) {

      if(arg(0) == 'node' && is_numeric(arg(1))) {
        $nid = arg(1);
        //you need to include node.pages
        module_load_include('inc', 'node', 'node.pages');
        $output = node_page_edit(node_load($nid));

        return $output;
      }
    }

    function utilities_block_info() {
      $blocks['edit_node_form'] = array(
        // info: The name of the block.
        'info' => t('Edit node Form'),
      );

      return $blocks;
    }

    function utilities_block_view($delta = '') {
      // The $delta parameter tells us which block is being requested.
      switch ($delta) {
        case 'edit_node_form':
          // Create your block content here
          $block['subject'] = t('Edit node Form');
          $block['content'] = $output;
          break;
      }

      return

 $block;
}


texts:
I want to get the edit form from a Webform Submission to handle this in the logged in user area.
Like node/{node_id}/submission/{submission_id}/edit
How do I do this?


texts:
I'm using Drupal 8 with Bootstrap theme, and I've created a sub-theme and different menus.

I've tried to edit the menu twig template but i am not really familiar with Twig.

How can I add a menu where links open in new tabs?


texts: How to get only field value in View template

texts:
How can I access/print the raw value of a date field? (or any field for that matter). I am working in a View template and I typically use $fields['field_myfield']->content. But that gives me the HTML not just the value.

My template.php file:

 function mytheme_preprocess_views_view_fields(&$variables)
{
    $view = $variables['view'];
    if($view->name == "news_main_list")
    {
          $variables['news_date'] = $variables['fields']['field_news_date_text']->content;
          $variables['news_type'] = $variables['fields']['field_news_type']->content;
          $variables['theme_hook_suggestions'][]='views_view_fields__news_main_list__block_1';
     }
 }

My views-view-fields--news-main-list--block-1.tpl.php file:

  <?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>

  <?php print $field->wrapper_prefix; ?>
<?php print $field->label_html; ?>

<?php print $fields['title']->content; ?>

    <?php print $news_date; ?> | <?php print $news_type; ?>
    <?php if ($news_type == "event") : ?>
        <?php print 'hello'; ?>
    <?php endif; ?>

  <?php print $field->wrapper_suffix; ?>


texts: How to integrate the Fusioncharts library with Drupal 7?

texts:
I have been trying to integrate the Fusioncharts library with my Drupal 7 site.

Just to check if everything is working properly, I followed this documentation for creating a basic graph with data contained in Data.xml file; the entire documentation is here.

FYI, I need to use PHP as I am more comfortable with it.

I have extracted the downloaded folder into /sites/all/libraries/FusionChartsFree/; with changes in paths (nothing else); I have pasted the code in the given example into my Drupal 7 node with the php input filter enabled. I also have the libraries module installed.

<?php
  //We've included ../Includes/FusionCharts_Gen.php, which contains FusionCharts PHP Class
  //to help us easily embed the charts.
  $name = "FusionChartsFree";
  if ($path = libraries_get_path($name)) {
    include $path . '/Code/PHP/Includes/FusionCharts.php';
  }
?>
<html>
  <head>
    <?php
      //You need to include the following JS file, if you intend to embed the chart using JavaScript.
      //When you make your own charts, make sure that the path to this JS file is correct. Else, you
      //would get JavaScript errors.

      include($path.'/Code/FusionCharts/FusionCharts.js');
    ?>
    <script type="Javascript" SRC="/sites/all/libraries/FusionChartsFree/Code/FusionCharts/FusionCharts.js"></SCRIPT>
    <title>FusionCharts - Simple Column 3D Chart</title>
  </head>
  <body>
    <?php
      //Create the chart - Column 3D Chart with data from Data/Data.xml
      echo renderChart("/sites/all/libraries/FusionChartsFree/Code/FusionCharts/Column3D.swf", "/sites/all/libraries/FusionChartsFree/Code/PHP/BasicExample/Data/Data.xml", "", "myFirst", 600, 300, false, true);
   ?>
  </body>
</html>

I get the below output. It is pretty long; hence, I have put then in part by part in these pictures.

(FYI, those Flash files that appear in the output, do not display anything if I click on them.)

Now, suppose I remove the below line from the code.

<?php
 include $path . '/Code/FusionCharts/FusionCharts.js';
?>

I get nothing. I mean only a text which reads "cahrt" in the below output.

My Question: How can I make Fusioncharts work in DRUPAL 7?

I am also having similar trouble with the pChart library too: Even pChart does not display anything, not even an error, or warning. Simply there is nothing in the node body.


texts: How to replace Operations links (dropdown) by icons?

texts: I'd like to have something like that (icons as buttons)   instead of text links in dropdown


texts: Why do I get "Command pm-disable needs a higher bootstrap level to run"?

texts:
Running drush dis varnish in the Drupal directory gives give me this message.

  Command pm-disable needs a higher bootstrap level to run.

Running drush --debug dis varnish -y gives the following output.

  Phar detected. Proceeding to drush_main().
  Loading drushrc "/home/user/.drush/drushrc.php" into "home.drush" scope.     > Cache HIT cid: 8.1.14-commandfiles-0-erased
  Bootstrap to phase 0.
  Bootstrap to phase 6.
  Drush bootstrap phase: bootstrap_drupal_root()
  Initialized Drupal 7.59 root directory at /usr/share/www/Drupal
  Find command files for phase 1 (max=6)
  Cache HIT cid: 8.1.14-commandfiles-1-erased
  Cache HIT cid: 8.1.14-annotationfiles-1-erased
  Drush bootstrap phase: bootstrap_drupal_site()
  Initialized Drupal site default at sites/default
  Find command files for phase 2 (max=6)
  Drush bootstrap phase: bootstrap_drupal_configuration()
  Find command files for phase 3 (max=6)
  sql-query: SELECT 1;
  Executing: mysql --defaults-extra-file=/tmp/drush_erased --database=dune --host=localhost --silent  < /tmp/drush_erased
  sql-query: SHOW TABLES;
  Executing: mysql --defaults-extra-file=/tmp/drush_erased --database=dune --host=localhost --silent  < /tmp/drush_erased
  Bootstrap to phase 1.
  Bootstrap to phase 6.
  Bootstrap to phase 5.
  Command pm-disable needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.
  The drush command 'dis varnish' could not be executed.

drush status and drush updb work. The output of the first command is the following one.

Drupal version         :  7.59
Site URI               :  http://default
Database driver        :  mysql
Database hostname      :  localhost
Database port          :
Database username      :  drupaluser
Database name          :  dune
PHP configuration      :  /etc/php.ini /home/user/.drush/drush.ini
PHP OS                 :  Linux
Drush script           :  /usr/local/bin/drush
Drush version          :  8.1.14
Drush temp directory   :  /tmp
Drush configuration    :
Drush alias files      :  /home/user/.drush/aliases.drushrc.php
Drupal root            :  /usr/share/www/Drupal
Drupal Settings File   :  sites/default/settings.php
Site path              :  sites/default


texts:
I have a view which shows a list of articles, located at:

  mypage.com/articles

Each article is linked to its main sub page view, like this:

  mypage.com/articles/name-of-my-artile-yay

The URL path is created with autopath & URL aliases.

In views, how do I create a contextual filter to show only the selected sub page view?

I have this as my path in views:

  articles/%

but don't know where to go from here. I tried title and making it lowercase and replacing spaces with a hyphen, but that won't always work and the URL aliases change the URL such that it removes words like:

  a, an, as, at, before, but, by

And if a page title is:

  This is my page title - with this

The URL alias becomes:

  my-page-title

Therefore it won't be able to match in my contextual filter using the page title.

What am I missing?


texts: How can I prevent user pages being created for users with a specific role?

texts:
I have various users on a Drupal site.

Internally, I differentiate between users by user role (e.g. 'member', 'non-member').

Is it possible that if a user has a certain user role, that I prevent them from having a user page that is visible to the public?

E.g., if user 10018 has user role 'non-member', how can I prevent user page (site.com/user/10018/) from being visible to the public and users of role 'member'?

Basically, I don't want to delete 'non-member' users unless it's absolutely necessary - but I don't want them to have user pages that are visible to anyone other than site admins.

Thank you!


texts: A node reference is empty, although the multilingual support is enabled, and the node is translated

texts:
I just created a multilingual site (English-French) using Drupal 7 with the module Internationalization 7.x-1.4.
Everything is working fine except with the module References 7.x-2.0. For instance, I created a content type "School" so that each user is affiliated to a school (User A --> School 1, User B --> School 2, etc.), meaning I simply added a node reference to "School" in the user account settings. But here is the problem: if a user chooses a school on the English version of the site it won't remember the school choice on the French version (the node reference becomes empty) and vice versa.

How do I solve this?

I did enable the multilingual support for "School" with translation.


texts: error 403 when trying to log in during checkout

texts:
It's the first time i'm posting on a forum but i've been really stuck with this problem for a few days.
So thanks for your help.

I'm working on a site that's entirely https.
The site uses the anonym checkout  possibilities. I recently observed that when a user wants to connect during checkout (using the "/user" link, I don't use extra pannel to log in), after adding a product to cart or after a purchase, he gets an error 403.
Whatever role he has, he is stuck with this error. The login and the password are correct. And this doesn't happen when we are on another page. It only appears from the moment a user adds a product in the cart.
Then he has to empty the session and cache of the navigator to connect to his account.

I don't understand the problem because I don't have this problem on localhost, the only difference i see between the two server is that i don't use https on the localhost.
That's why i think it's a session problem but i'm not sure.
I tried all the solutions proposed for the settings.php, I don't use secure page (i used to but i uninstalled it because the site is entirely https now).
The site is on a subdomain.

I have made a redirection to htacess to redirect possible entry by http to https with this code:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$https://a.domain.com/$1[R=301,L]

I don't know what else to do, thanks for your help. Sorry if there's a lack of information, just tell me.

Thanks.


texts: Which hook will load after node page load and file download

texts:
I need to run  db_insert and db_update once after a node is loaded. Its only for particular node content type. Which hook can i use for it?. Can i add that hook in template.php instead of adding it in a .module file?.

I need another hook which will run once after a file gets downloaded.


texts: How do I find out which module handle a GET/POST/PUT?

texts:
I'm reading a Drupal 7 project. However, unfortunately I can't find out which module handle an Ajax request.
I only know the destination address which has been rewritten. (Suppose it's http://example.com/abc)

So, the problem is how could I find out which module handle my Ajax request?


texts: How to get list of blocks for region on current page?

texts:
I have a template of my custom function and I am display certain number of items per row in this template.

For this reason I need to figure out if there are any blocks on the current page in any of the sidebars of my theme(left and right) so I can adjust the number of visible items.

So my question is how to get the list of blocks that are displayed on the current route in certain region and their visibility conditions were already processed?

I do not need to have exact information, ie. if some blocks have #access set to false or if they return empty render arrays are not important.


texts: Anonymous users can't see new content type in feed

texts: I've made a new content type, and I've made a View that is a list of that new content type. Anonymous users don't get any content in that list but can see the individual content types. Admin users can see the content in the view fine. Is it a permissions issue?


texts: Aggregated CSS/JS file names, when regenerated?

texts:
What triggers the aggregated/compressed CSS/JS file names to be regenerated?

Because of the default header for .css and .js set in Drupal's stock .htaccess is 2 weeks, this causes issues with Varnish which obviously just obeys the headers it receives from the application.

Caching .css/.js for 2 weeks isn't really necessary, our web servers can serve hundreds of requests for static files per second. It's the Drupal requests that always worry me. So I can change the .htaccess (though I actually override the Cache-control: max-age header in Varnish so we don't have to modify stock files provided by Drupal).

I have noticed that regeneration can sometimes can be triggered with a drush cc css-js but possibly only if the aggregated files are over a certain age.
Does anyone know what the logic is behind this?

Rather than overriding the header sent by Drupal, it would be useful to know when the file names are regenerated, because that's obviously a way of making sure that HTML code cached in Varnish is picking up a new set of CSS/JS files.


texts:
I´m using mime mail 6.x 1.1 module and simplenews 6.x 1.4. I create all my newsletter issues in html, and I choose to send in html. However, always the mails are received in Outlook, hotmail and gmail in plain text.

I am using those modules in anohter website and they work nice.

What must I check? Could be the host?

Thanks a lot!


texts:
How to alter existing field type instead of creating new one to add new options with custom processing for insert and display of the field.

Use case : upgrade hijri taarikh  project that extends the default date field types allows to use Hijri calendar for both select list and popup letting the user add Hijri dates and display Hijri dates.


texts: What is the protocol for adding a new module dependency to a module that has only had a dev release?

texts: I created a module a while ago and it has only had a 7.x-1.x-dev release on Drupal.org for the last month or so. There are a number of reported downloads and installs already for this module so I want to make sure that the handful of users that already are using this module are still considered in the next dev release I need to make. The new release will have a new module dependency that is from another project (i.e. not included as a submodule of mine). While I would normally create a 2.x version if the module had a stable release, it has only been in dev. Do I just go ahead and add the new dependency in the 1.x-dev or create a 2.x-dev?


texts: How to Add product type donation into cart programmatically with custom amount(100 or 200 or something)?

texts:
I am using commerce_donate module and I want to add a product (type=donation) into cart programmatically with the amount set as per the user has already selected on some other page. On some custom form submit, I want to add this donation type product into cart in order to process the usual commerce order / checkout.

How can I achieve this ?

Thanks.


texts: why importer cannot map to custom field type

texts:
I've created a custom field type and added a field with this field type to my content. When I add set any data on Node Edit page, the data will store into the database successfully. But if I try to set the data via feeds importer, in mapping, this field is missing. I don't know if I missed any hook function in my module, or is there any setting I have to do in my module.

Here, I list all hook functions I am using:

hook_field_info
hook_field_widget_info
hook_field_widget_form
hook_element_info
hook_theme
hook_content_is_empty

Does anyone have any idea about why I cannot find my field in mapping list? If you need more information, please leave me a message. Thank you!!!


texts: Theming custom entity created with Entity API: accessing entity's fields in template file

texts:
First of all let me say that this is my first project in Drupal and I am still confused, I apologize if my question is stupid.

I created a custom entity in Drupal 7 using Entity API. The custom entity represents a golf course.

I used this tutorial: http://www.sitepoint.com/series/build-your-own-custom-entities-in-drupal/
Then I tried to add a custom theme, to do so I followed this: https://www.drupal.org/node/1238606

My callback function looks like this:

function view_my_entity($id) {
  $entities = entity_load('my_entity_type', array($id));
  $entity = $courses[$id];
  drupal_set_title($entity->name);
  $output = entity_view('my_entity_type', array($entity));
  $output += array(
    '#theme'     => 'my_theme',
    '#element'   => $output,
    '#view_mode' => 'full',
    '#language'  => LANGUAGE_NONE,
  );
  return $output;
}

And this is my hook_theme():

function my_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_theme' => array(
      'variables' => array('element' => null),
      'template' => 'my_template',
    ),
  );
}

The problem is that in my_template.tpl.php I can only access the golf course variables this way (in this example I will access the address):

render($element['my_entity_type']['The Name of my Entity']['address']['#markup'])

As you can see, in order to access the address I have to use 'The Lakes Golf Club', (which is the name of the currently displayed golf course), as a key, but obviously that name is going to change every time I display a different golf course, so my question is:

How can I access the golf course attributes without having to use the golf course name as a key?

EDIT

the docs for entity_view() (http://www.drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity_view/7) say the following:

  Return value

  The renderable array, keyed by the entity type and by entity
  identifiers, for which the entity name is used if existing - see
  entity_id(). If there is no information on how to view an entity,
  FALSE is returned.

So how do I avoid that the array is keyed by the name of the entity? If it was keyed by the id it would be OK because I have the $id variable in scope.


texts:
I've been working on a Drupal 8 site for a month or so now and development has been progressing nicely until a week ago. It looks like the issues started at just about the same time that the website host applied a server update. The first part of the issue is that I now have a WSOD with the error - The website encountered an unexpected error. Please try again later. I thought that issue might be related to the hosting environment as it's still running php5.6 (now no longer supported by version of Drupal from what I understand).

I thought that if I copied the site files and database to a different environment running php7.2 or 7.3 I might be able to resolve the issue. However since I don't have root access to the dev server I decided to export the database from the dev server as a sql.zip file and then import it into my new database on the new 'test' server and copy the site files across. However while performing the Drupal install I added a prefix for the 'test' database tables. I realised what I had done and went to the settings.php file to change it. When I tried to push the file up via FTP I got a 'failed to write file' error. Instead of trying to sort out the permission via FTP I logged into the Cpanel. I set the permissions of the sites folder to 755 and checked the box to apply the permissions to all sub-folders and files. I checked and all files permissions were updated. I open the settings.php file using the edit option in Cpanel and edited the line with the database prefix (to target the imported tables from the dev site -they have no prefix) to

'prefix' => '',

and clicked 'save changes' and I got the error

"The system failed to create the file “/home/user_account_name/public_html/sites/default/settings.php.lock” (as EUID: 1045, EGID: 1040 1040) because of the following error: Permission denied"

If I change the prefix value and edit anything else like the username I can then save the file without an issue.

Can someone please explain what is happening here. I believe that there is some flag set in the database (or another file) that is preventing me from updating and saving the settings.php and it may also be the reason for my WSOD issue.

Drupal version is 8.6.10 on dev server and 8.7.3 on the test server.


texts:
Which modules and function should I use to store address of house and also display Google Map of it? I also want to use postal code, province, city each in views etc independently.

I understand I should use GMAP + location.

But not sure if I need to use Location CCK or Node Locations.

What is the best way to accept address and also show Google map in the node?


texts:
I would like to list information about all users using drush.

There is user-information, but it shows information only about single user.

Are there any other solutions?


texts: Rebuild exterior elements of form on submit

texts:
On the user page I display two types of groups a user can be subscribed to: a pending membership or an approved membership. To illustrate this:

The 'cancel membership request' button is the submit button of a form of which only this button is a part. When this button is clicked, a submit callback is called. This does some processing such that the membership request should be no longer in the list. Preferably even, the whole fieldgroup should disappear.

But since the form consists only of the button, $form_state['rebuild'] can do only something with regard to the button itself, which is not sufficient in this case. Setting $form_state['redirect'] to the the same page seems not to work either (the page is not rebuilt then).

How can I make the page rebuild so it reflects the changes invoked by the submit button?


texts: Form API, drupal_add_js() and setting a JS variable

texts:
Consider

drupal_add_js(array(
  'radio86_media' => array('barfoo' => 'booboo')), 'setting'
);

and

$form['#attached']['js'] = array(
  drupal_get_path('module', 'radio86_media') . '/select_media.js',
);

These two 'lines' work well separately, but I think they could (and should) be combined so that the variable setting is set on the second line, combining the logic.

I've been fumbling around it and just can't get it to work. With this current way, I can console.log the barfoo variable via JS by using Drupal.settings.radio86_media.barfoo so it does work, but I really would like to have it combined.

Any suggestions greatly appreciated!


texts:
I need to join a custom table custom_table on a View my_view.

I have a module created called join_table

The nid is the referential id (the nid is what ties the two table to the view).

Then, I need to take the info the column price in custom_table and be able to display using my Views template.

I'm completely lost.


texts: Custom view filter integer condition in string format

texts:
I have added a new custom view filter with next code:
/**
 * Filter .
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("filter_pricelist")
 */
class PriceListFilter extends FilterPluginBase {

  /**
   * @{inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $this->valueTitle = t('Price list quantity filter');
  }

  public function query() {
    $grupo = $this->query->setWhereGroup('OR');
    $this->query->addWhere($grupo, 'pricelist.fromquantity', 0, '>');
    $this->query->addWhere($grupo, 'pricelist.toquantity', 0, '>');
  }

}

It works good and filter is added to the query of my view. The problem is the compared values are in string format. This is the generated sql query:
SELECT pricelist.fromquantity AS pricelist.fromquantity, pricelist.toquantity AS pricelist.toquantity, pricelist.id AS id
FROM
{pricelist} pricelist
WHERE (pricelist.sku = '017016') AND ((pricelist.fromquantity > '0') OR (pricelist.toquantity > '0'))
ORDER BY pricelist.fromquantity ASC, pricelist.toquantity ASC

I don't know why It is comparing to string '0' instead of integer 0.


texts:
Could anyone please help with the Double field module in Drupal 8 and Twig? I am trying to produce the following with no luck so far as I cannot figure out the proper Twig variables to use.

{{ first }}

{{ second }}

I would like to have the raw values in the html above.
-- I'm adding some more info here because my goal is to understand the mechanics of twig in this case and how I can get the field values of the two subitems

I have overriden (as suggested by drupal's theme debug system) the field--fieldname.html.twig template in which I have the following

{% for item in items %}

      {{ item.first }}

      {{ item.second }}

{% endfor %}

which is not printing anything in the value areas and apart from that does not iterate through all the items either.


texts:
The following code is working fine for uploading images. The node is being created but the uploaded images (under /sites/default/files/simpletest) are getting deleted after each complete test suite run.
Here the sample code
public function testArticleCreate() {
  $edit = array();
  $edit['title'] = $this->randomName(8);
  $edit["field_description[und][0][value]"] = $this->randomName(16);
  $field_name = 'field_image';
  $edit['files[' . $field_name . '_' . LANGUAGE_NONE . '_0]'] = 'sites/default/files/test-image.png'; // existed
  $this->drupalPost('node/add/article', $edit, t('Save'));
  $this->drupalGet("node/1/edit");
  }

Screenshot

Getting 404 not found for the image path (sites/default/files/simpletest/505284/test-image.png)
Any suggestions?


texts: How to write test cases for custom ajax functionality using simpletest in drupal7

texts:
I am trying to write the test case for my custom ajax functionality in Drupal 7. I am firing the event on click in my .js file but the test case gets a fail.

In my .tpl.php template file I have the following code:

Click Here

In the Js file I am getting the event as follows:

$('#myFirstEvent').live('click', function())
$.ajax({
        cache: false,
        url: Drupal.settings.basePath + '?q=mymodule/add',
        data: {page: page, sort: sort, order: order},
        dataType: 'text',
        error: function(request, status, error) {
            alert(status);
        },
        success: function(data, status, request) {
            /**Function definition goes here**/

}

In my custom.test file I have the following:

$edit = array();
$this>drupalGet("myform/add");
$this->drupalPost('myform/add', $edit, 'myFirstEvent');
$this->assertResponse(200, 'Success');

But I am not getting the success screen (Green Color) after I execute my test cases.


texts: Should I save temporary data in $form_state or in my form class?

texts:
As far as I can see, there are two ways of storing temporary data when working with complex forms in Drupal 8.

$form_state->set('key', 'value'). The value ends up in $form_state['storage']['value'], and I can use it other places because it is passed around from function to function.
Make a non-static property inside class MyForm extends FormBase. The value is also accessible everywhere I need it, since all of the form functions are in one class.

After browsing through a lot of core EntityForm code today, it seems that both are used! Is any of the above necessarily "better" or more in line with "The Drupal Way"?

Related question: It seems that there is a 1:1 mapping between an instance of MyForm and the $form_state variable. Why then, is $form_state not implemented as a non-static class property? Then it wouldn't be necessary to pass it from function to function. The same can be asked of the $form variable.


texts:
What is the latest and best way to set a cookie upon login? What I mean is:
if a user succesfully logins, then a session cookie user-is-logged-in = 1 is set. When the user logs out, this is removed.

I see this https://www.drupal.org/project/logincookie but its very old and doesn't look supported..
I see this but https://www.drupal.org/node/2160739 but it starts with a requirement with Varnish which I don't have..

I am using Drupal version 7.43.

As you know session cookies set by Drupal don't do the trick, as anonymous users are also set a cookie and from a browser's perspective, they are not differentiable.

Thanks a lot for your help!


texts: Show facebook friends activities from my site

texts:
I have connected Facebook on my Drupal site. My requirements are as follows.

Suppose user X log in using Facebook. He does different sorts of activities like creates an order, writes a review, likes a content etc.

When another user Y logs in to my site through fbconnect, I have to show him his friends' activities on my site. For example, in this case if X and Y are friends in Facebook, Y needs to see all of X's activities in my site.

How can I achieve this feature? I'm using Drupal 6.


texts: Views filter (contextual?) by Taxonomy id

texts:
Have a question.

I have a D8 website for our company. This website contains service pages and now I would like to add a block with reviews on every service page. But the reviews should match the service.
The website has taxonomy vocabulary with all the services. So when I create a service page I have to choose a service from taxonomy (basically, one service page represents one term id from taxonomy vocabulary). And when I create a new review I also have to choose a service from the same taxonomy vocabulary.

So now I would like to add a block with the reviews on the service page. But I have no idea how to make the reviews match with the service page where they are embedded.

Is there some kind of filter what match term IDs from different fields?
Regular filter, contextual filter? Tokens? Unfortunately, nothing worked for me :(

I could create different blocks for every single service ... but there would be a more universal solution.

Would be happy to get any help with that.


texts: How to customize validation functions for some field?

texts:
I have the standard node add or edit form.
The edited node has several fields.
How can I customize validation functions for a field ?
For example, I need to switch off or change validation function for some field.
How can I do it ?


texts: Only allow 1 discount using commerce_discount

texts:
I am having trouble finding out how to only allow 1 discount per order.

eg. a specific user role allows 15% discount on their order.
We also have another discount set up that applies a further 15% on a certain product.

We don't want to allow both discounts to be applied when that specific user role orders that product.

We are using:

Drupal 7
Commerce 7.x-1.13
Commerce_discount v 7.x-1.0-alpha5


texts: Drush remote sql-dump starts with "stdin: is not a tty"

texts:
When I run drush @SITEALIAS.live sql-dump > db.sql on some servers or in fact any remote drush command I get:

stdin: is not a tty as part of the return.

This is difficult when doing sql dumps as then you have to edit a multi megayte file to remove that from the head.


texts: Repeatation of class while adding class in twig template

texts:
I want to add CSS class to

 as shown in the following code. There are three

 codes where I have added calss using {{attributes.addClass('')}}

from book-navigation.html.twig

{% if tree or has_links %}

    {{ tree }}
    {% if has_links %}

{{ 'Book traversal links for'|t }} {{ book_title }}

      {% if prev_url %}

          {{ '‹'|t }} {{ prev_title }}

      {% endif %}
      {% if parent_url %}

          {{ 'Up'|t }}

      {% endif %}
      {% if next_url %}

          {{ next_title }} {{ '›'|t }}

      {% endif %}

    {% endif %}

{% endif %}

The output I am getting is with above code is,

But, I want as following,

Am I missing something, or there is other right-way to do that? Very Thanks.


texts: Use the panel for layout with multiple columns

texts: I created my own content type. I would like to further customize it by adding columns. I installed the module panel. Can I use the same panel layout to include my content type? Also, how do I put a picture in a field of the panel?


texts: Grant permission for custom role from hook_install programmatically

texts:
Drupal Version: 8.5.5

Need to assign permission to existing role during module installation:
Am using below code in hook_install:

use Drupal\user\RoleInterface;
use Drupal\user\UserInterface;
function hook_install() {

 $permission = 'test permission';
    $tester_rid = RoleInterface::TESTER;

    if ('tester' == Role::load($tester_rid)) {
      $tester_role->grantPermission($permission);
      $tester_role->save();
    }
}

Above grant permission is not working.
I have also tried with

user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
      'my custom permission',
    ));
user_role_grant_permissions(RoleInterface::TESTER, array(
      'my custom permission',
    ));

Above hook_install is not working.

Pls help


texts:
I hope use a CDN source as default, which doesn't load the local jquery.js while the CDN is OK. If the CDN doesn't reply, load the local jquery.js.

I have writted this in my template.php.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>!window.jQuery && document.write('<script src="<?php echo base_path().path_to_theme(); ?>/js/jquery.min.js"><\/script>');</script>

It worked well until I used the Flag module, which loads the flag.js file. I think this file just work with the version of jQuery that comes with Drupa, as it doesn't work with the jQuery library from Google CDN.

Did Drupal developers rewrite the whole jquery.js? I cant believe that.

What should I do to solve this problem? Can I fix it by rewriting flag.js?
If it's possible I really don't want use other module such as the jQuery Update module; it is too huge.


texts:
How can I track user contact form submissions on Drupal 6?

I'm thinking of something similar to the webform results table but for user contact forms.

If not something that complex, then just simple statistics on contact form use, e.g. "UserX received 10 emails this month."

I'm pretty sure I'll have to create my own module which is fine, I just need to know how to go about this.

Do you have any ideas?


texts: Views exposed filter by season from date field (date range group as month only?)

texts:
How would I create an exposed filter by season (spring, summer, fall, winter) based on date fields? I figured the approach would be to create date range filter groups by MONTH only (no year), but I don't see a straightforward way of doing this.
Any tips or advice for getting a workable solution? Thanks!


texts: How to use Rules to perform a monthtly reset of a field for all users accounts?

texts:
Once a month I would like to reset a field on all users accounts to 0.

At the moment I have a horrible way of doing it. Each time a user logs in the data is scheduled to be changed only for that user. This is done through a rule (using the Rules module) which whenever a user logs in runs 'Schedule component evaluation' with a data selector of site:current-user and a date of the first of the month. The component that the rule calls 'set a data value' of 0. This is obviously not an efficient way of handling this. However it does work.

Ideally I would like to have a rule that runs occasionally, I could use when cron is run. This rule would schedule setting the data value for all users of the site. The problem is that I don't seem to have a data selector of 'all users' to pass to the component.

Am I missing something really obvious here?


texts: When using /user/login as the default 403 access denied page, how can I add the tabs block to the login form?

texts:
After removing the anonymous permission to view published content, and setting the 403 access denied page to /user/login, the tabs block is no longer shown with the user login form.

The tabs block shows up when going straight to /user/login, but not when initially hitting the page as an anonymous user. Also, when hitting the front page HOOK_menu_local_tasks_alter() is not being fired.

Default front page is /node


texts: Create a custom view, and add a custom sortable column

texts:
I want create a view for display a list of contents. (same type)
(its my first fully custom view x) )

I want display the view like this :

//form : the user select a Date field, its an exposed filter field

COLUMN1           COLUMN2_sortable
-----------------------------------
content_title0    "special_value0"
content_title1    "special_value1"
content_title2    "special_value2"
...
content_titleN    "special_valueN"

First, can you tell me a good web tutorial for learn to create a fully custom view (so, create the user select form (contain exopsed filter) , the content of the view). After several google search, I difficulty finding a good guide...

Second, the COLUMN2_sortable contain a integer data. And this data is calculed via an another custom module (this value depends on the date entered in the exposed filter field). I have no ideas how add a custom column (here, the COLUMN2_sortable) in my view.
Because this is my first try in fully creating of view, can you advise me about the good way for implement that ?


texts: Attempting to merge in an array of items into Twig classes

texts:
I have a Twig template where I'd like to merge in an array of items as classes. So far I have this code:
{% set classes = [
  'media',
  'media--type-' ~ media.bundle()|clean_class,
  not media.isPublished() ? 'media--unpublished',
  view_mode ? 'media--view-mode-' ~ view_mode|clean_class,
] %}

 {% for item in content.field_category | children(true) %}
   {% set classes = classes|merge(item) %}
 {% endfor %}

<section{{ attributes.addClass(classes) }}>

etc...

Note that {% for item in content.field_category | children(true) %} is using Twig Tweak.
In this case for example, item represents term values for each item in plain text as:
Nature
Travel
Architecture

and then with <section{{ attributes.addClass(classes) }}>, I'd like the set classes as well as my custom classes to all be merged together. However, I am getting an error:
Notice: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 73 of core/lib/Drupal/Core/Template/AttributeArray.php).

So this tells me, I did not merge the array of items properly but I am lost after this, not sure how to fix it. My guess is, I need to do this without a for loop somehow?


texts: How to disable auto create customer profile after edit order?

texts: When I edit order (at url admin/commerce/orders/1/edit) and save order, a new custom profile will be created. I don't want that. How can I disable that?


texts: Trouble extracting year from date field for computed field

texts:
I have a date field, 'field_date', from which I need to extract the year.  The date format is yyyy-mm-dd, so I figured the following would do it:

$date = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_date')));
$year = explode("-", $date)[0];
$entity_field[0]['value'] = $year;

This gives me Parse error: syntax error, unexpected '[' Am I not getting the date string correctly?


texts: How would I go about writing a function to change the url of /blogs to /news?


texts: Apache Solr integration on shared hosting with cpanel

texts: If I do not have any other access to my site's remote server other than file manager via CPanel, is there a way I can get Apache Solr up and running on my Drupal 7 site? The remote host does not provide me with shell access. Does anyone know a tutorial link for this?


texts: How can I create a views with right-join relationship?

texts:
I would like to create a view with a relationship between 2 tables, where the relationship must perform right-join instead of inner join.
How can I do?


texts: How to have separated enabled modules in multisite based on Domain Access?

texts:
I have installed 'Domain Access' module to handle some sub-domains on a multisite installation based on Drupal 7.

This module share users, nodes and modules. But I want to have separated modules enabled on each sub-domain. But it seems if I enable a module it will be accessible on all the sub-domains.

Is the any way to bypass it? Sharing users and nodes are good points of this module and I need them but sharing modules ... no.


texts: How to create a page view of two content type in Drupal 7

texts:
I have two content type named as workshop and meetings. I wanted to create a new page view (say events) of these content type such that event page should have titles of post from each content grouped with content type.

I tried to create this view but I can't select multiple content type while creating a view.


texts: Drupal HTML.tpl.php file won't effect site?

texts: My aim is to allow zooming in and out in mobile devices in my responsive Drupal 7 site. I have followed a Drupalize.me video and some more documentation that teach how to allow it via my theme's HTML.tpl.php and added the marked row there (Image attached), yet nothing happened. Maybe it should go to the system's HTML.tpl.php instead? maybe there is something to apply at the Drupal UI so that the site would be affected? P.S - I've cleared the Drupal cache.


texts: PHP Fatal error: Call to undefined function entity_crud_get_info() in #########\docroot\sites ... in xxx/modules/entity/entity.rules.inc on line 96

texts:
I am getting the above error whenever I install the module.
The above errors keep occuring on every page.
How can I debug it or solve it?
I am clueless and working for a solution
Any pointers would be helpful.

https://www.drupal.org/node/2238251

The above link also has same issue but no fix provided
I am pasting the debug_backtrace provided :

Array ( [0] => Array ( [file] => /includes/bootstrap.inc [line] => 1112 [function] => include_once ) [1] => Array ( [file] => /includes/module.inc [line] => 24 [function] => drupal_load [args] => Array ( [0] => module [1] => custom_sarres ) ) [2] => Array ( [file] => /includes/common.inc [line] => 5126 [function] => module_load_all [args] => Array ( ) ) [3] => Array ( [file] => /includes/bootstrap.inc [line] => 2267 [function] => _drupal_bootstrap_full [args] => Array ( ) ) [4] => Array ( [file] => /index.php [line] => 20 [function] => drupal_bootstrap [args] => Array ( [0] => 7 ) ) ) Fatal error: Call to undefined function libraries_get_path() /sites/all/modules/feeds/feeds.module on line 1021


texts: Fatal error: Failed opening required file

texts:
I am quite new in Drupal. When installing Kickstart module in a Acquia based Drupal 7 setup on a localhost, I got this message. I looked on the internet and saw a lot of answers, but it didn't help me. It seems the plugins.inc file is fine, but I can't do anything now.

  Fatal error: require_once() [function.require]: Failed opening required '/Users/aztem/Sites/acquia-drupal/sites/all/modules/panels/plugins/export_ui/panels_layouts.inc' (include_path='.:/Applications/acquia-drupal/common/pear:/usr/lib/php') in /Users/aztem/Sites/acquia-drupal/sites/all/modules/commerce_kickstart/modules/contrib/ctools/includes/plugins.inc on line 475


texts: How to set up Media module with image editor?

texts:
I have installed Media module (7.x-2.0-beta2), but I can't find the module or setting for editing images that is in the video Drupal 7: Media Upload with Image Editing.

I want to set up the Media module for editing images as per this video.

Image editor in the media module


texts: Is it safe to use $view->argument in views hooks?

texts: I am using $view->argument['nid']->value[0] in a views hook to render a sql select query. Is it already escaped or is it the same as using $_GET?


texts: Drupal 6 Can I use subdomain, for the dev instance of a site and use multiple site configs

texts:
How do subdomains work in relationship to multiple sites? This seems to be danced around in the documentation that is out there.

more specifically. If I have...

primarydomain.com  as my site in the site folder.... and point the domain
dev.primarydomain.com at the drupal install without a dev.primarydomain.com folder will dev load the primarydomain.com or the default site?

The key behind this is I am trying to setup a 3 tier environment for drupal  (dev, test, prod) and want to have as few transformation processes to move things up the tier. So I am hoping I can simply put dev infront of the domain and everything will work.

Also if it does work can I do the same thing on a sub-subdomain? dev.blog.primarydomain.com?

Thank you for your help I am relatively new to drupal and working on putting an existing site into a dev environment to learn more safely.


texts:
So, I'm trying to generate some markup using render arrays. I need to create some nested divs. I thought that I could do this by nesting the arrays, as such:

function make_array() {
  $items = port_view_get_block();
  $array['container']['#prefix'] = '
';
  $array['container']['#suffix'] = '
';
  $array['container']['#markup'] = 'This is inside the container div';
  $array['container']['slider']['#prefix'] = '
';
  $array['container']['slider']['#suffix'] = '
';
  $array['container']['slider']['#markup'] = 'This is inside the slider div';
  return $array;
}

This doesn't seem to work. The inner array isn't rendered.

What is the proper way to get a nested structure using render arrays?


texts: Webforms with subheadings that have their own fields

texts:
I realise what field sets are as they can group parts of your webform together. What I am looking for though is to have subheadings within those fieldsets.

I've been trying to find tutorials about this but all I can find is tutorials on how to build a simple webform with just a title, description and then label-field pairs.

Edit: Say I want a form that calculates taxes for someone and I want to start off with a fieldset that has a couple of radiobuttons like male/female, I live rural/I live in the city and whatnot. Then I want some label/textfield pairs like name address phone, etc...
Then within the same fieldset I would have a title that says 'do you have a secondary address?' and have that be the title for a subset of fields with again address and zipcode, etc..


texts: How to add padding/margin for sidebar-right in Adaptive Theme?

texts:
I am trying to make something with Adaptive Theme, but I can't find how to set a padding or margin to Right Sidebar...

I am using only content -- right sidebar  layout, and if I wish to add some padding for Right Sidebar - it just disappears and falls down to bottom of page.....

Also, the problem started when I wanted to remove any Margin for a Content area, which was set to 10 px; but - when I removed margin for Content, it disappeared from Sidebar; and if I try to add margin/padding to Sidebar only, It just fall to bottom of page, probably resembling the tablet layout...


texts: How to modify ds_bootstrap_layouts templates to add more layouts?

texts:
I'm using the Display Suite Bootstrap Layouts module in Drupal 7, and I want to create additional layouts.

For example, I want the 4-4-4 stacked turned into a double 4-4-4 stacked. I know how to access the files and modify them, but it causes errors and it doesn't show up in the backend.

How do I add more layouts?


texts: Create views from combination of various vocabularies' terms

texts:
I am trying to find out if there is a module that can work out this magic or if I need to make a custom solution.

The problem:
I have Vocabulary1, Vocabulary2, Vocabulary3. The ideal would be to have something like tagadelic for all 3 vocabularies on the side, so whenever a tag is clicked the content displayed is additionally filtered by that extra tag.


texts: Basic pages are being rendered incorrectly do they differ at all to the article or custom content types in any fundamental way?

texts:
I have a custom theme, all (custom) content types display as expected except basic pages. Is there something fundamentally different to basic pages that explains/ helps me to troubleshoot why the markup is different?

The site has custom theme/child-theme, custom modules, and a heap of contrib modules so I can't really "paste the code", and as it's a development site I can't give access to it.

The problem I'm experiencing seems to be HTML markup errors, some missing closing elements etc., but I've stepped through most of the code already and can't see anything. Is it something specific to basic pages that Drupal does differently?


texts: Is it possible to create a table from Paragraph fields in Views?

texts:
I'm trying to create a table in Views with the information from a node that is using Paragraphs. Somehow I can't find a way to display the values from the paragraph fields in a proper table, is this even possible?
All I can manage to do is the table as shown in the picture below:

If possible, how can I create a table where each field has its own column instead? And if that's not possible – what other approach should I use?


texts: What data type to use for Commerce price field in a rule with a Views Loop (Views Rules)?

texts:
I want to create duplicates of some Commerce Products with the goal of giving these products a new Product type. With great help (How to change the product type of selected Drupal Commerce products (without direct DB updates)?), I have managed to use the Views Rules module to create a Views loop that should iterate through a selection of Commerce Products and duplicating them (creating new entities) with the new product type.

All fields except one accept the data type "Text", and the variables created looks like [sku:value], [title:value] and so forth.

The problem is that I keep getting PHP errors like this:

  Unable to create entity commerce_product": Invalid data value given.
  Be sure it matches the required data type and format. Value at
  commerce_product()->commerce_price: .

... telling me that the data format for the Commerce price field is wrong though. I have tried using "text" as data type (and also "Price", "Commerce product" etc.).

Whatever I do in the action part of the Views loop, I keep getting a numeric field for the price (I can't just paste [price:value] in the field). I can switch to "Data Selection input mode", and add something like commerce-price:base-price (if I use Price as data type for the price field in the variable settings for the Rules View in question) but that also ends with a PHP error like I described above.

What to do with the variable for the commerce price here?

EDIT: this is the price field I get in the Action part of the Views loop, no matter what data type I assign to the price field in the Rules View, including Integer (in the variables configuration). I have also tried to add an action that converts the price into an integer jag before the action that creates the new entity. If I switch to Data Selection there are no price fields to be found.

And if I toggle to Data Selection mode this is what I get. No price field can be selected.

It really seems impossible to use the price field in a views loop.


texts: I have a view and an exposed filter with a date field, I want to make this filter as a date picker, not a text field, I've used Better Exposed Filters but didn't find anything in view, I had used it much time in D7 but In D8 cannot find it in the view exposed form style. So what should I do to use this module


texts: How to programmatically set user state to "active"

texts:
Is it possible to programmatically set all users to active?

This problem arises because I am trying to display my users using Views, but because my migrated users are "blocked", I cannot expose them to Views.

Could someone provide a snippet of code or a tutorial on how to set user status to active?

This is the code that I need to execute at the beginning.

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

// Set the active DB
db_set_active('sage');


texts: Is There a Generic Theme Duplication Module or Drush Command

texts: As I understand there are Drush commands for Adaptive Theme, Omega, Zen and maybe other themes for creating subthemes, but is there a more generic module/way to create/duplicate a theme?  It would be nice to give clients a way to mirror their theme within the interface.


texts: How do you load extra javascript files required for wysiwyg api plugin on node/edit pages?

texts:
I'm building a plugin using the WYSIWYG API module for Drupal 7 that will add a button to the toolbar of supported editors.

I'm using the hook_wysiwyg_plugin() hook to create a new button on editor toolbar but I need to load a few other javascript files. The hook_wysiwyg_plugin() hook seems to allow you to specify one JS and CSS file.

How can I load extra required javascript files required for the plugin javascript?

I've implemented hook_library() to define a library i.e. js/css files but am unsure how I hook that up to wysiwyg api so that they load on the node/edit screens?


texts:
I'm stuck on this issue, I've followed a variety of idea and tutorials trying to fix the issue, most which follow a similar path to this (http://stevenmcmurry.com/howto/2014_07/enabling-clean-urls-drupal-ubuntu-1404-lts). I'm running off of Apache2 on Ubuntu.

Currently my 000-default.conf looks like this:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port t$
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>
# error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

</VirtualHost>

But I'm still running into the issue of clean URL's not allowed to be enabled. The odd thing I'm trying to work on is at the moment, I can't see the .htaccess in the drupal site root.

Has anyone run across a situation like this?

Thanks!


texts: Adding more fields to the registration process

texts: In Drupal 7, is there a way to add more fields to the registration process? I was thinking along the lines of birthday, fullname, gender, twitter, etc. Also how do I access this data once it's in, so I can output it to my template files?


texts: Make the Main Menu have dynamic links based on url

texts:
My main menu has links to common things: HOME | PHOTOS | VIDEOS ... etc. Home points to /, PHOTOS points to /photo-galleries and VIDEOS points to /videos

The client has added a new feature request and I'm trying to figure out how to handle this. The site has a couple of general topics, let's say baseball, football and soccer.

When I browse to the main home page /, then the menu should point to /photo-galleries and /videos.

However, when I browse to the "baseball filtered" home page /baseball then I'd like the photo galleries menu link to point to /photo-galleries/baseball and the videos link to point to /videos/baseball.

This "filtering" should follow them through out the site, so once they are on /videos/baseball then all of the menu links should continue to have the baseball element on them.

I'm unsure how to approach this problem and I feel like there should be an elegant way to handle this and I'm not the first person to have this problem.

I understand how to setup my various Views on the different pages so they have contextual filters and only show the content items with the baseball tag, but my big question is about how to handle re-writing all of the URLs of the menus and the content URLs.

Help? :)


texts: Customising Views Serializer JSON Output

texts:
I have created a Views Rest Export that looks like this:

{
   "id":"10",
   "title":"Plot 10",
},
{
   "id":"20",
   "title":"Plot 20",
}

But I would like to wrap some extra bits around it like this:

{
   "mapwidth":"690",
   "mapheight":"982",
   "levels":[
      {
         "id":"uk",
         "title":"United Kingdom",
         "locations":[
            {
               "id":"10",
               "title":"Plot 10",
            },
            {
               "id":"20",
               "title":"Plot 20",
            }
         ]
      }
   ]
}

I have created a php file with this in it, which seems to work:

{
    "mapwidth":"690",
    "mapheight":"982",
    "levels":[
        {
            "id":"uk",
            "title":"United Kingdom",
            "locations":
            <?php $locations = file_get_contents('/api/plots?_format=json');
            echo $locations; ?>
        }
    ]
}

But I was wondering what the better way of doing this would be.

Thanks in advance.


texts: How can I programmatically alter a view query?

texts:
I need to be able to pass a date+time argument to a view. When I add a date field as a contextual argument, the query is only passing this in Y-m-d format. I need to include the time so that I can get a list of events that are happening at a certain time.

I think I should be able to use views_query_alter to change the ->where condition, but I'm not sure where to go from there. If I do this:

function mymodule_views_query_alter($view, $query) {
  if ($view->current_display == 'mydisplay') {
    dsm($query->where[0]['conditions'][0]['field']);
    $query->where[0]['conditions'][0]['field'] = ???
  }
}

This is the output from the dsm:

DATE_FORMAT(node__field_session_date.field_session_date_value, '%Y-%m-%d') = :node__field_session_date_field_session_date_value

How do I change that %Y-%m-%d to include the time in the correct format?


texts: Moving File Directory to Other Partition

texts:
I want to know if it's possible to move the files directory, put it in another partition, and point to it. I've tried several methods and can't find the solution.

This is what I've tried:

I created a second partition on my disk and moved all /files/ folders into it, so I have a D:/files folder.
I went to admin/config/media/file-system and changed the 'Public file system path' prompt from 'sites/FirstProject/files' to D:/files/.

However, the styles are missing from the site and I don't know why.

The installation path of my project is C:/xampp/htdocs/www/proyects/sites/FirstProject/files (it is a multi-site installation), and I want to move the files directory to this partition, D:/files.

Can someone help me?

Thanks in advance.


texts:
I am redirecting most of the pages of my old website to a new subdomain of the same domain, from http://www.domain.com/www-page_url to http://new.domain.com/new-page_url/with-different-slug. This new URL value exist in (almost) every page of the old website.

How would I proceed to create a general rule that permits the redirection from the page itself to new.domain.com/page_url existing field value?


texts: How do you upload files using the RestWS module?

texts:
I have a remote front-end application under development and I would like to interface with Drupal as a backend service, using the RestWS module to create a RESTful service to my Drupal instance (using JSON as my data format).

I have a node content type of type "article", that has an image field on it called "field_image".

I'm currently trying to figure out the proper way to upload a file to Drupal through the API created by RestWS.

I can retrieve a node with a file attachment via GET to the URL http://www.example.com/node/1.json, which retrieves the contents of node 1, including the information about the uploaded file:

https://gist.github.com/lhridley/8bbf95294aa529d74c74

I can also retrieve information specifically about the file attachment, using the FID returned when requesting information about the node, using the url http://www.example.com/file/1.json:

https://gist.github.com/lhridley/804eb93016845f369535

Now, my question:

How specifically do you upload a file using RestWS, so that you create a file resource to then use when creating a node?


texts: Creating followups to Commerce Orders for each Line Item

texts:
I had asked a question in another thread, and thought it might be helpful to create its own thread just in case it could be helpful to any other developers out there:

"I am trying to create a rule which follows up on existing orders of specific products. Each product has a different time interval for "follow up reminder", and my rule should trigger an email to be sent to a customer at a date which is calculated Order Creation Date + Follow Up Interval.

ie Order Creation + Value provided from Products in the order"


texts: Javascript that I add to page dosnt seem to run

texts:
The thing I want to achieve is that on a specific page my module places a google map with markers on it.

Here is how i do it:

First I add this:

$setting = variable_get('locationUrl', '');

if (!empty($setting)) {
    $items[$setting] = array(
        'title' => '', //page title
        'page callback' => 'page', // use the same name as your pagecallback
        // 'access arguments' => array('access simple page'),
        'access arguments' => array('access content'), // temporarily use this
    );
}

That is for creating the page.

Then I add this:

function page(){
     drupal_add_js('https://maps.googleapis.com/maps/api/jskey=AIzaSyDcl28Qcn9GTi02rRtQaLgVS4GWZbGcQ8E', 'external');

     $settings['myModule']['location'] = db_query('SELECT * FROM {locations}')->fetchAll();
     drupal_add_js($settings, 'setting');
     drupal_add_js('sites/all/modules/GoogleMapByDave/DGMap.js','external');

     $html = '

     ';
     return array('#markup' => $html);
}

That is for page content and adding the javascript.
I probbably should write this line differently right? "drupal_add_js('sites/all/modules/GoogleMapByDave/DGMap.js','external');"

And my javascript:

(function($) {
   Drupal.behaviors.myModule = {
     attach: function(context, settings) {

      //var locations = Drupal.settings.myModule.locations;

      function initialize() {

           var mapOptions = {
               center: { lat: 56.9714744, lng: 24.1291624},
               zoom: 9
           };
           var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

           var locations = [
                    ['Mājas',56.956344, 24.197409],
                    ['Domina',56.966058, 24.162004]
                    ];

           for (var i = 0; i < locations.length; i++) {

                  var loc = new google.maps.LatLng(locations[i][1], locations[i][2]);

                  var marker = new google.maps.Marker({
                        position: loc,
                        map: map,
                        title: locations[i][0]
                        });
           };

       }

       google.maps.event.addDomListener(window, 'load', initialize);

     }
   }
)(jQuery);

I look at the page that is created by this. The gooogle maps api is placed in the page. And it seems the javascript is placed too, but it dosnt create google maps in the page.

I have found out that if i just add this to my code:

drupal_add_js('jQuery(document).ready(function () { function initialize() {

    var mapOptions = {
      center: { lat: 56.9714744, lng: 24.1291624},
      zoom: 9
    };
    var map = new google.maps.Map(document.getElementById(\'map-canvas\'),
        mapOptions);

    var locations = [
                    [\'Mājas\',56.956344, 24.197409],
                    [\'Domina\',56.966058, 24.162004]
                    ];

    for (var i = 0; i < locations.length; i++) {

      var loc = new google.maps.LatLng(locations[i][1], locations[i][2]);

      var marker = new google.maps.Marker({
        position: loc,
        map: map,
        title: locations[i][0]
      });
    };

  }

  google.maps.event.addDomListener(window, \'load\', initialize); });','inline');

This will make the map show, but then i cant pass down variables right?


texts: Fatal error memory limit (always) while installing a module

texts:
I am asking for help in solving an extremely annoying problem. I have a simple website based on Drupal 9. Due to its simplicity, the installation of all modules was based on the Drupal UI. I also have one small module of my own that creates several blocks.
When I try to add libraries to the ReCatpcha module via Composer, I still have an error:

Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///home/myaccount/composer.phar/src/Composer/DependencyResolver/RuleWatchGraph.php

I have 512M of memory on the server. I would like to add that everything works fine on a clean Drupal 9 installation, modules are added correctly. On this page, however, it is possible to update Drupal 9 via Composer, but you cannot add any modules.
I was looking for a solution on the Internet, but there are only possibilities to increase the available memory to '-1' => no limit. It is not an option for me.
I will just add that I can not install any module. I always have the same message.
I suspect that Composer is not coping with something, but it won't say what. Is there any way to solve this problem?


texts: Long-running cron task never fully executed

texts:
I am developing a Drupal Cron that has a very long-running task.
First I tried with a simple Cron, which, of course, did not work because of "Memory exhausted" PHP fatal error.

Then, I developed a Batch with the Batch API which worked fine as a normal Batch. However, I could not make to run it completely inside the Cron. It receives the same PHP error.

After that, I developed a Cron using the Queue API. However, I could not make Drupal to run all queue jobs in the same cron. The execution stops at some point and I am unable to run more jobs. I know that there is an option to define the worker's function time, but my task is a long-running task. So it is limited by PHP.

I also tried to use Background Process module in order to execute my long-running task but it had the same problem as before: the execution stops at some point.

I am sure that the code can be executed completely. The only working way was through Batch page but I want to run it automatically every day (Cron).

Do you know how can I run a Cron until it finishes?

As I said, I tried with Batches and Queues but it did not work. PHP "memory exhausted" or timeout errors appear or the execution can be cut by Drupal.

Thank you.


texts: switching language requires users to login again

texts:
I have a multilingual site, that when people switch from one language to another, they are required to log in again.

but if they switch to the language they switched from the user is still logged.

so basically you could log into my site with 2 different accounts.

how is this possible? any ideas whats causing this?


texts: Hiding empty section of a custom content type if field is left empty

texts:
I am relatively new to Drupal so I need someone to school me here.

I have created a custom theme and using theme key to attach it to a new content type (HTML Email). It roughly has about 12 sections consisting of a header graphic and a text area.

I’ve created a view and added all the fields to it displaying as a block in my custom theme using the views-view-fields—[name].tpl.php.

It displays perfectly but my issue is not all the section of the content type will be used so If the text area in a section is left blank I want that section not to show up in the block.

Below doesn't seem to work

<? if ($fields['field_text']->content): ?>

           <?php print $fields['field_header']->content; ?>

         <?php print $fields['field_text']->content; ?>

<? endif; ?>


texts:
I have a node "Contact page" and a menu link called "Apply". "Apply" is a menu child of "Contact". Put another way, "Apply" appears on the second level of the main menu under a menu link called "Contact".

When I want to create another "Apply" link which should be a child of the menu link "Programme", "Programme" will receive the "is-active" class as the active menu parent although "Contact" is the original parent and should, ideally, be the active menu trail.

Menu structure:

Contact    Programme
  Apply        Apply [symbolic link to Contact > Apply]

This is important because there are different sidebars displayed on Programme > Apply versus
Contact > Apply.

Is there a way to create a symbolic link called "Apply" as a child for the menu link "Programme" that references to "Contact page" and sets "Contact" > "Apply" as the active menu trail?


texts: What would cause a form validator with the right naming convention not to execute?

texts:
I am supporting a site that uses version 7.x-2.0-alpha of the File Entity module, and a user reported that updating files was not working.

Using a debugger and comparing to another site, I tracked this down to the fact that the file_entity_edit_validate() function was not executing, which contains the code for actually saving the file that is in the "replace_upload" attribute of the form. The validator is not named specifically in the form definition; it looks designed to just be called by naming convention.

When I manually add '#validate' => array('file_entity_edit_validate') to the submit handler array for the form, everything works as expected.

This seems to be a conflict coming from some other module on the site, as when I install it from scratch using the same codebase, this problem does not occur. Also, building a site from scratch using the same versions of Media and File Entity does not exhibit the problem.

There are a ton of other modules running on the site. What could I look for that would be causing that validate hook not to fire?


texts: Which module can create a sitemap based on entity reference rather than menus?

texts:
Does a module exist that creates a sitemap based on entity reference rather than menus?

The site I am currently working on has it content linked using entity reference rather than using Drupal menus. The reason it has been done like this is because content can fall into multiple categories. But now I am facing the issue of generating a sitemap. Is there anyway to do this? Can it be done using Views maybe?


texts:
I have a #states on the exposed filter form as follow:

If field_a == 'b' then field_b show, field_c hidden;

else if field_a == 'c' then field_c show, field_b hidden;

All fields here are Select list.

The states is working fine, problem is the value of the hidden filter is affecting the view result, which i dont want.

Questions:

1) How to change the hidden field value back to default(to -Any- in Select List)? JQuery maybe?

2) How to avoid the hidden filter affecting the view result and to remove the filter (?...&field_b=xxx) in the query string?

updates: working code for states.

 $field_state = array( 'visible' => array(':input[name="field_a"]'
 => array( array('value' => 'a') )),       );

 $form['field_a']['#states']   = $field_state


texts: How do i create nested tabs in drupal 7 view?

texts:
I am trying to create an image gallery from view.

I have a content type called "Photo-Gallery" with fields  title of event,year,month and images

I have created a view with this content type and created page with Unformatted list.I am trying to make a gallery based on the following layout. How can i code custom view template?I want this by Year wise and then Month .

Unfortunately i am stuck on half way. Could you please suggest me a proper way to code the  view to get the exact result.

Awaiting quick replies.


texts:
hello I have a drupal multisite setup, with the same modules and paths enabled ( services with REST endpoints).
I have some weird behavior:

on site1 I call a URL and get the HTTP status 401 ( which is normal as the test has the not signed request). I am not signing for the purpose of this test.

on site1 it works no matter which browser I use.

now site2, all is setup, and when I test it from chrome/firefox/IE/safari it all works (rest client, rest console etc...), when I say it works it means that I get the 401 back.
BUT when I test with safari mobile, or webview I get a 404. same request, same everything.

here are some log entries:

site1.net ###.##.180.109 - - [13/Aug/2013:16:07:01 +0000] "GET /REST/myapp/sendPassReset/oscar4/123 HTTP/1.1" **401** 157 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B141 Safari/8536.25" [smartphones] [0.671] [MISS] [nil]

site2.net ###.##.180.109 - - [13/Aug/2013:16:07:15 +0000] "GET /REST/myapp/sendPassReset/oscar4/123 HTTP/1.1" **404** 5 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B141 Safari/8536.25" [smartphones] [0.219] [-] [nil]

site2.net ###.##.180.109 - - [13/Aug/2013:16:54:36 +0000] "GET /REST/myapp/sendPassReset/oscar4/123 HTTP/1.1" **401** 180 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36" [-] [0.285] [-] [k-xae2qQMbNdjU4VbQoTpoTh1c2gfnvp-8cz7505Ajk;]

both sites are served by nginx, and PHP-FPM, with the same configuration.
same code base.

any idea as to what can be happening?


texts: Disable transition effect field slideshow

texts:
I have installed the Field Slideshow module.

I want to set the transition effect to none in manage displays (content type).
How can this be done, I tried to set the interval to 0 but the slideshow keeps going.


texts: How to disable input field but show tekst with hook_form_alter?

texts:
In D8 I have a form with several fields.
One specific field is a number. Input widget is Integer.

This field is prevalued with hook_form_alter like:

$nid     = \Drupal::request()->query->get("source"); // query string param
$node    = \Drupal\node\Entity\Node::load($nid);
$pe_punten = $node->get('field_pe_punten')->value;

I would like to achieve that the user has no access but can see this value. To disable it I can do:

$form['field_pe_punten']['#access'] = FALSE;

But how to replace this input widget with a piece of text which says "10 points"

I red several other QA but could not find out how to do this?


texts: Which module hook to use for CRUD operations on custom table?

texts:
I have used hook_schema() in my module to create a custom table in the Drupal database - the data is unrelated to anything in Drupal.

I would like administrators to be able to insert, update etc. records in this custom table. I had thought to use the function hook_form() for this, but upon closer inspection this hook relates back to nodes. My custom table has no relation to nodes.

Is there a different function I should be using?


texts:
Is there a way to have a CCK Field have two values for one input?

For example, a field called 'Sodium' and two values, '190mg' and '8%'- first being the amount, second being % of daily value.

If not, whats the best way to achieve this?

Edit:

The best solution I am looking for would be sets of Fieldgroups, and each row having 3 inputs. Label | value (required) | value (optional) - so, Sodium | 190mg | 8%