texts: Drupal Form Ajax not updating form on first click

texts:
function _ajax_ticket_info($form,&$form_state)
{
    $subscriber = $form['info']['ticket']['subscribe'];
    _ticket_subscribe($subscriber['#value'],$subscriber['#name']);

    // Dunno if this is needed or not
    $form_state['rebuild'] = TRUE;

    return $form;
}
function _ticket_info($form,&$form_state,$node) {

    $is_subscribed = _ticket_is_subscribed($node->nid);
    $subscriber_count = count(_ticketsys_get_subscribers($node));

    $form = [
        '#prefix' => "
",
        '#suffix' => '
',
    ];
    // other form fields here not that important
    // just focusing on my problem
    $form['info']['ticket']['subscribe'] = [
    '#type' => 'button',
    '#value' => $is_subscribed,
    '#name' => $node->nid,
    '#id' => 'ticket-subscribe',
    '#ajax' => [
        'callback' => '_ajax_ticket_info',
        'wrapper' => 'ticket-info-form',
        'effect' => 'fade',
    ],
];
return $form;
}

So the problem is i'm using that code to update my form without reloading the page and when i do that it only executes the replacement on the second time i clicked the button $form['info']['ticket']['subscribe'] and i notice using inspect element on chrome that the form id and other form fields have --2 on their ids and increasing every time i click the Subscribe button

Any ideas whats wrong here. I really need to fix this thanks


texts: Updating to Drupal 7.x-dev until next stable release

texts:
I am currently using Drupal core 7.7 and Commerce 7.x-1.0-rc3 which requires changes that are only currently present in Drupal core 7.x-dev.

If I upgrade to 7.x-dev now in order to get the updates that the latest Commerce version needs, am I committing my project to following dev branch, and is there a danger of not being able to come back to stable cleanly, when the next stable release comes about?

It's not a live site, so temporary instability a dev branch may introduce is not necessarily an issue if I'll end up back on stable soon.

EDIT: Additionally, instruction for how to upgrade core from stable to dev using Drush would be super: Drush: Update core from stable to dev  :)


texts: Attaching two or more jQuery files to a theme

texts:
I was trying to add some jQuery files to a theme (to do some simple css logics). I could add one jQuery file by defining as follows

In the custom theme folder I edited themes.libraries.yml and added the following

global-scripts:
  js:
    js/jqueryfile1.js: {}
  dependencies:
    - core/jquery

and then I wrote my jquery code within inside custom_theme_folder/js/jqueryfile1.js as

(function ($){
Drupal.behaviors.myModuleBehavior = {
    attach: function(context, settings) {
        $(document).ready(function(){

            //code goes here

            });
        });
    }
};
})(jQuery);

Everything was fine till now. But when I'm trying to add my next file(jqueryfile2.js) only the the latest (jqueryfile2.js) is taking in action. I can see the previous file is also called in the DOM while checking the source but the code is not executing. After adding my second jQuery my libraries.yml will look like

global-scripts:
  js:
    js/jqueryfile1.js: {}
    js/jqueryfile2.js: {}
  dependencies:
    - core/jquery

At this point jqueryfile2.js is only taking in action not the first file. And there will be both my jquery files within inside the js folder and is called to the document.


texts: I am using Corporate Clean theme and I want to make some changes to how the logo and site name are displayed. What file would do that in? Sorry, newbie here!


texts: Which is the preferred way to change field content before rendered?

texts:
I'm working on an existing Drupal 7 module in order to make it work with Drupal 8. And for a peculiar aspect of its operation I'm currently a bit lost.

Th problem is that I must be able to make some changes in content of any text field, everywhere throughout all contents, before they're rendered.

In Drupal 7 I solved it behaving as a formatter, which I "grafted" before any existing formatter.
You can look at this SO post (I didn't know Drupal Answers at this time) to see more precisely how it worked.

After reading a lot of Drupal 8 documentation (which is currently quite messy) I can't yet realize which is the preferred way to achieve what I want.
I noticed some candidates such as the hook_entity_view_alter(), but also services and/or plugins, but keep totally undecided.

So I look for some advices pointing me to the right way.


texts:
So I'm making quite a few nodes through a script, an action. To do this I'm using the form_state drupal_execute method.

However because there is a lot of processing per node in one batch I get lots of nodes with different time stamps.

Is there any way to manually edit the timestamps a part from going into the DB? I've tried this:
outside loop:

$time = time();

inside loop:

form_state['values'] = $time;

And give the same timestamp to all the nodes. But apparently druapl_execute gives them a new time stamp.

Thanks.

EDIT: Solved!
I ended up adding this line, it was the fastest solution I could think of.

db_query("UPDATE  {node} SET  created = %d WHERE  nid = %d", $time, $form_state['nid']);


texts:
I received these two error messages today.  Not sure where they came from or what I did to cause it.  Any suggestions on how I fix the problem and what caused it?

1 - warning: htmlspecialchars(): Invalid multibyte sequence in argument in /home1/XXX/public_html/includes/bootstrap.inc on line 856.

2 - user warning: in /home1/XXX/public_html/includes/cache.inc on line 108.


texts: Is there a module or way to edit all my product's categories from one admin menu?

texts: Currently I have to go to admin>store>products and then go to each product individually to change their category. This is tedious when you have hundreds of products and need to change many of their categories. For just changing the title/name of a category/term I can just edit the taxonomy term but Ive also added many new terms. So is there a module or a setting to allow this? I am using ubercart.


texts:
I am working with Facebok Graph API and I am using FQL queries to get to the data. I am handing those API calls through URLs. Drupal's default URL perceive them as invalid URLs maybe because they have a lot of special symbols like " ) + , [

How do I disable or override Drupal's URL validation for specified form?


texts: Primary Links Not Showing Up On Certain Themes

texts: In Drupal 7, I have a page in the Primary links menu. I set the page content type to use the primary links. In Garland I can see the item at the top of the page, but in a bunch of other themes I can't, like AT Adaptive, Fusion, and Sky. What gives? How do I get the primary links to show up in those themes?


texts:
Hello I'm working on a module,
I currently have an array with Node objects (custom content types),
I am passing this array to a custom template (twig) but I can not render it with the values of its fields.

For example:

The dump object of the data that is coming to the template

array:2 [▼
  0 => Node {#564 ▼
    +in_preview: null
    #values: array:24 [▶]
    #fields: array:2 [▶]
    #fieldDefinitions: array:32 [▶]
    #languages: null
    #langcodeKey: "langcode"
    #defaultLangcodeKey: "default_langcode"
    #activeLangcode: "x-default"
    #defaultLangcode: "es"
    #translations: array:1 [▶]
    #translationInitialize: false
    #newRevision: false
    #isDefaultRevision: "1"
    #entityKeys: array:4 [▶]
    #translatableEntityKeys: array:7 [▶]
    #validated: false
    #validationRequired: false
    #loadedRevisionId: "9"
    #revisionTranslationAffectedKey: "revision_translation_affected"
    #enforceRevisionTranslationAffected: []
    #entityTypeId: "node"
    #enforceIsNew: null
    #typedData: EntityAdapter {#1065 ▶}
    #cacheContexts: []
    #cacheTags: []
    #cacheMaxAge: -1
    #_serviceIds: []
  }
  1 => Node {#562 ▼
    +in_preview: null
    #values: array:24 [▶]
    #fields: array:2 [▶]
    #fieldDefinitions: array:32 [▶]
    #languages: null
    #langcodeKey: "langcode"
    #defaultLangcodeKey: "default_langcode"
    #activeLangcode: "x-default"
    #defaultLangcode: "es"
    #translations: array:1 [▶]
    #translationInitialize: false
    #newRevision: false
    #isDefaultRevision: "1"
    #entityKeys: array:4 [▶]
    #translatableEntityKeys: array:7 [▶]
    #validated: false
    #validationRequired: false
    #loadedRevisionId: "10"
    #revisionTranslationAffectedKey: "revision_translation_affected"
    #enforceRevisionTranslationAffected: []
    #entityTypeId: "node"
    #enforceIsNew: null
    #typedData: EntityAdapter {#1198 ▶}
    #cacheContexts: []
    #cacheTags: []
    #cacheMaxAge: -1
    #_serviceIds: []
  }
]

As you can see, the data is inside the key #values

#values: array:24 [▼
      "vid" => array:1 [▶]
      "langcode" => array:1 [▶]
      "revision_uid" => array:1 [▶]
      "revision_timestamp" => array:1 [▶]
      "revision_log" => array:1 [▶]
      "revision_default" => array:1 [▶]
      "nid" => array:1 [▶]
      "type" => array:1 [▶]
      "uuid" => array:1 [▶]
      "isDefaultRevision" => array:1 [▶]
      "status" => array:1 [▶]
      "title" => array:1 [▶]
      "uid" => array:1 [▶]
      "created" => array:1 [▶]
      "changed" => array:1 [▶]
      "promote" => array:1 [▶]
      "sticky" => array:1 [▶]
      "default_langcode" => array:1 [▶]
      "revision_translation_affected" => array:1 [▶]
      "field_custom_title" => array:1 [▶]

    ]

The twig template:

    {% for node in nodos %}

{{ node.field_custom_title}}
 #not work
    {% endfor %}

How do I get the values of the fields from twig?


texts: Show users a view of nodes tagged with the terms they flagged - Drupal 7

texts:
I want users to be able to create taxonomy terms and other users to be able to flag these taxonomy terms (using the flag module, sort of Follow). Then i want each user to have a view of nodes which have been tagged with those taxonomy terms they flagged. Is this currently possible with views contextual filters? Any alternative also welcome.

Example use case: i flagged terms Technology and Business created by admin or other users. When a user posts a node tagged with Technology or Business, i will see the post on my wall (My wall is an admin created view of all nodes tagged with the terms that i have flagged)


texts: A view is just an SQL query on a table - in the UI how can I find what table an existing view is based on?


texts: Can't get an access to jQuery in my scripts

texts:
Edited problem description
I develop a theme for the Drupal 8. I need to have an access to jQuery $ context in my scripts, so I attached it in libraries as it says in docs.

global-styling:
    version: VERSION
    css:
        theme:
            libs/bootstrap/css/bootstrap.min.css: {}
            css/layout.css: {}

    js:
        libs/bootstrap/js/bootstrap.min.js: {}
        libs/autohiding-navbar/jquery.bootstrap-autohidingnavbar.js: {}
        js/global.js: {}

    dependencies:
        - core/jquery

But in the Chrome console I get an error that jQuery context $ isn't available.


texts: Display price in add to cart form BEFORE add to cart button

texts:
the logical flow of choosing attributes is seeing price adjustments based on the attributes chosen before the buy button ... how can i display the price in the form itself so it appears BEFORE the add to cart button?

here is an example of what i am talking about ... you have attributes, then you have price calculations based on attributes selected and very last thing is the buy button ... this is logical and i can't figure it out.

i did try using jquery to append the price to a div inside the form .. but that is a mess. all sorts of problems with ajax etc and not the correct approach anyway.


texts: Drupal 8 Menu Tree issue in my contrib theme possibly because of "Convert menu tree building to a service."

texts:
Previously, in my Drupal 8 contrib theme, I was rendering the full menu tree as:

function gratis_preprocess_page(&$vars, $hook) {

// Build the main menu links tree.
  $vars['primary_nav'] = FALSE;
  if (!empty($vars['main_menu'])) {
  // Build links.
    $config = Drupal::config('menu.settings');
    $menu_enabled = Drupal::moduleHandler()->moduleExists('menu');
    // When menu module is not enabled, we need a hardcoded default values.
    $main_links_source = $menu_enabled ? $config->get('main_links') : 'main';
    $vars['main_menu'] = menu_tree($main_links_source);
    $vars['main_menu']['#theme_wrappers'] = array('menu_tree__primary');
    $vars['main_menu']['#attributes']['id'] = 'main-menu-links';
    $vars['main_menu']['#attributes']['class'] = array('links', 'clearfix');
  }
}

However, in testing the theme with the latest Drupal 8 dev, I am getting a WSOD with this specific error:

PHP Fatal error:  Call to undefined function menu_tree() in /themes/gratis/gratis.theme on line 93

Line 93 from the above is:

$vars['main_menu'] = menu_tree($main_links_source);

I did a little searching and discovered this core change: Convert menu tree building to a service. and its corresponding change notice.

I tried adjusting my code to:

$vars['main_menu']= \Drupal::service($main_links_source);

... but now I am getting this error:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "main". Did you mean one of these: "maintenance_mode_subscriber", "user_maintenance_mode_subscriber"? in Symfony\Component\DependencyInjection\Container->get() (line 303 of core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php).

So I am at a loss of how to fix this. You can see the repo for my .theme file here.

Cross referencing Render full menu tree in Drupal 8 version.

Update: [working code]

Here is the code in its fixed and working version thanks once again to @Clive

// Build the main menu links tree.
  if (!empty($vars['main_menu'])) {
  // Build links.
    $config = Drupal::config('menu.settings');
    $menu_enabled = Drupal::moduleHandler()->moduleExists('menu');
    // When menu module is not enabled, we need a hardcoded default values.
    $main_links_source = $menu_enabled ? $config->get('main_links') : 'main';
    $vars['main_menu'] = \Drupal::service('menu_link.tree')->renderMenu($main_links_source);
    $vars['main_menu']['#attributes']['id'] = 'main-menu-links';
    $vars['main_menu']['#attributes']['class'] = array('links', 'clearfix');
    $vars['main_menu']['#theme_wrappers'] = array('menu_tree__primary');
  }

and then we render the wrapper set above with menu_tree__primary

/**
 * Theme wrapper function for the primary menu links.
 */
function gratis_menu_tree__primary(&$vars) {
  return '
' . $vars['tree'] . '
';
}


texts: Pathauto does not Transliterate when creating a node programatically (works when manually creating)

texts:
Drupal 7

Here is my code:

<?php
$languages = language_list(); // get all languages
$preferedLang = "sv";
global $language;
$language = $languages[$preferedLang];

$node = new stdClass(); // Create a new node object
$node->type = $type; // Or page, or whatever content type you like

node_object_prepare($node); // Set some default values

$node->title = $title;
$node->language = $preferedLang; // Or e.g. 'en' if locale is enabled

$node->path['pathauto'] = TRUE;

.
.
.

node_save($node);

When the title is set to

  Jakt på vildsvin och dovhjort erbjuds i norra Östergötland

it should use Transliteration and produce this path:

  /jakt-pa-vildsvin-och-dovhjort-erbjuds-i-norra-ostergotland

Instead the following (incorrent, not transliterated path) is created

  /jakt-p-vildsvin-och-dovhjort-erbjuds-i-norra-stergotland

Note that "å" did not transliterate into "a" and "Ö" into "o".

Also note that if I create the node manually this works.

What I have done

Verified that I have checked "Transliterate prior to creating alias"

Verified that I have both English and Swedish languages enabled

I have tried setting:

  $path["language"] = 'sv'


texts: How to get field label from a field machine name

texts:
$fields = \Drupal\Core\Entity\EntityTypeManagerInterface->getStorage('field_storage_config')->loadMultiple();

This is listing me all the fields.

foreach ($fields as $key => $instance) {
   $label = $instance->getLabel();
   $name = $instance->getName();
}

$label is giving me node.field_image

$name is giving me field_image

My question is how can we get the label of the field in drupal 8


texts:
I am acutally trying to build a custom webform submit handler to force the form to be rebuilded. I know that this is possible with the integrated webform settings, but I need to do it programmatically.

Here is what my code looks like at the moment:

function he_helper_form_alter(&$form, &$form_state, $form_id) {
    dsm($form);
    dsm($form_state);
    dsm($form_id);

    if(strpos(current_path(), 'print') !== false && $form['#node']->type == 'genericforms') {
        $form['actions']['submit'] = array (
            '#type' => 'submit',
            '#value' => 'submit',
            '#submit' => 'he_helper_custom_redirect'
        );
    }
}

function he_helper_custom_redirect($form, &$form_state) {

    $form_state['rebuild'] = TRUE;

}

The problem now is, that the rebuild works as expected, but the form data does not get submitted. I tried it with $form_state['redirect'] as well, but ran into the same problem.

Anyone got an idea how to solve that?

UPDATE:

function he_helper_form_alter(&$form, &$form_state, $form_id) {
  // dsm($form);
  // dsm($form_state);
  // dsm($form_id);
  if(strpos(current_path(), 'print') !== false && $form['#node']->type == 'genericforms') {
    // $form['#after_build'][] = 'he_helper_after_build';
    $form['actions']['submit'] = array (
      '#type' => 'submit',
      '#value' => '2hello',
      '#submit' => array('_he_helper_custom_submit'),
    );
  }
}

function _he_helper_custom_submit(&$form, &$form_state) {
  $form_state['redirect'] = 'print';
  $form_state['rebuild'] = TRUE;
}

This is what my code now actualy looks like. The redirect now works fine, but the data wont get submitted. I tried the after_build function as well, but when i am using this, even my redirect wont work. This is what my code looked like with the after_build

function he_helper_form_alter(&$form, &$form_state, $form_id) {
  // dsm($form);
  // dsm($form_state);
  // dsm($form_id);
  if(strpos(current_path(), 'print') !== false && $form['#node']->type == 'genericforms') {
    $form['#after_build'][] = 'he_helper_after_build';
  }
}

function he_helper_after_build(&$form, &$form_state) {
  $form['actions']['submit'] = array (
    '#type' => 'submit',
    '#value' => '2hello',
    '#submit' => array('_he_helper_custom_submit'),
  );
  return $form;
}

function _he_helper_custom_submit(&$form, &$form_state) {
  print 'hello';
  dsm('hello');
  $form_state['redirect'] = 'print';
  $form_state['rebuild'] = TRUE;
}


texts: Why do I get a syntax error on this query?

texts:
I need some help with this query:

$result = db_query("SELECT
  UNIX_TIMESTAMP(FROM_UNIXTIME(s.timestamp, '%Y%m%d')) AS date,
  s.nid, COUNT(*) AS all_count,
  COUNT(DISTINCT s.ip_address) AS unique_count
FROM {simpleads_impressions} s
WHERE FROM_UNIXTIME(s.timestamp, '%Y-%m-%d') BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 SECOND
GROUP BY date, s.nid");

The main issue is the WHERE clause, and the count/group issue.

$query = \Drupal::database()
    ->select('simpleads_impressions', 's')
    ->fields('s', array('nid'));
$query->addExpression("UNIX_TIMESTAMP(FROM_UNIXTIME(timestamp, '%Y%m%d'))", 'date');
$query->addExpression('COUNT(*)', 'all_count');
$query->addExpression('COUNT(DISTINCT ip_address', 'unique_count');
$query->where("FROM_UNIXTIME(timestamp, '%Y-%m-%d') BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 SECOND");
$query->groupBy('date');
$query->groupBy('nid');
$result = $query->execute()->fetchObject();

This is the error message I get:

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS unique_count FROM simpleads_impressions s WHERE (FROM_UNIXTIME(timestamp, '' at line 1: SELECT s.nid AS nid, FROM_UNIXTIME(timestamp, '%Y-%m-%d') AS utime, DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS startdate, DATE_SUB(CURDATE(), INTERVAL 1 SECOND) AS enddate, UNIX_TIMESTAMP(FROM_UNIXTIME(timestamp, '%Y%m%d')) AS testdate, COUNT(*) AS all_count, COUNT(DISTINCT ip_address AS unique_count FROM {simpleads_impressions} s WHERE (FROM_UNIXTIME(timestamp, '%Y-%m-%d') BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 SECOND) GROUP BY date, nid; Array ( ) in simpleads_cron() (line 23 of D:\www\nla-refactor\modules\custom\simpleads\simpleads.module).

What code should I use to fix the error?


texts: commerce_cart_order_load not working for anonymous user in drupal commerce

texts:
I have created an order programmatically, the order is created and shown in backoffice order listing, but most of the time in the cart it shows empty.When I checked I found that commerce_cart_order_load for anonymous user return false.

Please help me to find the solution.

Here is the code on submit function i have written :

global $user;
$product_id = $form_state['input']['product_id'];
$quantity = $form_state['input']['quantity'];
$audience = $form_state['input']['audience_id'];
$material = $form_state['input']['material_id'];
if ($product = commerce_product_load($product_id)) {
  $threshold = $product->field_threshold_quantity['und'][0]['value'];
  if(is_numeric($threshold) && $threshold != ''){
    if($quantity >= $threshold){
      $box_code = $product->field_box_code['und'][0]['value'];
      $product->sku = $box_code ;
      $quantity = 1;
    }

  }
  if (!commerce_cart_order_session_exists())
   {
                $order = commerce_cart_order_new();
               $order->log = t("Created by checkout page.");
               commerce_cart_order_session_save($order->order_id);
     }
  // Attempt to load existing order for user from session
   $order = commerce_cart_order_load();
    if(!$order){
      $order = commerce_cart_order_new($user->uid);
    }

  // Save new order to get order id
  if(empty($order->order_id)){
    $order->revision = FALSE;
    commerce_order_save($order);
  }
  $order_id = $order->order_id;
  // Wrapper for easy field access and adding line items, order passed by reference
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  //uid of the logged in user
  $uid = $user->uid;
  $line_item = commerce_product_line_item_new($product, $quantity);
  $line_item->field_line_item_audience['und'][]['tid'] = $audience;
  $line_item->field_line_item_item_type['und'][]['tid'] = $material;
  $line_item_added = commerce_cart_product_add($uid, $line_item, FALSE);
  //$order_wrapper->commerce_line_items[] = $line_item;
  commerce_line_item_save($line_item);
  if($uid  == 0 ){
      commerce_cart_order_session_save($order_id);
  }
 //
  // Save new line item to get line item id

 // Add line item to order wrapper
//

  // Save order with new order number and line item added
  $order->revision = FALSE;
  $order_wrapper->save();


texts: How to check if filefield has a value or not by Rules

texts:
I have a cck file field "pic" users can attach up to 3 images to. I would like to set a Rule with the condition depending on whether user has uploaded at least one image or not.

I set the condition "Saved content's field 'field_pic' has value" + "negate"  But no matter the field has a value or not (a file has been attached or not) the debug says "Condition "Updated content's field 'field_pic' has value" evaluated to FALSE."

I also tried this code below but again always the condition is FALSE.

return array(
  0 => array('fid' => 0, ),
);

How can I set the condition to check if the cck file field has at least one file or not?


texts: How can I alter the contents of a form before they are submitted?

texts:
I'd like to do something like the following:

Let's say that I intended to allow users to input their Social Security Number, in the format 123-45-6789, which is a field in a "Person" content type. When saving to the DB though, I'd like to store this SSN as an integer. So, before the form gets saved, I want to remove the dashes. How can I do this? I can't find an appropriate hook that will allow me to alter the data BEFORE it is submitted. Adding a submit handler would not work, I believe, since this additional handler would trigger after the data is already saved.

EDIT: I'd now like to change this value before the individual element's #element_validate function is used. I tried changing the callback of this element's #element_validate function, but then the actual value isn't being changed before being submitted to the database, and I get an insertion error.

EDIT2: I'm attempting to use value_callback, but still having the same issue - either I'm using this incorrectly, or this is not firing before the element's validator. Either way, the result is that rather than attempting to insert "123456789" into the database, "123-45-6789" is attempted, and since this is an integer field, insertion fails.


texts: hook_menu() items created in a custom module don't retain the active-trail of the parent tab

texts:
So I have a custom module that is adding 3 menu items (a main tab, and 2 sub-tabs). When navigating to the main tab (url: /casereports) the default_local_task is displayed as expected and both menu items (Case Reports and Jobs Completed) are active as expected. Everything is working fine except that when I click on the second tab (Jobs Created), the main tab (Case Reports) loses it's active status.  I can't seem to figure out what I am missing here and why it is not picking up it's parent and the active-trail.  Any ideas?

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

  $items['casereports'] = array(
    'title' => t('Case Reports'),
    'page callback' =>'drupal_get_form',
    'page arguments' => array('casereports_completed'),
    'access arguments' => array('access content'),
    'menu_name' => 'features'
  );
  $items['casereports/default'] = array(
    'title' => t('Jobs Completed'),
    'type' => MENU_DEFAULT_LOCAL_TASK
  );
  $items['casereports/created'] = array(
    'title' => t('Jobs Created'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('casereports_created'),
    'access arguments' => array('access content'),
    'type' => MENU_LOCAL_TASK
  );
  return $items;
}


texts: Is there any way to edit the shipping address on an existing order? I only see the billing address in the edit screen.


texts:
I have a site where members (with different roles) can post projects.

My goal : To show to "recruiters" (role) a view of all the users who have flagged their nodes. In other words, the flag accessibility / visibility is dependant of the author's role and node type.

I need :

to show a flag to every user if the author of the node has the role "recruiter"
to let the "recruiter" unflag a user from his view of applicants.

I can't / I can:

I cannot figure out how to control the visibility / accessibility of the flag based on the author's role. I've checked a few modules, but did not find anything relevent yet.
I'm ok with Views: I guess I could make a second flag only for "recruiters" (available in the view) and set a double condition : if user has flagged node AND if "recruiter" has flagged the user in the list, then remove user from the view. By doing this, the user would not be able to flag again the node (job post) if the 'recruiter" has (un)flagged the user.

My hope : to be able to combine available modules (no coding).

I guess a custom module could look for a boolean field (checkbox) only available to some roles and show (or not) the flag. But I'm no coder unfortunately.

Let's start with available modules : is there anything that I missed?


texts: Should a module implementing a filter delete the Drupal variables it uses, when uninstalled?

texts:
I checked some modules implementing an input filter, and (if not in few occasions) I have never seen the modules removing the Drupal variables, whose names are in the format "module_name_$format," when they are uninstalled.

Since a module should normally delete its Drupal variables when it is uninstalled, is there a reason why an input filter module doesn't normally delete its own Drupal variables (e.g. this is already done by Drupal)?


texts:
I have a view block disply that contains a list of nodes.
i want to restrict Nid's by my url in one field in node.(Similarly, system block visibility)
for example i have a field with name field_visibility and save node by fill that gallery

so, my list in block is:

  view-row-1 => [nid]-1 => field_visibility ='gallery' view-row-2 =>
  [nid]-2 => field_visibility ='contact' view-row-3 => [nid]-3 =>
  field_visibility ='blog' . . .

so in page www.example.com/gallery, in block should be

1. [nid]-2
2. [nid]-3

and in page www.example.com/contact, in block should be

1. [nid]-1
2. [nid]-3


texts: Create custom meta tag with the metatag module

texts:
Just this. I need to create some metatag using the metatag module: https://www.drupal.org/project/metatag

Something like:

<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />

I can't see how to get this in its setting.

Then after I will need to use these metatags in nodes and views.


texts:
I am trying to select an Entity with a condition on the node id.
Here's the query I use:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'event')
    ->propertyCondition('status', NODE_PUBLISHED)
    ->fieldCondition('nid', 'value', $id, '=')
    ->range($page, 1);
$result = $query->execute();

I get the following error:

  EntityFieldQueryException: Unknown field: nid in EntityFieldQuery->addFieldCondition()

How can I resolve this issue?


texts:
I still have problems to access form fields programmatically, I want to prefill my textfield but it doesn't work:

function mymodule_form_webform_client_form_66_alter(&$form, &$form_state) {
    $form["submitted"]["title"]["#default_value"] = "blabla";
}

Even with mymodule_from_alter it doesn't work


texts:
How do you translate the path portion of a module route?

For instance you have:

module_name.my_route_name:
  path: '/path/to/content'
  defaults:
    _controller: \Drupal\module_name\Controller\MyController

How do I get /es/ruta-de-acceso/a/contenido to point to the same route name?


texts: How to get hidden node value programmatically?

texts:
I am new to Drupal so this question might be stupid or impossible. I am sorry for that.

I am using the Hidden Nodes module in order to make nodes visible to some users, and not visible to anonymous users.

I also have a custom module where I get some nodes nid ($node->nid->value()), titles, and other stuff programmatically.

Now, I also need to get the hidden_node value for the nodes, but I can't get it because its not a node field.

Sorry if this seems confusing.

Thanks.


texts: How do I change the limit of user accounts gets blocked or suspended?

texts:
After entering the wrong password for 5 time, a user account gets locked/suspended.
How do I change this? Instead of 5, I need the accounts are blocked after 10 tentatives.
I already seen the Flood Unblock module, but it unblocks the already blocked users who entered the wrong password more than 5 times.


texts: Creating search pages for specific content types

texts: I am currently in the process of implementing different search pages, with distinct layouts/templates and behaviors for specific content types (a search for "blog" nodes, one for "video" nodes, etc), and I am confused as to what the best approach is for this. I've read that the Facet API module may help implement this behavior. I'm already using Apache Solr for the searching component, is this the best approach and what's the path of least resistance if using Facet API?


texts: Is there a way to enable the Gutenberg editor so I can use it with custom blocks?

texts: I've installed the Gutenberg Editor module and have it working with various content types, however I'd like to also use it to create content for custom blocks (as in structure > block layout > add custom block). I've tried googling but since Gutenberg uses the term 'blocks' to describe the sub-modular pieces of content it uses, I can't find any reference to the module itself being available as an editor for custom blocks, or another module that extends Gutenberg's functionality to custom blocks (or any block element).


texts:
I'm new to drupal and I try to understand the structure of it.

Let's assume I want to do the following regardless of the existence of a module doing this concrete job – just to understand the structure and best practices.

What I need is a calendar module. This calendar should be displayed on an own page. So I think I must provide a special calendar content type, don't I?
Then I want to display the next 3 events as a list on a front page. Here, I guess, I must provide a special block, which is only visible on the defined front page?

Is this the standard way of doing it?


texts: How to show Next and Previous slides besides the current slide with views slideshow module?

texts:
I'm trying to build a slideshow for my website using "views slideshow" similar with the below image:

I don't know how to make previous and next "slides, titles and count numbers" visible!
It seems It's not possible to make it happen with views slide show settings. may be with some function prepossessing or something It's possible but unfortunately I don't have that knowledge.
Would you please help me to figure this out!!


texts: Are there alternatives to using the Node Access module?

texts:
I have installed the Node Access module in a site, in order to assign view/edit capabilities to specific roles.

The pages in which I have granted "edit" permissions to specific roles show the editing option to users of that role, which is good; however, pages that have been limited to be viewed by only role X, and role Y are still viewable to any logged in user, wether they are in role X and Y or not. Has anyone experience this? All settings have been checked out, and there are no conflicting modules.
Is there a better module that has the same features the Node Access module implements?


texts: open_basedir restriction in effect despite file directory within web root

texts:
When trying to upload a logo to my Zen 3.1 subtheme (Appearance > Settings) I get the following error:

Warning: is_file(): open_basedir restriction in effect. File(/tmp/phpillr69) is not within the allowed path(s): (/home/testwww/web/) in image_get_info() (line 126 of /home/testwww/web/informator/includes/image.inc).
Warning: realpath(): open_basedir restriction in effect. File(/tmp/phpillr69) is not within the allowed path(s): (/home/testwww/web/) in drupal_realpath() (line 2177 of /home/testwww/web/informator/includes/file.inc).
Warning: getimagesize(): Filename cannot be empty in image_gd_get_info() (line 349 of /home/testwww/web/informator/modules/system/image.gd.inc).
The specified file logo.gif could not be uploaded. Only JPEG, PNG and GIF images are allowed.

It happens even though I have the paths in Configuration > Media > File System set to be inside the web root.

Public file system path: sites/[my directory]/files [permission 775]
Temporary directory: sites/[my directory]/files/tmp [permission 755]

It seems that Drupal tries to save a temporary file in /tmp/ although the temporary directory is set to something different.

How can I fix the problem to be able to upload a file?


texts:
I'm looking for a solution for streaming video in Drupal 6. Ideally, I'd like to be able to have users upload video via a content type, convert and encode it, then have the published version be linked to a streaming server (like DSS). I want to host the streaming server myself and ideally I'd like it to be free.

I've never heard of it, but it seems there is also something called Kaltura that might work.

Anyone have experience in this realm? Know of something simple I could integrate?

The best I option I can see so far seems to be to display the video via jw player and write something custom to upload videos to the streaming server from those that are uploaded via drupal.


texts: How to display product attribute as filter in product listing page?

texts:
I am creating an e-commerce website using ubercart and Drupal 7. I have created product attribute size and color for the product from the "Administration » Store » Products" and assigned to product.

I have created a views page to display product listing .

Now, the problem is that I want to display product attribute as filter in the above product listing page. I have searched on Google but did not find any solution for that.


texts:
I'm attaching ajax on textfield value. One enter value in textfield and ajax callback returns form element.

Below code is showing ajax 500 error. Can anyone tell what is mistake in this code?

function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

    $form['field_base_price']['widget'][0]['value']['#ajax'] = array(
            'event' => 'change',
            'wrapper' => 'final-price-wrapper',
            'callback' => 'final_price_ajax_callback',
            'method' => 'replace',
          );

    $form['field_final_price']['#prefix'] = '
';
        $form['field_final_price']['#suffix'] = '
';
          $form['final_price_label'] = array(
            '#weight' => 11,
            '#prefix' => '
',
            '#suffix' => '
',
          );
          $form['final_price_label']['title'] = array(
            '#type' => 'markup',
            '#markup' => '' . $form['field_final_price']['widget'][0]['value']['#title'] . '',
          );

    }

    /**
     * Final price AJAX callback.
     */
    function final_price_ajax_callback($form, $form_state) {
      return $form['final_price_label'];
    }


texts: How to implement a multi step approval with webforms/entityforms based on form components?

texts:
Is it possible to invoke multi-step submission workflow using either Webform or Entityform? Here is the scenario of workflows:

  An employee submits the form

  Superviser gets notification, after reviewing the form, he either approves it or denies the request on the same submission.
  If approved, an email notification gets sent out to Director who in turn approves or disapproves the same submission.

  If denied by supervisor, an email gets sent to an employee.

This scenario involves submissions by multiple roles to the same request. I could hide approval fields to employee role, but how would one access webform approval field component via rules for notification purposes? How would I freeze form state?

Should I rather use entityforms since every form component is exposed? As a last resort, I might implement my own solution using forms_api. But I would like to know first if it is possible using webform or entityforms.


texts: Rules - Page redirect not working on "after saving new content"

texts:
Using Drupal 7.7 and Rules 7.x-2.0-beta3

The rule set up is:

Event: After saving new content
Conditions: Content is of type news
Actions: redirect to url news

When adding a news story and clicking submit, the redirect does not happen and I get left with a 'Connection was reset' error in the browser.

Had anyone else this issue?
Any ideas how to overcome this?


texts: How can I theme the Views Exposed Filter?

texts:
I create a view in drupal 7 display a collection of books, and taxonomy for book types .. then I call book type taxonomy in my view and it displayed good .. But because book types taxonomy menu have about 10 items and maybe increased at any time, I want to display 3 items of book types and when click More link display a list of the others, I can't do it in css only, and I can't add a div to group the other part of the list .. so how can I do that?

thank you

when I try to print my exposed filter array

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
     $view = $form_state['view'];

    if ($view->name == 'taxonomybooktype' && $view->current_display == 'taxobooktype') {

        $form['field_book_type_tid']['#options']['All'] = "All";

              echo "<pre>";
      print_r($form['field_book_type_tid']);
      exit;
            }
    }

}

output:

Array
(
  [#type] => select
  [#options] => Array
    (
        [All] => All
        [0] => stdClass Object
            (
                [option] => Array
                    (
                        [7] => Chemical
                    )

            )

        [1] => stdClass Object
            (
                [option] => Array
                    (
                        [1] => computer
                    )

            )

        [2] => stdClass Object
            (
                [option] => Array
                    (
                        [6] => History
                    )

            )
    )
[#size] =>
[#default_value] => All
[#theme] => select_as_links

)

but now how can I group first tow options in a div and remain options in another div or group?


texts:
I would access to the description of node in body value, so I try this :

// ----------------------------
// Acesseur de la descrition d'un noeud
// ---------------------------
function dfsi_GetBodyOf( $node )
{
    $wrapper = entity_metadata_wrapper('node', $node);
    return $wrapper->body->value();
}
// ----------------------------
// Acesseur de la criticite d'un noeud
// ---------------------------
function dfsi_GetCriticiteOf( $node )
{
    $wrapper = entity_metadata_wrapper('node', $node);
    $wrapper-> field_criticite->value();
return $wrapper;
}

I have no problems to access criticite value, but when I try to access body value, it return "array" and I don't know why, can you help me?


texts: How do I mimic Pathauto transliterated output for an alias in my custom PHP code?

texts:
When writing my custom function I need to manually append node name to a taxonomy term link. To get the taxonomy term part done I use:

  $link_uri = taxonomy_term_uri($term);
  $path_alias = drupal_get_path_alias($link_uri['path']);

This works ok, now - I want to append node name ("/" . $node_name), but instead of raw string, I want the Pathauto transliterated output, as set in the URL alias configuration, for that node context.

What function should I use to mimic that output? I looked at hook_pathauto_alias_alter(&$alias, array $context) but I'm not sure that's what I need.


texts:
I forgot my drupal admin password and tried resetting it using forgot password option, but it fails to work( does not send the mail).

Drupal 8 is installed on my localhost. I tried manually editing the users table in the database, so I deleted the user with uid 1(admin) and also deleted corresponding data for uid 1 from users_field_data table.

I am unable to figure out the value to be inserted for uuid in users table. I tried giving 1 for uid, my_name for uuid and md5(password), but the login fails. uuid seems to be encrypted somehow and i can't figure how.

Also, I am using wamp, so I haven't tried using drush or drupal console for version 8.

I found two relevant answers on topics " Insert “uuid” in “users” and Is there a good and recent documentation on the UUID API in Drupal 8 core? ", but not of much help.


texts: Controlling/selling node access by node reference?

texts:
I have been using Drupal for many years now (starting with Drupal 6) and only recently - in the context of a big project - made the switch to D8. So far, working with D8 has been a very pleasant experience, to say the least. I was prepared, however, that there would be a few rocks on the road. And I would like to ask for help removing a big one (for me)...
In a nutshell, the situation is this: I am creating a kind of learning management system (LMS), with lessons, courses and classes. Each lesson belongs to exactly one course, but each courses may or may not belong to zero, one or more classes. I was thinking of using simple node references to structure this:

a field in the content type lesson that references the course that this lesson belongs to
and an entity reference field in the content type class that references all courses in this class (so, this is referenced the other way round)

Now, I'd like to sell access to each of these content types and my problem is this: If a user buys access to one of the classes, she should also be able to access all of the courses (and lessons) that are referenced by this class. So, when checking the access permissions for a single course, the system will not only have to check, if the user has bought this course, but also, if the user has access to a class that contains this course.
I was first thinking of solving this with the module Node access node reference, but this seems to work the other way round (and doesn't have a D8 version). Same for Access by Reference. (In general, most of the access control modules I looked at, don't seem to be ready for D8 yet.) But what about rule-based access control? Or groups?
Can anybody suggest a way forword?
Any help would be much appreciated.
Thanks in advance.


texts: Activate or DeActivate requirement status of field based on another field

texts:
I want to alter a form in my drupal 7 project.
I want to activate or deactivate requirement status of a field programmatically based on another field value.

if field value is male , military status field must be required but if it is female, military status is not required and also it must be hide.

Please guide me in this issue.


texts:
I've always used the Workbench and the Workbench Moderation modules, but recently, the link "My Workbench" in the admin menu has disappeared...

I tried reinstalling the module several times, but no luck there. And all the permissions are checked and double checked, so nothing wrong there.

What else could be the issue?


texts: how to correctly chain multiple files in '$settings['container_yamls'][]'?

texts:
In the settings.php file, I have the following line, to use a local service.yml.

$settings['container_yamls'][] = __DIR__ . '/services.yml';

I need to install the Redis module, which instructs to put the following line in the settings.php file.

$settings['container_yamls'][] = 'modules/redis/example.services.yml';

I'm not sure how the settings array works. I think that just adding that statement will overwrite the existing one.

I want to add the array item as suggested in the documentation for that module.

Should I use these lines?

$settings['container_yamls'][] = __DIR__ . '/services.yml';
$settings['container_yamls'][] = 'modules/redis/example.services.yml';

Or should I use these lines?

$settings['container_yamls'] = array(
  __DIR__ . '/services.yml',
  'modules/redis/example.services.yml',
);


texts:
I'm studying the content_entity_example module and there are some things I'd like to understand better.
In the file content_entity_example.routing.yml there is this block:

entity.content_entity_example_contact.collection:
   path: '/content_entity_example_contact/list'
   defaults:
   # Calls the list controller, defined in the annotation of the contact entity.
     _entity_list: 'content_entity_example_contact'
     _title: 'Contact list'
   requirements:
   # Checks for permission directly.
     _permission: 'view contact entity'

This is the routing path that shows the contact list, but I did not understand what it means

_entity_list: 'content_entity_example_contact'

Examples are avaiable

The examples are available at this link:
Drupal 8 examples


texts: Test mail not sending in drupal 7 SMTP configuration in windows 2012 server

texts:
I installed and configured smtp module with proper details in drupal 7. I tried to send test the mail in windows 2012 server but am getting the below error.
SMTP -> ERROR:

Failed to connect to server: php_network_getaddresses: getaddrinfo failed: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server.
SMTP Error: Could not connect to SMTP host.
Unable to send e-mail. Contact the site administrator if the problem persists.

Same build is working fine in Windows XP, 07 and ubuntu environments.
Not able to find the root cause. Any suggestions are welcome.


texts:
<?php
/**
 * @file
 * Contains \Drupal\custom_widget\Plugin\Field\FieldType\TaxonomyPriorityField
 */

namespace Drupal\custom_widget\Plugin\Field\FieldType;

use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\Field\Annotation\FieldType;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\EntityStorageInterface;

/**
 * Plugin implementation of the 'custom' field type.
 *
 * @FieldType(
 *   id = "taxonomywidget",
 *   label = @Translation("Taxonomy widget"),
 *   description = @Translation("custom field"),
 *   default_widget = "customwidget",
 *   default_formatter = "custom_formatter"
 * )
 */

class CustomField extends FieldItemBase{

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return array(
        'columns' => array(
            'field1' => array(
                'description' => 'One term from the vocabulary Category',
                'type' => 'text',
                'size' => 'medium',
                'not null' => TRUE,
            ),
            'field2' => array(
                'description' => 'An integer between 1 and 999',
                'type' => 'int',
                'size' => 'normal',
                'not null' => TRUE,
            ),
        ),
    );
  }

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties = [];
    $properties['field1'] = DataDefinition::create('any')
    ->setLabel(t('Category'));
    $properties['field2'] = DataDefinition::create('any')
    ->setLabel(t('Field2'));
    return $properties;
  }

  public function preSave(){

    /*some code here*/
    file_put_contents(DRUPAL_ROOT.'/logs/module.log', 'presave is executed');
  }

}

I am using the above code  in a field. But no code in there is being executed.    and I have no idea why.  Everything else in my field works except that presave function


texts: How to check if translation for the current node is available in node.html.twig?

texts: I have two languages on my site. How can I check e.g. in node.html.twig whether a node has both translations?


texts:
I have created a web form form and configure email setting for that but it sends the empty values in the email.

Here's my form:
http://www.harvardstreet.org/request-appointment

Here's my form Configuration:

And Here's how it's looking in the email:

Help me, please!


texts:
I want to migrate users from a Drupal 5 site to a Drupal 7 site.

I have enabled the Migrate and Drupal-to-Drupal data migration modules.

I know I have to make a custom module extending the built in classes of migrate_d2d module to migrate users. The problem is:- which migrate class do I extend while making the custom class?

And am I right in thinking that that code for creating the custom class should be placed in user.inc file?

I am migrating content from one database (legacy) to another database (active).


texts: How to properly programmatically add field collections to an entity in drupal 8?

texts:
What is the proper way to programmatically add a field collection to an entity in Drupal 8?

I can't find this online.

This is what I'm using and it seems to work.  The tricky part is setting the host entity:

  protected function randomUnorderedListItems($profile, $count = 3) {

    for ($i = 0; $i < $count; $i++) {

      //get definition of target entity type
      $entity_def = \Drupal::entityManager()->getDefinition('field_collection_item');

      //load up an array for creation
      $item = array(
        //use the entity definition to set the appropriate property for the bundle
        $entity_def->get('entity_keys')['bundle'] => 'field_unordered_list',
      );

      $item = \Drupal::entityManager()->getStorage('field_collection_item')->create($item);
      $item->setHostEntity($profile, TRUE);
      $item->field_card_title->setValue($this->random->sentences(4, TRUE));
      $item->field_titled_credential->generateSampleItems(3);

      $item->save();

      $profile = $item->getHost();

    }

  }


texts: Adding rel=canonical meta tag in comment paginated node pages

texts:
I posted this question: Google showing pages with ?page=2 urls and also read this post from Google: http://googlewebmastercentral.blogspot.in/2013/04/5-common-mistakes-with-relcanonical.html

I understand that node comments whether paginated or not are of low importance with respect to the node content itself. So all the paginated node pages reached by clicking links in the bottom just above "Post New Comment"( as in attachment) should have rel=canonical pointing to the main node page.

So these pages:

example.com/node?page=1
example.com/node?page=2 and so on

should have "rel=canonical" in the head section of html page pointing to example.com/node.

Though as mentioned in the Google's blog, even "rel=prev" or "rel=next" may also be desirable in case of such urls.

So I need help how to add rel=canonical in those paginated node page. How can I do it?


texts: How to automate database table access as objects and provide common operations, like CRUD and views integraion?

texts:
I think this is a pretty normal use-case: Developer has a database. Tables and columns have meaningful names and helpful comments, possibly also sane set of relations. Now he needs a module to be build on it.

Is there any automated way to provide CRUD and views integration, either dynamically or by creating a module backbone for developers to edit? Like scaffolding available in Cake PHP and other frameworks and languages? Doing it by hand for large number of tables is repetitive and boring, and that's both waste of time and source of errors.


texts: How can I allow authenticated users to edit their nodes only while they are unpublished?

texts:
I have a site in which content must be approved by an administrator before it is published.  Authenticated users have the ability to submit content, which is unpublished by default.  I would also like to be able to have them view and edit content while it is in the unpublished state (for cases in which they realize they made a mistake and would like to correct the submission, etc.)

However, I do not want them to be able to edit the content once it is published, so I don't want to give them blanket edit permissions.

How can I allow them to edit nodes of a given content type only so long as such nodes are in an unpublished state?


texts: How to use token as a filter value in views

texts:
I'm looking for a solution that would allow me to use tokens in views filter values. For example, if I have text field 'my_custom_text' I would like to have a filter that would allow me to use 'Is equal to' operator and a token value instead of hardcoded string.

Note that I can't use contextual filters because I have few filters that needs to be ORed.

Is there a module for that, or do I have to code that myself from ground up?


texts: Change Product price based on discount set by site owners for different domain - Drupal Commerce

texts:
I am working on a website that uses the following modules to create products.

Domain Module to create different domains for different store owners.
Drupal Commerce to create products and ecommerce facility.

The idea is each store admin will have a different domain in the website so that they can setup there stores. Also they are able to create the products for their own.
The product types have a field called "Commission", which stores a value in it. It is used to pay back some commission to the store owners if that product is purchased from the site owner's store.

Each site owner has a admin page where a custom module sets a variable called "Discount" which will denote the percentage of discount to apply in each product globally only to that domain.

As an example, suppose a domain store has a product with $100 and that product has a Commission 25% the upon selling that product the domain's site owner will get $25.
But if that site owner sets the global Discount variable as 50% then the buying user will have a discount on $100 product of 12.5% as $87.50 and the site owner will get commission as 12.5% as $12.50.

Is there any way or HOOK that I could use to alter the price once it goes to the Checkout page?


texts:
I found that the ST Conch theme has a full site installation package with that theme.

How do I go about doing this? And would it be possible to populate the database with the data as well...?

Thanks


texts:
have transferred a Drupal multi-site configuration to a new server with the intent to separate the two websites into individual Drupal installations.

I receive the following error from Drupal:

  PDOException: SQLSTATE[HY000] [2002] Invalid argument in
  lock_may_be_available() (line 167 of
  /home/designglassco/public_html/drupal/includes/lock.inc).

Most of the internet seems to point to a database issue but I have triple checked this information and all is fine.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'DB_NAME',
      'username' => 'DB_USER',
      'password' => 'DB_PASSWORD',
      'host' => 'localhost',
      'port' => '',
      'unix_socket' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

I tried both localhost and 127.0.0.1.

I am using Drupal 7.34, PHP 5.4.27, and MySQL 5.5.40.

Does anyone know how to fix this?


texts: Why isn't my composer installation working?

texts:
I followed the instructions on docs.drush.org for installing Drush, proceeded by the recommended steps for installing Composer and a new Drupal 8 project. My project (cfbtv) is located at ~/sites/cfbtv and it appears the composer template (whatever that is) installed Drupal in the web directory.

When I try the recommended Composer commands they fail. composer update devel outputs the following.

  Package "devel" listed for update is not installed. Ignoring.
  Loading composer repositories with package information   Updating
  dependencies (including require-dev)   Nothing to install or update
  Generating autoload files

When I run composer require devel, I get this message.

  [InvalidArgumentException]
  Could not find package devel at any version for your minimum-stability (stable).
  Check the package spelling or your minimum-stability.

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

So what is the problem here?
Composer seems to have installed properly, but I'm surprised these commands aren't working. Maybe it works and I'm not using it correctly.


texts: Deny/allow access to group-content only for some roles

texts:
I have a private group with a "notebook"...most pages of that notebook may be accessed by all members of that group, but some pages shouldn't. I tried to control access with the module "Content access" but that only works with node types that are not part of any group because organic groups seems to grant access to all nodes if the user belongs to that group.
Is there a way to deny access (based on roles) to nodes that belong to a group if the user is in the group?


texts: Taking node map from /map/node and using it on home page

texts: I need a google map block which would show all the nodes' location with markers. I noticed that Location module has this built in if I follow /map/node url. My question is, can I somehow take this map block and use it on my home page? Add it through blocks interface or by page components?


texts:
I'm creating a custom theme with base theme: stable. I have copied the template/layout/page.html.twig file into my theme. As I am reading the twig file I have noticed that there are some regions that I am not providing but are still being rendered.

Part of the file comment lists the regions available.

/*
 * Regions:
 * - page.header: Items for the header region.
 * - page.primary_menu: Items for the primary menu region.
 * - page.secondary_menu: Items for the secondary menu region.
 * - page.highlighted: Items for the highlighted content region.
 * - page.help: Dynamic help text, mostly for admin pages.
 * - page.content: The main content of the current page.
 * - page.sidebar_first: Items for the first sidebar.
 * - page.sidebar_second: Items for the second sidebar.
 * - page.footer: Items for the footer region.
 * - page.breadcrumb: Items for the breadcrumb region.
 */

I went looking in the stable.info.yml file and noticed there is not an entry for regions: so I am at a loss as how the page.html.twig file is able to render regions that are not listed in the stable.info.yml file.

Questions

How does this work without being defined in the stable.info.yml file.
Are there any other regions that work like this that are not in the page.html.twig file.


texts: drupal_static() uses a FUNCTION variable,what does it mean?

texts:
function drupal_set_page_content($content = NULL) {
  $content_block = &drupal_static(__FUNCTION__, NULL);
  $main_content_display = &drupal_static('system_main_content_added', FALSE);

  if (!empty($content)) {
    $content_block = (is_array($content) ? $content : array('main' => array('#markup' => $content)));
  }
  else {
    $main_content_display = TRUE;
    return $content_block;
  }
}

This snippet is pasted from common.inc. We pass in a __FUNCTION__ to  drupal_static() but I do not know what this variable means. Does it mean a cache for the outer function itself? How does it work? I do not see any data handled inside the function before it returns $content_block.


texts: How can we output unfiltered HTML in a CCK field

texts:
This seems like the simplest thing but for some reason we just cannot get this to work.

We have create 4 additional CCK fields for our "product" content type.

We enter simple HTML in to these fields and want to display these, as is, unfiltered on the node output.

Whatever we do, it always outputs as plain text, stripped of all html. Weve seen numerous references to the "Text Processing" options within the field settings, but they dont appear for us.

Ive even gone in and changed the text_processing value within the database for the field, Ive tried manually setting the filter type within the text.module code, weve spent days on what seems to be a simple and fundamental task.

How can we achieve this?


texts: After submission of a webform block how to replace that webform block with thank you message in the same page?

texts:
I have created a webform block and assigned to a page in the right sidebar. After successful submission of that block, I want the thank you message with the values submitted in the webform to displayed where block was there before in the same page.

I have given no-redirect option in the form settings of the webform.

Also in the block settings  of the webform block given view mode as form only.

But how would I replace the webform block with thank you message on successful submission of webform in the same page? Is there any Drupal way to achieve this. Have I missed any settings ??

Any help will be much appreciated.Thanks in advance.


texts: Concatenate and minify css with Gulp still necessary?

texts: I'm using Gulp as part of my theming workflow and was wondering if it was necessary to add the concatenate and minify tasks into Gulp if Drupal already does that when I check the option under Performance.


texts: Is there a way to strip identifying data from commerce tables?

texts:
I am interested in stripping personal addresses out of the  commerce_customer_profile and commerce_customer_profile_revisions database tables to sanitize the database for development purposes.

The site is using Drupal 7 and Drupal Commerce 7.x-1.13.

Has anyone come up with a way to do this?


texts: Content type allowing multiple nodes to be selected / linked

texts:
I have a content type of 'tutors' which currently has basic fields for their biography.

I have another content type 'venues' which lists the training venues my client operates.

I wish to allow the site admins to flag which tutors teach at which venues - allowing then a list of tutors to be shown on the venue page.

I am comfortable creating a view for each venue page - but what is my best mechanism to allow for a list of all available venues to be listed in the admin with a checkbox or similar so that a tutor can be 'assigned' to one or multiple venues?

Trying to achieve this in D7.


texts: Date field with granularity of Month, Year in Exposed filter, how to alter the default value?

texts:
I have a Date field with granularity of Month, Year in Exposed filter. Everything is working fine, but the month and year default values are shown as "-Month" and "-Year".
Let me know how to alter the form to remove the "-" from Month and Year filter.


texts: Can someone explain the @RestResource annotation for building a Rest resource?

texts:
I am trying to create a RESTful web service.  Above the class there is the following  comment.

/**
 * Represents entities as resources.
 *
 * @RestResource(
 *   id = "entity",
 *   label = @Translation("Entity"),
 *   serialization_class = "Drupal\Core\Entity\Entity",
 *   deriver = "Drupal\rest\Plugin\Deriver\EntityDeriver",
 *   uri_paths = {
 *     "canonical" = "/entity/{entity_type}/{entity}",
 *     "https://www.drupal.org/link-relations/create" = "/entity/{entity_type}"
 *   }
 * )
 *
 * @see \Drupal\rest\Plugin\Derivative\EntityDerivative
 */

What does this mean? What is it supposed to do?

I can't find anything useful about this, especially about the uri_paths array.


texts: Hook to track commerce product category view

texts: I am creating a drupal commerce module for tracking users. I want to access a hook in drupal commerce on product category page. Went through most of the documentation but was not able to find the hook to listen to for product category page view.


texts: I have a rather long procedure on form submit (need to send several email to different addresses); when the use submits the form, the application seems to hang while it is doing a lot of work. Is there a Drupal way to show a "operation in progress" (better showing an indicator) without using Ajax and/or Ahah?


texts:
On my Commerce Kickstart Page, I have each prodcut with 2 different variations.
My problem is that I am unable to change the variation title for the product variations that have been added first on the product itself. It continuously overrides my changes with the original, auto-generated title for a couple of products, but not all of them.
The second variation is always called "DVD - Product name" and works fine.

The first is set up like this:

When I now click on "Update product", it shows the correct values in the overview of the variations:

I now simply say "Save" on my edit product view and save the product. I click edit again and the old value is back as the variation title. But when I open the variation settings, it still shows me my changed title in the textfield:

I already took a look into the database, and the correct value (my changed title) is stored there. This made me think that this is a chaching problem, I played around with cache settings and stuff but that did not change anything.

It may also be noted that this problem does only occur for about 30% of my products, and also only for the first added products.


texts:
I've successfully added an item to the the admin toolbar and now would like to create a drop down menu from that (i.e. the way Manage > Structure drops down Content Types, etc.)

This is how I've created the tray links ...

/**
 * Implements hook_toolbar().
 */
function mymenu_toolbar() {

  // Create the toolbar render array
  $items['mymenu'] = [
    '#type' => 'toolbar_item',
    'tab' => [
      '#type' => 'link',
      '#title' => t('MyMenu'),
      '#url' => Url::fromRoute('<front>'),
      '#attributes' => [
        'title' => t('MyMenu'),
        'class' => ['toolbar-icon', 'toolbar-icon-mymenu'],
      ],
    ],
    'tray' => [
      '#heading' => t('MyMenu'),
      'shortcuts' => [
        '#theme' => 'links__toolbar_mymenu',
        '#links' => [
          ['my_page_1'] = [
            'title' => t('My Page 1'),
            'url' => \Drupal\Core\Url::fromRoute('mymenu.mypage1'),
            'attributes' => [
              'title' => t('My Page 1 Description'),
            ],
          ],
          ['my_page_2'] = [
            'title' => t('My Page 2'),
            'url' => \Drupal\Core\Url::fromRoute('mymenu.mypage2'),
            'attributes' => [
              'title' => t('My Page 2 Description'),
            ],
          ],
        ],
        '#attributes' => [
          'class' => ['toolbar-menu'],
        ],
      ],
    ],
    '#weight' => 999,
    '#attached' => [
      'library' => [
        'mymenu/mymenu.icons',
      ],
    ],
  ];

  return $items;
}

This produces ...

I thought perhaps adding my drop down items as children of the items in the #links array would work, but I haven't yet been able to work it out or find a good example of that being done.

Any suggestions?


texts: Installing demo content via module.install file with Migrate module

texts:
I'm trying to import content on installation of my feature, but it's not happening.  If I enable the migrate_ui module and go and manually execute the import, then it imports fine.

The code below is from my module.install file, which was originally taken from the restaurant_event feature of the Restaurant Distribution.

/**
 * Implements hook_enable().
 */
function parcel_event_demo_enable() {
  Migration::registerMigration('ParcelEventMigrateEvent');
}

/**
 * Implements hook_disable().
 */
function parcel_event_demo_disable() {
  Migration::deregisterMigration('ParcelEventMigrateEvent');
}


texts: Upgrade error: Attempt to create a field body that does not exist on entity type node

texts:
I am struggling with Drupal 8 upgrade for a months now. The Travis CI build is always failed with below errors.

I'm upgrading from Drupal 8.3.7 to 8.4.8 with Lightning (2.2.9), BLT 8.9.7, Drush version 8.2.3

Synchronized configuration: update views.view.frontpage.             [ok]
Synchronized configuration: update dropzonejs.settings.              [ok]
Synchronized configuration: update lightning_roles.settings.         [ok]
Finalizing configuration synchronization.                            [ok]
The import failed due for the following reasons:                     [error]
Unexpected error during import with operation delete for
node.type.page: Attempt to create a field body that does not exist on
entity type node.
Unexpected error during import with operation delete for
node.type.landing_page: Attempt to create a field body that does not
exist on entity type node.

I've successfully upgraded on localhost and exported the config file using "drush [mywebsite] cex sync" command. However, when I push to Github the Travis CI build failed with the errors above.

I've done the "drush [mysite] updb" command and it went without any errors.  I also ran the command "drush [mysite] entity-updates -y"

Googling the errors without any luck, so I thought to post it here.  Any help would be most welcome.


texts: trying to understand hook_views_query_alter for sorting

texts:
My requirement is to sort the nodes with a "condition" based on whether a field called myfield has value in it or not and then by date created. That means, show nodes first if a field has value and then by datecreated.

its something like this sql query

select field1,
       datecreated,
       if(isnull(myfield,1),1,0) hasvalue

from table
order by hasvalue asc, datecreated desc

For doing this I learnt that I need to create a module called tdyards and implemented tdyards_views_query_alter in tdyards.views.inc with this code in it and enabled the module.

<?php

function tdyards_views_query_alter(&$view, &$query) {
    print "
I am in tdyards alter query
";
    var_dump($query);
    die();
}

I was expecting this pileup my screen with the dump but it seems like it is never called this function. Am I missing anything else here? If my guess is correct it must call this for each and every view because my implementation doesn not have any condition


texts: How to show multiple Series of line charts in Views with the Charts module?

texts:
I need to create multiple line charts in the same chart.  I have a year column, a product column, and a consumer column.  I can plot product and year or consumer and year, but when I use all three columns I get a chart that puts both product and consumer data on the same line.

I am using the Charts module, with the Highcharts library as its charting engine and its views integration.

How can I get a product and consumer line to appear on the same graph?  I was hoping for the chart to look like Preview 6 here: https://www.drupal.org/node/2426177#preview6

Here is what my chart looks like.

Data:

Products:

Consumer:

Both:


texts: Content access based on the content author's role

texts:
I have a content type named "Files". I have given access for users with roles editor 1, editor 2 and editor 3 to update and delete their own content.

Now If a user with editor 1 creates a files content. I need to allow other users with same role (editor 1) to update and delete the content.

I tried Content Access Module but it doesn't helps.

Can anyone give me a working example for this scenario.


texts: Drupal 7 Theme [Business] not pulling in to non-front pages

texts:
I am programming five custom modules for a client in Drupal 7.  Tey have, well, HAD, a company in India doing their front-end work.  Something went wrong and the India company stopped responding and developing the front end, so I have been tasked with finishing the pages and of course still complete the modules.  Didn't think this would be a real big deal, but here is the rub--

The company created the front page template.  I went in created a few pages, [ie about, connect, meet the authors, etc].  When I looked at the pages, they looked awful, no formatting at all, except for the top navbar/header which is actually pulling from the subtheme.  I have enough css skills to realize these new pages are not calling the base theme, in this case, they are using the drupal business theme located here [https://www.drupal.org/project/business].

The former company created a subtheme, of sorts, off the "Drupal Business" theme and have the page--front and page.tpl.php along with css and js related folders and files.

i turned on devel_themer and see the front/home page is calling the new front-page template. When I look and click on the body/node of my new pages below the top nav/header, the function call reference "theme-field", not the base theme or the subtheme that is in /sites/all/themes....

Since I am more a programmer and hence the reason I love Drupal, don't have to worry about all the theming stuff.  I just need the new pages to apply the base theme's css and reference the settings correctly.

Could any of the theming pro's give me some insight, assistance please?  It seems like there is a setting to apply the theme to the pages you want, but I can't figure that out.


texts: Fetch Link field Label and Link separately in views-view-fields template

texts:
How can I fetch label and link field in views-view-fields--VIEW-NAME-HERE.html.twig file

So far I have tried

{{ fields.field_action_link.content }} give me the anchor tag prebuilt (html)
{{ fields.field_action_link.0.url }}
{{ content.field_action_link[0]['#url'] }}

but none of them seems to work for me. I am able to retrieve all other fields including image field.


texts:
I have configured an email handler with the condition that an email message must be sent when a submission is updated by filling an image file field (the image file field has to be "filled"), but email message is not sent. The handler works if condition is removed

Core is 8.6.3 and Webform 8.x-5.0-rc26

Thanks


texts: Different bar colors for each poll choice?

texts: I know how to change ALL of the bar colors - but how do I code it so each choice bar is a different color?  I basically just need code to append the number to the "bar" class, so it would read "bar-1" , "bar-2" etc.


texts:
I want to remove the following default links on the login block.

Create new account
Reset your password

I used hook_form_alter() but there is nothing in there that creates these links.


texts: How to change background colour of webform?

texts:
I'm finishing a website that someone else started and there are a few things I can't figure out. It's a Drupal 8 installation and I have administrator permissions, but I've tried every setting I can find in Drupal to change the background colour of the webforms on the site. I checked the web hosting for custom css and I found a file in this location;

public_html/themes/our_theme/css

And it looks like someone has been editing that file because there's commenting that aren't comments, but code that's commented out. However, when I make changes to that file, nothing happens. That could be because the file seems to be getting minified and saved as another file, which is then read by the browser when a user goes to the website.

Any help?


texts: 7 - How can I add a region inside another region?

texts:
I'm surprised I can't find the answer to this online.

I'm currently creating a custom header for my drupal site, so I've created a custom_header region in the .info and a region--custom-header.tpl.php file. Inside the region, I need to add another region.

I've tried to print the other region inside the header region, but nothing is showing up.

Good practise or not aside, how can I do this?


texts: Technical advantages of either Configuration or Features over the other?

texts:
In short, Configuration vs Features, in Drupal 7, fight!

As always, technical advantages, or other hard facts, as we don't do discussions here. Drupal 7 specific to limit to scope, as CMI vs Features is a completely different discussion.


texts: Drupal 7.36 configuration error: Call to undefined function field_attach_load()

texts:
I tried to configure Drupal 7.36 with WAMP and result back with the below error after clicking "configure site". I am using Window7. Please help!

Fatal error: Call to undefined function field_attach_load() in C:\wamp\www\sdg\includes\entity.inc on line 320


texts: drill down taxonomy node count using views

texts:
I don't know if I'm the only one having this issue but my problem seems to be common. I just could not find the solution here and Google.

My site have the taxonomy menu:
Classifieds
  Electronics
  Autos
Jobs
  Accounting
  Information Technology
I just want to show a summary for every term that has children on it. E.g., When you click on Classifieds it should show like this:
Electronics(160)
Autos(310)
And when you click on Autos(310) it should show for example:
Aston Martin(200)
Toyota(110)
And then drill down to the last child item with node count. (e.g. DB9 Coupe (xx) etc..)
When I use the views default summary display and you clicked on 'classifieds' it will show:
Free Stuffs(xx)
DB9 Coupe(xx) <-- this should should first as 'Autos' and not show the last child in the hierarchy!

Basically, it's just a page with summary counts of terms being used in nodes and count them by level in the taxonomy hierarchy. So, from clicking a parent term, the first child terms will only show with node counts, then when clicking on one child only the children of this child will show with node counts etc..

Thank you in advance!


texts:
I am using D7 and subtheming the commerce kickstart theme.

There is a view named Collection Products. I have added a field to the view called Product category: Description (indexed) that pulls in the taxonomy term description and places it above the product list. You can see the page here: http://freelance-graphic-designer.us/barmaiddev2/product-category/commercial-juicers

When it pulls this taxonomy term, all styling from the original content is lost. You can see how it comes in as one big block as h3. I have tried wrapping it in div containers in the wysiwyg editor on the original content page, but they just don't stay with it when it is pulled in by the view.

I have tried to style it within the view style settings with no luck.

I would like style the headings and body copy in my css style sheet and make it look more like the same content on its node here http://freelance-graphic-designer.us/barmaiddev2/commercial-juicers

Any suggestions? I am in a desperate hurry.


texts: Restrict publishing to certain Taxonomy Terms

texts:
Greetings and salutations. I am struggling to find a solution to the following matter:

Goal:
A Taxonomy named Sections has terms like Term 1, Term 2, Term 3. The goal is to only allow users to publish content under 'Term 1' and 'Term 2' and any content posted under 'Term 3' will not be automatically published and put to the moderation queue.

Modules tried (with no success):
Taxonomy Access Control
Taxonomy Tools


texts: Conditional Fields not working with ckeditor?

texts: i have a problem with conditional fields module in d7: Fields are not hidden when the ckeditor is activated for the certain field...if i switch to "plain text editor" everyting works fine... is that a bug or is it me not setting the right options...?


texts:
A "Fatal error: Class name must be a valid object or a string […] common.inc" appears on every page on the backoffice.

We don't how to reproduce this because it happens suddenly. When I've done a var_dump() of $class, and $entity_type, this is the result I obtained:

    string 'user' (length=4)
    TaxonomyTermController
    string 'taxonomy_term' (length=13)
    string 'user' (length=4)

The debug code has been added to entity_get_controller().

function entity_get_controller($entity_type) {
  $controllers = &drupal_static(__FUNCTION__, array());
  if (!isset($controllers[$entity_type])) {
    $type_info = entity_get_info($entity_type);
    $class = $type_info['controller class'];
    echo $class;
    var_dump($entity_type);
    $controllers[$entity_type] = new $class($entity_type);
  }

  return $controllers[$entity_type];
}

It seems that $type_info['controller class'] doesn't exist for "User".

This problem is solved when we flush the cache_bootstrap (via DELETE FROM cache_bootstrap) and cache (via DELETE FROM CACHE), but this is a temporary solution because it appears again.

It's a big problem for us. Any idea will be really appreciated.


texts:
Environment:

Drupal 7
Modules: Page manager, Devel generate, panels in-Place Editor, Panels, CTools, jquery-module

I defined a 3 column design but I can not add any content to any panel (superior, left side, middle column, right side...)

Any idea what it can be?


texts: Change taxonomy term field into text field in content-type

texts: Is there a way to transform a taxonomy term field into a simple text field? I need to keep all the terms present in the taxonomy field and have them separated by a comma.


texts:
How do I redirect users after they submit a form? I tried the following code, but it doesn't work. It says the route doesn't exist.

public  function submitForm(array &$form, FormStateInterface $form_state){
   $url = Url::fromRoute('/mon-profil/obtenir_document'); // == /node/1
   $form_state->setRedirectUrl($url);
}


texts: How to call field label & values in custom content type page template

texts:
I have created a custom page--mycontent-type.page.tpl for customizing display with html tags classes & attributes.
I'am unable to call that content type fields & their label.
I've tried these to print values but not worked for me.

<?php print render($content['field_name']); ?>
<?php print render($page['content']['field_name']); ?>
<?php print render($fields['field_introduction']->content); ?>

Please suggest me what code call the actual fields & label. Thanks in advance :)


texts:
I've got the below code

$query = \Drupal::database()
  ->select("excel", "e")->fields("e");
$group = $query->orConditionGroup()
  ->condition("grupindex", 1)
  ->condition("grupkodu", NULL);
$query->condition($group);
$excel_products = $query->execute()->fetchAll();

When I run SELECT * FROM excel WHERE grupkodu = 1 OR grupkodu IS NULL, I get 1594 records, however the above code gives only 638 records, which means only grupkodu condition is taken into account. What is the proper way to apply OR?


texts: Redirect to external url adds external url to current url instead

texts:
I'm using wampserver and I'm trying to redirect a visitor to an external url (which in turn will eventually send them back to another page on my drupal-site).

My site on wampserver is called localhost/testing and I use

drupal_goto(www.example.com, array(
  'external' => TRUE,
  'absolute' => TRUE,
  ));

However, the url I get redirected to is localhost/testing/www.example.com instead of www.example.com


texts: How do I mirror a database from remote Linux into Windows localhost?

texts:
I would like to mirror Linux dev.example.com into Windows dev.example.com.local properly to be able to do development locally.

I have already set up xampp and hosts (dev.example.com.local)
I have created localhost mysql database instance (dev).
I have set up Drupal 7 settings.php on local.
I can export remote db into sql.zip file and I can import it into local db

The key question I have now is
how to properly handle mysql export and import to make sure both local and remote mysql instances are in sync?

I bet Step 4 is not enough here.


texts: How render view with programmatically passed parameters of contextual filter

texts: I am using Drupal 8. Added new view My Vocabulary and created a contextual filter with paragraph ID. Now I need to render the view with passed parameters to contextual filter. What hook to use to solve my problem. Thanks.


texts: How to dump a single table from database using drush?

texts: I'm aware of mysqldump utility, but is there any way of dumping a single table from database using drush (e.g. for sql-dump, sql-sync)?


texts:
I'm trying to port the OpenID module from Drupal 7 to Drupal 8.

I have a form OpenIdLoginForm.php with the following code.

<?php
...
namespace Drupal\openid\Form;
use Drupal\user\Form\UserLoginForm;
use Drupal\Core\Form\FormStateInterface
use Drupal\Core\Url;
use Drupal\user\UserStorageInterface
...
class OpenIdLoginForm extends UserLoginForm {
... // getFormId, buildForm methods work nicely

  public function validateForm(array &$form, FormStateInterface $form_state) {
    ... // some validations
    openid_begin($claimed_id, $return_to, $form_state);
  }

... // submitForm method
}

openid_begin is defined in openid.module.

<?php

use Drupal\Core\Routing\RouteMatchInterface;

... // openid_help, working nicely

function openid_begin($claimed_id, $return_to = '', $form_state = null) {
  // some stuff
}

The folder structure is the following.

modules/
  openid/
    README.md
    openid.module
    ...
    src/
      Form/
        OpenIdLoginForm.php
        ...

Whenever I submit the form, and validateForm() is called, I get an error:

  PHP Fatal error:  Call to undefined function Drupal\openid\Form\openid_begin() in /modules/openid/src/Form/OpenIdLoginForm.php

What am I doing wrong? How would I invoke a module function from a form belonging to the same module?

Fun fact: invoking the function user_login_finalize() from submitForm() in OpenIdLoginForm.php works and I don't know why.


texts:
I've already managed to modify checkbox markup for a bit but there's still something that I can't access. Current markup is as follows and here you can see the duplicate text of which last one should be removed:

            <input type="checkbox" id="edit-submitted-payment-methods-1" name="submitted[payment_methods][1]" value="1" class="form-checkbox checkbox require-one-edit-submitted-payment-methods">

            In cash (to a member or representative)

    In cash (to a member or representative)


texts: How to change Views field settings programmatically?

texts:
I would like to change some field settings in a given view created with Views programmatically.

For example, I would like to change the "Formatter" and "Image style" settings of an Image field. This is what the settings of this field look like when I export this view:

/* Field: Taxonomy term: Natural images */
$handler->display->display_options['fields']['field_gallery_natural_images']['id'] = 'field_gallery_natural_images';
$handler->display->display_options['fields']['field_gallery_natural_images']['table'] = 'field_data_field_gallery_natural_images';
$handler->display->display_options['fields']['field_gallery_natural_images']['field'] = 'field_gallery_natural_images';
$handler->display->display_options['fields']['field_gallery_natural_images']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_gallery_natural_images']['type'] = 'colorbox';
$handler->display->display_options['fields']['field_gallery_natural_images']['settings'] = array(
  'colorbox_node_style' => '',
  'colorbox_image_style' => '',
  'colorbox_gallery' => 'post',
  'colorbox_gallery_custom' => '',
  'colorbox_caption' => 'auto',
  'colorbox_caption_custom' => '',
  'display_empty' => '',
  'custom_text' => '',
  'empty_callback' => 'mymodule_empty_fields_no_data',
);

I would like to change the "Image style" of the Colorbox formatter somehow like this:

$handler->display->display_options['fields']['field_gallery_natural_images']['settings']['colorbox_node_style'] = 'thumbnail';

and save that. How should I do that?

Like here:

EDIT 1.

Maybe I should use views_save_view():
http://api.drupal.org/api/views/views.module/function/views_save_view/7

It saves a view - so maybe I should query the whole view, change that, and use this function. But how exactly?

EDIT 2.

I found in views/includes/admin.inc that the given view gets saved like this: $form_state['view']->save(); in views_ui_edit_view_form_submit().

I already know how to change "Image style" of an Image field in a given view mode programmatically (as on "Manage display" tab after clicking the gear), but now I would be happy if I could do something similar with a given view.


texts: Custom module error, does'nt show on the page

texts:
I am new to drupal, so basically i have made a simple registration form. The problem is when i go to the registration form it shows a blank page .

i have made 3 files by the name of my custom module -registerme i.e.-

1.registerme.info

name = Register Me
description = A custom registration form
package = Drupal 7 Development
core = 7.x
files[] = registerme.module

2.registerme.module

<?php

function registerme_menu()
{
$items['registerme/newform'] = array(
  'title' => 'Registration Form',
    'page callback' => 'drupal_get_form',
    'page arguments' => 'registerme_newform',
    'access callback' => TRUE,                    //array('access content'),
    'file' => 'registerme.newform.inc',
    'weight' => '-2',
 );
return $items;
}

3.And finally i have registerme.newform.inc

<?php
function registerme_newform(&$form_state)
{
$form = array();
$form['account details'] = array(
    '#type' => 'fieldset',
    '#title' => t('Account Details')
);
$form['account details']['first name'] = array(
    '#type' => 'textfield',
    '#title' => t('First Name')
    );
$form['account details']['last name'] = array(
    '#type' => 'textfield',
    '#title' => t('Last Name')
    );
$form['account details']['mail'] = array(
    '#type' => 'textfield',
    '#title' => t('Last Name')
    );

$form['account details']['pass'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#maxlength' => 60,
    '#size' => 15,
    '#required' => TRUE,
    );
$form['account details']['pass'] = array(
    '#type' => 'password_confirm',
    '#description' => t('Enter the same password'),
    '#size' => 15,
    );
$form['home'] = array(
    '#type' => 'fieldset',
    '#title' => 'Home Address',
);
$form['home']['street'] = array(
    '#type' => 'textfield',
    '#title' => 'Street Address',
);
 $form['home']['city'] = array(
    '#type' => 'textfield',
    '#title' => 'City',
);
 $form['work'] = array(
    '#type' => 'fieldset',
    '#title' => 'Work Address',
);
$form['work']['street'] = array(
    '#type' => 'textfield',
    '#title' => 'Street Address',
);
 $form['work']['city'] = array(
    '#type' => 'textfield',
    '#title' => 'City',
);
 $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Register Me'),
 );
 return $form;
}
function registerme_newform_submit(&$form, &$form_state)
{
dsm($form_state);
}
function registerme_newform_validate(&$form, &$form_state)
{
// Some validation to be done on fields.
}

where i am doing wrong getting errors like

Warning: Invalid argument supplied for foreach() in menu_unserialize() (line 400 of
    C:\webserver\Apache\htdocs\Starter\includes\menu.inc).
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in
    menu_get_item() (line 479 of
    C:\webserver\Apache\htdocs\Starter\includes\menu.inc).
Warning: call_user_func_array() expects parameter 2 to be array, null given in
    menu_execute_active_handler() (line 516 of
     C:\webserver\Apache\htdocs\Starter\includes\menu.inc).
Warning: Invalid argument supplied for foreach() in menu_unserialize() (line 400 of
      C:\webserver\Apache\htdocs\Starter\includes\menu.inc).

The form dislpays a blank page when i click on the menu listing Register Me and the url is
    localhost/Starter/?q=registerme/newform


texts: How to override path of specific page using views

texts:
I have created a page view which contains files listing.
On existing Page there are three tabs called 'thumbnails' 'files' and 'thumbnail plus' now I want to override on 'files' tab view with my page view.
How do I do that?


texts: Missing bottom level item when a node is linked to two menu objects

texts:
I have been trying to create a custom menu block which shows a number of menu items with images on the current level.

I am having an issue where the active trail array doesn't return an menu item for the active node on level 4 of my menu. Here is an example of how I get the active trail:

$menu_tree = \Drupal::menuTree();
$menu_parent_tree = \Drupal::menuTree();
$menu_name = 'main';

// Build the typical default set of menu tree parameters.
$parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);

foreach($parameters->activeTrail as $active_menu_link) {
  if($active_menu_link !== '') {
    $active_menu_id = explode(':', $active_menu_link);
    $entity = \Drupal::entityManager()->loadEntityByUuid($active_menu_id[0], $active_menu_id[1]);

    kint($entity->getTitle());
  }
}

It seems that the issue is mostly related to the fact that the same node is linked to both a child menu item and a parent menu item. If I remove this then the function works as expected. This is the my menu structure.

The two menu items highlighted in red are both linked to the same node since I want it to act as an overview page for the category. It could be that theres something else I can do to structure the menu differently. I am open to any alternatives on how I can get around this.


texts: return message after hook_form_submit without Ajax

texts:
This might seem trivial to many of you, but how can you return a form with a customized message (according to the fields) in a hook_form_submit ? Like :

   <?php
/**
 * @file
 * Pages and display.
 */
/**
 * Constantes
 */

/**
 * *************** Formulaire *******************
 */

/**
 *
 * Implements a standard form.
 */
function MY_MODULE_form($form, $form_state, $arg) {
  $form = array ();
  $form ['#type'] = 'type';
  /**
   * All the form elements
   */

  // soumission du formulaire
  $form ['submit'] = array (
      '#type' => 'submit',
      '#value' => t ( 'Lancer la simulation' ),
      '#weight' => 10000
  );

  $form ['simul_message_retour'] = array (
      '#prefix' => '
',
      '#suffix' => '
',
      '#markup' => isset($form_state ['input']['simul_message_retour']['#markup'])?$form_state ['input']['simul_message_retour']['#markup']:'',
      '#weight' => $form ['submit'] ['#weight'] + 1
  );
  if (!empty($form_state['response_module'])) {
    $form['simul_message_retour']['#markup'] = convert_data_to_markup($form_state['response_module']);
  }
  return $form;
}

/**
 * Validation Works
 */
function MY_MODULE_form_validate($form, &$form_state) {

  $form_numbers = array (
    //Some form fields
  );
  // operations of validation
}

/**
 *
 * @param unknown $form_element
 * @param unknown $form_state
 * @return Ambigous <multitype:, unknown>
 */
function MY_MODULE_format_simul_datenaissance($form_element, &$form_state) {
  //checking some of the form construction
}
/**
 * Function of submit
 *
 * @param unknown $form
 * @param unknown $form_state
 */
function MY_MODULE_form_submit($form, $form_state) {
  $form_state['response_module'] = project_call_WS($form, $form_state);
  $form_state['rebuild'] = TRUE;
}

/**
 * function processing the call to the WS
 * @param unknown $form
 * @param unknown $form_state
 */
 function project_call_WS($form, $form_state){
  // checking if there are no errors
  if (form_get_errors ())
    return '';

  //Operations on the form
  $url = implode ( '/', $url_array );
  $parameters = 'URLTOWEBSERVICE';
  // HERE IS CALLED THE WEBSERVICE(the function call_ws is working well)
  $call = call_ws ($parameters );

  $build = array (
      //ETC
  );
 //Operations on the $builds array
  return $build;
}

Thanks a lot


texts: Show views active filter values as pills without using Facets

texts:
I have this requirement where selected filter values need to appear as "pills" on the page with an "x" which, when clicked, would unset the filter and reload the search without that value. I've used Active Facet Pills once before to achieve this. However, the view I'm working with is just a plain vanilla view (no facets). I've done a lot of searching, but nothing seems to come up on how to implement this.
How does one achieve this in D7 views?