texts: How to programmatically uncheck 'Generate automatic URL alias' option for all nodes

texts:
I've created some nodes programmatically and set the path alias. But when I then go into edit the node the 'Generate automatic URL alias' option is still checked, even though my alias is shown in the 'URL alias' textfield underneath, so consequently gets overwritten on save.

Also, when editing the node using the Entity module and entity_metadata_wrapper(), the alias is generated again and my alias is overwritten because of this problem.

When I load a node using node_load() I expect to see $node->path['pathauto'] but I don't, so I can't seem to disable it this way. Anyone have any advice?


texts: Unable to see page context in cache context

texts:
I created a page using Page Manager with Layout Builder. I created a path called: /my-account/{agent_number} witch allows me to create the agent_number string context.  I created my own custom block and able to get the agent_number like this:

$this->getContextValue('agent_number');

Now I build my block and would like to use contexts to cache my block:

/**
 * {@inheritdoc}
 */
public function build() {
  $data = get_expensive_data($this->getContextValue('agent_number'));
  return [
    '#theme' => 'my_custom_module',
    '#data' => $data,
    '#cache' => [
      'contexts' => ['agent_number'],
      'max-age' => 86400,
    ],
  ];
}

I created my own CacheContext service:

<?php

namespace Drupal\earc_card_details\Cache\Context;

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\Context\CacheContextInterface;
use Drupal\Core\Plugin\Context\ContextRepositoryInterface;

/**
 * Defines the AgentNumberCacheContext service, for caching.
 *
 * Cache context ID: 'agent_number'.
 *
 * @see \Drupal\Core\Session\AccountProxy::setAccount()
 */
class AgentNumberCacheContext implements CacheContextInterface {

  /**
   * The context repository service.
   *
   * @var \Drupal\Core\Plugin\Context\ContextRepositoryInterface
   */
  protected $contextRepository;

  /**
   * Creates LanguageInterfaceContext object.
   *
   * @param \Drupal\Core\Plugin\Context\ContextRepositoryInterface $context_repository
   *   The context repository service.
   */
  public function __construct(ContextRepositoryInterface $context_repository) {
    $this->contextRepository = $context_repository;
  }

  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t("Agent Number");
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
     $contexts = $this->contextRepository->getAvailableContexts();
     // Agent number is missing here.
     return $contexts['agent_number'] ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }

}

The problem is that $this->contextRepository->getAvailableContexts() does not return the agent_number context.  Is there a way to get the page bulder context to appear here?


texts: Get node field image in " hook_node insert "

texts:
I'm getting the values of the node that I'm about to create with my custom module and the function " hook_node_insert " but I'm not receiving the data of my image like the path and name.

I'm just getting the fid, is that useful?

Is there any other method to get the data?

Thanks guys !


texts:
I've set-up a Drupal Commerce website. Clients add products in the backend and give each product a price INCLUDING taxes (in this case €160,00). The product fiches on the product page should show the products with taxes. In the shopping-cart block (in the sidebar) as well.

However, on the check-out pages, the line items should be shown WITHOUT taxes (€126,40 in this case). The taxes should only be added in the block on the bottom...

I hope I make myself clear with this picture:

Does anyone have an idea on how to do this? Because I don't :)


texts:
What is the difference between watchdog Location and watchdog Referrer in dblog messages?

An easy example to see the difference would be nice, for example on the node creation/edit they are the same.In which case these two URLs will be different?


texts: Drupal 7 page layout suggestions-separate layout for each page

texts:
I need to create some layout for each pages.Suppose i have a page called "our dishes" and i need a different page layout for it.I need different layouts for all the pages like Guest book,Photo gallery careers etc.

How can i achieve this.I have a content type called 'ourdishes'.I heard that page--content_type_name.tpl.php is useful for this.So i created page--ourdishes.tpl.php page in theme folder.
i cleared the cache .But i don't know how to get the layout to the specific page.I have a menu item called 'our dishes' and when i click on that menu the default page.tpl.php layout is loading....

could you please provide the exact method for this?

So how can i inform the Drupal system about this new page .How will Drupal identify this theme for the page 'our dishes' ? How can i suggest it in template.php file?

Also if i have no such content type and i using the basic page for 'our dishes',how can i implement it?

thanks in advance,

Hari.


texts: How to open a link in ctools modal by clicking a views row in table format?

texts:
I want to open a page in ctools modal. This works for me.

Click

But now I want to open the same page in ctools modal by clicking the views row. The views is in table format.

It opens the link but not in ctools modal. I am using bootstrap theme.

I noticed that after page load there is another class added to the anchor tag ctools-use-modal-processed which is not added to the table row.

And we can't use an anchor tag before or after the tr in html table. We can only use it inside a td.

How can I achieve this?


texts: How to add page restrictions for blocks in drupal?

texts:
I'm using the drupal administrator menu for the settings
there i have a page called /desert/234234
the block should appear only when the url is /desert/(desert_id)
how can i restrict that


texts: How to attach a module to a drupal article?

texts: I have a php function in a drupal module. This function outputs some random text. I want to attach this module to a Drupal article so that each time someone creates an article, random text will appear in it. How can I do this?


texts:
I have on my site "Notification on comment"
How can I disable notifications in a case that I post to myself?

Thanks
Tzvika


texts: How to hide a block or text if user can edit node?

texts:
In a block there's a flag where users can ask for permission to edit the node. The admin gets a mail when the node is flagged. Admin can grant acces with node-acces to a particular user. This part is working.

However, when the user can edit the node, this block (or snippet; could use if else statement) should be hidden. I'm looking for (and can't find it) a snippet like

if user can edit
    {'you can edit'}
else
    {show flag}

How should I do the first part?


texts:
Sorry for being a little bit impudent, bit i would need someone to build an array into a code snippet. As I know nearly nothing about php coding, I managed to adept some code I found to get the urls of video files stored in field collection fields (one is for the .mp4 movie, otherone for the .webm version). So far, the code works well, but - here comes the problem - there is only the first value of each field collection field displayed. So, I Think i would need an array to regenerate the div container containing the  tag with the source paths for each value of the field collection, not only for the first one. I anybody can help me, I would be very, very thankful.... i am working on this since more than 6 hours now...

here is my code:

// get node object
$node = node_load($nid);

// get field collections from node
$field_html_5_video = field_get_items('node', $node, 'field_html_5_video');

// get all fields values if collection exists
if (!empty($field_html_5_video)){
    $field = field_view_value('node',$node, 'field_html_5_video', $field_html_5_video[0]);
    foreach ($field['entity']['field_collection_item'] as $id => $field_collection){

        // load the field collection item entity
        $field_collection_item = field_collection_item_load($id);
        // wrap the entity and make it easier to get the values of fields
        $field_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);

        // all values from the field collection
        $field_video_mp4        = $field_wrapper->field_video_mp4->value();
        $field_video_webm        = $field_wrapper->field_video_webm->value(); // an array of image data
        $field_video_description  = $field_wrapper->field_video_description->value();

        // getting the video urls
        $video_url_mp4          = $field_video_mp4['uri'] ? file_create_url($field_video_mp4['uri']) : '';
        $video_url_webm          = $field_video_webm['uri'] ? file_create_url($field_video_webm['uri']) : '';

        print '
';
        print '';
        print '';
        print '<video width="100%" controls>';
        print '<source src="' .$video_url_mp4. '" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\'>';
        print '<source src="' .$video_url_webm. '" type=\'video/webm; codecs="vp8, vorbis"\'>';

        print '</video>';
        print '';
        print '' .$field_video_description. '';
        print '
';
    }
}


texts: Using taxonomy exposed filter in a view ends in MySQL can only use 61 tables in a join

texts:
Scenario

One hierarchical vocabulary called Countries with 300 taxonomy terms, one for each country, indenting like:

America (level 1)

Anguila (level 2)

Antigua y barbuda (level 2)

... (level 2)

Europe (level 1)

Austria (level 2)

Armenia (level 2)

... (level 2)

One content type called Office, then you add a field called Country, and its type is taxonomy reference, related to you recent created vocabulary called Countries.
After that, you create a few nodes: the first is called 'My secret office', checking Afghanistan in its country field. The second node is called 'My beautiful office', checking Albania.

Now you think it should be interesting if you could have a page where you can see a list of all your offices. The finest way to achieve this is by creating a view. To do so, you create a view page with this configuration:

Filter criteria: Content: Content type (= Office)
Page settings: Path: /offices

Then you visit your new page /offices and you can see 2 offices: My secret office and My beautiful office. Everything works as expected.

Then you add a country filter in you page. Going back to views configuration:

Filter criteria: Content: Has taxonomy term (exposed, Show as hierarchical) related to Countries.

You return to visit your page, and you can see a filter listing 300 countries and your 2 offices. You are on fire, so you decide to test your brand new filter:

You check Afghanistan option, and click Search; then you only see My secret office. Great.
You check Albania option, and click Search; then you only see My beautiful office. Awesome.
You now check Afghanistan, Albania, Algeria, Andorra, Angola and so on until you have checked all your 300 countries. The correct output should be your 2 offices, since you have no more; so you click search and BAAAM: White Screen of Death. But you are smart, and you have allowed PHP yo show the error log. You see that MySQL had a failure:

SQLSTATE[HY000]: General error: 1116 Too many tables; MySQL can only use 61 tables in a join

It follows the entire query Drupal is trying to execute. You notice everything is fine EXCEPT for this:

LEFT JOIN {taxonomy_index} taxonomy_index_value_0 ON node_field_data.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_0.tid = :views_join_condition_1

LEFT JOIN {taxonomy_index} taxonomy_index_value_1 ON node_field_data.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_1.tid = :views_join_condition_2

LEFT JOIN {taxonomy_index} taxonomy_index_value_2 ON node_field_data.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_2.tid = :views_join_condition_3

LEFT JOIN {taxonomy_index} taxonomy_index_value_3 ON node_field_data.nid = taxonomy_index_value_0.nid AND taxonomy_index_value_4.tid = :views_join_condition_4

and so on. Drupal is using the left join technique to access the database. The problem is that Drupal is using one left join for each taxonomy termed checked, meaning the first one is related to Afghanistan, the second one to Albania, the third is for Algeria, and so on.

¿How can I make a search using more than 61 options?

I think it is not a crazy thing that an user could search for offices in America and Europe, resulting this in more than 100 countries being checked. While looking for a solution, I have wrote a litle Javascript code that prevents the user from marking more than 50 countries so he doesn't face the WSoD.

Setup:

Drupal 8.8.1 (core and all its modules updated)
I'm not using any contributed module related to taxonomy or views
PHP 7.1
MySQL 5.5


texts: Ideas on how to create a multi-part form, where the form requires completion/approval by another user

texts:
Desired form submission workflow:

User A fills out a form, along with an email address for User B
User A submits the form, which then notifies User B by email of a request to complete and approve the form
User B clicks a link in the notification email and is able to complete (and approve) User A's submission

User B would actually be adding extra data to the form, not just "approving" it.

What are your ideas for ways to accomplish such a multi-part form? Are there any modules (besides webform) that could assist with this type of form logic? Would you base this on webform, or Drupal 7's forms API?


texts:
I have an array like the following.

$form["something"]["something"] = array(
  0 => array( "#markup" => "line 0" ),
  1 => array( "#markup" => "line 1" ),
  2 => array( "#markup" => "line 2" ),
);

When rendering it in the theme function with drupal_render($form["something"]["something"]), I get only the first line.

  line 0

When I try to use foreach, this somehow does not return anything.

So what am I doing wrong? Should I modify an array itself and add some wrapper element? I would prefer to render it all with one line, without foreach.


texts: Is there a way to clone a feature in Drupal/Open Atrium?

texts: I want to create a clone of the Notebook feature and would like to do it without copying the files and doing a find/replace on the text. Is there an easy/built-in way to clone a feature and provide it with a new name?


texts: How can i give link in block for only listed paths based on user id?

texts:
I have created block and i want to give the only listed paths

i.e user/user_id   ex: user/123

i have given user/*  but it displays all pages where users pages are there.

i tried below ways

and enabled PHPFILTER and tried this


texts: Node values not retrieving properly in .theme and Twig files

texts:
I created a content type and have a couple of fields: a heading, links, and images.
After creating a node out that content type, I want to pull parts of the node into my homepage. And for that, I used the following in my .themename.theme.

use Drupal\node\Entity\Node;

function amarula_preprocess_page(&$variables) {

    $nid = 62;
    $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);

    $variables['field_vanilla_heading'] = $node->field_vanilla_heading->value;
    $variables['field_vanilla_main_content'] = $node->field_vanilla_main_content->value;
    $variables['field_vanilla_home_link'] = $node->field_vanilla_home_link->value;
    $variables['field_vanilla_home_thumbnail'] = $node->field_vanilla_home_thumbnail->value;
}

I get the value of the field_vanilla_heading in my page--front.html.twig

<h1>{{ field_vanilla_heading }}</h1>

But, the rest of the fields are giving problems.

For the main content {{ field_vanilla_main_content }}, which is long text with summary, I am seeing all the HTML in the page. How can I escape this in twig?

For the rest of the fields, kint tells me that they are null, which is not true:

{{ kint(field_vanilla_home_link) }}
{{ kint(field_vanilla_home_thumbnail) }}

Below is the list of all the field settings:

I can already get the node ID. But how can I get all the values of the node accordingly?


texts: Translate an SQL update query into Drupal language

texts:
I need to convert the following query that works against a database table

"UPDATE MYTABLE SET field_temp= %s", UNIX_TIMESTAMP(field);

into Drupal language

db_update('MYTABLE')
      ->fields(array(
          'field_temp' => UNIX_TIMESTAMP('field'), //or strtotime()
         ))
        ->execute();

seems to be not working.

UPDATE

db_update('MYTABLE')
        ->expression('field_temp',  "UNIX_TIMESTAMP('field')"),
        ->execute();

will run into:

PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value:

Some more details:

'field' is datetime format type, field_type is 'int' format type
I am running this script through a hook_update_N
I am debugging it by running update.php


texts: Ordering results for form autocomplete fields

texts:
I've done the cursory googling, but so far I haven't found anything close to an answer for this.
I'm using the Masquerade module with a custom module on top to extend it and make its searching algorithms a bit more "clever" (Soundexes, custom fields and such), and it returns the results in a certain order, passed through to drupal_json_output(). However, because JSON isn't exactly indexed, it means that when the autocomplete text field picks it up, it's in a slightly screwy order based on its keys (which are the users' usernames). I can forcibly send a array_values() to the JSON output, but it breaks Masquerade's functionality as it requires the username to be the key. I'd imagine this would be a problem with other autocompletion stuff in Drupal that uses JSON loads.
Can anyone suggest a way of doing this please? I'm not sure whether it's a matter of Masquerade or of D7's textfield autocompletion.
Thanks


texts: How to create multi level subgroups in organic groups?

texts:
I Need to create multi level of subgroups in organic groups like

like a tree. I don't know how to create using organic groups. Can anyone suggest.


texts:
I have developed a multi-lingual site with i18n module (7.x-1.13) and everything works as expected.My Drupal version is 7.34.

Recently, my client have asked not to translate the number. The website works in English and Arabic.

To be more specific, when Arabic is chosen, we do not want the numbers to be displayed in Arabic, instead we need to display the same in English. Now, each numbers are translated to Arabic when the language is chosen as Arabic, even the user input.

The default language is Arabic and I haven't installed any modules for translation of numbers.

Any help would be much appreciated.


texts: Simple Drupal page loads very slowly; slow 'DrupalDatabaseCache::getMultiple' query

texts:
I've installed Drupal (and CiviCRM within Drupal) on shared hosting my group's host assures me is adequate (though they refuse to enable PHP caching like APC on it). It's generally far slower than my installs on other servers or my home Mac. Even the simple, completely default Drupal front page (which just shows one promoted story, the only extra blocks being from the Devel module) loads slowly. Just now it took a minute, and the Devel block reported the following slow queries. Any help solving or at least diagnosing the problem very welcome!

  ms | # | where | ops | query | target

  41.05 | 21 | DrupalDatabaseCache::getMultiple | P A E |
  SELECT cid, data, created, expire, serialized FROM drupal_cache_menu WHERE cid IN (:cids_0)
  default

  32.97 | 21 | DrupalDatabaseCache::getMultiple | P A E |
  SELECT cid, data, created, expire, serialized FROM drupal_cache_menu WHERE cid IN (:cids_0)
  default

  28.13 | 21 | DrupalDatabaseCache::getMultiple | P A E |
  SELECT cid, data, created, expire, serialized FROM drupal_cache_menu WHERE cid IN (:cids_0)
  default


texts: Drupal Commerce - Database location of Shipping information

texts:
I am attempting to migrate the data located on the /admin/commerce/orders page of Drupal Commerce to a custom website that I have created. I am trying to use phpMyAdmin to locate and export any relevant database information in the Drupal database. I have found that the order id/email/timestamp are located in the commerce_order table in the Drupal database. However, I can't find the location (table/table column) of the user's name and shipping information.

Does anyone have an idea of where I could find this information?

I am currently using Drupal 7.53 and Drupal Commerce 7.x-1.13.


texts: How to make Drupal 6 search result URL have ".html" at the end?

texts:
I want the search result URL become

http://www.site.com/search/node/Search for something.html
http://www.site.com/search/node/cars.html

I've looked into custom_url_rewrite_outbound() but there is not much I can understand


texts:
I honestly did, what this and this tutorial told me, but somehow my autocomplete textfields still fire an ajax error. but to be more specific: the ajax error gives a 200 http response and a status OK, but no answer-text.

my setup is:

$form['field_new_verein_location_'.$i] = array(
    '#type' => 'textfield',
    '#title' => t('Neuer Verein Ort'),
    '#default_value' => '',
    '#size' => 60,
    '#maxlength' => 128,
    '#required' => TRUE,
    '#description' => t('description'),
    '#autocomplete_path' => 'dsregion/autocomplete'
);

function ds_regions_menu(){
    $items['dsregion/autocomplete']=array(
      'title' => 'location auto complete',
      'page callback' => '_dsregion/autocomplete',
      'access arguments' => array('access region autocomplete'),
      'type' => MENU_CALLBACK
    );
    return $items;
}

function _dsregion_autocomplete($string) {
    $matches = array();
    $result = db_select('ds_plz_ort','o')
      ->fields('o',array('ort'))
      ->condition('ort','%'.db_like($string).'%','LIKE')
      ->range(0,10)
      ->execute()
      ->fetchAllKeyed();

    foreach($result as $row){
      $matches[$row->ort]=check_plain($row->ort);
    }
  drupal_json_output($matches);
}


texts: How to access date value from a datelist form element for validation?

texts:
I have a simple form element using datelist as the type. I need to validate this to make sure the date is in the future. But I cannot work out how to access the date itself in the validation method.

Form:

public function buildForm(array $form, FormStateInterface $form_state) {

  $form['date_field'] = array(
    '#title' => $this->t('Expiry'),
    '#type' => 'datelist',
    '#date_part_order' => array('month', 'year'),
    '#date_year_range' => '2017:2027',
    '#date_increment' => 1
  );

  return $form;
}

Validation:

public function validateForm(array &$form, FormStateInterface $form_state) {

  $date_input = $form_state->getValue('date_field');

  if(strtotime(date($date_input)) < strtotime(date('now'))) {
    $form_state->setErrorByName('date_field', $this->t('The date must be in the future.'));
  }
}

From the above, $date_input currently returns an object (see below). Essentially, I want to access $date_input->dateTimeObject->date; but doing exactly that will return a fatal error.

  Fatal error: Cannot access protected property
  Drupal\Core\Datetime\DrupalDateTime::$dateTimeObject

$date_input object:

stdClass Object
(
    [__CLASS__] => Drupal\Core\Datetime\DrupalDateTime
    [formatTranslationCache] =>
    [dateParts] => Array
        (
            [0] => year
            [1] => month
            [2] => day
            [3] => hour
            [4] => minute
            [5] => second
        )

    [inputTimeRaw] =>
    [inputTimeAdjusted] =>
    [inputTimeZoneRaw] =>
    [inputTimeZoneAdjusted] =>
    [inputFormatRaw] =>
    [inputFormatAdjusted] =>
    [langcode] => en
    [errors] => Array
        (
        )

    [dateTimeObject] => stdClass Object
        (
            [__CLASS__] => DateTime
            [date] => 2027-12-01T00:00:00+11:00
            [timezone] => Australia/Sydney
        )

    [stringTranslation] =>
)

I could do something like:

$form_state->getValue('date_field')->format('d m Y');

But I suspect there is a better way?


texts: How to make my Drupal custome Service return data on GET?

texts:
I have defined few Drupal custom Services and they are working fine
via POST requests. But one of them needs to be available via GET.

This one:

function rooms_services_services_resources() {
    return array(
        'api' => array(
            'actions' => array(
                'hotel_inventory' => array(
                    'help' => 'Inventory of all Hotels',
                    'callback' => 'rooms_services_hotel_inventory',
                    'access callback' => 'rooms_services_access_callback',
                    'access arguments append' => false,
                    'args' => array(
                        array(
                            'name' => 'params',
                            'optional' => true,
                            'source' => 'param',
                            'type' => 'struct',
                            'description' => 'all passed URL parameters'
                        ),
                    ),
                ),
            ),
        ),
    );
}

It's working fine when I am making a request via POST with headers:

`Content-Type: application/x-www-form-urlencoded`

or

`Content-Type: application/json`

as those I have enabled in my REST Server...

How do I make it work via simple GET request ?


texts:
This following is my php library location:

sites/all/libraries/Baidu-Push-SDK-Php

I try to implement  hook_libraries_info():

/**
 * Implementation of hook_libraries_info().
 */

function baidu_push_services_libraries_info() {
  $libraries = array();

  $libraries['Baidu-Push-SDK-Php'] = array(
      'name' => 'Baidu Push SDK',
      'vendor url' => 'http://developer.baidu.com/',
      'download url' => 'http://developer.baidu.com/',
      'version arguments' => array(
        'file' => 'change_log',
        'pattern' => '([0-9\.]+)',
        'lines' => 14,
      ),
      'files' => array(
        'php' => array(
          'Channel.class.php',
        ),
      ),
    );

  return $libraries;
}

Then I try to load my library:

$baidu_push = libraries_load("Baidu-Push-SDK-Php");

But It show me:

The BaiduPushSDK library could not be found.


texts: Multiple submit buttons: Which one was pressed?

texts:
This may be a duplicate of the following: Multiple form submit, but I am unable to figure out how the answer applies to my situation.  So here is my go at asking this (I admit) quite similar question:

I have a table with a row of data, each row has a submit button.  It may look something like this:

$form['f'] = array();
foreach ($rows as $row) {
  $form['f'][$row['nid']] = array();
  $form['f'][$row['nid']]['nid'] = array(
    '#markup' => $row['nid'],
  );
  $form['f'][$row['nid']]['submit'] = array(
    '#type' => 'submit',
    '#value' => t('sumbit'),
    '#submit' =>  array('f_submit'),
  );
}

I.e. the form consists of a sequence of rows, extracted from the database,  I want to create a submit callback that picks up the value of the corresponding nid field and prints out its value.   I guess I am asking what to put where the comment below is.

function f_submit($form, &$form_state) {
  // Here I want to print the value of the relevant nid field
}


texts:
I use drupal commerce, I want if user info update if there is exist shipping profile update it else create new.

function mymodule_user_update(&$edit, $account, $category){
    $def_id=commerce_addressbook_get_default_profile_id($account->uid,'shipping');
    if($def_id){
       $profile=commerce_customer_profile_load($def_id);
       }
    else{
         $profile = commerce_customer_profile_new('shipping', $account->uid);
    }
        // Add the address value.
        $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
        $profile_wrapper->phone_mobile=$edit['field_mobile']['und'][0]['value'];;
        $profile_wrapper->phone_home=$edit['field_telephone']['und'][0]['value'];
        $profile_wrapper->field_user_addres = array_merge(addressfield_default_values(), array(
        'country' => $edit['field_user_addres']['und'][0]['country'],
        'thoroughfare' => $edit['field_user_addres']['und'][0]['thoroughfare'],
        'postal_code' => $edit['field_user_addres']['und'][0]['postal_code'],
        'locality' => $edit['field_user_addres']['und'][0]['locality'],
        'name_line' => $edit['field_name']['und'][0]['value'] . '  ' .$edit['field_last_name']['und'][0]['value'],
        'first_name' => $edit['field_name']['und'][0]['value'],
        'last_name' => $edit['field_last_name']['und'][0]['value'],
       ));
        // Save the profile.
        $profile_wrapper->save();
        //ym($profile,'message');
    //ym($account,'message');
}

but when I submit it in any manner ( even thought default exists) $profile filled by shipping default profile and create new shipping profile,
where is my fault? how can I update shipping profile?


texts:
I am not able to get exposed filters to work in Drupal 8.  Here is a screenshot to help me while I explain some of the issues

I want to filter by the title of a content type.  This title was renamed to "Name" as you can see me trying to put it in the value for the operator to compare.  This value seems to be the default since when I try this, "Name" is in the field and not grabbing any nodes.  Without anything inside the Value box, nothing is coming up for my queries when testing this filter.

So how do exposed filters work in Drupal 8?   Nothing I have tried has gotten any results.


texts: Custom module menu item declaration leads to error 404

texts:
function eventi_menu() {
  $items = array();
  $items['eventi/book/%/'] = array(
    'title' => 'Book',
    'page callback' => 'eventi_book',
    'access arguments' => array('allow booking'),
    'page arguments' => array(2),
    'type' => MENU_CALLBACK
  );
  $items['eventi/book_waits/%/'] = array(
    'title' => 'Book Waits',
    'page callback' => 'eventi_book',
    'access arguments' => array('allow booking'),
    'page arguments' => array(2),
    'type' => MENU_CALLBACK
  );
  $items['eventi/unbook/%/'] = array(
    'title' => 'Unbook',
    'page callback' => 'eventi_unbook',
    'access arguments' => array('allow booking'),
    'page arguments' => array(2),
    'type' => MENU_CALLBACK
  );

  return $items;
}

function eventi_book($nid) {
  echo 'something';
}

All worked OK, but suddenly, when I visit (for example) http://example.com/eventi/book/201, I get an error 404. I cleared the cache, but I keep to get the same error. Do you have any clue why it happens?


texts:
I have moved a drupal website from live server to localhost.

But the problem I am facing is that everything is broken. no css, no images only text is visible on pages.

On my live website when I click on login button a popup for login appears. But on local host its not working. I have tried using different login URLs but non of them worked for me.

Here is a URL of one image : localhost/sites/default/files/Screen%20Shot%202015-02-24%20at%206.08.54%20PM_0.png

Similarly I have viewed source code of page and here are URLs of CSS and JavaScript files

localhost/sites/default/files/css/css_UCtZrZRD9npGm4D7o8VXPkl5qDJq-m8IlhuR9ccf_tY.css

localhost/sites/default/files/js/js_0gj6QcpfRH2jzTbCQqf7kEkm4MXY0UA_sRhwPc8jC1o.js

These images and files are not found in this location, is this a cache problem ? All these files and images are missing from this location : localhost/sites/default/files

  Note : Most of you are pointing me to following Path :

admin/config/media/file-system

  Here is what I have

Public file system path : sites/default/files
Temporary directory : /mnt/tmp/test

  Now should I make both these paths empty ? or change the path ?


texts:
I have installed OAUTH login provider and all dependencies to provide authentication service to other web application throug drupal authentication.
The problem is that I still do not manage to test if the drupal auth login provider works correctly. I am not sure what is the URL that I shoud put in the client application to reach the server auth provider.

For example in local development environment if I try

https://localhost/oauth2_loginprovider/

I get a FORBIDDEN response from Apache while if I try to contact

https://localhost/oauth2/ ...

I get a 404 page not found on the server

Could you please help me?


texts: How can I programmatically reset a user's password

texts:
I have a native mobile application communicate with my drupal 7 site via services module.  I'd like to give users the ability to reset their password from the app.  Is there a way to initiate this process programmatically, so a an email is generated with a one time use token that expires in 24 hours?

Thanks


texts: D7 views 3, display content based on path

texts:
I have a block that displays results of the nodes i have created but i have those nodes on a specific path, anyway to put this short im trying to make a block from views that displays content based on the url it is on.

For example, if i am on page green, it displays all content from the path green/whatever or if im on red it displays content from red/whatever, im trying to achive this without making a bunch of blocks is there another module or something for this?

Any help is greatly appreciated.


texts: Multiple forms on the same page: hook_forms only works after cache_clear_all

texts:
In a User Tab there are multiple node forms of the same type.

To do this I implemented hook_forms. Multiple forms are shown and they work (sometimes).
But if the user adds some (or delete) nodes and calls his page again he gets the following error:

(Lets say the user owns node 1 and 2)

  Notice: Undefined index: mymodule_a_form_1 in drupal_retrieve_form() (Zeile 738 von /htdocs/includes/form.inc).

  Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'mymodule_a_form_1' was given in drupal_retrieve_form()
  (Zeile 773 von /htdocs/includes/form.inc).

  Notice: Undefined index: mymodule_a_form_2 in drupal_retrieve_form() (Zeile 738 von /htdocs/includes/form.inc).
  Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'mymodule_a_form_2' was given in drupal_retrieve_form()
  (Zeile 773 von /htdocs/includes/form.inc).

The forms work again if I clear all caches.

So what is wrong with this (sample) code?:

<?php

function mymodule_user_profile_tab_content($uid) {
  $out = array();
  $users_node_ids = _get_user_node_ids();
  foreach($users_node_ids as $nid) {
    $node = node_load($nid);
    $out[] = drupal_get_form('mymodule_a_form_'.$nid, array('node' => $node));
  }
  return $out;
}

/**
 * Implementation of hook_forms()
 */
function mymodule_forms($form_id, $args) {
  $forms = array();
  if (strpos($form_id, 'mymodule_a_form_') === 0) {
    $forms[$form_id] = array(
      'callback' => 'mymodule_a_form',
    );
  }
  return $forms;
}


texts: My website has a lot of rules and it's becoming hard to find a specific one fast via the UI. I know I can filter them, but I almost never use that feature. Is there a way to group rules with the same tag together in an expandable block or something? That would make life a lot easier. (Maybe I should post this as a feature request on the Rules' issue queue.)


texts: Granting per-node-type permissions in hook_node_type_insert()

texts:
I use the Override Node Options module to specify granular permissions for publishing, leaving Revision log entries, etc. for each node type.

I almost always grant the same set of permissions to a certain role for every node type, so I thought I'd have Drupal automatically assign them on node type creation:

function MYMODULE_node_type_insert($info) {
    if(module_exists('override_node_options')) {
        user_role_grant_permissions(4, array(
            'override ' . $info->type . ' published option',
            'enter ' . $info->type . ' revision log entry'
        ));
        $role = user_role_load(4);
        drupal_set_message(t('The @role role has been given permission to publish, unpublish, and enter revision logs on @nodetype nodes.', array('@role' => $role->name, '@nodetype' => $info->type)));
    }
}

But when I do so, I get errors:

  Notice: Undefined index: override NODETYPE published option in user_role_grant_permissions() (line 3152 of /htdocs/modules/user/user.module).

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot be null: UPDATE {role_permission} SET module=:db_update_placeholder_0 WHERE ( (rid = :db_condition_placeholder_0) AND (permission = :db_condition_placeholder_1) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => 4 [:db_condition_placeholder_1] => override NODETYPE published option ) in user_role_grant_permissions() (line 3154 of /htdocs/modules/user/user.module).

As it happens, node_type_get_types() ( which is called by node_permissions_get_configured_types()) does not return the node type I'm in the middle of creating, even though the documentation says "This list can include types that are queued for addition or deletion."

So now I'm flummoxed. How can I set a per-node-type permission automatically when that node type is created?


texts: Drupal 7 get user by Profile2 field value

texts:
I have Profile2 field name uid_intranet which is unique.
And in one of my module, I want to get $user object by uid_intranet. The API is kinda like:

$users = profile2_get_users('uid_intranet', 100)

But no such API. So any solutions?

Thanks!

UPDATE 01, my complete code:

// Helper
function _mymodule_get_profiles_by_profile2field($field_name, $field_value) {
  $table = "field_data_{$field_name}";
  $column = "{$field_name}_value";

  // Profile IDs
  $pids = db_select($table, 'ui')
    ->fields('ui', array('entity_id'))
    ->condition($column, $field_value, '=')
    ->execute()
    ->fetchAllKeyed(0,0);
  if (is_array($pids) && count($pids) > 0) {
    $profiles = profile2_load_multiple($pids);
  }
  return $profiles;
}


texts: How to keep Drupal site code in version control in sync with production code when using drush updates on servers?

texts:
I have 50 D7 sites I support (none are multisite). We do local development for changes to themes and modules tied to new functionality and bug fixes. Once the update works locally, we check that into git and use automation to push changes to our test servers.

Security and core updates tend to be run directly on our test and production sites using  drush upc --security-only

How can I keep our git repo in sync with the state of production code?

I can request a dump of production code and use a difftool to compare that to the latest commit and then apply those updates to the git repo code and commit, but is there a better way to do this?


texts: Creating a profile sub page and filling with Webform data

texts:
I'm looking to add an extra sub page to a user's profile that will contain the user's answers to a webform that they have previously submitted. I'm having trouble figuring out how to add this subpage.

Any direction appreciated.


texts: JavaScript running before page fully loaded

texts:
I can not figure out why JavaScript is running before the page is loaded.  The specific thing I'm waiting on is some images so that I can get their height.

The JavaScript is loaded via hook_preprocess_page(): drupal_add_js(path_to_theme(). '/js/smooth-accordion.js');.

Thanks for any help!

(function ($) {

Drupal.behaviors.listen_to_open = function(item) {
    // item height
    var bodyHeight = item.find('.accordion-body-inner').height();
    var imgHeight = item.find('.multi-image-wrapper li:first img');
    var targetHeight = bodyHeight > imgHeight ? bodyHeight : imgHeight;
    console.log(imgHeight.height());
    item.find('.product-showcase-open').click(
        function(){
            item.find('.multi-image-wrapper').animate({
                height: targetHeight + "px",
            })
            event.preventDefault();
        }
    )
}

Drupal.behaviors.smoothAccordion = {
    attach: function (context, settings) {
                    alert('doh'); // alerts before any text or images appear on page
        var $items = $('.accordion-item-wrapper');
        $items.each(
            function() {
                Drupal.behaviors.listen_to_open($(this));
            }
        )
    }
}
}(jQuery));


texts: How to print date in format «long» on node.html.twig template?

texts:
Try this code (at node.html.twig, Drupal 8.0.0-rc3):

{% set date = node.created|format_date('long') %}

And next:

{{ dump(date) }}

Return error:

Exception: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 165 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Drupal\Core\Datetime\DateFormatter->format(Object, 'long')


texts:
I have a text area with CKEditor. The default font in this text area and my theme is 20 pixels and I cannot change its size with CSS, but if I change theme and use Garland, the font change to the normal size.

If I copy Garland styles and page.tpl.php in my theme, the text area is still using a 20 pixels font. Why?


texts: How can I can I add functionality to my module so that the templates can be overwritten?

texts:
How can I can I add functionality to my module so that the templates can be overwrittable like in drupal core. I want to be able to use my module with various themes, but change the required templates.

The only way I have seen to add is via drupal_get_path and explicitly specifiying a theme/module.


texts: Drupal 8.4 - I can't seem to figure out why when my one user group accounts are logged in, anything that uses slick slider or owl slider is completely removed from view and can't be seen. I though it was a permissions issue but nothing in there seems to even give that option as a permission. When I'm logged into my admin account, I see everything fine. Does anyone have any idea what may be causing this or have run into this before?


texts:
Im currently developing a module, that implements an ios-like-switch to change the language (max number of two languages!). The switch is a designed checkbox with the not-default language as the only option. So far I git it implemented.

The tricky part - and here i need some inspiration of the advanced folks here - is,

How can i change the language of the site reasonably?

I could just add the language prefix (en/de) for example to the url...but what happens if there is no translation?

Questions:

Is there a clever api that i can query like: "Does the current node have a translation?"
If true: give me the url of that node...?

I hope this questions are clear enough? If not please comment...

Any inspiration or ideas to implement that properly?


texts:
I get this error when running Status Report:

  CTools CSS Cache  Unable to create

  The CTools CSS cache directory, ctools/css could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.

Where should I look for this folder?


texts: Conditional statement doesn't work in node.html.twig

texts:
I want to use {% if %} in a node.html.twig, but it doesn't work.

I am using this code.

{% if content.field_number == 0 %}
  zero
{% else %}
  one
{% endif %}

It always print one.

The following code always print zero.

{% if content.field_number %}
  zero
{% else %}
  one
{% endif %}

What code should I use to zero when the field contains zero?


texts: Drupal unexpected "Fatal error: Class name must be a valid object or a string [...] common.inc" on every page

texts:
"Fatal error: Class name must be a valid object or a string in C:\xampp\htdocs\uc\includes\common.inc on line 7506"

The error above showed up unexpectedly. I was adding a "Long text" field to a content-type, but when I expected to be brought to a saved field configuration page, I instead got a Fatal error on every page.

I had a look at includes\common.inc:

/**
 * Get the entity controller class for an entity type.
 */
function entity_get_controller($entity_type) {
  $controllers = &drupal_static(__FUNCTION__, array());
  if (!isset($controllers[$entity_type])) {
    $type_info = entity_get_info($entity_type);
    $class = $type_info['controller class'];
    $controllers[$entity_type] = new $class($entity_type); // Line 7506
  }
  return $controllers[$entity_type];
}

However, I just don't understand Drupal at a low enough level to understand the relationships between these variables and functions.

I also searched Drupal for people with a similar problem:

(1) I found one user who claims that I have to install the submodule "Relation Endpoints Field", but searching Drupal, there doesn't seem to be such a module.

(2) Another user suggested clearing the cache manually:

DELETE FROM cache;
DELETE FROM cache_filter;
DELETE FROM cache_menu;
DELETE FROM cache_page;
DELETE FROM watchdog;

(via WordPress API, misleading name, I know.)

Clearing those tables from the cache did not help.

(3) And another user suggested disabling old modules, specifically the "Old search facets" module. Because I can't find a module specifically pertaining to old search facets, I went into MySQL system table, and marked the Search module's line with a 0 status, indicating to stop loading the module altogether.

On that same link as (3), one user suggested enabling the Database Search Module, so I dropped all the tables, imported the latest stable .sql, and installed the module, but after recreating the problem (trying to add a field to a content-type), that as well concluded fruitless.

Still, the problem remains

The Fatal error shows up on every page, making the site completely non-functional. Any help or direction would be immensely appreciated. Thank you for looking.


texts:
newbie question...

Hi,

Before "exploding" my site, I would like to know if I can mix :
- https://drupal.org/project/honeypot
- https://drupal.org/project/regcheck

I'm trying to stop the registration process before sending a request to the server (regcheck) and still have an efficient protection from spam (honeypot).

More generally, is mixing antibot modules a good idea?

Thanks.


texts: Where are the po files and how to translate strings without using the UI?

texts:
I'm using Drupal 8 built-in translation. I've English and Spanish in my website. I've translated the website to Spanish as well. But I don't see any po files for the translation script. I've checked it under sites/default/files/.

Also I've to translate a lot of strings to Spanish, How do I do that using po files without using the UI interface for the translation.


texts:
I'm trying to follow the example of a custom rest api in https://www.drupal.org/docs/8/api/restful-web-services-api/custom-rest-resources.

I don't understand how I can access the request for get or post. In the example there is only a default response, but I would of course like to make it depending on the request headers and body.


texts:
String Overrides is working perfectly for built-in Drupal output such as admin menu links, and for custom code that uses t().

However, it doesn't work if I try and override text in the main menu links. These are standard main menu links, not created by custom code or anything. I've been told this is possible and shown a site where it has been done, apparently with no extra customisation.

It's not a theming issue, since the problem remains when I switch to Bartik.

Should it be possible out of the box to override these strings and if so, any suggestions where I might be going wrong?

The same string is being overridden successfully in other places, just not in the menu.

EDIT: Turns out the site that "it was working on" had been done manually, so never mind


texts: I have to show "On request" if price is 0, I have used Commerce Extra Price Formatters and it allow us to do so,but I need currency converter block also and if I go through Commerce Extra Price Formatters then it will not convert currency, So if there is any other alternative to show text without using any module then pls suggest..


texts: Disable (Close) webform form dynamically

texts:
We would like to be able to put our site into a "read-only" mode prior to doing major releases etc. I was hoping to achieve this for forms on the site by enabling or disabling my custom module, which I could easily do from drush during our release process.

The module would use a hook to disable all forms and show the closed message instead.

This is what I had so far:

<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implementation of hook_form_alter().
 *
 * Disables any webforms when this module is active. Include a custom config key
 * called `exempt_from_maintenance_mode` with any value to allow your form to
 * remain open during maintenance.
 *
 * E.g.
 *     exempt_from_maintenance_mode: 1
 *
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
function yvw_maintenance_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
    // Check for custom config key
    if (array_key_exists('#exempt_from_maintenance_mode', $form)) {
        return;
    }

    // Load the webform entity. This should prevent the module from disabling
    // all forms across the site.
    $webform_id = $form['#webform_id'];
    $webform = \Drupal::entityTypeManager()->getStorage('webform')->load($webform_id);

    // Only disable the webform if its currently enabled
    if ($webform->status() === true) {
        $webform->setStatus('closed');
        // Does not save. Maybe we need a different hook.
    }
}

The problem is I would need to call $webform->save(); which would permanently close the form. I was hoping there was a hook where I could modify the form configuration only at runtime, and not persist any of the changes to the database. But I haven't been able to find any hooks that look like they would do it.

I had a look at Close a webform when total seats reach a maximum which is close to what I want, but it appears that would only run on submission, and also permanently closes the form.


texts: Wrong number of Cart items in Foundation theme topbar

texts:
I use AuthCache and Drupal Commerce in my Drupal 7 site. I am currently building a new Foundation subtheme for the site with the Foundation topbar activated for mobile only.

Now, to show the number of items in the cart I simply replace the default cart block content with this in my template.php:

function mynewtheme_block_view_alter(&$data, $block) {
  global $user;
  if ($block->module == 'commerce_cart') {
    if ($order = commerce_cart_order_load($user->uid)) {
      // Count the number of product line items on the order.
      $wrapper = entity_metadata_wrapper('commerce_order', $order);
      $quantity = commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types());

      if($quantity){
        $data['content'] = ('('.$quantity.')');
      }else{
        $data['content'] = (' (0)');
      }
    }else{
      $data['content'] = (' (0)');
    }
  }
}

The above shows a basket with the number of items in the cart.

Then, to show the number of items also in the Foundation topbar on mobile devices or narrow windows I use this code in a preprocess_page hook in template.php:

  $cartblock = block_render('commerce_cart', 'cart');
  $vars['varukorgen'] = $cartblock;

Followed by this line in page.tpl.php:

<?php print render($varukorgen); ?>

Now to my problem... the number of items shown by the variable $varukorgen in page.tpl.php is incorrect on smaller window sizes when the topbar is toggled. It think that is shows a cached version of the number.

In the AuthCache settings in the block in question i have set "Never" for the Cache lifetime, Per user and I also enabled Ajax.

So why is the number not showing correctly when it is rendered by means of a custom variable in page.tpl.php?

EDITED: the solution was as suggested below to create a new region in the .info file, place the cart block in that region in the UI and then render that region inside the topbar region in page.tpl.php like this:

    <?php if ($page['topplist']): ?>

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

    <?php endif; ?>

Now the the number of items in the cart is updated as it should on every page by the means of Ajax (enabled in the cart block).


texts: Can't get template suggestions to be recognized

texts:
I am using D7. I have declared a custom template facet-item.tpl.php in a module named dsfacet. My code goes as follows:

/**
 * Implements hook_theme().
 */
function dsfacet_theme($existing, $type, $theme, $path) {
  return array(
    'facet_item' => array(
      'variables' => array('facet_name' => NULL, 'facet_values' => array()),
      'template' => 'facet-item',
    ),
  );
}

This custom template is invoked from another template with the following code:

<?php foreach ($facets as $name => $values): ?>
<?php print theme('facet_item', array('facet_name' => $name, 'facet_values' => $values)); ?>
<?php endforeach; ?>

Everything works great so far, but I'd like my theme to use more specialized templates based on the facet name.

So here's what I did:

1) I declared a template suggestion based on the facet name:

/**
 * Implements template_preprocess_HOOK for facet-item.tpl.php.
 * Adds template suggestions.
 */
function template_preprocess_facet_item(&$variables) {
  $variables['theme_hook_suggestions'][] = 'facet_item__' . $variables['facet_name'];
}

2) I changed the theme invocation to take into account the facet name:

<?php print theme('facet_item__' . $name, array('facet_name' => $name, 'facet_values' => $values, 'node' => $node)); ?>

3) I created some templates based on facet names:

facet-item--address.tpl.php
facet-item--phone.tpl.php
...

I then cleared the cache but... nothing happens. Only the main template facet-item.tpl.php is used. After a few hours spent on this, I'm at my wit's end. Any ideas?

(I've tried hard-coding the facet name everywhere to make sure it wasn't a problem with my variables... I've also tried every possible permutation of singe/double dashes/underscores...)


texts: How do I use the time function in Views Math expression?

texts: I'm having trouble with the Global: Math Expression in a View.  I have an entity type which is a student.  I'd like the student grade level to change automatically from year to year, so I'm storing a graduation year and would like to display grade level by a Math expression.  To do so, I need to include a current time element (month and year).  I have read that time() is useable, but I can't get it to work.  Perhaps I'm using the wrong format in the Expression box under Configure field?  As a test, I put in just time(), but I get a zero at the output.  Is time() useable within Views Math Expressions or do I have to abandon that approach and learn to use the Computed Field module?  If time() is useable, would I be able to convert seconds to years by getting an integer value for time()/60/60/24/365.25 or does is there no integer conversion function here?


texts: Creating multiple views from Entityform Submissions

texts:
I would like to create multiple views containing filtered/ordered results from submissions made into forms created using EntityForm.

In the documentation and in question on DA(The Entityform module allows me to create forms that any user can submit and the forms fields are available for me to use in views, similar to how a content type would work. it seems this is possible but I cannot figure out how.

Fields created and submitted in the forms are not listed under "add field" in views, nor in "add relationship".

So the question is:

How is it possible to fully interrogate Entityform submitted data using views?

THE SOLUTION:
As per Wolverine's answer it is very simple to do, displayed in the picture:

No idea how I missed it before!


texts: Site turned to maintenance mode without changing any settings

texts:
I have a client who's site maintenance came up without anyone touching it. What would cause something like this?

I have theories that it's the backup module. Would that be possible?

I just went and turned maintenance mode off last night and just now but the maintenance mode eventually goes back up.

I reviewed this thread but it wasn't related: How to access the admin pages for a site stuck in maintenance mode?

Since, I'm pretty sure that clean url's are turned on already.


texts: Show certain slides only on specific urls on views slideshow

texts:
Using views slideshow I want to be able to control what nodes of content type "slides" show depending on what URL, any ideas?  for example on page-front I would like to show slide1 and slide2, on node/43 I would like to show slide3 and slide4.

Having separate views is not an option because this is a slider that is on hundreds of pages and different content types.


texts: How To Pass Taxonomy Term (Name) to Filtered View (ID) - Drupal 7

texts:
I have a custom view (page) created using Views in Drupal 7.

It contains a taxonomy field and an (exposed) taxonomy filter. When viewing the custom page/view, it works exactly as needed and a user can select a taxonomy filter to limit results accordingly. For example, the default view is /books and the user, via the exposed filter can select /books?book_type[]=21 to show only the books that have taxonomy ID 21.

The problem I am experiencing is that I need a second custom view (essentially a series of thumbnails, each depicting a different 'book_type') to link directly to the /books?book_type[]=21 URL path. Within this second view, I have added the appropriate taxonomy field and via the Rewrite Results option of the field, I have selected Output This Field as a Link and inserted books?book_type[]=[field_book_taxonomy], where [field_book_taxonomy] is the referenced taxonomy field.

When I view this thumbnail page, the link works, but the URL contains the taxonomy name rather than ID. So whilst I need /books?book_type[]=21, the page receives /books?book_type[]=ficton.

I have tried various Contextual Filters, including Term Name converted to ID, but the URL always passes name and the page therefore returns "An illegal choice has been detected".

Ideally I would like to retain the path /books?book_type[]=ficton on the initial view and have this interpreted successfully by the actual filtered view.

Please can someone offer a pointer as to where I am going wrong with this?

Thank you.


texts: Views - Add a wrapper DIV around a Group

texts:
In Drupal 7, I have created a View that lists several fields. The fields are grouped by another field (the term ID of the field). The mark up looks like this:

[Term 1]

 [Field Content]

 [Field Content]

 [Field Content]

[Term 2]

 [Field Content]

 [Field Content]

 [Field Content]

[Term 3]

 [Field Content]

 [Field Content]

 [Field Content]

However, I need the mark up to look like this:

[Term 1]

 [Field Content]

 [Field Content]

 [Field Content]

[Term 2]

 [Field Content]

 [Field Content]

 [Field Content]

[Term 3]

 [Field Content]

 [Field Content]

 [Field Content]

I know that you can use views-view-unformatted.tpl.php (Style Output) to over ride the view and then insert a DIV to wrap the group.

However, I need my wrapper DIV to be like this
. The number ID will correspond to the term that has been used to group the fields. By default, if you use views-view-unformatted.tpl.php, you cannot insert tokens for term IDs into it.

Any help would be appreciated.


texts:
I am trying to update data filed in users table.

Please suggest a way how to update this field data with help of query or need to follow some other approach ?

$old_user_id = 123;
$new_user_id = 456;

$account_old = user_load($old_user_id);
$account_new = user_load($new_user_id);

if ($account_old && $account_new && !empty($account_old->data['uc_stripe_customer_id'])) {
  user_save($account_new, array('data' => array('uc_stripe_customer_id' => $account_old->data['uc_stripe_customer_id'])));
}

Thanks!


texts:
I have this snippet:

$nid = db_query("select nid from {node} where title = :title", array(':title' = 'scrivimi'))->fetchField();
dsm($nid);

It should work, at least from what I've read around the drupal api reference, but it doesn't.

I think the problem is with placeholders. In fact, if I execute the query without them, it runs perfectly, and returns the expected result!

Can you help me please?

I am using Drupal 7 (updated to the latest version), and I am testing this code using the Devel module.


texts: How can create custom twig template for particular page

texts: I want to create custom template for particular pages. Single template for multiple page in drupal 8.


texts: How to redirect logged in user to different page rather than what is configured in basic site setting?

texts:
I have the following requirement:
When an anonymous user visits the site, they will get /login page which is configured in Configuration -> Basic site setting -> Front page.
After logging in when they hit logo/home link they have to go to /dashboard/user page instead of /login page. How can this be achieved?


texts:
I'm new to drupal, and just trying to get it up and running smoothly.

I installed it manually on my Go Daddy account, but I'm getting these errors when I click on the customization links at the top of the screen:

I can still do things (add content, etc.) but since I'm new, I have no idea if there is anything not being shown to me because of these errors. I just did a fresh install and I'm still having the same problems. Any ideas?


texts: Simplest way to create a Commerce shopping cart icon showing the number of items

texts:
I'm looking for the simplest way to implement something similar to Amazon's shopping cart icon which shows the number of items in the cart, which then links to the cart:

I've found several options through browsing various support requests etc, most of which are at least 3 years old and sound surprisingly complex in terms of overheads relying on many features (e.g. this suggestion from 2012 of creating an entire custom Views view to generate one number and one static link).

Obviously, the icon is the easy part, can be done in CSS very easily, it's the number of line items that I'm most interested in. Particularly having it integrated such that it updates when a new item is added to the cart.

I thought this would be something Commerce would do out of the box, or with an add-on module, but if it is I can't find it.

Is there any simple way?


texts: page not found after restoring from the backup except home page (Tried all solutions, which I got through googling)?

texts:
I restored my site from the backup taken from another computer. Another drupal site is working fine in my machine, but this site which I restored from a backup is not working fine.

I am able to see the home page, front page but not any other pages of this restored site. when I click on links displaying 404 error (page not found).

When it is working for some other site, it has to work for other also. But I am missing some site specific configurations.

could any body please help me in this regard


texts: Extracting the values of Field Collection

texts:
I have created a foreach loop in my node template in Drupal 8 where values of the field collection are being printed as 1 and 2. Instead I want the content of the field collection which includes an image and two text fields to be printed here. How do I achieve that? Complete code would be helpful.
My code:

 {% for member in content.field_robot['#items'].getValue()  %}
   <div class="robot-member">
      {{member.value}}
   </div>
 {% endfor %}

I have no experience of playing in the .theme file but can follow basic instructions.


texts: Updating Node Field using drupal_write_record doesn't show changes until cache flush

texts:
Problem is in the title basically, I'm trying to update a specific field in my node and I have to do it by using drupal_write_record rather than loading and modifying the node object itself, or by using node_save etc, but my changes aren't being reflected until I flush the caches for the site.

Is there something I need to do to have Drupal immediately aware of the changes?

Code:

$next_delta = db_query('SELECT MAX(delta) + 1 AS del FROM {field_data_my_field} WHERE entity_id = :nid', array(':nid' => $nid))->fetchField();
  $data = array(
    'entity_type' => 'node',
    'bundle' => $node->type,
    'deleted' => 0,
    'entity_id' => $node->nid,
    'revision_id' => $node->vid,
    'language' => LANGUAGE_NONE,
    'delta' => $next_delta,
    'field_my_data' => 1,
  );
  drupal_write_record('field_data_my_field', $data);
  drupal_write_record('field_revision_my_data', $data);

I've tried adding entity_get_controller('node')->resetCache(array($node->nid)); into the code but that's not doing it either.


texts: Is it possible to insert a value in field using Rules?

texts:
How can I insert data in database using Rules?

I created entity type Job and added some fields. I want to insert values inside those fields when the flag button is clicked. I tried "set a data value" but I think it will work if I already have an existing field and value.

I also tried to use "add variable" in my Rules Action and set value on it. My question is how can I validate if it's working?

PS: I tried to look the data inside my database but I can't see it.


texts:
I'm migrating a current site from Wordpress to Drupal 7 and I'm beating my head against a wall with node hierarchy.  I can't believe this is as difficult as it seems!

I have imported the Wordpress content (which was only 'pages') and everything now shows up as 'basic page' in Drupal under Content.  Most of my pages had a parent-child relationship, and while I can go through every node and type in the proper parent for that node, this seems ridiculous as it is 5 or more clicks per node for every one of hundreds of nodes.

Surely there is a way to select a group of nodes and indicate the parent node of all of those in the group, or perhaps even a drag-and-drop interface.

This is basic stuff and there are posts clear back to 2006 complaining about the difficulty of this.  Surely it is not still this much of a pain...  Is it?


texts: Listing content inside an OG based on a tag name provided in the URL

texts:
I have a site divided in 4 organic groups:

Product
Corporate
Data
Users

Users belonging to a group are able to post content in that group as well as read it. Every group has its page accessible through the following URLs

example.com/product
example.com/corporate
example.com/data
example.com/users

in which an overview of the latest content published in  that group is shown inside a set of panels.

Every group has an specific vocabulary of 4 terms in order to subdivide content classification a little bit more.

THE GOAL IS:

I want to build some pages with page manager so that when a visitor types an URL like example.com/product/foo a page with the same design as the others is shown but filtering the contents inside that group to those tagged as "foo".

To achieve this I've started creating a page variant that would deal with requests in the form /product/%tag with the condition that %tag is a term in the "product" group vocabulary.

Up to this point, this works. When a user browses to example.com/product/foo the page shows as it should, and when it browses to example.com/product/bar (bar is not in the vocabulary) a "page not found" message is displayed.

Inside the views manager I also created a content pane view with the contextual filter based on term ID that:

When the filter is not available displays all results.
When the filter is available

Specify validation criteria
Validator: Taxonomy term
Vocabularies: corporate, data, product, users
Filter value type: Term name converted to term ID
Transform dashes in URL to spaces...
Action to take if filter doe not validate: Display content of "no result found"

THE PROBLEM:

The preview works well in the view admin page when providing the contextual filters but when I try it on the actual page, the "no results" found content is show.

Is there something I have to do with the "Argument input" option inside the views admin page? Am I trying to solve this issue twice by using page manager and contextual filters (should I use only one approach)?


texts: How do I loop over result rows and return calculated values?

texts:
I cannot get proper results from View PHP field.

I've set up a Flipped Table view of entity form submission of which I'm trying to calculate "results" (sum and count(for avg)) with following code

$results = array(); // For results
$static = get_object_vars($row);
dsm($static);
foreach($static as $key => $value) {
    if(strpos($key,'field_') !== FALSE){
        if($value !== NULL){
            $results[$static['entityform_id']]['count']++; // Count no. of fields
            $results[$static['entityform_id']]['sum']= $results[$static['entityform_id']]['sum']+$value; // Count sum of field values
        }
    }
}
return json_encode($results[$static['entityform_id']]);

which results:

{"count":55,"sum":55}   {"count":55,"sum":110}  {"count":55,"sum":165}  {"count":55,"sum":220}

At this point I do not understand that why sum is always row index * sum? Eg.1 =55, 2=110, 3=165... All the submissions have the same fields and field values (clones) which explaines sums but I can't figure out that where this multiplication "logic" happens?

It seems like it is looping/counting all four result rows every time.


texts: Allowing anonymous user based on condition

texts:
I'm currently working on a custom module with an access form and set permissions for anonymous users.

I'm trying to make it so that when an anonymous user enters the password in the access form, they are logged successfully into 'node/3.'

The trick is, 'node/3' and any other basic page node is blocked for anonymous users via the following code I placed in my .MODULE file.

use Drupal\node\NodeInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
function cookie_authentication_node_access(NodeInterface $node, $op, AccountInterface $account) {
if ($account->isAnonymous() && $node->gettype() == 'page') {
return AccessResult::forbidden()->cachePerPermissions();
}

return AccessResult::neutral();
}

Now, how do I get the anonymous user to access the page only for the condition that the password is entered in the access form?

Here's the code for the access form:

<?php
/**
* @file
* Contains \Drupal\resume\Form\CookieForm.
*/
namespace Drupal\cookie_authentication\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class CookieForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'cookie_authentication';
  }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state)       {
     $form['password'] = array(
      '#type' => 'textfield',
      '#title' => t('Access'),
      '#required' => TRUE,
     );

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
      '#button_type' => 'primary',
     );
    return $form;
  }
  /**
   * {@inheritdoc}
   */

    public function validateForm(array &$form, FormStateInterface  $form_state) {
        $values = $form_state->getValue('password');
        //$configValue =  $config->get('access');
        $configValue = \Drupal::config('cookie_authentication.settings')->get('access');
         if ($values != $configValue) {
            $form_state->setErrorByName('password', $this->t('This value is not valid!'));
        }
    }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $password = $form_state->getValue('password');
    setcookie("password", $password );
    drupal_set_message('valid code');
    $response = Url::fromUserInput('/node/3');
    $form_state->setRedirectUrl($response);

}

}

The password is loaded through a config form I built into the back-end...


texts: Steps required for transforming some table into a Pie Chart & Bar Chart and by only using core modules?

texts:
What are the typical steps and/or components required for transforming some data in a tabular format into a Pie Chart and/or a Bar Chart?

And this by only using (a) core modules of Drupal 7, and (b) some charting library that is used as the renderer to actually generate the graph?


texts: facebook login redirect drupal for facebook module

texts: I am using Drupal for facebook module. I want to redirect user to specific URL, if he login from facebook ? Note: I am using Login destination for normal users and works fine for this.


texts:
I have a node that has a cck field that has a link, when the person clicks on it, I need them to sign up then redirect to that link.

Is that possible?

logintoboggan, rules and login destination cant achieve this, they only send to one defined page.


texts: Filter date + between dates is not possible

texts:
In a view I show content that contain some fields and an entity reference.

In the Fields part of the view I have a field (Vervaldatum) like this.

The Vervaldatum field is a date field. I would like to have a "Vervaldatum between […] and […]" filter, but when I add a filter and select the Vervaldatum field, I get this.

I was hoping to get "between […] and […]" in the operator field, but no luck. It's like the field is handles as it is a text field, but the in the previous screen it's clear it is a date field.

These are the operators that I can use.


texts: How to make weights continous with db_update?

texts:
With pure MySQL, I can do something like:

SET @weight:=0;
UPDATE mymodule_table
  SET mymodule_weight=@weight:=@weight+1
  ORDER BY mymodule_weight, mymodule_id;

Is there a Drupal way to achieve similar result? Can I avoid calls to db_query and push it with db_update or db_merge?

MySQL solution adapted from this answer.


texts: Is it possible to restrict access to anonymous user to specific content types based on the author?

texts:
I've been looking for a module that could support my requirement for hours now and failed.

What I want to do is to restrict anonymous user to viewing content type pages based on a specific users. Lets say I have user1,user2 and user3. Anon should be able to view contents created by user1, but not user2 and user3.

I'm thinking of using node_access_hooks but I'm very new to drupal and I have no idea where to start with that. Can anyone help me with this?


texts:
I have a node called "survey". To create one, you go to:

/node/add/survey

I want to make a new url at: /make-survey, which must show exactly what you would see at /node/add/survey

What is the easiest way to do this in Drupal 7?

Follow up question:

Once I got the paths right, I now need to change the title. Currently it is "Create Survey" ... i would prefer if it's just "Survey"


texts:
I have created views with image gallery. Now I want to add alt tag to image how can I do it. I have not enabled alt field in content type configuration.

I want add alt tag to already existing images. Kindly provide the solution to achieve this.


texts:
Drush returns "sh: php: command not found, code: 127"

I just managed to get Drush working finally on my MacBook-Pro (2008).  For the longest time Drush would not interact with the Drupal installation.  Turns out the reason for this was the fact that Drush expects to use the default MacBook-PHP which is different from the MAMP-Stack-PHP which is what Drupal will be using.

This was sorted out and now appears to mostly work.  My environment is MacBook-Pro with Drupal-7.31 and Drush-5.9.  I am using the MAMP-PHP-5.5.14.

The conflicting PHP issue was resolved by renaming the MacBook-Default PHP file by adding an extension to its name. Then the .bash_profile file was modified to add a PATH to the MAMP-PHP and an alias was added for file-name of the PHP that Drush usually expects to substitute the newer MAMA-PHP.  If you need the details, those are explained in my other recent question: "Drush on Macbook Pro cannot read Drupal Correctly".

Now there is another issue coming up. When I run a "drush upc" or a "drush owiz" command, I get an error: "sh: php: command not found, code: 127". This seems to be telling me that Drush runs an sh-shell command which cannot locate my new MAMP-PHP file.

Any guidelines in fixing this, if this is in fact what this error means?


texts: Is the video processing of the ffmpeg transcoder done locally on my server?

texts:
When configuring the Video module, I'm posed to choose either ffmpeg or Zencoder transcoder.

While it's clear that Zencoder leverages video transcoding cloud services by Zencoder.com, I wonder if the ffmpeg option here means video processing is done locally on my server?

In other words, does ffmpeg option use the computing power of my own server and therefore it's completely free?


texts: My Chines characters converts to extra character while making order in paypal how to display item name in default language.?

texts: When i made any order of chines named item its get converted in extra character hwile it redirected to paypal site. how can i handle multi language in paypal


texts: How do I programmatically add a field to an existing fieldset that's part of the user entity?

texts:
I'd like to know how to add a field to an existing fieldset in a user entity

I've seen this example:

Add Fields to Field Group programatically
https://drupal.stackexchange.com/a/71902/1082

$groups = field_group_read_groups(array(
    'name' => 'node',
    'bundle' => 'article',
    'view_mode' => 'full'));
  $your_group = $groups['node']['article']['form']['group_your_group'];
  $your_group->children[] = 'field_your_new_field';
  field_group_group_save($your_group);

But I'm unsure what to supply for 'name' and 'bundle' and also what to supply for the line

$your_group = $groups['node']['article']['form']['group_your_group'];


texts: How to link the title in a teaser to the main content?

texts:
I have created a view that provides teaser content for different nodes.

This teaser content carries a main title and some more fields. I want to make the title as a link, which when clicked, takes the user to a page that displays the full node.

I tried enabling the "Link this field to its entity" for the title field in its view, but clicking on that link takes me to a page like:

http://localhost:8082/node/<node id>

I want it to go to a prettier looking URL like:

http://localhost:8082/<pretty URL>

How can I achieve this?


texts: Rules: How to modify an existing condition programmatically

texts:
I've been able to add a condition to an existing rule, but I can't find any documentation on how to modify an existing condition on a rule. The following code works for adding but I need to modify the one that already exists. Any ideas?:

$hk_delivery_rule = rules_config_load('commerce_shipping_service_hong_kong_delivery');

$hk_delivery_settings = array(
    'first_price:select' => 'commerce-order:commerce-order-total',
    'operator' => '<',
    'second_price' => array(
      'amount' => $hk_threshold,
      'currency_code' => 'HKD'
    )

  );

$hk_delivery_rule->condition(rules_condition('commerce_price_compare_price', $hk_delivery_settings));
$hk_delivery_rule->save();


texts: Describing an Entity Reference relationship

texts:
I'm wondering how to describe, or add extra information to a Entity Reference relationship between two content types.

I have 'event' and 'people' content types. An event can have many people, and each person can be an either an organizer, presenter, facilitator, etc.

How can I model this relationship? Do I need to have an Entity Reference field for each type of relationship, or can I add the type of relationship as a parameter of a single Entity Reference?

Thanks!


texts: Prevent Drupal from rewriting # as %23 in URLs

texts:
I have a field where I am rewriting the output, trimming it and providing a read more link. The read more link contains a # because it's a page anchor that triggers a views accordion on the destination page.

Views is converting the # character into %23 in the actual displayed link, which is breaking the link.

How can I convert it back to a # character in the url?


texts: How to group all custom modules under one menu using hook_menu?

texts:
I just started learning drupal 7 module development. I wanted to group all my custom modules under one category (say custom). I know how to manually do that using "admin/structure/menu/manage/management". But is it possible to create a new group and put all my module menus under that group using hook_menu ?

For Example :

  function hook_menu() {
  $items['admin/settings/custom/module-name'] = array(
  //other code here
  );
}

The above code doesn't create the "custom" menu item instead it creates "module-name" menu. I want to put "module-name" under "custom" ?


texts: Filter a view by a value being absent from a multiple value field

texts:
Given a field "field-participants" on a node type "discussion" that references an unlimited number of users:

How can I produce a view that shows all discussions that do NOT have the current user listed in their field_participants?

The problem comes from the fact that views creates a separate row of results for each reference in field_participants in any given discussion.

I can use 'Distinct' or Aggregation to get rid of duplicate rows, but while this would work to include results (showing discussions that listed the current user as a participant) it doesn't work to exclude results.

This is because a contextual filter on the current user with "excludes" checked only excludes the one of these rows that matches the current user. It doesn't exclude all the rows from that discussion. Therefore I get false positives: the view shows all discussions that have someone other than the current user listed as a participant.

Right now I'm thinking that I either need to figure out some arcane HAVING clause and add it to the query programmatically, or try to use the pre-alpha Flag module (setting a per-user flag and filtering by that instead of field_participants).


texts: Filtering list of nodes with attached views by taxonomy of node

texts:
I have a single article (page) which has an attached view thats displays a load of nodes (in a content called 'courses').

These nodes have a term reference field called 'language' which assigns them to a specific language the course is taught in.

Each of these nodes have an attached view which lists a load of related nodes (in this case 'products'), and these are also assigned with the same taxonomy called 'language'.

What i am attempting to do is to list these nodes, with the attached view filtered by the same taxonomy 'language'.

I've attempted to set up the view using contextual filters with the notion of getting the parent nodes id (When filter is not available use taxonomy term id from URL) but this only gets me the id of the top level node. What i'm looking to get is to pass the language tid from each course to its attached view.

I've used hook_views_query_alter to add on the join table for the languages table which i'd like to then fill with the tid from the passed taxonomy term to do the filtering.

Anyone done such a thing? seems pretty straightforward as it feels like i'm doing something in the wrong order (ie its rendering the view before attaching to the node).


texts:
I have a very simple form created with Form API (Drupal 7) and the latest entries are displayed within a sidebar block and are also clickable.

I'd like that when I click on any recent entry, it pre-fills the form automatically with these values but I don't know how to achieve this. Googling brought me to:

http://drupal.org/node/752056
http://drupal.org/project/prepopulate
http://www.keyframesandcode.com/resources/javascript/jQuery/demos/populate-demo.html

And I've also seen something that could be of interest with JS:

$("#edit-id").value('newvalue')

The thing is I'm very new to coding and would like more step by step examples to achieve this. I feel like Ajax would be the best solution here, to make a DB call when needed ans populate the form.

Any idea how to proceed?


texts: Drupal 7 form only submits when logged in

texts:
I've built a form with Drupal 7 FAPI and it works perfectly, but only when I'm logged in as an admin. Otherwise, if you try to submit it without being logged in the page just refreshes when submitted, the registration doesn't get captured in the DB and the page doesn't redirect to the thank you page. Does anybody have an idea of what might cause that behavior?

The site is running on a Windows IIS server, very much not my choice, if that helps in any way. Unfortunately it's not public right no so I can't post a link.


texts: where can I find the login block to modify?

texts:
I want to modify login block!Where can I see login block ?

I am using danland theme in drupal 7 site. So far I have walked through sites/all/themes/page.tpl.php file, node.tpl.php and template.php file, but I didn't find.

Can anyone help me in this ?

Thanks in advance.


texts: How can I access/inject external objects into my custom code at runtime

texts:
I have seen similar questions to this but none appear to directly and generally answer this question.

I want to add some custom.js to a module using libraries.yml file and in custom.js I want to access objects defined in 2 libraries.yml files: external.js and mylibrary.js. Libraries.yml loads the assets but doesn't appear to inject into the custom.js drupal behavior at run-time. Drupal appears to offer some kind of javascript module management by injecting jquery dependencies into a behaviour, but how so i inject js objects?

my-module.libraries.yml

  custom-library:
  version: 1.x
  js:
    # external.js defines external_js_object
    https://cdnjs.com/external.js : { type: external, minified: false }
    # a local library file
    js/mylibrary.js: {}
    # custom.js uses objects from mylibrary.js and custom.js
    js/custom.js: {}
  dependencies:
    # these are injected into the drupal behaviour
    - core/jquery
    - core/drupal

js/custom.js

    (function ($, Drupal) {
    Drupal.behaviors.custom_styles = {
      attach: function (context, settings) {
        // this works ok because jquery is injected into the behaviour
        $(".somediv").text("whatever");

        // this doesnt work. how to inject the external_js_object?
        external_js_object.run();

        // this doesnt work. how to inject the mylibrary_object?
        mylibrary_object.run();
    }
   })(jQuery, Drupal);

so my question again is: how do i inject the external js objects from external.js file specified in the library.yml file into the custom.js file so i can work with it?

Does Drupal support injection of external.js objects in the same way it does drupal dependencies? If so what is the correct syntax for me to inject my external_js_objects into a drupal behaviour?

I realise this needs something like import statements or webpack to make it work, but Drupal appears to have done half the job in the libraries.yml file but the import isnt clear. How do/can I extend (function ($, Drupal) {...})(jQuery, Drupal) to make them available in my js code.

In Drupal 8 can I use es6 imports without any additional package modules (e.g. webpack)? If so I do I map the files in libraries.yml to namespaces in custom.js? Specifically how do I import "https://cdnjs.com/external.js : { type: external, minified: false }" into my custom.js?

thanks


texts: Commerce Discount Module : Free Products : n+x

texts:
Is someone using commerce discount module and customized free products quantity field for buy x and get y functionality ? If i set buy 1 get 1(free product qty) its not multiplying while user updating quantity on cart.for ex-

I added 1 product = 1 qty.if user increase product qty with 2,its remaining same.like 2 = 1


texts:
I am working on a module which is able to automatically generate a developer document based on the hooks, menus, files and other attributes it holds.

Often when we install a new module, We need to search for the configuration options provided by it. So by automatically generating a document, this issue will be solved.

I started working on this based on clive's suggestion in the post (Get a particular module's information programmatically)
I could retrieve the menu links created by a module as clive suggested in that post.
To retrieve hooks used in a module, I used the PHP function token_get_all() to get all function used in a file and checked whether its a hook.

  Now, I need some suggestions about what can you know by looking through a modules file. What else in a module file can help one
  understand a newly installed module better?

  Is there any API's to get information about a hook from drupal.org?


texts: Restrict product availability to certain languages/countries in Commerce

texts:
I need to make a commerce shop where certain products (containing alcohol) should not be available to a certain country/language. How to do this?

Jonas


texts:
I need to find out the SQL query that is executed by a certain query. Views module can show the SQL when configuring the view but apparently the query is not the actual query that gets run in all cases.
I am aware that the Devel module can show the database queries, but there is no way with devel to show the actual queries except clicking the associated 'A' link with every query and there are hundreds of them.

How can I find out the actual query that the view executes? The view is displayed as a block.


texts: Ajaxly set Text Field Value with Drupal Forms API

texts:
I have a text field and a ajaxified link in my form:

$form['id_number'] = array(
    '#title' => t('ID Number'),
    '#type' => 'textfield',  //textfield
    '#suffix' => '
l(t('101-03043'), 'myid_choose_result/101-03043/1, array('attributes' => array('class' => 'use-ajax')))
',  //ajaxified link
    '#attributes' => array('id' => 'myid_search_id_number'),
);

The link above calls a function myid_choose_result define in my hook menu:

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

    $items['myid_choose_result'] = array(
        'page callback' => 'myid_choose_result',
        'access callback' => 'myid_user_access',
        'file' => 'myid.pages.inc',
        'type' => MENU_CALLBACK,
    );
    return $items;
}

What I want to achieve is every time the user clicks the link, the text field value will be the link's text. After doing so, I want to call a another function:

function myid_choose_result($id,$template){
      //Change the textfield's value into $id
      myid_some_function(); //Call another function
}

How will I do that?


texts: What are valid entity_id and entity_type values for node content?

texts:
I'm trying to track down some performance issues on a Drupal 7 site where out of nowhere the site will stall rendering content or dealing with administrative duties like updating a piece of content. Checking the logs, I've found errors when cron runs for:

EntityMalformedException: Missing bundle property on entity of type node
Notice: Undefined property: stdClass::$nid in node_build_content()
Notice: Trying to get property of non-object in _node_index_node()

This prompted me to create a view to look at all content types and return

title,
node_id,
entity_id
entity_type

This view shows the majority of site content has entity_id = 0 and entity_type = null (nothing).

Out of roughly 400 nodes, less than 20 have proper entity_types and entity_id values. Even creating a simple basic page with a title and body results in entity_id = 0 and no value for the entity_type.

You would think that the content wouldn't render however, all of this content will render at /node/xxx or pulled up in views and can be edited as usual.

I think this is one of the causes of the poor performance if not the cause so I'm looking to repair the broken nodes and and prevent this site from continuing this odd behavior. I'm pretty sure the entity_id should equal node_id and I'm pretty sure the entity_type should equal node.

Drupal 7.34


texts:
Is it possible to handle querystring parameters in webform module in Drupal 8.x with Uppercased letters like in this example?
example.com?collectionId=123 (notice uppercase "I")

Webform fields requires machine names (capital letters not allowed).
Currently i get forms pre-filled as expected using collectionid=123 instead of collectionId=123 but in my current scenario using the capital letter is a requirement in order to keep some legacy external process working untouched.

Any suggestions?


texts: a little clarification about contextual filter

texts:
When we say "Content: Has taxonomy term ID" or "Content: Nid", what do we mean by content? Is it the element which is being viewed currently or the element that is about to be fetched from view(output of view).

When "Content: Has taxonomy term ID" is added to a view, will it  compare with the currently viewing node whether it has term id or compare with the view's data that is being fetched, whether it has taxonomy terms?


texts:
I have some drupal 8 sites that make heavy use of the Paragraphs and Bootstrap Paragraphs modules.

Some of my users want to be able to create anchor style links to specific paragraph items on pages. For example; a user may wish to link directly to a specific accordion that is halfway down the page. They may wish to do this either from the body of the same page or with an anchor style hyperlink from elsewhere on the site. eg: mysite.com/mypage#myanchor

Other than adding a "name" field and creating a specific "anchor link" twig override for every paragraph type and field is there a more straightforward way of doing this?

In messing around with the anchor_link module It seems it can only find anchors in the body of a node. If you add an anchor to say, the body of an accordion the link function cannot see it.


texts: How to move the edit tab in node.tpl.php

texts:
The $tabs variable is being printed in page.tpl.php, but I want to move it under the title of my node. I can't use the $tabs variable in my node template and I don't see the variable being prepared in template.php as well.

How can I get $tabs to show where I want in my node template file?


texts: Feasability of module or submodule for user picture migration

texts:
It seems like there would be a fairly large number of Drupal 6 websites with user pictures that will need to be migrated to Drupal 7 at some point and that the difficulty of migration might be keeping some sites from migrating.

There are various posts here and there about the code needed to migrate user photos but this may be daunting to some users. Would it be difficult to create a module that the user could configure with source and target directories using the configuration menu and that would then perform the migration, so that user could avoid getting into Drupal's internals?

It would also be nice if drush could be used for this migration, but the solution above would probably be accessible to more users.

I'm not a developer, so creating and maintaining a module seems to be more than I could commit to, but I'm wondering whether this would be easy for someone with more experience.


texts:
I am using Force password change module to give a facility to user to reset the password after their first login. So far, I have installed the module and after creating the user, when I click on edit link, I could see the force user to change password check box option. But I am unable to see the same option in add user page (while creating user).

Any suggestions about how to enable same option on add user page?


texts: How to use trusted contacts as a selection rule for user panel page, drupal commons

texts:
In Drupal Commons, using Panels, I'd like to change the behavior of the user page.

One variant for users to view their own page, and another for viewing other user pages.
Also, I'd like to limit it so that only the trusted contacts of a user can view his/her page.

It is set up using panels, so first I added a variant with a selection rule: user: compare - User being viewed is not Logged in user. This works fine.

But how to configure it to limited to trusted contacts of a user.
The context for  user: user_trusted_contacts is already listed as an option, but I can't use it as a selection rule. There's no option there for "..user is one of".

I'm sure it can be done within panels, thanks for any help.
D

commons-7.x-3.46


texts: Is there a way I can set access to specific form elements?

texts:
I'm writing a custom ticketing system module for my company and I would like certain form elements disabled based on permissions. Is there a way I can do this without needing to make two separate forms (ex: user form, admin form)

I know for the items array in a menu hook, you can just set 'access arguments.' Preferably I'd like to just use the existing permissions I've already created for my module or even make it role specific.


texts: How do I add description and keyword to the front page?

texts:
I would like to know how to set description and meta keywords for the front page. I use the Meta tags module for articles, but it is not working for the front page.

I use Panel as my front page.

My website is http://www.techiestuffs.com, and runs on Drupal 7.

if you see the HTML source of the front page, it only contains the following HTML:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="http://www.techiestuffs.com/sites/default/files/favicon.png" type="image/png"/>
<meta name="Generator" content="Drupal 7 (http://drupal.org)"/>
<title>TechieStuffs | Stuffs for Geeks</title>

I had tried adding these functions in template.php:

function yourtheme_page_alter($page) {
  $meta_description = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
    'name' => 'description',
    'content' =>  'Description about the site'
  ));

  $meta_keywords = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
    'name' => 'keywords',
    'content' =>  'Some Keywords about the site'
  ));

  drupal_add_html_head($meta_description, 'meta_description');
  drupal_add_html_head($meta_keywords, 'meta_keywords');
}

But this function does not seems to work as you can see in my websites source code.

Does anyone know how to work out this?