texts: Change size of views exposed form search box

texts:
Im using hook_preprocess_views_exposed_form to change the output of my views exposed search box.  I am able to successfully change the text on the search button, but I am not able to change the size.  I cant figure out where I am going wrong.  Here is what I have:

function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
  // dsm($vars['form']);
  if ($vars['form']['#id'] == 'views-exposed-form-all-page') {
    $vars['form']['submit']['#value'] = t('Go');
    $form['text']['#size'] = '90';
    unset($vars['form']['submit']['#printed']);
    $vars['button'] = drupal_render($vars['form']['submit']);
  }
}

This is what I am stuck on:

$form['text']['#size'] = '90';


texts: How to conditionally send emails Drupal 8 Webform

texts:
I am trying to figure out how to do the following; based on a submitted value change the email behavior:

If (field 'send' value == no) then don't send the email
If (field 'member' value == yes) then change the email message

If I can find out how to do #1 above I could use that to achieve #2, in fact I suspect they have the same answer. I am looking for a hook but perhaps that is just me being stuck in D7 style of doing things.


texts: How to display search block in a modal dialog

texts: What I would like to accomplish is to display the search block in a modal dialog when the user clicks on a search button that I have created. I have created a search button block (basically an image with a link) and now I would like to point to the search block and have it appear in a modal dialog. I just don't know to go from here, or if it is even possible to go this route. Can someone provide some pointers on what I need to do?


texts: How to get All options of a 'select' field?

texts:
How can I get all options for a cck field?

For example, There is a field with 3 options in allowed values, like option1, option2, option3.Is there any function which receive the field name and returns option1 to option3?


texts: How to Add rel="nofollow" in "Add new comment" link in teaser?

texts:
Is there a code to add rel="nofollow" in the "Add new comment" link under teaser?

This is the code in the teaser as generated by D7:

Add new comment

So how I do I add rel="nofollow" in that line?


texts: Batch operation keeps looping after completion

texts:
The batch operation I created works fine, until it's done.  Once it's done it just loops back and does it again.  It will loop through until the VM runs out of resources.

I am fairly certain this has to do with my completeImport method.  If I throw a syntax error in there it will finish the import successfully but then error out once it gets to that method.

The controller for the batch op: (I ommited methods that had nothing to do with the batch itself.  They were for CRUD or building URLs.)

class MyModuleController {

  public function import() {
    $endpoints = array(
      'courses' => $this->getEndPoint('courses', NULL),
    );

    foreach ($endpoints as $data_type => $endpoint) {
      $response = $this->getResponse($endpoint);
      $operations = MyModuleController::processResponse($response, $data_type);

      $batch = array(
        'title' => 'Importing ' . $data_type,
        'operations' => $operations,
        'finished' => 'mymodule_complete_import',
        'init_message' => t('Importing...'),
        'progress_message' => t('Operation @current out of @total.'),
        'error_message' => t('Batch failed.'),
        'file' => drupal_get_path('module', 'mymodule') . '/mymodule.import.inc',
      );

      batch_set($batch);

      return batch_process('academy/courses/import');
    }

    return array(
      '#type' => 'markup',
      'value' => t('Imported?'),
    );
  }

  public static function processResponse($response_data, $data_type) {
    $operations = array();

    foreach ($response_data as $data) {
      switch ($data_type) {
        case 'courses':
          // Used to look up if a course was already imported.
          $id = (string) $data->Id;

          $data_array = array(
            'Name'                      => (string) $data->Name,
            'Active'                    => ((string) $data->Active == 'true' ? 1 : 0),
            'CourseCodeForBulkImport'   => (string) $data->CourseCodeForBulkImport,
            'EcommerceLongDescription'  => (string) $data->EcommerceLongDescription,
            'EcommerceShortDescription' => (string) $data->EcommerceShortDescription,
            'ForSale'                   => ((string) $data->ForSale == 'true' ? 1 : 0),
            'Code'                      => (string) $data->Code,
            'Id'                        => $id,
            'OriginalId'                => (string) $data->OriginalId,
            'Price'                     => (string) $data->Price,
            'Description'               => (string) $data->Description,
          );

          break;
      }

      $operations[] = array(
        'mymodule_response_importer',
        array($id, $data_array, $data_type),
      );
    }

    return $operations;
  }

  public static function completeImport() {
    return new RedirectResponse(Url::fromRoute('system.admin_content'));
  }

}

mymodule.import.inc:

function mymodule_response_importer($id, $data, $data_type, &$context) {
  $entity = MyModuleController::findExisting($data_type, $id);

  switch ($data_type) {
    case 'courses':
      if ($entity === FALSE) {
        MyModuleController::createNode($data);
      }
      else {
        MyModuleController::updateNode($data, NULL, $entity);
      }

      break;
  }
}

function mymodule_complete_import() {
  MyModuleController::completeImport();
}


texts: How to use leanModal for loading a node or content in Drupal 7?

texts: I'm using this http://leanmodal.finelysliced.com.au , but unable to achieve the goal since I need that after clicking on my button the new content or a url for an instance node/3 should get load in this modal, any idea how can I do it?


texts: Ignore certain state transitions in Workflow

texts:
Is it possible to disable certain state transitions with Workflow?

I have 4 states: Pending, Approved, Denied, and Urgent. A node goes directly to Pending when saved, where an editor can either Approve or Deny it. Deny kicks you back to Pending. Urgent happens when an editor hasn't reviewed a node in 7 days. Then it can also be Approved or Denied.

As Workflow is now, you can transition from any one state to any other state. But I have no use for going from, say, Approved back to any state, or from Denied directly to Approved. Is there a way to disable the transitions I don't need to use?


texts: Preventing frequently updated nodes from keeping them on the top of View

texts:
I have a view that lists content profile node and set the sort criteria to node:Updated date.

However, the problem is that some of the users updates their content profile node everyday to keep it on the top of the list.

I need to user sort criteria to node:Updated date but is there any way to prevent their nodes from being on the top of view?

Lest's say for example, within one week after their last update even if they update it again it stays where it is now and doesn't get to the top or somthing.


texts: How to remove the zip code field from the checkout page?

texts: I have a Drupal 8 website with Drupal Commerce 2.x. I want to disable the zip code field in the checkout page. How can I do this?


texts:
I have a conditional CCK field which displays if another field is checked.  This conditional CCK field is a required field.

However, if the first field is NOT checked, the conditional field is still validated.

How can I solve this problem?


texts:
How can I remove fields from the CKEditor dialog window?
In my case, I need to remove the "Caption" field from the "Table Properties" window. How can I do that?


texts: Administrator settings vanished for sheetnode content type nodes

texts:
I installed the sheetnode module. It was working ok and then the next time I clicked on "Edit" on the node, the following happened:

I don't know how the links for Publishing options, URL Path settings etc got disabled. I run as an administrator and I edited my permissions too (grant everything under sheetnode module to admin) but to no avail. Please help me get back to those links.

I run drupal 6.


texts: How to read testbot feedback / get more info

texts:
I have created a patch for migrate_spreadsheet, unfortunately it will not pass the testbot. Instead that gives me this (to me cryptic / uninformative) message:

  fail: [run-tests.sh check] Line 0 of : FATAL
  Drupal\Tests\migrate_spreadsheet\Unit\SpreadsheetIteratorTest: test
  runner returned a non-zero error code (255).

Where/what is line 0? My first change compared to the original file was on line 7, where I corrected a class name. The only other two changes in that file where in the docs.

So what does this fail mean?
How can I get more info from the testbot?


texts:
I have a custom form which currently shows on a page. The form is submitted via ajax and the view embedded is also updated via ajax. I do not want to show the form on a page. Instead I want to show it in a block. I should be able to put the block anywhere on the website.

This is my form

/**
 * Provide a form.
 */
function MYMODULE_form($form, &$form_state) {

  $form['wrapper'] = [
    '#type'       => 'container',
    '#attributes' => [
      'id' => 'mywrapper',
    ],
  ];

  $form['wrapper']['node_form'] = [
    '#type'  => 'fieldset',
    '#title' => t('Add article'),
  ];

  $form['wrapper']['node_form']['node_title'] = [
    '#type'     => 'textfield',
    '#title'    => t('Article title'),
    '#required' => TRUE,
  ];

  $form['wrapper']['submit'] = [
    '#type'   => 'submit',
    '#value'  => t('Save'),
    '#submit' => ['MYMODULE_form_submit'],
    '#ajax'   => [
      'callback' => 'MYMODULE_MYCALLBACK',
      'wrapper'  => 'mywrapper',
    ],
  ];

  $form['wrapper']['view_display'] = [
    // view machine name && display/block name
    '#markup' => views_embed_view('nodes', 'block'),
  ];

  return $form;
}

/**
 * Do some validation.
 */
function MYMODULE_form_validate($form, &$form_state) {
  // Better do some validation.
  // Here or via #element_validate.
  // @see https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7.x#element_validate
}

/**
 * Form submit. Node creation.
 */
function MYMODULE_form_submit($form, &$form_state) {

  global $user;
  $node = new stdClass();

  $node->type     = 'article';
  $node->title    = $form_state['values']['node_title'];
  $node->language = LANGUAGE_NONE;
  $node->uid      = $user->uid;

  node_object_prepare($node);
  node_save($node);

  // Empty out title field on rebuild.
  $form_state['input']['node_title'] = '';

  // Rebuild form.
  $form_state['rebuild'] = TRUE;
}

/**
 * Ajax callback to return the whole wrapper.
 */
function MYMODULE_MYCALLBACK($form, &$form_state) {

  return $form['wrapper'];
}

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {

  $items['example/form'] = [
    'title'            => 'Example Form',
    'description'      => 'A form to mess around with.',
    'page callback'    => 'drupal_get_form',
    'page arguments'   => ['MYMODULE_form'],
    'access arguments' => ['create article content'],
  ];

  return $items;
}


texts: How can I get Elysia Cron to run every 15 minutes?

texts:
I'm running drupal 7 on a shared host with cpanel and apache. I don't want to use regular cron because i want to run some tasks more regularly than others such as the search index. So i added Elysia Cron module. It doesn't run at the regular intervals I intend though. I'm hoping you all can give me some guidance.  Here's how I set it up:

I added a cron job in my cpanel like so:

http://mysite/sites/all/modules/elysia_cron/cron.php?cron_key=key and set the frequency to *****.

Then in Drupal I went to admin > configure > elysia cron and did the following:

Set search to run every 15 minutes and everything else either every hour or every day.

I also set the installation settings so that 'never/use external crontab' is selected for 'run cron on visitor's requests, every'.

But when I save these settings...cron doesn't run every 15 minutes for the search index as planned.

Any idea what else I might need to change?


texts: Access custom fields on account of current logged in user

texts:
I am trying to do something which seems like it would be pretty damn simple, yet I can't get to work; access a custom field (added via the UI at /admin/config/people/accounts/fields), for the current logged in user. I have tried example after example, but when it comes to accessing the field value itself, nothing works. Loading the user object is pretty straightforward, but when it comes to getting the actual field values, neither get() nor any other option has worked for me. In my case, I added a multi value entity reference field called field_distributors that references a Distributor node type, and I just need to access those fields in a form to set values for a select list.
use Drupal\user\Entity\User;

$user = User::load(\Drupal::currentUser()->id());

works to get a loaded user, object, and I can see the fields in both $user->fields and $user->values. How do I access those values?


texts: How to render a multiple value field of type generic file

texts:
If I use the textformatter module (included textformatter_contrib) I can display a repeatable field with links as a list.

By selecting 'list' as format for the full view of the field of the content type.
I can't select 'list' for the file field.
The default format for my file field is 'generic file'


texts: Best practice two domains on one codebase and database

texts:
I have one main domain name at site.com and I simply want to create blog.site.com using the same codebase and database. The only ways I see I can do that are by:

Using another install
Using a multi-site install
Using Domain Access

Among those 3 options, the most straightforward way to keep using one single codebase and database seems to be Domain Access but I wonder if it's not overkill for my use case?

This is with Drupal 7.


texts: Display taxonomy terms from a vocabulary as columns in a Views table

texts:
I have a content type called Resource with two taxonomy fields: States (Alaska, Arizona, Arkansas, etc.) and Type of Resource (Handbook, Standards, Training).

So a piece of content would have the following:
Content Title
State: Arizona
Type of Resource: Handbook

I am trying to create a table of data in Views that would display taxonomy terms across the top of the table as headers and then I'll use views aggregation to pull the number for each as such:

|States    |Handbook    |Standards    Training
|Alaska    |            |2            |1
|Arizona   |1           |             |

I am able to get a total count of resources for each state:

|States    |Total Resources
|Alaska    |3
|Arizona   |1

But have been unable to figure out how to get taxonomy terms into my field as column headers, any ideas?

Uses Views 7.3.


texts: How to delete all parent references of a taxonomy term?

texts:
How to delete references to parent terms?

I tried this:

$term->get('parent')->setValue(NULL);
$term->save();

Additional question: how to delete reference to a specific parent term?


texts: How can I change the way list appears when I click a tag?

texts: When I select a tag link, result shows the title and content. How can I change the list of related article appears only with title and not include any content please?


texts: Disable a 'enter/return' key function in a form

texts:
I have a form in which a user needs to fill the fields. As only two fields are the required fields, so when user fills the required fields and press enter(windows)/return(mac) key the form gets submitted. I'm trying to disable the enter/return key function. So, for this I tried to inject a jQuery within the form.

my jQuery is as follows:

(function ($) {
Drupal.behaviors.YOURTHEMENAME = {
attach: function(context, settings) {
$("input").keypress(function (evt) {
var enterCode = evt.charCode || evt.keyCode;
if (enterCode  == 13) { return false;
}
});
  }
});
}
};
})(jQuery);

The jQuery part is familiar to me, but it doesn't work in the site. And the form responds to enter/return key press.

Is there any other way to disable enter/return key press. something like a module..


texts: How to change order of custom module theme output?

texts:
I need to add some top links and sub top links . I altered hook_theme function and created two templates for these
code is like this-

function acts_theme() {
    return array(
            'acts_top_links' => array(
                    'variables' => array(
                            'links' => NULL,
                            'activelink' => NULL,
                        ),
                    'template' => 'acts-topmenu',
            ),
            'acts_submenu_links' => array(
                    'variables' => array(
                            'links' => NULL,
                            'activelink' => NULL,
                        ),
                    'template' => 'acts-submenu',
            ),
    );
}
function template_preprocess_acts_top_links(&$variables){
    $toplinks=$variables['links'];
    $activelink=$variables['activelink'];
    $variables['toplinks']=$toplinks;
    $variables['activelink']=$activelink;

}
function template_preprocess_acts_submenu_links(&$variables){
    $toplinks=$variables['links'];
    $activelink=$variables['activelink'];
    $variables['sublinks']=$toplinks;
    $variables['activelink']=$activelink;
}

Now I am using these theme output as-

function acts_display(){
    $build['acts_toplinks'] = array(
            '#theme' => 'acts_top_links',
            '#links' => $toplinks,
            '#activelink'=>'Company Law',
    );
    $build['acts_sublinks'] = array(
            '#theme' => 'acts_submenu_links',
            '#links' => $submenulinks,
            '#activelink'=>'/companylaw/acts',
    );

    $build['acts_table_rows'] = array(
            '#theme' => 'table',
            '#rows' => $rows,
            '#empty' => t('Currently there are no active content'),
    );
return $build;
}

I expect output as -
first to show- top links, then sub menu links and then table but output exactly reverse-
first I get table,then sub menu links and then top links
How can I achieve this?


texts: Pathauto and Token to get the first child term

texts:
I am trying to create URL path aliases patterns with Tokens and Pathauto.

My main issue is how to I get the child of a parent of a taxonomy term? So my url is something like this.

[child-term:name]/[node:name]

In tokens help page I can see a lot [term:parent] references but not child ones. I am sure is something simple but in the vast amount of tokens I cannot seem to find it.


texts: Is it possible to limit which products users can purchase by role?

texts:
I have three products, A B and C. Anyone can buy products A or B, but only users with the VIP role should be able to buy product C.

How can I make sure users don't see product C if they don't have the VIP role?  (It would be best if they could not buy it at all, but I will settle for a solution that simply hides it.)  My products are displayed in a view using a Product display content type.


texts: Change the e-mail value during user registration ?  form_set_value()

texts:
I have a custom module (entitled ta_module) : in the user registration form, it hides the e-mail field, and add a custom field where user have to enter what's before @ and then choose his e-mail domain name between the one proposed in a list next to it.

Here's the code :

<?php

/**
 * Implementation of hook_form_alter()
 */
function ta_module_form_alter(&$form, &$form_state, $form_id) {

   // If the form is the user_register form
    if ($form_id == 'user_register_form') {
        // Attach our custom validation function as the first validation function
        array_unshift($form['#validate'], '_ta_module_user_validate');
        // Hide the email address field
        $form['account']['mail']['#type'] = 'hidden';
        // Give the email address field a random default value (in this case a random number and a timestamp)
        // as we cannot unset it due to Drupal's validation rules
        $form['account']['mail']['#default_value'] = rand(1111, 9999) . '@' .time() . '.com';
        // Add our new text entry field
        $form['mail_first'] = array(
      '#type' => 'textfield',
      '#title' => t('Email address'),
      '#default_value' => '',
      '#size' => 35,
      '#maxlength' => 64,
      '#required' => TRUE,
    );
        // Add our select list of possible email domain values
        $form['mail_last'] = array(
      '#type' => 'select',
      '#title' => 'Domaine',
      '#title_display' => 'before',
      '#options' => array(
              // These are the possible email address domains
              'myentreprise.net' => '@myentreprise.net',
              'myentreprise.com' => '@myentreprise.com',
            ),
      '#default_value' => 'myentreprise.net',
      '#required' => TRUE,
    );
    }
}

/**
 * Function to piece together our email address
 */
function _ta_module_user_validate(&$form, &$form_state) {
    // If our two form elements have values
    if (!empty($form_state['values']['mail_first']) && !empty($form_state['values']['mail_last'])) {
        // Set the email address to the correct value
        $form_state['complete form']['account']['mail']['#value'] = $form_state['input']['mail_first'] . '@' . $form_state['input']['mail_last'];
    }
}

(see This Q/A for more infos).

All appear quite brightly, but when the user click on "create a new account", the user is created but the last function of my module doesn't work : the e-mail finally saved is the default value (something like 0129A@I1I101IZ10IZ.com) instead of the two pieces joined together...

HOW TO FIX THIS : Thus how to assign to mail the value of mail-first + mail-last ?

/!\ I'm working on Drupal 7, so I think it's an issue of uncorrect variables...

Thks for reading !  ;)


texts: Drupal 7 timestamp insert into mysql error

texts:
i get error when i want to insert current time to my table-field date,

  i get this error PDOException: SQLSTATE[22007]: Invalid datetime
  format: 1292 Incorrect datetime value: '1345724717' for column 'date'
  at row 1: INSERT INTO {users_history} (uid, nid, points, date, reason)
  VALUES ('31', '107', '2', '1345724717', 'session'); Array ( ) in
  points_node_insert() (line 57 of
  /home/www/live_project/htdocs/sites/all/modules/custom/points/points.module).

i have table like this:

uid int
nid int
points int
date datetime
reason enum

this is my query(this query works fine if i delete date field)

  $date = time();
    db_query("INSERT INTO {users_history}
       (uid, nid, points, date, reason) VALUES
       ('$uid', '$nid', '$points_for_post', '$date', '$reason')");


texts: How to modify a form to have some field surrounded by 'Details'?

texts:
I created a custom content entity with Drupal Console.
Three of its fields are defined this way:
// ----------------------------------------------------------------------------
    $weight++;
    $fields['picture'] = BaseFieldDefinition::create('image')
      ->setLabel(t('Picture'))
      ->setSettings([
        'file_extensions' => 'gif jpeg jpg png',
        'file_directory' => 'sel',
        'alt_field_required' => 0,
      ])
      ->setCardinality(3)
      ->setDisplayOptions('view', [
        'type' => 'default',
        'weight' => $weight,
      ])
      ->setDisplayOptions('form', [
        'type' => 'image_image',
        'weight' => $weight,
      ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
// ----------------------------------------------------------------------------
    $weight++;
    $fields['file'] = BaseFieldDefinition::create('file')
      ->setLabel(t('File'))
      ->setSettings([
        'file_extensions' => 'pdf',
        'file_directory' => 'sel',
        'description_field' => TRUE,
      ])
      ->setDisplayOptions('view', [
        'type' => 'file',
        'weight' => $weight,
      ])
      ->setDisplayOptions('form', [
        'type' => 'file',
        'weight' => $weight,
      ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
// ----------------------------------------------------------------------------
    $weight++;
    $fields['link'] = BaseFieldDefinition::create('link')
      ->setLabel(t('Link'))
      ->setDisplayOptions('view', [
        'type' => 'link',
        'weight' => $weight,
      ])
      ->setDisplayOptions('form', [
        'type' => 'link_default',
        'weight' => $weight,
      ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);
// ----------------------------------------------------------------------------

And the corresponding form looks like this:

I would like to have the 'file' and the 'link' field in something like the 'Picture' field...
I updated buildForm :
public function buildForm(array $form, FormStateInterface $form_state)
  {
    $form = parent::buildForm($form, $form_state);
    $entity = $this->entity;
    $form['link']['widget']['0']['#type'] = 'details';
    return $form;
  }

And I got this:

How can I do the same for the 'File' field (have it surrounded in some 'Details')?


texts:
RSS Feeds: Using Aggregator (Drupal Core) vs Feeds module - which has more features and is more reliable?

It looks like Feeds has more features. Is this true? and is it more reliable?


texts:
with module domain-acces, we can  manage domains and subdomains,
example:

domain.com is my first domain.
user1.domain.com is affected to user1
user2.domain.com is affected to user2

but user1 can connect to user2.domain.com that is my problem.


texts:
I have a specific block that has some form logic, intended for newly registered users. And I am a bit lost on what the logic would look like to render the contents for the form inside a hook_block_view. I've tried using a theme_form() call to get errors, mostly string offset and fatal errors from type comparison. I've tried using drupal_get_form, with the same results.

Here's the code below. Thoughts?

/**
 * Implements hook_block_info
 */
function example_module_block_info() {
  $block['item_select'] = array(
    'info' => t('Select Item'),
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );

  return $block;
}

/**
 * Implements hook_block_view()
 */
function example_module_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case "item_select":
      $block['subject'] = t("Select a book");
      $block['content'] = theme_form('example_module_form_select_item_form');
      break;
  }

  return $block;
}

/**
 * Implements an example form
 */
function example_module_form_select_item_form($form, $form_state) {
  $form['item_type'] = array(
    "#type" => 'select',
    "#title" => t("Make a selection"),
    "options" => array(
      "1" => t("This"),
      "2" => t("That"),
      "3" => t("The Other"),
      "4" => t("Banana")
    ),
  );

  $form["submit"] = array(
    '#type' => 'submit',
    '#value' => t("Save Selection"),
  );

  return $form;
}


texts: Drupal View of CiviMember troubleshooting

texts:
I've created a Drupal View of our current members in CiviMember

SELECT civicrm_contact.organization_name AS civicrm_contact_organization_name,    civicrm_website.url AS civicrm_website_url
FROM
{civicrm_membership} civicrm_membership
LEFT JOIN {civicrm_contact} civicrm_contact ON civicrm_membership.contact_id =  civicrm_contact.id
LEFT JOIN {civicrm_website} civicrm_website ON civicrm_contact.id = civicrm_website.contact_id
WHERE (( (civicrm_membership.status_id IN  ('4', '5', '6')) AND   (civicrm_contact.contact_type NOT IN  ('Individual', 'Household')) ))
ORDER BY civicrm_contact_organization_name ASC
LIMIT 50 OFFSET 0

But it keeps on returning duplicate results, sometimes 3 or 4 in a row and yet they're all single contact records with one current membership? Can anyone see where I've gone wrong?


texts: Most appropriate simple IP direct for Drupal 7

texts:
Having looked at the descriptions provided for the following modules

ip2cc
ip2country
geoip
smart_ip

I'm having trouble identifying which module would be the simple solution to my scenario.

I have established 'Landing Pages' which represent the different countries for my website. (initially)

e.g:
 - www.example.com/au (Australia)
 - www.example.com/us (United States)
 - www.example.com/uk (United Kingdom)

If a user lands at the www.example.com url and they are from IP addresses in Australia, United States or the UK, I'd want it to direct them to the appropriate landing page.

I'm not sure which module is the most appropriate for this scenario and how it would be applied.

Many thanks for your help.


texts: How to use the managed_file field in a custom form plugin

texts:
I'm attempting to create a module with a custom form that allows users to upload a file using a managed_file field. The name of my module is foundation_settings and the file structure is:

foundation_settings
  -foundation_settings.info.yml
  -foundation_settings.module
  -src
    -Form
      -FoundationForm.php

Inside FoundationForm.php I'm building the form with the following code:

public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('foundation.settings');
        $form['icons'] = [
            '#type'            => 'details',
            '#title'           => t('Front Page Icons'),
            '#open'            => FALSE,
            'icon1'            => [
                '#type'           => 'fieldset',
                '#title'          => t('First Icon'),
                'icon1_file'        => [
                    '#type'            => 'managed_file',
                    '#name'            => 'icon1',
                    '#title'           => t('First Icon Image'),
                    '#default_value'   => $config->get('icon1_file'),
                    '#upload_location' => 'public://',
                ],
            ],
       ];
}

However I'm not sure how to handle the managed_file when the form is being submitted. In my submitForm function I have

public function submitForm(array&$form, FormStateInterface $form_state) {
    $imageid = $form_state->getValue('icon1_file');
    $file = file_load($imageid[0]);
        if (gettype($file) == 'object') {
            $file->status = FILE_STATUS_PERMANENT;
        }
        $this->config('foundation.settings')
             ->set('icon1_file', $form_state->getValue('icon1_file'))
            ->save();
            $file->save();
}

The upload and saving works okay but I keep receiving this error after submitting

  The file used in the First Icon Image field may not be referenced.

How are you supposed to use managed_file field in custom form plugins?


texts: Unable to update content or enable / disable module via Drupal Admin once migrate to live server

texts: I have moved my website from local machine to live server, but after migration I can not save or update contents. After clicking on 'Save' button page refreshes without any changes. Also I can not enable or disable the drupal modules, and there aren't any errors displayed. Please help me out in this and do let me know solution in isolating this issue.


texts: How to print alt or title field image in twig node template?

texts:
I want to print alt or title field image file in node twig template Drupal 8. I tried use {{ node.field_images.entity }} to debug get value title or alt but in class \Drupal\file\Entity\File not function get those ! I saw {{node.field_images.entity.fileuri}} in link

So how to used {{node.field_images.entity}} to get value alt or title file images ?

Thanks !


texts: Error while mass subscribe using simplenews

texts:
I get this error while i am trying to mass subscribe users/email for a newsletter using the simplenews module in D7. How can i solve this error ?

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column
'tid' cannot be null: INSERT INTO {simplenews_subscription}
(tid, snid, status, timestamp, source) VALUES
(:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2,
:db_insert_placeholder_3, :db_insert_placeholder_4);
Array ( [:db_insert_placeholder_0] =>
[:db_insert_placeholder_1] => 1285
[:db_insert_placeholder_2] => 1
[:db_insert_placeholder_3] => 1368003712
[:db_insert_placeholder_4] => )
in simplenews_subscription_save()
(line 1501 of /sites/all/modules/simplenews/simplenews.module).


texts: db_query not returning anything (or empty) - drupal 7

texts:
I am trying to perform a db_query but am unable to do so.

The query I am trying to perform is very simple, but to make things even simpler, the following query does not even work for me:

$result = db_query('SELECT name FROM users WHERE uid = 1');

and if I do:

echo (string)$result->name;

nothing is displayed.

Does anyone know what could be causing this?

Edit - Updated with new code:

define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = "localhost";
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$result = db_query('SELECT OFFICE_ID FROM {OFFICE}');
$counter = 0;
foreach($result as $record) {
  $counter = $counter + 1;
  print $record->office_id;
}
print $counter;

Nothing will be printed, but at the end of the loop, the number of loops performed is the same as the number of rows returned from a direct query on the DB itself.


texts:
From a field template level, how can I get the link field URL value so I can theme this thing? Here is my overridden field template for this field:

{% for item in items %}
    {%
      set classes = [
        'btn',
        (loop.index0 == 0) ? 'btn--primary' : 'btn--inverted'
      ]
    %}

    {{ item.content['#title'] }}
{% endfor %}

It only holds two possible values.

I have tried every possible way to access the field value, but nothing seems to work.


texts: How can I create multiple cropped Media images without re-uploading them?

texts:
Solutions that I've found allow to crop Media, type Image when I've uploaded an image, but the media entity is not yet created (on the "Add media" page).

I need to upload a large full image once (and use it in full format on some nodes), and then crop it differently when I select it in different content types (to display small "zoomed" parts of the full image). So I need a manual crop to appear when I select a Media of type Image from a Media library. It can appear in Entity browser or on the node page.

Other solution is that I can create cropped images in advance being in my media library (/admin/content/media) or when adding a media (/media/add/image). The idea is that I do not want to reupload the image and add new title and alt.

Is this possible?


texts:
Has anyone been successful in adjusting autocomplete list width (entity reference tag style)? I have hard time grabbing the element in Inspector/Firebug.
The goal is to have the width wider than the field that it's bound to, so to accommodate entire item label.


texts: views exposed filter does not redirect to itself

texts: I came across to issue with exposed filter in my view. In a view's preview everything works fine. But on the page, after clicking apply button, the site redirects to front page, with get parameters in URL. What is wrong with this? I did everything in a UI and I didn't work with code. Thanks.


texts: How to print product ID in commerce-product.html.twig template

texts: I am not able to figure out how to print the product id in my commerce-product.html.twig for display on the product detail page. I tried different combinations of { product.field_id }} { product.id }} and can't find it.


texts: How can my JavaScript-function access the Web Property ID from the Google Analytics module?

texts:
I use the GoogleAnalytics module in most of my projects and have often the same issue:

Due to my countries policy requirements, every user has to be able to deactivate google-analytics cookies. To do so I need a little JavaScript to disable the cookie wich contains the UA/property ID, which is provided by the module.

Normaly such configs are set in the drupal-settings-json at the end of the page but there is no property-id in sight.

<script type="application/json" data-drupal-selector="drupal-settings-json">{"path":{"baseUrl":"\/","scriptPath":null,"pathPrefix":"","current....

is there any way for my JS-function to access this infirmation, or do I need to write an extra function to read the property ID and parse it to the drupal-settings-json somehow?


texts: Hosting a directory of legacy static HTML files on Drupal

texts: My clients has a folder of static HTML files from 1999. I want to upload the folder to Drupal and then use an iframe to frame it in. I know it sounds awful but that's all he has the budget for. How can I get Drupal to ignore the entire directory and serve up the files "as is"? It is required that the files be hosted on the same domain.


texts: Enable a flag automatically for specific users using Rules

texts:
I have a content type called testimonials, and in that I have a user reference field with multiple selection option.
I have a flag called 'Request to review' enabled on nodes of 'testimonials' content type.
I wrote a rule for sending mail to the author of the node if any user clicked on that flag.

What I need to do here is, I want to enable that flag automatically when a new node is saved only for the users who are selected in the form field user reference. And for remaining users the flag should not be enabled automatically i.e., they have to enable it manually by clicking the flag link.

Thanks


texts: How do I render a form in a div through a javascript call

texts:
I'm trying to load a form into a div using a javascript call. I can get the form in the div, but nothing works (autocomplete fields, wysiwyg fields, custom submit handler).
I know I must be missing something, but I can't figure out what it is.
What I have now to get the form:
$form = \Drupal::formBuilder()->getForm('Drupal\my_module\Form\MyForm');
$renderable = [
   '#theme' => 'my_form',
   '#form' => $form,
];
$rendered = Drupal::service('renderer')->renderPlain($renderable);

$response = new AjaxResponse();
$response->setData($rendered);
return $response;

I've also tried renderRoot instead of renderPlain, but to no avail.
The twig file looks like this (very simple):

    {% include 'header.html.twig' with {
        type : 'manual'
    } %}

        {{ form }}

Any help will be greatly appreciated.


texts: How to print author's email address in in node template

texts:
I have a content of type summary only visible by the author and administrators. I need to print in my node--summary.tpl.php the author's email address that was set at the account creation.

Any idea how this can be achieved?


texts: How to change "Description" in File field to drop down instead of text field?

texts:
What is the best way to modify the File field so the "Description" field is a select box instead of a text field. I.e. I want to go from:

To this:

I tried a quick experiment, editing the File modules file.field.inc file, which resulted in the screenshots above, but if I can avoid forking the File module and instead do it some other way it would be great.


texts: Different row tpl for every row in a view?

texts:
Can I create a different row template for every row in a view? Something like views-view-fields--foobar--0.tpl.php, views-view-fields--foobar--1.tpl.php and so on?
My goal is to create a slideshow width different template for every frame.


texts:
My problem is quite complex here:

I have a view table with pager. However, I don't want the "items per page" to be a select list. I want it to look like links: 5 | 10 | 15 | all. My solution for now is edit the views template and add the links with href=?items_per_page=5"and it works fine. But I really don't like that I have to reload the page everytime the link is clicked.

That's why I was thinking if it's possible to bind an onclick event to these links that will change the value of the <select> and then send an ajax post submit to the views form. I tried to do some simple $('form').submit() but didn't get the expected result (can't remember what I got, but I think either no changes or got redirected to somewhere else). I could not figure out how to mimic an ajax sumbit that views perform on this form.


texts: Get title of referenced item two levels deep with Search API

texts:
I have three content types: A, B and C.

A refers to B
and B refers to C

Now with use of the search api module I search my content types and I want to only output C. But in the result I want to show under which items the C is put. So some kind of breadcrumb. A view row should look like:

Type: C

Title of node

Found in: A > B

I am able to output the title of B but for some reason I'am not able to get the title of A. I tried to work with relationships in view but the A reference is not shown even not when I add B as a relation. I tried adding the content types to my search index and tried adding them direct as field to my search index ( field_content_B:entity:field_content_A:entity:title ). But nothing works. Can someone help me with figuring out what goes wrong?


texts: Drupal 8 update via drush removes files from vendor folder

texts:
I recently made a core update with drush for D8.
After the update I saw that it removed a folder from the 'vendor' folder on the server? Why did that happen?

The module has been installed via Composer because it needs dependencies to be installed: https://www.drupal.org/project/alinks

Re-installing the dependencies, works:

composer require "wamania/php-stemmer"

Is there something I did wrong? Do I need to update the core in a different way rather then using drush if you have installed modules via composer?

Removing the module via backoffice D8 and then removing folders from 'module/contrib' and 'vendor' and then re-installing the module works, but that is just not the way to do.

Thanks.


texts:
I'm making a website with 2 different kind of users. using the Profile2 module, and i'm kind of stuck.

Tourists who register with the normal user/register form.
And Guides who register with a custom guide/register form.

On the homepage we have a simple user menu with login and register button.

I want to customize the tabs on the user/register page to have two tabs:
Register as tourist and Register as guide

So I want the tabs of login and request password to be gone on the registration forms.

BUT I do want the login and request password tabs on the login page.


texts:
In Drupal 7, I used the following code implementing views_embed_view in a render array.

  $view_output = views_embed_view($view_name, $display_id, $uid);

  $page['profile']['bio_mobile'] = array(
    '#type' => 'markup',
    '#markup' => $view_output,
    '#prefix' => '
',
    '#suffix' => '
',
  );

How do I do that using Drupal 8?  Although the function is still documented, it return nothing more than just the array I passed in.


texts: How to make "Page specific visibility settings" for blocks more flexible?

texts:
My problem is that depending on a running mode my Drupal website might have either regular permalinks, or pretty, aliased ones. And "Page specific visibility settings" for blocks on specific pages (Show on only the listed pages) do not work across the modes.

It would be logical if let's say: node/23 syntax could work in any case, but it seems that it doesn't.

Do I have to change every setting for every block every time I switch permalink structure? Or there is more flexible solution to this?


texts:
How to get rid of the whitespace in printed fields?

Here's my source code in node.tpl:

<div class="banner" style="background-image:url('<?php print render($content['page_banner']); ?>');">

And here's the result (whitespace before http://)

Any ideas?


texts: How to put "Advanced form block" in a twitter bootstrap modal?

texts:
I want to add an Advanced Form Block into a modal. So far I've been partially successful, the block is added to the modal but the form is outside the modal markup.

The area marked in red is the form which should be in the div with the class modal-body. How do I make this work?


texts:
Hi I have 3 menus on my site and for display on mobile/tablet I would like to merge these menus to only 1 menu. Do you know how to do it. I tried to use menu_tree_all_data

and then merge them but I get Call to undefined function menu_tree_all_data. I'am confused that the function doesn't exist.


texts: How to programmatically set a custom field?

texts:
I am trying to programmatically change a custom field in a user object and I'm having very little success. I want to just use a function to set the field for the object, like field_get_items, except a setter version.

It seems like I could do:

$account = user_load($GLOABALS['user']->uid);

$edit = array(
    'field_custom' => array(
        'und' => array(
            0 => array(
                'value' => $lead_id
            )
        )
    )
);

user_save($account, $edit)

But there must be a better way to do this.

Any help would be appreciated. Thanks!


texts: Action attribute in forms is not a url. Why?

texts: When I check the action attribute of a drupal form, I never see a valid URL. What I see in the html code is a simple string, which usually matches the node title of the form. Given that the action attribute should contain a valid URL pointing to a server-side script, I am really confused! What are the mechanics behind the form's submission? Thanks in advance for your answers!


texts: Way to Configure IP Geolocation Views & Maps Module via Script

texts:
The module IP Geolocation Views & Maps has a ton of great features. By default, the data collection option: Employ the Google Maps API to reverse-geocode HTML5 visitor locations to street addresses is turned on.

Is there a way to turn off this option via a drush command, or through some code? I have automated our site setup process, and would like to ensure this option is turned off without requiring admins to click off the option in the admin UI.


texts: Print out $view object in custom field template

texts:
I've created a custom template for a field to display in my view. Based on the view theming information, I've named the file views-view-field--at-a-glance-test--page--field-track-icon.tpl.php (the view is called at-a-glance-test, the display is a page, and the field is field_track_icon.

The sample code given for a views-view-field template has the following comments:

/**
* Variables available:
  * - $view: The view object
  * - $field: The field handler object that can process the input
  * - $row: The raw SQL result that can be used
  * - $output: The processed output that will normally be used.
**/

I want to know what all is coming through in the view object, so I tried to do print_r($view). All I get is a completely blank page - there's not even a single line displayed in the rendered source. Usually this happens if there's a PHP error somewhere - am I doing something wrong? How can I print out the full contents of the view object?

EDIT

I just looked at our php error log and saw this:

  PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted
  (tried to allocate 117789481 bytes) in
  /home/www/expo/includes/theme.inc on line 1414

So obviously the view object is enormous... how else can I see what is coming through, since I have no control over our server's memory limits?

EDIT AGAIN

Per @Clive's comment below, I tried using dvm() instead of print_r, and did get some (a ridiculous amount) of output. Given that this is a template to override the display of a single field, I really want to see just the data for that particular field. So I tried dvm($field), and ended up with literally thousands of lines of nested arrays and objects. It's not pulling in just the data for this particular field, it's displaying data for the entire view, even though I passed in the field variable.

So then I tried dvm($row->field_track_icon), and got about 100 errors (Notice: Undefined property: stdClass::$field_track_icon in include() (line 28 of /home/www/expo/sites/all/themes/bluemasters/views-view-field--at-a-glance-test--page--field-track-icon.tpl.php).) The template comments state to use $data = $row->{$field->field_alias} as the format; first, what's the difference between field and field alias? I've attached a screenshot of the taxonomy term that the field I need is attached to. The field is called field_track_icon. What is the alias? Second, do I need the curly braces?

What do I need to do to get just the data for one specific field?


texts: Deleting a cloned node erases all paragraphs

texts:
Suppose node A contains a paragraphs field with a paragraph entity X. Duplicating the node by means of Node clone will create a new node - let's call it node B - with an exact copy of paragraph X. It is even possible to change the contents of X in node A and B independently.
But when A or B is deleted, X will be erased from both nodes. Obviously this is because there has never been created a new entity when replicating the paragraph, but only a new entity revision.

For Drupal 7, this behavior is documented in Paragraphs data loss with Node clone module and at least partly fixed by a patch.
But none of this seems to be the case for the Drupal 8 dev version of Node clone. Has anyone found a solution or workaround for this issue?

Drupal 8.2.0

Paragraph 8.x-1.0+14-dev

Node clone 8.x-1.x-dev


texts: split/divide main content region to columns or create another custom layout

texts:
I am building a theme and I want my main content region to be divided in 3 fixed columns. I have produced all my .css code and I just want to dynamically produce the markup (3 columns) and attach my styles to them. I know 'use panels or display suite' is the easy answer but I haven't till found a way to use them effectively.

Ideally I would have regions: content-left, content-center, content-right and when I create content I can choose where to place it. this <?php print render($page['content']); ?> needs some tweaking! Anyone?


texts: dropdown menu doesn't always show up in corporateclean

texts:
I customized a theme from corporateclean and now, adding a drop down menu, the drop down doesn't show up on the rest of the page. The link is http://athleticedgefitness.com/contact where it shows the Links drop down; if you go to any other page, you see that the drop down doesn't show up. Why not? How can I fix this?

I am using Drupal 7.

Clearing the cache didn't do it!


texts: I am looking for a responsive slider that can take text instead of images

texts:
Do you know of a responsive slider that can take text instead of images?

I have been using Nivo Slider and have had great experiences with its responsive design. I am using one on the front page. I wanted another, so I used Views Nivo Slider. My client decided to have another with text instead of pictures, but Views Nivo Slider didn't seem to want to do this. I don't think I can hack the Nivo Slider code because it would effect my other sliders on my webpage.

Here are some pictures. With images, the slider behaves normally.

When I add the body content and change the slider to show the body as so,

I get this:

Nothing shows up.

The same thing happens if I try to put the body into the title instead of the image.


texts: validation question for webform validate

texts:
I need to validate that a field does not contain only numbers. in other words it can have some numbers but must have some letters as well. Can someone help me with the regex to do that?

I am using webforms 7.x-3.18+3 and webforms validation 7.x 1.1

thanks


texts: Apache SOLR + Facet API + Taxonomy terms

texts:
I want to create a product catalog and I have been told that apache SOLR could be the best way to go. I installed Drupal Commerce, Apache SOLR Integration (7.x-1.0-rc2) and Facet API (7.x-1.0).
I added a custom field "category" to my product display content type which refers to a hierarchical taxonomy vocabulary.

Clothing

Tops
Dresses
Skirts

Accessories

Bags
Jewelery

Shoes

Pumps
Sneakers

On my products page I would like to see a facet block where I can select my categories.
I want to show my top level categories without their children at first, but when you select a category I also want to see its' children. You can achieve this functionality with the standard installation I believe.

BUT when I select one top level category (Clothing) my other top level categories disappear (Accessories, Shoes).
I don't want to be able to select multiple top level categories at once, I just want them to be visible...
Is that possible in any way?


texts:
I've been digging around the CSS and JS files but I haven't quite found the exact thing that places the throbber.gif where it appears when clicking on 'previous' or 'next'.

The styling is in system.base.css file and I found this declaration:

.ajax-progress .throbber {
    background: url("../../misc/throbber.gif") no-repeat scroll 0 -18px transparent;
    float: left;
    height: 15px;
    margin: 2px;
    width: 15px;
}

but besides removing the background, the other parts of this declaration do not affect the placement of the throbber.gif.

It's hard to use Firebug and get the styles as the throbber only appears after pushing a button and it's only alive for a few seconds so I've tried screen capturing during the 'throbbing' and measuring distances in the scrn cap in Photoshop and applying but I discovered that the throbber is 'attached' to the button somewhere as it just moves the whole kit and kaboodle... the 'throbber' still appears right next to either 'previous' or 'next' button.

I'm trying to avoid the little jump that happens. When pushing 'next', the 'next' button is shoved left and down a little to make room for the throbber gif, and then shifts back when the new page is loaded.

Any ideas?


texts: How to show a title-link in a view for authorized and hide it for unauthorized users?

texts: I have a view with some fields and one of them is the title field. Now i need the feature that when an anonymous user views the view, the title is not linked to it´s content. When the user logs in, then the title should link to its content. How is it possible to realize that? I have more or less no php skills.


texts: How do I set up an entityreference entity base field to show as a link to the target entity?

texts:
I have a base field on my entity type that's an entity reference, e.g.:
    $fields['type'] = BaseFieldDefinition::create('entity_reference')

How do I set this up so it displays as a link to the target?


texts: Where to check for node value constraints on services data receive

texts:
I have a REST service to create nodes. On data receive, node.create is executed, but before actually creating the node I need to check some constraints like node type and other node values.

Is there any I can use?


texts: Creating paragraph entities and adding to a node

texts:
I am using the Paragraph module in and I need to programmatically create paragraph entities and attach them to nodes.

Using the following code in a for-loop:

$paragraph = new ParagraphsItemEntity(array('field_name' => 'field_page_body', 'bundle' => 'text'));
$paragraph->is_new = TRUE;
$paragraph->setHostEntity('node', $node);
$paragraph->save(TRUE);

The paragraph entities are created and attached to the target node but the data is NULL for all 3 entries as the image below shows:

A properly working set of Paragraph entities attached to a node look like the following:

So, instead of UND i:e undefined, I am trying to attach programmatically created arrays of paragraph entities to my nodes.

Can anyone advice how I can modify my code to include my array of Paragraphs data?


texts:
I am new to Drupal. I first created my site in Drupal 7, but I had to use Drupal 6 because a lot of the modules I use were not ready yet.  Now I'm noticing more and more modules are having development releases for Drupal 7.

If I install a development release, will the upgrade manager notify me of updates once it's listed as the main module or will I need to switch to the main module to keep getting the notification?


texts:
I want to send emails listed in Views. The email column is collected from data submission of anonymous users (without login). The form is created using webform.

The table looks like this:

Name     |  email address
---------------------------
Name one | emailone@tod.ten
Name two | emailtwo@tof.fen

I have tried Views Send module without any success as reported in the issue about "Can't use email collected from a webform submission field".

How can I send email to all emails in the column?

or anyone can suggest another method.


texts: How do i do some search feature like this

texts:
I have a requirement like this show in image

Like left hand side i need to show some fields data and when i click on the links i should filter out the data in content area. and its should be like a AND operation ? I need to use VIEWS and what else modules are needed for this thing to be completed?


texts: Field Collection with Date for Calendar View

texts:
I'm working on the content design for a new site, but I'm having a major hangup with some of the connections between the data types, especially when it comes to Dates and Calendars.  Here's the rundown:

Films share a many to many relationship with Programs.
Programs can have one or many Screenings.
Screenings each have one Date and Venue.

I've successfully accomplished this using Node Reference and Field Collection.  There is a node reference between Films and Programs.  Programs contains a field collection called Screenings.  The field collection Screenings contains the fields Date and Venue.

The functionality I love from this setup is that each Date and Venue pair is grouped, and I can just click the Add button to generate another pair within that Program.  This satisfies the one or many requirement for Screenings.

Unfortunately, when I start to build this all into a Calendar view (Date module, Calendar module), it breaks terribly.  Depending on how I set things, I end up with SQL errors or index errors within Drupal.  None of it works.  Reading through issue posts, I've gathered that this is probably some sort of complexity added by Field Collection which is not handled in Calendar.

Short of getting Field Collection to play nice with Date and Calendar, can anyone suggest another method for implementing this?  My next thought would be to move Screenings off into its own node and create another node reference between that and Programs.  However, that would mean I lose the clean and simple Add button to generate a new Screening within a program.

Perhaps a custom add/edit form is all I really need.  Unfortunately, that road seems rather perilous for me without some clear guidance.


texts: How to show custom error messages below text field?

texts:
I want to display custom error messages below that text field in comments form. Currently it displays all error messages above the page which is not acceptable.

I'm using this theme for my blog. I also used this but it's not working. As I'm new in drupal I'm struggling with this, please suggest any solution.


texts:
In the module I am developing I need to add script which require jQuery.The will be added depending on configuration settings. Hence I am using template_preprocess_module(&$variables) where I am trying to add script by doing something like this:

function template_preprocess_module(&$variables) {
  if (TRUE) {
    $variables['jquery'] = ?;
    $variables['script'] = 'path to script in module';
  }
}

Then in the template I will simply be rendering these variable in the head section. But I am facing trouble in adding jQuery, because I don't know its source (obviously I know its source in core but I need something over here which automates path). Can the source be known by using something like drupal_get_path() ? I am also not sure if this is the best way to add script conditionally, any suggestion regarding this? Thanks.


texts: Trivial Example of a Module that Creates a Content Type

texts:
I want to write a module that creates a content type with a title and one or more textfields. I'm having a very hard time simplifying the roles of each hook function call in the documentation of the node_examples module.

Right now I'm trying to figure out what the next function should be and what it will do with the form data. So far I've gotten the content type and the forms to show up in the add content section of my site but when I save the "votable" content none of the form data is stored, just a blank piece of content with content type "votable". Could someone point me towards the next step?

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

    $form['votable_results'] = array(
        '#type' => 'textarea',
        '#title' => t('Results'),
    );

    return $form;
}

 function votable_node_info() {
    return array(
        'votable' => array(
            'name' => t('Contestant'),
            'base' => 'votable',
            'module' => 'votable',
            'description' => t("Select this content type to create a Contestent Page"),
            'help' => 'add content',
            'title_label' => t('Contestant Name'),
            'has_body' => FALSE,
        ),
    );
 }


texts:
I have a content type, Venues and a content type Events. In the Events post type, I have 'field_hosted_by' - allowing me to select the relevant venue.

On each venue page (/venue/venue-name), i'd like to create a block listing the events they are hosting – what would be the best way to do this?

I had a solution using taxonomies but this seemed inefficient, i'd rather not have to create a term for each venue, as well as a node.

Using Drupal 8.


texts:
I would like to set up a FAQ system using a custom content type and views. I would like to display the FAQs one of two common ways:

Each question is a link that hides/displays the answer below it when the link is clicked, or
Each question is a link that jumps down to a corresponding anchor on the page with the answer.

Are either of those possible in Views? I'm new to Drupal and learning as I go. Thanks.


texts:
I'm using CONCAT in a join. It works well in PHPMyAdmin, but the equivalent Drupal query doesn't work.

$query->join('taxonomy_term_data', 'td', 'sbc.tname LIKE CONCAT( td.name,  "%\" ) AND td.vid = sbc.vid');

This query causes the following error:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  '%\' in 'on clause'

However, the following query works fine.

$query->join('taxonomy_term_data', 'td', 'sbc.tname LIKE CONCAT( td.name,  \'%\' ) AND td.vid = sbc.vid');

The only difference between the two queries is the string quotes: In the first one I used double quotes to wrap %; in the second one I used single quotes.

PHPMyAdmin gives me the result whether the % is wrapped with single quotes, or double quotes. (Actually, it should.)

I think there is something I'm missing. I'm just curious to know what it is.


texts:
How would you suggest approach this using Drupal 7?

I'd like to create a 'Video' content type with the usual videos fields but I would also like each individual video content type to have many images attached, with each image having fields of it's own.

Basically, each content type would require one video and many images, with fields relevant for each image.

I've looked for duplicate questions and can't see anything that fits but if you know of something please point me in the right direction.

Thanks,


texts: Migrate part of a Drupal 6 installation to a new Drupal 7 installation

texts:
I'm trying to migrate the users and the Forum nodes (including comments) from Drupal 6 Installation (current productive system) to a new Drupal 7 installation (staging system). I wanted to start from scratch with Drupal 7 so I did not go the upgrade way, but now I'm facing the problem that some data has to be migrated anyway.

I tried several Import/Export modules, but none really does what I want. Any ideas?


texts: Custom node field type should also support content block; what should I do?

texts:
I'm using the Paragraphs module for nodes. Here is a quote from its project page:

  Paragraphs module comes with a new "paragraphs" field type that works like Entity Reference's. Simply add a new paragraphs field on any Content Type you want and choose which Paragraph Types should be available to end-users.

But the type is not in the add select on admin/structure/block/block-content/manage/basic/fields/add-field.

It would be nice, if this module could offer the paragraphs field type also for Content Blocks (or other field type creating modules their types).

Has someone an idea, what the module maintainer has to do along general lines? I want to ask this as a feature request in the module's issue queue. But it would be nice if I can give some hint to the maintainer.


texts: Theming menu--main.html.twig to Foundation 6 Top Bar responsive menu

texts:
How do I have to change menu--main.html.twig to get Foundation Top Bar working?

This is what I have so far in menu--main.html.twig:

        <button class="menu-icon dark" type="button" data-toggle></button>

      Site Title

        {{ menus.menu_links(items, attributes, 0) }}

<input type="search" placeholder="Search">

<button type="button" class="button">Search</button>

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0 %}

    {% else %}

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

        {{ link(item.title, item.url) }}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}

    {% endfor %}

  {% endif %}
{% endmacro %}

But it's always showing the toggle button? Do I have to activate any javascript for the Responsive menu and the Top Bar?


texts: Show external mysql database data in webform field

texts:
External database. - I want to allow drupal webform users to choose data from an external mysql database table. They would have the option to choose a region and an associated locality when completing the webform. What is the best way to expose this data in webform?

I have created a view using the entity reference but can't seem to expose this in the form field?
What is the simplest


texts: Fatal error after subtheming Commerce Kickstart Admin Theme

texts:
I am trying to subtheme Commerce Kickstart Admin Theme. I have copied all the folders and files to sites/all/themes/my__admin_subtheme, and changed the appropriate lines in my_admin_subtheme.info.

When I go to /admin/appearance, and change the section Administration theme to My Admin Theme, I get an error in template.php telling that the function commerce_kickstart_admin_preprocess_maintenance_page is declared twice.

How to solve this issue?

Edit:

When I change the name of preprocess function in template.php from commerce_kickstart_admin_preprocess_maintenance_page to my_admin_subtheme_preprocess_maintenance_page or delete template.php the fatal error disappear but I lose the formated html present in that function.

To make things more clear, the template.php is

<?php

/**
 * Override or insert variables into the maintenance page template.
 */
function livraria_acervo_admin_preprocess_maintenance_page(&$vars) {
  // While markup for normal pages is split into page.tpl.php and html.tpl.php,
  // the markup for the maintenance page is all in the single
  // maintenance-page.tpl.php template. So, to have what's done in
  // shiny_preprocess_html() also happen on the maintenance page, it has to be
  // called here.
  shiny_preprocess_html($vars);
  if (variable_get('install_task') != 'done') {
    $footer_markup =  '
' . t('Proudly built by') . '
';
    $footer_markup .=  '
' . t('Commerce Guys', array('@url' => 'http://www.commerceguys.com')) . '
';
    $vars['footer'] = array(
      '#prefix' => '
',
      '#markup' => $footer_markup,
      '#suffix' => '
',
    );
  }
}

I searched for that function in all file tree in root Drupal installation and didn't find any call for that function.

I see the function is related to the maintenance mode, the mode that I'm working now. Well, as I told above the fatal error disappeared but how to know where the function is called. I think the function is called somewhere and I would have to change the name in the file(s) that it's called, although I don't think this would the better way to solve the problem.

So some piece is missing in subtheming Commerce Kickstart 2 admin theme, and is related to the call of that function commerce_kickstart_admin_preprocess_maintenance_page.

I'm new to Drupal and have not practiced php very much, so I hope I have been cleared. If more information is needed please tell me. And sorry about my English too.

Thanks in advance!


texts: I'm beginner in Drupal 7 et Solr 4. I have $query and I want to do a group by category. How can I add 'group by' as a parameter to $query (DrupalSolrQueryInterface) ??


texts:
I've created a breadcumb using this and I've created one. But I would like to create breadcrumb for each page. I've 3 forms, above the form I need to set the progress of the form in the form of breadcrumb,

Drupal 7

$breadcrumb[] = l('hi', '/hi');
drupal_set_breadcrumb($breadcrumb);

In drupal 8 I've tried to use

$b = new Breadcrumb();
$breadcrumb[] = Link::createFromRoute(t('Home'), '<front>');
return $b->setLinks($new_breadcrumbs);

But this is not working...
how we can show that and where am I doing wrong?


texts: How can I print Views Exposed Filter widgets individually using views-exposed-form--mypage.tpl.php?

texts:
I have five exposed filter widgets that appear on this page.  I would like to group three of them together and add a title above that group of three so that my layout goes from:

views default

A
B
C
D
E

what I want

A
TITLE

B
C
D

E

Since this customization is specific to one page, I added a views-exposed-form--mypage.tpl.php in my theme's template folder.

The code looks like this:

    <?php foreach ($widgets as $id => $widget): ?>
      <div id="<?php print $widget->id; ?>-wrapper" class="views-exposed-widget views-widget-<?php print $id; ?>">
        <?php if (!empty($widget->label)): ?>
          <label for="<?php print $widget->id; ?>">
            <?php print $widget->label; ?>

        <?php endif; ?>
        <?php if (!empty($widget->operator)): ?>

            <?php print $widget->operator; ?>

        <?php endif; ?>

          <?php print $widget->widget; ?>

    <?php endforeach; ?>
    <?php if (!empty($sort_by)): ?>

        <?php print $sort_by; ?>

        <?php print $sort_order; ?>

    <?php endif; ?>

Instead of the foreach loop, how can I print the individual widgets?


texts: Drush rsync and drupal composer wrong destination dir

texts:
I'm trying to sync two D8 sites. Both set up with drupal composer which means that the directory structure is a bit different than usual. Composer puts drupal files inside web sub directory like this:

/var/www/drupal8
|-- composer.json
|-- composer.lock
|-- drush
|-- scripts
|-- vendor
`-- web
    |-- autoload.php
    |-- core
    |-- index.php
    |-- modules
    |-- profiles
    |-- robots.txt
    |-- sites
    |-- themes
    |-- update.php
    `-- web.config

My aliases file looks like this:

<?php

$aliases["local"] = array (
  'root' => '/var/www/drupal8/web/',
  'uri' => 'http://local.site',
);

$aliases["remote"] = array (
  'root' => '/var/www/drupal8/web/',
  'uri' => 'http://site.example.com',
  'remote-user' => 'dev',
  'remote-host' => 'site.example.com',
);

When I do drush rsync @remote @local I end up with all files from @remote/web inside @local/web/web like this:

/var/www/drupal8
|-- composer.json
|-- composer.lock
|-- drush
|-- scripts
|-- vendor
`-- web
    |-- autoload.php
    |-- core
    |-- index.php
    |-- modules
    |-- profiles
    |-- robots.txt
    |-- sites
    |-- themes
    |-- update.php
    |-- web
        |-- autoload.php
        |-- core
        |-- index.php
        |-- modules
        |-- profiles
        |-- robots.txt
        |-- sites
        |-- themes
        |-- update.php
        `-- web.config
    `-- web.config

I can't edit aliases to remove web sub dir from root path because then drush will not work as it will complain that it needs a higher bootstrap level to run (because it won't know where is drupal root folder).

How can I instruct drush to use proper destination path for synchronisation?


texts: How can I drag and drop sort nodes and output result as JSON?

texts: I have tried the DraggableViews module, but it creates a new table in the database that is not related with the entity fields of my entity and I'm using AngularJS as front-end with JSON API calls, so I just want to know if there is a way to do this Drag and Drop which also alter the table of the Entity in the database?


texts: fetchAll Database query returns an error

texts:
I'm building a REST Resource in drupal 8 php that returns the result of a query to the database. However using the fetchAssoc() only returns one result.
So I figured that fetchAll() returns all results, but it throws an error when I do so.
This is the code
$result = $database
      ->select('node__field_recipe_category', 'recipe_cat')
      ->fields('recipe_cat', ['entity_id','bundle'])
      ->condition('entity_id', [3,8], 'BETWEEN')
      ->execute()
      ->fetchAll();
     // Configure caching settings.
    $build = [
      '#cache' => [
        'max-age' => 0,
      ],
    ];

    // Return results.
    return (new ResourceResponse($result, 200))->addCacheableDependency($build);

This is the error
The website encountered an unexpected error. Please try again later.

Symfony\Component\Serializer\Exception\NotNormalizableValueException: Could not normalize object of type &quot;stdClass&quot;, no supporting normalizer found. in Symfony\Component\Serializer\Serializer-&gt;normalize() (line 164 of vendor/symfony/serializer/Serializer.php).
Symfony\Component\Serializer\Serializer-&gt;normalize(Array, &#039;json&#039;, Array) (Line: 116)
Symfony\Component\Serializer\Serializer-&gt;serialize(Array, &#039;json&#039;, Array) (Line: 176)
Drupal\rest\EventSubscriber\ResourceResponseSubscriber-&gt;Drupal\rest\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 177)
Drupal\rest\EventSubscriber\ResourceResponseSubscriber-&gt;renderResponseBody(Object, Object, Object, &#039;json&#039;) (Line: 76)
Drupal\rest\EventSubscriber\ResourceResponseSubscriber-&gt;onResponse(Object, &#039;kernel.response&#039;, Object)
call_user_func(Array, Object, &#039;kernel.response&#039;, Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(&#039;kernel.response&#039;, Object) (Line: 191)
Symfony\Component\HttpKernel\HttpKernel-&gt;filterResponse(Object, Object, 1) (Line: 173)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)

Any ideas?


texts: What are the features of the Group module versus Organic Group module?

texts:
To create groups in Drupal we have at this moment the Group module and the Organic Groups module.

From the Group module page:

  The Group module allows you to create arbitrary collections of your
  content and users on your site and grant access control permissions on
  those collections

From the Organic Group module page:

  Enable users to create and manage their own 'groups'. Each group can
  have subscribers, and maintains a group home page where subscribers
  communicate amongst themselves.

What are the features of Group versus Organic Group?


texts: Warning: Cannot use a scalar value as an array in _block_get_renderable_array() on hook_block_info / hook_block_view

texts:
I'm trying to create a module that creates a block to a specific region so I use this module on multiple sites instead of using the admin menu copy and pasting creating blocks with HTML code in it and putting it in the region that I want it to be.

Somehow the block doesn't even shows up in the blocks admin section. Maybe I'm overlooking something but I quite sure my code is correct for the hooks implemented below:

/**
 * Implements hook_block_info()
 */
function bannert_block_info() {
    $blocks['bannert'] = array(
        'info' => t('bannert'),
        'cache' => DRUPAL_CACHE_PER_PAGE,
        'region' => 'three_33_third',
        'status' => 1,
    );

    return $blocks;
}

/**
 * Implements hook_bock_view()
 */
function bannert_block_view(){
    $block['subject'] = t('');
    $block['content'] = _bannert_get_bannert();

    return $block;
}

/**
 * get banner
 */
function _bannert_get_bannert() {
    return include_once('banner.html');
}

The only thing I'm doubting about is the _bannert_get_bannert() function but that doesn't prevent the block from being created, now does it?

I'm getting this error now:

  Warning: Cannot use a scalar value as an array in
  _block_get_renderable_array() (line 346 of /Users/Jack/Sites/drupal-7/modules/block/block.module). Fatal error:
  Unsupported operand types in
  /Users/Jack/Sites/drupal-7/modules/block/block.module on line 352


texts: How to create a custom template for entities?

texts:
I'm having a dickens of a time overriding entity.tpl.php to create custom themes for my entities.

I am using ECK and Inline Entity Form. I've created entity section with bundle masthead. I've linked this to a node.

In a subtheme of the bootstrap theme, I then try to create a custom theme for this entity in a file called entity--section--masthead.tpl.php (note: I've also tried section.tpl.php and section--masthead.tpl.php and all sorts of permutations). Clear Cache. Nothing.

The only documentation is a few years old, and one of the most recent comments says this SHOULD work without the need for various hooks.


texts: Proper with "Executing Custom PHP Code" Action

texts:
I am trying to add an action that "Executes Custom PHP Code". I click Add a new action to the rule I have created and I choose "Execute Custom PHP Code" from the drop down the loading spinner appears for a couple of seconds and then disappear. The only thing I can do is click Continue which does nothing.
Then when i navigate to another page I receive the follow error

Value field is required.
The integrity check failed with the following error message: "Missing configuration for parameter code."

Has anybody got any idea why this is coming up.
It sounds like a box is supposed to appear but it doesn't.
As far as I can see I have all the right modules installed. (PHP filter, Rules, Rules Scheduler, Rules UI, Trigger).
Oh I am using Drupal 7.7 (I am planning on upgrading to 7.8 later today)
Thanks
Conor


texts: Hide Views Module Page if Field is Empty

texts: I am using drupal 7 and views 3.x. I am creating a page using views module. Page content came from content type. Example: I've page A which I create using views module. The page content came from field Z, which is one of field from content type X. Then, for the contextual filter, I use author id. So, my question is: how can I hide the page if field Z return null value. Thanks in advance.


texts: Show a maintenance page while moving the site

texts:
I am going to move the finished drupal site from the sub-directory to root, because the files are quite large, it takes a while to do so, I want to put a html file there to show 'site maintenance in process, be back soon'.

How can I do this while I move everything?


texts: How to download file upon submitting a form?

texts:
I have a form with the submit button.
And I have a file in '/sites/default/files/tmp/my_doc.docx'
I'm trying to download the file upon submitting the form.

Here is my code

public function submitForm(array &$form, FormStateInterface $form_state){
   $filename = '/sites/default/files/tmp/my_doc.docx';
   $response = new BinaryFileResponse($filename);
   $form_state->setResponse($response);
}

But it doesnt't work properly.

That is, the file is being downloaded but has the same name that name of php file containing this code.

Could you clarify me, what have I done wrong ?


texts: form_set_error highlight single field in multiple value field

texts:
Is it possible to highlight only one field with form_set_error when this field belongs to a multiple value field. Let's say I have a field name field_videos which accepts multiples values. After running validation, only video #2 isn't valid :

form_set_error('field_videos', t('Video URL not valid'));

How can I tell drupal to highlight only field #2 ?

Thanks


texts:
UPDATE: Following Shawn Conn's advice I was able to render a specific block changing

$res_output = drupal_render($res_output);

to

$res_output = drupal_render($output);

But I'm still unable to render a Book Navigation block. I was able to figure out how to render a specific block using the url to it's management page. On a block with the url

https://example.com/admin/structure/block/manage/block/103/configure

I used

$block = block_load('block', '103');

and that worked. However based on

https://example.com/admin/structure/block/manage/book/navigation/configure

I tried

$block = block_load('block', 'navigation');

and

$block = block_load('book', 'navigation');

and

$block = block_load('block', 'book','navigation');

with no luck.

I'm attempting to load a Book Navigation block programmatically inside another block. After doing some research it seems that I need to take advantage of the bload_load function. I'm using

$block = block_load('book', 'navigation');
$output =_block_get_renderable_array(_block_render_blocks(array($block)));
$res_output = drupal_render($res_output);
print render($res_output);

However there is no output. I have a feeling that the parameters for block_load are incorrect. I based them off of what the URL contained

/admin/structure/block/manage/book/navigation/configure


texts: what allows multiple selections in facets on commerce kickstart?

texts:
can someone tell me where the setting is to keep all the choices displayed after a selection is made in a facet block if my search is for a color say

[]Red
[]Green
[]Blue
[]Orange
[]Purple

I'd like to be able to select both red and green or red and blue etc etc...
I have hunted for a setting to keep the options in the blocks screen, facets screen (probably missed it somewhere in all the options), and tried to compare a commerce kickstart install with mine.


texts:
I have gone through the /upgrade gui part on my website.  However the geo location fields have not copied across.

Am I correct in thinking that instead of manually entering the data again, I could:

Create the field (same name) and add it to the content types I was using.
Export the field_data_field_location
Import both these fields into the Drupal 8 database as field_revision_field_location respectively?

As far I can see the tables are pretty similar, although there are same number of fields 2 of them are different.

The D7 Table has a field entity_type
The D8 Table has field_location_data

I will attach the schema for both tables.

D7:

+------------------------+------------------+------+-----+---------+-------+
| Field                  | Type             | Null | Key | Default | Extra |
+------------------------+------------------+------+-----+---------+-------+
| entity_type            | varchar(128)     | NO   | PRI |         |       |
| bundle                 | varchar(128)     | NO   | MUL |         |       |
| deleted                | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id              | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id            | int(10) unsigned | YES  | MUL | NULL    |       |
| language               | varchar(32)      | NO   | PRI |         |       |
| delta                  | int(10) unsigned | NO   | PRI | NULL    |       |
| field_location_lat     | double           | NO   | MUL | 0       |       |
| field_location_lng     | double           | NO   | MUL | 0       |       |
| field_location_lat_sin | double           | NO   |     | 0       |       |
| field_location_lat_cos | double           | NO   |     | 0       |       |
| field_location_lng_rad | double           | NO   |     | 0       |       |
+------------------------+------------------+------+-----+---------+-------+

D8:+------------------------+------------------+------+-----+---------+-------+
| Field                  | Type             | Null | Key | Default | Extra |
+------------------------+------------------+------+-----+---------+-------+
| bundle                 | varchar(128)     | NO   | MUL |         |       |
| deleted                | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id              | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id            | int(10) unsigned | NO   | MUL | NULL    |       |
| langcode               | varchar(32)      | NO   | PRI |         |       |
| delta                  | int(10) unsigned | NO   | PRI | NULL    |       |
| field_location_lat     | double           | YES  | MUL | NULL    |       |
| field_location_lng     | double           | YES  | MUL | NULL    |       |
| field_location_lat_sin | double           | YES  |     | NULL    |       |
| field_location_lat_cos | double           | YES  |     | NULL    |       |
| field_location_lng_rad | double           | YES  |     | NULL    |       |
| field_location_data    | longblob         | YES  |     | NULL    |       |
+------------------------+------------------+------+-----+---------+-------+

All help and advice appreicated!

Mark.


texts: Changing block templates based on context? moving title in body field in template

texts:
Is it possible to change my block template suggestion based on a particular context?

E.g. On certain parent landing pages (I could manually set; because there are only 3 conditions no determinate pattern), I need the block title to go inside the content <div>.

I could do a workaround and add the title in the body field. Although, I don't want to modify the block content (to add title in the body area/field) because they maybe used on other taxonomy pages; and the clients will have a hard time managing this (calls asking why is the title shown twice in the block management).

Would or could this be best in terms of most efficient solution achieved by preprocessing?

Current output on pages (Default drupal templates in psuedocode):

div.block-block-{delta}
  h2.block-title
  div.content

Desired output (on set parent landing pages)

   div.block-block-{delta}
     div.content
       h2.block-title

Desired output (on all other taxonomy pages)

div.block-block-{delta}
  h2.block-title
  div.content

Update:

These landing pages are just three nodes that the client wants. Theres not really a rhyme or reason to what determines if it is a landing page. I just need to set three node id's to trigger the block template change.


texts: Sheetnode Multisite Javascript error message: 'Unknow line type '' '

texts:
I'm using sheetnode in a multisite configuration and I'm trying to refer data from an other sheetnode into the current sheetnode.

My issue is very similar to this one https://www.drupal.org/node/1386114 except that clean url are working correctly:

Formula: '=mapping!A1'
Javascript error message: 'Unknow line type '' '

I've been looking at the network tab in chrome and I realize that the difference between a working version and my multisite are few white line at the top of the load/sheetnode call.

I believe that this is part of my problem but I don't know how to resolve it.

Any idea of what's going on ?

Thanks.


texts: Moving the fields and data from one content type to another content type

texts:
I have created a content type called "ContentA" and in that content type I have two fields, "Summary" and "Title". I have already created a new content type called "ContentB" and it is also having the same fields. What I need to do is move the data and fields everything from the first content type "ContentA" to second content type "ContentB" and I'm using Drupal 7.
I tried the node convert module, it is allowing only each node at once, I am having approximately 500 nodes, I cannot use that module. So looking for any module/script for bulk transfer

Is this possible with a module or maybe from SQL. I don't know what to do, I've been trying to do this from weeks and I'm stuck :( please help!


texts:
I'm using exposed simple hierarchal select module for a taxonomy in my exposed filter, i have deleted some terms from the taxonomy but the filter  still showing the deleted terms.

I tried clearing caches and cron and even waited one day with no luck!

Any ideas what is the problem??

❤


texts: reference an entity outside of the node/add or node/edit forms

texts:
I will explain you with my use case:

I have a content type "job post" and another content type "Exam" For apply to a job you must pass the exam, the "job post" content type has an entity reference field "field_exam" that is referencing the "Exam".

While user creates the "job post" he can create his own "Exam" or he can Call for tender on creation of an "exam" for the "job post". In that case the User will recieve "exams" of other users and he will choose one of them for his "job post".

The list of options is a view of "exams", in front of the title of each "exam" should be a link that says "Choose this Exam", and if I click that link the field "field_exam" of the "job post" must be referencing that "exam".

So the main point of this is, how to change update the "field_exam" value selecting the entity outside, for example in a view or in the node page...

Thanks for your help.


texts:
Here is the workflow

Users register with a valid email and a password
Drupal automatically sends an email to the new registered user
The email contains a link to verify the email
The email verification is performed

This is similar to email addition and verification of http://drupal.org. I can't find any module for that purpose. Some patches are available on https://www.drupal.org/node/115801. Any way?


texts:
I am using Drupal 7 with commerce module. In the commerce shipping pane I have created a new email filed through admin -> store -> Customer profiles -> Shipping Information and it is displaying in the shipping section that’s all fine.

Now what I have to do here is use this email while creating the account for anonymous users instead of using email from the account pane and also I need to hide the email filed in account pane.  Can anyone guide me how to implement this? Thanks in advance.

Ratheesh


texts:
I have a requirement in a project having 350 fields, but when I use views, I am facing a lot performance issues. So in place of reading all the data from individual tables, can I use serialization as alternative and serialize only few fields?

Is it possible in Drupal 8?


texts: User Login: login failed: 400 Bad Request

texts:
I am trying the log in rest API with Drupal 8.4

For that, I am using angular 5

I have all the configurations working.

This is how I get the data from the form and send it to the UserServices. The UserServices will do the post method with the correct header, the user, and the password.

onSubmit() getting the data from the form:

onSubmit(name: string, pass:string): void {
    name = name.trim();
    if (!name) { return; }
    let user: any = {
     name: null,
     pass: null
    };
    user.name = {value: name};
    user.pass = { "": pass};
    console.log('Json from the form ' +JSON.stringify(user));
    this.UserService.login(user)
      .subscribe(user => {
        console.log('subscribed to login function' + JSON.stringify(this.user));
       });
}

this is the login() function, that send the post method

login (user: User): Observable<User> {
  const url = `${this.mainUrl}/user/login?_format=json`;
  const postReturn = this.http.post(url, user, httpHaljson);
console.log('Login return from the user service' + JSON.stringify(postReturn));
return postReturn
}

This is my header i have tested with aplication json and haplication hal json

const httpHaljson = {
  headers: new HttpHeaders({
  "X-CSRF-Token": "Qfnczb1SUnvOAsEy0A_xuGp_rkompgO2oTkCBOSEItM",
  "Authorization": "Basic Qfnczb1SUnvOAsEy0A_xuGp_rkompgO2oTkCBOSEItM", // encoded user/pass - this is admin/123qwe
  // "Content-Type": "application/hal+json"
  "Content-Type": "application/json"
  })
};

Now, this is what i get from the console: User Login: login failed: Http failure response for http://drupal.dd:8083/user/login?_format=json: 403 Forbidden

This is how I send the data from the form:
Json from the form {"name":{"value":"asd"},"pass":{"":"123"}}

Login return from the user service

{"_isScalar":false,"source":{"_isScalar":false,"source":

{"_isScalar":false,"source":{"_isScalar":true,"value":

{"url":"http://drupal.dd:8083/user/login?_format=json","body":{"name":

{"value":"asd"},"pass":

{"":"123"}},"reportProgress":false,"withCredentials":false,"responseType":"

json","method":"POST","headers":{"normalizedNames":

{},"lazyUpdate":null},"params":{"updates":null,"cloneFrom":null,"encoder":

{},"map":null},"urlWithParams":"http://drupal.dd:8083/user/login?

_format=json"},"scheduler":null},"operator":{"concurrent":1}},"operator":

{}},"operator":{}}

Any idea what am i doing wrong? thanks!


texts: Is there a way to programmatically add new links to the primary links?

texts: Is there a way to add links to the primary links using PHP in Drupal 6? The reason I ask is that I want to add more links in the footer of the web page, which I don't want to put in the top navigation level.


texts: %1 doesn't get converted to taxonomy name when overriding title

texts:
When using Content: Nid as a contextual filter for "Content" (node) type views, I can check "Override title" and use %1, and the node id will be converted to the real node title when displaying this title. (For example, I can type "Gallery of %1", and it will be converted to "Gallery of Blablabla".)

When I create a view for showing "Taxonomy Terms", set "Taxonomy term: Term ID" as a contextual filter, check "Override title", and use %1 the same way I did for "Content", the taxonomy id doesn't get converted to the real name of the term! (so for example "term is %1" gets converted to "term is 261", which is not the expected result)

Why, and how can I get around this problem? I'd like to override the title and use the taxonomy term name.


texts: Is learning drupal fetch a good career and I need some guide lines to startapp development learning drupal


texts: How often does drupal core need updating?

texts: How often (on average) does drupal core need updating?


texts: Cloudflare Clear Cache For One URL, Convert Curl Command to Drupal::httpClient() Or php

texts:
I am creating a custom module to clear caches on cloudflare for one url.
The original curl command:
curl -X POST "https://api.cloudflare.com/client/v4/zones/123456789/purge_cache" \
     -H "Authorization: Bearer 123456789" \
     -H "Content-Type: application/json" \
     --data '{"files": ["https://example.com", {"url": "https://example.com/my-url"}]}'

Drupal::httpClient
try {
  $client = \Drupal::httpClient();
  $url = "https://api.cloudflare.com/client/v4/zones/123456789/purge_cache";
  $options = [
    'headers' => [
      'Authorization' => 'Bearer 123456789',
    ],
    'json' => [
      'files' => 'https://example.com',
      'url' => 'https://example.com/my-url'
    ],
  ];
  $response = $client->request('POST', $url, $options);
  $code = $response->getStatusCode();
  if ($code == 200) {
    return $code;
  }
}
catch (RequestException $e) {
  watchdog_exception('module_name', $e);
}

php version:
$data = Json::encode(['files' => 'https://example.com', 'url' => 'https://example.com/my-url' ] );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/zones/123456789/purge_cache');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$headers = array();
$headers[] = 'Authorization: Bearer 123456789';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_exec($ch);
curl_close($ch);

I got one working by clearing all caches on clouldflare.
Original:
curl -X POST "https://api.cloudflare.com/client/v4/zones/123456789/purge_cache" \
     -H "Authorization: Bearer 123456789" \
     -H "Content-Type: application/json" \
     --data '{"purge_everything":true}'

The working Drupal Version:
    try {
      $client = \Drupal::httpClient();
      $options = [
        'json' => [
          'purge_everything' => TRUE,
        ],
        'headers' => [
          'Authorization' => 'Bearer ' . $authorization,
        ],
      ];
      $response = $client->request($method, $url, $options);
      $code = $response->getStatusCode();
      if ($code == 200) {
        return $code;
      }
    }
    catch (RequestException $e) {
      watchdog_exception('cloudflare_purge', $e);
    }

The drupal version return 200, but it is not doing anything and the php version I could not get it work. I would appreciate any input.


texts:
i'm creating a form which uses ahah in Drupal 6.

I have 2 select fields. The first uses ahah in order to populate the second and it works well.

But the problem is when I add a file field to the form because the ahah call doesn't work (it doesn't appear in firebug and the page is refreshed instead of the normal behavior). If I remove the file field it works again.

Any idea please? I'm getting frustrated thinking about the solution.

Thanks