texts: How do I make my service dependent on another module existing?

texts:
I want to provide a service in my module, but only if another module (say the core File module) is enabled. I don't want to require this module, it should be optional.

Something like this:

services:
  helper.file:
    class: Drupal\helper\File
    arguments: ['@entity_type.manager']
    requirements: ['file']

Is there a way to do this without needing to declare it as a dynamic service? If not, is there an example on how to declare a dynamic service, because https://www.drupal.org/node/2026959 is woefully lacking:

  Finally, it is also possible to define the register() method to register services dynamically, however this should be very rare.


texts: How to include multiple Views in an already existing feature?

texts: I have to work with an old Drupal 7 site. It's using features. I created some new views, now I have to include these 2 new views into a feature which already has 1 view. How can I do it and which steps or hooks I should follow? Thank you


texts:
Is there a location where I can drop in a custom JavaScript file in Drupal 7.x?

It just includes simple event actions for menus, and I don't want to edit the theme/module files.

Or do I have to just add the "include" hook to the theme/module?


texts: How can I access individual form elements for theming?

texts:
I have overridden the default user login form in Drupal 8 using a different template in my sub theme, but it isn't of much use because when I access it in twig template, all I can do is

<form {{attributes}}>
{{children}}
</form>

Doing this I get the elements in same order, and there is not lot of modification option. I can put them in container but that is it. I was wondering there was instead a way to call elements like username field, password field individually instead of doing a bulk call using {{children}}.


texts: How to select a random user from a list of users that have flagged a content?

texts:
I'm trying to make some kind of contest site, in which users can publish random old stuff, which will be raffled later between the users that have marked that content.
I crated a specific content type for this, let's call it "kiwi", with a winner field.
Then created a flag for that content, so, every content created has the button saying "I want this", when you click, you are kind of "subscribed" to that content.
I want to create a rule, which chooses a random user from the list of user that have flagged the content.

I've been struggling with this for a lot of time, I don't have any more ideas on how to solve this.

Thank you very much


texts: Drupal 7 "The form has become outdated. Copy any unsaved work in the form below and then reload this page."

texts:
I have a problem. When I put this code in my module checkboxes work great but form throws an error:

"The form has become outdated. Copy any unsaved work in the form below and then reload this page."

Alert one add node form.

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

  $form['add_phone'] = array (
    '#type' => 'fieldset',
    '#title' => t('Adauga telefon'),
    '#weight' => 6,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

  $form['add_phone']['phone'] = array(
    '#type' => 'phone',
    '#title' => t('Phone Number'),
    '#required' => TRUE,
  );

  $form['add_phone']['phone_submit'] = array (
    '#type' => 'button',
    '#value' => 'Add',
    '#prefix' => '
',
    '#suffix' => '
',
    '#ajax' => array(
      'callback' => 'automobil_add_phone_callback',
      'wrapper' => 'add-new-phone',
      'effect' => 'fade',
    ),
  );

  if(isset($form_state['values']['phone']['prefix'])) {
    $upload_users_phone = _upload_users_phone($form, $form_state, 'add');
  } else {
    $upload_users_phone = _upload_users_phone($form, $form_state, '');
  }

  $form['field_temporary_phone'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
    '#title' => t('Telefon'),
    '#type' => 'checkboxes',
    '#weight' => 5,
    '#options' => $upload_users_phone,
  );
}

Ajax Callback

function automobil_add_phone_callback(&$form, &$form_state) {
  return $form;
}

Function that returns a list of user_phone that is stored in user profile.
If a user adds new phone it adds it and return the updated list.

    function _upload_users_phone($form, $form_state, $operation, $returns) {
  global $user;
  // load user

  $existingUser = user_load($user->uid);

  if($operation == 'add') {
    $existingUser->field_user_phone['und'][]['value'] = $form_state['values']['phone']['prefix'] . ' ' . $form_state['values']['phone']['number'];
    $user = user_save((object) array('uid'=>$user->uid), (array) $existingUser);
  }
    // edit field-data
  foreach ($existingUser->field_user_phone['und'] as $key => $value) {
    $val_list[] = $value['value'];
    $key_list[] = $key;
  }

  return $val_list;
}

What is a problem (why is the 'form outdated form' error thrown)?


texts: How to block certain IP addresses if we receive too many GET requests from particular IP addresses for a Drupal 7 website?


texts:
I am going to create this, But I really don't know how to do it.

and I want to create one view with two blocks.

what Format of view should be? (HTML list, Grid, Table, ...)

I don't know theming, How can I do this and arrange these blocks horizontally beside each other?


texts: Files View, How to display Images related to Media Gallery?

texts:
I have created a view in views to show files of type image. Under fields I have selected File Rendered. Now my view is displaying all the images.

The problem is this that I only want to display images which belongs to galleries created through media gallery module.


texts: How can I get a block to display only on node view in Drupal 6

texts:
I have a block that I need displayed only on the main page of a node.

I can get it to display on node/1/view by putting node/*/view in the conditions, but that only works if view is in the URL. I want it to show whether I go to node/1/view or node/1, but NOTHING else. If I try node/* it shows it for every node page, not just node/1. I also tried node/*/ but that didn't work at all as it appears the ending slash is being removed.


texts:
I'm using Drupal 7 and I have a module which has working implementation of the Entity API module.

In my_module.install file there is a hook_schema() in which I defined table columns:

$schema['my_subscription'] = array(
'description' => t('The base table for subscriptions'),
    'fields' => array(
      'sid' => array(
        'description' => t('Primary key identifier for an subscription log.'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'email' => array(
        'description' => t('Email of a users subscription.'),
        'type' => 'varchar',
        'length' => '250',
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => t('Full name of a user subscribing.'),
        'type' => 'varchar',
        'length' => '250',
        'not null' => FALSE,
      ),
    ),
    'primary key' => array('sid'),
);

return $schema;

In my_module.module there is a hook_entity_info():

 /**
 * Implements hook_entity_info().
 */
function my_module_entity_info() {
  return array(
    'my_subscription' => array(
      'label' => t('Subscriptions'),
      'base table' => 'my_subscription',
      'entity class' => 'Entity',
      'controller class' => 'EntityAPIController',
      'fieldable' => FALSE,
      'entity keys' => array(
        'id' => 'sid',
      ),
      'bundles' => array(),
      'module' => 'my_subscription',
    ),
  );
}

Records are created from the module like this:

    $values = array(
      'email' => $email,
      'name' => $name,
    );

    $subscription = entity_create('my_subscription', $values);

It's all working good, and there are couple of hundred subscriptions at the moment.

Now I need to expand the table with one more column, I'll call it 'test' for simplicity. I added a hook_update_N() to the my_module.install, added

 db_add_field('my_subscription', 'test', array(
    'type' => 'varchar',
    'length' => 64,
    'not null' => FALSE,
  ));

and ran update.php which added the column as expected.

Now, when I try to pass new column value in the $values array like this

    $values = array(
      'email' => $email,
      'name' => $name,
      'test' => 'lorem ipsum'
    );

    $subscription = entity_create('my_subscription', $values);

record is made, but the newly added 'test' column has the value of NULL no matter what.

I suppose I need to tell Entity API that there is new field that needs to be populated as well, but I don't know how.


texts:
I have a view with 2 fields, node_title and node_related_content. For the field node_related_content I use the formatter = rendered node and view mode = Preview. These rendered nodes are fetched from a multiple value field in a content type "product group" that I use for listing related products.

In the view I use a contextual filter that gives me all the node IDs that belong to this view.

Now, the view works fine for one result (one group of rendered nodes). But if I enter more than one node ID in the preview field it onlyt gives me the first group... I need to have all the products groups, not just the first one.

What do I do wrong here?

This is the resulting SQL query:

  SELECT node.title AS node_title, node.nid AS nid,
  field_data_field_koppla_givare.delta AS
  field_data_field_koppla_givare_delta,
  field_data_field_koppla_givare.language AS
  field_data_field_koppla_givare_language,
  field_data_field_koppla_givare.bundle AS
  field_data_field_koppla_givare_bundle,
  field_data_field_koppla_givare.field_koppla_givare_nid AS
  field_data_field_koppla_givare_field_koppla_givare_nid, 'node' AS
  field_data_field_koppla_givare_node_entity_type FROM  {node} node LEFT
  JOIN {field_data_field_koppla_givare} field_data_field_koppla_givare
  ON node.nid = field_data_field_koppla_givare.entity_id AND
  field_data_field_koppla_givare.entity_type = 'node' WHERE (( (node.nid
  = '26262,21888' ) )AND(( (node.status = '1') )))

So the above query only shows the rendered nodes found in the product group 26262. The product group 21888 is ignored.

UPDATE: after experimenting with the SQL query in phpmyadmin I have found out that the last row in the query should look like this:

  WHERE (( (node.nid IN('26262', '21888', '21877') ) )AND(( (node.status = '1') )))

Now, how can I alter my view to reflect that change?


texts: Trying to print translated field label/values to twig

texts:
I have been trying to figure out how I can print or display the translated values based on the current language of the page.

I have tried using some of the following options {% trans %} and {% endtrans %} does not work

{# {% trans  %}

{{ tab_label.entity.field_tab_title_selection.value }}

{% endtrans %} #}

2nd Option using preprocess, the problem with this method in the event I have multiple language setup I have to create multiple if's statement. Lets say I have 10 languages then I have to create 10 conditions

Using Pre-process

function iom_preprocess_page(&$variables) {

    $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $vars['language'] = $language;

}

{# {% if (language.getId() == 'fr')  %}

{{ tab_label.entity.field_tab_title.entity.translation('fr').label }}

{% else %}

{{ tab_label.entity.field_tab_title.entity.label }}

{% endif %} #}


texts: How to use Simple hierarchical select on a view starting at second level taxonomy?

texts:
I am using the Simple hierarchical select on a view for a an exposed taxonomy term, but I want the first level of the taxonomy to be preselected, so that the user can only choose the second and third levels.
I tried to do this by adding jquery to change the first element, but it doesn't load the second level taxonomy then.

Is there a parameter in this module so I can preselect the first level taxonomy term and not let the user change that?


texts: Using Workbench Moderation state changes as events

texts:
I would like to use the Rules module to send out emails to specific roles whenever a moderation state change event occurs on a node. So if a node is saved, and it goes from Draft to Needs Review, this rule would be triggered to send out emails to the Content Approver role.
This was possible in the Drupal 7 version of Workbench Moderation and Rules, but not out-of-the-box with the Drupal 8 version of these modules.
Any ideas what to do here to accomplish this?


texts: When user navigates to a URL, import feed of XML file specified by ID in URL

texts:
I have a url www.example.com/123456, generated by a third party source. So there is not, at the time the user clicks, any node that corresponds to that URL. The six digit number at the end is an item id, which corresponds to the XML document http://example.com/item/123456/description.xml.

Is it possible to configure Feeds and the XPath parser to, when a user clicks on one of these links, to grab that six-digit number, and import the data from the XML document (by argument) into a node?

EDIT

Here is some code I tried to test, but I don't know if it can trigger on navigation to the "node" (which, remember, doesn't exist until import).

    //Trying to grab those last six digits, which are the ID I need to grab the XML file
    $idnr = $_GET['q'];

    //Compare this ID to the aliases I have on already imported nodes so we don't import those again
    $nodeids = db_query('SELECT dst FROM {url_alias}');

    if(!in_array($idnr, $nodeids)){
    //Check if that ID is in the array. If not, create the node
          $node = new stdClass();
          $node->type = 'special_node';
          $node->status = 0;
          $node->path = $idnr;
          //I already have this feed set up for that particular content type and with XPath parser
          $node->feeds['FeedsHTTPFetcher']['source'] = 'http://www.source.com/' . $idnr . '/desc.xml';
          node_save($node); //Create the node
          $_REQUEST['destination'] = $node->path; //Redirect the user to the node
    }

Is any of this feasible to do? Especially in a way that isn't disruptive to the client?

EDIT 2

I have WAY too many fields to map to use Feeds (100+). Does someone have an idea how I could use Migrate to import this XML data upon navigation to the URL?


texts:
I have stumbled upon a caching problem. The scenario is the following.
I log in as admin. I visit another node. I return to the frontpage.
Result is that the frontpage is showing as if I am not logged in.

I think it is a caching issue, since checking from Network I can see that the frontpage is cached.

There is a problem that this is caused by modification of the html.tpl.php file.
I have added.

    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Sun, 01 Jan 2012 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />

Do you have any ideas or dealt with a similar issue?


texts: Simplenews - how pass values from own input

texts:
How I can pass value from added input to database(?) in Simplenews? I want to use this value later in newsletter, e.g. print it in block template.

Below is how I created field

function news_hook_form_alter(&$form, &$form_state, $form_id){
    if($form_id == 'simplenews_block_form_2730'){
        $form['field_name'] = array(
        '#type' => 'textfield',
        '#title' => t('First name'),
        '#required' => TRUE,
        '#size' => 20,
);
}}


texts: Translations working but not translating

texts:
I have a multilingual site.
I set as default language Portuguese and added another language as English.

I was able to translate everything but then I don't know what happened. All the blocks are working fine but when i try to translate a Basic Page this is what happens:

Example:
My basic page is in Portuguese (as default). I click "translate" and choose "English". I change the title and body of the Basic Page and save.

Then, when i switch to portuguese, everything is in English even the Portuguese Version!
And when I go change the portuguese version to portuguese translations, everything changes to portuguese.

The title is the only thing that says Portuguese and English respectively.

Any clues to what's going on? Can anyone help me?

Thank you!


texts:
I want be able to have users search for other users based on distance. I thought I did it correctly but everytime I search I get no results.

Heres what I did:

Install location https://drupal.org/project/location
Enabled location /w location entity, location search, location
taxonomy, user locations
Added location field to profile2 profile
Ran the US zipcode file that comes with the location module
Created a view to show profiles
Added a relationship to location
Added a filter of location proximity search based on zipcode and country /w a relation field_location


texts: How to use language-specific menu items in URL aliases

texts:
I'm working on a site with internationalization from the source language, English, into a few other languages. Translating the pages has worked out fine; however, I'm running into trouble with URL aliases.

Some of our pages have different menu labels vs. page titles (e.g. Terminals as the menu label vs. Terminal Information as the page title), and since the client wanted the shorter menu labels in the URL, my default path pattern (set using the Pathauto module) is [node:menu-link:parents:join-path]/[node:menu-link:title].

Menu items are also set per language – so while Terminals is the English version of the menu item for that page, when viewing the site in French, I have a menu item labeled Aérogares that's used only when the site is translated into French. This means that when the URL is constructed for a page called Maps in English and Plans in French whose parent is Terminals/Aérogares, the English URL alias is /terminals/maps, but the French alias is /fr/aérogares/plans.

Another part of the problem I'm facing is that when I save a translation of the page, this menu pattern ignores the source language and resaves every language's alias as that of the language of the translation (when saving a French translation, the English alias becomes /aérogares/plans, the Arabic alias becomes /ar/aérogares/plans, etc.).

I've tried a few different tokens as part of the URL alias options to see if they'd work, but without success:

[node:source:menu-link:parents:join-path]
[node:source:menu-link:title]
[node:source:title_field]

There are a few different options that would be acceptable in the end, listed here from most to least desirable:

Foreign-language URL aliases use that language's menu structure, e.g. Terminals/Maps is /terminals/maps in English and /fr/aérogares/plans in French, and saving one language doesn't affect the others
Foreign-language URL aliases use the language code followed by the full English path, e.g. Terminals/Maps is /fr/terminals/maps in French
Foreign-language URL aliases use the language code followed by the current page's English title, e.g. Terminals/Maps is /fr/maps

I'm running Drupal core version 7.61. Here's a list of relevant translation- and menu-related modules I currently have in use:

Entity Translation 7.x-1.0
Entity Translation Menu 7.x-1.0
Internationalization 7.x-1.26
Menu translation 7.x-1.26
Pathauto 7.x-1.3
Token 7.x-1.7
Translation Management (tmgmt) 7.x-1.0-rc3

How can I accomplish one of the desired URL structures and keep them language-independent when saving revisions to content?


texts: User_save is very slow for no apparent reason

texts:
As you could see on picture, saving data for users is very slow. Queries run fast, but for some reason it takes up to 2 minutes to save user data. The same happens with logging in.

What is more strange, I have DB versions of this site and have a previous version where this works normally and all of a sudden this started to happen.

I checked errors in log
Disabled modules
Cache reseting
Exported DB tables from working DB (user, user_roles, variables) to non working
Checked for missing modules
Tried older version of drupal (7.33).
Disabled some custom code modules

Tried everything I could come up, but still user_save is slow like on image and no errors or warnings appear. Really don't have a clue anymore what could be wrong, something in DB level must been wrong, not sure what to try anymore and where to look?


texts: How can I limit and show only the first referenced node per node in a view?

texts:
I have content type A with a field that references nodes of type B. This is field with multiple values.

I need to show all the values of content type A, and include one of the fields of the referenced content type B (an image). So I created a view showing these fields.

The problem is that I just want to show the first result of content type B and eliminate the duplicates of content type A. So according to the post Only show first entity reference in views, I used the module Views Distinct. And it works, the problem is that I have more than 2000 nodes and the query is very very slow.

So the next thing I thought was to use the Infinite Scroll module to make it faster. And this works, but the problem now is that I need to group the results by a field, and with this module the header of each group is being repeated, every time results are loaded.

So I thought I could use the Delta for the reference field, and filter it to the nodes with delta = 0, but I don't know why the first value is not 0 is a different number. So this option is not valid.

Does anyone know how to show only the first reference with a good performance?


texts: How to hide an exposed filter block if the view results are empty?

texts:
I have an exposed filter block on the sidebar on my page. I want to hide the exposed filter block if the result of the view is empty. What is the best was to do it ?
Right now i am having some Jquery code in a no result behaviour textfield wich hides some block elements. But i dont like this solution. I prefer if the code is clean and the html code is completely removed.


texts: I need to backup just a node. Usually I get this by searching the info of the node in the database but I'm just wondering if the backup and migrate module could help to do it?


texts: How can I bypass the Minimum cache lifetime when programmatically clearing the cache?

texts:
Is it possible to clear the cache of individual node without regard to the minimum cache lifetime in the cache settings Drupal 7?

It seems like node_save clears the cache:

entity_get_controller('node')->resetCache(array($node->nid));

However, that respects the minimum cache lifetime.

This is an issue when unpublished saved nodes go from an unpublished to a published state. Users served from the cache can't see the page until it expires, and it's immediately shared on Facebook or Twitter, those who click get a page not found 404.

I'm stuck using the Clear all caches button on /admin/config/development/performance. That seems like a heavy-handed approach.

Is there a better way?

Is cache_clear_all(); (called with no-params) the programmatic equivalent of the Clear all caches button?

Thanks in advance for any help!


texts: Drupal7 REST webservices API KEY vs OAUTH two-legged authentication for clientside JS consumer library

texts:
I'm working on an Drupal7 API, using REST services, and consumer JS library (no server code). I'm not trying to authenticate/authorize the end-users, only to identify and allow access to the 'application' using an API KEY.

The goal is to have the 'developers' create an account, request an API KEY, register domains for this api key, and use this key to 'identify' their application to the Drupal7 API. This is pretty much the same API-KEY model that Google Maps is using in v2.

I've looked into OAUTH 2legged approach, which would have been great if my client library was running on the server side, so the secret key wouldn't be exposed, but in our case, the library is JS only (client side), and it doesn't seem a good idea to expose the secret key.

Am i missing something about OAUTH that will allow this? Any pointers will be welcome.

Thanks!


texts: admin only can log from a certain country

texts: I want that the admin user to only be able to log in from a certain country, and that the other users that are not administrators will be able to log in from every country.


texts: Unable to create the menu after deleted an old one

texts: On Drupal 7, I just deleted an old menu(menu A) under "Administration > Structure > menus". When I try to create this same menu "menu A", it said The machine-readable name is already in use. It must be unique. How can I fix this?


texts: How to prevent dead wrappers for empty lazy builders?

texts:
I have a few fields that are using lazy builders and in some cases they will return empty render array. Unfortunately this will still display the field item html wrapper without any content in it. Due to theme CSS this often results in empty spaces or empty "boxes" with borders.

Is there a way to tell the parent render array to hide itself it there are no child items to render?


texts: How can I configure the Mail System module to use Swift Mailer for registration emails?

texts: This seems like it should be straightforward, but I haven't had success theming the default registration emails on my site. I am able to see the themed email (just using swiftmailer.html.twig in my theme) when I send a test email via the Swift Mailer UI, but using Swift Mailer for my formatter and sender in the default mail system config in the Mail System UI and using my theme to render the emails, I'm still not getting the themed registration emails as I would expect. I must be missing something simple, but I've tried all sorts of combinations without luck.


texts:
Is it possible to Create/Update a commerce order using parameters passed via the url?

What options are out there to achieve this?


texts: How do I create an Events page listing all Event nodes?

texts:
I have a Theatre website that I'm creating in Drupal 8, and I need to create an Event content type. This content type will be displayed on an Events page listing all Events in ascending order from closest date to latest. (I'm pretty sure I can get Views to do this.)

This is how each node should look like when listed on the Events page.

I know I need to create fields for:

Event Poster
Event Presenter
Name of the Event (This would be the Title Field)
Day(s) of the event
Time(s) of the event
Event price(s)
Link to external Ticketmaster-type website to purchase tickets

The problem I have is that not all events are only set up to be on one day or at one time; some events may be listed like the following (Where there are multiple time listings for the day) or some might be where the event is being held for multiple days and may have different times of when it is being held.

What field type should I use for the datetime field? Is there a special module I should get for this that allows multiple dates to be listed? Do I even need to worry about a special Time field or do I just keep it as a plain text field for the user to just type in the time(s)?

TL;DR: How do I create a date field that allows to list multiple days (maybe times) and then sorting the content type by the days of the event in ascending order?


texts: Workflow module missing content type mapping

texts:
I don't see a tab or area to add a content type to a work flow. The documentation does not match what I am seeing. The tabs I see at the top are:

Primary tabs
  Edit
  States
  Transitions(active tab)
  Labels
  Permission summary

Where should I look to find the mapping area?


texts:
The problem occurs when a node alias consists of a backslash.

My example:

drupal_add_js(path_to_theme() . '/js/script.js', array(
    'type' => 'external',
    'scope' => 'footer',
    'weight' => 5
));

Now I have a node with the alias EXAMPLE/example.html

The path to the script.js is now domain.com/EXAMPLE/sites/all/themes/example/js/script.js and not domain.com/sites/all/themes/example/js/script.js

What do I do to make the path right?


texts:
I have an custom module with Block:
namespace Drupal\generator\Plugin\Block;

use Drupal\Core\Block\BlockBase;

class GeneratorBlock extends BlockBase {

    public function build() {
        $form = \Drupal::formBuilder()->getForm('Drupal\generator\Form\ProjektForm');

        return array(
          'form' => $form,
          '#attached' => array(
            'library' =>  array(
              'generator/generator-css'
            ),
          ),
        );

    }
}

All it does is placing some From in there with additional .css file (from library). I can place this block via Admin -> Structure -> Block layout and it works fine.
What I want now is to load that block via Ajax (because I want to refresh the whole block in some cases). And by that I mean I want to load it into wrapper (like with $.load(...)) or get the content of the block in JS variable (not the whole page with block, but just the rendered block).
I've found the tutorial for Drupal 7 on drupal.org, but I failed to port it to Drupal 8.


texts: How to handle the 'Save and edit' form action?

texts:
I'm copying code from a module that does more or less what I want. However, the module I'm copying has a bug... The form we're trying to extend has both a 'Save' button and a 'Save and edit' button. The following code only seems to work when the 'Save' button is pressed, not when the 'Save and edit' button is pressed...

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

  $environment = reset($form_state['build_info']['args']);
  $is_external = apachesolr_environment_variable_get($environment['env_id'], 'is_external', FALSE);

  $form['make_external'] = array(
    '#type' => 'checkbox',
    '#title' => t('Make this environment external'),
    '#default_value' => $is_external,
  );

  $form['actions']['save']['#submit'][] = 'x_environment_edit_submit';
}

function x_environment_edit_submit($form, &$form_state) {
  if ($form_state['values']['make_external']) {
    apachesolr_environment_variable_set($form_state['values']['env_id'], 'is_external', TRUE);
  }
  else {
    apachesolr_environment_variable_del($form_state['values']['env_id'], 'is_external');
  }
}


texts:
How to subtracts two column in view?
for example:
 say column A and Column B need to subtract i,e [column A - column B]= column C.How can I achieve this is there any module available for it?


texts: WSOD afte uninstalling the Memcache module and deleting it's folder

texts:
I've uninstalled the Memcache API and integration module from my site and then deleted it's folder from sites/all modules.

Then, my site was down, and a WSOD appeared instead.

I went to Drush and typed drush cc all, and then this came up:

Afterwards I restored the deleted memcache folder at sites/all/modules, and again typed drush cc all... Then the site came to work, but now when I run Drush I still so something wired:

Why I have a WSOD when I remove the module's folder if the module itself doesn't even enabled?...
How can totally delete the module?

Update for user - Les Lim:


texts: How to filter view with date field by today's date?

texts:
I came up short on good ways to filter a user list to only show users who's birthday is today.
There has been efforts in D6 but nothing in D7?
As a "hack" I used an exposed filter for the birthday field (a date field) and then created a link from a block using PHP code:
$today = date("m-d", strtotime("today"));
print 'Today\'s Birthdays';

Ideally, I would like to override the input field with a select option to show " yesterday, today, tomorrow, next week".
Are there any better options doing this in D7?


texts:
I noticed this question, which discusses various ways to alter HTTP Response Headers.

Where would I be able to execute:

$response->headers->remove('X-Frame-Options');

I attempted to place this within my THEMENAME.theme file, but perhaps I am not doing it right because $response is not defined where I am using it.

Where does $response come from?

Where can I execute $response->headers->remove('X-Frame-Options');?

Note: I understand the risks of removing the HTTP Header.  This is for development/testing purposes only.


texts:
I'm working on the D8 port of the subdomain module. It allows the administrator to define a list of entities/bundles that can be accessed by subdomain aliases. In D7 I had form_alters to add the field, and a custom table tracking subdomains and their related entities for storage. In D8 I can add the field the same way, but I'm trying to figure out the best practice approach to storing the data.

I could declare a new content entity, but that seems like a lot of overhead for one varchar field.
I could extend the schema of targeted entities to include one extra varchar field. But when I think of altering table schema every time the administrator hits a checkbox, I think that can't be right.

I had a look at core's path module to see how they approach the problem, and they use hook_entity_base_field_info() to add the field, backed by a custom storage service. It seems like that's not a recommended approach for contributed modules, though.

Can anyone advise on what I should use? Am I missing something simple here?


texts: How to change "Secure Login Module - Secure base url" without login?

texts: I have installed Secure Login with Secure base URL setting on a live site, and clone that into a different domain for testing. The "/user" page has no login form because the Secure base URL should be different. How can I change this URL without login? Where is this data in phpMyadmin?


texts: Standard bootstrap main menu with dropdown?

texts:
When using bootstrap with drupal what is the standard way to create a main menu?

When I add the main menu block to a region it does not display as a bootstrap navbar.

When I try with superfish I can add some classes but for example the active-trail cant be changed on li.


texts: How to update a field on a Custom Block Type?

texts:
I want to update a field on a Custom Block Type in an update hook. I've seen examples updating fields on nodes, but it appears this doesn't work on block fields, which is surprising.

function ra_homepage_update_8004() {
$form = "some string.";
$uuid = 'f8b451ff-8bt5-494e-be81-sdfaasdfsadf';
if($block = \Drupal::service('entity.repository')->loadEntityByUuid('block_content', $uuid)) {

$block->set('field_form', $form);

}
}

The real question is how do I view the available methods on the field, because I've tried $block->get('field_form')->set($form); as well as $block->get(0)->setValue($form); and probably a few other things, but it's all just shots in the dark.


texts: How to display/hide a field only if has a certain value?

texts:
I am working on an event content type.
It contains a date field that lets users input the date in which their event will take place.
But sometimes the date of the event isn't known at the time the node is created. Users just need to create the event and discuss with other users (in the comments section) then decide when to organize it and add the date then.
So the date field has no default value and I created another boolean field that controls whether the date field is displayed or not using the conditional fields module.

The boolean field has two values, TRUE = « I know the date of my event ».
FALSE = « I will pick a date later »
The field is set to TRUE « I know the date of my event » by default.
If the user picks False « I don't know the date of my event yet », then the date field is hidden and no value is input.

The problems i'm facing are :
When displaying the event as a node and when listing all the events in a view :

If the user knows and inputs the date of the event :
- How to only display the date and hide the TRUE/I know the date of my event label/value of the boolean field

If the user chooses to pick a date later :
- How to display a « Date to Be Determined » message and hide the empty date field.

If you have ideas or a better way to handle this, you're welcome


texts: How to hide user profile fields defined as object properties?

texts:
I know it is possible to hide most fields defined on /admin/config/people/accounts/fields on the user edit form /user/<uid>/edit by using the HOOK_form_alter function in a custom module like this targeting user_profile_form:

$form['field_account_myfield']['#access'] = 0;

But how to hide user profile form fields the right way (no CSS tricks)?

in my case the URL is /user/<uid>/edit/Profil. These are the fields you can define with the core profile module enabled on /admin/config/people/profile.

They are defined as object properties in the $form['#user'] object, e.g.:

$form['#user']->profile_address

unset() and ['#access'] = 0 does not seem to work.


texts:
I changed services.yml file (i use dynamic cache):

renderer.config:
required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions', 'cookies:Drupal.visitor.Country']

And sey the cookie properly with an event:

$events[KernelEvents::REQUEST][] = ['checkCountry', 30];
...
 user_cookie_save(['Country' => $country]);

I checked and the cookie is saved correctly.
But the cache does not work...


texts: Prevent block config from being exported?

texts: In Drupal 8, how can I prevent block instance config from being exported? I want it to just be ignored.


texts: How do I backup a site when it weights is more than 200MB and host can't do it? I have it on hostinger.ru and can't backup with Internet server error 500. I cleared cache and deleted some modules.


texts:
I'm trying to remove all javascript for anonymous users but I've hit a roadblock.

This is the php I'm using in template.php (phptemplate_preprocess_page function):

$js = drupal_add_js();
unset($js['core']);
unset($js['module']);
unset($js['setting']);

$vars['scripts'] = $js;

print_r($vars['scripts']); // prints what it should
print_r(drupal_add_js('header', $js));  // prints everything like nothing happened!


texts: Printing printer friendly version of nodes in bulk

texts: My scenario is this, a user selects a bunch of nodes and selects to print all the nodes.  What I'd like to happen is, once the user clicks the print button, the print dialog opens up and all the nodes are printed at once.  I'm using the Print module and I'm having a hard time figuring out how to print programmatically and all at once.


texts: What is the difference between hook_preprocess_page and hook_preprocess_html?

texts:
I see that both hook_preprocess_page() and hook_preprocess_html() are implementations of hook_preprocess_HOOK(), but I don't understand when to use which.

hook_preprocess_page is called first, but that doesn't really help me understand who is calling it.

Looking at the debug_print_backtrace() output, it's getting called by theme(), but that doesn't really get me to the answer.

Is it simply defined by the array that is passed into drupal_render()?


texts: A module similar to Innovation News Module for Drupal7?

texts:
Hello I am looking for a module similar to Innovation News so that news content can be developed collaboratively, placed into editions, and exported as XML documents.

It seems Innovation News is on a dead line.

Anyone could help me?


texts: Customizing system response emails outside of the admin panel

texts: Can registration emails be customized through code rather than through the admin panel? I have message content that's reliant on values entered by user. Thanks.


texts: How to set a different theme for editing one's account

texts: I read somewhere that editing account information can be done a different theme or in the admin theme but can't for the life of me find it neither on google.


texts: How to inject configuration values into services?

texts:
In Symfony 2 when defining a service it is possible to inject configuration parameters by referencing them with %parameter.name% strings. For example:

services:
  app.mailer:
    class:        AppBundle\Mailer
    arguments:    ['%app.mailer.transport%']

But what is the correct Drupal 8 approach to injecting configuration values into services? Of course I don't want to use \Drupal::config() inside a service class. Passing configuration values each time a service is referenced does not make much sense either.

I know that I can inject the config service itself and then get configuration values from it, but that looks a bit crappy as my service itself has know how to read data from configuration service. For example:

# Yaml service configuration
services:
  app.mailer:
    class:        mail_module\Mailer
    arguments:    ['@config.factory']

PHP

<?php
class Mailer {
  public function __construct($config) {
    $this->mailTransport = $config->get('mail.config')->get('transport');
  }
}

Is there any other way to do this?


texts: Unable to access site after deleting an entry from the database

texts: The entry views.view.media from the config table in phpmyadmin was accidentally deleted. When visiting the site it giving the error The website encountered an unexpected error. Please try again later. I'm unable to login or access any page. What can I do to fix this problem? It's drupal 8.2.4.


texts: Limit Taxonomy display in Term Reference based on criteria?

texts:
I have Taxonomy called "Region" ex: (Region A / B / C)
Each user is linked to Taxonomy "Region" using Profile2 module (one person can be linked to multiple regions)
Content Type "Article" has a Term Reference field linked to same Taxonomy. (value = unlimited)

Requirement:
. In content type "Article", I am asking user to select the Region (as Taxonomy Select list) where this Article belong too - how do I limit the Taxonomy list based on the Region user have an access too?

ex: User1 is linked to Region A / User2 is linked to Region A & B; When User1  creates an Article, Term Reference Taxonomy to show "Region A" but when User2 - show both "Region A" and "Region B"

in SQL world, I would write something like this.

select t.name
from taxonomy t
where t.name in (select p.name from profile p where user_id = :%1);

How would you achieve this in Drupal without writing custom code?

p.s: My apologies - I am from database world and very new to Drupal; still learning Drupal lingo.


texts:
I defined the hook_views_data in order to display some data from a custom table in the database. One field is a nullable decimal(5,1). The value of this field is displayed correctly in the view but shows nulls as 0.0. "No results behavior" seems to have no effect on it in any way. The field is defined as follows:

$data['customview']['value'] = array(
        'title' => t('value'),
        'help' => t('the requested value'),
        'field' => array(
            'handler' => 'views_handler_field_numeric',
        ),
        'sort' => array(
            'handler' => 'views_handler_sort',
        ),
        'filter' => array(
            'handler' => 'views_handler_filter_numeric',
        ),
    );

Using PHPMyAdmin, I can verify that the values are null. Any custom properties I should add to the definition of the field in order to allow nulls (Display them as empty or dash)?


texts:
When I try to upload an image to a content type that has an image field, I get this very non-specific error:

The file could not be uploaded.

I have checked that the file is within the allowed size constraints, the proper format, and has no spaces or strange characters in the name. Saving the content works fine except for that one field.

I have other fields accepting uploads and images on this and other content types and they work fine.

I have no idea how to troubleshoot this issue. Where do I begin?


texts: Avoiding PHP timeout when geocoding many addresses - preferred method?

texts:
I have a script that's taking in a ton of address data from a CSV, converting it to JSON, and along the way it hits the Google Maps API to get the latitude and longitude of each address. It then writes the whole thing to a .json file that is used by another widget. This works well for small numbers of addresses but some of the files I'm importing have hundreds of addresses. I have considered several ways around this:

Queues: The problem with this one seems to be that I would have to save an object for each address and I don't want to completely fill up my database with address objects. I would then also have to somehow detect the completion of the queue and retrieve all those objects from the database to generate my complete json file. I worry about whether the server will deal with this well.
Some other Google Maps API: Am I even using the correct Google Maps API for this? Is there one that can get a bunch of coordinates for a bunch of addresses in one HTTP request? I couldn't find one but that doesn't mean it's not existing.
Feeds API (or some other core or contrib API for getting tons of data): It occurs to me that my hand-rolled solution might be circumventing some more Drupal-correct way to accomplish this task. Does Drupal offer something for making big batches of HTTP requests that I'm just missing?

So, basically my question is: what's the most Drupalish way to make and process a large number of HTTP requests from a module?


texts: Is there any way to reorder the nodes in a View?

texts:
I have a complicated View containing many pages and attachments. When I built the View, I didn't think much about the order of the pages and attachments, but now I would like to change the ordering because it affects how they are displayed in the end. I would also like the flexibility to add additional pages in the future and be able to control where those attachments appear in the page.

I know you can control an attachment's position using the Above/Below options, but I have one page with 6 attachments and I can't seem to break the ordering except by creating and deleting nodes.

Edit: I discovered that I can accomplish this by exporting the View and reordering the code there and then reimporting, but if a cleaner solution exists, I would love to hear it.


texts: How to stop spiders from crawling every combination of multiple drop-down pages

texts:
We have a site with around 10,000 pages and media items (mainly PDFs)
We use various tools to catalog, check and report on our site and, of course we encourage good spiders (Google et al.).
The problem we find is on pages which have SOLr search options.  When they have mutliple filter drop downs, spiders will find EVERY POSSIBLE COMBINATION of those and so our site suddenly becomes a 300,000 page site. In addition, almost one of those hits goes sailing past the (Varnish) Cache, so it makes a real impact on the server. So my logs are full of lines like this:
"GET http://www.xxxxxxxx.com/resources?f%5B0%5D=programs%3A991&f%5B1%5D=type%3A11&f%5B2%5D=type%3A578 HTTP/1.1"
It's annoying when every piss-pot little spam spider takes up major resources like this.
Anyone have an idea? Google has nothing....


texts: Limit the menu level on node add/edit page

texts: On node add/edit page we have a menu settings option. This option by default show all the nodes in the main menu under Parent Item tab. Is there a way we can limit the nodes in the menu(under parent item) to only first two levels.


texts:
I am using drupal-vm and drupal console, and following the instructions for installing drupal commerce on an existing site (drupal-vm made me a drupal 8 site) here:
http://docs.drupalcommerce.org/v2/install.html
specifically, the command was:
drupal module:install commerce_product commerce_checkout commerce_cart commerce_tax

I received the error in the Title, here's the whole output:

drupal module:install commerce_product commerce_checkout commerce_cart commerce_tax
 One or more modules "commerce_tax" are not available, running download process to get those modules
 Getting releases for module "commerce_tax"

[ERROR] There aren't any releases for module "commerce_tax"

[ERROR] Invalid module name: commerce_tax

Installing module(s) "commerce_product, commerce_checkout, commerce_cart"

[OK] The following module(s) were installed successfully: "commerce_product,
      commerce_checkout, commerce_cart"

// cache:rebuild

Rebuilding cache(s), wait a moment please.

[OK] Done clearing cache(s).


texts: xml feed parser from multiple sources, multiple url-source xml importers

texts:
I can't seem to find a good module that does what my title says. Xpath XML Parser is limited to a single source isn't it?

I needed to be able to import xml feeds from different URLs towards the same target (e.g. mapped to a specific content type). Say, my website will publish contents from different client's websites using an xml specification defined by me. My website then will get all contents by importing all those xml sources towards the same content type so my site will list all contents from different 'sources' effectively. Say real estate listings coming from different real estate agencies/agents...

Has anyone done this before?


texts: Why is the "webform submission updated" hook not using the correct data?

texts:
Created a function in respond to hook_webform_submission_update to generate a FillPdf.

function my_module_webform_submission_update($node, $submission) {

    if ($submission->nid == 43) {

        $uuid = ($submission->data['975'][0]);
        $sid = ($submission->sid);

        $f = "./sites/default/files/docs/mdx_lh_" . $uuid . "_" . $sid . ".pdf";

        if (file_exists($f)) unlink($f);

        $wf = array(array("nid" => 43, "sid" => $sid));

        fillpdf_merge_pdf(326,NULL,$wf);
    }
}

When the event is triggered, after pressing the save button, the FillPdf uses the old data.  Going over the webform a second time without changing anything, just clicking the save button, the FillPdf uses the correct data.

I thought the hook_webform_submission_presave was to change data (if needed) but it seems the event hook_webform_submission_update is triggered before data is actually saved.

Is there a way to force data save before calling fillpdf_merge_pdf, or is there another event to use?


texts:
This is regarding a Drupal 8 site, specifically Drupal 8.7.1 and the "Contact" module (with Contact Emails, Contact Storage enabled).

The issue that I'm running into is some of the fields are not included in the email that's sent out when the form is submitted. No Swiftmailer or other HTML email packages involved here, my ultimate goal is just to include all fields that were filled out.

I narrowed the situation down to this - when logged in, the resultant email sent out after form submission always contains all of the correct fields. If not, or in other words an anonymous user fills out the form, some fields are missing from the email entirely.

The aforementioned missing fields are actually paragraphs, or entity revisions, that I made use of to get access to the add / remove paragraph functionality on the front end. They work great, with a bit of preprocessing, but absolutely refuse to be included in email messages when the submitter is an anonymous user.

Sanity check - The fields are all there and filled out as part of the Contact Storage module, so that's not the issue. Anonymous users obviously do not have any kind of access to administer paragraph types, but this is not needed when the paragraphs are fields in a contact form(?).

I've checked around the various stack exchanges and other sites, but I can only find vaguely relevant issues, such as Theme contact emails. Using paragraphs in Contact does not appear to be a popular thing to do.
They are embedded as subforms, but I can't find anyone else who has asked this question.

The site is hosted on Acquia Cloud, PHP 7.2, if that helps. Short of digging through the module's entire codebase or setting up HTML mail with something like Swiftmailer, I'm stumped.

Any help is much appreciated, please let me know if you need any more detail on something - I know this is a lot to read without code or screenshots.


texts: How to create a custom display mode for user in D8?

texts:
I've created an edito custom content type wich can be linked to a user. I'd like to custom the display with the picture and the name of the user in a view. I don't know how to create a custom display mode for an user.

Any help ?²


texts: How do I add custom validations to Webform?

texts:
I have created the country and state fields with the Webform module, and I want to add a field validation for the state field when user select US as country.

How can I achieve this?


texts: node is appended after base url and before actual link

texts:
I am using drupal 7
In my home page when i hover any link say node/45 then there is right link like base_url/node/45

  But after visiting any node i.e. when i go to node/45 page, on that page when i hover on any link then node is prepended
  For ex: when i hover on products link then base_url/node/products is coming, i mean node/ is append before path.


texts: Providing a vocabulary in a custom module

texts:
I am about to create a module which provides a ready-to-use term vocabulary.

What would be the clean, Drupal way to do that? Is it just a matter of a bunch of queries in hook_install(), or should I perform some additional steps? Should I take any measures in order to make the terms translatable?

I am using Drupal 7.


texts:
We have a headless Drupal 7 project that uses express and handlebars for it's front end. I'm experimenting with updating the backend to use Drupal 8.

I've created a REST export type view, but when you inspect it you see that for any image field you don't actually get a URL in the JSON.

field_logos: [
{
    target_id: "1",
    display: null,
    description: null,
    alt: "My Image",
    title: "",
    width: "83",
    height: "71"
},]

I've done some research on this but can't find much documentation on this.

My first attempted fix was to change the view output format from entity to fields, and do as described in this thread. From that I can get a URI (again not a full URL path) but that screws my view up because it doesn't like multiple value fields, and won't nest anything so I get multiple rows with the same data.

During my googling I found this thread  which describes how functionality has been added to Twig to deal with this (or at least a very similar) issue. Obviously I'm bypassing Twig altogether so that's not an option.

Maybe I need to look at a views preprocess function? I'm not sure how to do this for the REST export view type, so any help with that would be appreciated.

Why has this been left out of the JSON output, it seems quite crazy to me to have ALT text and width/height of the image but not the path to it here.


texts: Commerce: Change cart line item dynamically on checkout page

texts:
I'm trying to substitute cart line items on the checkout page based on a custom input element, say a radio button. The requirement is to refresh the checkout page dynamically to reflect the new line item. Here's my approach:

Alter form commerce_checkout_form_checkout
Add custom input element with an #ajax setting
In ajax callback, substitute order line items using the following:

$order = commerce_order_load($form_state['order']->order_id);
$product_replacement = commerce_product_load_by_sku($sku);
$line_item_replacement = commerce_cart_product_add_by_id($product_replacement->product_id);
commerce_cart_order_product_line_item_delete($order, $line_item_wrapper->line_item_id->value());
$form_state['order'] = commerce_order_status_update($order, 'cart', TRUE);
commerce_order_save($form_state['order']);

Update order contents pane using the following:

$pane_id = 'cart_contents';
$checkout_pane = commerce_checkout_pane_load($pane_id);
if ($callback = commerce_checkout_pane_callback($checkout_pane, 'checkout_form')) {
  $pane_form = $callback($form, $form_state, $checkout_pane, $order);
  if ($pane_form) {
    $form['cart_contents'] = $pane_form + array(
      '#type' => $checkout_pane['fieldset'] ? 'fieldset' : 'container',
      '#title' => check_plain($checkout_pane['title']),
      '#collapsible' => $checkout_pane['collapsible'],
      '#collapsed' => $checkout_pane['collapsed'],
      '#attributes' => array('class' => array($pane_id)),
      '#tree' => TRUE,
    );
  }
}

Although the order contents pane does refresh to reflect the new product, an error occurs when I click "Continue to next step". Watchdog reports a commerce_order error:

  EntityMetadataWrapperException: Unable to get the data property commerce_total as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 442 of /var/www/mysite/sites/all/modules/entity/includes/entity.wrapper.inc).

Any idea what I'm doing wrong, or can you suggest an alternate approach?


texts: How to output results in a view hook module

texts:
So I've been trying to use the db_select() in a view hook (in this case, _views_pre_execute()) to overwrite the query that exists in a given view. I've followed instructions and gotten what I think should be correct, but would really rather use raw SQL. According to Lullabot, it's perfectly OK to use db_query() with raw SQL if your query doesn't have any dynamic components, which mine doesn't.

Problem is, I can't seem to get anything to happen. I've never seen a complete example anywhere of using one of these view hooks, so I'm not sure what else I need to do.

Every (partial) sample I've seen has something like, "// Perform operations on $record->title, etc. here." inside the foreach loop that processes the query result. Do I need to use that to manually write out the HTML for each field I want to display? I've tried that, and although the drupal_set_message() line is printing out, the foreach results are not. Do I need to hide all the fields from display in the Views UI?

I just can't seem to get the results of the query to print to the screen (so I really don't even know if the query is returning any results, although when run directly in phpMyAdmin it does return the desired records.) What IS printing is the view as configured in the UI, even though (I thought) using this hook was supposed to overwrite that.

Can anyone help me out? I've spent a week trying to figure out how to get this working, and I'm at the end of my rope.

Here are two versions of my function code; one using db_query and the other using db_select. I'd be happy if I could get either to actually print results to the screen.

db_select

function group_speaker_carousel_views_pre_execute(&$view){
    if ($view->name == 'speakers_carousel')  {
      drupal_set_message("view is {$view->name}");

      $query = db_select('node', 'n');

      $query->leftJoin('field_data_field_speaker', 'sp', 'n.nid = sp.field_speaker_target_id');
      $query->leftJoin('field_data_field_job_title', 'job', 'n.nid = job.entity_id');
      $query->leftJoin('field_data_field_company', 'company', 'n.nid = company.entity_id');

      $query->addField('n', 'title', 'node_title');
      $query->addField('job', 'field_job_title_value', 'field_job_title_value');
      $query->addField('company', 'field_company_value', 'field_company_value');
      $query->condition('n.status', '1', '=');
      $query->condition('n.type', 'speaker', '=');
      $query->orderBy('n.title', 'DESC');
      $query->range(0,1);

      $result = $query->execute();

      foreach($result as $record) {
        echo "" . $record->field_company_value . "";
      }

    }
}

db_query

function group_speaker_carousel_views_pre_execute(&$view){
    if ($view->name == 'speakers_carousel')  {
      drupal_set_message("view is {$view->name}");
      $result = db_query("SELECT n.title AS node_title, job.field_job_title_value AS field_job_title_value, company.field_company_value AS field_company_value
                         FROM {node} n
LEFT OUTER JOIN {field_data_field_speaker} sp ON n.nid = sp.field_speaker_target_id
LEFT OUTER JOIN {field_data_field_job_title} job ON n.nid = job.entity_id
LEFT OUTER JOIN {field_data_field_company company} ON n.nid = company.entity_id
WHERE (((n.status =  ':status') AND (n.type = ':type')))
ORDER BY node_title DESC",

array(':status' => '1', ':type' => 'speaker'));

      foreach($result as $record) {
        echo "" . $record->field_company_value . "";
      }

    }
}


texts: Drupal 7 Views Exposed Filter - How to Select all Taxonomy terms Upon adding new terms?

texts: Whenever I add new taxonomy terms I have to manually go into my exposed view filter to have them show up in the dropdown box when filtering. Is there a way to just select all terms with what im filtering by?


texts: Is there any ideas on webform mutile values on same field?

texts:
In webform select components, we can set multiple attributes but not for filed like textfield or numbers.
So I want to ask is there any ideas on that, so let user can add more value  on same field. Such as:
Telephone number, the web visitors may not have only one ,and we should allows multiple for that.
We found that the webform has store multiple  values in database which can come from in the form used like telephone[], but do not in the validation.
We do not want to changes the validation rules but we want to have a multiple attributes on textfied.
Is there any idea?
Thanks.


texts:
I created basic custom - made layout in Drupal 7 by setting up ( layout.info html.tpl.php page.tpl.php style.css )

I have also created Views in order to filter some certain content (text and photo). Is there a way to theme the Views but without preprocess functions. So no coding in the template.php ? How to do that if it is possible?


texts: How do I include a term's additional fields on node display?

texts:
With Drupal 6 there was Taxonomy Image to do this, but with the field goodness of Drupal 7 we can just add an imagefield to a certain vocabulary. This works quite well to output stuff with views, but I can't seem to find a way to show up the additional field on the node display.

In my case I simply have a vocabulary called countries that has an additional imagefield to hold the country's flag. When viewing a node that has assigned a country term I need the flag of the country to show up instead of its name.

Regards,
Daniel


texts: Queue Implementation for third party api

texts:
In my website I have a form and which submits data to third party website. that api is available some time and not available some time. I need to create a queue mechanism to insert failed api calls and show them in admin panel.

Once admin wants to process the queue then that data needs to be resubmit to the third party site.

I need to know how to setup a cron job for the same , if we have more records then we can run cron for every 10 mins.

Any suggestions? I am new to this drupal8 queues.


texts: How to change the query for content type in d6 to d7?

texts:
I have a code in D6 which is as given below

In Drupal 6 for each content type we had seperate table like content_type_[content_name]
--------------Drupal 6---------------------

    SELECT nid, field_id_value, field_oid_value,field_sts_value
    FROM {content_type_bstatus} fsa INNER JOIN
    ( SELECT MAX(nid) as maxnid , field_oid_value  // subquery
      FROM {content_type_bstatus}
      GROUP BY field_oid_value
    ) fsb
    ON fsa.nid = fsb.maxnid
WHERE fsa.field_sts_value <> 'success'

In Drupal D7 we have seperate table for each fields within the content type like
 field_data_[field_name]
and content_type is included only in nodes table
So, I am trying to implement the above code in D7

In Drupal D7 what i have tried is as follows but could not the exact solution

------------------Drupal 7----------------------------------
For the subquery above I have implemented the code below

SELECT MAX( entity_id ) , field_oid_value
FROM  `field_data_field_oid`
GROUP BY field_oid_value

How can I add the rest of code ..I have tried something which does not work
How can I write the code in d6 to d7 . I am using db_query in d6 and would use db_query or db_select but
HOW CAN I USE THE CONTENT TYPE FIELDS WHICH ARE HAVING SEPERATE TABLES in d7 database structure??


texts:
I have created a new content type on Drupal and I chose it will be available in which menus. But when I add a content for my new content type and after I check the "Provide a menu link" checkbox, the "Parent item" select list becomes empty after it was populated.

And this is caused by an ajax query that gets executed after checking the "Provide a menu link" checkbox.

And this query return an empty array.


texts: Recommended techniques for changing the appearance/design of my Bootstrap sub-theme?

texts:
I use Bootstrap (7.x-3.0 for Drupal 7 which I already created my own sub-theme and I enabled this sub-theme as my default theme. It seems to work so far.

Now, I want to change the appearance/design of my menu. Here is the appearance with the Bartik-theme:

And here is the equivalent using the Bootstrap-theme:

If I want to customize the Bootstrap theme to look similar to the Bartik theme, how do I do this? In the base-theme folder of Bootstrap I found menu-tree.func where the menu tags are generated, which looks like so:

/**
 * @file
 * menu-tree.func.php
 */

/**
 * Overrides theme_menu_tree().
 */
function bootstrap_menu_tree(&$variables) {
  return '
' . $variables['tree'] . '
';
}

/**
 * Bootstrap theme wrapper function for the primary menu links.
 */
function bootstrap_menu_tree__primary(&$variables) {
  return '
' . $variables['tree'] . '
';
}

/**
 * Bootstrap theme wrapper function for the secondary menu links.
 */
function bootstrap_menu_tree__secondary(&$variables) {
  return '
' . $variables['tree'] . '
';
}

Do I have to edit this file? I don't really think so. Further, each element of the menu uses the class called leaf which I couldn't find at all in any files of Bootstrap.

Hope my point is clear. I just want to edit the appearance of my menu and also of further elements without creating an entire custom-node.tpl.php. Is that possible or do I have to create an entire new file?


texts: Add a configurable text before the webform

texts:
I'm working with Drupal 7.

I created a webform content and I want to add a configurable text as an introduction before my form. It's not a textarea. It's just a simple text wich should be configurable from my admin.

I created a block wich contains my text and in settings > Show block on some pages only > I chosen Only the pages listed and set my link /content/add_project

But my text is not displayed.

Any idea please?

Thank you.


texts: What is the proper way to set up Drupal 7 on load balanced servers so that CSS and JS files are in sync?

texts:
We're moving our website to new Cloud Load Balanced servers on Rackspace. It's all a bit of a new experience for us, we've ironed out most of the issues, apart from one.

We've set up the new servers to lsync from Server A to Server B (Server A is master).

From time to time we see css/js files 404. We can guess what's wrong, it's file syncing not happening fast enough between servers, and when a cache clear occurs on Server A, such as a cron run, then Server B is requesting the old CSS/JS files, and that request may go to Server A.

What is the proper way to set up Drupal 7 on load balanced servers so that CSS and JS files are in sync and don't cause 404?


texts:
I got a menu with sub-items members of the Role X. When a anonymous user visits the page, he can't see the menu. When the user logs in, he is able to see it.

How can I keep menus visible to everyone while keeping their permissions?


texts: Create a .make file task in Bamboo by using Drush for a Drupal project

texts:
I'm setting up a CI system by using Bamboo. My aim: As soon as a change is pushed to the bitbucket server, the next task will create a ".make" file using Drush.

Bamboo is also found on the same server where Bitbucket server is.
I'm working on a local machine.

My knowledge of build tools are as follows. If you want to make a Java build, you either use Ant, Maven or Gradle tool. You have to set the environment variables to the path for the build tool and JDK. The executable for Ant is path\Ant.bat.

I want to know how I can make the CI setup in Bamboo. What is the executable for Drush 7? I'm getting an error while running to make the build like: "Unable to find executable at C:\drush\drush.bat. Will try to run it anyway.
The system cannot find the path specified.".

I used the command type for the bamboo task.

The drush command I used was: drush make-generate name.make

EDITED: I'm using XAMPP on Windows. I googled and noticed Windows users having difficulties with the installation. I then followed the guidelines "Installing Drush on Windows".

Install Cygwin
Now install Composer for Windows
Install Drush the common way. e.g Drush 7.x stable:

composer global require drush/drush:7.*

Source: https://www.drupal.org/node/594744

I installed Drush using Composer so I don't know where to find the path to the executable. During the Composer setup I used the php.exe in the "path/xampp/php" directory.


texts:
This question always comes up when I need to design a structure for data. When should I create distinct content types and when should I differentiate between nodes based on custom fields.

For example, say I have a gallery of people and a gallery of places. they differ only by one field that i use in the people gallery and not in the places gallery. in code i can easily know when it's people or places based on this field.

this is just one example from the top of my head. i'm asking for general guidelines, and not a solution to this specific problem.

these are the points i've come up with to help decide between different content types or different fields:

what are the chances one node will need to change type (people gallery suddenly becoming places gallery)?
how much do the fields differ?
how much you will need to create view with both types or with a single one?

any more thoughts?


texts:
I wanted to delete all migration modules because of that I use

drush config-delete migrate_plus.migration.ID

After that, I create a new migration module and enable it with

drush en migrate_NAME

and rebuild the cache.
I look at the status table with

drush migrate:status

but the table shows no migration. If I enable the migration again I get the message "Already enabled". When I try to import something I get the message "No migrations found".
Does anyone have any idea why this might be?


texts: How to hide a webform field from a node display when the per-user submission limit has been reached

texts:
I have a Webform field on my node, which links to an application form. The form is set to allow one submission per user (per node). I want the link to disappear after the user has submitted the form.

Any good ways to do this?


texts: Is there a way to change content in 1 master node and have it changed in hundreds of others?

texts:
I have searched for quite a while but with no success. Using D7.41, Views 3.

I have a lot of nodes of the same content type (~50 nodes) and all of these nodes have images and some text, plus 4-6 blocks of views in each (different text, different images and in some cases different blocks).

Task: to let the content manager edit this master template (change text, images, change blocks for all these 50 nodes), but the changes would then be replicated 20 times - I have exactly same structure replicated for 20 different regions - the same content, different paths. So that would be some kind of "Master template".

I do understand, that all of this could be managed with blocks, when all the content of the page is done via blocks, but maybe there is some other more clever way to achieve this?

Updated: one of the ways to reduce the amount of blocks used, I guess (as per user comment below), would be solution to have fieldable blocks. But in that case there is another question - how to do that?


texts: Does the Search API module integrate with the standard search?

texts:
I have Profile2 installed and want to be able to search on Profile2 fields that I have created. Does the Search API module integrate into the default Drupal search, which would therefore when configured, find Profile2 field values and the associated user?

If not, is there another approach I can use to include the Profile2 fields into Drupal standard search?


texts:
I'm trying to get Drupal to work inside an Alpine Linux docker container but for some reason drush can't be used to manage the website. The website itselfactually works fine, drush just can't bootstrap.

Here's the pertinent information:

 /var/www/html # drush core-status
 Drupal version         :  7.56
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  vlp-dcimysql01.dhe.duke.edu
 Database port          :
 Database username      :  tmp_drupal
 Database name          :  tmp_drupal
 PHP configuration      :  /etc/php7/php.ini
 PHP OS                 :  Linux
 Drush script           :  /usr/bin/drush
 Drush version          :  8.1.14
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /var/www/html
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default

/var/www/html # drush wd-show
PHP Fatal error:  Uncaught Error: Call to undefined function cache_get() in /var/www/html/includes/module.inc:754
Stack trace:
#0 /var/www/html/includes/module.inc(954): module_implements('system_theme_in...')
#1 /var/www/html/modules/system/system.module(2511): module_invoke_all('system_theme_in...')
#2 /var/www/html/includes/theme.inc(798): _system_rebuild_theme_data()
#3 /var/www/html/includes/theme.maintenance.inc(57): list_themes()
#4 /var/www/html/includes/bootstrap.inc(2872): _drupal_maintenance_theme()
#5 /var/www/html/includes/errors.inc(179): drupal_maintenance_theme()
#6 /var/www/html/includes/bootstrap.inc(2609): _drupal_log_error(Array, true)
#7 [internal function]: _drupal_exception_handler(Object(Error))
#8 {main}
  thrown in /var/www/html/includes/module.inc on line 754
Drush command terminated abnormally due to an unrecoverable error.                                                                                [error]
Error: Uncaught Error: Call to undefined function cache_get() in /var/www/html/includes/module.inc:754
Stack trace:
#0 /var/www/html/includes/module.inc(954): module_implements('system_theme_in...')
#1 /var/www/html/modules/system/system.module(2511): module_invoke_all('system_theme_in...')
#2 /var/www/html/includes/theme.inc(798): _system_rebuild_theme_data()
#3 /var/www/html/includes/theme.maintenance.inc(57): list_themes()
#4 /var/www/html/includes/bootstrap.inc(2872): _drupal_maintenance_theme()
#5 /var/www/html/includes/errors.inc(179): drupal_maintenance_theme()
#6 /var/www/html/includes/bootstrap.inc(2609): _drupal_log_error(Array, true)
#7 [internal function]: _drupal_exception_handler(Object(Error))
#8 {main}
  thrown in /var/www/html/includes/module.inc, line 754

As stated before, the platform is Alpine Linux, PHP is 7.1.9

I can add more if anything is unclear. I've checked the PHP logs but they just produce the above output. I'm open to there just being a module/extension missing, but I'm not entirely sure how to figure that out if it doesn't ever tell me "undefined function extensionFunctionX" or something like that. The above undefined function appears to be a Drupal core function.

Note that the website works, so it's communicating with the database without issue, I can also do a SHOW TABLES in MySQL and see the Drupal installer's tables were created.


texts: change node field value without node->save or without causing hook_entity_presave infinite loop

texts:
Have CONTENT_TYPE_NAME with field_counter that the user can set when editing a node.  If a user edits and updates that field I want all other nodes that have this field set (to an equal or higher value) to increment their values by 1.  I am overriding hook_entity_presave for this purpose.
As you can see in the following code I am getting all nodes of the same content type using entityQuery exluding the node that was about to be saved.  For all the nodes found I am getting the entity and incrementing the field value by 1 and setting the field value and saving the node.
    function MY_MODULE_entity_presave(EntityInterface $entity){
      if ($entity->getEntityType()->id() == 'node') {
        $changed_field = array(
            "field_counter",
        );
        $nid = $entity->id();
        foreach($changed_field as $field ){
          $value = $entity->{$field}->value;
          if(isset($value) && $value !=""){
            MY_MODULE_change_field_value($field,$value,$nid);
            //...
          }
        }
      }
    }

    function MY_MODULE_change_field_value($field,$value,$xeid){
      $query = \Drupal::entityQuery('node')
        ->condition('status', 1)
        ->condition('type', 'CONTENT_TYPE_NAME')
        ->condition('nid', $xeid,"<>")
        ->condition($field,$value,">=");

      $nids = $query->execute();

      foreach ($nids as $nid) {
        $node = \Drupal\node\Entity\Node::load($nid);
        //or
        //$node = \Drupal::entityTypeManager()->getStorage("node")->load($nid);

        $old_value = $node->{$field}->value;
        $old_value++;
        $node->{$field}->value = $old_value;

        $node->save();
      }
    }

This code works with but has a problem. All nodes updated programmatically will call entity_presave again and cause an infinite loop.
I did not find a way to update field value without calling node->save() if there is a way please let me know (I know there was a way in drupal 7 field_attach_update which is deprecated as of 8.0.x I think)
Is there a way to call node->save() which does not call hook_entity_presave ?
or alternativelly what checks can I do in the hook_entity_presave to know if the field was just updated programmatically and not from user edit ?


texts:
I have a menu:

Parent-1
 - Child-1-1
 - Child-1-2
 - Child-1-3
 - another_child
Parent-2
 - Child-2-1
 - Child-2-2
 - another_child

I needed change the name of Parent-2 item (Parent-2 text is unique), I did it with hook_link_alter() hook:

/**
 * Implements hook_link_alter().
 */
function MY_MODULE_link_alter(&$variables) {
  if ($variables['text'] == 'Parent-2') {
     $variables['text'] = t('New name');
  }
}

I need too to change the names of all child of Parent-2 dynamically. I can't do it with hook_link_alter() hook because in my example there is two elements(another_child) with the same name. Those changes must not be saved in database.

How can I do this?


texts: I want to create a hook function so that other modules implement it, any pointers to how it is done?


texts:
how to remove or edit comment item like fieldset-wrapper.
just i want the form-type-select show and or edit description in fieldset wrapper.
tnx for all


texts: Part of foreach in tpl.php of the View acts strange

texts:
I created foreach in tpl.php of the View and it looks like this:

<?php foreach($view->result as $result): ?>

<img src="<?php print file_create_url($result->field_field_client_image[0]['raw']['uri']); ?>" class="img-responsive">

<?php endforeach; ?>

My View has only one image field. Now I have two nodes and each of them have only one image, as output I should get:

but I got:

which is very strange.

My content type that I'm showing through Views has only one field for image and it is limited on 1 image file only.

Does someone have any idea what is the possible problem?


texts: Ckeditor upload tab missing for admins and authenticated users

texts:
I'm running a D7 system where I'm using Ckeditor, Ckeditor media and media.
I'm having an issue where within 'image' tab the 'upload' tab is only showing for superuser not for admins or rest of the users.

Admins/Authenticated

Superadmin

Can someone please help figuring out to whats going wrong


texts:
I have a webform on my site and on user submission, I want to send the webform data to some php application that get the value of some variables from the URL.

This task requires me to access the webform submitted data when the user clicks "Submit" button and construct a URL (/myphpapplication?query=....) containing user filled webform values.
Please help me to achieve this.


texts: The PUT request shows "HTTP/1.0 406 Not Acceptable: Missing node type"

texts:
I have been trying to update a node data from the PUT request using cURL. bit due to some reason its showing "HTTP/1.0 406 Not Acceptable: Missing node type", I think the request is done proper but the data is not in proper format. Below is my code.

        $newSketchBoard = array(
          'title' => $title,
          'type' => 'rest_sketchboard_user',
          'field_sketchboarduser_user_id[und][0][value]'=>$data['uid'],
          'field_sketchboard_paintjob_id[und]' => $data['paintjobid'],
          'field_sketchboard_template_id[und][0][value]' => $data['templateid'],
          'field_sketchboard_user_color_id1[und]' => $data['colorid1'],
          'field_sketchboard_user_color_id2[und]' => $data['colorid2'],
          'field_sketchboard_user_color_id3[und]' => $data['colorid3'],
          'field_sketchboard_user_color_id4[und]' => $data['colorid4'],
        );
        $entity_id=$sketchboard_data['entity_id'];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER,true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 600);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_COOKIE, "{$session_cookie}");
        curl_setopt($ch, CURLOPT_PUT, 1);
        curl_setopt($ch, CURLOPT_URL, REST_BASE_URL."/node/{$entity_id}");

        $putString = $newSketchBoard;
        // Put string into a temporary file
        $putData = tmpfile();
        // Write the string to the temporary file
        fwrite($putData, $putString);
        // Move back to the beginning of the file
        fseek($putData, 0);
        curl_setopt($ch, CURLOPT_INFILE, $putData); // file pointer
        curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString));
        //curl_setopt($ch, CURLOPT_POSTFIELDS, $newSketchBoard);
        $result = curl_exec($ch);
        print_r($result);

I also tried using the following code, but it's not working.

$putString = json_encode($newSketchBoard);
$putString = http_build_query($newSketchBoard);


texts: How do I control the number of cols in a textarea?

texts:
According to the Form API, you control the number of columns in a textarea with the #cols attribute.  However, setting this seems to have no effect when I use it inside a $form array (the companion #rows attribute works as expected).

This may just be a bug (and I understand that bug-reports are off-topic on SE DrupalAnswers). But I have searched the issue queues and haven't found any bug reports about this, which makes me suspect that there is something rather basic that I've misunderstood.

So: What is the correct way to control the number of  cols in a textarea?

Environment: Drupal 7 fresh install, Bartik theme with no customization.


texts: how to programatically output menu submenu

texts:
I know that the menu_block module allows you to display a sub menu of a menu with a specified menu depth. How can I do this programatically? I see that using

menu_tree_page_data()

you can set a maximum depth, but no way of specifying the Starting level, as you would from the Menu Block UI page.


texts:
I started creating my site in Wordpress 3.1, and I have hit a speed bump. I am considering switching to EE or Drupal 7, in hopes of achieving my vision of the site.

The problem I am having is excluding terms in the dropdown menu query. Currently I have taxonomies for CarMake, CarModel, Year, etc... My problem is when I select Honda, the  menu does not exclude non Honda cars, so you get a giant list of car models.

The search menu then would return all "posts" that include those taxonomy terms in the "Videos" custom post type. Each "post" was essentially a blog post with a very short description and a youtube video.

Before I invest countless hours learning Drupal or EE, I would like to find out how hard this menu/search would be to implement. An example of the menu I would like to re-create is here


texts:
I am using the Captcha module to protect my site against spam.

I have put everything else on my form inside a fieldset which is collapsible by default. Howeve, the captcha fieldset is the only thing being output last and outside of the fieldset. Using hook_form_alter and dsm($form) I cannot see the captcha fieldset so i'm guessing it's not part of the form??

after scouring through the code i have discovered it's created via a theme function (theme_captcha) which I can override inside my template.php.

I would like to know how can I bring this fieldset inside the form just above it? Look at the screenshot attached.

Thanks


texts: I'm using Drupal 6 and context. It seems that context does not react on path like this mypath?123 Is there any way to check such path with context?


texts: Taxonomy hierarchy via separate dropdowns

texts:
I am building a view that requires users to select from a drop down menu containing a list of taxonomy terms, which will then filter the view results based on those terms. So far, so good.

I want to make the dropdown menu with only all of parent taxonomy terms of a specific vocabulary so that when one of the parent terms is selected, a second drop down menu shows all of the children of the selected term.

How can I accomplish this, preferably without an extra module? I will consider any means to accomplish this goal.

More specifically, I am building a view based on states and counties, and want users to first select a state and then select from the list of counties for that state.


texts: Reference node inherits taxonomy terms of referenced node

texts:
This is a problem that's been bugging me for days now and haven't yet found a solution in Drupal 7.

I'll be more specific:

I have a content type named Debate and another one called Vote.
Vote type has a node reference field to Debate type.

Debate type has a term reference field (autocomplete widget, 4 values, Voting choices vocabulary) where user inserts the voting choices of his Debate node.

Vote type has a term reference field (select list, 1 value, Voting choices vocabulary) where user can choose a term to vote.

My problem is that the select list of the term reference field of the Vote node shows all the terms of the Voting choices vocabulary. What I want is the select list of the Vote node to show only the terms that come from the Debate node it's referring to.

In other words I need to filter out the terms of the Vote node based on the Debate node it's referring to, when I'm at the node/add/Vote form of course.


texts: Hide Group audience/content visibility in node

texts:
When displaying a node belonging to some OG, the group audience and the group content visibility is displayed at the end of the node just after the content of the node.

Is it possible to disable that ?
I would avoid code editing if possible.


texts: Arrange formatted fields in Views row using a template

texts:
I want to render the rows of my “Recent content” Views page using a template in order to

subdivide the rows into multiple divs,
freely move around the rendered fields within these divs, and
apply some custom PHP where needed.

Idea A (fails): I could achieve this by creating a new Display Suite layout for nodes and using this layout to render my view set to display format “Content”. However, I need to group the rows by a specific field, and grouping by fields is not available in the “Content” display format – for this, I would need to chose the display format “Fields”.

Idea B (fails): When displaying fields (say, as an unformatted list), I can make use a copy of

views-view.tpl.php to adjust the coarse layout of the view, e.g., put an additional div around the whole content block;
views-view-fields.tpl.php to adjust how a single field should be rendered;
views-view-unformatted.tpl.php to adjust the coarse layout of rows, e.g. put
an additional div around the whole row. However, here the $row variable is not an array of rendered fields but rather a string containing the full html markup of the row, so I cannot access single fields and move them around within the row as I wish.

Idea C (works, but isn't it extremely inefficient?): I could display an unformatted list of fields, but render only the Node-ID-field. Then, in views-view-unformatted.tpl.php I can load the whole node corresponding to the current row via $node = node_load($row); and access all fields attached to it via $node->field_whatever. These I can then move around as I wish, wrap in divs, and apply custom PHP.

Idea C seems to work, but it also seems highly inefficient, as I will have to load the full node for every row. Also, I want to leverage the many views display formatters that my fields come equipped with, which I would have to re-build manually.

Question: Is there a way to specify formats for specific fields within the Views UI, submit only these to a template (and not the whole node), and move them around freely within the row as explained above?


texts: What version of jQuery does Drupal 8 use?

texts: How can I find out what version of jQuery a particular release of Drupal 8 core is using?


texts:
I have Drupal 7 using the DKAN module. When I edit a resource and try to save it, I'm getting a The URL is invalid error message.

Here is the url that is being edited from: http://hostname/?q=dataset/datasetnet/resource/e1f740cd-e80c-40d7-8d5d-e5a7221afe7c and then url change to http://hostname/?q=node/2051/edit.

So I checked the log and here is what I'm seeing the following errors:

Notice: Undefined index: filefield_dkan_remotefile in dkan_dataset_resource_node_form_validate() (line 536 of /dkan/dkan/profiles/dkan/modules/dkan/dkan_dataset/dkan_dataset.forms.inc).

Is there a reason why the resource is not saving?

Thank you,
Kevin


texts: Redirect to checkout after pressing the "Add to Cart" button

texts:
When a user presses the "add to cart" button on a product page, I want to automatically redirect the user to the checkout page.

Drupal 7 has an issue for doing this programatically and an issue for doing this with the Rules module.

Rules is still in alpha for D8, and I tried to make a rule that acts on after saving a new order, but I'm getting an error when I try to add an action:

Error: Call to a member function getDataType() on null in Drupal\rules\Plugin\RulesAction\EntityCreateDeriver->getDerivativeDefinitions() (line 99 of modules/contrib/rules/src/Plugin/RulesAction/EntityCreateDeriver.php).

So I want to redirect from add to cart to the checkout page programatically.

But there is no documentation yet.  So if anyone can explain how to do this, I would be much obliged.


texts: How do I update a node via a custom form?

texts:
I have built a custom form (in a module) that creates several related nodes in the database when submitted. Now, I need to create a module so that a user can update his/her submitted form data at a later date. Here's my rough plan:

(1) Determine the nodes that the user wants to update via a wildcard in a requested url;
(2) retrieve the required data from the database;
(3) build a form and insert the retrieved database values via the #value property;
(4) bulid a submit function that uses db_update to update the node

Is this the right approach for updating a node via a custom form? Here's my (not working) module code so far:

// Implements hook_menu().
function update_card_menu() {
    $items['update-card/%update_card'] = array(
        'page callback' => 'update_card_form',
        'page arguments' => array(1),
        'access callback' => TRUE,
    );
    return $items;
}

// Database query function.
function update_card_load($nid) {
    $query = db_select('node', 'n');
    $query -> condition('nid', $nid);
    $query -> join('card_number', 'cn', 'n.nid = cn.entity_id');
    $nodes = $query
    -> fields('n', array('nid', 'title'))
    -> fields('cn', array('field_card_name_nid'))
    // This query will get more complex - I need more nodes and more fields
    -> execute();
    foreach ($nodes as $field) {
        $card['nid'] = $field -> nid;
        $card['card number'] = $field -> field_card_number_nid;
    }
    return $card;
}

$card now contains some values I want to populate my update form:

Array ( [nid] => 123 [card number] => 456 )

But how do I get $card into my form builder function, so that I can populate my #value properties from this array? My code does not work.

/**
 * Renderable form array return function.
 */
function update_card_form() {
    return drupal_render(drupal_get_form('update_card_capture'));
}

/**
 * Form builder function.
 */
function update_card_capture($form, &$form_state, $card) {
    $form['nid'] = array(
        '#title' => t('nid'),
        '#type' => 'textfield',
        '#value' => $card->nid
    );
        $form['card number'] = array(
        '#title' => t('Card number'),
        '#type' => 'textfield',
        '#value' => $card->card_number
    );
}


texts: Displaying top visited links from other content types in one (filtering)

texts:
I have made one block for most visited links (Top Links) in my Drupal website, but I don't know how to list most visited from different pages. For example, if I have created a page named "Drupal" and within that page I have added some content with some title, then I have to examine and count those titles and list the top visited title from each and every page on my homepage (only one from each and every title that is most visited) and list them on my homepage block.

Could anyone help me with this.


texts: Field not rewritten even though "Hide rewriting if empty" not selected

texts:
Simplified situation:

A view includes fields first_name and last_name.
first_name is marked "Exclude from display".
last_name has the label Full name (which becomes the column heading in the view).
last_name has "Rewrite the output of this field" checked and the rewrite text [first_name](space)[last_name].
last_name has neither "Hide if empty" nor "Hide rewriting if empty" checked in "No Results Behavior".
Records with both first_name and last_name or only last_name show properly in the Full name column.
Records with only first_name (i.e. empty last_name) show nothing.

Seems Drupal should rewrite the field for records with no last_name to show first_name since there is a specific "Hide rewriting if empty" checkbox that is not checked. Is this expected behavior? Or might there be a module interfering with things?


texts: Custom pane data not retained on back button

texts:
I have created a custom checkout pane in the checkout form. The panes order is: checkout->custom_pane->review->complete

When I click 'continue to next step' on custom pane, it goes to review pane and I see all the custom pane data. However when I click the 'Go back' on review pane, it's not retaining the data on custom pane. I see only blank fields on custom pane.

Appreciate any help. I am new to DrupalCommerce.


texts: Mixed content issue while running updates.php in Drupal 6.37

texts:
We are facing this issue again for Drupal version 6.37.
We do not have jquery update module installed.

In our case the progress bar just hangs but the functionality is accomplished.The Drupal core and modules do get updated.
When we run the update.php since ours is a https site, we get the Mixed content error

Mixed Content: The page at 'https://example.com/update.php?op=start&id=14' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://example.com/update.php?id=14&op=do'. This request has been blocked; the content must be served over HTTPS.

Any help will be appreciated.


texts: What is the proper way to drop database references for an uninstalled drupal module?

texts:
I've uninstalled the Commerce Coupon 7.x-2.0-beta3 through the admin ui and removed the corresponding folder from the sites/all/modules directory. Now when I install the previous version of Commerce Coupon 7.x-1.0-beta7 I get hit with the error.

DatabaseSchemaObjectExistsException:
 Table commerce_coupon already exists.

When I look at the Database in phpMyAdmin I see the the following references.

commerce_coupon
commerce_coupon_type
field_data_commerce_coupon_order_reference
field_data_commerce_coupon_reference
field_revision_commerce_coupon_order_reference
field_revision_commerce_coupon_reference

I am not very familiar working with tables through SQL. Is there a basic procedure or query that is commonly used for deleting all references to a particular Drupal module?


texts:
I want to use theme_debug to check which elements of a site use which .tpl files.

I have tried turning it on by using the drush command:

drush @mysite vset theme_debug 1

Though I do get the response theme_debug was set to 1, this does not seem to work.

Would anyone know if there is a way to get this working?

(Drush it's self seems to be working ok as I can use drush @mysite cc all)


texts:
I would like to have a font awesome icon in my link text.

<i class="fa fa-pencil"></i>Blogs

Since link fields are generated in LinkGenerator.php, they get escaped.

if (!SafeMarkup::isSafe($variables['text'])) {
  $variables['text'] = Html::escape($variables['text']);
}

There doesn't seem to be any way to bypass this by setting a HTML option to TRUE.

Is there any way to achieve this?


texts:
Sorry, I'm very newbie to Drupal. I have my new website with Godaddy, I installed Drupal, , and I'm trying to install "Views", but none of the versions I try to install are working. Through the upload a module link, I put the path to the file, it starts to upload, but sometimes it returns me to the original upload module page, or I get a blank page.
Then, I tried through the URL link, and I get messages like this one:
"
Uncaught exception thrown in session handler.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'uid' cannot be null: UPDATE {sessions} SET uid=:db_update_placeholder_0, cache=:db_update_placeholder_1, hostname=:db_update_placeholder_2, session=:db_update_placeholder_3, timestamp=:db_update_placeholder_4 WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ); Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => 0 [:db_update_placeholder_2] => 186.31.188.159 [:db_update_placeholder_3] => overlay_refresh_parent|b:1; [:db_update_placeholder_4] => 1420733668 [:db_condition_placeholder_0] => vYQ5soHEzo2a4yioZAIpOtgpf0qdJGqEUNOSy7erQ8c [:db_condition_placeholder_1] => ) in _drupal_session_write() (line 209 of G:\PleskVhosts\inversiones360.com\httpdocs\drupal\includes\session.inc).
"

Any help would be very appreciated. Thank you.

Marcel