texts: Show all events that are active between two dates chosen from exposed date filter

texts:
I have a problem in showing views results with an exposed date filter in D7 views 3.x.

problem

We have several events with a date field. It is required to fill in a start and end date.
We want a visitor to choose a start date and an end date with an exposed filter in a view.

wanted results

The results should show every event that occurs:

Events that occur between the two dates
Events that are already started. So the start
date is already in the past.
Events that are in the future but the end date is not between the chosen dates.

We have already tried to configure a startdate with "equals or greater than" and an end date with "equals or less than".

Am I overlooking something?


texts:
I'm looking for a list of the events that Drupal 7 logs via watchdog. The question I'm trying to answer for a colleague is this:

"What logging Drupal is capable of, specifically related to security, performance, and metrics?"

I realize that I can log whatever I like but I'm looking for the default list. Googling hasn't helped.

Thanks very much.


texts:
I am developing a small module which is dependent on the php_ldap extension. I would like to make sure that this extension is enabled before activating the module and if it is not display a message telling the user that the ldap extension needs to be installed and enabled. I have tried using hook_enabled() for this purpose, but since this hook is fired after the module is enabled it will not work as expected:

function example_enable() {
  if (!function_exists('ldap_connect')) {
    // Here I would like to halt the activation of the module
    drupal_set_message(t('The Ldap extension needs to be enabled.'), 'error');
  }
}

I am not sure how to stop the user from enabling a module if a specific extension is not installed or loaded. I was thinking about using hook_install(), but I am not sure that would work either.


texts: Drupal 6 Feeds Module User Import & Ubercart

texts:
I've noticed that in Drupal 7 there is a way to map fields for importing users, but I don't see the same option for Drupal 6. Am I missing something? I'm trying to import users that include address fields from a CSV, but I can't see a way to map it all correctly.

I need to import addresses, phone numbers, zip codes, join dates, etc. and make sure they're mapped to the correct member/user fields in Drupal/Ubercart


texts: I want to get the real password(not md5 encryption) when edit the account profile via user profile form and save. how to do that?

texts:
Possible Duplicate:
  How can I get the real password via hook_user_update()?

I want to change the current user password, and get the new password(the real password, not md5 encryption) when edit the account profile via user profile form(e.g.: example.com/user/1/edit) and save. would anyone can tell me how to do that? I tried using hook_user_update(), but it didn't succeed.


texts:
I have a multisite in Drupal 8 eg. same codebase, differrent db. The client is asking for different color scheme for each subsite. I was thinking of implementing somehow Bartik's color picker, but have no idea how. The current theme is not derived from Bartik.
O the question is how can I implement color picker in my custom subtheme?

Thanks


texts: Changing background color in table when status is changed

texts:
I have table in VIEWS who stores from webform so i want to make is
When user select green from webform, then those informations need to be with green background, if other user select blue, that need to be blue in my table with results.


texts: Is it possible to download sandbox projects with Drush?

texts:
Normally, one can download a module from drupal.org like this:

drush dl views

However, this doesn't work for sandbox projects.  Is there an easy way to download them or I am stuck with git clone?


texts: Where can i try searching the module "File_styles"?

texts:
I have installed the media module for drupal 7 but it requests me the installation of a module I cannot find File_Styles.
Where can I searching this module?


texts:
I have found quite nice drupal module, the "tab tamer". It allows admin to edit labels of tabs and sub tabs, but also disable or enable them. I have install the module, and set that user/register and user/password to "Disabled". Unfortunately I can see all the time both labels. Did I make something wrong? I use the latest drupal7. Great thank for any tips or advices :)

nykon


texts:
I want to customize the status message after creating a content to include the current URL.

From

  @type %title has been updated.

to

  @type %title has been updated. Your permalink is (URL)

I'm running Drupal 7 using the String Overrides module.


texts: Start form as modal, from the controller

texts:
I see a lot of examples of modal forms. But in all these example the modal is started from a current form. There is always a link-button involved. I would like to start a form as a modal from the controller by using:

$form = \Drupal::formBuilder()->getForm($formId);
return $form;

Can someone give me an example of which extra code is needed to show the form ($formId) as a modal??


texts: Drupal 6 - Theme custom search form results

texts:
I have a custom search form written in my custom-module. On submit, i have used do_search api and then I have made some modifications/customization with the results.

Now having my customized results, how can I render them?

Work so far--->

In custom-module.module

function custom_module_search_ticket_form_submit($form, $form_state) {
   // do_search()
   //  customizations (in the sense, removed few results according to my requirements. Otherwise the result-object/array format is same as of core search results)

    return theme('rootcandy_my_search_results', $results, $type);
}

function custom_module_theme() {
  return array(
    'rootcandy_my_search_result' => array(
      'arguments' => array('result' => NULL, 'type' => NULL),
      'template' => 'rootcandy-my-search-result',
    ),
    'rootcandy_my_search_results' => array(
      'arguments' => array('results' => NULL, 'type' => NULL),
      'template' => 'rootcandy-my-search-results',
    ),
  );
}

Rootcandy is the theme I have used. In rootcandy's template.php

function rootcandy_preprocess_rootcandy_my_search_results (&$vars)  {
  // copied lines from core search module's search.pages.inc function template_preprocess_search_results(&$vars)
}

function rootcandy_preprocess_rootcandy_my_search_result (&$vars) {
  // copied lines from core search module's search.pages.inc function template_preprocess_search_result(&$vars)
}

Under rootcandy theme folder, Added below tpl.php files

rootcandy-my-search-results.tpl.php  (copied from core search's search-results.tpl.php)
rootcandy-my-search-result.tpl.php   (copied from core search's search-result.tpl.php)

Now I have done this much, clearing cache, after everything; Submitting my custom-search-form renders nothing, other than the form. When I print my customized results, they are fine. Theming part is not working.

Where is the mistake? Plz help !


texts: Add slideshow option to 'link image to' in Views

texts:
I have created a View that displays images uploaded on my website as thumbnails and in a grid style. However when I click on an image I would like some slideshow function to show so the user can click 'left' and 'right' to scroll through the images.
How can I add this functionality to 'the Link Image to' setting?


texts: Node edit form with entity reference - show more than just the title in the autocomplete box

texts:
I have three content types: application, organization, and organization_note. Application has an entity reference to organization and organization has an entity reference to organization note.

The application edit page has an autocomplete field for organization. When a user selects an organization which has a note, I would like the display to be different somehow, ideally a reminder to check the organization's notes.

This question is very similar to this one (unanswered).

I'm at a loss here, and I don't really even know if this is possible. How would I go about doing this? (This is Drupal 7, by the way.)


texts: Migrate Module and AddressField Locality/City Lookup in PrepareRow Fails

texts:
I'm running a migration to move volunteers from a csv file to drupal.  I have written the following code.

<?php
/**
    * @file
    * Migration for Volunteer File
*/

ini_set('auto_detect_line_endings', TRUE);

class VolunteerMigration extends Migration {

public function __construct($arguments) {
    parent::__construct($arguments);

    $this->description = t('Imports Volunteers from CSV file ');

    // Create a source object
    $columns = array(
        0 => array('pkid', 'PKID'),
        1 => array('fname', 'First Name'),
        2 => array('lname', 'Last Name'),
        3 => array('email','Email'),
        5 => array('dayphone','DayPhone'),
        6 => array('eveningphone','EveningPhone'),
        7 => array('address','Address'),
        8 => array('city', 'City'),
        9 => array('state','State'),
        10 => array('postalcode','zip'),
        11 => array('occupation','Occupation'),
        12 => array('interests','Interests'),
        13 => array('created','Timestamp'),
    );
    $address_arguments = array(
        'first_name' => array('source_field' => 'fname'),
        'last_name' => array('source_field' => 'lname'),
        'thoroughfare' => array('source_field' => 'address'),
        'locality' => array('source_field' => 'city'),
        'administrative_area' => array('source_field'=>'state'),
        'postal_code' => array('source_field' => 'postalcode'),
    );
    $this->source = new MigrateSourceCSV('/mnt/www/cylindrical/theoregonproject.com/data/drvollist.csv', $columns, array('header_rows' => 1));

    // Create a destination object
    $this->destination = new MigrateDestinationNode('volunteers');

    // Create a map
    $this->map = new MigrateSQLMap(
        $this->machineName,
        array(
            'pkid' => array(
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ),
        ),
        MigrateDestinationNode::getKeySchema(),
        'campaign_migration'
    );

    // Create Mappings
    $this->addFieldMapping('title', NULL)->DefaultValue('Volunteer');
    $this->addFieldMapping('field_volunteer_address')
        ->arguments($address_arguments);
    $this->addFieldMapping('field_volunteer_id', 'pkid');
    $this->addFieldMapping('field_email', 'email');
    $this->addFieldMapping('field_dayphone', 'dayphone');
    $this->addFieldMapping('field_eveningphone', 'eveningphone');
    $this->addFieldMapping('field_occupation', 'occupation');
    $this->addFieldMapping('field_interests', 'interests')
            ->separator(',');
    $this->addFieldMapping('created','created');

}

public function prepareRow($row) {

    if ( $row->zip ) {
        $row->city = zipcity($row->zip);
    }
}

public function zipcity($zip) {
    $ch = curl_init('http://ziptasticapi.com/' . $zip);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    $result = curl_exec($ch);
    curl_close($ch);

    $json = json_decode($result,true);

    return $json['city'];
}
}
?>

I'm am using the ziptastic api to fill in the cities using the zipcode.  Running the migration returns all except the address portion of the migration.  The zipcity function works as expected (returns city given a zipcode) but none of the address arguments are migrated.

I have adapted this code from a previous and successful migration minus the preparerow / zipcity additions.

Mark


texts: How to login to Acquia Cloud using Acquia Connector?

texts:
I've been having this error when logging in my subscription in Acquia Cloud:

Error: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (0)

I think it is a PHP problem, not sure.

I want to migrate my local drupal site in the Acquia Cloud for my project.

How to resolve this error?


texts: Input formats and WYSIWYG editor problem

texts:
I have install 2 editor: YUI and TinyMCE

But wysiwyg settings are:

Why I can't setup editor on this input formats?


texts:
I have a Drupal 7 site running including Commerce. I'm asked to make the webshop work in a way that the mail send after completing payment is send to the product owner(s).

So when creating a product via /admin/commerce/products/add the admin fills in the email address of the product owner/seller in a custom field called field_seller_mail.

When the visitor of the website pays its order, the site should send one or more mails to the owner(s) of the products zo that they can handle the delivery of the products.

In rules I choose the when payed in full trigger.
Then I choose to loop in the action part and loop trough the line items, but the field field_seller_mail is nowhere to be found.

What is the best way to solve this problem?


texts: Why the main theme isn't applied in the preview?

texts: When I’m in administration mode, using the 'seven' theme, and I click on Preview, instead of using the main theme, the preview uses seven's stylesheets, which is silly-willy because it’s not what I would expect from a preview.


texts: Views Block's machine name is being "hashed" (?)

texts:
A Drupal newbie, so correct me if my understand is wrong, but normally, when a Block is created by Views, the machine name of the block is appended to the Views' machine name.

i.e. "article_listing_view-block_1"

When using block_load($module, $block_id) function, the way I've been doing it is to call it thus:
$block = block_load("views", "article_listing_view-block_1");

However, for some very odd reason, one particular Block with the machine name:

"flag_comments_as_offensive-block_1"

has a hashed machine ID of:

"92a591f5a81d13a3dd5492f073f9e135"

I say "hashed" because the machine ID changes based directly on the machine-name of the block. If I change it from block_1 to block, it will change, and when I revert back from block to block_1, it will revert the machine ID back to the above. So there's a direct correlation between the machine name and the "hashed" ID it generates.

Instead of calling block_load("views", "machine name"), I have to use the hashed machine ID, which isn't a problem but it did take me a long time to figure out. The way I figured it out was to go into Structure -> Blocks and hover over the "Configure" link and look at the URL. I noticed that all my other Blocks have a URL that included its machine ID, but for this particular block, it was the hashed machine ID. Once I put in the machine ID into block_load, viola, it worked like a charm!

So I guess the question boils down to: What's going on, and why is Drupal hashing my machine name? Is this a bug, or an error on my part?


texts: Node empty fields behave badly when created with Entity Metadata Wrapper

texts:
Problem

Creating a node with the Entity Metadata Wrapper causes two frustrating results if select fields are left blank. (using #empty_option from the FAPI) .

(My form to create a node is pretty much just a more complicated version of the [create a node in code][1] example).

Display Problem

Typically when a node is created and a select field isn't filled in, the field will not display at all.

However when using the Entity Metadata Wrapper to create a node, if you then view the node the empty field titles still appear.

Indexing Problem

More frustratingly, if the node is indexed in this state it appears to store a blank string, which will appear as a blank option in a facet and throw the following error on ticking the blank facet.

Notice: Uninitialized string offset: 0 in SearchApiFacetapiTerm->addFacetFilter() (line 86 of
/srv/www/mysite/public/sites/all/modules/search_api/contrib/search_api_facetapi/plugins/facetapi/query_type_term.inc).

The Question

Both of these problems, disappear if I edit the node and save it. So something is being called in this process, or creating a node normally that isn't called with the Entity Metadata Wrapper.

Has anyone seen this before? What could be being called in a normal node creation that's not being run with the entity metadata wrapper?

Sample Code

This is an extra code for a node with the select field field_area.

function createanode_form, &$form_state){

   $area_field = field_info_field('field_area');
   $area_values = list_allowed_values($area_field);

   $form['field_area'] = array(
     '#type' => 'select',
     '#title' => t('Area'),
     '#options' => $area_values,
     '#empty_option' => t("-None-"),
   );

   .....

  $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Submit'),
     '#weight' => 70,
  );

}

function createanode_form_submit($form, &$form_state) {

    $values = array(
      'type' => 'job_advert',
      'uid' => $user->uid,
      'status' => 1,
      'comment' => 1,
      'promote' => 0,
    );
    $entity = entity_create('node', $values);

    $ewrapper = entity_metadata_wrapper('node', $entity);

    $ewrapper->title->set('Test title');
    $ewrapper->body->set('A bunch of text about things that interest me');
    $ewrapper->field_area->set($form_state['values']['field_area']);

    $ewrapper->save(true);
    entity_save('node', $entity);
}


texts:
Using Drupal 8 I created a form to load data from a webservice with ajax below the form. Now i'm trying to add pagination to result, but the paginator is not been loaded, i'm doing something wrong?. I've tried to follow the guide from https://www.drupal.org/docs/7/creating-custom-modules/howtos/paging-non-sql-data but it's for Drupal 7. Thanks in advance.

Here's my code:

$response contains an array with data from webservice.

$total contains the record of results

//number of records per page
$num_per_page = 3;
//get current page
$current_page = pager_default_initialize($total, $num_per_page);
$chunks = array_chunk($response, $num_per_page);
$current_page_items = $chunks[$current_page];
foreach ($current_page_items as $i => $item) {
  $current_page_items[$i] = array(
    '#theme' => 'ajax_search',
    '#item' => $item,
  );
}

// Generate the render array for our page
$render_array['page'] = array (
  '#theme' => 'item_list',
  '#items' => $current_page_items,
);
// Calls Drupal standard pager theme and set 5 page links on pager
$render_array['pager'] = array (
  '#theme' => 'pager',
  '#quantity' => 5,
);

$response = new AjaxResponse();
$response->addCommand(
  new HtmlCommand(
    '.result_message',
    $render_array)
  );
return $response;


texts: How do I check if a block region is empty?

texts: I'm wanting to apply some specific CSS on the condition that a block region is empty. How do I make this check?


texts: Alter views fields using preprocess function before render?

texts:
How do I edit a views field using preprocess before it is rendered to the screen?
Let's say the field originally outputs something like this:

Note title

now I want to change that adding the number of comments in that node

Node title (4 comments, 1 new)

I know I can achieve this with joining two fields together or altering the template (tpl) files for that particular field but I'd like to learn how to use preprocess function in order to achieve this.


texts: How to export content to campaign monitor?

texts:
How to export content to campaign monitor:

the admin will chose content from different content types
that content will be exported to campaig nmonitor
will be separated in different campaigns lists
Any ideas how to do that?


texts:
I'm using a Services and RESTful Web Services, All is Okay with me except the deleting and updating node, I've activated the node CRUD resource in my service. When hit the URL using DELETE

  MY_SITE/ENDPOINT/node/delete

I got Response as TRUE with status 200 OK. As I've read on the internet that if I want to delete a node, I should hit a URL like this, including nid in the last argument

  MY_SITE/ENDPOINT/node/delete/NID

But I got 404 Not found. So I want to know the error that I've made or what is the correct way to delete node using services and restful.

Thanks


texts: How to prepare directories in private file system?

texts:
I've configured private file system. Using it from UI works well.
I want to generate dump site content via devel_generate with custom modifications. So I'm hooking into Node API for assigning sample PDF files to nodes.

Inside private directory I want to create directory structure:

  $dir = sprintf('private://org%d/%d/person%d', $this->getOrganization()->nid,
                    date('Y'), $this->getEmployee()->uid);

  if (!file_prepare_directory($dir)) {
    throw new Exception('Cannot create document file directory or it\'s not writable');
  }

But exception is thrown.

How to set proper directory permissions? Content is generated  via drush command - drush genc.


texts:
I've spent the best part of the last day or two trying to implement lazy_builder (as seen in this brilliant tutorial https://github.com/joachim-n/drupalcon-europe-2020-lazy-builders).
However, rather than with a block or page render. I'd like to implement the lazy_builder into hook_tokens() and make the $replacements value dynamic so that it uses the lazy_builder.
We have a value saved to session that we use as the value of a token (so it back be used across the site).
$session = \Drupal::request()->getSession();
$session->get('my_value');

I've tried setting $bubbleable_metadata with both addCacheContexts and addCacheableDependency
$bubbleable_metadata->addCacheContexts(['session']);

&
$session = \Drupal::request()->getSession();
$bubbleable_metadata->addCacheableDependency($session);

However both these options make the page UNCACHABLE.
I'd like to keep the page a cache HIT, but load in the token value via lazy_builder.
My question is, is there anyway to leverage lazy_builder, in the token replacement?
/**
 * Implements hook_tokens().
 */
function mymodule_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = array();
  if ($type == 'my_token') {
    foreach ($tokens as $name => $original) {
      // Find the desired token by name
      switch ($name) {
        case 'my_token':
          $session = \Drupal::request()->getSession();
          //make the below use lazy_builder
          $replacements[$original] = $session->get('tracking');
          break;
      }
    }
  }
  // Return the replacements.
  return $replacements;
}


texts: PHP interpreter dies during database.int/execute during file.api.php/file_save in fields/file/file.field.inc/file_field_presave

texts:
I Dont know what to say really.

At the top level, im calling entity_metadata_wrapper.save on a user entity.
This code has been in production for months
The issue is during the save of a portrait field in the user bundle.
This doesnt happen anywhere else in the site, which still works fine in general

The final behaviour is that the php interpreter just dies, with no error at all. There is no mysql error. just stops during the execute function call..

At this point it seems clear that its something to do with the mysql driver outside drupal, but with no error message im reaching the edge of my skillset here.

Ive been developing drupal sites for about three years, have many of them, and have had this site up production for months.

Help would be much appreciated!

Regards,

Christophler


texts: Shipping conditions based on a custom field

texts:
I have custom fields in my customer profiles (so I don't use the dynamic addressfield) like name, streetname, number, postalcode and country. Now I would like to create 3 different shipping services with conditions based on different countries.

For example:

Shipping 1 = Netherlands, Shipping 2 = Germany, Shipping 3 = Belgium.

In my customer profiles I have a custom field called 'country' which have the values Netherlands, Germany and Belgium in a select list.

When setting a condition for the selected shipping service I am unable to select the correct data selector (order address component comparison doesn't work, cause that only works with the dynamic addressfield). I tried using 'entity has field' but that doesn't seem to work either (or I used the wrong settings?).

Any suggestions?


texts: How to cache custom controller markup for logged-in users?

texts:
How do we set up a controller so the rendered output is cached?

Blocks are cached for logged in users by default, and the build function doesn't even run once the block is cached for logged in users.

I have some custom controllers for landing pages where I would like to cache the output for logged-in users.

I guess I could put everything within those controllers in a block or in several blocks, but is there a relatively simple way to make a controller behave like a block and not even run the build function once it is rendered for a logged in user?


texts: How to use the LOWER function in a Drupal query?

texts:
I want the query like below:

select * from tbl where LOWER(name) = $name

My current query is:

$resultArr = db_select('adbanner', 'n')
    ->fields('n')
    ->condition(LOWER('n.blog_title'), $page, '=')
    ->execute()
    ->fetchAll();

But it doesn't work.

How should I write this type of query?


texts:
What I want to achieve is rather simple but either I haven't drank enough coffee yet or Google is boycotting the wanted results :)

I have a view ("the view"), of type "page" , formatted and styled exactly the way I want it; all is good.

Using the Weight module I have created another view ("the sorter"), also a page, with which to sort "the view".

What I'd like to do is to add 2 tabs, above both views, one leading the "the view's" url and one leading to "the sorter's" url, for easy back and forth transitions from the sorting mechanism to the front-end.

Thanks in advance!

EDIT: Of course I want only the administrators to see those tabs.


texts:
One of my client drupal 6 site boost installed and working properly. Now they need to integrate varnish to the site. For that the site is upgraded to pressflow. The varnish is installed in server, and Varnish 6.x-1.1 installed in site.  The varnish running status got in admin/settings/varnish page.

varnish version: 2.1
server: ubuntu

When boost is disabled i got varnish working properly, i used isvarnishworking.com to check the varnish status.

My problem is to make work boost and varnish together. For doing so, i followed this article Boosted Varnish - High Performance Caching made easy. I updated the default.vcl with the changes mentioned in this article, but it not caching.

It showing age header is less than 1

the other details are

In admin/settings/performance i set Caching mode: external and Page cache maximum age: 1 day

Any help to make work boost and varnish together is greatly appreciated


texts: How to create a test configuration that can called in a test class?

texts:
I am attempting to write a unit test by extending UnitTestCase. Below is how my code works, but I need a way to create a test (or mock) configuration that can be used to satisfy the testing.

How can I accomplish this?

To keep question short i am only adding pertinent code. Current issue is that my test cases are failing because the configuration is not valid.

Error message:

  Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.

mymodule/src/plugin/mymodule_field/provider/MyClass.php

class MyClass extends ProviderPluginBase {
  /**
   * {@inheritdoc}
   */
  public static function someFunction($input) {
    // Get the config.
    $config = \Drupal::config('mymodule.settings');
    $test_value = $config->get('test');

    if (!empty($test_value)) {
      /* process $test value */
      return True;
    }
    elseif (empty($test_value)) {
      /* do something else */
      return false;
    }
  }
}

mymodule/test/src/Unit/MyModuleValueTest.php

class MyModuleValueTest extends UnitTestCase {
  public function testIsEmpty($value, $expected) {
    /* I am stuck here on how to get the config */
    $this->assertEquals($expected, MyClass::someFunction($value));
  }
}


texts: Setting multiple checkbox values with form_set_value

texts:
I have a field that is a taxonomy term reference with a checkbox widget that allows multiple values.

I am looping through a json structure, finding the associated code value and then setting the value on the checkbox widget in the form with a case statement.

My problem is it's only setting the last value, not all the values. Here is the code. In this case where the hosts array contains all three values, I would expect all checkboxes associated with all three taxonomy terms to be checked. Only the last one is checked.

//json structure
"hosts": [
    {
        "alias": "external",
        "url": "abc.com"
    },
    {
        "alias": "internal",
        "url": "abc.com"
    }
    {
        "alias": "local",
        "url": "abc.com"
    }
]

          //php
          $hosts = $response->{'hosts'};

           foreach($hosts as $host){

           $alias = $host->alias;

            switch($alias){
                case "external":
                    form_set_value($form['field_proxy_host'], array(LANGUAGE_NONE => array(0 => array('tid' => '758'))), $form_state);
                break;
                case "internal":
                    form_set_value($form['field_proxy_host'], array(LANGUAGE_NONE => array(0 => array('tid' => '759'))), $form_state);
                break;
                case "local":
                    form_set_value($form['field_proxy_host'], array(LANGUAGE_NONE => array(0 => array('tid' => '760'))), $form_state);
                break;

            }

        }


texts: Update the settings of a View Display programmatically

texts:
I can load a ViewExecutable and create a new Display programmatically:

$view = Views::getView('existing_view');
$display = $view->newDisplay('page', 'New page', 'page_2');

But how can I update the settings for the new display programmatically?

The display is an instance of \Drupal\views\Plugin\views\display\Page but I can't see any way of saving options to it.

The setOption method exists, but how can persist the options to storage?


texts:
I'm defined a menu with a hook_menu, but he appears in navigation menu.
how do I put in the user menu?

$items['budget/view'] = array(
    'title'             => t('Ver gastos'),
    'description'       => 'Veja quanto é que anda a gastar',
    'page callback'     => 'page_budget_view',
    'page arguments'    => array(2,3),
    'access callback'   => ($user->uid > 0),
);


texts: What is the appropriate way to get items from an entityqueue?

texts:
I was having trouble finding API examples for entityqueue in Drupal 8.

I ended up writing a query to get the items.

$query = $this->database->select('entity_subqueue__items', 'esi')
  ->fields('esi', array('items_target_id'))
  ->condition('esi.bundle', $name_of_queue)
  ->orderBy('delta', 'ASC');

$nids = $query->execute()->fetchCol();

But I'd like to use a built in function if possible. Where's the function for retrieving items from an entity queue?


texts: How to store a nodes Fivestar average rating inside another field with computed fields

texts:
In order use rating to sort on inside search api, i'm trying to store the fivestar decimal value inside another field that can be indexed. This is because Fivestar doesn't play nice with search_api, so this will be a workaround.

I have a computed field that performs different tasks on the node such as copying the field_review_votes_average to field_index_review_score. I'm using this code to do so.

$entity->field_index_review_score[LANGUAGE_NONE][0]['value'] = $entity->field_review_votes_average[LANGUAGE_NONE][0]['average'];

But I keep getting Notice: Undefined index: und, what code can I use to to retrieve the average score?


texts: How can I avoid broken filenames in cached content?

texts:
I'm using Feeds to import data from Site A to Site B. Feeds runs every 15 minutes to check for new content, via cron / job_scheduler. I have caching turned on, with minimum lifetime and expiration both set to 15 minutes, with the hope that content will be rebuilt for anonymous users every 15 minutes.

The problem I'm having is that if Feeds updates a node and brings over a new image (or the same image; Feeds renames the same image every time the parent node updates) then the image on the rendered node is broken, as the original image doesn't exist anymore. e.g. example.com/files/image.jpg is deleted and replaced with image_0.jpg, while the cached page still has image.jpg in its source. Is there a good way to combat this, outside of having Feeds replace the existing file?


texts: Display page created using panel programatically

texts:
I am using Drupal 7 and Panel module.

I have created custom page using panel module. page-welcome

I want to render this page on the following url user/%user/my-profile

Is there any way to print page programatically..


texts: How do I assign different colors to each serie of a Google bar chart

texts:
I'm using Charts module to create some charts using the API. Depending on some variable i can create a pie chart or a column chart.

That variable is chart_type:

$chart_type = 'column';
$chart_type = 'pie';

This is the code I have:

$chart = array(
    '#type' => 'chart',
    '#title' => 'title',
    '#chart_type' => $chart_type,
    '#chart_library' => 'google',
    '#legend' => FALSE,
    '#tooltips' => TRUE,
    '#height' => 234,
    '#colors' => array('#006400', '#c11d0b'),
);

$chart['Status'] = array(
    '#type' => 'chart_data',
    '#title' => 'title',
    '#data' => array(500, 100),
    '#show_in_legend' => FALSE,
    '#show_labels' => FALSE,
);

$chart['xaxis'] = array(
    '#type' => 'chart_xaxis',
    '#labels' => array('Good', 'Bad'),
);

$my_chart['chart'] = $chart;

return drupal_render($my_chart);

When the chart is of type Pie, I can see the two colors (green and red) correctly assigned to the slices of the pie.
However, I can't assign the same principle to the column chart - in this case, both bars are green.

What I need is to have the colunn chart with the first bar green and the second one, red.

EDIT: Also, on the pie chart, I get two circles and I want to get rid of them. I thought it was a legend but it's not so... how can I remove them also?


texts:
I'm working with a Drupal site that features a fair amount of content, in excess of 1000 pages. The content is grouped in to Books and from there a hierarchical parent & child structure is created, often 4 or 5 levels deep.
What I'm finding difficult is content editors managing the order of content within books. The default method of adding a weight value can be difficult to understand. The drag & drop method (via Structure > Books) is also difficult to use with so much content, it can be really tricky to reorder items in the hierarchy when you are dragging a parent item with many children etc.
It would be great if the drag & drop ordering allowed users to collapse/show items within the structure, I feel that would make things much more manageable.
Am I missing something obvious somewhere? Or is there a better way to achieve this?


texts: How detect format of date field in form alter?

texts: How can I find if a form has date/time field or not and if it has, how can I detect what is date format for it?


texts:
When I run command "drush status" I cannot see any MySQL settings (user, password or database).

I cannot use commands like "core-quick-drupal" because it requires access to MySQL, before /sites/default/settings.php is created.

How can I set such MySQL connection?

I have installed drush in linux in directory /user/share/php

When I install Drupal from web browser interface, I can see that database support is enabled. I have problem only when installing drupal via drush


texts:
I made a template for the login block on the main page. It works.

Here is user-login.tpl.php code:

<?php
    $elements = drupal_get_form('user_login_block');
?>

Login

<?php
print drupal_render($elements["form_id"]);
print drupal_render($elements['name']);
print drupal_render($elements['pass']);
?>

             Forgot password

       <input type="submit" name="" value="Log in" />
       Sign up

<form> and
 tags were added around my template code, breaking the layout. Now the block doesn't float: left.

Here is the rendedered HTML:

<form action="/node?destination=node" method="post" id="user-login-form" accept-charset="UTF-8">

Login

<input type="hidden" name="form_id" value="user_login_block" />

  Login *
 <input type="text" id="edit-name--2" name="name" value="" size="15" maxlength="60" class="form-text required" />

  Password *
 <input type="password" id="edit-pass--2" name="pass" size="15" maxlength="60" class="form-text required" />

             Forgot password

       <input type="submit" name="" value="Log in" />
       Sign up

</form>

How to remove extra
 and put the form inside
? I tried that manually, but then I get 2 forms.


texts: Can Nivo Slider change slides without any effects?

texts:
I am trying to make the Nivo Slider module slide in between pictures without any effects. Is this possible from the Drupal admin section? Do I need to dive into code to do this?

Thanks!


texts:
The documentation is vague: https://www.drupal.org/docs/8/modules/json-api/working-with-files-post

I am trying to upload an image following the sample code given for uploading a "document" on above page.

Simplified example:
Given an admin user "bot" and a base-64 encoded qr code.

I create the json payload following the example in the documentation

{
  "data": {
      "type": "file--image",
      "attributes:": {
          "title": "QR Code",
          "uri": "public://folder/qr-code.png",
          "data": "iVBORw0KGgoAAAANSUhEUgAAAG8AAABvAQMAAADYCwwjAAAABlBMVEUAAAD///+l2Z/dAAAAAnRSTlP//8i138cAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAEsSURBVDiN1dS7jcMwDABQGirU5RYQoDXUaSV7AX8WsFdSxzUCeAGrUyGYRzuJ79KIKoIDTnCRVyj8gBTQ24H/wQ1gQNNCBrAiI+UOafRmoAqG48eSTKur2Gq4+VzJ3q/x190SKbfOLpivJAvkejs0/F3lF8hnh9yFn8YWuIEBR7tXs6ugJkIVEzSPrIqMBF94By72DFTmpteJVAxXoBI5RK9Nz4lpmbtTCx2FdGdWZRLmHuzo1/m8K5DWKeWB6001NEOg0dHrbombt9wfHu8GrcgYeEjuN00Lkky0m1eEdkoVTIa3rHfQBCuST6TzH0DmMbGBo/AukEjehSHkLtmYrExeyWNioXmWL1EDd34GW0XPneQ3h2Tym0OKh/Y5sUU+9hfcOmqZf/YCf4zfOAszBtzxUOsAAAAASUVORK5CYII="
      }
  }
}

Which translates into this curl command

curl \
--user bot:bot \
--header 'Accept: application/vnd.api+json' \
--header 'Content-type: application/vnd.api+json' \
--request POST http://drupalvm.test/jsonapi/file/image \
--data-binary '{"data": {"type": "file--image", "attributes:": {"title": "QR Code", "uri": "public://folder/qr-code.png", "data": "iVBORw0KGgoAAAANSUhEUgAAAG8AAABvAQMAAADYCwwjAAAABlBMVEUAAAD///+l2Z/dAAAAAnRSTlP//8i138cAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAEsSURBVDiN1dS7jcMwDABQGirU5RYQoDXUaSV7AX8WsFdSxzUCeAGrUyGYRzuJ79KIKoIDTnCRVyj8gBTQ24H/wQ1gQNNCBrAiI+UOafRmoAqG48eSTKur2Gq4+VzJ3q/x190SKbfOLpivJAvkejs0/F3lF8hnh9yFn8YWuIEBR7tXs6ugJkIVEzSPrIqMBF94By72DFTmpteJVAxXoBI5RK9Nz4lpmbtTCx2FdGdWZRLmHuzo1/m8K5DWKeWB6001NEOg0dHrbombt9wfHu8GrcgYeEjuN00Lkky0m1eEdkoVTIa3rHfQBCuST6TzH0DmMbGBo/AukEjehSHkLtmYrExeyWNioXmWL1EDd34GW0XPneQ3h2Tym0OKh/Y5sUU+9hfcOmqZf/YCf4zfOAszBtzxUOsAAAAASUVORK5CYII="}}}'

This results in an error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'uri' cannot be null

What am I doing wrong?

I am using a local Drupal instance generated by https://github.com/geerlingguy/drupal-vm#quick-start-guide on Mac Sierra 10.12.6

It is

Drupal core 8.5.3

Includes: Automated Cron, BigPipe, Block, Breakpoint, CKEditor, Color, Comment, Configuration Manager, Contact, Contextual Links, Custom Block, Custom Menu Links, Database Logging, Datetime, Field, Field UI, File, Filter, HTTP Basic Authentication, Help, History, Image, Internal Dynamic Page Cache, Internal Page Cache, Link, Menu UI, Node, Options, Path, Quick Edit, RDF, Search, Serialization, Shortcut, System, Taxonomy, Text, Text Editor, Toolbar, Tour, Update Manager, User, Views, Views UI

With the following Modules

File Entity (fieldable files) 8.x-2.0-beta6
JSON API 8.x-1.18
JSON API File 8.x-1.1
Token 8.x-1.3

(And with the core HTTP Basic Authentication module enabled)


texts: How to show files with lighbox/colorbox effect?

texts:
My goal is to create a gallery of all media of the site. I created a views-page of type file with bootstrap grid format that displays all file type of my site (File: Mime type (has word jpeg jpg png gif YouTube)).

My first problem is to get lightbox or Colorbox to display the file on click on the page. Is there any way I can get lichtbox in code (css, function,...) or views showing only file.(Note I'm not using fields but file). That mean when I'm on the views-created page, I can click on any file(image or video) and it react with lightbox overlay.

The second one is to remove certain content type files from the views display. (I don't want user profile images to be displayed or private files).

Thirdly, i want to create a menu to sort the file per type(image, audio, images, and taxonomy terms.) Maybe there is a good tutorial for this on google. I couldn't find anyone, ;)


texts: Drupal 7 ajax button added via ajax callback

texts:
I have an issue with this ajax callback in a form. Here is the callback:

function mymodule_add_more_callback($form, $form_state) {

$commands = array();

$current_id = $form_state['number_fieldsets'] - 1;

$id = 'node_group_custom_' . $current_id;

$fs = drupal_render($form['custom_fieldset'][$current_id]);

$commands[] = ajax_command_append(".vertical-tabs .vertical-tabs-panes", $fs);

$commands[] = array(
    'command' => 'enable_tab',
    'id' => $id,
    'id_li' => 'vertical_tabs_li_' . $current_id,
    'current_id' => $current_id,
);

return array(
    '#type' => 'ajax',
    '#commands' => $commands,
);

}

enable_tab is a custom ajax command that works fine.

$fs is a fieldset that contains a few form elements.

$fs also contains another ajax button that is intended to remove the corresponding fieldset via Ajax

$form['custom_fieldset'][$i]['remove'] = array(
'#type' => 'submit',
'#value' => 'x',
'#limit_validation_errors' => array(),
'#attributes' => array(
    'title' => t('Remove section'),
    //'class'   => array('remove_section'),
    'style' => 'cursor:pointer',
    'id'    => 'remove_section_' . $i,
),
'#ajax' => array(
    'callback' => 'mymodule_remove_section',
    'wrapper' => 'names-fieldset-wrapper',
)

);

The problem is that the remove ajax button does not work as expected. It should trigger this callback mymodule_remove_section but it is just reloading the page. I assume this is happening bcause it is added with ajax_command_append. Is there any solution to add ajax buttons with ajax_command_append called from another ajax callback?

EDIT

I'm passing a html string - $fs = drupal_render($form['custom_fieldset'][$current_id]); that obviously does not have the ajax event attached. Is there any other alternative? For example to pass the $form['custom_fieldset'][$i]['remove'] button instead of rendered html source along with my custom command?


texts: Getting error for drush site-install :Unable to find a matching SQL Class

texts:
I have created a drupal project using composer:

composer create-project drupal-composer/drupal-project:8.x-dev ./ --stability dev -vv

Then I downloaded drush using this command:

composer global require drush/drush

Now I try to install the drupal site using this drush command:

drush si standard --db-url=mysql://***:***@localhost/recommande_db --site-name=***** --account-name=*** --account-pass=*** --account-mail=*****

I'm getting this error:

exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL Class. Drush cannot find your[error]

database connection details.' in

/Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/commands/sql/sql.drush.inc:588

Stack trace:

#0 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/commands/sql/sql.drush.inc(573):

drush_sql_get_class(Array)

#1

/Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/commands/core/site_install.drush.inc(117):

drush_sql_get_class()

#2 [internal function]: drush_core_pre_site_install('standard')

#3 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/includes/command.inc(366):

call_user_func_array('drush_core_pre_...', Array)

#4 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/includes/command.inc(217):

_drush_invoke_hooks(Array, Array)

#5 [internal function]: drush_command('standard')

#6 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/includes/command.inc(185):

call_user_func_array('drush_command', Array)

#7 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67):

drush_dispatch(Array)

#8 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/includes/preflight.inc(66):

Drush\Boot\BaseBoot->bootstrap_and_dispatch()

#9 /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendor/drush/drush/drush.php(12): drush_main()

#10 {main}

I tried all the suggestions found in several forum but no solution.
Can you help please!

For your information here the result of the "drush status" command:

PHP executable         :  /usr/bin/php

 PHP configuration      :

 PHP OS                 :  Darwin

 Drush script           :  /Applications/MAMP/htdocs/dev.recommandemoi.ma/vendo

                           r/drush/drush/drush.php

 Drush version          :  8.1.2

 Drush temp directory   :  /tmp

 Drush configuration    :

 Drush alias files      :


texts: How to define a new cache context for a node

texts:
I am preprocessing a node with some data, i want to define a new cache context  based on this data.

function hook_preprocess_node(&$variables) {
    $variables['change'] = rand(0,5);
}

Once i have defined the new context i think i shuold be able to use it as follows.

function  hook_entity_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode) {
  if($entity->getType() == 'page'){
    $build['#cache']['contexts'][] = 'change';
  }
}

I can't seem to find out how to define a brand new cache context based on the data in my preprocess so that i can use it in hook_entity_build_defaults_alter();


texts:
I am creating a custom form and have run into a problem. I'm using the WYSIWYG module and for some reason the text areas  on this custom form don't show as rich text editors (tinymce shows on other parts of he site)

    $form['terms_format'][implode('~', array(MODULE_NAME, FIELD_TERMS))] = array(
    '#title'         => t('Terms and Conditions')
   ,'#type'          => 'textarea'
   ,'#description'   => t('Terms and conditiona')
   ,'#default_value' => variable_get(implode('~', array(MODULE_NAME, FIELD_TERMS)), "")
   ,'#required'      => TRUE
);
$form['terms_format']['format'] = filter_form(FILTER_FORMAT_DEFAULT);

Any ideas what i'm doing wrong? I'm using drupal 6.


texts: Alter the results returned by "Display a summary" for the Addressfield module

texts:
When I set contextual filters in a view for Content: my field: country and Content: my field: administrative area (state/province) and select "Display a summary" for "When the filter value is not available", it returns a list of country/administrative area codes (e.g. "JP"), not the names of the country/administrative area (e.g. "Japan").

How can I show the names of the countries/administrative areas instead of the codes?


texts: Accordion display for views inside panel

texts:
I have a panel page which contains 2 views. I only want 1 view to display as an accordion. My problems are -

If I set the style setting of the view to accordion - nothing happens.
If I set the style setting of the panel to accordion - both views become accordions.

I think panel settings are overriding view settings.
Any idea how to fix this?


texts: Block the password conformation pop-up window for security concern

texts:
In one of our application we need to block the password conformation pop-up window for security concern .

Example: When a user creates a new account that time user provides password and in Firefox the confirmation window came to store it in cookies or not. We need to block this programatically instead of manually.

I have searched more and more from last two days for disabling autocomplete=off feature for my specified forms like login forms. I have tried all things that I searched from google but popup is still enable.

I added this to all forms in hook_form_alter

$form['#attributes']['autocomplete'] = 'off';
I added this to all forms fields that I want to autocomplete off in hook_form_alter

$form['MY_Field_Name']['#attributes']['autocomplete'] = 'off';
I added this to all forms fields using jquery

$("input#Password").attr("autocomplete","off");

But it is still appearing remember password popup.

My Firefox Borwser Version is 40.0.3

My Google Chrome Version is Version 44.0.2403.157 m


texts: How to provide the “Privacy policy link” correctly on EU COOKIE COMPLIANCE module?

texts:
After this recent update of the module, when I run a Status Report, it warns me that: “Privacy policy link not provided”, but I actually think I did it by filling up the field “Privacy policy link”, am I missing any additional configuration on the module set up (Drupal 8.5.5)?

Note that, despite this warning the message abouts the cookies is displayed on the website and the respective button “MORE INFO” links to a page I created with additional info on the cookie compliance.


texts: standalone rsync and ssh work, but drush gets me a "Permission denied (publickey)"

texts:
I've got a production site (on shared hosting for now) of which I just want to have backups at this stage. and I've got a backup instance which I want to overwrite with the prod site.

This is my /etc/drush/aliases.drushrc.php:

<?php
$aliases['bak'] = array(
        'root' => '/var/www/',
        'uri' => 'testvm',
        'db-url' => 'mysql://user:pass@localhost/drupal',
        'path-aliases' => array(
        '%dump' => '/var/bak.sql',
        '%files' => '/var/drupal_files',
      )
);

$aliases['prod'] = array(
        'root' => 'livesite.com:/home1/ruser/public_html/',
        'uri' => 'livesite.com',
        'db-url' => 'mysql://ruser:pass@localhost/drupal_drp3',
        'remote-user' => 'ruser',
        'path-aliases' => array(
        '%dump' => '/home1/ruser/prod.sql',
        '%files' => '/home1/ruser/drupal_files',
      )
);
?>

And all I'm getting through drush is:

Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]
Could not rsync from livesite.com:/home1/ruser/public_html// to /var/www/        [error]

Even though I can rsync/ssh/scp with no issue to and from the live site. Certificates are in place, and working fine, but not for drush...

What I'm not seeing here???

PS I've seen What could cause remote drush commands to fail with ssh errors when ssh works in all other cases?, but the accepted answer does not make any difference for me.

Update:

I was using drush as root, so I tried creating a local user with same name as the remote user. I chowned the backup instance to the remote user.

ruser@drupal:~/.drush$ drush -v rsync @prod @bak
$options['ssh-options'] = '-o PasswordAuthentication=no -i /home/ruser/.ssh/id_rsa';

Loaded alias @prod from file /etc/drush/aliases.drushrc.php [notice]

Loaded alias @bak from file /etc/drush/aliases.drushrc.php [notice]
You will destroy data from /var/www/ and replace with data from livesite.com:/home1/ruser/public_html//
Do you really want to continue? (y/n): y
Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --exclude="settings.php" --stats --progress livesite.com:/home1/ruser/public_html// /var/www/);
receiving incremental file list
rsync: failed to set permissions on "/var/www/.": Operation not permitted (1)
rsync: failed to set permissions on "/var/www/.htaccess": Operation not permitted (1)
./

Number of files: 14547
Number of files transferred: 0
Total file size: 92209263 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 313420
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 1017
Total bytes received: 316801

sent 1017 bytes  received 316801 bytes  42375.73 bytes/sec
total size is 92209263  speedup is 290.13
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1536) [generator=3.0.9]
Could not rsync from livesite.com:/home1/ruser/public_html// to /var/www/ [error]
Command dispatch complete

This user has certificates in place in the live site as well. But still no luck...


texts: What is the URL for configuring OAuth2 services?

texts:
If this is the code in oauth2_servers.services_auth.inc module, what is the url to enable the "require authentication" checkbox?

/**
 * Services authentication "controller_settings" callback.
 */
function oauth2_server_services_controller_settings($settings, $controller, $endpoint, $class, $name) {
  $form = array();
  $form['require_authentication'] = array(
    '#type' => 'checkbox',
    '#title' => t('Require authentication'),
    '#default_value' => isset($settings['require_authentication']) ? $settings['require_authentication'] : FALSE,
  );
  $form['scope'] = array(
    '#type' => 'textfield',
    '#title' => t('Scope'),
    '#default_value' => isset($settings['scope']) ? $settings['scope'] : '',
    '#description' => t('A space-separated list of required scopes. Leave empty to ignore the check.'),
  );

  return $form;


texts:
I try to use jQuery UI dialog.
Based on this, I put this in a node:

        This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.

    Some stuff...

And it works! The popup window shows up automatically when the node is displayed.
But I noticed that jQuery is deprecated in Drupal 8.
So, how should I do the same thing in a more "Drupal" way?

[EDIT] Making progress...
@leymannx Using the 1rst example of Ajax Dialog Boxes page you provided, I get this working (see the screen capture).
My next step: how to have the dialog box displayed automatically when the page is reached without having to click the link?


texts: How to make translated taxonomy terms correctly be shown in a view?

texts:
I wonder how to make a multilingual taxonomy term show up in view results.

I'm using Drupal 7. To get my terms translated, I'm using the setting Translate. Different terms will be allowed for each language and they can be translated. Next, I can edit the term, use the tab Translation, and add a translation for the name in Deutsch (and save it afterwards).

But when I then try to create a view to displays these terms(category), they get displayed for both the Deutsch and the English terms. How can I fix this?


texts: How to get product variations inside webforms?

texts:
I have a product, A, B, C ... variations foo, bar, tar...

I am showing all three products in a url like drupal.dev/all-products.

I managed to display all three products via a webview. Now below these products I am making a webform to handle submissions, and in this webform I  would like to be able to show all product variations, but there seems to be no way to fetch product variations in webforms.

How can I go about doing this?


texts:
I have a site (Linux/Drupal/Apache) that generate a .xlsx file from custom code and its saved to files, but after that I cannot download it from drupal, it give permission denied.

Forbidden
You don't have permission to access xxxxxxx.xlsx on this server.

The upload file is saved with -rw------- or 600 permission, and the user/group from Apache.

If I chmod the file to 644 it works.

How can I made that any file generated in that way, will be -rw-r--r-- or 644 ?


texts:
I'm using Omega 3, and have a redundant HTML doctype header line.

How do I correct this so I have my HTML5 <!DOCTYPE html> line, and specify RDFa?

Currently, the first two lines of my pages are:

<DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">
<html lang="en" dir="ltr" version="HTML+RDFa 1.1"...>


texts: How can I trigger a javascript function when a Drupal ajax call is complete?

texts:
I need to do some extra things after Drupal ajax is done inserting some stuff into the DOM. With jQuery this was brain-dead simple, but I can't for the life of me figure out how to do it in Drupal 7 :s

Do I add something to my ajaxified link? I read something about attaching a behavior...confusion is setting in...


texts: Need a simple Google Maps solution; lost in the labyrinth of modules

texts:
First of all, let me just state that I don't care which version of Drupal I'd have to use (6 or 7). I have experience with both versions I just didn't need to work with Google Maps till now. The requirements are pretty basic (from what I understand):

1) Have a node for every company that I want to add in the map

2) In the node edit form I would like to add an address and have it added in a custom google map (or maybe copy-paste the link of a google map location)

3) Have a search function to find the nearest company for a given location

There are like tons of different modules out there, and I would like to be pointed to the right direction instead of looking through 15+ different modules just to finally realize that I need to write a custom module for myself.

Thanks in advance.


texts:
My task is to update all modules of  a site and commit. Everything goes well except when I ran the command drush pm-update projects drupal-6.28

  PHP Fatal error:  Call-time pass-by-reference has been removed in /Users/scottnassery/c2d-deals2/sites/all/modules/contrib/uc_post_affiliate_pro/uc_post_affiliate_pro.module on line 926
  Drush command terminated abnormally due to an unrecoverable error.   [error]
  Error: Call-time pass-by-reference has been removed in
  /Users/scottnassery/c2d-deals2/sites/all/modules/contrib/uc_post_affiliate_pro/uc_post_affiliate_pro.module,
  line 926

  Fatal error: Call-time pass-by-reference has been removed in /Users/scottnassery/c2d-deals2/sites/all/modules/contrib/uc_post_affiliate_pro/uc_post_affiliate_pro.module on line 926
  Scotts-MacBook-Pro-2:c2d-deals2 scottnassery$ drush up uc_post_affiliate_pro --security-only --no-core
  PHP Fatal error:  Call-time pass-by-reference has been removed in /Users/scottnassery/c2d-deals2/sites/all/modules/contrib/uc_post_affiliate_pro/uc_post_affiliate_pro.module on line 926
  Drush command terminated abnormally due to an unrecoverable error.   [error]
  Error: Call-time pass-by-reference has been removed in
  /Users/scottnassery/c2d-deals2/sites/all/modules/contrib/uc_post_affiliate_pro/uc_post_affiliate_pro.module,

My question is how can I fix that error and how can I restore the module to a old version should I redownload it  and replace it?


texts: How can I get parameter i.e node id from URL in views link path . Eg. - suppose in taxonomy term's view I am giving field name's custom link path is "document/getParameterFromCurrentURL/{{tid}}". where suppose getParameterFromCurrentURL  is variable or etc so how can i get id from current url in getParameterFromCurrentURL.


texts: Getting form variables data into twig templates

texts:
I need to pass an array to twig along with the form.

public function buildForm(array $form, FormStateInterface $form_state) {
   $form['job_locations'] = $job_locations;
   $form['#theme'] = 'search_form';
   $form['#method'] = 'get';
   ......
   return  $form;
 }

where $job_locations is

Array
(
[0] => Array
    (
        [city] => Singapore
        [count] => 5
    )

 [1] => Array
    (
        [city] => Toronto
        [count] => 3
    )
 )

And my twig file looks like

 {% for location in form.job_locations %}
        {% if location.city  %}

              {{ location.city }}

     {% endif %}
    {% endfor %}

Everything is coming correctly but it is throwing an error in the error log like

User error: "count" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of C:\xampp\htdocs\aws\dev\careers\core\lib\Drupal\Core\Render\Element.php)

User error: "city" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of C:\xampp\htdocs\aws\dev\careers\core\lib\Drupal\Core\Render\Element.php)

Please help me to solve this.


texts: Proper way to access data in a custom table

texts:
I have a module for which I've created a custom table in the database. I want to access various data in the table.

Since normally accessing content types is done via the abstraction layer provided by Drupal itself I'm wondering what would be the most "drupal" way to access the data in my table.

I assume I could simply use Database::connection class and function, but it seems a tad brutal(so to speak).

Would it make sense to create a repository or am I just overthinking this and should just go ahead and use the Database class and be done with it.


texts: Render array value empty for Datetime field

texts:
I'm using hook_form_alter to modify an admin edit node screen. The form has a datetime field which I'm unable to get the value for in the render array. textfields value usually appears in value->#default_value.

xxx_form_alter(&$form, &$form_state, $form_id) {
  print(json_encode($form['field_date_test']['widget']));
}

When the page loads, the value is in the input field but I can't find where I can get hold of the value before the page loads.


texts: Logged out when hit home link in drupal 7.19?

texts:
Noticed I am auto logged out or at least that is how it appears with the admin bar disappearing and login form visible when I hit the home link.

If I go from logged out home page to another page I appear logged back in.

I am on drupal 7.19 and it resides in a folder set up as a subdirectory.

drupal.mysite.com

the folder is at drupal.mysite.com/drupal

This only occurs when I am navigating about without www prefix and does NOT happen when navigating about with www prefix. My site can be accessed either way but currently advertising as without prefix. The www is more secure obviously but need both to work.


texts: Ajax pager failure in view after modifying view on hook_views_query_alter

texts:
The requirement is for different pages on the website to show different Twitter feeds according to the current page. There is a context (triggered according to the path) that inserts a view block into the footer. A custom module kicks in when the query for the view block is about to be executed. The module does some simple processing to determine what Twitter feed(s) are required to be displayed on the current page.

So, the custom module contains:

/**
 * Implementation of hook_views_query_alter
 */
function twitter_feed_selector_views_query_alter(&$view, &$query) {

  if ($view->name == 'tweets') {

    // Some processing...

    $feed = _twitter_feed_lookup($matching_path);
    $view->query->where[1]['conditions'][0]['value'] = $feed;

  }
}

However, the view block has a lite pager and Ajax enabled. And when the user clicks on the pager links to see the next/previous page of tweets, no tweets are coming back from the view.

I can't find how to get around this. If I turn off Ajax on the view, all is well, but the whole page is reloaded each time the pager is clicked -- which is way too clunky.

Can anyone suggest a means to make my amendments to the view query work nicely also with the Ajaxed results from the pager?


texts: Import menu items with translations based on Entity Translation

texts:
Currently I'm trying to migrate content (both nodes and menu items) from my old CMS (non Drupal CMS) to my D7 instance. In that light, I have exported the menu items as JSON files and I have also created the migration classes using migrate module and a third party one called Integration (https://github.com/nuvoleweb/integration/). I followed the same procedure for the content which I have imported into my D7 successfully. The problem that occurred regarding the menu links is the following:

In order to import menu items I use the MigrateDestinationMenuLinks method provided by migration module. The menu items should be imported along with their translations where it should be used entity translation. During the import phase, I get following error:

  An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging
  information follows. Path: /ECBWEB_instance/batch_de?id=514&op=do
  StatusText: OK ResponseText: Fatal error:  Call to undefined method
  MigrateDestinationMenuLinks::getEntityType() in
  /var/www/html/ECBWEB_instance/sites/all/modules/integration-7.x-1.x/modules/integration_migrate/src/AbstractMigration.php
  on line 30

While this happens I noticed that the menu item has been migrated but only in one language (language neutral) and not the rest of the others. The aforementioned error seems to reveals that migration module does not provide menu import methods for entity translations. Below you can find the class I've made in order to migrate the menu items (from JSON to Drupal)

public function __construct($arguments = array()) {
parent::__construct($arguments);
$this->setMap(new MigrateSQLMap(
  $this->getMachineName(),
  array(
    'mlid' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => 255,
    ),
  ),
  MigrateDestinationMenuLinks::getKeySchema()
));

$this->setDestination(new MigrateDestinationMenuLinks('menu-a-menu'));
$this->addFieldMapping('menu_name')->defaultValue('menu-a-menu');
$this->addFieldMapping('language', 'default_language');
$this->addFieldMapping('router_path')->defaultValue('node/%');
$this->addFieldMapping('plid', 'parent_id')->sourceMigration($this->getMachineName());
$this->addFieldMapping('link_title', 'subject');
$this->addFieldMapping('link_path','internal_url');
$this->addFieldMapping('weight','weight');

// Get the current folder and path
$json_folder = DRUPAL_ROOT . '/' .
drupal_get_path('module', 'migrate_example') . '/json/menu/';

$list_class = new MigrateListJSON($json_folder . 'list.json');
$item_class = new MigrateItemJSON($json_folder . 'menu-:id.json');
$this->setSource(new MigrateSourceList($list_class, $item_class));
}

Has anyone was ever in position to migrate menu items configured with entity translation? I'm stuck in this point a lot of days now and the documentation for migration of menu items is very poor.


texts:
Batch fails with SQL error "String data, right truncated..." for node field_collection field. But when saving node with the same field value there is no errors and Drupal log has no errors corresponding that problem.

Here is batch callback

function lt_generator_generate_text($report_nid, $context) {
  $node = node_load($report_nid);
  $report = entity_metadata_wrapper('node', $node);
  if ($report->type->value() == 'report') {
    if (LT_GENERATOR_DEBUG) watchdog('lt_generator_node_started', $report_nid);
    foreach ($report->field_report as $report_info) {
      if ($report_info->field_task_title->value()) {
        $report_info->field_task_title->set(_generate_random_text($report_info->field_task_title->value()));
      }
      if ($report_info->field_issue_title->value()) {
        $report_info->field_issue_title->set(_generate_random_text($report_info->field_issue_title->value()));
      }
      $report_info->save();
    }
    $context['results'][] = $node->title;
    $context['message'] = t('Text generated for @node_title', array('@node_title' => $node->title));
    if (LT_GENERATOR_DEBUG) watchdog('lt_generator_node_finished', $report_nid);
  }
}

This callback is simply generates random text with the same length as its value and save field_collection ($report_info->save();)

field_task_title - varchar(255), is russian or english text or even mixed.

I was looking at the length of these strings and found out it is 259 length both (one that was as field value and another one generated string). So while processing batch it fails to save field_task_title with 259 length string, but saving node is succeeded with the same string, that makes me confused. Any ideas why this happens for nodes? Also have u any ideas how to make batch don't fail everytime?


texts: Dealing with node language when manually updating node

texts:
I'm trying to manually update a node and I'm not sure how the language works.

The node is in English, so $node->language = 'en';

However, all my fields data are organized like this in the node:

$node->field_name['und'][0]['value']

I thought 'und' means "language undefined", so shouldn't it be 'en' instead?

I'm trying to automate the process so is it safe to assume fields will always use 'und' in nodes?


texts: Results table with form select for filtering

texts:
I have a page set up via a custom module, which contains some data rendered in a table, not using views. I didn't use views because it requires some various calculations that views calc couldn't do.

The table works fine, however, I would like to add a dropdown above the table, so that is has the equivalent of exposed filters like you would see in views.

The trouble is, i haven't had any luck in rendering a form (for the filter widget) in the same page callback as the table.

Below is the code i have up to this point. I figured this would be a common use case and this information must exist somewhere, but i haven't had any luck in finding an answer to this.

<?php
function mymodule_reports_menu() {
  $items = array();
  $items['people'] = array(
    'title' => 'Members',
    'page callback' => 'mymodule_reports_page',
    'access arguments' => array('access content'),
    'weight' => 1,
  );
  $items['people/fees-by-month-paid'] = array(
    'title' => 'Members by Card Number',
    'page callback' => 'mymodule_fees_by_month_paid',
    'access arguments' => array('access statistics'),
    'weight' => 1,
  );
  $items['people/fees-by-card-number'] = array(
    'title' => 'Members by Card Number',
    'page callback' => 'mymodule_fees_by_card_number',
    'access arguments' => array('access statistics'),
    'weight' => 1,
  );
  return $items;
}

function mymodule_fees_by_card_number_form($form_state) {

  $form = array();

  $form['year'] = array(
    '#type' => 'select',
    '#title' => t('Year'),
    '#description' => t('Toggle the Year'),
    '#options' => array(
      '2015' => t('2015'),
      '2014' => t('2014'),
    ),
    '#required' => TRUE,
  );

  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#submit' => array('mymodule_fees_by_card_number'),
    '#validate' => array(),
  );
  return $form;
}

function mymodule_fees_by_card_number($form_state) {

  // parameter that i will be setting up as the widget
  $year = '2015';

  $output = drupal_get_form('mymodule_fees_by_card_number_form');

  $members = array();

  $members = mymodule_get_membership_by_year($year);

  foreach($members as $key => $row) {
    $card_number[$key] = $row['card_number'];
    $name[$key] = $row['name'];
  }

  array_multisort($card_number, SORT_ASC, $name, SORT_ASC, $members);

  $yearly_sum = 0;

  $header = array('Card Number', 'Name', 'Paid');
  $rows = array();

  foreach($members as $member) {
    $rows[] = array($member['card_number'], $member['name'], $member['paid']);

    $yearly_sum += $member['paid'];

  }
  $rows[] = array('', '', 'Total:  $' . $yearly_sum);
  $output .= theme('table', array('header' => $header, 'rows' => $rows));

  return $output;
}


texts: Need to change the subdomain URL structure - D7

texts:
Need to change the subdomain URL structure from:

sub1.example.com
sub2.example.com

To:

www.example.com/sub1
www.example.com/sub2

Is there any module to do this in Drupal 7

If there is no other module in the text I need to rewrite the module for D7 version which is available in D6 in the below link. But before doing that I would like to confirm is there any modules ?

Below text is taken from the link:

  Of course this could quite easily be achieved using a redirect /
  RewriteRule in an htaccess file – but in this case we wanted to to
  achieve the URL re-routing without actually using a redirect. In other
  words, the URL in the browser’s address bar should always show URLs
  like this


texts:
I'm learning Drupal 8 after working with 7 for a number of years and I'm a bit unsure how to approach this. I need to be able to add a block and have it appear on a few specific pages.

I also need to be able to add some text and a link to this block. Is there a way to add these as fields to the block that can be filled in when the block is added to the page?

It looks like I could accomplish something similar by creating a new content type with those fields and adding it as an "Entity view" but this seems like overly complicated.

Is there another way I'm not aware of?


texts: How can I limit access to the text format drop down in a paragraph?

texts:
I'm trying to limit the access for users to change the value of text format dropdown but I can't seem to find the correct dropdown to alter. Here's what I have so far but it seems to disable access to the field itself and not the text format dropdown.

function hook_field_widget_WIDGET_TYPE_form_alter(&$element, &$form_state, $context) {
  if ($element['#paragraph_type'] == 'my_paragraph_bundle') {
    $element['subform']['field_text_long']['widget'][0]['#format']['#access'] = FALSE;
  }
}


texts:
Is it possible? To use the viewBuilder of an entity to generate the complete html and save that output into a string instead of sending it to a browser.

It would open the possibility to have email messages render using twig templates.

I have been poking around the different services and using the renderer service I can render the page-specific output as html but I can't find a way to get the complete HTML code into a string.

Matt.


texts: Can't set arguments to a view for displaying all data

texts:
I use

$view = views_embed_view('export_emargement','page_1',$journee,$region,$produit);

it works well, but If I don't want to specify $region the view does'nt works.

Im my view admin if I set argument like this 797/62/24 it works

If I try 797/all/24 it works too!every data are displayed

In my code i try this, but it can't be parsed

$args = array($journee.',"all",'.$produit);
or
$args = array($journee.',all,'.$produit);
$view = views_embed_view('export_emargement','page_1',$args);


texts:
Here's an example raw query of what I am trying to achieve with database API:

SELECT * FROM (
    SELECT
      n.nid AS entity_id,
      n.uid,
      n.title,
      node_body.body_value,
      node_body.body_format,
      'node' AS entity_type
    FROM
      `node` n,
      `field_data_body` node_body
    WHERE
      n.status = 1 AND
      n.type = 'forum' AND
      n.nid = node_body.entity_id
  UNION ALL
    SELECT
      c.cid,
      c.uid,
      '-' AS subject,
      comment_body.comment_body_value,
      comment_body.comment_body_format,
      'comment' AS entity_type
    FROM
      `node` n,
      `comment` c,
      `field_data_comment_body` comment_body
    WHERE
      c.nid = n.nid AND
      n.status = 1 AND
      n.type = 'forum' AND
      c.cid = comment_body.entity_id
) AS results ORDER BY results.entity_id

I have to do this using db_select() because of the pager.

My question is: how can I use db_select() for selecting results that are not from a specific table, but from subqueries like the query above?

Thanks!


texts: How to set manual crop to be compulsory for image?

texts:
I searched a lot for this problem but not getting any solution.
Any help is very appreciate.

I am using Manual Crop (7.x-1.5) module for cropping the images.
But problem is that I want to set cropping to be compulsory for image. I did not find any option in manual crop setting to set it as required.


texts: How do I display submenus separately from their menu tree?

texts:
I'm trying to display all 3rd level submenus for a menu item on one page, with each in its own display block. I've tried the Menu Block module but it only seems to work for the active trail, which means I can only display all 2nd Level and 3rd Level menus as one unit rather than just 3rd level menus as separate units.

In addition to the Menu Block module, I also tried access the menu tree directly with this code.

      $main = menu_navigation_links('main-menu', '2');
      echo theme('links__system_main_menu', array(
      'links' => $main,
      'attributes' => array(
      'id' => 'main-menu',
      'class' => array('links')
    ),
  ));
?>

Here's the menu structure:

- Parent Menu 1
- Parent Menu 2
  - Child Menu A
    - SubChild Menu 1A
    - SubChild Menu 2A
    - SubChild Menu 3A
- Child Menu B
  - SubChild Menu 1B
  - SubChild Menu 2B
  - SubChild Menu 3B

What I'd like to display when Parent Menu 2 is selected:

Block 1:    SubChild Menu 1A  | Subchild Menu 2A  | SubChild Menu 3A

Block 2:    SubChild Menu 1B  | Subchild Menu 2B  | SubChild Menu 3B

Any help on the right way to display submenus separate from their tree would be greatly appreciated.


texts: Can I delete nodes of a given content type with Drush?

texts:
Just wondering if Drush is capable of deleting nodes of a given content type.

Something like: $ drush delete-node --type=MyContentType

If not possible, can I create a method like that?


texts: Which hook to use to give a user a role after purchasing something in Commerce 2?

texts:
I made a site that sells services in Commerce 2.  I want to hide access to the "Orders" and "Payment info" pages until a user purchases the first product.

To do this, I created a role, Paid, for users who have purchased something.  This role has permission to view orders and so forth.

Which hook should I use to give the user the Paid role after making a purchase?


texts:
I installed WYSIWYG module with ckeditor library.
i had configured the text format and the ckeditor profile, but the only problem i'm facing is "pasting from word".

When i copy some content with colored text, some list and table, after i click on "paste from word" button, paste the content inside the textarea and hit ok, colors and the size of fonts and other formating disappear.

Any solution? thanks.

Content From Word:

Content When Pasting Using "Paste From Word":

Content After Ok:


texts: Are user browser information and ip address available as tokens in Rules?

texts:
I am sending an email to admin from contact form. In the email I want to send the user browser information like browser name and version and the user ip address. But I'm unable to see the tokens for these values?

I want the browser info and ip address for both logged-in and anonymous users.

Are these tokens available in the Rules module? Or I will have to create custom tokens?


texts: Image styles not working, uploads to to files directory

texts:
Image styles are not being applied. I have the /files/ directory set to CHMOD 777, GD Library is installed. When you upload an image, it just goes to the /files/ directory, none of the styles are generated into their styles folder. Reports -> status report is clean. Image uploads, but it stays in files directory, no thumbnails are generated, all paths are broken to the image even to the thumbnail in the Media page.

Hosted on AWS EC2 Linux/Apache

.htaccess in /files dir:

# Turn off all options we don't need.
Options None
Options +FollowSymLinks

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>


texts: Views, Contextual Filters, and Path Alias

texts:
First, a disclaimer:  I am less than a year into learning Drupal just to give you a frame of reference.  I am probably using incorrect terminology in my searches so if there is an answer out there, a point in the right direction would be greatly appreciated.

I am building a site that will have multiple "categories."  In each category, there will be page content.  So, my URL will (should) look like this:

www.example.com/category/page

All of my pages have been put into their respective subdirectories which are named for their categories.  For example:

widgets/page1  (node 10)
widgets/page2 (node 13)
widgets/page3 (node 24)
services/page1 (node 12)
services/page2 (node 15)
services/page3 (node 17)

If I type the url /widgets/page1 I get the "article" not the view.  If I type in the url with node id:

www.example.com/widgets/13

The view works perfectly and shows me widgets/page2

I created a page view for widges and set its path to "widgets"  so the url would be:

www.example.com/widgets

I have created a view that displays all my relevant info.  I also created an "attachment" that shows me related content from the same category.  This actually works quite well - it displays all the relevant content with linkable titles.

The problem that I am running into is when I click on one of the titles (or type the link directly) it no longer goes through the page view.

How do I structure this so that all links go through the views?  I am missing something, I just don't know what.

Screenshot of my Views Page


texts:
I have a view containing saved user webform drafts set up in a table format.  I have given permission to the authenticated user to delete own submissions.  When clicking the delete link located on the table it redirects user to a separate page asking "Are you sure you want to delete this submission?"  I'd like to accomplish one of two things.

Have no delete confirmation, when the user clicks delete it is immediately deleted. Preferred
Have the delete confirmation page as a pop up.

I'm new to coding drupal modules but I believe I have isolated the code to be found within the webform.submissions.inc folder, line 465 - 467:

$question = t('Are you sure you want to delete this submission?');

return confirm_form($form, NULL, "node/{$node->nid}/submission/{$submission->sid}", $question, t('Delete'), t('Cancel'));

Any help would be appreciated, I have searched and researched and keep coming to the same results.


texts: How to detect if field support multi values?

texts: It seems that field_info_instance doesn't return such info...


texts: How to avoid custom module hook_node_presave being overriden by a profile module node_presave

texts:
I'm willing to override a value before it get saved in database.
The same value is already overriden by commons_trusted_contacts module using hook_node_presave.

So my custom module hook_node_presave get overriden by commons_trusted_contacts_node_presave.
How do I let drupal know that he need to run my custom hook_node_presave after other hook node presave or to not override that single field value.

Below line being overridden :

$wrapper->group_content_access->set(OG_CONTENT_ACCESS_PUBLIC);


texts: I'm getting an error saying I'm inserting a duplicate entry when there isn't one

texts:
I have a form for users to update labels for cameras that my Drupal 7 module is displaying.  When the user submits the form, first I check to see if the submitted value already exists int he DB:

$query = db_select('floormap_cameras', 't')
      ->fields('t')
      ->condition('camera_name', $_POST['camera_update'][1], '=')
      ->execute()->fetchAll();
var_dump($query);

Then, if the value doesn't return any rows, I update the 'camera_name' field for the matching address:

if (empty($query[0]->camera_name)) {
   try {
     $update = db_update('floormap_cameras')
        ->fields(array(
          'camera_name' => $_POST['camera_update'][1],
        ))
        ->condition('address', $_POST['camera_update'][0], '=')
        ->execute();
    }
    catch(Exception $e) {
      echo $e->getMessage() . '<br />';
    }

This is where the trouble comes in....no matter what I put in for the new label, I get an error saying:

  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
  'Shannon6' for key 'camera_name'

I get this even though nothing I attempt to enter is already in the table.  The update shouldn't even run if the value is being used, I'm only running it if the first query returns nothing matching the label.

Here is the contents of the table, as you can see the value from the error posted is not in the table:

mysql> SELECT * FROM tlsconnectapp.floormap_cameras;

+------------+-------------+

| address    | camera_name |

+------------+-------------+

| monitor=30 | Counter C   |

| monitor=31 | Counter D   |

| monitor=33 | Counter E   |

| monitor=34 | Counter F   |

| monitor=35 | Counter G   |

| monitor=36 | Counter H   |

| monitor=29 | Counter V   |

| monitor=28 | monitor_28  |

| monitor=29 | monitor_29  |

| monitor=30 | monitor_30  |

| monitor=31 | monitor_31  |

| monitor=32 | monitor_32  |

| monitor=33 | monitor_33  |

| monitor=34 | monitor_34  |

| monitor=35 | monitor_35  |

| monitor=36 | monitor_36  |

| monitor=28 | TestCam     |

| monitor=32 | Waiting     |

+------------+-------------+

18 rows in set (0.00 sec)

Any ideas as to why I'm getting this error?


texts: Drupal 7 - Entitiy Reference - Reference field to a conent as a link

texts: I created content - lets call it X - which has a field with the type of entitiy reference (done with Entitiy reference). This field refers to a content that can be selected via select list. When X is shown the reference field appears but not as a link so that I can directly forward to that content. Do I need any additional module for that?


texts: Rules: Load List of Entities by Object or Entity ID (Performance)

texts:
I'm looking to load a list of Users by an Entity Reference Property within Rules. There may be times when I need to load hundreds or thousands of Users that have a matching Property to update a secondary Property. I'm having a difficult time determining the best performance option.

Here's my use case:

Users within our website may be linked to a Company (stored as a Node with Content-Type: company). When any user of this Company purchases membership, the company Node is updated with a Taxonomy Term Reference "Member." Then, every employee (read: User with entity reference to the same company node) of that organization needs to have a Taxonomy Reference field within their account updated to reflect they are a "Member (Corp)."

My Rules Based Solutions (that is executed when the order is first Paid In Full that sets the Data Value for that Property of the Company node, then...):

Solution A (Rules without VBO View):

Fetch all User Entities By Property: company, where company = Company node.
Loop through User list.
Check that Entity has Field: "Membership Status."
Set Data Value: "Membership Status" = "Member (Corp)."

Solution B (Rules with: Load a List of Entities from a VBO View):

Pass nid as parameter to view.
Loop through returned List.
Check that Entity has Field: "Membership Status."
Set Data Value: "Membership Status" = "Member (Corp)."

Solution C (Rules with: Load a List of Entity IDs from a VBO View):

Pass nid as parameter to view.
Loop through returned List.
Fetch User Entity by ID.
Check that Entity has Field: "Membership Status."
Set Data Value: "Membership Status" = "Member (Corp)."

I'm hesitant to load up every Entity that matches due to Performance implications; however, being fairly new to Drupal, I'm not sure the most efficient method to bulk update all of the affected Users.

Can you help me better understand the performance implications of these solutions? Perhaps, I'm missing a better option that I haven't considered? Thanks in advance for your help!

*This question is in reference to Drupal 7.


texts:
I have a site with 760123 nodes, and 20123 users.

When visiting any page, I get the warning, "Rebuilding content access permissions." I tried rebuilding the access permissions, but the process is very slow.
I see this post, and tried the proposed solution, but it is not working.

I'm using  Drupal 6.


texts: How to fetch Drupal entity from a webservice?

texts:
I'm building a rather special D8 website.

It will contain a lot of common node types (book, dvd, ebook, etc).
But - the data will not be fetched from the database, instead it will be fetched from a webservice (=WS).

The visitor will enter http://example.com/book/[urlencoded-book-title]-[urlencoded-id-from-ws]. Then the site will fetch the entity from the WS instead of the DB?

Is there a module that I can use to populate my entities from the WS?

The reason why I'm not saving in the DB is that there is over 50.000.000 records.

PS: I'm talking about loading a node content from the webservice and bypassing the database.


texts: How do I put form field sets in jQuery UI tabs?

texts:
I have created a custom form in a module via Form API. The form sits in a page created by hook_menu, which calls a function that renders the form from a form builder function. Also included in my module is a form submit function.

Currently, my form is divided into field sets that can be collapsed and expanded. It would be a lot nicer if the field sets were in tabs. To acheive this I intend to use jQuery UI tabs with the following code snippet:

drupal_add_library('system', 'ui.tabs');
drupal_add_js('
(function($) {
    $(function() {
        $( "#tabs" ).tabs();
    });
})(jQuery);
', 'inline');

I know I can put the other required markup in #prefix and #suffix properties in the $form array to wrap the field sets in tabs - but where does the above code go in the module? Should I be using hook_node_view or hook_view or something to ensure that jQuery UI tabs are initialised on my form page?

Thanks


texts: How to send email to multiple recipients on creation of new node using rules module?

texts:
I have created one node type.
Now, I want to send an email to multiple recipients on creation of new node using rules module.


texts: How to add auto taxonomy to node fields?

texts:
How to add auto categorization(Taxonomy Term) to node based on node body/description.

Node Body/Description: Retro is back in style, so flaunt the same when wearing this T-shirt from PUMA. Fashioned for men, this piece can be easily worn when heading out for a crazy day ahead with friends. Live in the moment by wearing this T-shirt with casual trousers and flip-flops when you hit the street with your best buddies
Here i have : ->T-Shirts, flip-flops, MEN etc,
By reading this content i want to assign auto taxonomy term reference in node field as T-Shirts to node.
Is it possible to do this?
Anyone help me ASAP.
Thanks in advance.


texts:
Running Drupal site and running Solr cannot connect.

I have installed a clean Drupal 7.34. It runs fine.

I have installed a clean solr-4.10.3. It runs fine.

I've installed apachesolr-7.x-1.7 and followed the instructions in the README.txt almost to the letter. Where it says things like

  Move apache-solr-1.4.1/example/solr/conf/schema.xml and rename it to
  something like schema.bak. Then move the solr-conf/solr-1.4/schema.xml
  that comes with this Drupal module to take its place.

I've had to change .../example/solr/conf to .../example/solr/collection1/conf.

Now when I try the test URLs in the README file they work fine, but when I try
"test connection" from Drupal it says "Your site was unable to contact the Apache Solr server."

I've also tried the recipe at

https://www.lullabot.com/blog/article/installing-solr-use-drupal

Again, I manage to get solr running, now in tomcat, but the same connection error pops up when I try connecting from Drupal.

Please, what am I missing? Are there logs for apachesolr that might help me see why this connection is failing?


texts: Administration page doesn't show pop-up (overlay) windows

texts:
When I try to place new block by clicking "Place block" button or when I click "Configure" on the block I see no pop-up window as I see in tutorial videos, like here: https://www.youtube.com/watch?v=D2KvCGGtBuk 3:10 and 4:25. It seems that this problem is persistent in other administration menus (like views, when I try to choose view format). How do I enable them? Why aren't they shown?

I'm on Drupal 8.1.1, with Nginx web server, Ubuntu 14.04 x32, DigitalOcean. There are no errors in status report except not protected configuration files and trusted host settings, which will be solved when site opens to public.


texts: How do I get the name of the content type?

texts:
in Drupal 7, which function do I need to call to get the name of the content type? I have the $node object and I also have the id of the content type if I use $node->type. But I need to get the name of the content type set in the system, not the ID as something like 'name_of_the_content_type'. I need it as 'Name of the content type'.

Thank you.


texts:
I need to retrieve all nodes whose node ID is equal to their tnid, or whose tnid is equal to 0. I am using the following code.

$db_or = db_or();
$db_or->condition('nid','tnid','=');
$db_or->condition('tnid',0,'=');

$query = db_select('node', 'n')
  ->condition($db_or)
  ->fields('n',array('title','nid','tnid','type','language'))
  ->extend('PagerDefault')->limit(50)
  ->condition('type','article','=')
  ->orderBy('created', 'DESC');

It does not work. It returns 0 node IDs, which is not the expected result, since the following code returns a different result.

db_query_range("select * from {node} where (nid = tnid or tnid = 0) and type = 'article' order by created DESC",0,1000);

If I remove $db_or->condition('nid','tnid','='); the first query returns only nodes with tnid equal to 0.

So, why does the first OR condition break my code?


texts: Changing Button Text on Content Type form

texts:
I created a content type called "video" and I created a module named df_video.module with:

function df_video_video_node_form_alter(&$form, &$form_state) {
    $form['actions']['submit']['#value'] = t('Upload');
}

I am trying to change the button text of my Video content type form from "Save" to "Upload" but nothing seems to work when I hit refresh. I also tried clearing the cache. I've tried many variations of the function name with no success. I would prefer to use the specific name of the form in the function name so I don't need to do a switch statement.

Also, just out of curiosity does anyone know if there is something special for placing hooks in a .inc.php file? Not doing this currently but I'm thinking it would just be an include to the main module file.


texts: Steps to Create a copy of a Drupal 7 website using cpanel?

texts: I want to create an exact copy of an existing drupal 7 website in a subdomain. What steps should I take to do this using just cpanel?


texts: How to distinguish between custom modules and contrib modules?

texts:
We have taken a project where we have to upgrade a site from d6 to d7.

But their module structure is poor, and does not distinguish between custom and contrib modules. We also want to know what's upgradable, and what isn't?

This would be helpful for sending project estimation.

Is there a way to do this using drush perhaps?


texts: Datetime retrieved from db is 7 hours off?

texts:
I am having trouble displaying the correct date, well actually its only the time.

In the db the date is stored in this form: 2012-09-28 23:30:00

That is the value for a date of an event.

When I retrieve it using this script:

$ttdate = $obj->field_date_test_value;
$nttdate = strtotime($ttdate);
$okdate = format_date($nttdate, $type = 'medium');
print $okdate;

...it works fine but the time is off by 7 hours.
So instead of showing Fri, 9/28/2012 - 4:30pm it shows Fri, 9/28/2012 - 11:30pm.

Note that on the event's page, drupal retrieves the correct time...

I did some research and I figured it has to do with the timezone? But I have the timezone set to Los Angeles so I am not quite sure what is going on. Maybe its my script?


texts: How to remove custom block parent div's?

texts:
I have created custom block in my custom module. I have created block template file into module templates folder. Custom block content coming successfully as per given in block__MODULENAME__dummmy_xyz.tpl.php file. I have only added following code into my block tpl file:

Hello

But it is coming with block parent div's, Block id and block-inner tag. I dont want to show those extra div's.
Following is the hook_theme which I have in my module file:

/*
 * Implements hook_theme().
 */
function MODULENAME_theme($existing, $type, $theme, $path) {

    $items = array();

    $items['MODULENAME_dummmy_xyz_block_theme'] = array(
        'type' => 'theme',
        'path' => drupal_get_path('module', 'MODULENAME') . '/templates',
        'template' => 'block__MODULENAME__dummmy_xyz',
        'variables'  => array()
    );
    return $items;
}

I am rendering block into tpl using,

$block = block_load('MODULENAME','dummmy_xyz');
print drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));

block.tpl.php code:

<?php print $outer_prefix . $inner_prefix; ?>
  <?php print render($title_prefix); ?>

  <?php if ($title): ?>
    <h2<?php print $title_attributes; ?>><?php print $title; ?>

  <?php endif; ?>

  <?php print $content_processed; ?>

  <?php print render($title_suffix); ?>
<?php print $inner_suffix . $outer_suffix; ?>

Kindly guide me.


texts: Display categories in views to get chosen and to display specific tags

texts: I wonder if there is a possibility to display categories and after clicking them, views display only specific category's items. Is it possible?


texts: Where does drupal store content-type display settings?

texts: I have several similar sites built by drupal. When I finished configuring one site, I wanna clone first site's setting to others(by importing SQL exported from the first site).But I can't find where drupal store content-type(ex:article)'s display setting in mysql?