texts: How can I get a default value in a dropdown using form API?

texts:
$results = db_select('users', 'u') ->fields('u',array('name','uid','mail')) ->execute();
$options = array();
foreach ($results as $result) {
$options[$result->uid] = $result->name.' | '.$result->mail;
}
unset($options[array_search(0, $options)]);
$form['user'] = array(
'#type' => 'select',
'#title' => t('Select User'),
'#options' => $options,
'#default_value'=>('select a value'),
'#states' => array(
'visible' => array(
':input[name="data_set"]' => array('value' => 'education'),
 ),
 ),
);
$form['submit']=array(
'#type'=>'submit',
'#value'=>t('Expire')
);

I have this dropdown , how can I get the default value like Select a value or something


texts: How can I configure half dollar amounts to be displayed as $n.50 while whole dollar amounts display as $n?

texts:
In drupal commerce, I have a product variation type with a price. In the 'manage display' area, in the 'format' section I have 'strip trailing zeroes' selected.

My prices are all either whole dollar amounts or half dollar amounts, for example $5.00 or $9.50. With 'strip trailing zeroes' selected, whole dollar amounts are displayed as expected: $5. However, half dollar amounts are displayed as $9.5.

How can I configure half dollar amounts to be displayed as $9.50 while whole dollar amounts display as $5?


texts: Where is root directory in Drupal Acquia Desktop?

texts: With other systems it's www or htdocs, but what about with Acquia Desktop?


texts:
I enabled the fancybox module, but since doing so am getting the following error messages:

Notice: Undefined index: options in _fancybox_filter_settings() (line 559 of /home/mysite/public_html/sites/all/modules/fancybox/fancybox.module).
Warning: Invalid argument supplied for foreach() in _fancybox_filter_settings() (line 559 of /home/mysite/public_html/sites/all/modules/fancybox/fancybox.module).

Any advice as to how to fix them?


texts: How to rebuild a cached page when it expires?

texts:
I'm using views caching after reading this great Q&A and getting good results. I have to keep the expiration short because I'm showing the "last comment" in the view and those changes often.

I'm thinking about using views content cache to expire the cache every time a comment is added. Or cache actions to do it with rules.

What I would like to do is rebuild the cache immediately after it expires? I read that boost module offers that but I need a solution for authenticated visitors (already use Varnish for anonymous).

The cache graceful module seems to offer that but only has 20 installs (plus requires a couple of other modules).

Are there any other solutions that allow expiring a cache and "warming" it up right away?


texts: How can I return literal JSON from a node as a JSON object in views json?

texts:
I have a content type with a field called output. This field will contain JSON. I want to output this field as JSON using Views JSON (in Views Datasource). The problem I'm encountering is views datasource is a. wrapping my field in quotes, and b. escaping my double quotes...

    [
    {
    "content": "{\"account-confirmation\":{\"body\":\"\",...

I need it to return something like:

    [
    {
    "content": {"account-confirmation":{"body":"",...

I've tried everything I could possibly think of. Is there any way I can output the literal value of the field without wrapping the value in quotes and escaping quotes?


texts:
I have implemented a hook_form in my custom module and I can't figure out how I can get the form to display.

Here is my hook form:

   function data_retrieval_form($node, &$form_state)
    {
        $type = node_type_get_type($node);

        $form ['title'] = array(
            '#type' => 'textfield',
            '#title' => check_plain($type->title_label),
            '#default_value' => !empty($node->title) ? $node->title : '',
            '#required' => TRUE, '#weight' => -5
        );

        $form ['field1'] = array(
            '#type' => 'textfield',
            '#title' => t('Custom field'),
            '#default_value' => $node->field1,
            '#maxlength' => 127,
        );
        $form ['selectbox'] = array(
            '#type' => 'select',
            '#title' => t('Select box'),
            '#default_value' => $node->selectbox,
            '#options' => array(
                1 => 'Option A',
                2 => 'Option B',
                3 => 'Option C',
            ),
            '#description' => t('Choose an option.'),
        );

        return $form;
    }

I have also implemented hook_menu which registers a url with a callback to the form:

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

    $items ['examples/form_example'] = array(
        'title' => 'Example Page',
        'page callback' => 'drupal_get_form',
        'access arguments' => array('access content'),
        'type' => MENU_SUGGESTED_ITEM,
    );

    return $items;
}

The problem I am having is that I cant understand how to get the form to display, the url does not work, how exactly do I display the form?


texts: How to get the number of registrants (RNG module) from the theme layer

texts:
In my theme I want to display not only the maximum number of registrants on the full view of a node but also the number of seats still available.

What is the easiest way to get the number of registrants? In Drupal 7 I retrieved this number by passing the node id into the registration_event_count() function, does RNG provide a similar function?


texts: How can update.php be disabled from checking for Postgres databases?

texts:
Whenever I try to run the database update script update.php after upgrading modules a WSOD appears and the php error log shows this message:

  PHP Fatal error:  Class 'DatabaseTasks_postgresql' not found in <site root>/includes/install.inc on line 1338.

The only reason I can think of is that sometime ago I setup a Feed to import some records from a Postgres database into Drupal and it probably configured Drupal to check for Postgres. I am not sure if that is the real reason as it could be a different thing.

Is there some module I need to reinstall for the failure to go away?

These are the offending lines in install.inc.

**
 * Ensures the environment for a Drupal database on a predefined connection.
 *
 * This will run tasks that check that Drupal can perform all of the functions
 * on a database, that Drupal needs. Tasks include simple checks like CREATE
 * TABLE to database specific functions like stored procedures and client
 * encoding.
 */
function db_run_tasks($driver) {
  db_installer_object($driver)->runTasks();
  return TRUE;
}

/**
 * Returns a database installer object.
 *
 * @param $driver
 *   The name of the driver.
 */
function db_installer_object($driver) {
  Database::loadDriverFile($driver, array('install.inc'));
  $task_class = 'DatabaseTasks_' . $driver;
  return new $task_class();
}

update.php triggers a call to this piece of code and causes the error. Any ideas of the code may be bypassed or Drupal reconfigured to fix it?


texts:
When I post something with long blockquote, that's OK, but when this post appeared on front page, it's breaking is such way, that no one can guess that there are also a continuation of the post.

For example, the post: http://en.nuclear-plant.org/node/23

Front page: http://en.nuclear-plant.org/

How to solve this? How to give a hint to readers, how to make "Read more" label more visible?

I don't want to add <!--break--> to each post, because, I have very long quotations, and want to fold them.


texts: mediafront module showing thumbnails instead of original image

texts:
I am doing the annoying crosspost thing but I can't get any answers on drupal.org so hoping somebody here can answer this.

I'm using the mediafront module to display images or videos in a slider. it shows videos just fine and if the first slide is a image it shows up correctly. However the subsequent slides the images show up as thumbnails. It is putting in specific styling in the image tag to make it a thumbnail. I really need an answer for this and hope somebody knows what is going on.

Thanks.


texts:
I have some slightly complicated ajax form logic that I'm struggling with.

I would like to replicate the following form conditions.

radio1 - always visible
option1
option2
option3

radio2 - only visible if option 2 and 3 are selected in radio1
option1
option2
option3

select3 - only visible if option 1 is selected in radio1
contents of select list to be controlled by on options in radio2

Problems

when radio2 is changed it still fires the ajax function

when the form is submitted the select list uses the default option set rather than one that has been built from the selection radio2

Below is the code I have used following the ajax example from the examples module.

function uk_general_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
if($form['#id'] == 'views-exposed-form-documentation-search-page') {
if(!empty($form_state['values'])) {
  $form_state['input'] = array_merge($form_state['input'], $form_state['values']);
}
$doc_type_options = $form['type']['#options'];
$form['type'] = array(
  '#type' => 'radios',
  '#options' => $doc_type_options,
  '#title' => '',
);

$doc_line_options = $form['line']['#options'];
$line_selected = isset($form_state['values']['line']) ? $form_state['values']['line'] : key($doc_line_options);
$form['line'] = array(
  '#type' => 'radios',
  '#options' => $doc_line_options,
  '#title' => '',
  '#ajax' => array(
    'callback' => 'uk_general_forms_documents_products',
    'wrapper' => 'products-dropdown-replace',
  ),
  '#states' => array(
    'visible' => array(
      ':input[name="type"]' => array(
        array('value' => '29'),
        array('value' => '31'),
        ),
      ),
    'disabled' => array(
      ':input[name="type"]' => array('value' => '30'),
      ),
    ),
  );
$form['title'] = array(
  '#type' => 'select',
  '#prefix' => '
',
  '#suffix' => '
',
  '#options' => _get_products($line_selected),
  '#states' => array(
    'visible' => array(
      ':input[name="type"]' => array('value' => '29'),
    ),
    'disabled' => array(
      ':input[name="type"]' => array(
        array('value' => '30'),
        array('value' => '31'),
      ),
    ),
  ),
);
}
}

function uk_general_forms_documents_products($form, $form_state){
  return $form['title'];
}

function _get_products($selected) {
  $product_query = new EntityFieldQuery;
  $product_query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'product')->fieldCondition('field_line', 'tid', $selected)->propertyOrderBy('title', 'ASC');
  $result = $product_query->execute();
  $product_nids = array_keys($result['node']);
  $products = entity_load('node', $product_nids);
  $titles['All'] = '- Any -';
  foreach($products as $product) {
    $titles[$product->title] = $product->title;
  }
 return $titles;
}


texts:
I've been using a combination of drupal_mail() and Mimemail to send out HTML formatted email; it's working fine.  However, in some circumstances, I also need to be able to send out plaintext email, not an empty HTML template, but a completely raw, plaintext message.
I can't figure out how to disable Mimemail for these messages, while leaving Mimemail in place for the others.
How might I be able to do this?


texts:
I would like to have a map on my website displaying all my stores. That worked out pretty well except for the fact the map is displaying more then just my country.
Is there a way to just show one country?

I made the map undraggable and users are not able to zoom, so the map is pretty much fixed but still, I would like to just show my country.

Is this possible with macro's? And if so, how do I create them?

EDIT:

So my country is Belgium and I would like to hide France and Germany (and if possible highlight Belgium...)


texts: How to replace allowed_values for a select field by external definition?

texts:
I created a custom content entity, called member, with some fields of which one, called status, is a list appearing in form as a select:

$fields['status'] = BaseFieldDefinition::create('list_integer')
  ->setLabel(t('Statut'))
  ->setRequired(TRUE)
  ->setSettings(array(
    'allowed_values' => array(
      0 => 'Ancien',
      1 => 'Actif',
      2 => 'Non renouvelée',
      3 => 'Renouvelée',
      4 => 'En attente',
    ),
  ))
  ->setDefaultValue(4)
  ->setDisplayOptions('view', array(
    'label' => 'above',
    'weight' => 7,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'options_select',
    'weight' => 7,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

I'd like to put the definition of the allowed values 'somewhere else' (meaning not directly in the definition of the member entity).
I know I could create another content entity (e.g. possible_status) that I would reference this way:

$fields['status'] = BaseFieldDefinition::create('entity_reference')
  ->setSetting('target_type', 'possible_status)')

But it seems a bit 'rich' to handle a couple of values...
Is there another way to store the values 'outside' the code defining the member entity?
An include file, a text file, a JSON file I could import?
What would be the best practice for that?

[EDIT]
I changed for this:

$fields['status'] = BaseFieldDefinition::create('list_integer')
  ->setLabel(t('Statut'))
  ->setRequired(TRUE)
  ->setSettings(['allowed_values_function' => 'association_allowed_values_function'])
  ->setDefaultValue(4)

with this in my module:

function association_allowed_values_function(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = TRUE) {

  if ($definition['entity_type'] == 'member' && $definition'field_name' == 'status') {
    $values = [
      0 => 'Ancien',
      1 => 'Actif',
      2 => 'Non renouvelée',
      3 => 'Renouvelée',
      4 => 'En attente',
    ];
  }
  return $values;
}

and it works!

Now, I'd like to move association_allowed_values_function to an include file.   And I don't know how...


texts: on submission of form respective form should open

texts:
in my form i have to show two radio button and one submit button, for example

candidate(radio)

organization(radio)

submit button.

my requirement is that

if user click/check on candidate and submit then candidate form should be open.

or

if user click/check on organization and submit then organization form should be open.

my code:

<?php
/**@file
*donation.module*/
/**
*Implements hook_menu()*/
function donation_menu(){
$items['donate'] = array(
'title' => 'Donate',
'page callback' => 'drupal_get_form',
'page arguments' => array('donation_donate_form'),
'access arguments' => array('access content'),
'access callback' => TRUE,
);
return $items;
}
/**
*Implements hook_form().
*/
function donation_donate_form($form, &$form_submit){
/*the options to display in our form radio buttons*/
$options = array
'candidate' => t('Candidate'),
'organization' => t('Organization'),
);
$form['officials'] = array(
'#title' => t('OFFICIALS'),
'#type' => 'radios',
'#options' => $options,
'#default_value' => $options['candidate'],
);
$form['name'] = array(
'#title' => t('NAME'),
'#type' => 'textfield',
);
$form['submit'] = array(
'#value' => t('PROCEED'),
'#type' => 'submit',
);
return $form;
}


texts:
I don't want to show blocks inside some pages, and I can't touch the theme files.

Is there any way to do this programmatically inside a module?


texts: Programatically assigning multiple user role ?

texts:
I am trying to assign multiple role while creating a user programatically. I am successfully creating a user and assigning one role using below code

$user = \Drupal\user\Entity\User::create();
// Mandatory.
$user->setPassword('111');
$user->enforceIsNew();
$user->setEmail('abcd@gmail.com');
$user->setUsername('abcd');
$user->addRole('lecturer');
$user->save();

I want to assign two roles during this code execution and tried the below code but it did not work

$user->addRole(['lecturer','program coodinator']);

How do I assign this?


texts: Non-CRUD resource action with Drupal 7 / Services 3

texts:
I can't get this simple example working with a custom action.

I had to move it form here How can I create a simple non-CRUD resource action with Drupal 7 / Services 3? to an own question.

The example looks like this for CRUD retrieve:

function mymod_services_resources() {
 $api = array(
   'test' => array(
     'operations' => array(
       'retrieve' => array(
         'help' => 'Drupal 7 Services 3 test',
         'callback' => '_mymod_test',
         'access callback' => 'user_access',
         'access arguments' => array('access content'),
         'access arguments append' => FALSE,
         'args' => array(
           array(
             'name' => 'fn',
             'type' => 'string',
             'description' => 'Function to perform',
             'source' => array('path' => '0'),
             'optional' => TRUE,
             'default' => '0',
           ),
         ),
       ),
     ),
   ),
 );
  return $api;
}

function _mymod_test($fn) {
  return "Test is working";
}

This works fine and returns for http://myhost.dev/endpoint/test/retrieve

Test is working

But when i try a custom action like this

function mymod_services_resources() {
 $api = array(
   'test' => array(
     'actions' => array(
       'custom' => array(
         'help' => 'Drupal 7 Services 3 test',
         'callback' => '_mymod_test',
         'access callback' => 'user_access',
         'access arguments' => array('access content'),
         'access arguments append' => FALSE,
         'args' => array(
           array(
             'name' => 'fn',
             'type' => 'string',
             'description' => 'Function to perform',
             'source' => array('path' => '0'),
             'optional' => TRUE,
             'default' => '0',
           ),
         ),
       ),
     ),
   ),
 );
  return $api;
}

function _mymod_test($fn) {
  return "Test is working";
}

http://myhost.dev/endpoint/test/custom returns just a 404

When i try it like this

function mymod_services_resources() {
 $api = array(
     'actions' => array(
       'custom' => array(
       ...

It is not shown in the Services list.

@Clive
Yes, i tried to GET that resource. But when i try to POST

curl -i -X POST --header "X-CSRFToken: p2BMMItuM6QD9HvdPulxS5IBnXDBnczT46VoLLSqJLM" http://myhost.dev/endpoint/test/custom

i get a
    HTTP/1.1 404 Not found: Could not find the controller.

But this solution - see the comments new user have to last 8 hours to answer own question :)
yields to an other question.

How can i get the whole path, not just index 0
    'source' => array('path' => '0'),

I like to get all path segments after the controller. in my case

myhost.dev/endpoint/test/foo/bar/1/2/3

i liked to get foo/bar/1/2/3 with index 0 i can get just foo.


texts: How do I change the default configurations for the node options?

texts:
I want to change some default configurations for the node options; for example, the authoring information has 'Authored by' field which is defaulting to auto-complete authors. I want to change this to a drop down instead.

Is there a module that can do this? I learned that editing a module is not advisable, and I cannot find modules that can override default configurations anywhere.


texts: Render link in twig with 'entity:node/n' as uri in array

texts:
With the module "config pages" I've set some variables global to render in templates.
In mytheme.theme I've added a function:
function mytheme_preprocess(array &$variables, $hook)
{
    $myConfigPage = \Drupal\config_pages\Entity\ConfigPages::config('config_name');
    $variables['my_settings'] = $myConfigPage->toArray();
}

In the config_pages I've created a link field.
I would like to render them, but I get below output.
How can I render the link in Twig?
  ^ array:3 [▼
      0 => array:3 [▼
        "uri" => "entity:node/186"
        "title" => "Title 3"
        "options" => []
      ]
      1 => array:3 [▼
        "uri" => "entity:node/189"
        "title" => "Title 1"
        "options" => []
      ]
      2 => array:3 [▼
        "uri" => "entity:node/195"
        "title" => "Title 2"
        "options" => []
      ]
    ]

Twig:
  {{ dd(my_settings.field_links) }}
  {% for link in my_settings.field_links %}
    <div class="field__item">
      {{ dd(link) }}
      {{ link.uri|render }}
      {{ link.title }}
    </div>
  {% endfor %}

None of above are working.


texts: Dynamic parameters passed to page callback

texts:
I have the following hook_menu:

  $items['products/autocomplete.json/%'] = array(
    'page callback' => 'json_list_products',
    'access arguments' => array('access products')
  );

Here is the function:

function json_list_products($keywords) {

  $items = array();
  foreach(_sql_select_products($keywords) as $product) {
    $items[$product['Product_ID']] = $product['Product_Name'];
  }

  drupal_json_output($items);
}

$keywords is not populated with the value of the % as i suspected - how do I populate this value?

Alex


texts:
I am trying to get edits in a content type's fields to be displayed and reflected in the view.

Here is a picture of the settings followed by how they are being displayed.

There is no book type being displayed which should group the books into how they have been assigned.

Also the body is appearing above the rest of the fields even though I have it in a different order in the display settings.

I am saving the settings using the 'save' button at the bottom of the screen. I have cleared all the caches. I have logged in and out again but nothing is changing when I edit the manage fields or manage display screens.

What am I doing wrong here?

thank you.


texts: Programmatically get View Field rendered HTML

texts:
I need to programmatically read a field output from a View in Drupal 8. The field output has been rewritten with extra text and twig. My code:

 foreach($view->result as $row){
    foreach ($view->field as $fieldId => $field) {
      if ($fieldId == 'Fieled 1') {
          $field_output = $view->style_plugin->getFieldValue($row->index, $fieldId);
      }
    }
  }

The output is a numeric value, which does not make sense to me. (The field  is a text field overwritten with a long text paragraph).
Any help would be really appreciated!


texts: Best practice for custom module variable names?

texts:
I've gotten into the habit of doing pretty robust configuration panes for my modules now, and I'm finding the variable names & management to be quite the pain.

I have variables like mymodule_section_subvar_varname_type_context and I not only loose track of the order of the elements in my variable names but I feel as if having a variable name that long is a design flaw.

I've been considering using a serialized array in a variable mymodule_section_settings in conjunction with a set of functions that make it easy to maintain that array but I'd love some input in what (if any) best practices have been established outside of prefixes and/or examples of modules that we trust and what they are doing for large sets of variables.

Thanks!


texts: Custom simpltest does not run successfully

texts:
I have written an automated test to create a node of a specific content type.

Here is the code:

class GlueTestingBuySystemTestCase extends DrupalWebTestCase {

  protected $privileged_user;

  public static function getInfo() {
    return array(
      'name' => 'Buying system',
      'description' => 'Buying system test',
      'group' => 'GLUE',
    );
  }

  public function setUp() {
    $this->profile = 'testing';
    // Enable any modules required for the test. This should be an array of
    // module names.
    parent::setUp(array('glue_testing'));

    // Create and log in our privileged user.
    $this->privileged_user = $this->drupalCreateUser(array(
      'administer nodes',
      ));
    $this->drupalLogin($this->privileged_user);
  }

  public function testBuyingSystem() {
    $edit = array();
    $edit['title'] = $this->randomName(8);
    $this->drupalPost('node/add/test', $edit, t('Save'));
    $this->assertText(t('Test Node Type @title has been created.', array('@title' => $edit['title'])));
  }

}

It does appear in the group "GLUE" but when I run the test it gives me the errors:

Failed to set field title to lLzjWnd0
Found the Save button
Found the requested form fields at node/add/test
"Testing Node Type lLzjWnd0 has been created." found

And does not create any node nor created the user.
Any one who have idea that what is wrong in my code?


texts: How can I show the receiver name in a rules email

texts:
I use the rules module in Drupal 7. I use it to send an email to a few receivers with a certain role. How can I get their name or userID? Is there a Replacement Pattern to get the email Receiver details?

edit:

I'm sorry for being unclear. I have made a rule that emails all users with a certain role after new content of a certain type was created. In this email I would like to start with "Hi [Username_of_email_receiver]" but it seems I can only use the author username or the current logged in username


texts: What do all these problem have in common (can't find the origin)?

texts:
A series of problems appeared in my install and I need help to narrow them down to a probable cause.

Most problems come in Views

1) All the dropdown menus that group options are gone. Clearing the cache will then display then again for once. Reloading the page again reproduces the issue.

2) Some block views with ajax/exposed filters are broken: instead of reloading themselves they call the home page with the arguments in the url: http://www.mysite.com/?field_tags_tid_i18n_op=or&field_tags_tid_i18n=All&status=All

Again, clearing the cache may solve the issue, but only once

3) Here and there, some glitches such as an geofield map not showing in a form until clearing the cache. And again, clearing the cache is only a one time fix as the issue reproduces next time the page is loaded.

I have tried the following:
- Clear the caches (All cache taken indepently work except CSS and Javascript, Theme and tokn regsitry, and update data)
- Clear the content of cache tables directly in mysql
- Remove all performance otions (aggregate css and javascript, cache,...)


texts: 8 - How can I detect when an entity is being autocreated?

texts:
I have an entity_reference field that autocreates entities (i.e., the 'Create referenced entities if they don't already exist' option is enabled in the field's configuration). I'm looking for a way to set some values on those autocreated entities before they are saved (e.g., author, revision message, ...).

What I've tried so far:

hook_node_presave(), but there is no indication on the $entity object that it's being 'autocreated' through an entity reference field.
I can see that the new entities are being autocreated in \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::preSave, but it's not clear to me if/how I can override that method without implementing my own entity_reference field type.

Any suggestion for how to set values on an entity when it is being autocreated?


texts: How can I use Metatag Module to set specific tags on specific nodes?

texts:
I'm using the Metatag module to set tags on content generally throughout my project. But there is one group of content where I want to be able to set the metatags for specific nodes. Because these nodes have unique specific tags, I want to be able to set them at the node level.

Is there a way to do this?


texts:
I added an image field to my user on this page admin/config/people and marked the allowed file extensions to be eps, png, jpg.  However, it doesn't allow me to upload .eps file, but only .png and .jpg.

I get this message:

  The specified file gold coins elements vector5.eps could not be uploaded. Only files with the following extensions are allowed: jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp.

How can I upload an .eps file?


texts: how to programmatically set unpublish_on

texts:
How can I programmatically set the unpublish_on field(scheduler module) for a node entity in drupal 7?

$entity = entity_metadata_wrapper('node', $node);
$entity->language(LANGUAGE_NONE);
$entity->title = 'My Title';
$entity->body->set(array(
    'value' => $body,
    'summary' => $summary,
    'format' => 'full_html',
  ));
$entity->scheduler_settings->set(array(
    '#required' => TRUE,
    '#unpublish_on' => '2018-06-25 12:23:11',
    '#date_format' => 'd.m.Y H:i:s',
  ));


texts:
I am trying to embed current user edit form in block. Actually I want just to embed some of the newly added fields. I tried to follow this code:

Embed some user profile fields in a block form

But I failed to find the "category", and code does not produce any output except of "save" button.

EDIT: Provided possible solution does not work for me. It does not print custom fields by any means.


texts: page not found after migrating drupal 7 to dev version same server using drush archive-restore

texts:
I have tried twice over to migrate a production site to a development version using a different database and although the files are all there and the database is also there I just keep getting a 'Page not found' when browsing to the dev version. I have checked my settings.php file which is pointing to the correct database too.

Here is a list of the process I used:

drush archive-restore /home/username/drush-backups/archive-dump/20120821113939/hampstea_db.20120821_113946.tar.gz default --destination=./hamp-dev --db-url=mysql://username:password@localhost/db_name

Any suggestions? Thanks in advance


texts: Bundle fields for entity without type config entity not created

texts:
I have entity that has bundles defined in code(hook_entity_bundle_info) and does not use config entity. It also defines fields for each bundle in \Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions. But when I install the module the bundle fields are not created, only the base fields.

According to documentation this is possible and config entity is not needed to provide bundles and fields. So do I have to manually create the fields in hook_install or I'm missing something here?

If I run the following code only one field will be created out of 11. Strangely that field is my custom field that I've defined in the my module. Others(string, entity reference..) are left out.

  $entity_type_id = 'resource';
  $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
  $bundles = \Drupal::entityManager()->getBundleInfo($entity_type_id);
  $update_manager = \Drupal::entityDefinitionUpdateManager();

  foreach (array_keys($bundles) AS $bundle) {
    $fields =\Drupal\mymodule\Entity\Resource::bundleFieldDefinitions($entity_type, $bundle, []);
    if (!empty($fields)) {
      foreach ($fields AS $name => $definition) {
        $update_manager
          ->installFieldStorageDefinition($name, $entity_type_id, $entity_type->getProvider(), $definition);
      }
    }
  }

If I run the following code the fields are present, so it's not an issue with definition.

\Drupal::service('entity_field.manager')->getFieldDefinitions('my_type', 'my_bundle');

I found few references on the internet for hook_entity_field_storage_info but so far I have no idea what to do with it.


texts: I can't get the SKU value for a commerce product in a rule action

texts:
I created a rule to be fired when a "New Commerce product is saved" Then I set a action to create a Product Display node and and another action to  set the title for the Product Display to be the same as for the new commerce product. So far so good.

Now I need to create another action to set the field product of the Product display to be the same as the Commerce product SKU.

Here is the problem since I can not get this value. I tried to add a condition of the type "Entity has field" but it seems like the SKU vale is not a field at all.

How can I accomplish with this?

Code for the rule:

{ "rules_create_product_display" : {
    "LABEL" : "Create Product Display",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "commerce" ],
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : [ "commerce_product_insert" ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "product_display",
            "param_title" : "[commerce-product:title]",
            "param_author" : [ "commerce-product:creator" ]
          },
          "PROVIDE" : { "entity_created" : { "product_display_created" : "Created Product Display" } }
        }
      },
      { "entity_save" : { "data" : [ "product-display-created" ], "immediate" : 1 } },
      { "redirect" : { "url" : [ "product-display-created:edit-url" ] } },
      { "drupal_message" : { "message" : "Product display created. You can edit it at: [product-display-created:nid]" } }
    ]
  }
}


texts: Custom entity api create options list for checkboxes without field api

texts:
I want to create a checkbox widget in my custom entity to select multiple options.

I don't want to use the field api, instead I want to use my custom table with multiple columns, one of them shall have the values which were chosen.

For select I use the following:

$info['pricedefault']['properties']['preis_zeiteinheit'] = array(
'label' => t('Time unit'),
'description' => t('Preis Zeiteinheit'),
'type' => 'integer',
'schema field' => 'preis_zeiteinheit',
'options list' => 'zeiteinheit_options_list',
'translatable' => TRUE,
);

and

function zeiteinheit_options_list(){
return array(0=>t('0'),1 => t('YEAR'),2 =>t('MONTH'),3=>t('WEEK'),4=>t('DAY'));
}

But how to write a checkbox function with the correct table column?

Thx in advance,

maen


texts: Filter strong and b from content through views

texts:
I'm use CKeditor, which inserts b and strong tags for bold text, and sometimes when Drupal is showing teasers, only the opening tag is included. Resulting in the bold type face cascading down and being applied to all the text below it. Is there any way to filter out particular html tags(strong, b) from the teaser display in views?

EDIT: If one chooses to use fields, there is also the option in views to strip all html but leave particular tags, which is can accomplish the same thing but from the opposite direction


texts: Attaching existing server files to filefield

texts:
How do you set an existing file path for a file field, in Drupal 7? The only option I see is to upload the file again.

In Drupal 6, FileField Sources seems to do this.

Does FileField Paths or IMCE along with file field allow assignment of server files?
Is there an API to programmatically manage file fields?

Edit
I just discovered that this can all be done with the media module. I also have mediaelement installed. However it is not completely intuitive, so here are the steps I took:

Import to media library: /admin/content/media/import

Create a mediafile asset field. This allows you to attach from the library.

Display formats (example for audio) are at /admin/config/media/types/manage/audio/display/, instead of content type "manage display" which only provides "large", "small", "preview", etc.


texts: How to filter a view according to nodes permissions

texts:
I would like my view to not display nodes to which the current user does not have access to.

I have implemented hook_permission "access nodes of type mytype"

I have also implemented hook_node_access this way:

function mymodule_node_access( $node, $op, $account)
{

   if ($op == 'create')
    {
     $type = $node;
    }

   else
   {

    switch($node->type)
    {
      case "mytype":
        if ( !user_access("access nodes of type mytype") )
         {return NODE_ACCESS_DENY;}
        break;
    }

   }

 return NODE_ACCESS_IGNORE;
}

I set up the view to displays only nodes of type "mytype".
When a user who does not have the permission "access nodes of type mytype" clicks on a link in the rows of the view, he gets the page "access denied" which is what I want.
But I also want the view to not display the nodes of type "mytype" if a user does not have the permission to "access nodes of type mytype".

How do I implement that?

Thanks,

Baba


texts: joining 2 form, but submit handler can not work

texts:
I joined this 2 form and the current submit only works for the 2nd form... also it is showing an extra save button :( can anyone help me how to join the submit,preview and delete button?

here is my code :

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

switch ($form_id)  {
  case 'product_node_form':

    global $user;
    $uid = $user->uid;

    module_load_include('inc', 'profile2_page', 'profile2_page');
    $profile2 = profile2_by_uid_load($uid, 'main');
    $entity_form = entity_ui_get_form('profile2', $profile2, 'edit');

    $form[] = $entity_form;

    dsm($form);

    return $form;
  break;
}

}


texts:
I need to use Php Filter with ckeditor.
Problem is that Ckeditor change this:

  <?php echo "hello";?>

to

  <p>&lt;?php echo "hello";?&gt;</p>

How can I solve this?

I already added this:

config.allowedContent = true;

under Custom JavaScript configuration at: admin/config/content/ckeditor/edit/Full

But it didn't help.

I also make sure I checked Php evaluator under Enabled filters at admin/config/content/formats/full_html


texts: Image slideshow with onclick on thumbnails

texts:
I am theming a node. I Want the images in the node to be displayed as below:

when I click on the second image second image should be loaded , when I click on third image third image should be loaded and so on.

How can I do this.


texts: Need to add a condition between two fields in a view

texts: I am a Drupal 7 novice. I have two fields of two different contents in a view. The first field is a boolean and the second is text (configured to an external link). Now, I want to make a condition like "If the first field is Yes, then the second field should be hidden."


texts: Drupal navigation always returns a 404 error

texts:
I have been given a Drupal site which I have to get it running.

I have Apache / Drupal / MySQL up and running, and created a new .conf file in Active Sites, and set the document location to /var/www/html/

I have edited my hosts file so that I have an entry for

127.0.0.1 samplesite.com

If I browse to samplesite.com/index.php I see the index of the site. So far so good. It is all styled, and as I see genuine content I must be hitting the database

Now no matter what link I click on on that page, I get a 404 error. (Looking in the log files its a 404 523 error if that has any bearing on it.)

I then found out the admin userid (using drush), reset the password, and cleared all caches. Still the 404 errors.

If I go to samplesite.com/user or samplesite.com/admin, I still get the 404 error, not an admin login page.

As this is an existing site, and works online, I am blaming something in my setup / configuration (being as the url on a failed link is similar to samplesite.com/about, I am assuming it is in the navigation configuration, but now I am stuck).

Is there an apache url rewriting module (or drupal one?) that needs some configuration? Or can anyone suggest something else I may have overlooked in apache / drupal configuration?

I now have the line $base-url = 'samplesite.com'; in my settings.php file, and none of the other urls work. However it accepts that I am logged in as admin as I have an additional admin menu at the top of the page. (none of the links work though)
Curiously, if I disable wifi, then the page doesn't load at all (I wouldn't have thought that wifi on or off would affect localhost)

Ok, My fix came when I followed this thread https://www.drupal.org/node/1572984

I needed to add in the following.

<Directory /var/www/html>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

However I only got here because of the help I received along the way, I think this was just the missing piece.


texts: How can I validate exposed filter from View?

texts:
I have build View which work for search exactly content by number filed "ICO".
How can I validate exposed filter form for only number and regular expression which enable only eight digit number?

Can you any help me with some example code for build it?


texts: How to prevent a rule to be triggered inside a rule?

texts:
I'm using the Rules module and I have two rules:

A: When flagged, 'Post a journal entry to the ledger'
B: When unflagged, 'Remove journal entry from the ledger'

Rule A includes also two Rules components with conditions that check if the journal entry is balanced:

If the condition 'balanced' is true:
 - Post journal entry to the ledger.

If the condition 'unbalanced' is true:
 - Show a warning on the page and UNFLAG the journal entry.

The problem is that I don't want the Rule B to be triggered inside rule A, which currently happens.

Theoretically I could add a condition to Rule B like 'is balanced' but I don't want to modify other rules in order to prevent the execution of a rule inside a rule.

Is it possible to prevent nested Rules from firing?


texts: re-saving users with default field collection items

texts:
I wanted to post to @Clive comment on How can I quickly re-save all users on my site? and ask about how to do this for fields in a field collection but couldn't because I've never posted to this site before so I had to ask a new question. He provided the following code to run as a php script in VBO on all users:

$items = field_get_items('user', $entity, 'field_name');
if (empty($items)) {
   $entity->field_name[LANGUAGE_NONE][0]['value'] = 1;
}
user_save($entity);

This solution works great for a single field of a user. I need a similar solution for setting default field values in a field collection after importing users.

I migrated 6000+ users and have set default values for fields in a field collection after the fact that don't show up unless I re-save a user account. I want to bulk re-save all 6000+ users so that the default field collection fields are saved and are visible. It's almost identical to the original question except the field is not just a singular field associated with the entity -- the field(s) in question are part of a field collection. How do I access the fields from my default field collection to then force re-save of users?

Is the proper way to access field data through entity_metadata_wrapper? If this is the case, how do I get/set the values of fields in a field collection that I want to associate with users using this wrapping class?


texts: Installing the slideshow plugin with CKEditor

texts:
I'm using CKEditor 4.5.6.91 with Libraries and WYSIWYG. I've tried the following:

Installing the Slideshow plugin to CKEditor by following the directions on the Slideshow plugin page exactly (that is, download it to the plugins/ folder, then add CKEDITOR.config.extraPlugins = 'slideshow';. This didn't work because I never got any kind of "slideshow" checkbox in the WYSIWYG settings.
I also tried downloading a custom version of CKEditor that has the Slideshow plugin already installed with it. Same problem as above.
Then I tried using  hook_wysiwyg_plugin() to create the checkbox. Now I'm getting the error in the js console, Error: [CKEDITOR.resourceManager.load] Resource name "slideshow" was not found at "/sites/all/modules/my_module/ckeditor/slideshow/dialogs/slideshow.js/plugin.js?t=FB9E". Here's the full code:

function mymodule_wysiwyg_plugin($editor, $version) {
  switch ($editor) {
   case 'ckeditor':
    return array(
     'slideshow' => array(
      'path' => drupal_get_path('module', 'mymodule') . '/ckeditor/slideshow/dialogs/slideshow.js',
      'buttons' => array(
       'slideshow' => t('Slideshow'),
      ),
      'load' => TRUE,
     ),
    );
    break;
  }
 }

I've tried giving the path to both slideshow/dialogs/slideshow.js and slideshow/plugin.js and in both cases got the same error.

I've run out of ideas of what to do to make the slideshow button appear and be functional in the CKEditor.


texts: How do I enable and use the password module for Drupal 6?

texts:
I've uploaded the module to my site, but it doesn't appear in the list of modules so I can't enable it. Does this module work differently than other modules?

https://drupal.org/project/password


texts:
I need the base path in my custom.js file. I have added this custom.js file in my MYTHEME.info file.

In custom.js file I'm trying to print

var baseUrl = Drupal.settings.basePath;
console.log(baseUrl);

Gives me empty value.


texts: Removing a row from a view depending on the user currently logged in

texts:
I have a view which prints out a table of blog posts.  There are 2 columns - title and tags.

If a post has a tag assigned to it called core-team then users with the role non-core shouldn't be able to see the post displayed in the table.

The view which is created displays every blog post so everyone can see them - but I can't figure out how to remove or not show a row from the view if the user logged in is non-core and the post has the tag core-team.

Any ideas?


texts: Adjusting module weight: what are the risks and things to look out for?

texts:
Today I changed the weight of a custom module of mine in order to change the execution method of hooks (hook_form_alter). I've changed the weight to 1 value heavier than the other module's weight. This seemed the safest thing to do instead of giving it a "random" weight of 100. The original module is a core module (translation) so I hope I didn't break anything.

When adjusting the weight of a module in order to change the execution order of hooks, what are the things to look out for and what are the risks involved?

What I can think of: unwanted behaviour as result of high coupling.


texts: Stop rendering custom entity label in view mode

texts:
I have declared a custom entity with a schema with a few fields on which is all working as I expect.

I want to remove the label when rendering the entity so have tried the following.

Added some view modes to the entity info hook and although I can see that they exist when I go to manage display none of my entity fields appear. Not sure if this is how it should work or not.

Any ideas?


texts: Entity alteration to prevent entity from being indexed by search_api

texts:
I'm using search_api/search_api_solr, and would like to be able to exclude certain nodes from being indexed by Solr at all.  In looking at search_api.api.php, I see this text:

  Please be aware that generally preventing the indexing of certain items is
  deprecated. This is better done with data alterations, which can easily be
  configured and only added to indexes where this behaviour is wanted.
  If your module will use this hook to reject certain items from indexing,
  please document this clearly to avoid confusion.

I'm just getting into the whole entity API, so it's not so "easy" for me to do this.  I'm thinking that he's referring to hook_entity_property_info_alter(), and I've used that to add a property to an entity so it is available as a facet and field available in search results.  However, I'm not seeing how to alter the entity so that I can control whether it is indexed by search_api or not.  Can someone point me in the right direction?

Thanks.


texts:
I'm writing my first custom field type. The field will contain a rating field for authors. Now when I create the class for the field and activate my module nothing has been found. No errors can be found in the log and the field is not be inserted into the field list of the content type.

I used the "Drupal 8 Development Cookbook" for more information about Drupal 8, but when I check my source with the example from the book I can't find any changes (except from my custom rating).

My class that contains the custom field was placed in the src/Plugin/Field/FieldType/Rating.php file and looks like:

<?php

/**
 * @file
 * Contains \Drupal\RateField\Plugin\Field\FieldType\Rating.
 */

namespace Drupal\RateField\Plugin\Field\FieldType;

use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;

/**
 * Plugin implementation of the 'Rating' field type.
 *
 * @FieldType(
 *   id = "rating",
 *   label = @Translation("Rating field"),
 *   description = @Translation("This field stores a rating of the object."),
 *   category = @Translation("General"),
 *   default_widget = "string_textfield",
 *   default_formatter = "string"
 * )
 */
class Rating extends FieldItemBase {
  /**
   * {@inheritdoc}
   */
  public static function schema(\Drupal\Core\Field\FieldStorageDefinitionInterface $field_definition) {
    return array(
      'columns' => array(
        'rating' => array(
          'description' => 'Rating',
          'type' => 'int',
          'length' => '255',
          'not null' => TRUE,
          'default' => '0',
        ),
      ),
      'indexes' => array(
        'rating' => array('rating'),
      ),
    );
  }

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties['rating'] = \Drupal\Core\TypedData\DataDefinition::create('range')
      ->setLabel(t('rating'));

    return $properties;
  }

}

Can someone help me with this?


texts: Exclude a free product from total calculation

texts:
In Drupal Commerce, how can I exclude a product from partial total calculation? The product is inserted as free product via a Commerce Discount rule, but in total calculation it appears and then is subtracted.
I would exclude this insertion/delete operation.


texts: Avoid reattaching javascript when a form is rebuilt by ajax callback

texts:
I have a form that uses ['#attached']['js'] to attach a simple javascript file. A checkbox element of this same form uses ['#ajax'] to dynamically update some portions of the form. I'm finding that, when the form is rebuilt after the ajax callback, the javascript file is reattached multiple times, causing unintended behaviors.

Is there any way to avoid reattaching a javascript file to a form if that same javascript has been attached previously?


texts: I have more than thousand images on my site. adding a class to each image manually is very time consuming process is there any way to add the class "adaptive-image" to all images already uploaded automatically.


texts: How to get Page Manager to react on path alias before node/%node

texts:
I have a CTools Page Manager Panels Variant that I want to apply to a whole load of different content, based on paths. Basically I want this Page Manager Page to handle all paths matching:

foo/*/*

Some paths will be node path aliases, some will be generated in other ways, i.e. not nodes.

I've set up a Page Manager Page with one Variant on the path foo/%blah/%baz, and this works well.

The problem is that if foo/bar/whatnot is a node's path alias, Page Manager sees this as node/1234 (it's menu path), and reacts with a different variant (node/%node), never considering the page page/variant I want.

My understanding of Drupal's "fitness" logic for menu router items would mean that my thing would win if the node's path alias was used, because foo/%/% has a fitness of 4, whereas node/% has a fitness of 2.

Is there any way to achieve this?


texts: List returned by drush site-alias is correct, but drush @sites finds an incorrect list

texts:
I'm using drush 7.x-4.5, Drupal 7.28, Apache 2.2.21, PHP 5.3.8. I have a multi-site installation, with a dozen or so sites, such as:

/path/to/drupal/sites/example1.com
/path/to/drupal/sites/example2.com
/path/to/drupal/sites/example3.com

Each of these is a symlink to some other location, which is not entirely uniform, e.g.:

example1.com -> /home/example1/drupal

...but another site might be:

example2.com -> /home/example2/www

If I run drush -r /path/to/drupal site-alias, I get a correct list of sites:

example1.com
example2.com
example3.com

However, if I then try to do something like drush -r /path/to-drupal @sites status, I get something unusable:

You are about to execute 'status' on all of the following targets:
  #drupal
  #www
  ...

So I can see it's just resolving the symlink and grabbing the last component of the path, then flattening that down to a set of unique last components of paths, which of course does not work at all.

I have tried filling out aliases with /etc/drush/aliases.drushrc.php, and while the aliases work in the single-site context (e.g. with $aliases['e1'] = array('root' => '/path/to/drupal', uri => 'example1.com'), the command drush /path/to/drupal@e1 status). The list that the @sites comes up with is unaffected.

Have I just set up this multi-site installation in an unusual way? It seems to otherwise be fine.

For what it's worth, I have a parallel Drupal 6 multi-site installation, and it has essentially the same problem.


texts: Do you really need SSL on local dev environments?

texts: If a Drupal site is running on production with https, is there any reason why this should be done also on local dev like xampp? Just wondered about so many people desperately trying to run SSL on localhost (independently of Drupal).


texts:
Running Drupal-to-Drupal 7.x-2.1.  I am attempting to migrate d6 comment attachments to d7 using the UI.  In d6, I used the Comment Upload module for comment attachments.  d7 does not have such a module, but you can attach files to comments by adding a file field to the comment structure.

I created migration code which provides the source file field information I need (from the d6 comment_upload table).  I created a file field in the d7 destination content type comment structure.

However, when I run the Drupal import option in the d2d UI and navigate to the destination map for the content type comment in question, I do not see the file field I created.

Is this normal?  A bug?

I have seen a 'solution' to migrating files attached to comments from d6 to d7 advertised here, but after following 3 links, it only provides a vague explanation with examples of core node file migration.  There is no example, or logic, provided to show how to actually map a d6 file field to a d7 comment file field.

My hope was to be able to do this through the d2d ui, but it does not appear to display comment file fields.

Any help on this?

Thanks!


texts: I want to create a view of display type page with a path of '/%/bookmarks'. Whenever this view is linked on a page clicking on the link will open the view in an overlay instead of a new page. How can I do this?


texts: Insert the next recurring charge date in custom table when user purchase a product?

texts:
My site have a subscriber role that have some special permissions. User has to purchase the role. I used ubercart module for this.

I added a feature to assign role on purchase of subscription. Subscription can be for 1 week, 1 month or 1 year. User can cancel own recurring charge. Uc_role module manages the assign and remove role of user. It handles the next date of recurring. But uc_role not manages the past date.

My question is that I want to show the user who purchase a subscription in past. Is there any hook or something so I can work on it?


texts: Display suggested search result on search page if search result is empty

texts: There are any way or module to display search result from suggested keyword on search page if search result is empty. just like google search, But result should come from my Apache solr system.


texts: base_url in settings.php with mobile version

texts:
I've both www.example.com and m.example.com pointing to the same directory in Ubuntu and there was in the settings.php  with this line:

$base_url="www.example.com";

I want to ask what will happen in this case in Drupal where sites are accessed as www. or the m. versions?

In the hook_custom_theme I'm returing a mobile theme whenever the URL is starting with "m.".

I was getting some wierd mix up of mobile and the desktop versions.

I was not able to find any cid with "http://m." URLs in the cache_page mysql table. After I removed this $base_url now  both mobile and the desktop versions seem to be showing fine now and also cache_page table is having rows with cid with "http://m...".

I'm not fully sure this but could $base_url cause this?


texts:
Is there a module which redirects Anonymous users to user login form after submitting node form and saves the node only when user successfully logs into data?

Will I have to do it by $_SESSION if theres no module supporting the above functionality?

EDIT:-
For anonymous user, I want to show node add form of custom content type. But when anonymous user fills all information and clicks submit, the control should go to login form and after user logs in then only the node should get saved with a confirmation message.
So is there an existing module for above requirement.

EDIT2:-
If the user doesnt logs in then the data should not be saved. So the data should get saved only when the user logs into the system after he is redirected to log in form.
Even after he logs into the system after two days, then the data should not get saved.


texts:
Running a website on Drupal 6.

I'm currently using Faceted Search to search the default database for the website.

I've installed a separate Knowledgebase application (KB Publisher) which has it's own database and search, but I would like to use one search box (the default website search box) to index/search BOTH the default website database & the Knowledgebase database.

I'm not really a hard core programmer and am looking for some ideas/assistance in doing this?

Thanks,

John


texts: Customize user registration form by adding/modifying fields in the form and handling submit function

texts:
I am new to drupal.

I need to customize a registration form by adding fields like id,mobile etc.

Can I accomplish this by creating a custom module?

If yes could anyone please help me with a brief idea on creating and overriding the default user registration submit function. I have to insert these details to another table and also have to pass the data as a service request.

Ive created a custom module with function

function module_form_alter(&$form,&$form_state,$form_id){
$form['#submit'] = 'module_form_submit';

if($form_id == 'user_register_form'){
    //print_r($form_id);
    $form['email'] = array(
            '#type' => 'textfield',
          '#title' => t('id'),
          '#default_value' => '',
          '#size' => 60,
          '#maxlength' => 15,
          '#required' => TRUE,
     );
    }
}

function module_form_submit($form, &$form_state){
  echo "test";
 exit();
}

module_form_alter is being called and I can see the new field on the registration screen but the submit function is still not called. I need to override the default drupal register submit.

I already have the following function in my theme template.php

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

  $items['user_login'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'portal') . '/templates',
    'template' => 'user-login',
    'preprocess functions' => array(
     'portal_preprocess_user_login'
    ),
  );
  $items['user_register_form'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'portal') . '/templates',
    'template' => 'user-register-form',
    'preprocess functions' => array(
      'portal_preprocess_user_register_form'
    ),
  );
  $items['user_pass'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'portal') . '/templates',
    'template' => 'user-pass',
    'preprocess functions' => array(
      'portal_preprocess_user_pass'
    ),
  );

  return $items;
}

user-register-form.tpl.php

    <?php print drupal_render_children($form); ?>

And page--user--register.tpl.php with the html

<a href="<?php echo $home; ?>"><img src="<?php echo drupal_get_path('theme', 'portal') . '/images/logo.png'; ?>"  width="100"><?php echo $createaccount; ?>

            <?php
            $elements = drupal_get_form("user_register_form");
            $form = drupal_render($elements);
            echo  $form ?>

     <?php if ($messages):?>

                <?php print $messages; ?>

        <?php endif; ?>

Is this approach fine or should I change this approach inorder to make my custom module functional?

One problem, I need to validate this form in client side, Ive added js in module_form_user_register_form_alter function as
         $form['#attached']['js'] = array(drupal_get_path('module', 'modulenamne').'/js/myjs.js',);

File is loaded but when clicked on submit the js is not working, instead the page is loading and drupal submit is executing.


texts:
I have a vocabulary that I want to shows as menu. For this, I installed the taxonomy menu module and edit the vocabulary to hang from a menu item of Main Menu. The menu is shown perfectly.

The problem goes when I localize the terms of vocabulary, the menu is only shown in a default language. I have tried to rebuild the menu (by checking the "Select to rebuild the menu on submit." on vocabulary edit page and submitting), but the problem persists.


texts: Limit menu items available as possible parents on node creation

texts:
As I create a node I want to assign i to a menu item parent. I know that I can limit it to what menu(s) are available on:

  /admin/structure/types/manage/my_type

But it would narrow it down to "only some of the menu items". For instance if I have a menu like this:

  Main menu

  Home (page)
  Service type A (page)
  Service type B (page)
  Service type C (page)
  About us (page)
  Contact us (page)

If I then have content type "Service", I don't want the editor to by mistake place the new node under About us. They should only be able to select "Service type A" (or B or C).

I would be nice if I just missed the module that does this trick.


texts: How to access label of List (text) via node_load()

texts:
In my module I'm generating some json based on some node content.

$node = node_load($nid);

One of the fields in the node is field_sport_type which is of type List (text). The allowed values look like this:

mens-surfing|Men's Surfing
womens-surfing|Women's Surfing
junior-mens-surfing|Junior Men's Surfing
junior-womens-surfing|Junior Women's Surfing
skate|Skate

When I var_dump($node), the field_sport_type section looks like this:

["field_sport_type"]=>
      array(1) {
        ["und"]=>
        array(1) {
          [0]=>
          array(1) {
            ["value"]=>
            string(14) "womens-surfing"
          }
        }
      }

So, the 'value' is the key from the allowed values, but I want to get the Label, not the key. In other words, I won't want womens-surfing, I want to get Women's Surfing.

How can I get access to the label of my List (text)?


texts: Difference between $form_id and $form['#id']?

texts: What's the difference between $form_id and $form['#id'] in hook_form_alter() ? Why they have not the same values?


texts: How do I add another field to facet for conditional filtering

texts:
I currently have a facet block that lists all sizes available for a certain category. The sizes come from a taxonomy vocabulary.

I want the sizes facet block to only show the sizes that have stocks > 1. The stocks field is a text field in the shoe content type.

Just a sidenote if it's helpful, both the stocks and sizes are indexed through apache solr and are displayed as facets through search API.

I have tried field aggregation and dependencies but neither satisfy my requirements. Any directions towards the right way would be greatly appreciated.

Regards.


texts: how to identify first element in array of node objects?

texts: hook_node_load($nodes, $types) in Drupal 7 takes two arrays as parameters. In the module I'm working on (Drupal 7 port from Drupal 6), just one node of one type is being loaded. I tried $node[0] to specify the first node in the array, but no joy. How do I get at the first node and the first type? There is only one object in each array.


texts: What is the different between an install profile and a drush make file?

texts: I am just getting into using drush and excited about using drush make and installations profiles. What is the different between a drush make file and an installation profile and do they /can they work together?


texts: Wrap comment replies in a collapsible fieldset

texts:
I found an article about wrapping all comments (http://scito.ch/content/wrap-comments-collapsible-fieldset), but I just want to wrap comment replies in a collapsible fieldset.

How do I achieve this?


texts:
drush sql-sync @devyau @stageyau returns:

Call to a member function dump() on a non-object in
/root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc, line
275

echo $PATH returns:

/root/.composer/vendor/bin:/usr/lib64/qt-3.3
/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
/root/bin

drush @devyau uli returns:

Call to undefined function drush_sql_get_class()
in /root/.composer/vendor/drush/drush/includes
/environment.inc on line 366

drush @stage uli returns:

call to a member function db_spec() on a non-object in
/root/.composer/vendor/drush/drush/includes/environment.inc, line 370

Here's environment.inc lines 361 to 378:

/**
* Tests the currently loaded database credentials to ensure a
database connection can be made.
     */
function drush_valid_db_credentials() {
try {
    $sql = drush_sql_get_class();
    if (!$sqlVersion = drush_sql_get_version()) {
      return FALSE;
    }
    if (!$sqlVersion->valid_credentials($sql->db_spec())) {
      return FALSE;
    }
    return $sql->query('SELECT 1;');
  }
  catch (Exception $e) {
    return FALSE;
  }
}

drush ard returns:

The external command could not be executed due to
an application error. Unable to determine sites directory for
devyau. Archive saved to /root/drush-backups/archive-dump/20150703220104
/none.20150703_220105.tar.gz

drush status returns:

 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /root/.composer/vendor/drush/drush/drush.php
 Drush version          :  7.0.0
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /etc/drush/prodyau.alias.drushrc.php
                           /etc/drush/devyau.alias.drushrc.php
                           /etc/drush/stageyau.alias.drushrc.php

devyau.alias.drush.php:

 <?php
 $aliases['devyau'] = array(
 'uri'=> 'dev.[sitename]',
 'root'=> '/var/www/vhosts/dev.[sitename]/',
 'db-url' => 'mysql://[username]:[password]/devDBname',
  );
?>

stageyau.alias.drush.php:

?php
$aliases['stageyau'] = array(
'uri'=> 'stage.[sitename]',
'root'=> '/var/www/vhosts/stage.[sitename]',
'db-url' => 'mysql://[username]:[password]/[stageDBname]',
  );
 ?>

Been working on this one for a week. Stumped. Any ideas?


texts: Breadcrumbs in Drupal Bootstrap is not updating when the menu link title is changed

texts:
we are using Drupal 7 and are having a problem with the drupal-bootstrap module. When we change the "Menu link title" to a new string the breadcrumb text string is not updated

We are running the latest version of the drupal-bootstrap module
I've tried clearing the cache inside of Drupal (configuration - development - performance - caches - clear all caches)
I've also cleared the browser cache and tried to load the page on two different computers

Does anyone know what else we could try here or what the problem is? I'd prefer to stay away from the PHP code if possible

One option would be to just remove the page and create a new one with the new "Menu link title"

Grateful for help and with kind regards,
Tord


texts:
I am struggling to find a way to handle this need. I have a few views exports set up on our site. The Client can go to the view page and download the csv. Works great.

The client is asking to see if the csv's can download nightly without them having to go to the page and click to download. I have not seen something in Drupal that allows me to handle this. I am a front-end dev so not a module creator. I have gone through rules scheduler with no luck.

Can someone try to share some insight to point me in the right direction. Thanks!!!


texts: Add fields to entityform, when it's created

texts: Is that possible that I set default fields for entityform types when it's created? There will be site admin users. They will create registration forms for events, but there are 2 mandatory fields that they forget about sometimes, but they have to add it, because it breaks a few modules. Like voucher code and the email fields. Also, they sometimes recreate a field with different names. Like they add a new email field, with the name "field_email" address, but the field I'm checking is the "field_email_address". I want to add these fields to the form programmatically, right after the site admin clicks the "Save entityform type" button, but only when he creates it first. Is it possible to add a field programmatically to an entityform? And if it is, then how? Thanks in advance!


texts:
is there anyway to populate nodes when type a custom content type value using node reference in drupal 7 ?

node refernce populate nodes when we start typing the title of the nodes . is there any option in drupal 7 that we type custom field and it populate the related nodes as it is working with the title.

Thanks


texts: How to change the order of fields in the Drupal Commerce Checkout Form

texts:
I'm using Drupal Commerce 7.x. I have added some fields to the checkout form in the customer profile. Specifically I've added 'Title' and 'Organization'. I'd like to move some of the fields around because they aren't in the order I'd like, but I can't figure out how to move them.

For example, right now the order is:
1. Country (I def. don't want that first)
2. Full name
3. Address
etc.

I want it like this:

Full Name
Title (new field)
Organization (new field)

I tried using a module that does this (just as an example, obviously, since only two fields are listed here). Am I on the right track?

<?php
function CommerceAlter_form_commerce_checkout_form_alter(&$form,
&$form_state, &$form_id) {
   $order = array('edit-customer-profile-billing-field-title',
'addressfield-container-inline');
    foreach ($order as $key => $value){
      if (isset($form[$value])){
        $form[$value]['#weight'] = $key;
      }
    }
}

But it didn't do anything.

Note: I was unsure how to reference the fields. The first one above called 'field-title' is the ID for that field and the second listed for addressfield (which is in the form by default) is by class .addressfield-container-inline).


texts: Shipping address, rates selection asked even if there's no physical products

texts:
We have made a Drupal 7 website with Commerce module. The website has a combination of physical and non-physical products.

The shop has a small problem (or potentially big), in that it asks for shipping address and shipping rates (flat rate) from the shopper even if they only buy non-physical products.

We have used the Physical Product module and Physical Fields module to accomplish the physical product functionality.

I found a similar question, regarding a different (older) commerce version (7.x-1.0), but this question had no accepted answer, so I decided to ask my own question for my relative version of Commerce (7.x-1.3).

Any help, pointers on where to look/investigate this problem, or even a confirmation whether the single answer posted on the similar question is the right way to go about accomplishing this would be greatly appreciated.

If you need any more information from me, please ask.

Ok I just found a Rules rule with machine name commerce_shipping_method_flat_rate. So I added a condition to this rule "The order contains shippable products". I also unchecked the tickbox labelled "Require a shipping service at all times, preventing checkout if none are available." in Store-> Configuration-> Checkout Settings, and Shipping Service pane config.

This seemed to have done the job. However I had the Shipping Service pane in the "Shipping" part of the Checkout process, so now if you're buying non shippable products, you enter your details in the first page, then go to the Shipping page it displays a blank form with a Continue or Go back buttons to proceed to the Review page.

Is there a way to go straight to the Review page if there's no shippable products?


texts: Theme change removing blocks but keeping reserved machine names

texts:
Not sure if this is a silly question or not...

I am using Drupal 8.

I was messing around with a sub-theme to a custom theme I am making. For now, the sub-theme has almost nothing in it and all the same regions as the custom parent theme.

When I swapped back to the parent theme as the running theme it dumped all my blocks into the header (ok, annoying but fine) but it also removed a number of blocks I had created.

For example, I had created several copies of the 'Site Branding' block with different settings which I then gave custom machine names to and styled with some twig template files. They were all missing but when I tried to recreate them I encountered a machine name already in use error.

Is there a way to avoid this happening or having the machine names also be removed when the theme changes?

Ultimately, once the theme and base theme and an accompanying module are complete I plan to properly install and uninstall all these blocks programmatically but while I am experimenting I would like to be able to switch themes without breaking all my template files.


texts: How to force regeneration of Twig templates?

texts:
Twig generates classes for its templates. These classes are effectively caches by being written to disc.

Generally speaking, one probably doesn't need to bother with the details of how the twig templates are handled, but there could be cases when the Twig templates must be manually re-generated. (Similar to the need for the Registry rebuild module in D7)

If it's relevant, I'm asking because I'm stuck with an error that looks like this:

  Fatal error: Class '__TwigTemplate_ddad913164239ac659c2bca09b3a49a5' not found in core/lib/Drupal/Core/Template/TwigEnvironment.php on line 107


texts:
I am listing the fee of students in a view developed using views 3. How can I show the total of fee for all records displayed at bottom as Total Fee:

Thanks for your help.


texts: What are the equivalent functions that I should use for HTTP handling?

texts:
Looking at the functions listed in the HTTP handling page for Drupal 7, I noticed that the following functions don't exist anymore in Drupal 8. (The links are for the Drupal 7 documentation pages, where the links to the Drupal 8 documentation for those functions are missing.)

drupal_access_denied()
drupal_get_query_array()
drupal_goto()
drupal_http_request()
drupal_not_found()
drupal_site_offline()

What functions/methods should I instead use in Drupal 8?


texts: How to add a custom antispam questions in User registration Form

texts:
Recently I am receiving some user registration Spams...I use reCaptcha module but I want to add a anti-spam questions while User registers registration as you see in many forum sites.

Does anybody know how to do that ?...is there any module ..?


texts: Setting a #default_value to a select list during Feeds import

texts:
I need to set an entity reference select list's #default_value during (or after?) a Feeds import of Commerce products. Two term reference fields are used as arguments in the entity reference view that the product's entity reference field uses, and there is always one result. I set the entity reference field to required to avoid the pesky -None- option in the list, so, when you view a product's page, the entity reference field appears to be filled in correctly. Alas, it is not. No #default_value is set. This is the code I have so far, but I'm not even sure I'm even using the right hooks for this because of the use of Feeds to add and update products:

function set_keywords_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'commerce_product_ui_product_form') {
$form['#after_build'][] = 'set_keywords_after_build';
}
}

function set_keywords_after_build($form, &$form_state) {
$form['field_product_keyword']['und']['#default_value'][] = 0;
return $form;
}

The logical thing to do would be to scrap the custom module and set it in the Feeds importer, but so far, I have not found out how to do that. What bugs me the most is that manually going into each product page and simply hitting Save will do exactly what I need.


texts:
I created a migrate script to import hundreds of records into a specific content type. A year after, I need to add another field to the content type and import values specific to each record. Because of changes made to some of the records over the past year, I cannot re-import the content from the csv file with the additional column. I am using config-edit to edit the migrate .yml file. Is there a way to rerun the migration to import content for the new field while ignoring all other fields that already have content.

I am using Drupal 8.

Thanks,


texts: Get number of hits on user page into a view

texts:
Possible Duplicate:
  how to track user profile page views?

I would like to know how much time a user's page has been viewed, to sort my users by most total views.

My statistic module is active, and configured, but, i'm only able to retrieve the "content statistics: total views".

Is anyone have a solution?

Thanks,

-- Drupal 7, views 3


texts: Escaping special characters in Apache SOLR search

texts:
In Drupal 7 ,

On typing asdas;' in search box and searching,i get blank page.I have
integrated Apache solr search in drupal 7.

SOLR VERSION: solr-4.7.2
Drupal Module Used: apachesolr (https://www.drupal.org/project/apachesolr)

I don't know how to escape such special characters.

; means end of solr query.i think that is causing such issue.

Site is indexed.And after integrating solr search you get two options when you search a keyword:(see attached image)

site(this is solr search option)
content(default drupal nodesearch).

For now i have disabled default drupal search i.e node search.

I am using only solr.And now on searching  asdas'; i get a blank page.

Keynote: only keyword asds;' i.e Key word having semicolon gives blank page else search works properly.

Attached is example image. Content tab is default drupal search and site tab comes after you integrate apache solr. In my case only site comes as i have disable content search.


texts: How to force account creation before commerce checkout is complete?

texts:
I currently have a one-page checkout that works great for anonymous users. After payment is complete, an account is created with the 'Create a new account for an anonymous order' checkout rule.

Now I need to add a subscription product to the site, and plan to use Commerce License and Commerce License Billing to sell a role. To handle recurring payments, I plan to use Commerce Card on File.

This introduces a problem because Card on File requires an authenticated user in order to save cards. See https://www.drupal.org/node/1553468

How can I create a user account before checkout finishes so that Card on File can properly save cards?

Ideally, there would be a custom checkout page that forces account registration as a first step in checkout, but only for users purchasing subscription products.

I don't allow visitors to register on the site at the moment (except via Commerce Checkout), and I'd rather not change that.


texts: Is there any module or some configuration that I can define the meta tags for the views page display in drupal 7 using Views 3.0?


texts: Form validate & submit functions not firing on form loaded with AJAX

texts:
I've created a form that is loaded with ajax when clicking on a button, but the form validation doesn't work (and so is my custom submit function).
The regular (Drupal's) form validation did work when I used MENU_NORMAL_ITEM and entered the form to a test page, but now when I'm using the current code it's not working.

I guess that when I'll manage to "fix" Drupal's form validation I'll also be able to use my custom submit function.

My code:

function MYMODULE_menu() {
  $items['ajax/my_ajax_page'] = array(
      'title' => 'My title',
      'page callback' => 'MYMODULE_my_ajax_callback',
      'type' => MENU_CALLBACK,
      'access arguments' => array('access content'),
  );

  return $items;
}

function MYMODULE_my_ajax_callback() {
  print render(drupal_get_form('my_form'));
  drupal_exit();
}

Thanks.


texts: How do I create individual fields on a node?

texts:
I would like to use individual Taxonomy fields on a node - not a preconfigured Content Type. e.g.

Color: Red
Year: 2015
Project details: Short description.

This is just working fine with the Core Field Module. The downside of it is that it's preconfigured on the Content Type. Users can’t add more fields to a node. I need more flexibility. E.g: Thus, I am using a text field with unlimited Number of values.

Example with Core Text Fields

However I am missing Taxonomy’s term reference feature: People have to type in all data on every node. I hope this makes sense. I’ve created a quick mockup to show what I am looking for. I would love to define individual description and Taxonomy terms.

What’s the best way to get full flexibility?


texts: How to prevent views to replace single quotes with double quotes in HTML output?

texts:
I'm using the rewrite option of a view field to generate some HTML. One tag has a data attribute, which should contain an array for later use in JavaScript with JSON.parse():

…

For JSON.parse() it is necessary to enclose the array fields within double quotes, therefore I have to use single quotes for the enclosure of the HTML attribute. The output should look as follows:

…

But somewhere in the process Drupal replaces the singe quotes with double quotes, changing the output to:

…

Which apparently is misformatted.

My question is, why does this happen, where does it happen, and is there a clean workaround?

I know, that it would be a much cleaner approach to write a custom views field. But then again, this feels a bit like an overkill.


texts: How do I change theme for tables rendered with theme_table()?

texts:
I'm willing to change look and feel of Drupal tables. I was building my own theme using Zen's STARTERKIT, and the current look and feel is not pretty.

How can I change template for tables? Specifically, I like the table theme being displayed in Administration theme/Admin panel. How do I use that theme for my tables?


texts: Using "Security Review" gives file permission errors, how to fix them?

texts:
I've searched the drupal docs and all over the internet, but I don't find a concrete answer regarding what file permissions the drupal directory should have.

I've been redirected to this page: http://drupal.org/node/244924

On almost every search, but this page doesn't actually tell me what each file's permission should be. I'm trying to pass "Security Review's" permission test, but it literally says ALL my files have wrong permissions.

I know its a very specific question, but can anyone give me a specific CHMOD number for each directory and files in the directories?? I've spent a good portion of the day looking for this with no success..


texts:
Trying to look an answer for this but couldn't.

Default workflow of Drupal adding content is: "Add Content" > Choose Content Type. Can I just make my website to do direct adding content without need to choose the content type in advance?


texts:
I'm experiencing an issue on multiple sites where (image) media aren’t appearing in blocks despite working fine in node fields.
I first thought it only happened to me when using the linkicon module, but since then i created a custom block type for image blocks (using entity reference media fields) and the same thing happens, ie. the html renders nothing:

There's no problem rendering the fields in nodes on the same sites using the exact same display settings.
I've checked both the media, block and block_content logs and they show no errors.
My setup:

Drupal 8.9.7
Barrio 5.1.3
Local environment running on ddev
Remote environment running on cloudways

Any ideas what the issue might be?


texts: How to manually or programmatically delete a field?

texts:
I tried creating a field, but my server crapped out halfway with an Internal Server Error due to some spambot attack...

Now, when I try to add the field again, I am getting:

  The machine-readable name is already in use. It must be unique.

I guess some tables were populated in the db. How can I remove these easily?


texts: "Did not meet requirements; missing migrations" error

texts:
In a custom D6->D8 migration module, how does one selectively migrate specific content-types, vocabs and blocks, etc, without receiving the error: 'XXX did not meet requirements. Missing migrations XXX'

I can already selective limit via migrate_prepare_row(), but anytime I do so content related to anything not migrated makes MI throw this error and fail.

Is there any core process plugin that addresses this type of scenario per row?


texts: How to get nodes by custom field value using EntityFieldQuery?

texts:
I am trying many options, e.g:

$entities = $nodeQuery->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'article')
    ->fieldCondition('field_archived','field_archived_value', '1', '=')
    ->pager(10)
    ->execute();

field_archived is the machine name of my custom field added to article. field_archived_value is a column inside field_data_field_archived table.

In this case I am getting error:

PDOException: SQLSTATE[42S22]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'field_archived_field_archived_value

What I am doing wrong here?


texts: Views page list of all content grouped by taxonomy term

texts:
I have created a view in Drupal 7 that displays all nodes that contain a particular taxonomy vocabulary. The view contains a page in an unformatted list format set to show content | teaser. All I am trying to do is to group the list by the specific taxonomy term. Here is an example of what I'm talking about:

TERM A
Title
Teaser

Title
Teaser

TERM B
Title
Teaser

I've scoured the web and have only found solutions for displaying EITHER taxonomy terms OR content, but not both. Am I missing something? Is this not possible with Views?

Thank you so much to whomever can help, I've been agonizing over this for days.

-Dave


texts: How to send email to "anonymous" user when a new node is created

texts:
I've been looking at a couple of modules and none of them seem to work the way I want to.

I'd like to display a textfield for an anonymous user to enter his email. Everytime a node of a certain type (blog post) is created, an email would be sent to every person who gave their email.

How could I achieve that in Drupal 7 ?

Thanks


texts: How to add webform to existing content type?

texts: I have installed Webform and would like to add it to my custom content type. I have checked my content type under admin/config/content/webform and saved the webform settings but I still don't get the option to add a webform to my content type.


texts: D6 to D7 upgrade error Invalid datetime format Incorrect integer value

texts:
After upgrading a D6 to D7 site. I get this error when trying to save an existing page on the site that has uploaded image files, and the page will not save. If I remove the uploaded files, the error goes away and I can save the page.

  PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect
  integer value: '' for column 'field_upload_inline_image_width' at row
  1: INSERT INTO {field_data_field_upload_inline_image} (entity_type,
  entity_id, revision_id, bundle, delta, language,
  field_upload_inline_image_fid, field_upload_inline_image_alt,
  field_upload_inline_image_title, field_upload_inline_image_width,
  field_upload_inline_image_height) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4,
  :db_insert_placeholder_5, :db_insert_placeholder_6,
  :db_insert_placeholder_7, :db_insert_placeholder_8,
  :db_insert_placeholder_9, :db_insert_placeholder_10); Array (
  [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 37
  [:db_insert_placeholder_2] => 25955 [:db_insert_placeholder_3] => page
  [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und
  [:db_insert_placeholder_6] => 24 [:db_insert_placeholder_7] => NNSA
  Headquarters [:db_insert_placeholder_8] => [:db_insert_placeholder_9]
  => [:db_insert_placeholder_10] => ) in field_sql_storage_field_storage_write() (line 514 of
  /var/www/html/upgrade2a/modules/field/modules/field_sql_storage/field_sql_storage.module).

This is my table structure field_upload_inline_image, do i need to alter the Type or Null column?

entity_type (Primary) varchar(128)  No The entity type this data is attached to
bundle varchar(128) No The field instance bundle to which this row belongs, used when deleting a field instance
deleted (Primary) tinyint(4)    No 0 A boolean indicating whether this data item has been deleted
entity_id (Primary) int(10) No The entity id this data is attached to
revision_id int(10) Yes NULL The entity revision id this data is attached to, or NULL if the entity type is not versioned
language (Primary) varchar(32)  No The language for this data item.
delta (Primary) int(10) No The sequence number for this data item, used for multi-value fields
field_upload_inline_image_fid int(10)   Yes NULL The file_managed.fid being referenced in this field.
field_upload_inline_image_alt varchar(512)  Yes NULL Alternative image text, for the image’s ’alt’ attribute.
field_upload_inline_image_title varchar(1024)   Yes NULL Image title text, for the image’s ’title’ attribute.
field_upload_inline_image_width int(10) Yes NULL The width of the image in pixels.
field_upload_inline_image_height int(10)    Yes NULL

I'm using Media 7.x-1.5 Bundled with File entity 7.x-1.5. I am not using UUID module.
maybe I need to then I will need
the file_managed table is missing the uuid column


texts:
Is there any way to theme or override the Site off-line page?

The page with below massage:

  The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.

This page uses Garland by default and it has Drupal logo on the page.
I would like to remove this Drupal logo and also change the texts.


texts: Change max length of signature field to more than 255 characters

texts: How can I change the max length of the drupal 7 signature field to more than 255 characters? I've already changed the sql data type from 255 to varchar(900), yet drupal still shows the error, as soon as a user wants to update his signature to more than 255 characters.


texts:
I am trying to set up a cron job that automatically backups up a Drupal site using drush but then encrypts that file. I would like to accomplish this using a single command but am not sure how to go about it.

Here is the command that does the backup and logs any messages (this works):

drush @mysite archive-dump --destination="/home/drush-backups/archive-dump/mysite.$(date +\%F_\%H-\%M-\%S).tar.gz" &>> /var/log/mysites/$(hostname -s)/drush-cron.log

However when I try this:

drush @mysite archive-dump --destination="/home/drush-backups/archive-dump/mysite.$(date +\%F_\%H-\%M-\%S).tar.gz" | gpg -e -r mypublickey &>> /var/log/mysites/$(hostname -s)/drush-cron.log

It does not work. Any ideas where I am going wrong? What is the correct command?

Thanks.


texts: I know that I can attach a field to any content type. I have to attach a field to all content types in a my site which are more than 40 content types. It is hard for me to attach this field manually. I'm seeking for an automated way to do this. Is there any module to do that?


texts: How do I programmatically get the field type of a specific field?

texts:
I'm able to get a list of the field types with the following code.

$defs = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();

I want to get the field type of a specific field. How do I get it?

For example, I'd like to check if the field type of field_image is _image. Is there code similar to the following one?

$fieldType = \Drupal::service('plugin.manager.field.field_type')->getDefinition('field_image');


texts: I am using Drupal 7. I want to show my account page as a block, where user can edit their personal information. Does anybody have an idea regarding this. Do I need to write custom module? Thanks


texts: How to display "About the author" tab in article display page?

texts:
I want to basically override the normal display of article, to include two tabs in that. One tab will be "Read Article", which when clicks loads the article page. Others tab will be "About the Author", which when clicks loads the author page.

So ultimately when I go to any article page, there will be two tabs, "Read Aricle" (selected by default), and "About the author".

Please suggest how can I achieve this. I have tried overriding node display by using Panels, but I am not able to add links or display author information in another tab.

-- Thanks for your time.


texts: Anonymous users getting same product items in cart

texts:
I am using drupal commerce module, i have an issue with anonymous users, when users click on add to cart button, cart is showing extra items which are added by other anonymous users.

I am using custom code for add to cart using ajax. following is the code.

    // Add a product to cart on ajax call.
    function mymodule_custom_add_to_cart($product_id,$uid){
        $line_item = commerce_product_line_item_new(commerce_product_load($product_id));
        commerce_cart_product_add($uid, $line_item);
        $order = commerce_cart_order_load($uid);
        commerce_cart_order_refresh($order);
        // loads data array from order object
        $data = mymoudle_custom_cart_load_all_variables($order->order_id);
        $jsonencoded = json_encode($data);
        print $jsonencoded;
    }

I dont know why all anonymous users are getting same products in there cart.

Please help me to find out the issue.

UPDATE 1:

I have changed the code for anonymous user as following, then i am getting an error: EntityMetadataWrapperException: Unable to get the data property data as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 451 of /entity.wrapper.inc

CHANGED CODE

    // Add a product to cart on ajax call.
    function mymodule_custom_add_to_cart($product_id,$uid){
        if($uid == 0){

            $order_id = commerce_cart_order_id($uid);
            if($order_id == false){
             $order = commerce_cart_order_new(0, 'checkout_checkout');
            } else {
             $order = commerce_order_load($order_id);
            }

            // Load whatever product represents the item the customer will be
            // paying for and create a line item for it.
            $product = commerce_product_load($product_id);
            $line_item = commerce_product_line_item_new($product, 1, $order->order_id);
            commerce_line_item_save($line_item);

            // Add the line item to the order using fago's rockin' wrapper.
            $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
            $order_wrapper->commerce_line_items[] = $line_item;

            // Save the order again to update its line item reference field.
            commerce_order_save($order);

            // loads data array from order object
            $data = mymoudle_custom_cart_load_all_variables($order->order_id);
            $jsonencoded = json_encode($data);
            print $jsonencoded;
        }else{
            $line_item = commerce_product_line_item_new(commerce_product_load($product_id));
            commerce_cart_product_add($uid, $line_item);
            $order = commerce_cart_order_load($uid);
            commerce_cart_order_refresh($order);
            // loads data array from order object
            $data = mymoudle_custom_cart_load_all_variables($order->order_id);
            $jsonencoded = json_encode($data);
            print $jsonencoded;
        }
    }

UPDATE 2: ISSUE RESOLVED.

Site is crawling by googlebot, which is clicking addtocart link and its adding an product to anonymous user account automatically, so i removed link for addtocart button and used commerce addtocart form.


texts: How do I display the "recently created node" block using Views?

texts: I am trying to show the recently added content data in a block, using the Views module, but I can't see any record even if I recently added some nodes.


texts: I'm using drush to automatically build Drupal 7 sites.  I want to have each of the new generated sites use a custom logo.  I've been searching for a drush command that will allow me to set the path for the logo to a folder in the .../sites/siteName/files/  folder, but cant find one.  Can this be done with drush?


texts: Checking site performance on remote vs. locally

texts:
I had read a blog article recently describing how to set the settings on your local host to be a reasonable comparison to a remote host in order to test Drupal configurations and performance issues before pushing code up to the remote.

What settings should I change?
Is it true that the performance should be about the same if the settings are comparable?


texts: I made an AJAX email page that allows the user to send a short email, and it loads a separate page showing a message similar to"Your email has been sent." Can I make that last page (the one that shows the message) unsearchable? It's just a success page, and I think it shouldn't come out in any search result.


texts: Views Slideshow: how to change items per slide based on screen resolution

texts:
I have a Views Slideshow slider with 3 items per slide (see below).

I am looking for a way to make it change the items per slide number dynamically when the screen width hits a certain breakpoint -for example 2 items per slide on tablet screen and 1 item per slide on mobile screen.

Been trying for few days but without success.
I'm able to access the number of slides in the JSON
 var slideNumber = drupalSettings.viewsSlideshowCycle["#views_slideshow_cycle_main_publications_featured_slider-block_1"].items_per_slide;

Any ideas are welcome.


texts: Custom Submit Handler to Integrate Payment Gateway in a Webform

texts:
I would like users filling up a webform in my site to make a payment before the form is submitted. The form should be submitted if the payment is successful else an error message should be displayed.
Is a custom submit handler with the payment gateways code/api in submitForm() a good way go about doing this?
Thanks for your help


texts: How can I add a class to a title of a view?

texts:
I'd like to add a class to the title (H1) of a view, so that a specific style could be applied. This is Drupal 6 with a Zen subtheme.

Thanks