texts: How can I programmatically recalculate an order total after changing the billing country

texts:
I have various international tax rules in place, specifically for EU VAT at different rates. This is all working as expected.

On the checkout form, when you enter a non-EU address, like Australia, when you go to the next page in the checkout process, the UK VAT line has been totally removed from the order total, exactly as I would expect.

My client wants to update the order summary on the billing page by AJAX to avoid confusion. Australian customers still see the UK VAT rate before they submit their address.

I've got the AJAX update working fine, and can load the order, update the billing country, and save the order. When I then refresh the page the address remains as I changed it, but the order total still reflects the old country.

I have traced through the code to see how the submit handler deals with this and I can't see what I need to do.

Is there a way I can recalculate the order total in code, either in form_alter or the AJAX callback, so that the order object reflects the correct price for the billing country already set?

So, in short, if I change the billing address for an order, in code, how do I tell that order to recalculate it's totals?

I hope that makes sense and thanks for any help you can give.

This is what I'm trying, in hook_form_alter:

  if ($form_state['order'] &&
    !empty($form_state['input']['customer_profile_billing']['commerce_customer_address'][LANGUAGE_NONE][0]['country'])) {

    $new_country = $form_state['input']['customer_profile_billing']['commerce_customer_address'][LANGUAGE_NONE][0]['country'];
    $order = commerce_order_load($form_state['order']->order_number);
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    if (!empty($order->commerce_customer_billing)) {
      if ($new_country !== $order_wrapper->commerce_customer_billing->commerce_customer_address->country->value()) {

        $order_wrapper->commerce_customer_billing->commerce_customer_address->country = $new_country;
        $order_wrapper->commerce_customer_billing->save();
        $order_wrapper->save();

        commerce_order_calculate_total($order);
        commerce_cart_order_refresh($order);
      }
    }
  }

Stepping through each call watching the commerce_order_total and the number of components never changes, no the VAT line never changes and the price never changes. When I press "Continue to next step" the VAT line changes (is either added or removed appropriately).

Very frustrating. I've looked at the submit call and tried to trace through it but can't find where the total is being changed. I'm guessing it's in rules somewhere. If it makes a difference we're using commerce_eu_vat


texts: Configuration changes that will not import?

texts:
I have some configuration that will not import. If I run drush config-import --preview I see the changes to be imported; I hit 'y' to import. When I run the same command, the changes are still there?

My guess is that when I run this command the config files should say to the database: 'hey, be like me'. Then when I run it again, Drupal should ask 'are the config files and database the same?' - they should be if they were synced - and Drupal should say 'cool, nothing to do, they match'. Right?

Am I missing something - if not, what can I do? Thanks.

$ drush config-import --preview
 Collection  Config                                            Operation
             core.entity_view_display.node.page.search_result  update
             core.entity_view_display.node.page.search_index   update
             core.entity_view_display.node.book.teaser         update
Import the listed configuration changes? (y/n): y
The configuration was imported successfully.                                                                                [success]
$ drush config-import --preview
 Collection  Config                                            Operation
             core.entity_view_display.node.page.search_result  update
             core.entity_view_display.node.page.search_index   update
             core.entity_view_display.node.book.teaser         update
Import the listed configuration changes? (y/n):


texts: Override one line in core tabelselect jQuery behavior so custom checkboxes aren't affected

texts:
I have created a custom table using a Form API tableselect element, and within my table, I have embedded a checkbox form element that is checked based on an entity field (see here for details). The checkbox functionality works fine. The problem I've discovered, though, is that the Select/Unselect All checkbox that is created as the first column in the table also affects my custom checkboxes, in that when I click on the select/unselect all checkbox, it also selects/unselects all the checkboxes in my column.

The offending code is in the tableselect jQuery behavior, and it's one line that makes the assumption that the only checkbox a tableselect element will ever have is the one that is part of the element:

if ($(event.target).is('input:checkbox')) {
  // Loop through all checkboxes and set their state to the select all checkbox' state.
  checkboxes.each(function () {
    this.checked = event.target.checked;
    // Either add or remove the selected class based on the state of the check all checkbox.
    $(this).closest('tr').toggleClass('selected', this.checked);
  });
  // Update the title and the state of the check all box.
  updateSelectAll(event.target.checked);
}

As the comment says, it does all checkboxes. Sigh.

From what I've been reading, my only option is to use hook_js_alter to replace the behavior with my own version. However, that seems like a bit of overkill just to change a couple lines. Is there another way to keep this behavior from affecting my checkbox field, or am I understanding correctly?


texts: Exclude a not-hidden field in the content

texts:
In Drupal 7, I'm tying to show all the taxonomy terms from a specific vocabulary linked to the current node being viewed. I'm doing this with a new block defined in my module.

I added a field called tags in my contenttype and gave this field the whole taxanomy behavior. This made it possible to get the terms with:

$node = menu_get_object();
$node->field_tags <- array of tags to use

But, here comes the problem, this field is only there when it's set to visible in admin/structure/types/manage/page/display . But when i do that it also becomes visible in the content. If i put it to hidden it does not only get removed in the content/node view, but it's also gone from the whole $node object.

It there a way of getting the fields from the current node that are set to hidden?

Thanks,
Jonathan


texts: Panelizer page manager variants not selected

texts:
I have installed the page manager, panels everywhere and Panelizer. A long time ago I set up a few content types and managed them with Panelizer, it all works fine.
I've made a site_template variant, just once at this time and it all works also fine. Now I wan't to make different site templates for different content types.

So I've made a node_view "Panelizer"-variant for each content type. I've also made the different site_templates variants. Then I select the site_template for each node_view variant. But it din't work's as I expected it!!

It always tooks the site_template variant at the top and not the selected. It seems that the node_view panelizer variant is never selected, because the panelizer overrides the page manager (? !).

Please help me, thanks!


texts: Drupal View for the 10 Most Recent Items Sorted by Date ASC

texts:
Is it possible to construct a view of the 10 most recent nodes sorted by date in ascending order?

This sounds simple, but it seems as if it's more complicated than I'd imagined.

I think to do this in SQL you'd need a subquery, and I can't see that views is capable of that...

...or is it possible to reverse the order of the rows in the view after they're brought back from the database?


texts: How to resist anonymous user to access module internal files? eg. path starts from \Drupal\module\mymodule\files

texts:
I have one file placed in my module. I want that only authenticated users or admin can access the content of this file. For anonymous users, it should be shown 'You don't have permission to access...'

Link is like Sample File'

Right now issue is, even if i logged out, I am able to see the content of this link.

I tried this:

if(isset($user->roles[1])) {
        global $base_url;
        return $mylink;
      }

but above code is not working for me.

What is the best possible way to achieve this?


texts:
I want to add a captcha to the PDF generator from the Print Module so that my server doesn't waste time generating a PDF for robots and to prevent DOS attacks.

There is a similar question asked, but the accepted answer doesn't actually answer my question (the PDF Version part), but rather only the E-mail part.

Since the PDF Version doesn't link to a form, there isn't a form ID I can add to the Captcha module. Is there a way to require a CaPTCHA to download/generate a PDF?


texts: What is the most performant method to run many UPDATE statements?

texts:
What is the most performant method and best practices method to run many UPDATE statements efficiently? Currently I'm just creating a text block of many UPDATE statements separated with semicolons and passing that into a single db_query() call.

Using this method I'm currently getting this error, so I'm guessing it's not a smart way:

  PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute
  queries while other unbuffered queries are active. Consider using
  PDOStatement::fetchAll(). Alternatively, if your code is only ever
  going to run against mysql, you may enable query buffering by setting
  the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.:

Is there a better way that is as fast? I will need to run possibly hundreds of UPDATE statements.

Why must I do so many queries? For every node, I track three metrics of that node. These metrics are determined form other sources programmatically (like traffic data). For speed, I created a table that just tracks the nid, and the values of the three metrics. On a regular basis, I have to update the metrics for every node in this table. Every node in the system will have a row in this table.

I determine a forth metric from the values of the three, so each day I have to:

Update the values of metrics 1-3
Update metric 4 based on values of metrics 1-3


texts: What module would give an image thumbnail list in a slider format?

texts: Which module would give the following slider effect? So i have a list of image thumbnails and I want to be able to scroll through them by clicking on the left or right arrows and have it show X number of them depending on my screen size.


texts: Drush on distributed server architecture

texts:
We have distributed cloud server architecture - storage, database and webserver. We have installed drush 8 on storage server, as there are project files. We do not have direct ssh to the database or webserver.

When I try to run e.g. drush cc all on this storage server, response is error: PDOException: could not find driver.

I suppose that problem is, that database server is remote (database is not on storage server), so drush cannot find SQL driver. Settings.php is configured correctly, site is running, only drush has problems.

I read more about drush aliases, or syncing, but I do not think, that this is the solution for my problem. Do you know how to solve this problem and how to use drush on this type of server infrastructure?

Thanks for your help.


texts: Can Drush be assigned as a ssh users default shell?

texts:
Problem:
I need to allow ssh access to my web server to dev team in order to use Drush. I am reluctant to give them full SSH access due to lack of trust in their SSH skills and knowledge.

Attempted Solution:
I tried creating users on my server and only allow them access to Drush using the following command.

useradd -s /usr/bin/drush drushuser

On logging in with drushuser, a list of commands displays and logs out immediately.

I do something similar with git and git-shell, I set the /usr/bin/git-shell as their default shell and it does allow them to push and pull content remotely.

Is there any way I can get the same results for drush?


texts: No HREF on Content menu on admin toolbar

texts:
I have a very odd problem that cropped up yesterday on one my sites.  The site is Drupal 7 with the stock toolbar module installed.  When you access the site for the first time logged in as an admin user, the Content menu link does not work.  All the other menu links work fine.  When you go to the Structure page next, the Content menu works correctly.

Looking at the source, the A tag for the Content menu does not have an HREF attribute. All the other menu links do.  When you go to the Structure page, the Content menu has an HREF attribute as expected.

I looked at the menu_links table and everything looks good.

I ran debug through the toolbar.module and the array data is correct.

I ran debug into the toolbar.tpl.php file calling render($toolbar['toolbar_menu']).  The array data is correct.

I'm now looking to see what else might be causing the HREF to "disappear" from the Content menu.

Has anyone seen this before?

The first commenter mentioned looking at the static page source (great idea...DevTools has made me lazy ;) )

Content
(Find and manage content.)

So the HREF is in the A tag. I'm looking at all the Javascript on the site now.

** UPDATED **
I added the following code (from http://addyosmani.com/blog/mutation-observers/):

var observer = new MutationObserver(function (mutations) {
  // Whether you iterate over mutations..
  mutations.forEach(function (mutation) {
  // or use all mutation records is entirely up to you
    var entry = {
      mutation: mutation,
      el: mutation.target,
      value: mutation.target.textContent,
      oldValue: mutation.oldValue
   };
   console.log('Recording mutation:', entry);
  });
});
var options = {
  childList: true,
  attributes: true,
  characterData: true,
  subtree: true,
  attributeOldValue: true,
  characterDataOldValue: true,
  attributeFilter: null
};
var target = document.querySelector('#toolbar-link-admin-content');
observer.observe(target,options);

This is the output which confirms that something is modifying the DOM.

Recording mutation: Object {mutation: MutationRecord, el: a#toolbar-link-admin-content, value: "Content (Find and manage content.)", oldValue: "/admin/content"}
Recording mutation: Object {mutation: MutationRecord, el: a#toolbar-link-admin-content, value: "Content (Find and manage content.)", oldValue: ""}

How do I go about finding what is causing the change? What code fired the observer?


texts:
I have a Query like this:

$query = db_select('nid_tid', 'nt')
->fields('nt')
->condition('terms', $name,'=');
$result=$query->execute();

$row=$result->fetchAssoc();
$nid =$row['nid'];
$ex=explode(',', $nid);
foreach ($ex as $tag_nid)
{
  $out .= $tag_nid;
}

return $out

I want paging this result .for example per 10 result in one page

thank you


texts: How to make specific field disabled on node submit, but enabled on node edit?

texts:
In content type testtype I have 2 required field: field_one & field_two.

I need to make field_one only enabled on node submit, while field_two only enabled on node edit.

So, when submitting, we can only see field_one, and when editing, we can only see field_two


texts:
In order to allow users to add a remote video from Youtube, I am using the media type in a custom content type.
When users create a node of that content type, and add a media, they get a list that includes the media created by other users. I need that users see only the media they created, when creating a new node.
How can I achieve this?


texts: Fill filter between (min, max) field programmatically drupal

texts:
I have created the view. It displays all comments from a certain time period. So I need filter created date and between option, isn't it?

But also I need to get these MIN and MAX options from node: MIN - created node time and MAX - node`s filed "to_date".

So, How can I pass these parameters to view? Is here some solution?

Edit:

Case: I should create contest module(contest for most popular comments).

Process: Admin creates a node of type Contest. There he must specify contest "To date" and add the description. So in order to determine contest winners, I have created view, that must sort all comments by total views and filter by range date(node created and "To date" field) from node on which page view is displaying.
I need to display this view under node: I do it in this way:

$page['content']['winners'] = array('#markup' => views_embed_view('contest_winners_one', 'block'));

But how to change view filter for every view instance?


texts: How do I override views-view-summary-unformatted.tpl.php inside my own theme?

texts: I cannot override views-view-summary-unformatted.tpl.php inside my own theme. I copy the tpl from the views module directory, paste into my theme directory and modify the code. My website will not recognize the new tpl. If I make the changes directly inside the views module, then I can see my changes on my website. However, I know it is not best practice to hack a contributed module. I've tried adding "--myViewName" to the tpl file, but this doesn't help. When I look at the Theme Information in my view, I don't see views-view-summary-unformatted.tpl.php listed there. (The reason I am trying to override this tpl is that I want my alpha bar to include all letters of the alphabet even if there are no entries for a particular letter.) Can someone please help me figure out what I am doing wrong? Thanks!


texts: How to conditionally book an appointment on calendar module?

texts:
I would like to offer the opportunity for users of the site to book a visit to the doctor, do not let book if the day is full of appointments and show the day in red on the calendar.

Is this possible?


texts: Create native Excel XLS and XLSX files from scratch and export directly to a PDF file

texts:
We are considering migrating a Cold Fusion application to Drupal and I am wondering if the below 2 capabilities that are current Cold Fusion application is doing can be done within Drupal 7.

The ability to create native Excel XLS and XLSX files (NOT HTML tables that Excel has to convert each time it opens) from scratch. This includes the ability to use native Excel functions, formatting, and multiple tabs/sheets. CFSPREADSHEET makes this a relatively simple task for us.
The ability to export directly to a PDF file. CFPDF and CFCONTENT makes this almost as simple as wrapping the desired output in a set of tags and it’s done in many cases.


texts: Delete button not working on forum comment

texts:
I am using the AJAX Comments module.
For forum I am using the Advance Forum module.
In forum topic  I have some post replies, my issue is when I am click on delete button on forum comment a popup is shown with message:

  You are not authorised to access this page

I have assigned the permission so any one can delete their own comment.

I don't know what is the issue because on other content type comment its working fine but only on forum comment its not working.


texts: is there any way to add Country Module in a taxonomy field.


texts: When trying to preprocess view fields why does hook_preprocess_views_view_fields not always get called?

texts:
I'm currently preprocessing a view to rewrite fields based on some other logic. We basically want paragraph content to link to the parent that's using it. We're using search api and search api solr so we have to index a lot of entities we might not actually display as pages.

Currently i have the following preprocess

    function centers_search_preprocess_views_view_fields(&$vars) {
        // return early if not the correct view.
        if($vars['view']->name !== 'search_solr') {
            return;
        }

        // only rewrite urls of page attachments. Currently all are listed but
        // it's possible we won't need to handle all of them.
        $content_types = array(
            'page_attachment_basic',
            'page_attachment_full_width_link',
            'page_attachment_slideshow',
            'page_attachment_tabs',
            'page_attachment_three_column'
        );

        // Get the entity type of the row content.
        $row_type = $vars['row']->_entity_properties['entity object']->type;
        // Check to see if the type is in the above array of page attachments and that
        // referencing entity is populated. If not then this content isn't being used on
        // any pages.
        if(in_array($row_type, $content_types) && array_key_exists('referencing_entity', $vars['row']->_entity_properties['entity object']) == TRUE) {
            // Query the page attachment table for the referencing entity.
            $query = db_query('SELECT entity_id
                FROM field_data_field_page_attachments
                WHERE bundle IN (:type)
                    AND field_page_attachments_value = :nid', array(
                        ':type' => array('second_level_page', 'network'),
                        ':nid' => $vars['row']->_entity_properties['entity object']->referencing_entity->item_id
            ))->fetchAssoc();

            // load the entity
            $parent_nid = $query['entity_id'];
            $parent_node = node_load($parent_nid);

            // get the path alias for the content.
            $parent_node_url = drupal_get_path_alias('node/' . $parent_node->nid);
            global $base_path;
            $parent_node_url = $base_path . $parent_node_url;

            // Rewrite the url to point to the referencing entity.
            $pattern = "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/";
            $vars['fields']['title']->content = preg_replace($pattern, $parent_node_url, $vars['fields']['title']->content);
            $vars['fields']['view_node']->content = preg_replace($pattern, $parent_node_url, $vars['fields']['view_node']->content);
        }

        switch($vars['fields']['type']->content) {
            case 'Second Level Page':
                $vars['fields']['type']->content = 'Page';
                break;
            case 'Blog entry':
                $vars['fields']['type']->content = 'Blog';
                break;
            case 'Page Attachment - Tabs':
                $vars['fields']['type']->content = 'Page';
                break;
            case 'Product':
                $vars['fields']['type']->content = 'Publication';
                break;
            case 'Project':
                $vars['fields']['type']->content = 'Network Project';
                break;
        }
    }

But when we have the view set up to use ajax and auto submit for the exposed filters the preprocess seems to only run for the first load and then the ajax responses of filtered content seem to skip the preprocess function.


texts: Which hook_view_ is always executed and never cached?

texts:
In D8.6 I have problems with counting in a view. After the counting a message in the site should display the total. The message is sometimes show and sometimes not.

I used several different view hooks as some are not executed after caching. Therefore I used the list with all hooks for views

function nvgh_views_post_render(ViewExecutable $view) {

  $result = $view->result;
  $total = 0;

  foreach ($result as $row => $rowinfo) {
    // kint($rowinfo->nid);
      $node = \Drupal\node\Entity\Node::load($rowinfo->nid);
      $total = $total + $node->get('field_pe_punten')->value;
      // $pe_punten = $node->get('field_pe_punten')->value;
  }

  drupal_set_message('Het totale aantal punten bedraagt voor dit overzicht: ' . $total, 'status', TRUE);

}

Which hook should I use in orde to see the message every time?


texts: Bluehost cloud hosting, varnish caching issue authenticated user

texts:
I have narrowed down my problem to varnish on my cloud server provided from bluehost.

When logged in you make an edit, but it is not reflected back until 5-10 minutes later.

Clearing all caches, browser history, etc. nothing helps expect logging into bluehost and clearing the varnish cache.

Any ideas?


texts: Show custom page while the server processes a form

texts:
Form submit handler sends some time consuming requests to other servers. I need to show custom page with some simple content like timer/progress-bar/images while server will process submitted data.

Not sure how this could be properly done in Drupal 6.26.

Found useful batch tool (set_batch()), but didn't figure out how to replace default progress-bar with custom page and content.


texts: Using the Profile2 module, how to access contextual information to place a views block on profile page?

texts: I'm trying to add a list of author's content to a profile2 page. The profile page is separate from the user account page so I can't use get UID from URL option.


texts: site created using drush arr failing with missing index.php

texts:
I am using drush archive to copy a live site to a test environment.  The test environment is on my local machine, the live site is on a hosted platform.

The arr command seems to complete successfully and the new database config is correctly appended to settings.php, the files are all restored to the appropriate directory on my local machine and the database is created and populated.  So far, so good.

If I navigate to the default page  http://localhost/~drew/site2, the home page is displayed, but it is clear that the CSS is from my theme is not available - I think that this is because the CSS was compressed and cached on the live site, so I can probably ignore that for now.  If however, I try and navigate to any other page, I get an HTTP 404 saying localhost://~drew/site2/index.php not found yet when I check the filesystem, it's definitely there, and the web server can clearly see it because it created the home page earlier when I navigated to the default page.

I do use pathauto and have set explicit path names for my pages on the live site - could this be broken in some way when restored?

Thanks


texts: Errors while creating Drupal Commerce product programmatically

texts:
I am creating a Drupal Commerce product programmatically.

I have this test custom PHP script in root folder where Drupal is installed.
I am trying to create product/ custom product type "sensilab_product" (product type is already defined in Drupal admin ui), but i get errors when i run this script.

I want to know what to include in the file to start Drupal bootstrap?
I've got this script from this url: http://polso.info/how-create-drupal-commerce-products-programmatically

It is Drupal 7.41 /Install profile Commerce Kickstart (commerce_kickstart-7.x-2.31)

<?php

    ini_set('display_errors','1');
    //ini_set('memory_limit', '512M');
    define('DRUPAL_ROOT', getcwd());
    include_once 'includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    module_load_include('inc', 'node', 'node.pages');

    // Product
    $product = commerce_product_new('sensilab_product');
    $product->sku = "PRODUCT-SKU111111";
    $product->title = "Product Title 1111111";
    $product->language = LANGUAGE_NONE;
    $product->uid = 1;
    $product->commerce_price[LANGUAGE_NONE][0] = array(
    'amount' => 10 * 100, // $10
    'currency_code' => "EUR",
    );
    commerce_product_save($product);

I get this errors:

PHP Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923

Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923
PHP Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923

Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923
PHP Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923

Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923
PHP Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923

Notice: Undefined index: REMOTE_ADDR in /home/sanazentyal/public_html/drupalCommerce/includes/bootstrap.inc on line 2923
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'PRODUCT-SKU111111' for key 'sku': INSERT INTO {commerce_product} (revision_id, sku, title, type, language, uid, status, created, changed, uuid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array
(
[:db_insert_placeholder_0] =>
[:db_insert_placeholder_1] => PRODUCT-SKU111111
[:db_insert_placeholder_2] => Product Title 1111111
[:db_insert_placeholder_3] => sensilab_product
[:db_insert_placeholder_4] => und
[:db_insert_placeholder_5] => 1
[:db_insert_placeholder_6] => 1
[:db_insert_placeholder_7] => 1459943194
[:db_insert_placeholder_8] => 1459943194
[:db_insert_placeholder_9] => d6a9bafb-d0fe-44d1-a217-df7ebfa0c865
)
in drupal_write_record() (line 7333 of /home/sanazentyal/public_html/drupalCommerce/includes/common.inc).


texts: I'm trying to add a custom CSS class to the <body> tag, How can I modify or pre-process the <body> tag to add the class body, Is it right to style the <body> tag with css file?


texts: Using hook_form_alter to hide a field in a view exposed filter

texts:
I am using hook_form_alter to hide a field in a view exposed filter.

function cars_form_alter(&$form, &$form_state, $form_id) {
if($form_id == "views_exposed_form"){
    $form['field_price__1']['#type'] = 'hidden';
  }
}

My questions are :

It only works if use $form_id == "views_exposed_form". But I don't want for all views only for my specific one which has form_id=views_exposed_form_car-results_panel_pane_3 ,but it doesn't work if I use the specific form id
Using the above snippet,I can hide the field but not its Label.How can I hide also the label?


texts: Sending data via post and redirecting user

texts:
So I made a module that needs to gather some data and redirect user and that data to a payment site.

function payment_upload_form($form, &$form_state){

$form = array();
$form['#action'] = 'www.somepaymantsite.com';
$form['#method'] = 'POST';
$form['CustomerFirstName'] = array(
    '#title' => t('First name'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#size' => 25,
);

$form['CustomerLastName'] = array(
    '#title' => t('Last name'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#size' => 25,
);
etc....

$form['customersubmit'] = array(
        '#value' => 'Pay now',
        '#type' => 'submit',
        '#submit' => array('wspay_submit'),
    );

return $form;

}

function payment_submit($form, &$form_state){
$option = array(
        'ShopID'=>'xzy',
        'ShoppingCartID' => $temp_cid,
        'TotalAmount'=> $amount,
        'Signature' => $signature,
        'ReturnURL' =>'http://some_sitecom',
        'CancelURL' => 'http://some_site.com',
        'ReturnErrorURL' => 'http://some_site.com/1',
        'CustomerFirstName' => $form_state['values']['CustomerFirstName'],
        'CustomerLastName' => $form_state['values']['CustomerLastName'],
        ....
        );

$options = array(
  'method' => 'POST',
  'data' => drupal_http_build_query($option),
  'timeout' => 15,
  'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);

$response = drupal_http_request('www.somepaymantsite.com', $options);
 $response->redirect_url = 'www.somepaymantsite.com';

The problem is that it does not redirect me on the first go, but when I use the same ShoppingCartID it redirects me and I get an error because the ID is the same(it need's to be different every time), but the data is in the URL .
So my question is why does it not redirect the user with the data to the site when he clicks Pay now.

---------------------- EDIT -------------

How can i create a middle page in drupal that has this data and sends it like that, meaning a confirmation page :

        <form name=“pay“ action=“https://to.the.shop.something“ method=“POST“>
    <input type=“hidden“ name=“ID“ value=“some_value“>
    <input type=“hidden“ name=“ID2“ value=“some_value“>
 <input type=“hidden“ name=“ID3“ value=“some_value“>
    <input type=“submit“ value=“Pay now“>
    </form>


texts: Partial searches through exposed filters in views

texts:
So this is an extension of a question I asked earlier today: Trouble setting up a search for a single field

To save you some reading, I have a client that wants to put a bunch of distributors in as a custom content type and have the user use a search function and find the closest distributor based on one field, their zip code. Each dealer has a number of zip code prefixes that they service. For example, a distributor that services 999 will service zips 99901, 99902, and so on. Through using views and exposed filters, the search works if they put in the first 3 numbers. But if they try to put in more, it breaks and doesn't return anything.

These prefixes are stored in one field like so: 111, 112, 113, and so on. How can I get views to only look at the first 3 numbers if they put in their full zip code or is there some other way to get this to work?


texts: How to hide input from user inside a textfield

texts:
I need text inside a textfield FAPI form element to be obscured visually, just like the password field when you type into it.

password FAPI form element does not have proper functionality for what i need, I need textfield functionality but with the ability to hide the input from user.

Is this possible with Drupal 7 FAPI?


texts: Output the total number of rows in a view

texts: Does anyone know how to show the count of the results of a custom view?


texts: How to get the parameter value from an ajax call in the page controller?

texts:
I have the following js code according to es6.
(($, Drupal) => {
  Drupal.behaviors.mymodule = {
    attach: () => {
      document.querySelectorAll("a").forEach(element => {
        element.addEventListener("click", e => {
            fetch("/mypath", {
              method: "POST",
              body: JSON.stringify({
                path: $(this).attr("href")
              }),
            });
        });
      });
    }
  };
})(jQuery, Drupal);

and in the page controller:
public function content(\Symfony\Component\HttpFoundation\Request $request) {
  $path = $request->request->get('path');
}

But I am not getting the path. Can someone tell me how to get the path in my page controller?


texts: Hook not getting called (image_title module)

texts:
I'm attempting to use the image_title module to replace a node's title by an uploaded image.  I thought it was working, but I've since discovered that it was only showing for me, not for anyone else on the site. =(

In debugging, I inserted the following into the image_title_preprocess_page() function:

$fh = fopen('/tmp/myfile', 'w');
fwrite($fh,date('r') . " starting page\n");

and I've found that this hook isn't getting called for anonymous users.  I can't think of why that would happen.  I also don't know much about the process by which hooks are run, though.

Perhaps page caching is causing the hook not to be called?

EDIT: If I just bypass the web server & call php index.php directly, image_title_preprocess_page() does get called, but then it does a SELECT image FROM {image_title_menu} and it finds nothing relevant.  I have to wonder why it's using the 'page' hook instead of the 'node' hook in the first place though.  Maybe this module just plain doesn't work.

I'm using Drupal 6.22, and while I'm investigating this (and maybe after, too) I've got a github fork here: https://github.com/kenahoo/drupal-image_title .

Thanks.


texts: One taxonomy term in multiple vocabularies

texts:
Is there is a way to refer to one term in more than one vocabulary?

e.g. i have 2 vocabularies ... Properties for sale and Properties for rent

Properties for sale:
-Apartment
-House
-Land
Properties for rent:
-Apartment
-summer house
-Room

So, how can i have the term (Apartment) in both vocabulary


texts:
As the title explains, I want to make a custom maintenance page, different from the default one.

For that I've read this tutorial: Theming the Drupal maintenance page.

I copied the file /module/system/maintenance-page.tpl.php to my theme folder, changed it a little bit, and I enabled the $conf['maintenance_theme'] = 'themeName'; line in settings.php; but I can't see the changes

What else do I need to do?


texts:
I am using 'Location map module' and I have made a block of it displaying my required map.
My requirement is to view that map in colorbox when some user clicks on 'Map' link.

I need to use Location map module only. I tried to achieve above using views but didn't worked.

Can anyone help ?


texts:
I am new to drupal and drupal 7, I saw a video tutorial previous day regarding drupal 6, there they just used this:

print $content;
print $title;

to display post title and content separately however, in drupal 7 , I copied one of theme page.tpl.php file and there is only  this:

 <?php print render($page['content']); ?>

This shows full content inlcuding everything, how do I split them into parts like:

I want to customize my template like this

Welcome to My site // for header

                            Some text Portion //

This should be same for individual page and front page that shows 2 or 3 posts.

I tried making custom node.tpl.php file too, should I add some special function call to make it able to load content from node.tpl.php file ?

I pasted this code in template to render from page.tpl.php file of my theme

function connect_preprocess_page(&$vars) {
if (isset($vars['node']->type)) {
    $nodetype = $vars['node']->type;
    $vars['theme_hook_suggestions'][] = 'page__' . $nodetype;
}
}


texts: date field missing when use date popup with date & time

texts:
in my custom module, I have used the following code:

$form['event_date'] = array(
    '#type' => 'date_popup',
    '#title' => 'Set Date & Time :',
    '#date_format' => 'd-m-y H:i',
    '#default_value' => date('d-m-y H:i'),
    '#date_year_range' => '-3:+3',
    );

but after submitting it only show time field value. also work fine when only use date('d-m-y').


texts: Advice: change the name of the author by his role in a comment

texts:
I would like to have some advice about my preprocess function i made this morning.

My goals was to replace the name by the role of the author in a comment.

I have many questions because i think my code isn't optimize and i would like to improve it:

I don't know, as a beginner, if it's better to do what i want to achieve in a module or in a preprocess function?
I used this path to change the comment author name : $variables['author'] It works but is it this variable we have to use if we want to alter the comment author.
I made my request inside my preprocess function, is it good to do that? I have only few comments for now, but when i'll have hundred of comments, do you think i'll have a problem of performance? Is there a way to improve it?

function bartik_extended_preprocess_comment(&$variables) {
 $result = db_query("SELECT users.uid AS uid, role.name AS  role_name
              FROM {users} users
              LEFT JOIN {users_roles} roles_id
                ON (( (users.uid = roles_id.uid ) ))
              LEFT JOIN {role} role
                 ON (( (roles_id.rid = role.rid ) ))
              WHERE (( (users.uid = :uid ) ))", array(':uid' => $variables['elements']['#comment']->uid));
$store = array();
foreach ($result as $row) {
  $store['uid'] = $row -> uid;
  $store['role'] = $row -> role_name;
}

if($variables['elements']['#comment']->uid == $store['uid']) {
   $variables['author'] = check_plain($store['role']);
}
}

Thanks,


texts: Get field formatter setting value from preprocess

texts:
I have added to media>video files a taxonomy term reference "video_quality", i.e. 480, 720...

I use those files in a content type "video-article" and render the file with Video.js module. This module come with some field formatter settings such as "autoplay".

I am building a module for Video.js to integrate resolution support. Based on field_formatter_settings module, I use HOOK_field_formatter_settings_form_alter to alter the formatter settings and add my custom option, i.e. selecting the appropriate taxonomy term reference.

The goal is to alter the Video.js field rendering to add a resolution selector. The resolution is attached to the video file, and the field should obtain this information in the field preprocessing in order to give the various resolutions to the template file.

I don't know how to achieve this in a generic way. I'm able to find the values i'm looking for using the "devel" module:

vars
vars > items
vars > items > [0,1,2]   <-- 3 video files attached to the node in ONE field
vars > items > 0 > field_quality > und > 0 > taxonomy term ID

The real problem is that I want to get the file's field "field_quality" name without hardcoding it.

How can I request my video field's formatting options to get my custom "resolution_selector" setting (that contains the field name!) ?

tl;dr

How can I access field formatter settings from field preprocess? Where are those settings stored?


texts: How to add a menu tab to a node to link to an information page to be used by author?

texts:
I just need some direction from module developers. I would like every node to have an 'information page' that the author can easily view. When they are logged in and viewing the node, I'd like it to appear as a link right along side that node menu bar (where it says "Edit, Revisions, Devel" etc.), called menu tabs.

I'm not very familiar with custom modules, but I'm simply looking for the basic framework, or an example module, that will add that menu link, and also allow me the place to begin adding my code.

I'm basically trying to display Google Analytics data for each node.


texts: Split D7 User Account Edit Form in multiple blocks

texts:
I need to split the user account edit form that shows up on one page to multiple pages. That means I want to separate change password fields, two custom fields i created - field_first_name and field_last_name and so on.  For moving the password fields to new block I used the solution provided in this link How can I display a change password form on its own? and it works great.

I am trying to use the same code except make some minor changes for modifying the custom fields (first name and last name).  The only difference is, I need to pre-populate these fields with the values from the current logged in users information.

// Get the currently logged in user object.
$form['#account'] = $GLOBALS['user'];

// Textfield for first name.
$form['field_first_name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#size' => 60,
'#default_value' => what should I enter here?
'#required' => TRUE
);

Also if I enter a new value for these fields, it doesnt get updated in the user account. I am using the following code -

/**
* Submit handler for change_name_form().
*/
function change_name_form_submit(&$form, &$form_state) {
// Set up the edit array to names to user_save()
$edit = array(
'field_first_name' => $form_state['values']['field_first_name'],
'field_last_name' => $form_state['values']['field_last_name']
);

// Save the account with the new name.
user_save($form['#account'], $edit);

// Inform the user.
drupal_set_message(t('Your information has been changed.'));
}

What additions / changes do I need to make to the code to get the desired output?  Any help is greatly appreciated -


texts: Possible permissions error with drush make

texts:
I am trying to run drush make distro.make but getting the following error. The only thing I can see I did different was ran sudo drush make distro.make once. Any ideas?

copy(/http---updates.drupal.org-release-history-drupal-7.x): failed to open stream: Permission denied drush.inc:840                                                                                [warning]
Could not download project status information from http://updates.drupal.org/release-history/drupal/7.x                                                                                [error]
Non-existent project type  on project drupal

previously I was running without sudo and it was working fine.


texts:
I'm trying to add a facebook like button to my website. I've tried fb_social which seems to do the job, however, it seems that Service Links can do it as well, but I couldn't figure it out.

As I haven't been able to make Service Links work, maybe I am mistaken and it doesn't do what I think it does.

I'm thinking of Service Links over Facebook social because in the future I'll propably add more service than just facebook.


texts: Customize the appearance of sharing articles to social media

texts:
I am new to Drupal and I just added a few buttons for sharing articles to social media (Facebook, Twitter etc.)
I want to customize the appearance of sharing posts.
After a few "research" I found out that I need to install meta-tags module to customize it...

The problem is that I can t figure it out how to change image or description. I tried but it didn`t work.
This is how it looks like a shared article, banner image instead article image and description with irrelevant details.


texts: Suggestions for sending email to third party merchant when checkout is completed

texts:
I need to build a site that will sell products on behalf of merchants referenced on the site and I need to notify these merchants every time a sell of their products occurs and send them information about the order we received for their product. Out of the box, commerce uses rules to send an email to the buyer and can also notify the site admin that a new order was created.

That is great but what if I need to notify a third party? Is there a way to do this out of the box or via configuration? Or is there a module for that?
I have been looking and couldn't find anything. When I try to use rules the only email available for order checkout as tokens are the customer email and the site admin email.

For the sake of clarity here is the setup I have gone for so far and where I am stuck:

I have setup a field collection on my product pages listing the contact details for the merchant selling the product.

I collect three fields information inside the field collection:

name of merchant
address
contact email

I can easily make them visible on the order form with views by using relationships but I need to make the contact email available to rules so that I can set up a rule that will send and email to the merchant when the checkout process is completed.

That's it.

Thanks for your help


texts: Drupal Commons make group content visible for anonomous users?

texts:
I have a Drupal (7.52) Commons (commons-7.x-3.40) website which currently requires users to log-in to see published content.

Now I need to publish content so it is visible to non-authenticated users... I'm not sure the best way to accomplish this.  I'm not very experienced with Drupal, the most logical thing to me would be to simply create a new Group which allows anyone (anyone|Any site member can contribute) to view content but this option seems to still require authentication.

Other options seem to be add:

new content-Type e.g. Public_Group (or perhaps Public_Page)
new role for unauthenticated users (e.g. called anyone), or
a module like this: https://www.drupal.org/project/og_visibility ?

Not sure where to start looking - please help!

Thanks


texts: How to get/provide tpl file of editing a field collection?

texts:
I want to theme a my collection field on the edit page. I have several fields in one collection and that collection gets all the height of the screen.

Though, I want the values of the collection field to fit on 200px to 300px height. To achieve this I need to override the tpl file... But how to know the name of tpl to be overriden ?

Has anyone got a clue ?


texts: What configuration is required to use date_views with a field?

texts:
I have a custom entity "referral" which is available for views:

function mymodule_entity_info() {
  return array(
    'referral' => array(
      'label' => t('Referral'),
      'controller class' => 'EntityAPIController',
      'views controller class' => 'EntityDefaultViewsController',
      ...
    ),
  );
}

The mymodule_referral table has a field referred_at which is a timestamp (stored as an int); I'd like to add a filter on this field to my view. I've got it displaying and filtering correctly with hook_views_data_alter and views_handler_*_date, but I'd prefer popup date selectors.

I understand that the date_views submodule of date should do what I want, but I can't find proper documentation on how to use it.

function mymodule_views_data_alter(&$data) {
  ...
  $data['mymodule_referral']['referred_at']['filter'] = array(
    'real field' => 'referred_at',
    'handler' => 'date_views_filter_handler',
  );
}

doesn't seem to be sufficient, because it displays in the view edit page as

FILTER CRITERIA

    Referral: Referred_at (Missing date fields!) | Settings

If I open the settings there's a compulsory field

DATE FIELD(S) *
Select date field(s) to filter.

with no options to select.

The only reference I can find to the "Missing date fields!" error message talks about hook_date_api_fields, but that hook doesn't seem to exist in 7.

What configuration am I missing?


texts:
I have a Footer region defined for my theme, and it has two blocks in it.

I have a region--footer.html.twig file and both blocks are rendered with {{ content }}.

The issue is, I need to wrap both blocks in some containers, and then each in separate containers, something like this:

    {{ block_1 }}

    {{ block_2 }}

How do I reference the blocks individually?

One of the blocks was custom and is some basic HTML, I can't seem to find a machine name for it, so I can't even try {{ content.my_custom_block }}


texts: I am new to Drupal. I have a form which adds details of user to my table. I want to display that node in a popup window. How would I do this?


texts: Route AJAX failure messages to console instead of popup

texts: How can I prevent ajax failure popups and instead route the failure to the console log instead?  Is this something I can do with Drupals implementation of jQuery?


texts: What else must I do to set up a new custom module?

texts:
I am defining my first custom module and cannot get Drupal to see it.

What I have done:

Created a subdirectory with module name at sites/all/modules/custom/mymodulename. The name is just letters, nno spaces underscores or dashes.
Added two files mymodulename.info & mymodulename.module.
mymodulename.info contains: name = mymodulename and includes a description, package = Other, and core = 7.x.
ran update.php
flushed caches
reloaded admin/modules page
module is not listed???

I suspect that I somehow let Drupal know this is my first attempt and it is just messing with me! How can I appease it?


texts: How to set variables in an installation profile?

texts:
I cannot find any documentation on the variables[] array in an installation profile info file. I can set some variables successfully in that file and others give me an invalid format error when I visit the settings page to check them after the install. The ones that I would like to set are:

variables[site_403] = <front>
variables[user_cancel_method] = user_cancel_block
variables[update_check_frequency] = 7
variables[update_notification_threshold] = security
variables[update_notify_emails] = myemail@example.com

In Drupal the source it looks like update_notify_emails is probably an array. Is there a way to make this setting an array via this .info file? I am trying to set these using the info file or the install hook rather than exporting the variables as features using a strongarm.inc due to these best practice recommendations linked on this distribution developers guide page.


texts: Unable to filter Views by a date field in the user profile

texts:
I have used the Profile module to create a date field on users profiles.

Now I want a view to list users filtering by that date field, but when I choose "Add filter criteria" in the Views UI, it does not list the date field. Fields of other types show up normally.

Is this a Views bug? How can I filter a view based on a date field from user profiles?


texts: How to let users register with their Facebook accounts?

texts:
I would like to let visitors choose between signing up by using Drupal's core sign-up system, or to register using their Facebook account.

I looked at a few Facebook related modules but that was a little confusing, and I couldn't make up my mind on which one to use (I don't use Facebook myself so I guess that doesn't help).

What are the differences between regular registered users and those who signed up using their Facebook account?
Will Drupal have access to their emails?


texts: Form text field is too wide for the side bar

texts:
I created custom block for my entity and I want to add this entity creation form to the 2nd sidebar. I managed to do this and this is how it looks like now:

First textfield goes out of bounds, where as second one, which is textarea type, is okay. After looking at Form API, I realized that textarea is re-sizable and textfield is not. How can I solve this? If I put title as text area it doesn't look that nice so I would be very happy if I could stick to textfield and make it fit somehow?


texts: How do I install multiple drupal sites in a single installation?

texts:
I am trying to install multiple sites in a single installation on a local server.

But I don't have any idea about how to do this.

Can anybody tell me how to create multiples site using Drupal 6?


texts: Configuring an Entityform with a term reference field

texts:
I have an entityform that users use to upload pdf files. On the form there is a 'Term Reference' field (select list) that lets them choose the type of document that they are uploading, e.g. 'letter', 'contract', 'invoice' etc...

These entityform submissions are then displayed as a view with the 'term reference' field displayed next to a link to the uploaded document.

My problem is that when I click on the term reference the term's page is not populated with the entityform submissions that have been labeled with it.


texts: How to insert a custom search fields in a views page

texts: I have a view page showing some books and I want to have an advanced search with search criterias at the top of this page. The search box should search inside the books page or books content type.


texts: Finding data using MySQL queries in the Node tables

texts:
Outside of the Drupal system I am trying to get user data based off of the user table and export this information into a CSV.

I'm not quite understanding how the Node table system works and where to get my data let alone how to Join it in MySQL manually.

I have my users table, the standard users table from Drupal. I'm trying to get data from quite a few tables for the user, a simple one line profile type data per user. Under a regular database structure setup it would be as simple as a few joins to the right xref ids and tables and you're good to go. It's not quite working here of course.

One of the tables in question is called field_data_field_sexo_meta. This holds the information if the user is Male or Female.

As you can see the field field_sexo_meta_value holds the information. But I do now know how to join this table to the user ID.

I've tried quite a few tables to get the user ID to link to this entity_id field but nothing as of yet has worked. For instance I've tried field_data_field_paciente which has these fields:

The last field there is the uid field, but this doesn't link anything either.

I've also tried linking to the column uid in the nodes table and a type = 'termometro' but also it doesn't link to anything and I get null on my joins.

So evidently I'm missing which table links the field_data_field tables to the users.

This is my current query:

SELECT
  u.uid,
  u.name,
  u.mail,
  ur.rid,
  n.field_su_nutricionista_es_uid,
  s.field_sexo_meta_value
FROM users AS u
  LEFT JOIN users_roles ur
    ON (ur.uid = u.uid)
  LEFT JOIN field_data_field_usted_es p
    ON (p.field_usted_es_uid = u.uid)
  LEFT JOIN field_data_field_su_nutricionista_es n
    ON (n.entity_id = p.entity_id)
  LEFT JOIN field_data_field_sexo_meta s
    ON (s.entity_id = p.entity_id)
WHERE ur.rid = 5
     OR ur.rid = 4
GROUP BY uid


texts: Updating Drupal core in a Acquia Dev Desktop?

texts:
Running the latest Acquia Dev Desktop (with subscription) with Drupal 7.22 core.

I´d like to update the Drupal core to the most recent version, but after reading the documentation on Acquia that is available to unsubscribed users, I wonder if that is at all possible. Any ideas on how one would go about this?


texts: Add two items with different shipping methods to basket / checkout in drupal commerce

texts:
I am currently using drupal commerce to build a
website for my partner who sells jewellery. I consider myself a fairly
confident drupal user and have built various websites using the platform.
This is the first time i have used commerce though.

So my issue is with shipping. I have three shipping package types defined in
a taxonomy, and a nice way to select which of these 3 package types the
product should be shipped by using a term reference field in product
creation. I have successfully got commerce to reference to this term
reference using Commerce Taxonomy Conditions. So far I have 3
shipping package types set up and 3 world zones and can get the correct
shipping cost associated to each of these options to come up fine in the
checkout pane.

So i have 9 shipping services (3 package types x 3 world zones)

BUT

The problem comes when there are two different package types (taxonomy terms)
added to the basket and therefore there should be two prices added together and in checkout it comes up with "No valid shipping rates
found for your order, and we require shipping service selection to complete
checkout."

How can I get this to work please? What am I missing?

I have tried OR and adding to that the taxonomy term which is true and the two taxonomy terms which are false and now i can get two package types displayed in shipping in the check out pane but not getting them adding together?

This is currently doing my head in, any help would be gratefully received.
Thanks,


texts: Setting a new users profile fields based on a form

texts:
Users on my site all have a "home region" field. This profile field is saved for each user and used to customise various site features, so that the user gets shown local content.
These regions aren't states or cities - they're more like electorate / local council boundaries (I'm not really sure what the US analogy would be). Most users are going to be uncertain about which region they actually want to save to their user profile.
I have a form which allows users to either (A) explicitly select their region from a select dropdown or (B) enter their postcode, submit the form, and get back their region. This form works fine.
I want users to be able to pick a region at registration time using this form, and have that region saved to their profile. Ideally I'd like to integrate the "select region" form with the user_register form, so that they can submit the form, get told "you are part of X region" and then click "register" and create a new user account with that region.
What I'm doing is using hook_user() to insert my form elements, perform my extra validation and then try to save the region data to the user on submit.
EDIT: the below is roughly how I solved this
function mymodule_user($op, &$edit, &$account, $category = NULL) {
  /* add "select your region" functionality to the user edit form */
  $category = 'Regional information';
  switch ($op) {
    case 'register':
    case 'form':
        /* "register": The user account registration form is about to be displayed. The module should present the form elements it wishes to inject into the form. */
        /* "form": The user account edit form is about to be displayed. The module should present the form elements it wishes to inject into the form. */
        $form = array();
        $form['Regional information']['region'] = _region_select('', _region_select_options());
        $form['Regional information']['postcode'] = _postcode();
        return $form;
        break;
    case 'validate':
        /* "validate": The user account is about to be modified. The module should validate its custom additions to the user object, registering errors as necessary. */
        $region = $account['region'];
        $postcode = $account['postcode'];
        // form_set_error() if I need to
        break;
    case 'insert':
    case 'update':
        /* submit happens *before* the user account is saved - we want insert or update
           "insert": The user account is being added.
           "update": The user account is being changed.
           The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit. */
        $region_code = $edit['region'];
        $postcode = $edit['postcode'];
        if (!$region_code && $postcode) { // pull the region from the postcode
            ...
        }
        if ($region_code) {
            $region_term = taxonomy_get_term($region_code);
            $region_name = $region_term->name;
            /* the profile module wants the name of the region, not the id */
            $profile_edit = array( 'profile_region' => $region_name );
            profile_save_profile($profile_edit, $account, $category);
        }
        break;
  }
}


texts: MSAccess to SQLite install and setup custom content types?

texts: I'm looking for information on how I could use or import a MSAccess database into a SQLite install of Drupal 7. Is this possible or will I have to export the MSAccess tables to CSV or something and then add them to the SQLite db slowly?


texts: What does it mean if expire is set to null in a cache table?

texts:
I am looking at the documentation for the expire field in the cache tables and the documentation in CacheBackendInterface.php says:

@param int $expire
One of the following values:

CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should not be removed unless it is deleted explicitly.
A Unix timestamp: Indicates that the item will be considered invalid after this time, i.e. it will not be returned by get() unless $allow_invalid has been set to TRUE. When the item has expired, it may be permanently deleted by the garbage collector at any time.

When I look in a cache table, for example cache_render, I see that many entries have NULL in the expire column and I noticed it only get clear on a complete cache clear, such as after running drush cr.
What does a null value set for the expire column in a cache table mean?


texts: Web form Report crashes upon adding date field

texts:
I'm using the Webform Report module (version 7.x-1.0) alongside Webform module (7.x-4.16) on Drupal 7.22. When I add Date column to Webform report then save it and view ,Report crashes with message ..website is currently unable to handle this request.HTTP ERROR 500. no matter what format(yyyy/mm/dd..) I enter in date field or leave it empty same happens, If I create report in View by adding all fields including Date fields it works. Also in Webform-Results -Table it works.
Any suggestions..
Also can we in drupal 7 enter date and time both in same textbox so it lands in db in one field or it must be separated as I see drupal has it as separate types?

Thank you,
Nikola


texts:
I would know if it's possible to drop a database table created by a module.
I could see the hook "uninstall" and "disabled" but nothing works.

Can you help me please?


texts: From what directory should "drush cc all" command be run?

texts:
I've always ran drush cc all this way:

 C:\example\sites\all\modules>drush cc all

But can I also run it this way?

 C:\example>drush cc all

Does the second option fully clear the cache and the first one only the modules cache?

I never thought about this, always did it the first way...)


texts: drupal running really slow on apache mac os x

texts:
I'm running drupal sites on my localhost with virtual host.
everything was running perfect but then it suddenly stopped working, I tried to restart apache to fix the error but still not working.
It takes about 30 seconds to load the home page, and about the same for other pages.
I'm running mac os x with Apache MySQL "no MAMP".
thats really confusing me more is that it runs only on firefox, on safari it takes forever and never loads.


texts:
I was planning on using a new domain name when migrating my legacy site to Drupal. I already have the php script that will translate old urls into Drupal Urls (I'm not using pathauto for that).

Now there is a chance I have to keep showing content on the old domain (mainly for SEO purposes). This site won't have any login or write-backs at all, it basically just shows the content and link to the new site.

How would I intercept the 404's that Drupal would now generate, preferably at a very low bootstrap level since there could be tons of invalid requests?

Update:

Sounds like I could use hook_boot() to intercept every page request early and then have the query string parsed and redirected to the matching node/... page on the same site.

Or, similar to Fast404 I could add an include_once to settings.php and do the redirect there:

include_once('.sites/default/modules/myredirect_module/myredirect_module.inc');

Will there be a big difference between those two options?


texts:
I want users to be able to log in (signup) in site with their Facebook or Google plus account. But I didn't find anything for Drupal 8.

Is there any module or solution for doing this job or I should downgrade and use Drupal 7 in our project?


texts: Drupal 7 views add one field as a URL to another

texts:
I am using Drupal 7. I have a view where i filer a certain content type say "A" and display the below 2 fields
  Content: Title
  Content: File attachments

My File attachment formatter is set "Url to file".

What i am trying to achieve is to make 'Title' as a link with the 'File Attachment' URL

Thanks in advance!


texts: How do I create a unified list of referenced users in a multi-entry entity-reference field in a multi-entry field collection field?

texts:
My set up is similar to the setup in this question:
How to integrate Field collection module in Views?
I have a content type with a field collection field (hereafter itineraries) that accepts unlimited entries.  In the field collection is a (user) entity reference field (hereafter travelers) that accepts unlimited values.  It also has another (user) entity reference field (hereafter approvers) separate from the field collection.
I've created a user view, with a contextual filter to select the current logged in user.  This view has a relationship to bring in the nodes that reference the current user via the approvers field.  I have another relationship pulling in the itineraries attached to the node.
What I would like to do is make a field in my view that has a comma separated list of travelers on the node.  I can get the travelers from a single itinerary into a field, but nodes with multiple itineraries result in multiple rows.
I guess the solution must be to somehow embed a view to feed this view, but I'm not sure how to approach that, perhaps that would require an additional module?
Update:  At @no-sssweat's recommendation I tried out the Views Field View module.
I tried a content view, passing the nid and using a relationship to get the field collection items.
With that I was able to get something like this for a node with the two itineraries, the first with two travelers and the second with one:

Travelers:
Person One, Person Two
Person Three

I also tried a field collection item view, with the intention of passing in the field collection item ids as contextual filters.  Testing this in the view itself, I got one traveler per row, but in practice I couldn't figure out a good way to pass id1,id2,id3 to the view. The view with ids input manually looks like this:

Travelers:
Person One
Person Two
Person Three

So in both cases I would get all the travelers listed in one field as the result of the embedded view, but they are listed each in their own divs within the field. I'm trying to figure out how I can get them listed as a comma separated list of values. I want to get to a field that looks like this:

Travelers:
Person One, Person Two, Person Three

Can you help me get over that last hump?


texts:
I want to create a project like http://www.chinatexnet.com/, but before begin writing code I want to ask for advice from the experts.

So, project that I am planning to develope contains just one main website and multiple sub-sites (about 500 subsites). If you look at http://www.chinatexnet.com/, there is one main site and too many subsites with same(simple) structure. The main site has noting its own it just gathers information from subsites. Subsites have defferent look, defferent information but same simple structure.

So what I am thinking is to create two sites, one for main site, the second is just template for subsites. Than create instalation profile by the second site (of course with the data which users inserted) and automate procces with drush. Finally get multisite system.

Is this right way or I need to use contrib modules like Domain Access or Subsites? I've read a lot about multisite system, and I know there can be problems like updating or gathering data to main site. But I can't see another way, so, if anyone has experience with such kind of projects, please, advise me.

P.S.: Sorry for my english :)


texts: Creating custom cron jobs in the same module

texts:
I have Drupal 7 installation with Feed Import module enabled (not the same as Feeds module!). From this module I need to import data from several xml feeds with a different schedule. For example feed A should be imported once a day, but feed B - once a week.

I have done research and suggestions are that Elysia Cron or Ultimate Cron should help to do this. However I can't figure out what needs to be done to actually achieve that different feeds can be imported on different times.

If I take Ultimate Cron case as an example, then using their API ultimate_cron.api.php https://www.drupal.org/project/ultimate_cron I have found following suggestion:

I create a hook in Feed Import module, and define a new cron task (to import feed which is already defined in Feed Import by name "test API feed RAW"). Code looks like this:

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

  $items['test_api_feed_raw_cron'] = array(
    'title' => t('test API feed RAW')
  );

  return $items;
}

However when I go to Cron page in administrative layout and manually execute newly created task, nothing happens. It shows that cron task has been executed successfully, but no data is imported.

It seems that this newly created task is not actually linked with the feed that is defined in Feed Import module. Or that it is not triggering import of that feed.

What am I missing and doing wrong here? I'm not so strong with php and module development, any help will be appreciated.

I have already googled and looked for various solutions, but nothing works. I really feels like I'm missing something very basic and obvious. But of course it could be also opposite and I'm trying to achieve something really complicated..


texts: Drupal 7 list all the nodes that match a specific tag

texts:
is it possible to pass a specific url to Drupal7 that lists all the nodes that has a specific tag? i'm searching for something similar to "?tag=" used by wordpress.

I've already created tags and added the tag field to my nodes

Thanks


texts: How can I programmatically get a list nodes that a user can update?

texts:
I'd like to build a list of nodes which the current user is able to update. This is to be used in a site using Organic Groups.

My first hope was that there would be a Views filter that can check that the content is editable. Alas, no.

My second attempt was to use EFQ:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'suggested_listing')
    ->addMetaData('account', $account)
    ->addMetaData('op', 'update')
    ->addTag('node_access')
    ->pager(20);

would work, but it seems as though OG isn't setting the update column in node_access?


texts: Module stopped working when upgrade to 7.x-3.11

texts:
I have a API that was working before I did the upgrade. It returns JSON, but after upgrade it only shows:

Services Endpoint "my_test" has been setup successfully, and it never gets inside 'access callback' => ‘_my_test_access'...

Can anyone help me please?

My code:

function magmanager_services_resources() {
return array(

    'my_test' => array(
        'create' => array(
            'help' => 'My test',
            'callback' => '_my_test',
            'access callback' => ‘_my_test_access',
            'access arguments' => array('create'),
            'access arguments append' => TRUE,
            'args' => array(
                        array(
                            'name' => 'pid',
                            'type' => 'int',
                            'description' => t('Pid'),
                            'source' => array('data' => 'pid'),
                            'optional' => FALSE,
                        )
                    )
            )),
);
}

function _my_test_access() {

return TRUE;
}

function _my_test(){

$arr = array('a' => '1');
return json_encode($arr);
}

Testing in command line: $  curl -X POST -v -F "pid=44430"  localhost/api/my_test

  POST /api/my_test HTTP/1.1
  User-Agent: curl/7.37.1
  Accept: /
  Content-Length: 143
  Expect: 100-continue
  Content-Type: multipart/form-data; boundary=------------------------03146779a7db0f80

  < HTTP/1.1 100 Continue
  < HTTP/1.1 200 OK
  < Date: Mon, 02 Feb 2015 18:21:27 GMT
  * Server Apache/2.2.16 (Debian) is not blacklisted
  < Server: Apache/2.2.16 (Debian)
  < X-Powered-By: PHP/5.3.3-7+squeeze23
  < Expires: Sun, 19 Nov 1978 05:00:00 GMT
  < Last-Modified: Mon, 02 Feb 2015 18:21:27 +0000
  < Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
  < ETag: "1422901287"
  < Vary: Accept-Encoding
  < Content-Length: 56
  < Content-Type: text/html
  <
  * Connection #0 to host left intact
  Services Endpoint "my_test" has been setup successfully.


texts: Prod CentOS core-only site work fine but local Ubuntu backup has no css loaded

texts:
I made a backup of my prod CentOS site to local Ubuntu. The site is all core --- Both by means of templates or modules; No contribs whatsoever. No customizations.

Yet the CSS won't load for whatever theme.

These are the only errors in drush ws --full

 128377  file      File temporary://filedOb2TA could not be moved/copied because the destination directory public://js is not configured correctly.   notice    http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128376  file      The file permissions could not be set on public://js.                                                                              error     http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128375  file      File temporary://fileEzTm0r could not be moved/copied because the destination directory public://css is not configured correctly.  notice    http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128374  file      The file permissions could not be set on public://css.                                                                             error     http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128373  file      File temporary://fileBagPhj could not be moved/copied because the destination directory public://css is not configured correctly.  notice    http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128372  file      The file permissions could not be set on public://css.                                                                             error     http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128371  file      File temporary://fileII1wDa could not be moved/copied because the destination directory public://css is not configured correctly.  notice    http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128370  file      The file permissions could not be set on public://css.                                                                             error     http://localhost/benia/  127.0.0.1  19/Aug 22:15
 128369  file      File temporary://fileYPV93p could not be moved/copied because the destination directory public://js is not configured correctly.   notice    http://localhost/benia/  127.0.0.1  19/Aug 22:06
 128368  file      The file permissions could not be set on public://js.

Trying to fix it, I made sure that under admin/config/media/file-system the tmp folder is /tmp and then created a directory named tmp folder in root and gave it 755. I also gave 755 to sites/default/files

Tried 777 for both (including sudo chmod 777 files/ -R).
Tried sudo chgrp www-data files -R

While reading on how to fix these in D.O but it wasn't quite clear from what I've read; Most solutions included patches and I don't think its valid for my case. Maybe a Linux expert could shed some light why it happens.


texts: Drupal How to add javascript to ctools modal popup

texts:
I need to hide some element with some condition using jquery inside ctools modal popup in drupal after popup load. I used drupal_add_js but that not work.

Any suggestion?


texts: Download a File Outside of Web Directory

texts:
I have a scenario where certain files are stored outside of the Document Root directory, like this...

/home/user/public_html/{drupal files are in here}
/home/user/data/{special data files are in here}

I would like to allow users with special permissions to download files from /home/user/data using Drupal's built-in file wrapper, but I'm not sure how to link to the files.

Addendum: Most of my files are stored in the usual location:

/home/user/public_html/sites/default/files

It is only some of them I need to store in the external data folder. For security reasons I do not want to change the sites/default/files/ directory to /home/user/data.


texts: This question has been asked before, but a while ago, looking for a fresh opinion. Many more people seem to be using references (perhaps because it's a port from Drupal 6) but the functionality of entity reference seems pretty good. Opinions? Thoughts?


texts: Suppressing APC cache warning messages in watchdog log

texts:
My Drupal-oriented shared webhost recently updated PHP and APC and turned on reporting APC warnings. Now my watchdog log has many, many entries of the form Warning: include() [function.include]: Unable to allocate memory for pool, indicating that sometimes the cache is overflowing.

I know what these warnings mean: that's not my question. The APC cache is 96MB, which is big enough most of the time. But I have 127 enabled modules and certain page loads or doing admin work will overflow the cache. This doesn't occur on every page load by any means, but the warnings are filling up the log, making it hard to find more interesting entries, and causing the log to wrap more often than I'd like. I'm trying to cut down my needed modules but nearly all are there for good reasons.

I cannot change most of the APC settings (I might wish to use apc.filters, for instance).

Is there any module or other method that you know of that will filter messages before they get put in the log? I could make the log bigger, but I still have the problem of finding the wheat in the chaff of warnings.


texts: Make errors also display in proper format and language

texts:
I used webform and Internationalization. It works fine, but when error message are displayed, it shows in partial english and RTL and LTR is mixed up as shown in image.

how do i correct it.


texts: How do I create a sticky navigation bar in Open Social?

texts:
I'm using D8 and working on new theme in Open Social witch uses bootstrap/sass. In my theme I want the navigation bar (in the header region) to be sticky at the top of the screen.
I've made some javascript/sass code but I can't get it to work. This is what I have done so far:

Created a new javascript function in the theme_name.js file:

    //-- Sticky Header
    (function($) {
        Drupal.behaviors.navbar = {
            attach: function (context, settings) {

                var nbar = $('.header');

                if (nbar.length) {
                    var elmHeight = $('.header-top').outerHeight(true);
                    $(window).scroll(function() {

                        var scrolltop = $(window).scrollTop();
                        if (scrolltop > elmHeight) {
                            if (!nbar.hasClass('sticky')) {
                                nbar.addClass('sticky');
                            }

                        } else {
                            nbar.removeClass('sticky');
                        }
                    });
                }
            }
        }
    })();

This is a code snippet from the navbar.scss file:

.navbar-sticky-top {
  @include z-depth-3;
  position: fixed;
  top: 0;
  left: 0;
  z-index: $zindex-navbar-sticky;
}

Code snippet from the index.twig file:

...

This is the content of the region--header.html.twig file:

{% if content %}

      {{ content }}

{% endif %}

What am I missing here?


texts: How to load all contexts of a Panels page?

texts:
The Panels Ajax Tab module is loading panes (minipanel pane) on panel pages via Ajax:

$pane = panels_mini_block_view($name);
echo $pane['content'];

This will get the contexts defined on the minipanel.
What I would like to have is the context that is defined on the host Panel page. I have a working solution for page manager pages, where context is 'static', so there is no argument but everything is fixed. The solution is ugly but works:

inject_panels_page_context($page_name);
$pane = panels_mini_block_view($name);
echo $pane['content'];

function inject_panels_page_context($subtask_id) {
  ctools_include('page', 'page_manager', 'plugins/tasks');
  $page = page_manager_page_load($subtask_id);
  $task = page_manager_get_task($page->task);
  $subtask = page_manager_get_task_subtask($task, $subtask_id);

  // Turn the contexts into a properly keyed array.
  $contexts = array();
  $args = array();
  foreach (func_get_args() as $count => $arg) {
    if (is_object($arg) && get_class($arg) == 'ctools_context') {
      $contexts[$arg->id] = $arg;
      $args[] = $arg->original_argument;
    }
    else if ($count) {
      $args[] = $arg;
    }
  }

  $count = 0;
  $names = page_manager_page_get_named_arguments($page->path);
  $bits = explode('/', $page->path);

  if ($page->arguments) {
    foreach ($page->arguments as $name => $argument) {
      // Optional arguments must be converted to contexts too, if they exist.
      if ($bits[$names[$name]][0] == '!') {
        ctools_include('context');
        $argument['keyword'] = $name;
        if (isset($args[$count])) {
          // Hack: use a special argument config variable to learn if we need
          // to use menu_tail style behavior:
          if (empty($argument['settings']['use_tail'])) {
            $value = $args[$count];
          }
          else {
            $value = implode('/', array_slice($args, $count));
          }

          $context = ctools_context_get_context_from_argument($argument, $value);
        }
        else {
          // make sure there is a placeholder context for missing optional contexts.
          $context = ctools_context_get_context_from_argument($argument, NULL, TRUE);
          // Force the title to blank for replacements
        }
        if ($context) {
          $contexts[$context->id] = $context;
        }
      }
      $count++;
    }
  }

  ctools_include('context-task-handler');
  ctools_include('context');

  $handlers = page_manager_load_sorted_handlers($task, $subtask ? $subtask['name'] : '', TRUE);
  $handler = $handlers['page_' . $subtask_id . '_panel_context'];
  $contexts_all = ctools_context_handler_get_handler_contexts($contexts, $handler);

  $current_page_ = page_manager_get_current_page();
  $current_page_['contexts'] = $contexts_all;
  page_manager_get_current_page($current_page_);
}

But this is still not collecting context that is using arguments, such as the current node (on the node_view panels page) or current user account (on user_view page). Those arguments are defined in ctools/page_manager/plugins/tasks - each of them separately.

What would be the preferred way of collecting all contexts, including, contexts with arguments and added contexts? Is there a cache that could be used?


texts: Embedded field collection not saving with node using conditional fields

texts:
Why is the field collection portion of my node form not saving?  I am working on a form that collects travel plans from staff members.  As part of this I have a nested field collection to collect itineraries and legs within those itineraries.

to give you a rough description of the related fields:

This is not all the fields on the form, but this should give the idea of the structure.  I fill out the form, save, and the saved node contains all the other information, but nothing that was in the field collections shows up.

Since country is an additional module, I tried deleting the country field, but that didn't solve anything.  I'm also using the conditional fields module extensively to show and hide other fields though the fields in the field collection are not affected by this.

Finally I'm using a custom module called missions (UPDATE:  I've disabled the module, and the problem persists, so it seems not to have been the form_alter) to show one field in the field_mr_fc_legs field collection when field_mr_home_leave is checked.  The entire code of which can be found below:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function missions_form_mission_request_node_form_alter(&$form, &$form_state, $form_id)
{
  $form['body'][LANGUAGE_NONE][0] += array(
    '#placeholder' => t('Day 1

*  Activity 1
*  Activity 2

Day 2'),
  );
  $form['field_mr_home_leave'][LANGUAGE_NONE]['#ajax'] = array(
    'callback' => 'missions_hide_home_leave_toggle',
    'wrapper' => 'itinerary-section',
  );
  $form['field_mr_fc_itineraries']['#prefix'] = '
';
  $form['field_mr_fc_itineraries']['#suffix'] = '
';
  if ((!empty($form_state['complete form']['field_mr_home_leave']['und']['#value']) && $form_state['complete form']['field_mr_home_leave']['und']['#value'] == 1) || (empty($form_state['values']['field_mr_home_leave']) && $form['field_mr_home_leave'][LANGUAGE_NONE]['#default_value'] == 1)) {
    $home_leave_toggle_access = true;
  } else {
    $home_leave_toggle_access = false;
  }
  foreach ($form['field_mr_fc_itineraries'][LANGUAGE_NONE] as $key => &$itinerary) {
    if (is_integer($key)) {
      foreach ($itinerary['field_mr_fc_legs'][LANGUAGE_NONE] as $key => &$leg) {
        if (is_integer($key)) {
          $leg['field_mr_fc_leg_home_leave']['#access'] = $home_leave_toggle_access;
        }
      }
    }
  }

}

function missions_hide_home_leave_toggle($form, $form_state) {
  return $form['field_mr_fc_itineraries'];
}

What is the likely cause of this?  The Recent log messages report shows just that the node was updated.  Is it my module?  Is it nested field collections?

What I've tried

I disabled my module, and it didn't make a difference
I removed the nested field collection and it didn't make a difference.
I removed the country field to verify that it wasn't the country module causing the issue.
The issue seems to be caused by conditional fields, when I disable that, the form saves properly.


texts:
I'm working on my very first drupal website and it will consist of a login form which will then give the user access to a form. This next form will allow the user to query my database to show the closest matches in the category they search - and when they select one they will able to fill in some details on another form, attach some files and then send the information via email.

Security is the most important factor here as the information is all confidential. Can you help me work out what plugins/modules I should be looking at to make my system most secure. And what possible security problems I need to be aware of?

[Note: I have used cmsmatrix.org to compare what the CMS can do and one thing I've noticed is for Drupal it says it can't do things like ssl logins or ssl pages. So should I even be using Drupal in that case?]


texts: How to delete lines from a table created by a custom module?

texts:
I'm working on a custom module that has an admin form designed to contain a number of values.
age 21 => value, age 22 => value, etc.

The issue I'm having is that while I can add information to the table I've created through my form, I'm only supposed to have 1 possible value per age.
I dont know how to delete the old value before the new one is added.

This is what I have that adds info to my table successfully:

/**
* Saving Score administration settings and DB information
*/
function savingsscore_admin_form() {
  $form = array();
$form['savings_ages'] = array(
  '#type' => 'fieldset',
  '#title' => t('Saving Ages'),
  '#weight' => -1,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  '#description' => t('Description of fields in this fieldset here'),
);
$form['savings_ages']['saving_age21'] = array(
'#type' => 'textfield',
'#title' => t('21'),
'#size' => 10,
'#maxlength' => 10,
'#default_value' => '10.85',
);
  return $form;
}

/**
* Handle submission of Admin forms
*/
function savingsscore_admin_form_submit($form, &$form_state) {
db_query("INSERT INTO {savingfactors} (saving_age21)
VALUES ('%s')",
  $form_state['values']['saving_age21']);

drupal_set_message(t('Your form has been saved.'));
}

I know that what happens next should start like:

 db_query("DELETE FROM

But I dont know what I should add next, I'm uncertain of the syntax.
Any help or links to documentation would be much appreciated

Thanks
Stephanie


texts: How do I load information for views programmatically?

texts: I have a view for a blog page that has the basic fields associated such as title, body, post-date, image, and author. What I need is a way to get access to the fields of the view to show on parts of the site with out creating a page or block. I just need the view to organize my information and will be using jQuery to parse the data.


texts: Drupal commerce: how to force user to pay with specific payment method?

texts:
I Have written a shipping method (name:X) and a payment method(name:Y) for drupal commerce. the problem is that I want to force user to pay with Y if he selects X and I want to disable other payment methods on this condition.

it can manually be done with rules! but I want to programmatically add this limit.
how can I do it? is there a hook or something else?


texts: How to change user field value after node form is submitted?

texts:
I currently have a user field called field_reputation with a default integer value of 0 (if a user registeres).

The idea is that this field increases when certain actions are executed. For example, when a user publishes a new article, field_reputation should be its current value + 10.

I am trying to achieve this using a form hook:

function MYTHEME_form_alter( &$form, &$form_state, $form_id ) {
  if ( TRUE === in_array( $form_id, array( 'node_article_form') ) ) {
    foreach (array_keys($form['actions']) as $action) {
        if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
          $form['actions'][$action]['#submit'][] = '_increase_reputation';
        }
      }
}

And then this function is called:

function _increase_reputation(array &$form, FormStateInterface $form_state) {
  // Do something here
}

However I can't seem to figure out what code should be written in this function.


texts: Expose filter with collabsible div on click in a Calendar

texts:
I have created a calendar showing Events in different cities.The City names are taken as Taxonomy and are displayed as a filter.On selecting a Particular city the Calendar shows all the events of that particular city in that month.I want the number of events in that particular city in the filter next to the city name.On clicking the City name in filter it should display the event details under it. Eg.If Atlanta have 4 events and Chicago have 1 event London doesnt have any event in July it should be displayed as

Atlanta(4)
Chicago(1)
London(0)

for that particular month. On clicking the City the display is like-

Atlanta

Event1
Event2
Event3

Chicago(2)

London(0)

ALong with calendar filtering and showing only Events related to Atlanta.

How to get this Functionality please help.


texts:
I'm trying to add JS to content create pages using the second function from @kiamlaluno's answer

However, this is not working for me.

I created a module with his folder structure:

add_js
  add_js.info
  add_js.module
  custom.js

add_js.info:

name = Add JS to admin pages
description = Add js to admin pages
core = 7.x

add_js.module:

<?php

    function add_js_init() {
      if (arg(0) == 'admin') {
        $path = drupal_get_path('module', 'add_js');
        drupal_add_js($path . '/custom.js');
      }
    }

custom.js:

jQuery(document).ready(function ($) {
    $("html").addClass("hello");
});

Also tried this .module file:

<?php

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'my_form':
      $form['#after_build'][] = 'mymodule_after_build';
      break;
  }
}

function mymodule_after_build($form, &$form_state) {
  $path = drupal_get_path('module', 'mymodule');
  drupal_add_js ("$path/mymodule.js");
  return $form;
}

Although I am pretty inexperienced still, I did remember to enable the module and flush the caches... :D


texts:
I have set up a menu with a list of menu titles which is working fine. But as I want to style the link li with a background-color and rounded corners, I need to be able to manually insert a break in longer length menu titles, rather than rely on the width controlling the line break automatically.

From what I've been able to glean from searching online, there is some way to do this by modifying a copy of a template file from core into my theme, but I'm not sure how to do this or if there is a simpler way.

Using Drupal 7.


texts: Print out a Drupal Commerce field only if it has a value

texts:
In Drupal Commerce, you can use the following to print out a field in your node.tpl.php file:

<?php print render($content['product:field_NAME']); ?>

See here fore more information

But how do you print a field only if it has content?

For a normal Drupal field you would use the following:

<?php if (isset ($node->field_NAME)): ?>
  <?php print $node->field_NAME['und'][0]['safe_value'];?>
<?php endif; ?>

But that doesn't work with a Drupal commerce field.

I would appreciate if someone could offer any pointers!


texts: How to see changes inside Paragraphs or Field Collections with Diff

texts:
I have read and checked that Paragraphs and Field Collections revisions are tracked. But when I make a change to the node and then look at the Revisions tab, no changes done with fields inside Paragraphs or FC are displayed. Does Diff support display of those changes? If yes, how can I see them?

Things I checked:

Enable the Revisions page for this content type is checked.
Standard comparison preview is Full Content and it has paragraphs field displayed.
Diff module is installed and enabled.
On page admin/config/content/diff/fields in Global settings for Paragraphs Markdown callback is set to "Drupal HTML to text", as well as for those field types that are inside paragraph.

I can see field changes for my content type, but the comparison page does not show changes for fields that are inside paragraph.
What is missing?


texts: extract list of user id's from views to tag a content automatic

texts:
I want to extract a list of users id's from views to automatic tag the user generated content.

The function is important because a company should be able to make a list of users receiving their ads. These ads are a defined content type they are able to make and it would be great if these user id's could be tagged automatically. This is the only way (as I see it) I am able to control which users are exposed to these ads, because in most instances its only part of a group that should be exposed to it.

Can anyone help me with making this functionality, either in code or through modules I do not know about.


texts: Drupal 8: Multi-sites in subdirectories not working

texts:
I followed this tutorial(Drupal 7) but it not worked for me(Drupal 8):

Multi-site in subdirectories
https://www.drupal.org/docs/7/multisite-drupal/multi-site-in-subdirectories

This is my enviroment:

CentOs 7 with SELinux(mode: enforcing)
Varnish 4.0.3
Apache 2.4.23
Drupal 8.2.4

I need to create the next structure of sites:

/          <-- First site
/site2     <-- Second site
/site3     <-- Third site

In the file sites/sites.php i have:

$sites['localhost.site2'] = 'site2';
$sites['localhost.site3'] = 'site3';

In the directory sites/ i have:

default/
site2.localhost
site3.localhost

In the root of the drupal o have the next symlinks to .:

site2 -> .
site3 -> .

In my .htaccess file i have:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/site2/(.*)$
  RewriteRule ^(.*)$ /site2/index.php [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/site3/(.*)$
  RewriteRule ^(.*)$ /site3/index.php [L,QSA]

When i tried to access to each subsite, he shows me the default. What is wrong?