texts: Programmatically add a translation of month

texts:
I need to add a custom translation of long form of months. The existing translation must be changed slightly.

One way to do it is via UI, however, not all months are available for translation yet (this is a new site). I would like to write a function in a module that would add all translations of months programmatically (and it would also be possible to use it on other sites). Is there a way to do it?


texts:
Until recently I've only been doing mainly superficial support on a website.
But now the question has been asked to revert the server the website runs on, to a few months ago.
The website is Drupal, but runs in IIS with a Microsoft SQL database instead of MySQL.
Now, I've never done a backup/restore procedure from a website, nor do I know what the risks are or what needs to be done.
I was looking at https://www.drupal.org/node/22281, but I still don't feel wise/secure enough to know what I'll be doing.
The main problem for me is; I need to keep the content of the website as it is now, but I don't know for certain where this is located/stored. The database?
Changes in files haven't been done to the website as far as I'm aware, so I hope this won't amount to a problem.

Basically what I'm asking is; is there a way to be certain that a rollback of an entire server and then a restore of content wouldn't amount to any difficulties?

Any general (or specific) information would be much appreciated,
Thanks


texts: what are the different ways to use the variable in many functions within a module?

texts: I want to access a variable changed in one function in another. I tried this with Session and global variables. I need the variable to be persisted across multiple page requests. are there any other ways to do this?


texts:
How can I have the page argument appear in the page title?

    $items['path/path/%'] = array(
    'title'            => t('Dynamic Title %1'),
    'page callback'    => 'pagecallback',
    'page arguments' => array(2),
     'type'             => MENU_CALLBACK,
    'access arguments' => array('access content'),
  );

Is there some kind of text replacement or something you can use in there, or is what I'm asking impossible?


texts: archive_page() from archive module in drupal 6 shows all nodes not date specific

texts:
I installed Archive module and used following code in a custom template:

print archive_page('all', 2012, 10, 12);

but it shows every single node I posted, How can I make it load nodes according to date I specified in the code?


texts: How can the items in a field collection view be restricted to those of its containing entity?

texts:
I have an entity type with a field collection that I want to display as table within the main entity display. I have created the view as a block view and added it as a block field using Display Suite.

However items that don't belong the containing entity appear in the display. In effect the embedded view displays all the field collections items, instead of those added to the containing entity.

The Contextual filters and the Relationships in Views UI don't display a means of linking the collection items to the host node.

Is there a way of filtering the view by the node?


texts: Is there anyway to show all results in a view initially, but only show 1 result after user sets an exposed filter?

texts: I need to be able to show all results of my view initially but then only show 1 result after the user selects their options form the exposed filters.


texts: Change layout of a view 'page display' based on number of grouping field occurences

texts:
Sorry about that rather specific title: hopefully my question will clarify itself with the following:

What data is on the table to work with

I have a View (page display) that lists nodes based on the main categories "Fruit" and "Veggies"
So I have two pages: 1 at www.mysite.com/fruit  and the other www.mysite.com/veggies

arg(0) is being used as a contextual filter to get the right nodes on
both those pages.
I'm grouping my nodes (grouping field dropdown in Style options) based on the taxonomy term they belong to (eg for "Fruit" > sweet and sour) to reflect their hierarchical place in the taxonomy structure (see below)

fruit
-- sweet(taxonomy term)
-- -- banana node
-- -- melon node
-- sour(taxonomy term)
-- -- lemon node

veggies
-- red (taxonomy term)
-- -- paprika node
-- -- onion node

What I would like achieve

I would like to be able to add different styling to a page that has only 1 main category (like the veggies - categorypage -> we only have the "red" subcateg there) as opposed to a page that has 2 or more main categories (like the fruit - categorypage -> we have 2 subcategs there: "sweet" and "sour")

What I have uptil now (it's working but I need to clean up my act/code)

As stated ... this already functions , but I would love to know:

if I followed Drupal protocols.
if there are better ways (more performant, cleaner code, easier)

I've got this in my template.php

/* Helper function so I can reach my specific display in the preprocess hook below*/
function <themename>_preprocess_views_view(&$vars) {
  if (isset($vars['view']->name)) {
    $function = __FUNCTION__ . '__' . $vars['view']->name . '__' . $vars['view']->current_display;

    if (function_exists($function)) {
     $function($vars);
    }
  }

// This is where I inject a custom CSS file in the case where I've got only 1 Main category (as explained above)
function <themename>_preprocess_views_view__need__page(&$vars) {
  $tidArr = $vars['view']->field['term_node_tid']->view->field['term_node_tid']->items;
  $terms = array();
  foreach ($tidArr as $key=>$tids) {
    $terms[] =  current(reset($tids));
  }
  $uniqueTids = count(array_unique($terms));
  if($uniqueTids < 2) {
      drupal_add_css(path_to_theme() .'/css/my_custom_css.css');
  }

}

Disclaimer: Heavy question , I know ... but hopefully clear enough so you can all understand what is going on , and what I'm trying to achieve.
Understand that I'm happy I got it working , but I would be even more happy if I could do it the Drupal "way" and have my code as lean and mean as possible.
thanx for taking the time.
    }


texts: Render menu item children without being 'expanded'?

texts:
In Drupal 8, how can I render a menu links children without checking 'expanded' on the menu link? I am building a drop down that displays on hover, the links need to render.

My code so far:

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    <ul>
    {% for item in items %}
      {% if menu_level == 0 %}
        {%
          set classes = [
            'global-top__utility-item',
            'js-utility-item',
            item.in_active_trail ? 'active-trail',
            item.below ? 'has-submenu'
          ]
        %}
      {% endif %}
      <li{{ item.attributes.addClass(classes) }}>
        {{ link(item.title, item.url) }}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      </li>
    {% endfor %}
    </ul>
  {% endif %}
{% endmacro %}

When a parent link has children, they are not rendering unless 'expanded' is checked, which breaks the menu.


texts: Media Wysiwyg + CKeditor. Replace inline images with custom images programmatically

texts:
I am trying to replace individual images in old node body with a default image using media + ckeditor programatically so as to save disk space as there are lot of images in server.

I was successful in replacing image for an image field programmatically. However, I am not able to determine how do I replace those images embedded within a body along with body text while loading a node using node_load.

I intend to replace these images using hook_cron and run replacement operations on older nodes images.


texts: Is there a way to check user permissions in javascript? I have a segment of code that I only want visible if the user has the proper permissions, and I think it would be easiest way to check the permissions, and then just set the segment to display: none; if the user doesn't have the right permissions.


texts:
I have a "medical records" content type which has a "medical process" field embedded (type=paragraphs bundle, number of values unlimited). In the paragraph bundle its has visit time, diagnosis, treatments, images, etc., so the paragraph can record every visit.

Everything works well, however, if we have a lot of paragraphs, in the view page, it looks ugly, so I would like to add some labels to each visit record enter image description here(paragraph), such as "the first visit", "the second visit","the % visit)...as I know the field group can only show a static label, token not available. Do anybody know how to realize this?


texts: How to replicate this form with exposed filters

texts:
I'm wondering how can I achieve something like that "Browse Listing" block (on the right) with exposed filters - http://demo.rlisting.com/rlisting/result
Should I create Content type for each Property type and add Listing type as a vocabulary or to use only one content type for all properties and then add property and listing types as vocabulary or as text fields with select list?
And more importantly how Min & Max range could be created?

using drupal 7.14, views 3.3


texts: cannot enable module after DB migration, only in one environment

texts:
I have 3 environments: live, stage & dev.

I've taken a database backup from live and imported into stage & dev.

I clear all caches on stage & dev and navigate to /admin/modules to turn on module_a but on stage it's disabled and i'm unable to enable it.

It seems strange that I am enable it locally but it's disabled on stage.

How do I go about debugging this?


texts: What is the best module for student registration form

texts:
What is the best module to use if i want to create a
student registration form for my website.

Some of the fields in this form is referred to taxonomy and content types as entities.

Im a novice user of drupal 7
and cant find any mdoule that does this, I keep getting FORM API tutorial in my seaches but I when I checked it involves a lot of programming.. :(

Thanks


texts:
I have a Drupal 7.8 site with the Field Collections module version 7.x-1.0-beta2, which is presently the current version.

I'm having an issue where, after I create a new field collection field on a content type, I am unable to edit the field collection. I go into admin/structure/field-collection, and click on 'manage fields' for the appropriate collection, yet the site reloads the same administrative page, which lists all field collections.

I've done some googling, and haven't found any reports of this problem. Also I haven't seen anything in the issue queue for Field Collections.

Does anyone have any thoughts on this?

Edit: I've flushed the caches several times, and tried this on several different sites.


texts:
I tried to use a rule found in another topic (https://www.drupal.org/node/2050565), but it doesn't work. I want to send an automatic email to the product's creator, when the product is sold.

{ "rules_send_email_to_product_owner" : {
"LABEL" : "Send email to product owner",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
  { "data_is" : {
      "data" : [ "commerce-order:commerce-line-items:0:type" ],
      "value" : "product"
    }
  }
],
"DO" : [
  { "mail" : {
      "to" : [ "commerce-order:commerce-line-items:0:commerce-product:creator:mail" ],
      "subject" : "Test mail",
      "message" : "Test mail nr 1",
      "from" : "Sender",
      "language" : [ "commerce-order:state" ]
    }
  }
]

}
}

Any help would be greatly appreciated :)


texts:
Using a Block's visibility setting of Show block on specific pages: Pages on which this PHP code returns TRUE (experts only)...

...what PHP would I write that returns TRUE so that the block only shows on "Page Not Found" pages?


texts: Conditionally require user to complete a content type based on answers from other content types?

texts:
I'm working on a drupal project that collects information about a business and then offers advice based on the information submitted.

Following the initial sign up process, a user can add a new business profile content type.  This will be the entity referenced by all other nodes related to this entity aka the "business profile". Based on the answers provided within this initial questionnaire, I want to require the user to complete other supplemental questionnaires (basically other content types with entity reference to the main business profile content type) before submitting a finalized business profile.

For example, in the initial business profile there may be the question "Do you have any foreign operations?", if the user answer yes, I would want to make them complete the "foreign operations" content type questionnaire with many fields that relate to foreign operations.  Further, if the user answers no to a question such as "do you have any employees?" I don't want to make the user complete an extended questionnaire (aka an employee related content type) regarding employees.  In addition to simple yes/no answers, if a user selected a certain business industry SIC code from a select list, I would want to require specific content types to be completed with questions related to this industry.  In my mind, I could have 50 content types with questions, but for each business's unique operations, they may only need to complete 5 of those content types.  Finally, I would need a dashboard to keep track of what content types are required, pending and have been completed - then once all of the required supplemental content type questionnaires are verified completed, allow the user to submit a finalized profile.

I would say my level of drupal is intermediate as I understand the basics of entity referencing, structure and views; however, admittedly my experience in rules is limited. I'm using drupal 7.x.

I'm hoping someone can help to offer me a rough step by step of how best to accomplish this. (i.e. use this module, within rules conditions add blah, etc. etc.)  Is my approach the correct one or is there a better solution such as webform, etc.?

Any help or guidance is appreciated.


texts: How do I add a "Please select"/ "none" option to a required select input in a form?

texts:
I cant find anything about that in the drupal 8 form api on how to add an option "Please select" to a select element. The form item is mandatory so you must select something. Of course, selecting "Please select" should invalidate.

$select['#options'] = $options;
$select['#required'] = true;


texts: Converting D6 fieldgroup implementation to D7

texts:
I have a module that I'm working on that used the code:

  if (module_exists('fieldgroup')) {
    foreach ($content_types as $type) {
      fieldgroup_save_group($type, array('group_type' => 'standard', 'group_name' => "{$type}_group", 'label' => t("@type information", array("@type" => ucwords(str_replace("_", " ", $type)))), 'settings' => array(), 'weight' => -2));
    }
  }

$crc_field = array(
  'field_name' => "{$type}_crc32",
  'type_name' => $type,
  'label' => t('CRC32 hash'),
  'type' => 'text',
  'widget_type' => 'text_textfield',
  'group' => "{$type}_group",
);

This is in the .install file.  What would be the appropriate method to use the D7 fieldgroup module to add an entity's fields to a fieldgroup.  Is that no longer done in .install?


texts:
I'm trying to figure out how to get the last database error after a query fails, and I'm having trouble finding the appropriate function. It seems up until Drupal 7 there was a db_error() function that would return the information.

How should I retrieve a database error in Drupal 7?

My code:

try {
    $q = db_query($q);
} catch (Exception $e) {
    $error = db_error(); // this is what I'd like to do
    $transaction->rollback();
    watchdog_exception('my_module', $e, t('Caught an error: ' . $error));
}

I'm aware that I can get some information from the exception, but I'd like to get it directly from the Drupal 7 API.


texts: Add and customize login block on page.tpl

texts:
I'm trying to add the user login block in my page.tpl file. I've tried inserting the following code but  the only thing I see is the username, password and submit fields. The "Register" and "Forgot your Password" fields are not there. And I would like to do this in code form. Cause I wanna put the user login block in a specific place.

if(!user_is_logged_in() ){
    $userLoginForm = drupal_get_form('user_login');
    print drupal_render($userLoginForm);
}

Thanks :)


texts: How to make submenus appear on hover regardless of what page you are on?

texts: I am using CorporateClean theme for this site and I want the submenus dropping down from the main menu tab "gallery" to appear on hover no matter which page you are on. How to achieve this?


texts:
I have a path controlled by page manager & domain access selection rules.

Let's say I'm on the Main (US) version of the page, and I need to know of the spanish version of the page is valid.

/contact-us

/es/contact-us

I've tried things like drupal_valid_path, drupal_lookup_path, etc.

The only option I've found is to do something like
menu_get_item()
Then hack the global language, call the callback from menu_get_item with

//hack global language here
$router_item = menu_get_item($path);
$page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
if (MENU_NOT_FOUND != $page_callback_result) {
   //url is not valid
}
//set global language back to original

Is there a simpler more generic way to programmatically do this? If there were some function like drupal_valid_path that would just say if the path results in 404 or not, that would be great, though I haven't found something like that yet.


texts: Text (plain, long) automatically has line break converted to

texts:
I have created a field Text(plain, long) and have a custom template
which currently only outputs this field.

{{ content.field_testing }}

When the output is rendered, all the line breaks are converted to <br> I need  to remove. I could add some filters but I figure there must be a way to prevent it in the first place. How can I do this?


texts: I would like to display only the teaser view of nodes

texts:
I hope someone can help me. Here's my issue:

I'd like to create a content type - let's call it News Story.

Amongst its other attributes, this content type will have a taxonomy field.

I would like to be able to create a number of views around my site to display a subset of the News Story content, based on its taxonomy value.

However, I do not want the News Story to generate a standalone node/page - I only want the news stories to appear in views of news stories.

Have you done this before? How did you do it?

I'd be really grateful for your help.

Thanks


texts: User Relationships view showing each relationship more than once

texts:
I'm trying to display a users relationships through Views(3). I'm getting duplicates for accepted relationships. Also, the current user show's up under his/her own relationships. Here's what I got so far:

Format: Unformatted list
Show: Fields

Fields
User: Name
User: Picture

Filter criteria
User: Active (Yes)
(rtid) User relationships: Requester or Requestee is current user (True)

Sort criteria
User: Created date (desc)

Block name: None
Access: Permission | View user profiles

Contextual filters
User relationships: Requester user  // I've tried (rtid) here with the same result

Relationships
User relationships: Requestee user
User relationships: Requester user
User relationships: RTID

Use AJAX:Yes


texts:
I'm working in a multisite, the theme had page--front.tpl.php file for the main site, but I want to exclude this file in the other sites.

How can I do this?


texts: I'm new to drupal and I'm using drupal 6 I want when I upload an image using imagefield  to display its width and height in pixels the only thing that appears after uploading is the image thumbnail, so any ideas?


texts: How to get IMCE to view just one S3 bucket folder created by IMCE

texts: I have 700 training courses. I want to to be able to go to a drupal page and access that courses files using only the IMCE module. I like the ability to create folders and download and upload files. I can't seem to get the IMCE module to just connect to just one course folder that connected to an S3 bucket. I will eventually have 700 of these folders. I only want the user for that particular page be be able access those files for that folder. These folders will reside in an Amazon S3 bucket in which IMCE is already connected. See image for further clarification.


texts: How can I save form data on a node in Drupal?

texts:
I want submit form data and save on specific node but I don't know that how to do?

function test1_menu() {
  $items['mytest'] = array(
    'title' => 'My Tes',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test1_form'),
    'access callback' => TRUE,
    'weight'=> 1,
    'type'=> MENU_NORMAL_ITEM,
  );
  return items;
}

function test1_form($form, &$form_submit) {
  $form['firstname'] = array(
    '#title' => t('First Name'),
    '#type' => 'textfield',
    //'#required' => TRUE,
  );
  $form['lastname'] = array(
    '#title' => t('Client Name'),
    '#type' => 'textfield',
    //'#required' => TRUE,
  );
  $form['submit'] = array(
    '#value' => 'Test',
    '#type' => 'submit',
  );
  return $form;
}

function test1_form_form_submit($form_id, &$form_state) {

}


texts:
Drupal code

function form_example_form($form, &$form_state)
{

    drupal_add_js(drupal_get_path('module', 'form_example') . '/js/test.js');

    $form['price_form'] = array(
        '#type' => 'fieldset',
        '#title' => t('Add Item'),
    );

    $form['price_form']['item'] = array(
        '#type' => 'textfield',
        '#title' => 'Item Name?',
        '#size' => 10,
        '#maxlength' => 25,
        '#required' => TRUE,
        '#ajax' => array(
            // #ajax has two required keys: callback and wrapper.
            // 'callback' is a function that will be called when this element changes.
            'callback' => 'form_example_simplest_callback',
            'wrapper' => 'listDiv',
            'effect' => 'fade',
        ),
    );

    $form['price_form']['textfields'] = array(
        '#prefix' => '
',
        '#suffix' => '
',
        '#markup' => '',
    );

    $form['price_form']['price'] = array(
        '#type' => 'textfield',
        '#title' => 'Item Price?',
        '#size' => 10,
        '#maxlength' => 10,
        '#required' => TRUE,
    );

    $form['price_form']['submit_button'] = array(
        '#type' => 'submit',
        '#value' => t('Click Here!'),
    );
    if (!empty($form_state['values']['item'])) {
        $result = db_query("SELECT * FROM {item} where item_name='" . $form_state['values']['item'] . "'");
        if ($result->rowCount() != 0) {
            $form['price_form']['textfields'] = array(
                '#markup' => 'Already exist',
            );
        } else {
            $form['price_form']['textfields'] = array(
                '#markup' => 'New Item',
            );
        }
    }

    return $form;
}

function form_example_simplest_callback($form, $form_state)
{
    return $form['price_form']['textfields'];
}

On blur of item textfield,I am showing status of item whether item_name exist in database or not.But It is showing perfectly for first time.

As it replaces a form name with 'form_name-2' after first ajax callback,it is not working afterwards.

How can I resolve this issue?

Thanks in advance


texts: How to change images without removing and re-uploading via GUI back end?

texts:
I have some images I need to change in batches on the website.

For example, I want to replace all color header images with grayscale images.

What I did was subsitute the old images with the new ones in folder:

C:\patch\sites\default\files\styles\slideshow_1920_x_700_scale\public

Now the problem is that after doing this, even if I restart the computer(using aquia dev desktop), clear all caches ect...

The color images still show up on the website, even if the grayscale ones are in the folder.

The only way to get the grayscale images to show is to go in the content item, remove the image, and reload the identical grayscale one.

Is there a way to batch do this WITHOUT having to manually remove and re-upload?

What if I had to change 1000 images...?


texts: html text or custom image to the user profile page?

texts:
On my user profile page, how do i add some extra html code or custom php code to the user profile page? as i would like to add a custom generated image based on userid in the profile page.

Please advice.


texts: How do i test wether a view inside a panel is empty?

texts:
I have a view inside a panel (node-panel).

The layout of my panel is handled in my-panel-layout.tlp.php.

Now when my view is empty It's title and fields are no longer displayed. I would still like the pane to display the view's title and the views field in the same way they are rendered when the view is not empty. To this effect, I have copied the produced html of non-empty view and included it in my-panel-layout.tlp.php.

It works but now I need a test for my tpl.php file to decide to display this hmtl when the view is emty. Something like:

 <?php   if( /*empty($myView)*/  ) : ?>

     /* my default html here */

    <?php else : ?>

     <?php  print $content['left']; ?>

 <?php endif; ?>

The problem is that in my tpl.php file I do not have access to a variable that would tell me if myview is empty. I cannot use empty($content['left']) because I have other elements in that left pane that get returned even when my view is empty so $content['left'] is never empty. Besides $content['left'] is already rendered.

How can I provide my tpl.php access to a variable that would let me test if my view was empty? Is there a preprocess function I could call?


texts: How do I rewrite Solr search results to show related entity reference field?

texts:
1: I have two node types: "Plants", and "Pests". related using a field in the plants node type called "affecting_pests".

How do I modify the solr Search result view; in the case of a Pests result, to display " name of pest==>affected plant " in the results title, and instead of link to pest page, redirect to the parent plant that the pest affects?


texts: How to disable/enable a context programmatically

texts:
I want to disable contexts programmatically (for automated updates, where a new release of a website needs a context to be disabled).

I manage contexts using Features, but Features doesn't hold the enabled/disabled status of the context.

I can't find a function to change context status programmatically. There's a support request but the snippet is not working (nothing happens, context remains the same status).

After some investigation I came across the context_status variable. It seems to hold an array with context names as key and TRUE as value: each of these contexts is disabled. If you edit that variable by unsetting one context, the context becomes enabled.

So it seems the only way to disable/enable a context programmatically is to edit this conext_status.

Is there a better way to do it?


texts:
I have the file ID (fid), and the rest of the file object.

I need to get fields from the parent media entity, but I can't find anything about loading a media entity from a file object.

Drupal 8.4.0

Update

I asked this question in relation to another: Media name as link to file

As far as I could find Kevin's comment is correct.


texts:
I want to calculate the path aliases for array of nids. But it always give me the path for latest content. Actually I can not get all the nids. My array structure is like below. When I used the command product_childnid = array_pop(array_keys($result['node'])); I always get the 100 nid but I want all of them for path aliases.

Array
(
[node] => Array
    (
        [78] => stdClass Object
            (
                [nid] => 78
                [vid] => 78
                [type] => product
            )

        [80] => stdClass Object
            (
                [nid] => 80
                [vid] => 80
                [type] => product
            )

        [82] => stdClass Object
            (
                [nid] => 82
                [vid] => 82
                [type] => product
            )

        [84] => stdClass Object
            (
                [nid] => 84
                [vid] => 84
                [type] => product
            )

        [86] => stdClass Object
            (
                [nid] => 86
                [vid] => 86
                [type] => product
            )

        [88] => stdClass Object
            (
                [nid] => 88
                [vid] => 88
                [type] => product
            )

        [90] => stdClass Object
            (
                [nid] => 90
                [vid] => 90
                [type] => product
            )

        [92] => stdClass Object
            (
                [nid] => 92
                [vid] => 92
                [type] => product
            )

        [94] => stdClass Object
            (
                [nid] => 94
                [vid] => 94
                [type] => product
            )

        [100] => stdClass Object
            (
                [nid] => 100
                [vid] => 100
                [type] => product
              )
          )
  )

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'product');
$query->propertyCondition('status', 1);
$query->fieldCondition('field_product_sub_cat', 'tid',array($leaf_nodes));
$result = $query->execute();
if (isset($result['node']))
{
  $product_childnid = array_pop(array_keys($result['node']));
}
$path = 'node/'.$product_childnid;
$product_alias = drupal_get_path_alias($path);


texts: I clone content type by using bundle copy module, but the view of the content type never the same as the first one, how can I clone the style too


texts: How do I add a prevent duplicate item RULE to my commerce site

texts:
I am learning/working with RULES in my Drupal7 Commerce store.  I thought this would be a fairly simple rule to create, but I can't find a work around for my need.  I have a commerce site, that has our team uniforms.  Each member is entitled to one and only one patch.  If they add a second patch to their cart, I want a message to appear telling them that they can only have one patch in there cart and the add to cart process stopped.

So here is the scenario.

Click the Add to Cart button for first patch, order/item/patch goes
into cart
Click the Add to Cart button for a second patch, message
appears "you can't do that" and item does not go into cart

Where I am stuck is,  what to select in the RULES UI, so it will check to see what is in the cart, look at the sku or item number [both of these are unique to the item], determine if the item that is to be added a duplicate, if so, pop up warning message, do not continue the process of adding that item.

Any help would be greatly appreciated.


texts: Need help sending e-mail with SKU, billing address, and shipping info to dropshipper

texts:
I have a product type with a term reference. This term reference lists different dropshippers. My goal is to send en e-mail to the dropshipper referenced when an order is placed.

Right now I have a rule set up to send an email to the dropshipper referenced. However, I can't seem to expose the right tokens for the email message. I need to be able to send a SKU, shipping address and the shipping info.

A few things to note:

  I am using https://www.drupal.org/project/commerce_rules_extra
  Currently, I do not have a shipping module installed. I realize this data cannot be exposed at the moment.

Screenshots:

  Rule
  Component Settings
  Component Conditions
  Loop
  Available Tokens for e-mail Message


texts: In the date and time settings I have configured globally that Monday is the  first day of the week, but this setting is is not set for views. Is there another configuration for views?


texts:
I am using drupal 7 and i have been having this issue where i am trying to add a new page onto an existing drupal site but all I'm getting is one content (the page title and some body text) displaying.all the content types which include some images that eventually build up the page are  published but are not displaying on the final live site even after clearing the cache both on admin/config/development/performance/cache and on phpmyadmin.i have also created a page--mynewpage--tpl.php page for that page.i believe i have done all the url's correctly.while adding the content types, i referenced the previous working pages just to make sure that i was filling all the required fields so as to have some uniformity within the site
What could i be missing out on, since i added the link of my new page to the page.tpl.php.
I have been trying to get a solution for this for a week now and any assistance form you will be greatly appreciated


texts: Change the Drupal Commerce checkout completion page

texts:
How do I redirect the final checkout page of my Drupal Commerce install (from checkout/%/complete) to the actual order created (user/%/order/%)?

This seems easier than having to build and theme the line items in the completion message pane, not to mention I have inserted other information to the order display.


texts:
I've installed workbench and tried to work with it. I followed the step-by-step instructions given in the video here and I was almost successful in creating the content and moderating it between the two kinds of user one is Publisher and the other is content-creator.

Content-creator creates the content and forwards it to needs-review, now the publishers gets the access to the content in the needs-review tab. And the moderation should be done between these two users.

Here, my issue is when the content-creator creates a content - he is unable to see his content in his profile (I mean either in 'MyContent', 'MyDrafts' and 'Needs review'). And the same case with the other user (publisher)- the Needs-review tab looks empty even though there is some content created by 'content-creator'.

To keep it short, MyWorkbench tab looks empty- the Needs-review tab, MyContent tab and MyDrafts tab are empty. The only way the content appears is in Content tab.

I'm not aware of workbench module, I've followed all the instructions given in the video. I'm missing any?? Please give your answers.

Thanks in advance.


texts: Creating a product page with a template file

texts:
After being a long time observer I finally have a question that I can't find an answer to. I have tried searching, both on here and on Google, but to no avail.

I am using Drupal 8.3.2 with the Drupal Commerce 2 module.

I am trying to theme a product page. I have switched twig debugging and created my own 'commerce-product.html.twig' file to overwrite the default one.

The problem I am having is that I want to be able to insert the different fields in the html using the twig template engine like I have done for custom content types on some of the pages on my site.

{{ fields.field_header.content}}

  {{ fields.body.content}}

For the example above, I created a view and a block, and within the block used the markup above to call the field values within the view.

Now that I have come to the product page I am unsure which is the correct way to proceed.

Should I create a view for a product page, or can I call the product values in a similar fashion to above. For example.

{{ product.field_product_image.content}}

Or do I need to create a view and select the fields I want to display etc. in a similar way to what I have done for my custom content types.

I have tried to search for the answer, but I haven't been able to find much help.

That's landed me here, making my first post.


texts: CKeditor not showing. 403 on ckeditor.config.js and ckeditor.styles.js

texts:
I have a site with ckeditor 7.x-1.16 installed (not the WYSIWYG module). I have a local dev (XAMPP windows) staging (Linux) and production (Linux).

On the local dev copy and the production copy ckeditor isn't showing on the edit body tag.

In firebug net tab ckeditor.config.js and ckeditor.styles.js are showing as 403 - forbidden.

I have tried replacing my local copy of the ckeditor module and the ckeditor library with the ones from the staging server where ckeditor is working. This does not fix my dev copy.

I have tried upgrading to ckeditor 7.x-1.17. I have tried a new install of 7.x-1.16. I have tried deleting the ckeditor library and downloading a fresh version. I have tried moving the library files to the alternative location within ckeditor. I have tried to increase the permissions in windows of the ckeditor module (I believe windows doesn't have chmod). I have also tried chmod 755 on the module files on the production site. None of these has helped.

ADDITION: I have have made a new local version of the Staging server version (where the problem doesn't occur). The problem is on the fresh local copy, despite it having the same files and db as the staging version.


texts: URL alias not working for costume content type page.tpl file

texts:
I a created a template file (page--cusomtype.tpl.php) for a specific content type and a node of that content type. Also I'm using Path module for create alias.

When I view the node with node/[node-id], I can see it;
when I use its path alias, I get a "page not found" error. So how to apply alias for node of that content type?


texts: How should I remove a region and zone in an Omega 3 sub theme?

texts:
I have a sub theme of Omega 3.

What is the correct way to completely remove regions and zones from my sub theme? Is it OK to just simply disable them and then remove them from the .info file?

These regions and zones are never going to be used and I want to simplfy the site by removing anything that isn't needed.

Thank you


texts:
I have a page with multiple blocks loaded asynchronously by the Big Pipe module.
I'd like to be able to run some javascript code (in my case, open an ajax popup) immediately after the page is loaded.
The thing is my javascript code (included the standard way, attached to Drupal.behaviors as a library) is executed after all the Big Pipe blocks are loaded, which takes several seconds.
I was able to reproduce this behavior from a fresh Drupal 9 install (standard) with the Big Pipe Demo module and a custom module whose only role is to include a JS file with an alert() (inside a Drupal.behavior). As expected, the alert is not displayed until the Big Pipe Demo blocks are loaded.
Any idea how I could run some JS before the Big Pipe blocks starts loading ?
EDIT :
The only "solution" I found so far is to put my JS outside Drupal behaviors and inside a setTimeout so the needed DOM is (hopefully) loaded when the code is executed... I hope I can find a less dirty way of solving this issue !


texts:
I'm creating a custom module to deliver an amalgamated news feed from various sources, all ordered by date. One of these sources is FB, and I'm having real issues with it.

I'm using fbapp module as a dependency (https://www.drupal.org/project/fbapp), so that I can use it's authentication fbapp_app_authenticate() and fbapp_graph_request() without having to worry about the constant facebook graph updates making my own code obsolete.

I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:

"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"

Here's my code:

$token = fbapp_app_authenticate(variable_get('my_module_fb_app_id', ''), variable_get('my_module_fb_app_secret', ''));
$type = variable_get('my_module_fb_query', -1); // this is "posts" in this case
$graphId = variable_get('my_module_fb_graph_id', '');
$target = "$graphId/$type";
$params = array('access_token' => $token['access_token']);
$data = fbapp_graph_request($target, $params);

As an update, here's the queries and responses it produces:

graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials

array(1) {
  ["access_token"]=>
  string(43) "<redacted>|<redacted>"
}

graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"

string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"

Does anyone know if this is a correct way to query Facebook, or if there's a better way of programmatically obtaining a page posts?


texts:
At our university we have dev/test/live versions of our sites at urls like

dev.example.foo.edu
test.example.foo.edu
live.example.foo.edu (the real live url is example.foo.edu)

There are certain Drupal site variables (values in the variables table) that need to change depending on the environment (dev, test, live) where the site is running.

The first time the site is migrated to the live environment certain site variables need to magically change from their "dev" values to their "live" values.

After that initial migration we will periodically load the live database into the dev and test sites to update their content.  When this happens I want certain site variables to change to their "dev" values.

I don't want the site builder to have to do anything.  I want the variables to simply change to the correct values.

It's okay if the site admin wants to manually override these variables.  They shouldn't have to, but there could be a need for this...

I mainly need a Drupal 7 solution--bonus if it works with Drupal 6.

Possible solutions:

Does a module exist that will do this?

I haven't found one. I've looked at

http://drupal.org/project/tadaa (incomplete)
http://drupal.org/project/context_domain (provides a url "reaction" but  context can't provide the kind of variable condition I need.  Looked at http://drupal.org/project/context_var (provides a Reaction not a Condition)).
http://drupal.org/project/strongarm (can set variables...often used with Features...)

Use hook_update_N (http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_N/7)

This doesn't meet the requirement that the site builder doesn't have to do anything. They would have to copy paste a update_71234() in some install file. They would also have to remember to run update.php in various situations.

Write a custom module?

This works:

/**
 * Implementation of hook_cron().
 */
function ucb_varenv_cron() {
    global $base_url;

    //if (variable_get('ucb_varenv', FALSE) === FALSE) {
        $parts = explode('.', $base_url);
        $vars = ucb_varenv_vars();
        $p1 = str_replace('http://', '', $parts[0]);
        while (list($k, $v) = each($vars[$p1])) {
            variable_set($k, $v);
        }
        //variable_set('ucb_varenv', TRUE);
    //}

}

function ucb_varenv_vars() {
    $vars = array(
      'dev' => array(
        'cas_server' => "TEST2.example.com",
    ),
       'live' => array(
         'cas_server' => "auth.example.edu",
    ),
    );
    return $vars;
}

Hook cron seems like a clumsy approach.  The commented ucb_varenv code was from and experiment where this would run one time only at hook_boot()--but that seemed like a bad idea.

The more I think about this, I wonder if there is some way to leverage strongarm to do what I need.


texts: How to process field input so b52 goes into database as B-52

texts:
Situation: D7 Text field on a content type.

User enters something like: b52

I want it stored in the database as: B-52

I have a function that does the regex. I just don't know where to process the input before it goes in the database.

Don't want to install Field Validation or do any validation forcing a User to "correctly" format their own data. I just want to catch their input, modify it, and save it in the database as so.

What hook do I use and can it be done in the theme?


texts: Drupal 8 & Solr 8.1: No search results, error: "The datasource with ID '' could not be retrieved for index..."

texts:
I have Drupal 8.7.1, Solr 8.1.
My Solr Server is running and my content is indexed.

But I have no results (with a query or without) in my view, and an error:
Drupal\search_api\SearchApiException: The datasource with ID '' could not be retrieved for index 'Solr search index'. in Drupal\search_api\Entity\Index->getDatasource() (line 365 of C:\Users\Oksana\Documents\sites\drupal2\modules\search_api\src\Entity\Index.php).

The function that produces this error in the indicated file is:

 /**
   * {@inheritdoc}
   */
  public function getDatasource($datasource_id) {
    $datasources = $this->getDatasources();

    if (empty($datasources[$datasource_id])) {
      $index_label = $this->label();
      throw new SearchApiException("The datasource with ID '$datasource_id' could not be retrieved for index '$index_label'.");
    }

    return $datasources[$datasource_id];
  }

As I understand, the Search API module receives no results from Solr.

If I type http://localhost:8983/solr/first_solr_core/select?indent=on&q= in browser, I get:

{
  "responseHeader":{
    "status":0,
    "QTime":1,
    "params":{
      "q":"",
      "indent":"on"}},
  "response":{"numFound":0,"start":0,"docs":[]
  }}

Which means, as I understood, that Solr has no results.

How can I find where is the problem (what happens with results after contents are indexed, and where results disappear)?

Thank you


texts: How to create store in commerce_store programmatically?

texts:
I would like to create a store in drupal commerce_store programmatically, while I am searching for a couple of hours I realize that commerce_store is a entity type. It has bundle named store. Please see image below.....I want to add new store name My Store2 programmatically under Commerce_Store entity type.

Thanks


texts:
A click event on a link with the use-ajax class on it does not seem to propagate up the DOM. Is this true? If so, is there a setting that will allow it to propagate?

Not being a JS whizz, I'm struggling to see where the call is made (preventDefault? return false?) that blocks the propagation. I've had a look at misc/ajax.js and there is a setting element_settings.prevent that looks like it might be relevant, but I haven't found any documentation on this.


texts: How can I add {% if %} for a field name?

texts:
What would be the correct way to write an {% if %}  "field_name" "is", in Drupal 8 Twig files?
I would like to add a CSS style specifically to one field and I believe this will achieve that.

Here is my current code within Twig file:

{%
  set classes = [
    'field',
    'field--name-' ~ field_name|clean_class,
    'field--type-' ~ field_type|clean_class,
    'field--label-' ~ label_display,
  ]
%}
{%
  set title_classes = [
    'field__label',
    label_display == 'visually_hidden' ? 'visually-hidden',
  ]
%}

{% if label_hidden %}

  {% if multiple %}

      {% for item in items %}

{{ item.content }}

      {% endfor %}

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

{{ item.content }}

    {% endfor %}
  {% endif %}

{% else %}

{{ label }}

    {% if multiple %}

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

{{ item.content }}

    {% endfor %}

    {% if multiple %}

    {% endif %}

{% endif %}


texts: Displaying SQL-table as a paginated list

texts:
I'm trying the following and it works:

my.module:

   function my_menu() {
      $items['page_example'] = array(
        'title' => 'Page Example',
        'description' => 'Page Example',
        'page callback' => 'page_example',
        'access callback' => TRUE,
        'file' => 'my.page.inc',
        'file path' => drupal_get_path('module', 'my'),
        'type' => MENU_CALLBACK,
      );
     return $items;
   }

my.page.inc:

function page_example() {
  return array(
    'page_example' => array(
      '#type' => 'markup',
      '#markup' => generate_list(),
    ),
  );
}

function generate_list() {
  $query = db_select('users', 'name')
    ->extend('PagerDefault')
    ->fields('name', array('Name'))
    ->orderBy('created', 'DESC')
    ->limit(20);

  $result = $query->execute();
  $output = '';
  foreach ($result as $row) {
    $output .= $row->name.'
';
  }

  $output .= theme('pager');
  return $output;
}

But then I try prepending a uid-field to each row and it fails:

  $query = db_select('users', 'name', 'uid')
    ->extend('PagerDefault')
    ->fields('name', array('Name'), 'uid', array('Id'))
    //->addField('uid', 'User Id')
    //->addField('name', 'User Name')
    ->orderBy('created', 'DESC')
    ->limit(20);

  $result = $query->execute();
  $output = '';
  foreach ($result as $row) {
    $output .= $row->uid.': '.$row->name.'
';
  }

With the error:

Recoverable fatal error: Argument 3 passed to db_select()
must be an array, string given, called in my.page.inc
on line 13 and defined in function db_select()
(line 2387 in includes/database/database.inc).

UPDATE:

On Camsoft's comment (thank you) I've modified the code to:

  $query = db_select('users')
    ->extend('PagerDefault')
    ->fields('name', array('Name'), 'uid', array('Id'))
    //->addField('uid', 'User Id')
    //->addField('name', 'User Name')
    ->orderBy('created', 'DESC')
    ->limit(20);

And now it fails with

DOException: SQLSTATE[42P01]: Undefined table: 7 ERROR:
missing FROM-clause entry for table "name" at character 8:
SELECT name.Name AS Name, created AS created FROM {users}
users ORDER BY created DESC LIMIT 20 OFFSET 0; Array ( )
in function PagerDefault->execute() (line 80 includes/pager.inc).

I'm just trying to figure out how to add a 2nd SQL-table field to a paginated db_select... Please do not suggest a "View" to me, because I'm trying to understand DBTNG at the moment.


texts:
Stumped. This should be Drupal 101, but the dots aren't connecting.

Scenario: from among many, I have two content types:

employee
department

Each content type displays on its own but we will also run a list of employee teasers as a  list within a views block on the department pages. This is easy to create: I use views to render the list, i.e.,

View uses filter criteria of "department" for a teaser list of employees.

Set the views block to display on the appropriate department node page on the blocks admin page and all is good. However, I have 7 department pages. Sure I could create the first view, clone that view per required filter type, but, better, is reusable code. Both content types have the same "department" field list (uses the core list module) where I've identified the department.

How can I use that "Department" list field to create the link that joins the employee list to the department when rendering the department page?


texts: Programmatically translate a string in hook_update_N()

texts: Is there a function I can use to perform a string translation in hook_update_N()?


texts: how to put permission to only paid users can print something in my drupal site

texts: I have a Drupal site which I plan on putting a print pdf function to its contents. How do I manage this so that only paid users can print the pdf?


texts: How to alter country dropdown in location module?

texts:
I have been researching a way to limit the available countries in the drop-down that comes with the contributed locations module. I think hook_form_alter() is the way to handle just showing certain countries, but starting a hook_form_alter() snippet from hand is not something that I have the ability to achieve. After much googling I have not been able to find a code snippet to get me started.

A project I am working on now only allows registrations from the US and Canada, so I want to limit that drop-down to just those 2 countries. The function that calls the country list is location_get_iso3166_list() and the array is $countries. The location module is being used to populate pieces in the Content Profile module.

I have found a couple posts online that suggest just commenting out the countries that are not needed in the .inc file; this is not an option for this project as we are on a multi-site set-up, so changing it in the module will affect other sites. I think I need to add a hook_form_alter() snippet to the template.php.


texts: How to alert users that they have a survey / webform to complete

texts:
Using D7 with the latest version of webform.  We have created several surveys and all is working fine, but a question came up in a meeting, is there an easier/automated way of sending emails to the specific users that need to complete the survey.  What we do now, is create the survey, save, then go into our email client and send out a note that a survey is ready for you to complete at whatever url.

We would like to click a button "send survey url to:" and then add the email address of the user who needs to be alerted of the availability of the survey.  They would jsut click the link and be taken to the the survey.


texts: When to use a new field on the user account or a custom table and when use user.data service?

texts:
Is there any rule when to use a new field in the user account for storing information and when to use the user.data service?

My initial approach was:
When the information should be editable either by an administrator or by the user itself, then use a new field. When the information should not be editable, only by code, use user.data service or a custom table.

E.g. in my case I am storing some information about where the user came from (marketing campaign) and some other information gathered during registration. This information is not meant to be shown to the user or edit by the user. Thus I decided to use the user.data service.

Now I am experiencing a very fast growth of the user_data table and I'm wondering whether my approach was correct. Maybe I should have created a new table for this or use a new field in the account.

Is there any rule when to use the user.data service and any limitations?


texts: Calculate shipping cost by weight in Drupal commerce

texts:
I've set up a commerce website and I'm trying to calculate the shipping rate.

I have 2 shipping rates: a standard rate and a secure rate.
Now I need to increment the price of both these rates by 2 euros if the weight of the total order is over 2 kg's (or 2000 grams since the weight is shown in grams).

I followed Randy Fay's tutorial: http://vimeo.com/33838479 but he multiplies the cost by an amount and this is not what I need.

Another related question (calculate shipping by weight) is a little closer but I do not need a cost per pound.

I've tried to create rules to achieve this, but I really don't know how to do any of this.

I also added this patch in an attempt to get things working properly.

Right now, I can't figure out how all the pieces fit together, I'm sure I have everything I need but I could use some help putting everything together.
Can someone guide me in the right direction?


texts: How to Integrate Non-Gregorian Calendars in Calendar Module?

texts:
I plan to create a simple event calendar on Drupal 7 that uses the Arabic Calendar (Hijri) instead of Gregorian (western) calendar. Instead of developing a new module, I was wondering if I can use the capabilities of Calendar Module and make it use Hijri Calendar instead of Georgian calendar in views and in the calendar template. The mini-calendar should be Hijri Calendar. No need for Month or Year calendars.

There is a module called Calendar Systems that adds the support of Hijri Calendar to Drupal but I'm not sure how it can be integrated with the Calendar Module or Views.

What are my options?


texts:
I am creating Drupal 8 node using code and same time I am assigning a menu link as well its working fine. I am creating a menu using this code.

MenuLinkContent::create([
        'title' => $item['title'], // Menu title is your title of menu, in this case node title
        'link' => ['uri' => 'entity:node/' . $value->entity_id],
        'menu_name' => 'main',
        'expanded' => true,
        'parent' =>"menu_link_content:".$parent,
        'weight' => 0,
      ])->save();

Its working fine for me.
but I am not getting how to update these menus. Because its adding duplicate menu items when I am again creating node.


texts: How to loop through fields from the Field Collection?

texts:
Here below is the code loading data present in the field collection.
$field_collection = entity_load('field_collection_item', $ids = FALSE);

In each field collection, there are many fields, i would like to loop through each fields
is there a way to do it? Any help?


texts: "Accept answer" button for Advanced Forum comment

texts:
I have a forum using the Advanced Forum module in which users ask questions. I want to add a button next to responses, so that the poster of the question can accept one of the answers (in fact, just like this forum works). I then want that post to appear highlighted as being the correct answer.

I realise that Flag is the module to use for this functionality, but I'm not sure how to make the "Accepted answer" appear to all users when the node owner flags the comment, when they are not owners of the original comment. Any ideas about how I can implement this functionality?


texts: Flags: flagging unflagging rules, how to check if an user has already flagged a node?

texts:
I'm using Drupal 7 and I created 3 flags for article content type; these flags are global flags: bad, nice and cool. Now, I want create a rule in order to check if an user has already flagged an article.

For example: a user flags article as bad.
Now the user wants to flag the same article as nice.
Theoretically, the user must unflag bad and flag nice.

I want a rule that check if the user has already flagged a node; if yes, the previous flag must unflagged.

In Rules there are Rules Conditions that can execute php code, but flag api, has a $flag-is_flagged function that checks if an user flagged a node only if the flag is non-global flag.

Any idea?


texts: jQuery plugin isn't reacting in Drupal site

texts:
On this page i try to implement PrettyPhoto jQuery lightbox plugin for my Bootstrap 2 website. However the images are not appearing in the lightbox? It looks like the jQuery plugin isn't reacting?

The jQuery file i use are:

jquery.prettyPhoto.js

and before my closing body i use:

(function ($) {
    $(document).ready(function(){
        $("[rel^='lightbox']").prettyPhoto();
    });
})(jQuery);

Do i also have to adjust something in the jQuery file jquery.prettyPhoto.js to work in Drupal?

Update:

I solved the problem! In the <a href> it needs the attribute rel="lightbox[group]". But in Drupal Configuration » Content authoring » Text formats i had to add the  to Allowed HTML tags and turn Add rel="nofollow" to all links OFF. This solved the problem!


texts: how to show file counter using file_download

texts:
This is a beginner question, in file_download module. I have installed it and then I followed Install Instructions. But I couldn't figure out how to show the counter or statistics_popular_block, I tried to create a new view but didn't get any thing. I am new to views.

When I look to the source code I can see things such like:

src
  FileDownloadSettingsForm.php
  Plugin
     Block
         FileDownloadPopularBlock.php
     views
         field
             FileDownloadCounterTimestamp.php
             FileDownloadNumeric.php

any help?


texts: Module compatibility between major Drupal versions

texts:
I am planning to use Drift chat on Drupal website, which is built in Drupal 7.

I could see Drift modules only for Drupal 8? Will this work with Drupal 7 as well?


texts:
I've added the search block to my fixed navigation bar at the top of the page (the nav bar is fixed when you scroll the page). The problem is that searching for the term leads to no where. When I enter a word in the search field and submit, the page simply refreshes and no search page results is shown.

The search block is placed in a region I created that goes in the fixed nav bar, which is a php include in a separate php file.

The address bar brings up the following query.

  /?search_block_form=regardless&form_build_id=form-z5VjHhWMMLVlbCpugfuhle7ETfQxjhL9vCmIGq9ZdW0&form_token=c4WPVTbY1GKQOXvFraDuX9e7Nn-41wQWYiS3zJ-jkJs&form_id=search_block_form


texts: how can add external php function or class to theme file?

texts: As I asked above, is it possible to add or include externally written classes or functions files to drupal theme files e.g 'theme_name.theme' file?


texts:
I have set an ajax callback to a form using the form api #ajax. I also have custom jquery in a file which styles part of the page and sets click handlers. I found something funny - my custom javascript only begins working AFTER the ajax has been called on the drupal form. Before I that form api ajax is called, it doesn't work.

Why would this be?

EDIT:

I am attaching my behaviors like this:

(function($) {
  Drupal.behaviors.updateCart =  {
    'attach': function(context) {
    $(document).ready(function () {...

This file is being included inside of my modules hook form alter:

if($form_id == 'commerce_checkout_form_checkout') {
  drupal_add_js('sites/all/modules/my_subscription/js/updateCart.js');
}


texts: How do you get a node ID from an order in ubercart?

texts:
How do you get a node ID from any of the products in an ubercart order?

I'm trying to get the product author's (uid) from the order as shown below

The order will only contain nodes/products by the same author so a node ID from any of the products in the order will do.

$sid = db_query("SELECT uid FROM {node} WHERE nid = :nid", array(':nid' => $product->nid))->fetchField();

$seller = user_load($sid);


texts:
I am using ckeditor module and for file browser I selected the ckfinder module. When I click on browser server ti shows the page not found in ckfinder popup.

I have checked the permissions and matched the config.php with other site. When I check the browser console, I found the below issue :

  Failed to load resource: the server responded with a status of 404
  (Not Found)
  http://example.com/sites/all/modules/ckeditor/ckfinder/core/connector/php/connector.php?command=Init&type=Images&id=Full


texts: How to properly restrict node access (including update/delete) based on field value?

texts:
I have following requirements:

Users have (among others) role "tier1", "tier2" or "tier3". Higher value means more permissions and anonymous users are considered "tier0".
Users from tier2 and tier3 can create certain node type - MyNode. And only these users can update and delete them.
The node type MyNode contains (my custom) field for restricting access - it's a simple integer. 0 means all users can access it, 1 means users of tier 1-3 can access it, etc.

What's the proper way to implement the node restriction?

What I tried & longer description of the problem

After Googling and reading documentation, I found hook_entity_access. I simply iterated all fields and if I found my access field type, read the value and handle it. It was working pretty nicely for viewing, editing and deleting. But not for views - they completely ignored that.

After some more googling, I found that hook_entity_access/hook_node_access are ignored in views as explained on Node access rights. This page also explains that this problem should be solved by using  hook_query_TAG_alter, however I can't understand how it should be used. It seems to me I'm missing some bigger picture and failed to google it. But I found another solution - to use hook_node_access_records with hook_node_grants. I implemented this solution (with a tutorial help).

So each instance of MyNode provide grant based on field value, e.g. gid 2 means tier 2-3 can access the node. Each user is given grants based on their tier role, e.g. user with tier1 receive grants with gid 1, 2 and 3. This fixed view problem, but caused another one - if I set access of a node to 3, then users of tier 0-2 cannot view it (that's correct), but user of tier 2 can edit it (that's problem).

After some testing, it seems like permissions are handled differently for view and update/delete. View grant permissions are AND-ed with basic permission system (/admin/people/permissions), but update/delete permissions are OR-ed. I used the basic permission system to determine which roles can generally create, update and delete MyNode nodes.

So my current solution is merge of both approaches - grant system for views and hook_node_access for working with nodes directly. However, it seems to me quite hacky, dirty solution - I practically implemented same thing twice in different systems, because each system can handle only subset of all operations. And so, my question is - what's the proper implementation? What is correct Drupal-way?

Note: of course, I looked at modules to solve this. I rejected most of them, because they're still in alpha/beta/rc phase, while lifetime of D8 is ending. How much time I would have to wait for D9 implementation? Others were imho too bloated for "simple" "compare numeric value with role and accept/reject".

My system: Drupal version: 8.8.3


texts: Drupal 7 - Profiles 2 Module - Share profile data or migration

texts:
I'm making a platform for 2 types of users:free and paid.

The issue I encounter is the data of the users when updating from one profile to another.

If the user has "free" profile he gets some fields, but when updating the "paid" profile has the same fields+extra.

I first thought of showing the "paid" fields as an extra to the "free" (so the users with "paid" profile have both "free" and "paid" profiles assigned to them), but the issue appears when the user wants to create the profile directly paid as he has no option completing the "free" ones only after he has registered.

Is there any way to make the fields autopopulate (when completing the "field_1" in "free" the data to apear in "field_1" in paid)?
Or to make the data viewable cross multiple profile types?

Conclusion:I need a way for the data to ve visible cross profiles


texts: How to prevent users editing their profile, but allow password change?

texts:
I have a Drupal 7 site that has additional fields added to the user profile page, to capture additional information (with these fields then displayed on the public-facing profile).

Only administrators should be able to edit non-admin profiles.

However, I am using !login_url (one time login) functionality in email confirmations to allow new users to set their own password and I need to retain this feature.

I have installed the User Protect module, but unless I enable the 'Edit own user account' permission, the one time login link returns a 'You are not authorized to access this page' message and the password cannot be entered.

Is there a way via User Protect, another module, or via custom code for me to retain the Change Password option, but remove access to all other fields that have been added to build a more complete profile?


texts: Why doesn't composer install drush on $HOME/bin directory?

texts:
I'm trying to learn to to use drush.

I installed composer to my $HOME/bin/directory:

$ ls ~/bin
composer  composer.phar  subl  sublime  sublime_config.sh  sublime_text

Then I tried to install drush globally:

$ composer global require drush/drush:dev-master
Changed current directory to /home/nnieto/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing pear/console_table (1.1.5)
    Downloading: 100%

  - Installing symfony/yaml (v2.2.1)
    Downloading: 100%

  - Installing d11wtq/boris (v1.0.8)
    Downloading: 100%

  - Installing drush/drush (dev-master 31fa220)
    Cloning 31fa220c9ee33a250d135ad0d65b5b6c92c6c188

pear/console_table suggests installing pear/Console_Color (>=0.0.4)
drush/drush suggests installing youngj/httpserver (dev-master#41dd2b7 as 1.0.1)
Writing lock file
Generating autoload files

I expected to find a drush file on ~/bin, but instead I got a nope from Linux:

[nnieto@localhost ~]$ ls ~/bin
composer  composer.phar

What am I doing wrong?


texts:
I have tried to create a hook that deletes an entity of type notification when the entity of type deadline is deleted, but the hook never gets called. Entities of type notification have one referenced entity of type deadline.
 I have tried to clear the cache several times but without any luck. Am I missing something?
 /**
   * Implements hook_entity_predelete().
   *
   */
  function dib_notifications_entity_predelete(EntityInterface $entity) {
    if ($entity->bundle() == 'deadline') {
      $array = \Drupal::entityTypeManager()
        ->getStorage('node')
        ->loadByProperties
        (['type' => 'notification',
          'title' => $entity->label()
        ]);
      $notification=reset($array);
      $notification->delete();
    }
  }


texts:
Will try to be brief.

I have a node with "n" images asigned to it, now i want to add new images (and keep the currents) to the node, i've  tried this but no success until now. The next code does nothing:

$node = Node::load($node_id);
$node->field_car_picture[] = $new_images;
$node->save();

Also tried this and removes the current pictures and leave only the new images:

$node = Node::load($node_id);
$node->field_car_picture->setValue($new_images);
$node->save();

Any help will be appreciated


texts: Webform in block allowing clicking on send button and redirecting to page view, without validation the fields even when they are empty

texts:
Webform in block is allowing to click on send button and redirecting to page view, without validation the fields even when they are empty.

so if I come to the website and click on submit (on my form in block) instead of validationd and showing the little popup it redirects me to the form page view url.

But when I start typing something in my email fieled, then after clicking on submit I get a popup that email is in wrong format etc.

How to correct the behavior so that the popup shows the message like "the field is empty" etc.

Is it a bug of webform or am I missing something?


texts:
I have a link http://examplesite.com/my-site#userid. Only authenticated users have permission to view this link. If unauthorized users follow this link I have created a redirect using drupal_goto('another-page'). But the unauthorized users are now being redirected to http://examplesite.com/another-page#userid. The userid part is not removed. Could someone help me with this.Thanks

When I go to http://examplesite.com/my-site#userid the following function is being called:

function my_page() {
    if($user->category == 0){
            drupal_goto('another-page'); //user gets redirected to http://examplesite.com/another-page#userid
    }else{
              //Corresponding code
    }
}


texts: In views, how do I show posts from this calendar day, ten years ago?

texts:
I have a view in which I want to display posts that I made on this date 10 years ago. I can get close but not exactly what I want by setting the view's filter  to the following:

"Authored On is between: (offset) -10 year and -10 year +1 day"

My problem is that if it's currently 1pm on Dec. 17, 2019, I want to see all posts from the Dec. 17, 2009, regardless of hour posted. Instead I am seeing posts from Dec. 16, 2009 1pm to Dec. 17, 2009 1pm. I don't care what time the post was authored at, I just want it to show if the calendar day from 10 years ago is the same.

How can I set up my filter to do this?


texts: Manage media per user without using the Media Manager widget

texts:
In Drupal 9, I have users loading audios into their profile.
When logged in, users should only see their private audio media in the media manager.
This works well with a contextual filter, as long as you are in the media manager. But on the user edit page it doesn't work well, because the media manager widget wont work with the same contextual filter, as the global media manager view.
On the User edit page the ideal version would be a regular upload field (as one would have for a file), which loads the audio into the media library as a media entity. And a simple list of the audios already uploaded. A simple way to manage only 'my' files on 'my' user edit page without using the media manager widget.


texts: How to export Roles and dependent selected permissions using Feature module?

texts:
I have created some roles and permissiones. I have set dependent permissions to roles. Now, using Feature module, i am able to export and import created Roles and permissions, but not dependent permissions on role accordingly.

Is there any way to do this? or any best module?


texts:
I am trying to run a batch job of importing items from a csv file. When I click submit on my form and my batch process starts, I do get a batch process bar which says its progressing, but it never calls my callback function or my finished function. I've done a dpm() of th $batch array before I run it, and it seems to be in order. What am I missing?

$count = 1;
  while($count <= count($csv) ) {
    $operations[] = array('ons_institutional_subscriber_importer_import', array(array_slice($csv, $count, $count + 10)));
    $count = $count + 10;
  }
  $batch = array(
    'title' => t('Importing Institutional Subscribers'),
    'operations' => $operations,
    'finished' => 'ons_institutional_subscriber_importer_finished',
    'init_message' => t('Import is starting.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Import has encountered an error.'),
  );
  dpm($batch);
  batch_set($batch);
  batch_process();

and my callback functions

function ons_institutional_subscriber_importer_import($csv, &$context) {
  dpm('hello');
  //more code here...
}
function ons_institutional_subscriber_importer_finished($success, $results, $operations) {
  if ($success) {
    $message = format_plural(count($results), 'One post processed.', '@count posts processed.');
  }
  else {
    $message = t('Finished with an error.');
  }
  drupal_set_message($message);
}


texts: filter condition based on the date range

texts:
I want to create view with filter condition like i should able to mention the date range for a particular field filter condition and should able to filter the field based on the date range.

Ex: In the fig ,i want to filter ID of Person based on the date range as shown in the figure.here i am trying to get all the updates like what and all changes done for that particular id From date to To date.please if anyone know how to achieve this let me know..! as of now i am trying with multiple ways but no luck.any idea...will be appreciated.
Thanks in advance.


texts: Programmatically insert commerce stock failed

texts:
I am using this code to insert the commerce stock but it fails some how:

$cp = commerce_product_new($product_type);
$cp->is_new = TRUE;
$cp->revision_id = NULL;
$cp->uid = 1;
$cp->status = 1;
$cp->created = $cp->changed = time();
$cp->sku = $product_sku;
$cp->title = $product_title;
$cp->language = LANGUAGE_NONE;
$cp->commerce_price = array(LANGUAGE_NONE => array( 0 => array(
   'amount' => $product_price,
   'currency_code' => 'GBP',
)));
$cp->commerce_stock[LANGUAGE_NONE][0]['value'] = 10;
commerce_product_save($cp);

I checked on the documentation using:

$cp->commerce_stock[LANGUAGE_NONE][0]['value'] = 10;

should do the trick, but strangely its not updating. Am I missing anything? All the rest is working except the stock.

thank you


texts: Where to put a script to provide AJAX/JSON response?

texts:
I'm using drupal 7. I want to create a php script that uses Drupals DB abstraction layer to query the database and spit out JSON data.  Where would I place such a script?  At the moment, I've done it in a round-about way by create a new node, then in the function theme_process_page() of my theme/template.php, I wrote an IF statement to detect the node id, then run my code, then call a die() statement.

Is there a more appropriate place for me to put this script?

** additional notes **
This script is to be called every time a person presses "Provide a menu link" when adding/editing a node in the CMS.  The script will then automatically select the appropriate Parent Item and weight based on any other existing translation.


texts: Adding a Select List (Text) field to an entity bundle programmatically

texts:
I've been searching for hours, but can't seem to find a solution to this. Now, I'm able to create a plain old text field as such as this:

In moduleA.install:

if (!field_info_field('field_myfield')) {
  $field = array(
    'field_name' => 'field_myfield',
    'type' => 'text',
  );
  field_create_field($field);
}

Then, in moduleB.install, I add that field to a specific taxonomy bundle:

$instance = array(
  'field_name' => 'field_myfield',
  'entity_type' => 'taxonomy_term',
  'label' => 'MyField',
  'bundle' => 'new_terms',
  'widget' => array(
      'type' => 'text',
  ),
);
field_create_instance($instance);

What I would like is the field it creates to be a select list, instead of just a text field. I've been looking around, trying to figure it out (using "list-select" in place of type), but any time I've deviated from what's above, I get an error on field_create_instance when installing moduleB. I realize it's probably (hopefully) something as simple as knowing the proper widget name, but I either can't seem to find it, or am searching for the wrong thing.


texts:
In my block i have different taxonomy term:
term A
-term B
--term c
---term D
when i am on term b it is set to active or bold if i am on term d then it is set to active and bold.
this is already been used
$options = array();
if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(2) == $t->tid) {
    $options = array('attributes' => array('class' => 'active'));
}

i am new in drupal anyone tell me how it is possible?


texts: How to use values from a referencing node (parent) in a referenced node (child)

texts:
On a Drupal 7 site, we have two node types, one called "Collection" (parent node type) and one called "Fabric" (child node type). Collections and Fabrics are connected through an entityreference field.

We want to have a pair of values defined on the Collection node, which is then selected in various combinations for each Fabric node. These are "Colorway" and "Design". We'll define for example 3 Colorways and 8 designs for a given Collection. And when we create each Fabric for that Collection, we will choose one Colorway and one Design - there is always one value from each as a pair.

Most of the time, these values will be defined when creating the Collection node. But occasionally, we will want to add a Fabric node independently. If the needed value (e.g., the new Fabric's colorway) does not already exist, we want to be able to add it via the Fabric node/add form and have it saved back to the Collection so that the value collection's value list remains in sync.

We're wondering what the most future-proof and scalable way to build this would be. We couldn't find any ready-to-go modules to do this. We considered using taxonomy, but it doesn't seem like a good fit (though it does feel like it should be some kind of node-centered taxonomy). It feels like this should be done with fields (and some custom code to do the synching), but maybe a different approach is better?


texts: Profile 2 Not showing fields on user edit page

texts:
I install Profile 2 module and create separate registration page.
after login with this user
not showing that fields on edit user page
Can any one help me in this


texts: Adding conditional statements to custom text fields in views

texts:
I have custom text fields set to display two items as follows:

  [field_title]: [field_subtitle]

Is there a way I can get rid of the colon if the subtitle field has no value? via php or javascript?


texts: Filter on the count of a term reference field

texts:
I am trying to filter a view on the count of a term reference field.

Users submit a node of type Write Up. One of the fields is an entity reference of Employee and another is a term reference of Reason. One of the terms in the Reason vocabulary is Absence.

I am trying to create a view that shows all Employees with zero Write Ups of Absence.

My view is showing all Employees with a relationship to the Write Up. My thought was to add a filter of COUNT of Content: Reason = 0. However, I can only select the term or aggregate. I cannot seem to do both.


texts: How to set a rule that sets a term reference field value and text area value in a commerce order entity

texts:
This relates to a post I made here How do I copy a "purchase limit" field from a product to a product line item

Situation:
We are building a commerce website using Drupal 7 and Drupal Commerce for a government agency that distributes free publications

They have a limit on the number of free items that can be ordered at once, (unless the person ordering has a good reason.)

We have a field called copy limit on our product entities.

If the user enters a quantity on the” add to cart “for that exceeds the copy limit, we want the order to go into a holding area after the order is completed for further review.

Our plan is to use a taxonomy term to do this. We have a vocabulary called "Is this a bulk order?" It has two terms, yes and no.

We want to have it so if the quantity in one of the line items in a customer's order exceeds the copy limit, the term reference field for the "Is this a bulk order" vocabulary is set to yes.

Also (I'm not sure if this belongs here but....)

In a related question, we are trying to get the user fill out a field if the copy limit is exceeded explaining why they need to exceed the limit. We have a field on the order called "Bulk Order Explanation"

Right now, I have rule that after saving a new line item, and the quantity exceeds the copy limit, the user is brought to a add content page for a content type I called "Bulk Order Explanation"

What we want to happen is that after they save the "Bulk Order Explanation" node, the body of the content type is used to populate the bulk order explanation field.

I am not even sure if I am headed in the right direction on either of these things.
Thanks for any insight you can provide!


texts:
I must use Drupal 5.10 for one project. It's already done, but I am doing some changes, so I must add this line to each node:

  Viewed: 3 | Total views: 30

I know I must use the Statistics module, but I cannot find one for Drupal 5. Can anyone help me please?


texts: create text box search for multi select field in view

texts:
I have a custom content type in my drupal installation called Stores. While creating a new content for Stores I have a checkbox where I can select multiple zip codes.

I have created a view with my store listing and I want to add an option for the user to have a text box where s/he can enter a zip code and the store list gets filtered based on this. I have exposed the zip code field as a filter in the view. However since this is a multi-select field the filter shows up as a drop down to the user instead of a text box. I want a empty free-flow text box instead of a drop-down with all the zip codes in it.

I really appreciate any help or pointers regarding this..


texts: Using module_invoke() and render() causes PHP warnings

texts:
From within a block, I've used the following PHP to add additional blocks inside it:

$content_search = module_invoke('search_api_page', 'block_view', 'content_search');
$user_search = module_invoke('search_api_page', 'block_view', 'user_search');

print render($content_search);
print render($user_search);

When I do so, I get the following warnings:

  Warning: Invalid argument supplied for foreach() in element_children() (line 6541 of /var/www/mysite.dev/public_html/includes/common.inc).
  Warning: Illegal string offset '#children' in drupal_render() (line 5998 of /var/www/mysite.dev/public_html/includes/common.inc).
  Warning: Illegal string offset '#children' in drupal_render() (line 6008 of /var/www/mysite.dev/public_html/includes/common.inc).

It appears that the problem is tied to the render() function as I can call print_r($content_search) and everything looks good, but I can't render the blocks without these warnings.


texts:
I try to create something like questionnaire using views exposed filters. I have a content type xxx with fields:

field_1 (with options a,b,c)
field_2 (with options a,b,c)
field_3 (with options a,b,c)

I have 9 nodes, each containing only one option (node_1 has only "a" option from field_1 selected, node_2 has only "b" option from field_1 selected etc... so together 9 nodes)

Task: User chooses from 3 dropdown lists. For example choices are (field_1 - a, field_2 - a, field_3 - c)

I need the result to contain :

node that has field_1 with option "a" checked
node that has field_2 with option "a" checked
node that has field_3 with option "c" checked

Is this possible to acheive using views filters or I need another solution? I would like to use any views solution  Thank you.


texts: How to display comment form and comments per node in a view

texts:
I am trying to display comments + comment form per node in a view of nodes following this answer. So I'm trying full content display with row style options, which works perfectly on another site I am working on, but on this one, I don't have the "Display comments" toggle box

So I have reinstall the site and disable every thing I could : contrib modules / themes and templates / custom code / libraries / fields & comment fields / all content types trying with new ones / uninstall & reinstall comment modules / combination of permissions for all/just admin in view-post-skip options. Still nothing.

Anyone has seen this before?


texts: A change in the production site affects test and staging sites and vice versa

texts:
I have a production site like www.example.com and I use 2 subdomains test.example.com and stage.example com for testing and staging purposes. Each of these 3 versions of the site uses it's own database. The user and password is the same for all 3 databases, but of course the database names differs. I have checked and double checked that the correct database names are set in the settings.php file for the 3 sites, respectively.

Nevertheless, when I do a content change in one of these 3 site versions, that same change becomes immediately visible in all 3 sites.

I have tried to turn off all my caching modules, like Boost and Memcache and Content.

EDITED:
I have now narrowed it down to a caching problem. If I flush all cache in the site that shows the wrong content, it reverts to the right content. So content changes ends up in the right database. But as I said, even though I have all caching turned off, and all caching modules are disabled, all content changes in one site are immediately reflected in the 2 other sites (until I flush all cache in these 2 other sites).

Does anyone have an idea about where to look? Some common caching in the server environment?


texts: How to render the feed display of a view as an xml file to download?

texts:
I have created a custom entity. I have used a controller for view_builder.
"view_builder" = "Drupal\mymodule\Entity\Controller\MymoduleViewBuilder"

MymoduleViewBuilder.php
class MymoduleViewBuilder extends EntityViewBuilder {

  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
    $view = Views::getView('rss_feed');
    $view->setDisplay('rss_feed');
    $view->execute();
    $render = $view->render();

    $result = \Drupal::service('renderer')->render($render);
    return ['#markup' => $render];
  }

}

I also tried:
print $render
drupal_exit();

But this is also not working. Can someone puts me in the right direction?
Or do I need create another route for that? but the question is still, how will I download the feeds view as xml file?


texts:
I'm trying to make the user creation form redirect back to the home page when you submit it. I'm using Content Profiles so it is two forms sharing a submit button. Even if I set #redirect = '/' on both forms the form always redirects back to itself. It works and everything, but won't redirect how I want.

Any ideas?

Code:

function mymodule_form_alter(&$form, $form_state, $form_id) {
      switch ($form_id) {
        case 'user_register':
        $form['#redirect'] = '/';
        break;
        case 'coordinator_node_form':
        $form['#redirect'] = '/';
    }
}


texts:
I have block template. How do I output this block on front page just by calling render($page[region_name]), where region_name is the name of a region to which the block is assigned.

Edit: I want to print the whole region assuming it contains only this block.


texts: As a module developer, how do I handle outputting user defined strings with regards to translatability?

texts:
A module I maintain is introducing the ability to customize some messaging that is output to users on the site. Up until now, that messaging has been hard-coded and output using the TranslatableMarkup class. I'm now allowing these strings to be customized in configuration.

Is it still appropriate to just dump whatever the configured string is into the TranslateMarkup class? It seems like I should not do that.

I found this old core issue that seems to be related to what I'm discussing, but there's no clear conclusion on what to do.


texts: Refactoring an entire site without reinstalling

texts:
I don't know if this a strange question ;)

I've a site, based on Drupal 7, core and all modules are updated and everything is managed with features (and obviously custom code for theme and some modules).

I've started it some years ago, now I've learned many things. There errors, too many modules, etc.

I would like to refactor it, preserving:

users
nodes (and so revisions), but refactoring some fields
taxonomy and terms

Now, the question is: what do you suggest?
I see two ways:

create a new drupal installation, with content types, taxonomies etc, and so migrate contents, terms, files and users from old site to the one. So I should have to create views, etc etc. Thid way could be simple because I've "only" to manage contents migration, but maybe I'll lose revisions
work on a new branch (code on git), remove old features, recretating theme, removing everything that are not useful etc, with new configurations. This could be an hard work, but it preservs contents, etc.

Is there another way?

Thanks for suggestions :)


texts: How to add gratuity when a commerce cart is updated?

texts:
I need to add a gratuity to my site when user add a product to a cart. The function is the same to the ioby.org site. Each time the cart is updated we will update the gratuity on the cart. I have read the solution for this function from newsignature who developed this site but it's hard for me to using rules to do it. Anyone can help me? Thanks so much!

Here is the solution from newsignature:

  Gratuity was at first going to be a tax type in the Commerce system.
  However, one of the requirements was to also give the user the ability
  to remove the gratuity if they felt that they didn’t want to cover the
  costs for it. Since tax isn't usually an optional item in shopping
  carts, the ability to remove it has not been placed in the Commerce
  tax module.  To enable that ability, we place the gratuity into a line
  item that is calculated every time the cart is updated. Once again we
  used the Entity API to generate a new product, and this time the
  gratuity type that has an individual SKU, and a price that is a
  percentage of the order total. Another custom feature we added was to
  show a popup message when a user removes the gratuity, explaining to
  them the importance of gratuity for ioby.  Since the view doesn’t
  discriminate between the different line items, it was necessary to use
  some front end javascript that handles this feature.  And of course,
  with items being added and removed from the cart, it was necessary to
  change the price of the gratuity on the fly, assuming it wasn’t
  removed.


texts: I edited the database but the site's showing old content no longer in it

texts:
I needed to find-and-replace text across several nodes in my database, so I exported it via PHPMyAdmin and then ran the find-and-replace on the resultant .sql file. I then dropped all tables in my database and imported the edited .sql file. Now when I inspect my database with PHPMyAdmin I see that the text I removed with the find-and-replace is no longer there; however when I view or edit a node with the text I've replaced I see the replaced text still there. This is despite the fact that if I search for that text in the .sql file I imported (or a fresh .sql export after the import) I don't find it anywhere.

Why is this? How can I fix it, and successfully find-and-replace text in my site with the method above (or some better method, though that's slightly changing the question)?

Example

If you view source on http://gwwc2.centreforeffectivealtruism.org/node/546 you'll see at the start of the node content:

<style type="text/css"> <!--        @page { margin: 2cm }       P { margin-bottom: 0.21cm }         A:link { color: #2198a6; text-decoration: none }    -->     </style>

However when I run SELECT body_value FROM field_revision_body WHERE entity_id=546 (which seems to be the right query as I'm using D7) I don't see this anywhere in what's returned, which instead starts:

<p>A perennial criticism


texts: How to make a table sortable by CCK field

texts:
An odd question: I have a custom column added to the default admin/content page that shows the value of a CCK field "field_foo". I'm trying to sort the table by this field. (I can't use Views for this unfortunately). This is what I have for the header:

$header = array(
  'title' => array('data' => t('Title'), 'field' => 'n.title'),
  'foo' => array('data' => t('Foo'), 'field' => 'n.field_foo', 'sort' => 'desc');
)
$query = db_select('node', 'n')
   ->extend('PagerDefault')
   ->extend('TableSort');
node_build_filter_query($query);

I also tried the name of the field as declared in the $rows, ie...

'foo' => array('data' => t('Foo'), 'field' => 'n.foo', 'sort' => 'desc');

This results in a link at the top of the Foo column head, but when I try to click on the link to sort Asc or Desc it doesn't really work and the Foo values aren't ordered in the requested order. If anyone has any suggestions I'd really appreciate it.
Thanks!


texts:
When debugging I prefer using the Devel module because of the clickable Krumo output.

However when disabling the Devel module on production unremoved calls to e.g. dsm() can cause a WSOD because of calls to undefined functions.

By using the built-in debug function this does not happen but it will miss the nice krumo output.

Is it possible to get krumo output with the debug() function / or otherwise prevent the WSOD on production sites when using devel functions?


texts: How to upload files which are other than English names?

texts:
In Drupal, how to upload files which are other than English names?

The problem I am facing is that when I upload files for which their name is other than English their name changes to an unknown format in the file directory, like:

áˆ¾áŒáˆ®á‰½áŠ“ áˆ¨á‹³á‰µ á‹¨á‰µáˆá áŠ á‰ áˆ  áŠ¨áŒá‰¥áˆ áŠáƒ_2

Any help?


texts: SymfonyTestsListener does not exist on PHP Unit Test

texts:
When I try to run a unit test I get an error that SymfonyTestsListener does not exist.  Am I running this correctly?

../../vendor/bin/phpunit -c phpunit.xml ../modules/custom/my_module/

Class "Symfony\Bridge\PhpUnit\SymfonyTestsListener" does not exist

I am using PHPUnit 6.5.13.


texts:
I have (4) four different product variations in product display: 3, 7, 10 and 14. Each of them has own price.

I would like to have that maximum that could be bought is 14. If someone buy 7 then there is only 3 and 7 variation left.

Or if there is still 14 left and someone buys 3 then there is 10, 7 and 3 left.

So value 14 should never be exceed.

Is this mission impossible? Any help is needed. Thanks!


texts: How to create a search box bloc with search API

texts:
I'm using Drupal 8 and i've installed search API and Search API Solr Search.

I followed this great tutorial

How can I display a search box on all of the pages of my website ?


texts:
I have some nodes like this http://sprachzentrum.com.ar/cursos/curso-intensivo-de-alem%C3%A1n-nivel-a21-agosto-2011 and webforms and want to insert titel and day field as an option in the webform.

So that the user can choose from different levels

thanks of course! My question was: I have a node with an titel and some customer fields like level an time an I ask myself if its possible tu render the listbox automaticaly so that i will a options like:

1| [custom-field-level-1] [node-title-1] [custom-field-time-1]
2| [custom-field-level-2] [node-title-2] [custom-field-time-2]
3| [custom-field-level-3] [node-title-3] [custom-field-time-3]

So for each node from a certain type I will get an option on my webform