texts:
Is there a way to validate fields individually like you would've done for the file upload (Eg: file_validate_extension etc)? I want to do something like this:

$form["field_name"] = array(
  "#type" => "textfield",
  ...
  "#field_validate" = array("field_validate_numeric") // or "field_validate_email" or "field_validate_url" etc
);

I know there are new html5 field types but I want to be able to validate textfields.

Also, I need this because I might not know the actual tree structure or field parents and I want to validate the field no matter how the form looks.


texts:
Say I want to ask the user to rate articles on usefulness from 1-10.

How can I apply that rating to weight calculations for future searches of the same issue/tags?

I would like the most useful articles to appear higher in the search results.


texts: Search is broken after updating search_api_solr from 8.x-2.7 to 4.1.4

texts:
My Drupal site has a search form, which connects to a Solr index. All of this was working smoothly.
But then I updated drupal/search_api_solr from 8.x-2.7 to 4.1.4 (which also required me to update drupal/search_api from 1.13 to 1.17) – and now the search is broken. Specifically:

The "default" search results – the ones that are displayed when I first land on the search page, before entering any search keywords – are now different.

When I do enter keywords and submit the search form, it always returns no results. This happens with any keywords, even when there are definitely items in the index that should match.

Here's what I've already tried:

Cleared the Drupal cache repeatedly (of course).
From the Drupal configuration dashboard, I have:

Confirmed that the Solr server and index are configured correctly, and that Drupal is able to access them.
Deleted everything in the index, and re-indexed. (This appeared to complete successfully.)
Examined the AJAX response to the search submission, and compared it to the response on a working instance of the site. (The only difference is that HTML returned on the working site includes results, and the HTML returned on the broken site doesn't.)

Looked for upgrade guides for the search_api and search_api_solr modules. (I haven't been able to find any.)

Any suggestions? I'm running out of ideas here.


texts: Create a view to show a user his or her recent activity

texts:
I am creating a view that would display the activity of the users. When user 1 is logged in, it would show the activities of user1 only...his node uploads, his comments etc,,,such as:

User1  commented on "Some Artcile"   Time
User1 Uploaded his article "Some BLOG"  Time

How should i proceed. I am using Views3, and Drupal7


texts:
I am using webform module. it is good for fulfil reqs. but there is a problem here.

i want to add placholder in textfields and in textarea. i am failed to do so.

Anyone can suggest any solution?


texts: How can I restrict external URLs in link field to allow only certain domains?

texts:
After creating a Link field and use the Link with service icon format, I find out that there is no option to restrict external URLs to external domains that I want
For example, if I only want to allow Twitter links, something like add https://www.twitter.com/*.
Someone already asked here, but it seems that the Advanced Link module is not available for my Drupal version.
With what module and how can I filter my desired URLs in Drupal 9?


texts:
When a user searches for a certain tagged iamge I want them to be able to click on the tag and re-direct them on a page which contains all the images with that tag.
E.g. if I click Italy, all the pictures which have Italy as tags will be displayed.
Can I use Views module for it?


texts: Include a part template on specific node page

texts:
I would like to include some custom html code only on a specific node.
I created "parts" directory and put a custom twig template in it. (mytheme/templates/parts/custom_html.html.twig)

I then copied over the page.html.twig to my templates directory, and included the custom template with:

{% include directory ~ '/templates/parts/custom_html.html.twig' %}

I want to show this only on a certain node, say "node/2". I don't wan't to create a custom template just for this page, like "page--node--2.html.twig".

Is there a way of using a condition to just show this template on the specific node?

Kind of like this?

{% if 'node/2' %}
    {% include directory ~ '/templates/parts/custom_html.html.twig' %}
{% endif %}


texts: Why do so many classes define a ::t() method?

texts:
I've encountered MANY methods substituting the translation function — forms, entities, plugins... What is the point when there is the global t() function that has exactly the same code

return \Drupal::translation()->translate($string, $args, $options);

as the methods do?


texts:
How do you work with regions if your website has different page layouts? For instance, the home page is a header-content-footer page, while the article page is header-sidebar-content-footer, etc.

Learning themeing :)

Thanks!


texts: Running drush sql-sync between linux drupal alias as source and windows drupal alias as target throws rsync:chgrp error

texts:
i can see from this post that rsync is trying to set group on the file which may not make sense for windows. The question is, how can i pass rsync options while running the sql-sync command as

drush sql-sync @linux_alias @windows_alias

I can run the same command between two linux drupal aliases without any problems.

Thanks!


texts: Can I run bulk update for URL aliases at command line?

texts: I have over 30,000 nodes, and bulk update is painfully slow. Is there another way to run this?


texts: How to get Fixed Navigation when scrolling to the top

texts:
I am using this module Single Page Site to get a single page and it works well.  However I want to get the navbar fixed when scrolling up the page but I cannot figure out how and where to put this jquery code in my site.

$(document).ready(function () {

  var navbar = $('.navbar');
  var origOffsetY = navbar.offset().top;

  function scroll() {
     if ($(window).scrollTop() >= origOffsetY) {
         $('.navbar').addClass('.navbar-fixed-top');
         $('.main-container').addClass('menu-padding');
     }
     else {
        $('.navbar').removeClass('.navbar-fixed-top');
        $('.main-container').removeClass('menu-padding');
     }

  }

  document.onscroll = scroll;
  });

Actually what I am trying to achieve is something similar to this website http://www.orisnv.be which itself using the modules Single Page Site.

I appreciate any help or hint.

Thanks.


texts: Remove case sensitivity from username when logging in

texts:
When I try to login, my usernames are treated as case sensitive. As in if username is john and I try entering John, it is not accepted.

Is it possible if I could make all the characters lower case before they could be submitted?

Thanks


texts: Why required form field has #required=FALSE on theme level?

texts:
I have a form with managed file field. Form has single field. I have declared this field as required and indeed after submit without file I have an error: Field is required.

I wanted to add HTML5 validation to this field, but in my custom theme_file implementation $variables array has #required => FALSE for this field...

I have even red asterisk above this input field so I truly don't know what is wrong..

My custom theme_file:

function custom_file($variables) {
    if (! _custom_isMyTheme()) {
        return theme_file($variables);
    }

    $tpl = <<<HTML

%s

        %s

HTML;
    dpm($variables);//devel shows #required property as FALSE
    return sprintf($tpl, t('Select'), theme_file($variables));
}


texts: The 'drupal' way to implement delete button UI: part 2

texts:
I asked this question earlier The 'drupal' way to implement delete button UI
The answer worked perfectly. I would like to take it a step further and make sure my routing is done the best way for Drupal. (I'd hate to think there's some uber-powerful method out there I'm missing out on).

snippet from hook_menu():

$items['bluenose/rmlist/%'] = array(
  'page callback' => 'bluenose_app_rmelement',
  'page arguments' => array(1, 2),
  'access arguments' => array ('access bluenose_app wishlists'),
  'type' => MENU_LOCAL_TASK,
);
$items['bluenose/rmlistitem/%']=array(
  'page callback' => 'bluenose_app_rmelement',
  'page arguments' => array(1, 2),
  'access arguments' => array ('access bluenose_app wishlists'),
  'type' => MENU_LOCAL_TASK,
);
$items['bluenose/rmavailableprop/%']=array(
  'page callback' => 'bluenose_app_rmelement',
  'page arguments' => array(1, 2),
  'access arguments' => array ('access bluenose_app wishlists'),
  'type' => MENU_LOCAL_TASK,
);

The method those route to:

function bluenose_app_rmelement($type, $id)
{
  switch($type)
  {
  case 'rmlist':
    bluenose_app_remove_wishlist($id);
    drupal_goto('bluenose/wishlists');
    break;
  case 'rmlistitem':
    bluenose_app_remove_list_item($id);
    drupal_goto('');
    break;
  case 'rmavailableproperty':
    bluenose_app_remove_available_property($id);
    drupal_goto('');
    break;
  default:
    break;

  }
}

Just to clarify the flow:
There are three hook_menu items that route $type and $id to a common rm* method.
This method switches among possible $type params. When it hits the right one, it calls the appropriate remove method (which performs basic crud), then calls drupal_goto() with a url that makes sense to the end-user.

How's that method chain look to you guys?
Thanks a lot!


texts: Is there a way to import a view grid into a Carousel

texts: Hi i have created grid view of a content type coupon which has a logo,description and download button and i'm wondering is there a way to import that view into a Carousel so it can display a grid of 9 coupons and when i hit next it displays another set of 9.


texts: Zen subtheme: no sidebar on a given page

texts:
The overall layout of the site is composed of a 2 column layout (main content area + right sidebar). I have a /forum section on my site and I would like to have a single plain area for it and its childs.

Adding a forum.tpl page containing no sidebars does the trick?
Another way might be to prevent .sidebar-second being loaded as a
body class for a given URL (mysite.com/forum). Is this a clean way
to do it and above all will it escalade to /forum/subforums ?

I'm using a 7.x-5.x zen subtheme with D7 and Advanced Forum as the forum solution.


texts:
My drupal form submit function is not called. validation function is called. Form name is Mymodule_user_profile_form($form, &$form_state), validation function name is Mymodule_user_profile_form_validate($form, &$form_state) and submit function name is Mymodule_user_profile_form_submit($form, &$form_state). I have studied all the previously asked questions.

This is the last portion where I declare my submit button is defined.

$form['profile']['profile-share']['profile-save-reset-btn']['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Spara'),
  //'#name' => 'save-profile',
);

I have tried like this.

$form['#submit'][] =  'Mymodule_user_profile_form_submit';

var_dump($form['#submit']); Shows the submit function but it's never called. Any Idea about this?


texts: Drupal Commerce 2 Promote Product to Front Page

texts: I am using drupal commerce 2 to create an ecommerce website. Need to promote some products to front page but there is no option in product types to promote the product to front page. In Drupal Commerce 1 we use to reference the product in product display node and that can be easily promoted to front page. Is there any different method to do that ?


texts:
Hello Drupal community!

I have a questions about displaying content with views. Is it possible to center the content within the block, in-browser?

Right now I have two entities next to each other, both left-aligned. I am trying to get them both centered in the block, and centered on the page.

Any ideas?


texts: Date field select option in custom module

texts:
I am using drupal 7 and i am need of create a custom module to show the selected filter option values to be displayed on some other pages. By default we using the filter in the views, it shows the filter result values on the same page. So that only i prefer to go custom module.

In my custom module i have four fields which are two drop down values and one keyword search functionality and final one is year based search. I have a problem with passing the drop down option year based filter. The functionality works fine for me. But while the we show the drop down of the year it doesn't mention the default select year. The first option shows empty and rest of the option shows the year. While picking a year it searches fine, But I want to show the default value in the year field, to know the field was choosing the year.

I code is

    function customsearch_box($form, &$form_state, $form_id){
    $form['release_date']= array(
        '#type' => 'date_select',
        '#title' => t(''),
        '#title_display' => 'invisible',
        '#date_format' => 'Y',
        '#size' => 40,
        '#default_value' => 'RELEASE DATE',
        '#attributes' => array('title' => t('Enter the terms you wish to customsearch for.')),
      );
    }
    function customsearch_box_form_submit($form, &$form_state) {
      if($form_state[input][release_date][year]=='RELEASE DATE'){
        $form_state[input][release_date][year]='';
      }
      $form_id = $form['form_id']['#value'];
      $form_state['redirect'] = array('research-result',
      array('query' => array(
        'field_srch_release_date_value[value][year]'=>trim($form_state['input'][release_date][year]),),),);
    }


texts: Invalid form POST data - ajax for Authenticated users

texts:
I have a Drupal form using ajax. When I submit the form I am getting the following being displayed:

When I check the Drupal log I have the following entry.

I have Googled the error and found this post but it applies to anonymous users. I am only using this with authenticated users.

Searching for the error in the code returns the ajax_get_form() function in ajax.inc

 $form_state = form_state_defaults();

  $form_build_id = $_POST['form_build_id'];

  // Get the form from the cache.
  $form = form_get_cache($form_build_id, $form_state);
  if (!$form) {
    // If $form cannot be loaded from the cache, the form_build_id in $_POST
    // must be invalid, which means that someone performed a POST request onto
    // system/ajax without actually viewing the concerned form in the browser.
    // This is likely a hacking attempt as it never happens under normal
    // circumstances, so we just do nothing.
    watchdog('ajax', 'Invalid form POST data.', array(), WATCHDOG_WARNING);
    drupal_exit();
  }

$form is not an object. I am not sure why.

In the ajax_get_form() function I am doing ado a dd() of $form_build_id. This returns me something like form-ymw-BN0Zhp9j2CZf82mZzslbUBiLo8kZbreXhB1y8kE.

If I perform the following SQL in the database I get a result.

select *  from cache_form where cid like '%form-ymw-BN0Zhp9j2CZf82mZzslbUBiLo8kZbreXhB1y8kE%';

The cid in this instance is  form_state_form-ymw-BN0Zhp9j2CZf82mZzslbUBiLo8kZbreXhB1y8kE.

In form_get_cache() the code is as follows:

function form_get_cache($form_build_id, &$form_state) {
  if ($cached = cache_get('form_' . $form_build_id, 'cache_form')) {
     //code missing
  }
}

From cache_get() we are looking for form_form-ymw-BN0Zhp9j2CZf82mZzslbUBiLo8kZbreXhB1y8kEbut what we have stored in the database is form_state_form-ymw-BN0Zhp9j2CZf82mZzslbUBiLo8kZbreXhB1y8kE. Of course we do not match so nothing is returned.

I am unsure why this is happening.

My form code is as follows

  $form['welcome'] = array(
    '#markup' => //some html markup,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Test'),
    '#ajax' => array(
      'callback' => 'myform_js',
      'wrapper' => 'message_container',
      'method' => 'replace',
      'effect' => 'fade',
      'event' => 'click',
    ),
  );

  $form['result'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
    '#type' => 'fieldset',
  );

The function myform_js() is not being hit as when dd() is added to the top it is not called. I can't see anything obviously wrong with this so not sure if there are any environmental issues that could cause the issue.

I have also tried changing the type of $form['submit'] to button.

It looks that the part that is failing is the call to cache_set(). I am unsure as why at the moment.


texts: Show a page with child Terms when parent Term clicked in block?

texts:
I want to Display child terms when a parent Term is clicked with Views in Drupal 7.
         Example

     Parent1
          .child11
          .child12

      Parent2
          .child21
          .child22
          .child23

So when Parent1 page is Visited, i will display the content of parent1 but with a block showing

          .child11
          .child12

Any insight in Achieving this will be Appreciated. Thank you.


texts:
My website has a content type with about 15 fields. Now I don't have all the data to fill the fields all the time. I've got close to 1000 entries in this content type.

Is there any module that can work as a Notifier. Ex: I've chosen to have Content Type A selected and the module tells me how many Entries that are not 100% filled and what fields are missing. ?


texts:
I am unable to redirect back to the page after executing the user_save. Following is my code snippet:

//if the response code is failed rollback the user changes and redirect
if ($results['code']!=200) {
  user_save(NULL,$account);
  drupal_goto("/admin/people");
}


texts: Could not find package with stability dev in a version installable using your PHP version

texts:
When I want to install Drupal Commerce using Composer via Git Bash terminal and using the following command:

$ composer create-project drupalcommerce/project-base mystore --stability dev

I get the following error:

  [InvalidArgumentException]   Could not find package
  drupalcommerce/project-base with stability dev in a version
  installable using your PHP version 5.6.40.

  create-project [-s|--stability STABILITY] [--prefer-source]
  [--prefer-dist] [--repository REPOSITORY] [--repository-url
  REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers]
  [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs]
  [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--]
  [] [] []

So what can I do?


texts: How to check in Rules the value of a field collection field contained in a user account?

texts:
I want to give a specific user a price override on specific products. In doing so, I added field collection on the people account setting. This field collection has to two fields: product sku and price.

I also created a rule with this codes:

{ "rules_price_override" : {
"LABEL" : "price override",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
"ON" : { "commerce_product_calculate_sell_price" : [] },
"IF" : [
  { "user_has_role" : {
      "account" : [ "site:current-user" ],
      "roles" : { "value" : { "2" : "2" } }
    }
  },
  { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
  { "entity_has_field" : {
      "entity" : [ "site:current-user:field-price-override:0" ],
      "field" : "field_product_sku"
    }
  },
  { "data_is" : {
      "data" : [ "site:current-user:field-price-override:0:field-product-sku" ],
      "value" : [ "commerce-line-item:commerce-product:sku" ]
    }
  }
],
"DO" : [
  { "commerce_line_item_unit_price_amount" : {
      "commerce_line_item" : [ "commerce_line_item" ],
      "amount" : [ "site:current-user:field-price-override:0:field-regular-price:amount" ],
      "component_name" : "base_price",
      "round_mode" : "1"
    }
  }
]
}
}

But it only good for the first field collection value.

What will be the best way to make it loop, so that it can change its index as site:current-user:field-price-override:0 - end


texts: Use an existing Drupal site to create a new site

texts:
Today I tried to copy a existing Drupal site for creating a new one on a other domain-name.

The problem: the new website still uses the old DB. So if I create a new user for example, this user also show up in the other (first) website. The same thing for deleting content.

What did I do:

Created a new DB for the new website.
Backup the DB form the old website and find/replace the domainname
to the new domain-name is the sql-file.
Import the SQL into the new DB
Copy the website-drupal folders from the old website - change the
setting-file in map DEFAULT with the new DB info. (so it connects to
the new DB - after that i FTP the files to the new host.

When I visit the new domain-name a copy of the website showed up and I could login. The first thing I wanted to do was delete all content and users. But seems to be the actions I do in the new website also happens in the old website.

I did a search on Google and find out I did have to change some info in SQL-file. First time I did not do that so I did everything again... so also with step 2)

But the new website seems to be still connecting to the old website. I erased the DB of the new site and the website is still working. So it makes still contact with the OLD DB.

So changing the settings-file and SQL file was not enough.

What did I do wrong??

Any tips, links are welcome!


texts: How to print a raw field value containing special characters in a node template?

texts:
I have a text field which get filled with an URL, I am now trying to get the raw value of this field like "http://example.com", but every method I tried like

entity_metadata_wrapper
field_get_items and field_view_value
field_extract_value

just returns the following " http:  example.com"

How can I pull it out right?

Edit:

Debug says:

[field_externer_link] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [value] => /download/hier.jpg
                        [format] =>
                        [safe_value] => /download/hier.jpg
                    )

My node.tpl content: (Also tried methods mentioned above resulting in same output as you can see below)

$object = entity_metadata_wrapper('node', $node);
$externer = $object->field_externer_link->value();
echo '
Download
';

The output:

Download


texts: Return data from WebformHandler to Controller

texts:
I created WebformHandler where I need to get data entered in the form on submit. It's something like this:

<?php

namespace Drupal\xxx\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Form submission handler.
 *
 *
 * @WebformHandler(
 *   id = "xxx",
 *   label = @Translation("xxxx"),
 *   category = @Translation("xxx"),
 *   description = @Translation("xxx"),
 *   cardinality =
 *       \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *   results =
 *    \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */
class XxXx extends WebformHandlerBase {

  public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

    $values = $webform_submission->getData();
    // Get data here
  }
}

I also have the Controller and defined route with template file. Controller looks like this:

<?php

namespace Drupal\xxx\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\xxx\Plugin\WebformHandler;

/**
 * Class SearchFlightsController.
 */
class XxXController extends ControllerBase {

  /**
   * xXx.
   *
   * @return array
   *   Return search parameters string.
   */
  public function xXx() {

    return [
      '#theme' => 'xxx',
      '#search_query' => $this->t('Test Value'),
    ];

  }

}

My question is how to pass the data that I get in WebformHandler on form submit to Controller that need to show the page with defined route?


texts: Add inline style to render array attributes, without XSS filtering

texts:
I wish to use an inline style to add a dynamically generated background image URL to a div, e.g.

  $build[0] = [
    '#type'       => 'container',
    '#attributes' => [
      'id' => 'thumbnail-image',
      // the example below is a YouTube thumbnail, to be cropped using other CSS
      'style' => sprintf('background-image: url("https://img.youtube.com/vi/1234567890/sddefault.jpg");', $video),
    ]
  ];
  return $build;

The XSS filtering silently drops style attributes.  Can I disable that for an individual render array, or otherwise work around it?

Note: this is generating output for a Field Formatter, used in a view.

The official advice is:

  If your markup needs any of the tags not in this whitelist, then you
  can implement a theme hook and/or an asset library. Alternatively, you
  can use the key #allowed_tags to alter which tags are filtered.

Things tried:

1) using a theme hook and a template

Here's my template:

Sample output

It's working, except the style attribute is still being stripped out.

2) #allowed_tags (but it's not a tag, it's an attribute):

'#allowed_tags' => array_merge(\Drupal\Component\Utility\Xss::getAdminTagList(), ['style']),

Successful workaround:

This code is in a field formatter for views, so I overrode the default views template. The views templates allowed a style attribute to pass through as I would have expected.

Initially I made a template for one specific field, but the problem was I needed to access the values of a separate field too and it was proving hard/impossible to retrieve them with the row._entity variable.

So then I decided to use views-view-fields.html.twig instead, which gives access to all the fields. This took rather longer, but as my code had a couple of conditionals and some variables used more than once, on balance the end result is cleaner than doing everything in the UI. (It's worth leaving yourself a note in the view UI admin comment and any docs that the view field is overwritten.)


texts:
When I post a comment, I get the following error on Drupal 7:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-28-0-0-und' for key 'PRIMARY': INSERT INTO {field_data_comment_body} (entity_type, entity_id, revision_id, bundle, delta, language, comment_body_value, comment_body_format) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => comment [:db_insert_placeholder_1] => 28 [:db_insert_placeholder_2] => 28 [:db_insert_placeholder_3] => comment_node_multi_discussion_theme [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => test [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 451 of /ftphome/dev_itf_events/modules/field/modules/field_sql_storage/field_sql_storage.module).

What could be the cause?


texts:
I want to check a data when an user submits a form. I set a custom submit handler in form alter, but my custom handler function never gets called. I don't understand why.

This is my code :

/**
 * Implements hook_form_alter().
 */
function custommodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
    if($form_id == "node_test_form") {
        kint("toto"); //toto is displayed when I load the form page
        $form_state->setSubmitHandlers(array("_custommodule_test"));
    }
}

function _custommodule_test(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
    kint("mwahahaa?"); // never displayed
    die(); // doesn't work, the submit form page loaded successfully
}

I cleared cache, but the issue is still there.

Edit ##

I tested add a validate handler, the problem persists.. The code :

/**
 * Implements hook_form_alter().
 */
function custommodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
    if($form_id == "node_test_form") {
        kint("toto"); //toto is displayed when I load the form page
        $form_state->setSubmitHandlers(array("custommodule_myform_mysubmit"));
        $form_state->setValidateHandlers(array("custommodule_myform_myvalidate"));
        $form_state->getSubmitHandlers(); // display array("custommodule_myform_mysubmit")
        $form_state->getValidateHandlers(); // display array("custommodule_myform_myvalidate")
    }
}

function custommodule_myform_mysubmit(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
    kint("submit ?"); // never displayed
    die(); // doesn't work, the submit form page loaded successfully
}

function ccustommodule_myform_myvalidate(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
    kint("Validate ?"); // never displayed
    die(); // doesn't work, the submit form page loaded successfully
}


texts:
I have a Views block showing the profile of a user. I would like to make it look like so:

where there is a button next to some of the changeable fields, when clicked will make the field value a textbox, where the user can update it.

How can I achieve this with Drupal?

Config: Drupal 7, Bartik theme.

Any help is appreciated.


texts: Why is my view not displaying Solr index results?

texts: I have a multilingual site and I created a Solr server, created an index (for all content types), added fields, generated the search (it displayed that all my nodes were succcessfully indexed 8/8), then created a view using that index and selected render entity and the view has no results. I tried fiddling about with every setting in the search_api options/index, rebuilding the index, clearing the cache, and the view results is always empty. Ideas?


texts: How to clear form element values after validation error

texts:
I have a rather complex form validation depending on multiple fields. If validation fails, I would like to set the form values (of all or some explicit fields) to an empty value. This is what I tried, but none of the three approaches works:

public function validateForm(array &$form, FormStateInterface $form_state) {
  ...
  if (!$authorized) {

    $this->messenger->addError($this->t('An error occured.'));

    $form['name']['#value']=''; // approach 1

    $form_state->setValue('name',''); // approach 2

    $form_state->setValueForElement($form['name'], ''); // approach 3

    $form_state->setRebuild();
   }
 }


texts: How to include XML file in node for js map rendering?

texts:
I have a clickable map that uses js, css and xml to display. I previously was provided solutions in a previous thread  How do I implement a clickable JavaScript map? using drupal_add_css() and drupal_add_js().

Can I add multiple CSS files with drupal_add_css() using an array? Or, do I need to list these as separate commands?
The other problem is I need to have an XML file to feed the data into the JavaScript file. I attempted to edit the JavaScript file by hardcoding the XML file location, but that doesn't seem to work.

$.ajax({type: 'GET',url: 'sites/default/files/repfinder/xml/usaMapSettings.xml'

What should I be doing so that the JavaScript code recognizes the XML file? Without it, no map is displayed.


texts: Expose Date Filter instead of Start & End Dates

texts:
I have a content type event with start and end dates marked. I have create a view with exposed filter, where in users can choose a date and see the event on those days. Right now, view is only allowing me to choose start and end dates. This way if an event is between March 1st - March 10th, there is no way for user to filter and see the events for say March 5th. Technically event being from 1st-10th is also present on March 5th. How can I expose a filter where in user can get events by any date.

Below is what I have now:

But I want like below:


texts: How to create a View that shows other nodes that have the same entity reference as the current page

texts:
I have job nodes, that relate to organizations. I want a sidebar block that will display other jobs that are related to the same organization.

I have tried a lot of different permutation of contextual filters and relationships, but so far I have not been successful.

I can only get the nid of the current node via a contextual filter, but that filters the content directly. I need just to get the referenced organization node, and then filter the view by that reference, but I can't seem to make it work.

(This question is for Drupal 7 with entity reference. The same question for Drupal 6 is here).


texts: Restricting Video upload to mp4 format alone - in media module

texts:
I have been struggling put restriction for uploading video to upload only mp4 videos in media module, other media content like image etc. can be uploaded, but I need to put restriction for video type alone.

I am newbie in Drupal, can some one help me in this, what are the places I need to change in media module.

I would really appreciate any help on this. I did found sites\all\modules\media\includes\media.pages.inc file which had a function media_add_upload_validate($form, &$form_state) also then I found sites\all\modules\media\includes\media.variables.inc which had function media_variable_default and media_variable_get. Then I got lost. I am not sure if these are the correct files where I need to make the changes. Also I was wondering if I have to make change in Drupal core module to do the video upload restriction to mp4 perfectly.

Thanks


texts: How to set only one save button for a page with Editable Fields by Views?

texts:
Using Views, I created a page that has editable fields(by Editable Fields Module) for Profile2 fields. Those editable fields have few kinds of type/widget of field such as Text, SHS(Simple Hierarchical Select) for Term reference, and Radio Button for List (text).

Now, I have a problem that few save buttons for each type/widget of fields are displayed in the page. The one is placed below SHS field and seems for saving only it, another is placed below the Radio Button field, and the other is for the Text one.

I want only one save button for all of fields in a page. Do anybody know how to unify those save buttons into one?


texts: Is it possible to POST more than one article at once?

texts:
How do I POST two or more articles at once?

Something like follows:

{
"_links":{ "type":{ "href":"http://drupal8/rest/type/node/article" } },
"title":[{"value":"Title 1"} ],
"title":[{"value":"Title 2"} ]
}
Result: Status Code: 400 Bad Request "Syntax error"

It is even possible for a single request to add more than one article?


texts: How to implement a Views 3 exposed filter in block as a list of links, and update the view via ajax?

texts: I need to create a views exposed filter that is displayed as a list of links, and updates the view via Ajax.  I've tried using Better Exposed Filters and it will display the filter as links, but without ajax.  I've tried to figure out how to theme the default views select element (which is ajaxified) as a list of links, but haven't found a good way to go about this yet.  Any suggestions would be much appreciated.  Thanks!


texts: How an user set his own password while creating account

texts:
When a user creates an account he is only asked for a username and email.

I also want him to set his own password when he creates an account. how can i manage that as admin?

Thank you!


texts: hook or similiar to automatically send any webform submissions to an email address, without manually adding a handler to each existing webform?

texts:
We have a Drupal 8 site running Webform 8.x-5.2. We have a special role, "Webform Editor", who is not a developer, but they are trained to create the webforms that we need for our organization.

We've been dealing with some organizational issues about who is getting what webform submission emailed to them. To help us troubleshoot the issue, we the developers want to implement a feature where each webform submission gets automatically copied (cc'ed or sent separately) to an email address that we devs have access to.

I looked at the webform module's hooks, and I didn't see any that jumped out at me as a post-submission hook. Webform version 7.x had one, but version 8.x doesn't appear to.

I made a custom submission handler, but realized I would have to add it manually to all existing webforms (we have more than I want to click through).

I began to write a form_alter hook to add custom submit handler, but when I debugged the $form and $form_state, I didn't see any information (i.e. sid) about the submission record. I suppose that the submit hooks fire before the submission record is created.

In the webform cookbook, there's a recipe for "How can you automatically create a default email handler for a webform when it is created", but again, I want to automatically add this to existing webforms.

If I could do this with something like a hook, once and for all, that is what I'm looking for. If the answer is "No, you can't do what you want automatically; you'll have to make a handler and manually add it to all existing webforms", am I interested in hearing that answer, too. I don't want to chase down any more rabbit holes of approaches that won't work.


texts: How to translate admin interface in Drupal Commerce Kickstart?

texts:
I have translated my site in Japanese. But it is not translating all the content. I want to translate all the strings available on the site, including admin panel.

I searched for the string in the translate interface, but I couldn't find it. I used Translation template extractor to search the strings. But this thing also didn't help me.

Please tell me how to change the admin side text?

Here's the image showing what kind of strings I want to change :


texts: How do I select the most recently created entity item in Rules

texts:
I have in Drupal Commerce products the price of which needs to calculated based on a value that is updated daily. (For the curious: the prices that are stored are worked into a formula that includes current copper sell prices and a copper price to total price ratio). I have used the Entity Construction Kit to create a small entity type to store copper prices - basically just date and price.

I'm having trouble selecting the most recently added copper price entity though.
Right now I'm looking at action "Fetch entity by property" (out of Entity Rules) and selecting by the current date. This would mean though that each day the customer would need to think to add a new price for tomorrow - which would definitely cause trouble.
Is there a module that offers to sort a list and select the last/first item in Rules?


texts: Entity base field requires value despite setRequired(FALSE)

texts:
I have set a field in my entity to not required using

->setRequired(FALSE)

However when I then leave the field blank and try to save the entity I get this error

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'category' cannot be null: INSERT INTO {myentity_field_data} (id, langcode, uid, question, category, runtime, anonymous_vote_allow, cancel_vote_allow, result_vote_allow, status, created, default_langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => en [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => test [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => 1 [:db_insert_placeholder_8] => 1 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 1442607827 [:db_insert_placeholder_11] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 930 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

So is this a result of setRequired or some failure of my entity reference?


texts:
I'm trying to create a custom template using the Drupal Newsletter module.

I need to populate the newsletter with existing content. For this, I think I need to replace a token like [node:nid] in the newsletter body (which is created with CKEditor). However, I have been unsuccessful.

When I use the token filter module, I'm only able to replace global tokens like date or [site:url] and not tokens involving a node. Can someone please help me out?


texts: Programmatically update field collection data in custom entity

texts:
I am in desperate need of help.

I have a custom entity called Question which has a bundle called data.
Within the data bundle, I have a collection field called options with two subfields called correct_option & misc_option.

-Question
 -Data
  -options
   -correct_options
   -misc_options

I am desperately trying to programmatically write data into those 2 option fields but the following code is not working:

$field_collection_item_value = 1596; // Get field collection item value.

$field_collection_item = entity_load('field_collection_item', array($field_collection_item_value)); // Load that field collection item.

$field_collection_item->save(); // Save field-collection item.

The 1569 is the ID of an existing question entity.

Whenever the code is executed I get the following error:

  Fatal error: Call to a member function save() on array

I would appreciate any help. I'm at a loss and not sure how to get this working.


texts: I'm working on a custom field that will store a string.  The text will have a custom formatter applied to it that will manipulate the structure of the string (adding dashes in the right places).  I have a javascript that will apply those changes in the field's input textbox when creating a new content type with the custom field, but I can't figure out how to fire the javascript when the user enters the text.  Can it be done and if so can anyone point me in the right direction?


texts: Problem with migration from Apache to IIS

texts:
I run a website with Drupal in Linux/Cpanel/Apache/MySql and it worked perfect.
I want to put this site in Windows/plesk/IIS/MySql. I backed up and restore database in the new host and copied Drupal files.

My website run in new host with some problem.

I can't see administrative page; this page is white.
My links don't work with clean URLs and I should add (?q=) to links.
My images with ImageCache are not shown. The URLs for images are not correct and have a space.


texts:
I'd like to know if there's a module that would allow users without administrator rights to inspect the database in order to see what nodes are using certain fields from specific content types.

Basically we want to get rid of some of the fields present on some of the content types we have on our platform but we're not sure how many nodes are using them and what values have been filled out from the back-end without having to dump the database.


texts: Error during "composer drupal-update" for Drupal 8.0.5

texts:
I've been running a Drupal 8 site since 8.0.0, using the Address module. As this required some CommerceGuys dependencies in the /vendor folder, I've been using the following commands to load dependencies (and update to newer versions of other components):

php sites/all/modules/composer_manager/scripts/init.php
composer drupal-update

However when I run this for 8.0.5, I'm getting the following error (not all output included):

  Drupal\Core\Composer\Composer::vendorTestCodeCleanup

  Removing guzzlehttp/promises (1.0.2)
  Installing guzzlehttp/promises (1.0.3)

  Drupal\Core\Composer\Composer::vendorTestCodeCleanup

  Removing guzzlehttp/guzzle (6.1.0)
  Installing guzzlehttp/guzzle (6.1.1)

  Drupal\Core\Composer\Composer::vendorTestCodeCleanup

  Removing symfony/browser-kit (v2.7.6)
  Installing symfony/browser-kit (v3.0.3)

  Drupal\Core\Composer\Composer::vendorTestCodeCleanup

  Removing fabpot/goutte (v3.1.1)
  Installing fabpot/goutte (v3.1.2)

  Drupal\Core\Composer\Composer::vendorTestCodeCleanup

  Removing behat/mink (v1.7.0)
  Installing behat/mink (v1.7.1)

  Drupal\Core\Composer\Composer::vendorTestCodeCleanup
  Script Drupal\Core\Composer\Composer::vendorTestCodeCleanup handling the post-package-update event terminated with an exception

  [RuntimeException]
    The directory 'tests' in package 'behat/mink' does not exist.

The CommerceGuys modules components are not getting loaded. I'm not sure if this is because of the above exception.

This has worked for every previous Drupal 8 update, so I'm not sure what's different this time.


texts: Drupal Views : Cumulative filtering from an exposed tag cloud

texts:
Sorry for this newbie question...
I hope you can help.

I need to set up a search result page, with a tag cloud as a filter.
If user select one tag (termX), the matching rows are being displayed.
He could refine his search by clicking on a second tag, to refine it even more (displaying results matching termX AND termY).

Ideally, the selected tags in the cloud, should be visually seen as "selected".

Any idea which module should I rely on ?
Do I need to go through a custom development instead ? Any hints ?


texts: What to do for correct book navigation for 2 languages (always both book pages are shown)

texts:
We are using in productive system D6 (here it works!) and now we upgrade to 7.25 (it doesn't work). I have a problem to get the book navigation working in the right way. It shows always both languages in the block. How to set up it correctly?

I don't know if it is important, but here some facts from our D6 productive system:
- default language: GERMAN
- Source language for translation: GERMAN
- Second language: ENGLISH

We use pathauto and the links to an English and German page are in that way:
DE: /content/
EN: /en/content/

Language negotiation settings: Path prefix only
Content selection mode: Only current language.

Does anyone know which is the D7 equivalent parameter or configuration for D6 "Content selection mode:Only current language"?

Thank you
Mathias


texts:
I am using search api solr and using views for search results. In my content type, there will be a multilingual field using entity translation and also a field representing language of the node. I am having three languages in the site.

I would like to sort the results by language.

Like, if the site language is set to english,

The search results should first list all english language nodes and then second language and then third. Suggest me a way to fix this.


texts: "Page not found" or "Forbidden" when submitting form Is it a problem with Apache?

texts:
I have some reseller hosting and I am running Drupal 7 sites on several different accounts there.

I recently noticed a problem when updating one of them. It happens when I am editing content or changing admin settings.

I go to an admin page - e.g. my.site/admin/people/permissions.
I make a change and hit "Save".
The page submits and reloads. The address
bar still says my.site/admin/people/permissions, but the page content
is:

  Page not found
  The requested page "/admin/people/permissions" could not be found.

I tried changing .htaccess files, disabling modules, etc, but nothing worked. In the end I did the following:

Created a new hosting account on my reseller hosting
Installed a fresh copy of drupal-7.58
Created a new database

When I repeated the actions above, I got the same results, except this time the error message was the following.

  Forbidden
  You don't have permission to access /drupal-7.58/admin/people/permissions on this server.

  Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I then checked another account on the same reseller hosting. It's running Drupal 7.54 and showing Page not found.

I didn't have the problem a few weeks ago, so I am wondering if my hosting company has changed something in Apache which is causing this problem (really clutching at straws here).

I am using:

Apache 2.2.32
PHP 5.6.30
MySQL 10.0.34-MariaDB

Can anyone help?


texts:
In Drupal you can use the following in template.php to test for a node type:

function THEMENAME_preprocess_node(&$variables) {
  if ($variables['type'] == 'INSERT TYPE HERE') {
    // include code
  }
}

How do you test for an entity that is attached to a node?


texts:
I downloaded the Admin_toolbar module, installed and enabled it with Drush (drush en admin_toolbar -y).

If I look in admin, it's enabled. But it's not working; it's not hovering.

Notes:

I have a Git workflow. But for now I just installed it locally. I had some issues with the $config_directories. For the configuration files. Could this may have to do with this? Now I returned to default settings in settings.php and in admin/reports/status I get no errors.
I installed with Acquia Dev Desktop and have Mac OSX. Shall I trie de-install and install again maybe?


texts: In Drupal 7, moving the comment form above the comments

texts:
Before anyone suggest the Comment Form Above Comments, I have already tried that it did not work.

Honestly there seems to be amazingly little documentation on this issue, given that comment form above the comments is so standard on many sites now a days I would figure there would be a simple button to click to make this happen.

This leads me to believe that either there is a simple solution that I am completely missing or there is no way to do this and I am doomed.  Me I am hoping for the first one.

I have a blog site... I read about altering the core code of the comments module, but I have also heard that it is bad practice to alter the core code.  So if there is another solution out there available to drupal 7 I would appreciate it.


texts: Print out recaptcha webform verification

texts:
I created a webform-form-230.tpl to readjust the webfrom layout.

    <?php print drupal_render($form['submitted']['name']); ?>
    <?php print drupal_render($form['submitted']['e_mail']); ?>
    <?php print drupal_render($form['submitted']['subject']); ?>
    <?php print drupal_render($form['submitted']['date']); ?>

    <?php print drupal_render($form['submitted']['message']); ?>

<?php print drupal_render($form['submitted']); ?>
<?php print drupal_render_children($form); ?>

I added recaptcha module.
How do I add recaptcha script in it?


texts: How to combine two node/add/* forms into one form but create two different types of content in drupal 7 on submitting it?

texts: I want to combine two content/add/* forms into one form but create two different types of content in drupal 7 on submittiing a single from.


texts: Update Drupal 6 CCK fields through another tool

texts:
I am looking to update the fields of Drupal 6 CCK through a mini panel where some certain users can only change their information.

I am choosing to update out to be an area that customers already know and not have to change environment, in this case Drupal, which is used internally by the team to register a few things.

I found a solution updating directly in the database, but are not advising me, any suggestions for a more correct way?


texts: How can I access variables set by node_view_multiple() in node.tpl.php or a preprocess function?

texts:
I'm using this code In Drupal 7:

$nodes = node_load_multiple($nids);
$build += node_view_multiple($nodes);

The node_view_multiple() function adds a variable to the build:

$build['nodes'][$node->nid]['#weight'] = $weight;

How can I access this variable either in the node.tpl.php template file, or otherwise in hook_preprocess_node()?


texts: Undefined index: und on search-result.tpl.php for Taxonomy Terms

texts:
I want to show the node title and related taxonomy terms in a table and modifying the search-result.tpl.php to do this.

What I use to for taxonomy terms is that:

<td class="field-item">
<?php
    $str = '';
    foreach($result['node']->field_my_taxonomy_term['und'] as $obj)
        $str .= l($obj['taxonomy_term']->name, 'taxonomy/term/' . $obj['tid']) . ',&nbsp;';
    print trim($str, ',&nbsp;');
?>
</td>

This code works in one of my Drupal website and doesn't work on another one and gives this error:

Notice: include() (.../search-result.tpl.php  line 20) Undefined index: und.
Warning: include() (.../search-result.tpl.php  line 20) Invalid argument supplied for foreach().

How can I show the taxonomy terms related to the node in search-result.tpl.php?


texts:
I have a site with 2 multi site like

abc.com
xyz.abc.com
zxy.abc.com

All sites have same drupal 7 code base. and I shared all users successfully across all portals.

my setting file for sub-site looks like this

$main_database_prefix = 'abc.com.';
$current_database = 'xyz';
$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => $current_database,
      'username' => 'xxxx',
      'password' => 'xxxx',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => array(
              'default'   => '',
              'users'     => $main_database_prefix,
              'sessions'  => $main_database_prefix,
              'role'      => $main_database_prefix,
          'role_permission'      => $main_database_prefix,
              'users_roles'   => $main_database_prefix,
              'user_ips'   => $main_database_prefix,
              'user_profile_details' => $main_database_prefix,
              'price' => $main_database_prefix,
              'transaction' => $main_database_prefix,
          'db_roles' => $main_database_prefix,
          'user_modification_history'=>$main_database_prefix,
          'authmap'=> $main_database_prefix,
          'user_industry'=>$main_database_prefix,
          'user_account_request'=>$main_database_prefix,
          'user_account_details'=>$main_database_prefix,
          'country'=>$main_database_prefix,
          'states'=>$main_database_prefix,
          'discount'=>$main_database_prefix,
          'taxname'=>$main_database_prefix,
          'price'=>$main_database_prefix,
          'transaction'=>$main_database_prefix,
          'field_data_field_subscriber_name'=>$main_database_prefix,
          'field_revision_field_subscriber_name'=>$main_database_prefix,
          'profile'=>$main_database_prefix,
          'profile_type'=>$main_database_prefix,

    )
    ),
  ),
);

all tables working properly , except

'field_data_field_subscriber_name'=>$main_database_prefix,
      'field_revision_field_subscriber_name'=>$main_database_prefix,
      'profile'=>$main_database_prefix,
      'profile_type'=>$main_database_prefix,

I can not see these fields on registration page or in backend
The only difference is these table are entity reference table.

I googled things a lot for this but no success.

Thanks in advance.


texts: Drupal 8, Commerce 2 custom products, variations and order items

texts:
I'm trying to create custom products with Commerce 2. More specifically I'm trying to have custom ui for customers to build their purchasable products.

I thought that I would be able to create single Product and it's variation and then make some adjustments for price and some other fields. It seems that I'm able to programmatically create custom OrderItem, set all custom fields as needed and then add item to cart. Apparently this works as expected.

But I'm having issues getting custom price set for the OrderItem. Seems that I have to create separate ProductVariation for each ordered item, even if it's the same in all practical purposes. Only differing data is price. I tried using instructions here(http://docs.drupalcommerce.org/v2/recipes/orders.html).

$order_item = \Drupal\commerce_order\Entity\OrderItem::create([
  'type' => 'custom_order_item_type',
  'purchased_entity' => $variation_red_medium,
  'quantity' => 2,
  'unit_price' => $variation_red_medium->getPrice(),
]);
$order_item->save();

If I leave unit_price empty, to be set later, I get TypeError: Argument 1 passed to Drupal\commerce_order\Entity\OrderItem::setUnitPrice() must be an instance of Drupal\commerce_price\Price, null given, called in /var/www/drupalvm/web/modules/contrib/commerce/modules/order/src/OrderRefresh.php on line 143

I'm trying to do this:

// You can also set the price with setUnitPrice.
$unit_price = new \Drupal\commerce_price\Price('9.99', 'USD');
$order_item->setUnitPrice($unit_price);
$order_item->save();

Only way I got this to work was setting ProductVariation price separately, but this then updates the basic price on the Product page, which really isn't what I'm looking for..

On the documentation it says this:

 * adjustments [OPTIONAL] - [Array(Drupal\commerce_order\Adjustment)]
 *   Array of any price adjustments.

but I can't get this far because OrderItem creation fails because of the missing price. If I set price, it just get's overridden from the initial ProductVariation.

I suppose that I can get around this by creating those ProductVariations on the fly, but I'd rather not since I don't need those for anything else than this single purchase.

So I guess I'm looking for some instructions on how to do dynamic products. Tried PurchasableEntity initially, but couldn't get that working at all and wasn't able to reverse engineer my needs from ProductBundle or similar.

Or any info how to set OrderItem price independently from ProductVariation.

Cheers,

Janne


texts: How to relate an image to an article when posting the article in REST API

texts:
Using the following code we can post a node trough rest API. However, if there is an image attached to this article we need to post the image node first and then include the image fid in the article.I successfully posted the image also but as far as the documentation is very incomplete I am not able to find a way to add the image fid to the second request to attach it to the article.

$serialized_entity = json_encode([
   'title' => [['value' => $node->title]],
   'body' => $node->body_array,
   'type' => [['target_id' => $node->node_type]],
   '_links' => ['type' => [
       'href' => $base_url.'/rest/type/node/'. $node->node_type
    ]],
]);

$response = \Drupal::httpClient()
    ->post($base_url.'/entity/node?_format=hal_json', [
        'body' => $serialized_entity,
        'headers' => [
            'Content-Type' => 'application/hal+json',
            'Authorization' => 'Bearer '. $token->access_token
        ]
    ]);

Is this the right way to attach an image? if yes, what are the request parameters we need to add the image to the node post request?

Any help would be appreciated.
Thanks


texts: Create a vocabulary with terms that are linked to a content type

texts:
I need to create a vocabulary with this "twist": the taxonomy terms of the vocabulary are the titles of the article based on a specific content type.

This means that if I create, modify, or delete an article based on the content-type "vocabulary," the relative term in the vocabulary should be added, modified, or deleted.

Imagine I have the content type "Cars." I create different articles, one of which is "Ferrari 456", and another one is "Volkswagen Golf." I want a vocabulary called "cars" with a term for each article (e.g., one for "Ferrari 456", one for "Volkswagen Golf").


texts:
Now apachesolr search works only in content. It also have to work on other fields
for eg: on typing "test", It searches only in content.

My requirement is  to search on description,label also (which i have already indexed).
content:abcd OR description:sample_upload_document
Using  apachesolr.api.php,I tried hook_apachesolr_query_prepare($query)

function MYMODULE_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {

     $query->addParam('qf','content description');
     watchdog('solr result',print_r($query,true));

}

refering to the sitehttp://knackforge.com/blog/selvam/drupal-7-filtering-solr-results.
After performing that, i found description is added to

SolrBaseQuery Object
    (
        [params:protected] => Array
            (
                 [qf] => Array
                    (
                        [0] => content^40
                        [1] => description
                    )

But still when i give the value for description, search results would not yield any value.

Am i correct in a way? why doesnt it return the result?

How to do that? default search,searches the given text only in content.How to make it to search on other fields like description,label?


texts: I have a dashboard with about seven views that are each very expensive. Most of the views can be computed hourly, but I would prefer cron to run them rather than the unfortunate user. How can I have cron refresh the views cache and never a user?


texts:
I need to move a legacy Drupal 7 site to our new Aegir hosting environment. Unfortunately, the file structure is "non standard". I need to move drupal/materials to drupal/sites/default/files/materials but also need a corresponding path rewrite or redirect .htaccess or http.config is not an option, I need to do it in Drupal.

Redirect module does not do tokens or wild cards. Match_redirect module does not rewrite, but matches on a many to one bases. A rewrite would be better than a redirect.

I cant seem to find an existing contrib - how would I do this in PHP with the Drupal APIs? Would I want to use hook_boot or hook_init?


texts: How do I in Drupal 7 hook into the status message update area after saving a node and it says "updated node" to be a link to that node

texts:
In Drupal 7, after saving a node it redirects you back to the page of the node with the message status saying "blog 'title of blog' has been updated".

How do I turn that status message into the link of that node? I need to do this since I have rules setup where I have it redirect to another part of my site, and it just shows the status message of that node being updated. I just need that clickable. im assuming it would be a hook somewhere hook node save?


texts:
I'm looking to use the Paragraphs Drupal 8 module with a decoupled installation of Drupal 8 but would like the structure made in the admin area to be output in the JSON API responses.

How can I modify the JSON API responses from Drupal 8 to include this page structure data?

If anyone wants to know, having it decoupled & outputting structure information is a requirement I've been given.


texts: When adding a node, the site images do not show

texts:
I have some image links that are inside standard  tags, that link to some external sites. Example:

The images display no problem, until I go to add a node of my custom content type "Front Page Announcement". Then, the images do not display - i.e. the path to the image cannot be found.

I URL I get is: http://localhost/bedsastro_new/node/add/front-page-announcement
And the images are in assets/site-images/

When I look at at where the browser is expecting the image to be, it's :
http://localhost/bedsastro_new/node/add/front-page-annoucement/assets/site-images/pic.jpg

How do I ensure that Drupal is looking at right location for the images (i.e. http://localhost/bedsastro_new/assets/site-images/pic.jpg) ?

Thanks!
Daz


texts: How do I programmatically close a simple_dialog window

texts:
I'm in D7

I open a simple dialog window with the simple dialog module, and i want to close the dialog programmatically.

I've tried this

// not working !
jQuery('#simple-dialog-container').dialog('close');

and this

jQuery(document).find('div.ui-dialog').remove();
jQuery(document).find('div.ui-widget-overlay').remove();
//This seems to work because the window disappears, but I can not open it again.

The X icon on the top-right do this proprely, but i can't catch the action

Thank you for help


texts:
I want to append the name of a directory, say 'abc' to public:// uri of sites/default/files directory, such that it will point to the 'abc' directory inside sites/default/files.

Actually, whenever I try to do this file_move($file_object, 'public://abc', FILE_EXISTS_REPLACE) it moves the file inside sites/default/files and creates a file called 'abc'.

I want to move the file inside 'abc' directory, by appending 'abc' to public://, how do I do this?

I have searched for this and found that public://abc does the trick, but its not working for me.


texts: No content but empty row outputted by view

texts:
I have a view as follows:

Display: Master
Format: Unformatted list
Fields: Content: Images
Filter criteria: Content type, published
Contextual filter: Content: Nid with 'Provide default value' set to 'Content ID from URL'

The view is placed on the node using Panels and Panalizer modules.

The node in question had no images uploaded to the image field but the view is outputting an empty row as follows:

I have checked and unchecked the 'Count the number 0 as empty' and ' Hide if empty' on the 'Content: Images' field but the view still shows.

How can I hide the view (by removing this empty row) if there are no images on a node?

Happy to attach any additional information you require to this post. Thanks.


texts: Services module: What is 'Index' operation?

texts:
D7 / Services 3.2

retrieve / create / update / delete are very straightforward, make senses to me that matching 'CRUD', I don't understand what 'index' here does?

Thanks.


texts: Editing canonical links without a module, contained in $head?

texts:
I've not been using Drupal for long (< 3 weeks) but have good knowledge of standard PHP, so I really don't know the 'Drupal' way of doing things yet.

What I'm trying to do is edit the canonical tag for a mobile site. The current path is realtive, however I need it to be absolute, and link to the desktop version of the site.

As far as I can tell the current implementation is not using any module to insert the canonical tag.

By looking at the source code of the rendered page the code appears to be contained in the $head variable which is in html.tpl.php as below

<head profile="<?php print $grddl_profile; ?>">
<?php print $head; ?>
<title><?php print $variables['field_meta_title']; ?></title>

I've come across a couple of pages like this one that mention things like template_process_html, drupal_get_html_head() and hook_html_head_alter() as relevant functions, but in that example the request is to remove the canonical tags, not to edit them.

I wouldn't mind using a module (providing it would allow me to change the link from www.mysite.com... to m.mysite.com...) but I would need to remove the current canonical tags which comes back to my orignial issue of not being able to find where it is.


texts: I have created a custom module with page URL like $items['testpage/get']. How can I create a separate page.tpl file for this URL? Link is like: http://199.x.x.x/mysitename/testpage/get.


texts: Add allowed file extensions in Views Send file field

texts:
Using the Views Send module to send mass email.
On the email creation page I want to set my custom validation extensions for the file field provided by Views Send in combination with MimeMail (r# 267 in views_send.module).

For the file field I am trying to set the only allowed extension to be of type .docx by using the following function:

function my_module_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == "views_form_views_send_page") {
    if ($form_state['step'] == 'views_send_config_form') {

      $form['mail']['views_send_attachments'] = array(
        '#type' => 'file',
        '#title' => t('Attachment'),
        '#upload_validators' => array(
          'file_validate_extensions' => array('docx'),
        ),
     );
  }
}

Unfortuanetely this is not working. What am I doing wrong here?


texts: Is there anywhere a good writeup on Drupal directory structure?

texts: I wonder if there is a good writeup on Drupal directory structure?


texts: Allow two widgets for a taxonomy term reference field (hierarchical select dropdown and autocomplete)?

texts:
This may be impossible, but here's my situation.  I have a taxonomy called Hobbies which includes a rather large number of terms (300) in a hierarchy.

In their profiles, users have a term reference field so that they can list their hobbies.

Right now, I'm using the Hierarchical Select module, which displays the hierarchy cleanly and is great for browsing.

However, users often have trouble finding the term they are looking for because it is not under the parent term that they expect.  So, I would like to have an autocomplete option as well.

Is there some way in Drupal 7 to provide users with both a way to browse (like in Hierarchical Select) and to do direct input (like the core autocomplete)?

I am fairly certain there is no way to put two widgets on the same page, but is there some way to provide a second widget via an alternate interface?


texts:
I'm building a student application on which we have the requirement that student can pay its fees via instalment.I have googled around the same but I does not found how to achieve it.Does there any existing module for to achieve the similar functionality.If you have any ideas then do let me know how to achieve this.
The instalment payment will be charged only in two instalments(first instalment and second instalment).The amount of the first instalment can be vary from second instalment.


texts: How to override page.tpl.php with view's template file

texts:
I am using D7 and view3 (beta). I created a view named employee with a template for the field first_image, views-view-field--employee--page--field-first_image.tpl.php. When I rescan the theme information, this template became bold. It worked fine (When clicking the image, a slim box will show).

But I inserted this view in a basic page using insert view2.x dev module with tag [view:employee]. But this time my template file doesn't show and seems to be broken. How can I solve this?


texts:
i am new to drupal and trying to migrate same pages to drupal. I am able to create one node via druapals API, but when trying to create more nodes in a loop it doesn't work...

This is the working code:

    define('DRUPAL_ROOT','/var/www');
    require '/var/www/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

    #construct the new node object
    $node = new stdClass();

    #specify node properties
    $node->uid = 1;
    $node->title = "new node";
    $node->log ="";
    $node->status = 1;
    $node->comment = 1;
    $node->promote = 0;
    $node->sticky = 0;
    $node->type = 'veranstaltung';
    $node->language = 'und';
    $node->created = time();
    $node->changed = $node->created;
    $node->tnid=0;
    $node->translate=0;
    $node->body['und'][0]['value']="
content
";
    $node->body['und'][0]['format']="filtered_html";
    $node->body['und'][0]['safe_value']="
content
";

    #save node
    node_save($node)

If i put this in a for-loop and change the body and title each iteration it doesn't work.. The code is inside an external php script. Even copy the code and paste behind it again with other body and title does not work.

Thanks a lot


texts: Why can't I change values in my cookies?

texts:
I'm storing my users city in a cookie.

I want that cookie to expire by browser session, so I don't want to store this information in $_SESSION, because I want $_SESSION to persist for the default 23ish days.

So I'd like to stick with Drupal storing all of its stuff in $_SESSION as normal, but also set a cookie with a custom lifetime. When the user selects a city I set a cookie in my forms _form_submit() hook:

$c = 'Washington'; // ...or whatever
$_COOKIE['city']['cityname'] = $c;
setcookie('city[cityname]', $_COOKIE['city']['cityname'], 0);

If I print this out with print_r($_COOKIE['city']) I get:

Array ( [cityname] => Washington [state] => 65 )

Yay, it works!

Then the user selects a new city and the same code runs again (I know it's running because I've tried inserting a die; in there):

$c = 'New York';
$_COOKIE['city']['cityname'] = $c;
setcookie('city[cityname]', $_COOKIE['city']['cityname'], 0);

I print the $COOKIE value out again and get:

Array ( [cityname] => Washington [state] => 65 )

So the value hasn't changed and I'm left with the previous city. Why aren't my cookies values changing? Is there a way I can fix this, or a recommended workaround available?


texts: how to output custom image field (uri) from a Group entity on page.tpl.php?

texts:
I have a custom image field associated with a "group" entity(Created by the Group Module) that is called field_header_image. Im looking to output the image uri as background style in the page.tpl.php template. To achieve a "Full Screen" effect, I need to get to the outside of the div containers which puts me into page.tpl.php. I simply need to print the url or uri for the image called field_header_image.

I used to use something like this but since Groups are not nodes, Im wondering how to access these fields?? the code below was in my old theme template using Organic Groups so the header image was a field in a node. easy to access!

<?php print file_create_url($node->field_header_image[LANGUAGE_NONE][0]['uri']); ?>

But that code throws an error now. Id like to be able to insert a similar php statement into my page.tpl.php template that references the entity_type of 'group' instead of 'node'.
From the devel module output in Krumo, I can see that the object is located here:

$...['content']['system_main']['group'][1]['field_header_image'][0]['#item']['uri']

I wish I could figure out how to turn that into a php statement but the problem with that output from Krumo is I need it to work for any group page and pull that pages content, it looks like this location would pull that specific groups header image(group 1)


texts: How to hide Input Format Options and help text under a textarea?

texts: How to hide Input Format Options and help text under a textarea when adding|editing a node?


texts: Is there a way to insert "0000-00-00 00:00:00" in a datetime database field?

texts:
Is there a way to insert "0000-00-00 00:00:00" datetime database field?
Should I change the database field's default value to "0000-00-00 00:00:00"?

I got replies on Stack Overflow, and it works with plain PHP, but it gives an error with Drupal.


texts: 'Failed to get available update data" behind a proxy

texts:
I am running Drupal 8.1.2 behind proxy in Ubuntu 16.04. There is an error:

Failed to get available update data for one project.

even the following is added in settings.ini:

$settings['http_client_config']['proxy']['http'] = '192.168.1.8:3128';
$settings['http_client_config']['proxy']['https'] = '192.168.1.8:3128';
$settings['http_client_config']['proxy']['no'] = ['127.0.0.1', 'localhost'];

I tried both 192.168.1.8:3128 and http://192.168.1.8:3128/ and neither works.

Both http_proxy and https_proxy work well in bash though.

How can I fix the error?

Update, with screenshot:


texts: How to set an ALL option on contextual filters passed to a view with twig tweak?

texts:
In Drupal 8, I have a twig tweak embedded view that passes variables from the Layout Builder dialogue to filter results in a custom block.
{% set event_type = block.field_filtered_events_event_type.value %}
...
{{ drupal_view('events_group_content', 'filtered_events', event_type, center_id, cat) }}

The filters all work great except I need an option for ALL results if the user doesn't select anything from the filter. I have the “Display all results for the specified field” checked under "When the value is NOT available", but it does nothing. If I try to insert the block without making any selections, it posts and empty block.
Is there a way to add an ALL option as the default values passed into the view?
Adding my attempt to unset if not selected -
<div>
  {{ title_prefix }}
  {{ title }}
  {{ title_suffix }}
  {% if block.field_filtered_events_event_type.value|render is not empty %}
    {% set event_type = block.field_filtered_events_event_type.value %}
  {% else %}
    {% set event_type = 'all' %}
  {% endif %}
  {% if block.field_filtered_events_center_id.target_id|render is not null %}
    {% set center_id = block.field_filtered_events_center_id.target_id %}
  {% endif %}
  {% if block.field_filtered_events_samhsa.target_id|render is not null %}
    {% set samhsa = block.field_filtered_events_samhsa.target_id %}
  {% endif %}
  {% set upcoming = block.field_filtered_events_upcoming.value %}
  {% set qty = block.field_filtered_events_qty.value %}
  {% if upcoming == 1 %}
    {{ drupal_view('events_group_content', 'filtered_events', event_type, center_id, samhsa) }}
  {% else %}
    {{ drupal_view('events_group_content', 'filtered_events_past', event_type, center_id, samhsa) }}
  {% endif %}
</div>


texts: D7 bug with db_select, 'addExpression' and 'having' conditions?

texts:
As I asked in the drupal forum http://drupal.org/node/1393748 (no answers..)
I have an issue with a db_select query.

It seems that addExpression "GROUP_CONCAT" and "HAVING" is causing an issue.

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ATTO' in 'having clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS ...

<?php
$query = db_select("adm_f", "f");
    $query->fields("f", array("F_ID", "F_TIT", "F_TITOR", "F_DES", "F_ANN", "F_PAE", "F_REG", "F_IMG"));
    $query->addExpression("GROUP_CONCAT(t.TAG_DESC separator ', ')", 'ATTO');
    $query->leftJoin('adm_a', 'a', 'a.F_ID = f.F_ID');
    $query->leftJoin('adm_t', 't', 'a.TAG_ID = t.TAG_ID');
    $query->condition('t.TAG_TIP', 'code', '=');
    // other conditions..
    $query->groupBy('f.F_ID');
    $query->groupBy('f.F_TIT');
    $query->groupBy('f.F_TITOR');
    $query->groupBy('f.F_DESC');
    $query->groupBy('f.F_ANN');
    $query->groupBy('f.F_PAE');
    $query->groupBy('f.F_REG');
    $query->groupBy('f.F_IMG');

    // BUG ???
    if(trim($_GET['F_ATTO']) != '')
        $query->havingCondition('ATTO', '%'.trim($_GET['F_ATTO']).'%', 'LIKE');

$query = $query->extend('PagerDefault')->limit(10);
    // echo($query->__toString()); exit;
    // execute
    $rs = $query->execute();
?>

I solved the problem with a workaround, but I would like to use HAVING and not a second query...

Many thanks for your help!!


texts: 'Create Node' form as part of panelized page

texts:
How can I add 'create node' to a panelized page?
I basically want to have the 'create x CT' form at the top, with a view of submitted nodes below.  What's the best way to achieve this with panels?  thanks


texts:
Is there a way to force a batch process to stop if some kind of error occurs?  In particular, I have a batch that starts with saving a record to a database. Each subsequent batch operation depends on the database insert working correctly.  I'd like to force the batch to stop if the first batch fails.

The batch is called like this

$batch = array(
    'operations' => $operations,
    'finished' => 'mymodule_batch_finished',
    'title' => t('Merging records'),
    'init_message' => t('Starting processing'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Processing has encountered an error'),
    'file' => drupal_get_path('module', 'mymodule') . '/forms/mymodule.inc'
);

where $operations is the array of functions to call.

Each function uses PDO to update the database.  I'm trying to figure out how to stop the subsequent $operations from being called if the query in the current operation fails.

try {
  $sth = $dbh->prepare($sql);
  $sth->bindParam(':newid',$new_id,PDO::PARAM_INT);
  $sth->bindParam(':id',$id,PDO::PARAM_INT);
  if($sth->execute()) {
    $context['results']['[] = $sth->rowCount();
  }
  else {
    // TODO: stop processing due to an error
  }
}
catch(PDOException $e) {
  // TODO: stop processing due to an error
}

If an error occurs, I want to bypass the remaining operations and go straight to mymodule_batch_finished


texts: What is the memcache report screen telling me?

texts:
I'm experimenting with memcache and installed it via these instructions on a dev box. I think I have it working.

The config file is mostly left at default:

# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

My Question: What am I looking at here? How do I know how "effective" this set up might be? For example, when the sets row says "0.14/s; 773 sets (29.97%) of 2,579 commands", does that mean 29.97% of insert/updates where cached?

I'm having difficulty reading this report.


texts: Defining and manipulating help text for a path

texts:
Ok, this is a very basic question. If I create a 'page' in drupal using 'add content'. Does this new page (and the path defined for it, say, through 'pathauto') automatically get registered with a callback as a menu item so I can reference it's path in a custom module somehow?

For example, I tried the following code. Case #1 doesn't show anything on that page (a page created the typical way through the admin UI). The second case displays the help text correctly when I go to admin > modules > mymodule and click the 'help' link.

So what's going on here?

function mymodule_help($path, $arg) {
  switch ($path) {
    case 'services/software-training/webinars':
      // Help text for the simple page registered for this path.
      return t('This is help text for the simple page.');

    case 'admin/help#testmodule':
      // Help text for the admin section, using the module name in the path.
      return t("This is help text created in the page example's second case.");
  }
}


texts: Is there any way to open the core overlay window with a Custom URL using JavaScript?


texts: Create a cron job to automatically clear cache

texts:
I'm trying to clear cache automatically with a cron job but it didn't work.
I'm debugging simply on the browser at this link website-url/cronjob.php.
I think it's a problem with the syntax, I have tried to truncate the tables from database.

As you can see in the code attached below, I've tried two methods, but neither one works.

\Drupal::database()->truncate('cache_config')->execute();
mysql_query('TRUNCATE TABLE yqxq_cache_config');
mysql_query('TRUNCATE TABLE yqxq_cache_container');
mysql_query('TRUNCATE TABLE yqxq_cache_data');
mysql_query('TRUNCATE TABLE yqxq_cache_default');
mysql_query('TRUNCATE TABLE yqxq_cache_discovery');
mysql_query('TRUNCATE TABLE yqxq_cache_dynamic_page_cache');
mysql_query('TRUNCATE TABLE yqxq_cache_entity');
mysql_query('TRUNCATE TABLE yqxq_cache_menu');
mysql_query('TRUNCATE TABLE yqxq_cache_render');
mysql_query('TRUNCATE TABLE yqxq_cache_toolbar');
?>

What do I need to change to make this script work?

This is an example of query from the statistics view, which doesn't update if I don't run clear cache.

<?php
$count_users_tot = db_query('SELECT COUNT(uid) FROM {users}')->fetchField();
print $count_users_tot;
?>


texts: When a node is created, automatically update data in a corresponding node

texts:
Background (simplified)
We're collecting data for a study in which participants come in on several occasions to have health measures taken. We have two custom node types: Participant stores background data about a person, and Visit stores information from a single visit (e.g., their blood pressure that day). Each Visit is related to one Participant via a field created by the Node References module.
On each visit, a participant might qualify for a one-time reward. Visit nodes have a reward_visit field indicating whether the participant earned a reward on this visit, and Participant nodes have a reward_ever field indicating whether the participant has ever received a reward.
Question
I'd like to set up the following behavior: If a Visit node is created where reward_visit was set to Yes, also set reward_ever to Yes in the corresponding Participant node.
Is there a way to make this happen automatically, using Node References or some other relations module? I could custom-code it using hook_node_insert() or something, but I'd like to know if there's already an accepted way.


texts: Setting a Warning message in the Page.tpl.php file

texts:
I'm trying to set a warning message based on a PHP if statement in my page.tpl.php file. I can get a message out using $messages but I cannot using drupal_set_message(). Should I be using the latter before page.tpl.php?

The problem is the $messages variable comes out as plain text, I'd like to use Drupal's message system if possible:

drupal_set_message(t('Don\'t panic!'), 'warning');
$messages = t('Don\'t panic!');


texts:
I have a view which overrides the default taxonomy page. The view has a contextual filter which look for the tid in the URL.

My goal is to get the taxonomy term to display as the title of the page.

I tried setting the view's title to "Department: [field_dept]" (the field which references the taxonomy term and is loaded in the view). This work great, [field_dept] is replaced with the taxonomy term as expected.

There is an exception though. When the view has no results, there is no [field_dept] to look up and my page title looks like this "Department: [field_dept]" :-/

Now I'm trying to figure out how to get the taxonomy term from the tid, which is in the URL and available in my view.

Is there a function available in views that will return the term from a tid? Something like get_term_from_tid(%1), so I can use it in the title of the view or via title override in the contextual filter?

Drupal 7.14

Views 7.x-3.3


texts: DrupalGap response is HTML instead of JSON

texts:
I want to build a restful service to communicate with my Android app.

System: Drupal Commons with Drupal 6
Module for restful service: DrupalGap
Test tool: Poster plugin for Firefox

I do everything like in the tutorial from Tyler, but I got my login screen as HTML, instead of correct login; I can't get the system connect states as anonymous user. If I am already logged in so the login functionality says "you alread logged in" and the system connect state shows correct data.
The Views module has a setting to enable "Views API Mode" to wrap JSON in HTML, but this setting is disabled and so this can't be problem.

Does anybody know a solution for my problem?

If I follow the installation instructions for DrupalGap on a fresh Drupal 6 site, everything works out of the box. I can also access the DrupalGap demo site.


texts: How do I insert the node ID into a link field?

texts:
Building a site with content types Business, Product, and Review. Currently when users click a business name, they are taken to the Full Content view for that Business (e.g. sitename.com/business/[business name] since we are using PathAuto).

Created a custom View called Profile (sitename.com/profile) with a contextual filter that shows a selected Business as a rendered entity followed by two view attachments that show their Products and Customer Reviews.

We can manually type sitename.com/profile/6 into a browser and see a business with the attachments for products and reviews, but we are having trouble getting users there.

Tried adding a new field to Business with a default value and tokens to generate a URL to the business' profile view (e.g. Link with a default value of "/profile/[node:id]"). This field would be hidden on the input form for Business but displayed on the Full Content view.

We have not been able to get this working and do not know a better way to approach the challenge. If it is possible to get the Products and Reviews to display on the Business content page without using the Profile view (e.g. User clicks a Business name and sees their profile with products and reviews underneath), that would also meet the requirement.

Would prefer to do this without custom coding if possible, but acceptable if it is the only or best way. Happy to answer questions for clarification or provide links to the site (still in beta) if it would help.


texts: PDOException: SQLSTATE[42S22] When adding quiz content

texts:
I am trying to implement the quiz module on a new website and it's throwing the following error when attempting to add content > quiz. I believe the code I have was part of a feature I was trying to migrate over from a different website so I could retain the functionality involved with it, but it's proven to be less than compatible. (Going from Drupal Commons 7.50 to Plain Drupal with a demo theme built in 7.54).

Can someone interpret this error and point me in the right direction as to what the missing piece of the puzzle is here?

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.allow_change_blank' in 'field list': SELECT base.qnp_id
  AS qnp_id,  base.vid
      AS vid, base.nid AS nid, base.uid AS uid, base.number_of_random_questions AS
      number_of_random_questions, base.max_score_for_random AS max_score_for_random,
      base.pass_rate AS pass_rate, base.summary_pass AS summary_pass,
      base.summary_pass_format AS summary_pass_format, base.summary_default AS
      summary_default, base.summary_default_format AS summary_default_format,
      base.randomization AS randomization, base.backwards_navigation AS
      backwards_navigation, base.keep_results AS keep_results, base.repeat_until_correct
      AS repeat_until_correct, base.quiz_open AS quiz_open, base.quiz_close AS
      quiz_close, base.takes AS takes, base.show_attempt_stats AS show_attempt_stats,
      base.time_limit AS time_limit, base.quiz_always AS quiz_always, base.time_left AS
      time_left, base.max_score AS max_score, base.allow_skipping AS allow_skipping,
      base.allow_resume AS allow_resume, base.allow_jumping AS allow_jumping,
      base.allow_change AS allow_change, base.allow_change_blank AS allow_change_blank,
      base.build_on_last AS build_on_last, base.show_passed AS show_passed,
      base.mark_doubtful AS mark_doubtful, base.review_options AS review_options,
      base.result_type AS result_type FROM {quiz_node_properties} base WHERE (base.vid
      IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 351 )
      in EntityAPIController->query() (line 187 of
      /Applications/AMPPS/www/example/docroot/profiles/cms/modules/contrib/entity/inc
      ludes/entity.controller.inc).

Here is how the process went:

I implemented an online training feature from our current website for the new one
It included syllabus and quiz content types, neither of which worked until I installed the Title module
Once Title was installed, I received a new error only when trying to create content type quiz:

  EntityFieldQueryException: Unknown field: title_field in
  EntityFieldQuery->fieldOrderBy() (line 954 of
  /var/www/html/example/docroot/includes/entity.inc).

I updated the quiz from 7.x-5.0-alpha4+77-dev to 7.x-5.1 and all seemed well
I removed a quiz field field_syllabus_ref and recreated it a different way, to reference the title of the syllabus page in the quiz.
Now I get the error below unless the module is uninstalled. When it is uninstalled, I am still able to add quiz content but I get a different error instead after saving it.


texts: External login should set custom properties in user object

texts:
I have a Drupal website and a Symfony based API. I have configured Drupal to use my API for logging in. The users are stored in Symfony.

When logging in, Drupal will store a user in the database to create a user object. On this user object, I want to set some custom properties. For example an id which is a reference back to my Symfony user so that I can load the users settings, etc. later on.

I have not managed to figure out how to do this. I hope someone has an example on how to do this or can point me in the right direction.

Below is the code I use for logging the user in. First I check if the entered username matches an administrator that Drupal knows of. If it does, I will use the default Drupal login validation. If not, I will login through the API.

/**
 *  Validates the login. Uses either the default Drupal validation or a custom validation.
 */
function myy_authenticate_validate($form, &$form_state)
{
    // Retrieve name and password.
    $name = $form_state["values"]["name"];
    $pass = $form_state["values"]["pass"];

    // Check if the user exists in the Drupal users
    if ($user = db_query("SELECT * FROM {users} u WHERE name = :name", array(':name' => $name))->fetch())
    {
        // A user exists. Loads the user information.
        $user = user_load($user->uid);

        // If the user is an administator, log him in using the Drupal validator.
        if (in_array("administrator", $user->roles))
            return user_login_authenticate_validate($form, $form_state);
    }

    // The user didn't exist in the Drupal users. Now, try to authenciate using the custom validation.
    $authenticated = myy_symfony_auth($name, $pass);

    // Check if we did authenciate
    if ($authenticated)
    {
        // This sets up the external user with Drupal by creating a local entry. If they don't exist they are added.
        user_external_login_register($name, "myy");

        // We must set the "uid" to pass back. This looks up the logged in user and sets the Drupal UID.
        $user = user_external_load($name, $pass);
        $form_state["uid"] = $user->uid;
    }
    else
    {
        // Do nothing. Drupal will handle the errors.
    }
}

myy_symfony_auth is a method which returns whether or not we were able to login using the API.

Does anyone have an idea how I can add custom properties to the user object when a login succeeds? It is only relevant to do this when the login was performed using the API (meaning that it was not an administrator who logged in).


texts: Modify form (add select option) by another form in Modal

texts:
I wonder if Drupal can add an additional segment of data in a form on the fly using another form via Modal.
I have this form in a table.
City             | Description      | Active
New york         | abc              | checked
Chicago          | efg              | checked
-- Select city-- | -- input text -- | -- checkbox --

[button Add new city ] // This is a button to add new city to select options

I cannot call up a separate form and overwrite the values via JavaScript because sending the data causes an Incorrect City selection error. I need to rebuild the form options.
I usually do this by adding an AJAX callback to the button and overwriting the form configuration in the callback function. It makes sense with small data segments, but when there are 10 fields in each row, I would like to construct a separate form that adds options and updates the form state (available options to choose from), because for many, many changes form has been big structure of code.
Is there a way to do that?


texts: Change max length of title in a custom block added via a template file

texts:
A drupal 7 website has a custom block added via a template file. The block displays previews of article content type belonging to a certain rubric. It uses the following line to do so:
$block = module_invoke('views', 'block_view', 'given-block-name'); echo render($block['content']);

The articles displayed have their titles truncated at the length of 50 characters. I could not find the number 50 in the files on the hosting, so it should be somewhere in the database, and so somehow changeable via the admin panel. Yet I am having a very hard time finding where to change this number. I have changed the length of the teaser for the article content, but that apparently bears no influence on what is displayed in the given block.


texts: How to create HTML Tooltips using the Charts module's API with Google Charts?

texts:
I'm using the Charts module and I've been trying to set up a simple pie chart that has HTML in the tooltips.  We would like the HTML to be menu links, but they can just be manually coded into the chart code.  However, I have not been able to get this working.  Looking at the API (http://cgit.drupalcode.org/charts/tree/charts.module#n46) it seems there is an option to set: '#tooltips_use_html' => TRUE

But I haven't been able to get it to work.  I've tried the following code in the body of a node:

$chart = array(
    '#type' => 'chart',
    '#title' => t('Pie Chart with tooltips (no data labels)'),
    '#chart_type' => 'pie',
    '#chart_library' => 'google', // Allowed values: 'google' or 'highcharts'
    '#legend_position' => 'right',
    '#data_labels' => FALSE,
     '#tooltips' => TRUE,
     '#tooltips_use_html' => TRUE
  );
  $chart['pie_data'] = array(
    '#type' => 'chart_data',
    '#title' => t('Gender'),
    '#labels' => array('Male', 'Female'),
    '#data' => array(10, 20),
  );

/*
$chart['pie_data_item'] = array(
    '#data' => 10,
    '#color' => 'NULL',
    '#title' =>'Male',
  );

$chart['pie_data_item'] = array(
    '#data' => 20,
    '#color' => 'NULL',
    '#title' =>'Female',
  );
*/

  $example['chart'] = $chart;

In place of $chart['pie_data'] I've also tried the commented out code $chart['pie_data_item'].  With the first approach I do get a result, but the HTML is not rendered correctly, and labels are being treated as the tooltips?  Is there anyway to tell what HTML goes into each tooltip?

EDIT: Using the patch in https://www.drupal.org/files/issues/2209467-9--raw_options.patch as recommended by Pierre.Vriens I was able to enable the #raw_options array.  I've looked around and haven't found any clear documentation what that array is supposed to look like though.  How would I use #raw_options to generate HTML tooltips?


texts:
I want to create a view with specific nodes. How can I tell views specific node ID's in a list to display?

So for example, I want an unformatted list with node id's 33, 30, and 15.

I tried using the Filter Criteria: Content:NodeID. The problem is that it only allows for numeric value evaluation. It works when i specify using ONE node id. If I add another, it doesn't display anything. If I add another filter using Content:NodeID and specify another node. It also doesn't do anything.

It allows for a regex, but I'm not sure that even with a regex it would allow me to drop in a list of NID's.


texts: Disable Commerce Card on File for Donation Product Type

texts:
Using Commerce (7.x-1.1), Commerce Card on File (7.x-2.0-beta5), Commerce Recurring Framework (7.x-2.x-dev) and Commerce Donate (7.x-1.0)

I need Commerce Card on File for my recurring product entities, however I do not want the functionality applied to Donation Products.

How do I keep the Commerce Card on File functionality for recurring products, but disable it for donation products?