texts: How to set form element order with field_attach_form (and why does it do it?)

texts:
Problem

I'm attaching the user register form to the add node form using hook_form_alter (for a custom content type). (Forcing an anonymous user to register when they create a node.)

My solution to this problem, has been to put a large chunk of the user register code into hook_form_alter (because I'm a "great" developer).

While this works in a custom form, in hook_form_alter the following function

 field_attach_form('user', $form['#user'], $form, $form_state, $langcode);

Causes the register fields to always appear in the middle of the form. (#weight does nothing.)

Reading through the documentation, it appears this function always puts the fields at the top of $form_state['values'] and you can change it by setting the #parents property on the incoming $form parameter.

2 Questions:

Why does the order in $form_state effect the display of my form? I thought the #weight property in the form elements determined this.
I don't really understand how to set the parents property. Do I need to create a parent which encompasses all of the standard node add form, and then set this new form relative to that?

More code in case it's wanted.

mymodule_form_alter (&$form, $form_state, $form_id) {

...

if (user_is_anonymous($user)) {

    $admin = user_access('administer users');

    $form['administer_users'] = array(
       '#type' => 'value',
       '#value' => $admin,
    );

    $form['#user'] = drupal_anonymous_user();
    $form['#user_category'] = 'register';

    $form['#attached']['library'][] = array('system', 'jquery.cookie');
    $form['#attributes']['class'][] = 'user-info-from-cookie';

    $account = $form['#user'];
    $register = ($form['#user']->uid > 0 ? FALSE : TRUE);

    $form['#validate'][] = 'user_account_form_validate';

    $form['account'] = array(
      '#type'   => 'container',
      '#weight' => 61,
    );

    .... //form elements for user reg like password, username email etc. go in here...

    $langcode = entity_language('user', $form['#user']);
    field_attach_form('user', $form['#user'], $form, $form_state, $langcode);
    foreach (field_info_instances('user', 'user') as $field_name => $instance) {
      if (empty($instance['settings']['user_register_form'])) {
        $form[$field_name]['#access'] = FALSE;
      }
    }

}


texts: How do I retrieve values from a webform?

texts:
I can see the values submitted in the $_POST, so I know they are there, but when I uses a submit handler to retrieve them, I get NULL. I'm fairly new to PHP so not sure if it's a simple syntax mistake or something more. Thanks.

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

  if ($form_id == 'webform_client_form_47') {

    $form['#submit'][] = "zendesk_forms_support_form_submit_handler";
  }
}

function zendesk_forms_support_form_submit_handler($form, &$form_state) {
  form');
  $ticket = array(
      'description' => $form_state['values']['description'],
      'subject' => $form_state['values']['subject'],
  );
  echo $ticket;


texts: Add new items to a multivalue field instead of override existing values

texts:
I have an Article content type with a multi-values taxonomy reference field (field_article_countries) for the Countries vocabulary. I also have a Book content type with a multi-values taxonomy reference field (field_book_countries) for the same vocabulary.

I am trying to:

Loop through all the loaded articles one by one
Get all the field_article_countries values
Set those values to field_book_countries
Save the loaded Book node

For example, a Book node (ID 12) has field_book_countries set to none. An Article node (ID 3) has field_article_countries set to Italy; another Article node (ID 40) has field_article_countries set to Greece, Turkey, Egypt, Brazil, Spain.

I want to:

Load the first Article node
Get the value of its field_article_countries (Italy)
Load the Book node and set its value of field_book_countries to Italy
Load the other Article node
Get the values of its field_article_countries (Greece, Turkey, Egypt, Brazil, Spain)
Set the field_book_countries values for the Book node to Greece, Turkey, Egypt, Brazil, Spain, Italy
Save the Book node

The code I am using to achieve this is the following.

$articleIDs = [
  '3',
  '40'
];

// Load all the articles.
$articles = \Drupal\node\Entity\Node::loadMultiple($articleIDs);

// Loop through the loaded articles.
foreach ($articles as $article) {
  // Get the "Countries" Values.
  $countries = $article->get('field_article_countries')->getValue();

  // Set the 'countries' values to the node "book".
  $book->set('field_book_countries', $countries);
  // $book->field_book_countries[] = ['target_id' => $countries];
}

// Save the Book node.
$book-->save();

However, for some reason and during the loop, the new values of field_book_countries are overriding the existing one.

What am I doing wrong?


texts:
I'm trying to retrieve a value from a Node object. It looks like the value is there, when debugging and checking out the object. But somehow it cannot be accessed.

Trying to get the field:

// $this->entityManager is an instance of EntityTypeManagerInterface
$node = $this->entityManager->getStorage('node')->load($nodeId);

// hasField always returns FALSE
$node->hasField('field_google_hire_identifier');
// $node->get('field_google_hire_identifier'); returns unknown field error

Debugging $node->hasField, looking inside getFieldDefinition:

  public function getFieldDefinition($name) {
    if (!isset($this->fieldDefinitions)) {
      $this->getFieldDefinitions();
    }
    if (isset($this->fieldDefinitions[$name])) {
      // This code should be executed, but it is not.
      return $this->fieldDefinitions[$name];
    }
  }

The second if statement content is not executed, with my understanding it should be.

The node was created with migrate.

I disabled APC and Opcache.


texts: How to load paragraph entity on node object?

texts:
I'm using paragraphs in my content type. I've created a paragraph type and added content. Now I want to load the paragraphs in a foreach. But nothing's showing up. $paras is empty:

$node  = \Drupal\node\Entity\Node::load(1);
$paras = $node->get('field_paragraph')->referencedEntities();


texts: How do I set up an action to email all users with a certain role?

texts:
I'm using Rules 7.x-2.6 and the way it works has changed a bit since I last saw.

I have a rule as follows:

EVENT
A node has been flagged, under "Report content"

CONDITIONS
None

ACTIONS
Send mail to [site:mail]

However, I'd like to, instead of sending directly to [site:mail], send an email to all users flagged with an "admin" role.

Now I know that I'll need to provide a loop do so, but my sticking point is generating the list of users to pass to the loop. So far, I have attempted to add a new action:

"Fetch entity by property"
Entity type: User
Property: User roles
Value: admin

But this doesn't seem to give me what I want in data selection, when passing it to the loop. Can someone recommend what they would set here?


texts:
I am not able to login on my site.  All the times I try, I get this error:

  Sorry, unrecognized username or password. Have you forgotten your password?

I checked 10 times, but the password I use is correct.

I am not sure what happens; even if I try to create a new account, and login, I still get the same error.

I was able to login with that username and password previously, even on live, where I am still able. It is just on local where I cannot login anymore.

mod_rewrite is enabled on the server, so the problem cannot be that. I noticed that the session is automatically destroyed, for the administrator user.

Why does this happen?


texts: Why does DRUPAL_BOOTSTRAP_PAGE_CACHE phase come before DRUPAL_BOOTSTRAP_DATABASE?

texts:
According to this article about drupal_bootstrap function, all parameters for drupal_bootstrap() run sequentially. And if we see the sequence, here first comes - DRUPAL_BOOTSTRAP_CONFIGURATION, second DRUPAL_BOOTSTRAP_PAGE_CACHE and then database (DRUPAL_BOOTSTRAP_DATABASE),

So, My question is cache is itself stored in database, so in order to serve pages from cache, a database connection is a must. Then How Drupal manages these calls sequentially?

Accordingly, DRUPAL_BOOTSTRAP_DATABASE should come before DRUPAL_BOOTSTRAP_PAGE_CACHE. If not, what is the reason?


texts: Unable to evaluate action (commerce recurring)

texts:
I'm using commerce recurring module in my project (along with few additional commerce modules like card on file, invoices and few more). Recurring was working fine around 10 days ago. Since then I continued with development of other areas.

I came back to testing recurring payments and there's a problem with it during cron job rule/acion. I get following three errors in following order

Notice: Trying to get property of non-object in commerce_product_line_item_populate() (line 1354 of /site/public/sites/all/modules/contrib/commerce/modules/product_reference/commerce_product_reference.module).

Unable to get a data value. Error: Invalid data value given. Be sure it matches the required data type and format.

Unable to evaluate action commerce_recurring_generate_order_from_recurring.

I'm stunned and stuck, no idea where to start looking. Everything was fine before. I installed few other modules in the meantime, also did some custom coding, but nothing that would address or impact core recurring module setup or rules. Not even sure how to start debugging it

I've discovered there's a problem with this function on line 504 in commerce_recurring.rules.inc:

$line_item = commerce_product_line_item_new($product_wrapper->value(), $recurring_entity->quantity);

This is where errors come from. $product_wrapper->value() returns an empty Array


texts: How to add background image in my theme which uses color module?

texts:
In my theme i want to add background image instead of background color provide by the color module.

i don't want the background color set by color module instead i want to add background image, is there is any way to do this?, please suggest me.


texts: I have a site that is translated in English and French - can't change "Home" link in menu

texts:
My entire Drupal 8 site has been translated except I can't find where to change the translation of the "Home" link. When the site is in French mode (with the /fr) all my menu items show the appropriate French translation except for "Home" which I would like to read "Accueil" when I've switched to French.
Thanks for any insights.


texts:
I have a use case that I need to add the retail price on a receipt twig next to the discounted unit price. Ive tried every possible field syntax I could think to try, looked everywhere and stumped...

{{ order_items.i_need_the_retail_price... }}

Is it possible to get that related field with twig syntax? It doesnt appear to be carried into Order Items.


texts: Organic groups chat - what are my options?

texts:
I have several organic groups which has members added. I want to a chat system that allows members within the same group to communicate amongst each other.

What modules can i do to achieve this? what are my options? I am running drupal 6.


texts: Changing the field separator for multivalue fields

texts:
I have a problem which should have a simple solution, but I simply can't figure it out. Perhaps I'm overthinking it or missing some piece of information. Being new to drupal it's not unlikely at all.

I'm trying to output a list of links through a View. No matter which Format I chose (unformatted list, grid, etc.), Drupal never fails to add a comma between each link. I'm having a great deal of trouble removing this comma.

Setting a separator under Field Settings have no effect, but I guess that's only applicable if I had another list of links.

I have tried editting 'views-view-field.tpl.php' by adding the line:

<?php $field->field_associated_quicklinks->separator = ""; ?>

But it doesn't seem to work. PHP and I aren't on friendly terms, so I'm loathe to start messing too much with the scripts - unless I got some helpful tips from you guys.

All in all I'm stuck on this, and frustrated that I'm having this problem in the first place. Drupal shouldn't go around adding content to my output.

------ EDIT:
Well, after several hours and a few tufts of hair, I found this great vid: http://www.youtube.com/watch?v=sxZQqgvJk3sI believe it's exactly what I needed to know, but I still can't make it work.

I did as prescriped:
1) Copied the field.tpl.php file, removed the comment and changed the mark-up a bit.
2) I named the file 'field--field_associated_links.tpl.php' and copied it into the templates folder of my sub-theme.

I get no reaction whatsoever. Could it be confused by the fact that my field name starts with 'field' as well?

Any and all suggestions are very welcome!


texts:
I'm using Drupal 7, and I have a node type that has an image and body text.  I want the display for this node to display the image inline with the text (ie, apply float:left to the image).

Is there any way for me to do this through the frontend, or will I have to manually change the CSS for the image field's class?


texts: Maintenance page being rendered as an entire page load after the main page load

texts:
I've noticed that I've got a maintenance page being rendered in its entire HTML markup format after my pages. The site is not in maintenance mode, and this is not intentional behaviour. I'm trying to debug, but even as a reasonably experienced Drupal developer I still don't understand all the mechanisms at work here. Guidance on that would be welcomed.

I had been using the module CDN, to experiment with integrating a CDN. That was using that area at the bottom of the page, but when I disabled it, and uninstalled it, it has not stopped the problem.

I then enabled Theme developer 7.x-1.x-dev just to help me see what was going on, and the maintenance page render has stopped appearing. I then disabled Theme developer again and it has returned. Does this help anyone to suggest something?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

[...]

This also displays on my admin theme. Does this mean it is not something to do with my custom theme? Is there anything in particular that I could look or has anyone seen this behaviour before?


texts:
We installed the metatag module,
and we activated all metatag entries on the modules administration page.
On the module settings
we selected content type Node:article and went to Open Graph.
We edited the tag image with the value [node:field_image],
the same for tag image url

In the page source, we checked the meta properties:
"og:image" content="https://domain name/sites/default/files/field/image/name of image.jpg"
"og:image:url" content="https://domain name/sites/default/files/field/image/name of image.jpg"
Using this internet address directly in the browser, the article image is displayed as expected.

Meanwhile, Facebook still does not show the article image. The main logo image is shown, even after emptying the cache of the Drupal site and the cache of the browser.

What does go wrong?


texts: Finding the code generating the menu with links

texts: Where is the code that generates the menu and links shown in the following photo?


texts: Create a views chart that display the percentage progress of some tasks over each week

texts:
I have successfully created multiple charts in views using Google Chart Tools, but this one is tricky;

Here are the entry dates:

I have multiple tasks that are Nodes and each one of them have a 'date field' for planning date and a 'date field' for date actually completed.
I need to create a chart in views that display the percentage of tasks planned and completed over each week. This chart will be linear and it has to display the values in a progression.

I've managed to get percentage for each week for both planned and completed date, knowing of course the total number of tasks. Also i have created the linear chart that display the weeks number on the X-axis and the amount of percent on the Y-axis, but the values are displayed independent for each week and not in progression as I want.

Example:

Week 35: 3 task planned (30%), 2 completed (20%); Week 36: 3 tasks planned (30%), 3 completed (30%); Week 37: 4 tasks planned (40%), 3 completed (30%). Total: 100% planned, 80% completed.

The chart values must be displayed as:

Week 35: Planned 30% / Completed 20%;
Week 36: Planned 60% / Completed 50%;
Week 37: Planned 100% / Completed 80%;

I need a function that adds the previous value to the next one to display the chart progressively until 100%.

Suggestions?


texts: How to add "new" icon on node view page for predefined time frame

texts: I would like to add "new" icon on node view page of some content type for a predefined time frame after the node content is created or updated. For example, I would like to display "new" icon on the top of node view page for 2 weeks after the node content was saved. I found this for Views but need it for node page. Is there anyway to achieve this?


texts: How to access an Ajax callback return value?

texts:
First a confession: I did not write the JavaScript reproduced below. Unfortunately, I am a rookie JavaScripter, and this script was scavenged from another project and slightly adapted by me.

The script is using a jQuery function to flip the CSS of a webpage to expose an "active" category tabs list item and hide the rest (i.e. it lets the user navigate between tabs on a single Drupal pages without suffering the delays of reloading the page from the server).

It works as intended.  Here is the code (rbg.js);

(function ($) {

Drupal.behaviors.rbg = {};

Drupal.behaviors.rbg.attach = function(context) {
  // set default Category tab if one is set in URL anchor
  var anchor = window.location.hash;
  if (anchor) {
    $('.rbg-category-tabs a.active').removeClass('active');
    $('.rbg-category-tabs li a[href=' + anchor + ']').addClass('active');
    $('.panel').hide();
    $(anchor).show();
  }
  // show the selected category panel
  $('.rbg-category-tabs a').click(function() {
    $this = $(this);
    $('.panel').hide();
    $('.rbg-category-tabs a.active').removeClass('active');
    $this.addClass('active').blur();
    var panel = $this.attr('href');
    $(panel).fadeIn(330);
    $('input[name="category"]').val(panel);
    return false;
  });

};
}(jQuery));

I use this to add the Javascript to my Drupal site:

// Add javascript.
drupal_add_js(drupal_get_path('module', 'rbg') . '/rbg.js');

I want to know the value of the variable anchor on the next Drupal page load, I am simply unable to figure out how to do it.  I've tried to read up on Drupal's Ajax framework, but I am unable to figure it out on my own.


texts: What is the simplest way to transfer webform /data/ from one instance to another?

texts:
I have much webform data that I want to move from a data entry instance to a testing instance, but I don't want the entire database.  What is a simple recipe for exporting and importing drupal webform data.

I know about the webform export / webform import modules, and the import module that this is possible, but I can't find the correct combination of parameters that makes it happen.

Thanks


texts:
I have the following hook in mymodule.module
function mymodule_preprocess_views_view_unformatted(&$variables) {
  $view = $variables['view'];
  $rows = $variables['rows'];

  if (in_array($view->id(),
      [
        'my_view',
      ]
    )
  )
    {
        foreach ($rows as $id => $row) {
          $custom_row_class = 'card-background-' . get_card_background();
          var_dump($custom_row_class);
          $variables['rows'][$id]['attributes']->addClass([$custom_row_class]);
        }

      var_dump($variables['rows'][0]['attributes']);
    }
}

The output is:
/Users/me/Sites/mysite/web/modules/custom/mymodule/mymodule.module:55:string 'card-background-11' (length=18)

/Users/me/Sites/mysite/web/modules/custom/mymodule/mymodule.module:58:
object(Drupal\Core\Template\Attribute)[7400]
  protected 'storage' =>
    array (size=1)
      'class' =>
        object(Drupal\Core\Template\AttributeArray)[7223]
          protected 'value' =>
            array (size=1)
              ...
          protected 'name' => string 'class' (length=5)

Right after supposedly adding the class to the rows attributes, it isn't there, and not surprisingly isn't in the attributes value passed to views-view-unformatted.html.twig.


texts: In order to help pay for our drupal 6 website we need to be able to derive some revenue from banner ads.  I am looking for suggestions on how to implement banner ads utilizing google type ads (or someone else) so that the ads display within a predefined rectangle and if the users clicks on an ad (which takes them to a new tab/page) it gives our company some revenue.


texts: Is there way to create regions for view modes programmatically?

texts:
So I have programmatically created a view mode and I need to theme it. The view mode will be rendered via views modules for different content types and The structure requires that I separate fields into to separate regions. A image region and content region. The different content types will be able to choose the fields they want for each region. So event may use featured image, while news article can use hero image field.

I really don't wan't to use display suite if there is some programmatic way of doing this.


texts: Terrible views performance for multi-value date fields?

texts:
EDIT: I created a Drupal issue for this: https://www.drupal.org/node/2846485

In D8, I have a content type "Event" with a multi-value DateRange field called "Date". I have one single event node, and this event node has 100 values for the date range field (1 daterange value per day for 100 days).

I've created a view that outputs a row for each occurrence of the event. I accomplished this by having the view output Fields, and added the "Title" and "Date" field. For the "Date" field configuration, I have it set so that it will render a row for each value of the field, so 100 rows end up being returned like this:

Without render caching enabled, it takes 20 seconds for the results to render. With render caching enabled, and the cache primed, it takes 0.5 seconds.

With the cache disabled, I would expect it to take a bit longer, but not 40 times longer. The reason I'm testing with the cache disabled is that I don't want my site to be taken down after a cache clear, especially since this view will eventually be on the homepage (although with the result set limited a bit). So I'm interested in doing whatever I can to speed up initial rendering of these items.

I used BlackFire profiler to figure out what's going on. It revealed that DateRangePlainFormatter::buildDate is called 20,000 times and took 15 seconds of the total 20 second time:

I can sort of figure out the 20,000 number. There are 100 rows output, one for each date occurrence. Then for each row, views must be trying to render all 100 dates AGAIN. And all that happens twice I guess for some reason?

Ideally views would only call out to render the date fields 100 times, one for each date that's output. I would even settle for 200 times, but 20,000 seems like a bug somewhere.

It looks like I'm going to be spending a lot of time looking deep into views rendering, but hopefully someone can save me some time!

Can anyone point me in the right direction on how to solve this?


texts: Is it possible to make the Wysiwyg module use the CKEditor's CDN for delivering the editor to the browser client?


texts:
I developed a custom module in Drupal 7. I asked a similar question here:
Drupal 7 Get field value by machine name and pass to javascript

But the difference in this question is, instead of a taxonomy term, I want to get the field value of a regular text field.

Here is the code that I use to get the field value of a taxonomy term to pass to javascript, which currently resides in my theme's hook_process_page function:

if ($node = menu_get_object('node')) {
  $tid = $node->field_test['und'][0]['tid'];
  $term = taxonomy_term_load($tid);
  drupal_add_js(array('mymodule' => array('test' => $term->name)), 'setting');
}

Some things that I can see might ned to be changed right away are "tid," "taxonomy_term_load."

How can I change this code to instead get the text value of a field instead of a taxonomy term, to pass to mymodule?

EDIT:

Per a suggested change, I've modified the code, though I'm not sure this is what was meant:

if ($node = menu_get_object('node')) {
  $fieldValue = $node->field_test['und'][0]['value'];
  $term = taxonomy_term_load($fieldValue);
  drupal_add_js(array('jsblock' => array('test' => $fieldValue->name)), 'setting');
}

The in response to Drupal.settings.jsblock.test, the console outputs null.

Here is the Drupal notice:

Devel results:

How can I get the field value and pass it to my jsblock module?


texts:
I made my own custom cache context by creating the service which links to a class which implements CacheContextInterface, and it seems to work, but the problem is, on page load, it doesn't seem to check if the context itself has changed.  Neither the getContext() function nor the getCacheableMetadata() function runs on page load.  If, for example, I go to a page that is a different route, it will run those functions for my cache context, as well as others.  Also, if any cache tag on any page is invalidated, it will go to my custom cache context and update, but otherwise it will remain cached.  How do I get that same invalidation goodness that different routes seem to have?

I notice, in core's core.services.yml, the cache_context.route service depends on the current_route_match service, which links to CurrentRouteMatch.php and depends on the request_stack service.  Which of these things is what causes Drupal to end up checking if the route has changed?  I want to do this same thing for my custom cache context.

Will I have to depend on some core service, or is there something I can put in either a service definition (in the module's services.yml) or the service class itself that says it wants to be updated?

EDIT: What was happening was that I put this new context on a block which loads on the main page, and it was indeed checking the context only for logged in users (just as 4k4 said) but for anonymous users, on page load, it wasn't checking the context so it wasn't updating the block.  I guess when it comes to requiring a cache context for anonymous users, it would be better to have the page invalidate more frequently, or get the content with ajax instead.


texts: new submit button to node form not displayed?

texts:
When i try to add a new node of type article for example i want to add a new submit button with new submit function so i did like this in hook_form_alter :
function MYMODULE_form_alter(&$form, &$form_state, $form_id){
  switch ($form_id){
        case "article_node_form" :
            $form['submit_delegate'] = array(
                '#type' => 'submit', // I tried also '#type' => 'button'
                '#value' => t('Delegate'),
                '#submit' => array('MYMODULE_form_submit_article_delegate'),
            );
            dpm($form);
            break;
  }
}

this is the dpm result of the new form element :

submit_delegate (Array, 3 elements)
type (String, 6 characters ) button
value (String, 8 characters ) Delegate
submit (Array, 1 element)

Thanks in advance.


texts: Change jQuery version with hook_form_alter

texts: How do I change the jQuery version used for a form with a specific form ID?


texts: How to modify the commerce price formatter label to match shipping service?

texts:
Please see attachment. Using Commerce Kickstart 2.

I have a working solution, but I am hoping someone can tell me how to improve it, as it 'feels' poor.

The footer for the default shopping cart view is a footer called commerce_order_total which shows a subtotal for each line item type... typically labeled 'Subtotal' for products and then a generic 'Shipping' label for shipping line items.

That generic 'Shipping' label is hated by our customers. They expect to see the actual shipping service (UPS, Fedex, etc.) So I created a work-around, which I show below, but I fear it is not an efficient solution... basically I just made a tweaked copy of the default commerce code for the price formatter.

What I hope to improve...

Surely there must be a more robust way for the footer to be 'aware' of whether the page being viewed is a cart or an order from history without having to look at the URI, right?
And is there a faster/cheaper way to retrieve the shipping service without loading the entire order -and- all line items?
I was thinking there must be a more granular way to override the description of 'Shipping' in that footer without having to re-invent the entire wheel. I just gave up and did the old cut/paste.

TIA,

---JC

function MYTHEME_commerce_price_formatted_components($variables) {
  global $user;
  $line_item_title = '';
  $order_number = '';
  $path_parts = explode('/', request_path() );
  if( sizeof($path_parts) == 4 && $path_parts[0] == 'user' && $path_parts[2] == 'orders') {
    $order = commerce_order_load($path_parts[3]);
    // dpm($order);
  }
  if( isset($order) && !$order )
    $order = commerce_cart_order_load($user->uid);
  if( isset($order) && $order) {
    foreach ($order->commerce_line_items['und'] as $line) {
      $line_item = commerce_line_item_load($line['line_item_id']);
      $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
      // line item TYPE display title
      $line_item_type_title = commerce_line_item_type_get_name($line_item_wrapper->type->value());
        // for shipping line items
      if ($line_item_wrapper->type->value() == "shipping") {
          // shipping data
        $shipping_data = $line_item_wrapper->value()->data;
          // shipping method display title
        $line_item_title = $shipping_data['shipping_service']['title'];
      }
    }
  }
  // Add the CSS styling to the table.
  drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');
  // Build table rows out of the components.
  $rows = array();
//  dpm($variables['components']);
  foreach ($variables['components'] as $name => $component) {
//    dpm($component);
    if($component)
    $rows[] = array(
      'data' => array(
        array(
          'data' => ($component['title'] == 'Shipping' && $line_item_title ) ? $line_item_title :  $component['title'],
          'class' => array('component-title'),
        ),
        array(
          'data' => $component['formatted_price'],
          'class' => array('component-total'),
        ),
      ),
      'class' => array(drupal_html_class('component-type-' . $name)),
    );
  }
  return theme('table', array('rows' => $rows, 'attributes' => array('class' => array('commerce-price-formatted-components'))));
}


texts: How do I trigger an event when a button is clicked on a user profile?

texts:
Let's say I want to make a bunch of nodes based on what's in a specific field when someone clicks a button on their user profile.

Is this possible with a custom built module? And if so what hook would I use to display that button on the user profile, and how would I get it to call a custom function on click?


texts: migrating from localhost to server - What to do with the folder sites/localhost.mysitename?

texts:
I am trying to migrate my site from acquia dev desktop (local host server) to bluehost.
In my site on my computer I have inside the "sites" folder, 3 folders:

all
default
localhost.mysitename

Inside localhost.mysitename I have the "files" folder, and inside that I have the following folders: adaptive theme, banner, color, ctools, custom_search, custom_search, feeds, pictures, styles, styles. in addition I have the ".htaccess" file and many pictures and logos of the site.

Should I change the folder name of "localhost.mysitename" to only "mysitename"?
Should I change it at all or to other name?


texts: Is there a Drupal module that would allow you to use custom tables for making hotel and trip bookings and reservations? In my project, I have to use a specific API from a third party tour operator for gathering data for the offers, and displaying them. Thank you in advance.


texts: Can't seem to edit page title in og/users/%/add_user

texts:
In our what should be titled "Add Users", both H1 and title both contain the value "Home". I have even tried to overide with another module's hook_menu_alter.

function hook_menu_alter(&$items) {
   $items['og/users/%node/add_user']['#title'] = t('test');
}

Page.tpl.php is untouched:

<?php if ($title && !$is_front): ?>

<?php print $title; ?>

<?php endif; ?>

Any idea of other areas I should try?


texts: Using Rules Drupal Commerce Get Product Sku Field

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

Still trying to skin the same cat. I have a Drupal 7 Commerce site. I've created a Rule which Executes Custom PHP to collect the unit price from an external database via PHP.

I'd show you the Export but it looks -ugly- at this point as Drupal is formatting the code with lots of escs. Anyhoo... It (almost) works except that I need to access the Product ID for the line item.

EVENT: Calculating the sell price of a product
CONDITION: Entity Has Field FIELD: commerce-line-item VALUE: commerce_product
ACTION: Set Unit Price To A Fixed Amount

So the Execute Custom PHP looks like this:

    $data = 'name=value&name1=value1';
    $options = array(
        'method' => 'GET',
        'data' => $data,
        'timeout' => 15,
        'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
    );
$result = drupal_http_request('http:test_vendor_site.com?Svc=Start?CartID=12345&Cust=443030&Cntact=2254&ProductID=something', $options);

// Parse the $result to $new_unit_price code in here...

$value = $new_unit_price * 100;
return $value;

...all I need to get this working is to retrieve the Product ID in here so I can add it to the URL I'm passing to drupal_http_request. How do I do this? I thought by adding the Entity Field condition I could access the Product variable for the line item but I'm obviously not addressing them properly.

Any ideas?

TIA,

---JC


texts: Default value for datetime field definition in content entity?

texts:
I have the following datetime field definition for my content entity:

$fields['start_date'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Start date'))
  ->setDescription(t('Start date in GMT time.'))
  ->setSettings([
    'default_value' => DrupalDateTime::createFromTimestamp(time()),
  ])
  ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'string',
    'weight' => -4,
  ])
  ->setDisplayOptions('form', [
    'type' => 'datetime_default',
    'weight' => -3,
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

As a result, when creating a new entity, I get the field display without default value set in a form. I also tried setDefaultValue method but with no luck.
What is the proper way to set the default values for the custom content entities?


texts: How to export Panels and Mini Panels with Features?

texts:
I am trying to export the Panels and Mini Panels on my website with Features.

On the features drop down menu, there is an option for "Panels: panels_renderer_pipeline". However, when I click on it, no checkboxes appear.

I have looked though the "StrongArm" option but cannot find anything related to Panels and Mini Panels.

Thanks for any help!


texts:
I'm trying to reduce repetitive coding by adding my own static HTML content into some form of reusable token that can be added into page bodies amongst regular code, but can't find a method. Here's what I'm looking for:

Desired content to be inserted into page body

I type this all the time and want to automate it

Token idea to insert this into a page Body

Here is some regular content

[token:my-repetivie-div]

and some more content appearing after my-repetitive-div

End result

Here is some regular content

I type this all the time and want to automate it

and some more content appearing after my-repetitive-div

This question is similar to this one, but he didn't quite get a straight answer, so I'm spelling it out here.

The Token Filter module wasn't what is needed, as it only addresses using pre-existing Tokens not creating custom ones. Would the Custom Token module achieve this?

If there's a better way to achieve this other than Tokens, i'm all ears!


texts: How do I unhook commerce_kickstart_blog_preprocess_node?

texts:
I am using Commerce Kickstart 2 with the their blog module, which includes a hook_preprocess_node() I need to short-circuit.

I looked at How to "unhook" a hook from a module? and I thought I could put the following in a module.

function my_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'commerce_kickstart_blog_preprocess_node' && isset($implementations['commerce_kickstart_blog_preprocess_node'])) {
   unset($implementations['commerce_kickstart_blog_preprocess_node']);
  }
}

It doesn't do anything. What am I doing wrong?


texts: Pressflow 6 forms creating session cookies

texts:
We have a Pressflow 6 website behind a Varnish cache but our cache hit-rate is awfully low. I've recently found that stripping the "Cookie" header from requests completely increases the hit-rate to 97-98%.

The vast majority of our users are anonymous, so Pressflow shouldn't be setting a session cookie, however we do have a number of forms on the site and it seems that when someone uses a form a session cookie is set in their browser. The forms aren't fancy, the page they submit to just says "thanks for your comment" so there's no need for a session as POST requests aren't cached anyway. The cookie's lifetime is about a month and a half too.

I was considering stripping the cookies when there's no "DRUPAL_UID" cookie, however I'm loath to remove them all in case there's a legitimate reason for them being set.

So, two questions:

Is there a legitimate reason for these cookies being set?
If not is my best option to get Varnish to strip them out or is
    there a way to prevent them from being set or to remove them within Pressflow?


texts: Automatically create and assign terms based on url

texts:
How can we automatically create and assign taxonomy terms based on the URL?

For instance: /climate-change/statistics/new-zealand/polar-bear-maulings

Existing terms: climate-change, statistics

How can Drupal assign climate-change, statistics to the node, and also create and assign new-zealand and polar-bear-maulings to it as well?


texts: How to flag term reference without flagging term?

texts:
I need do something like the skills system in linkedin.

The logged user with role "employee" have a profile2 called "employee". In this profile I need add a term reference field where the user can add his skills or create some skills new by Autocomplete term widget (tagging)... Like in linkedin.

After that, the other authenticated users can confirm the single skill of a user.

I tried to do this with taxonomy, term reference field (in the profile2 "employee") and flag... The problem is that if a user add the skills by term reference field, eg. term1, term2, and an other user confirms (flags) that skills, the terms are flagged for all users. So if an other user add term1 and term5 the current user visits his page and the term 1 is alredy flagged.

Can you help me?


texts: Remove a contextual filter programmatically

texts:
Is there a way to programmatically remove a contextual filter from a view? I have a view where, at times, I want to display it without the contextual filter active. This is the code I tried.

function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'some_view') {
    unset($view->args);
  }
}

I also tried the same code within hook_views_pre_execute().

How can I achieve this?


texts:
I have a drupal 7 site.

Running a auto login feature when people click on my newsletter.

A hook is fired when they visit the site to check for the cookie.
my setup :
Background info : I am already using Memcache, APC, Varnish,

2 Varnish Servers (8 GB)
1 Db percona server (32 GB)
1 HaProxy 4
Webservers, 16 GB

my question is, Performance wise. I can see that my server cannot handle 8000 users logging in.

Is there any way to make this impact on the server more "soft" in terms of performance. So my DB doesnt go down. when 8000 request auto login at the same time.

Example 1.

Ex: 1 request to auto login, causing 3-4 query to DB via  the core Drupal API if so if I get 1000 users at the same time I got 3000 queries to DB -> DB cannot handle the load. What to do ?!

Best regards

Victor


texts: I'm new to drupal and I have read about view UI module in many places but was not able to find what exactly it is.Can any one help me on this ?


texts: How to output just a page's contents in page.tpl.php in Drupal 7?

texts:
I am creating a page.tpl.php template in Drupal 7 in which I want to rearrange how certain elements of the page are laid out. Specifically I want the title of the page to appear before the tabs and messages section (which I have done) and have the content of the page appear after the tabs and messages section (this is where I run into issues). I can't find a way to just render the $page['contents'] without the title. Is there a way to achieve this in Drupal 7?

I know that the node.tpl.php template handles the node specific layout, but it doesn't allow me to layout the page like as described above.

Thanks.


texts: Passing multiple values in fields as mentioned in another field (as number of values) by user

texts:
I want a field that upon getting a value in a text field (eg. 1, 2 anything) shows respective fields.
If user inputs 5, then five fields will appear (similar to multiple values of a field, unlimited)

How can I make this possible?
There is a conditional module that provides UI for state API but is that enough for the working?


texts: Using a Views Output as Options in a Webform in Drupal 7?

texts:
I have a list of articles on my site and currently I have a View that lists all of these articles. I want to be able to build out a webform where a user can select certain articles and then have it emailed to an address. I basically want to turn the Views list of articles into a radio button box where it can be selected for inclusion into the webform.

Are there any modules that can do this? Or how would one go about doing this if there is no module that supports this.


texts: How can a user choose items from a view?

texts:
I've 3 types of users:

Author
Reader
Site Admin

What I've done so far?:

I've created Content Type named Book. Authorscreate account on my site & login & then add the information about the books they authored. I've a View with page-display named books which lists all the books.

What do I need?

Reader should be able to pick 'x' no. of books from the this view. The no. of books a Reader can pick depends on his level Voracious Reader, Moderate Reader, Occasional Reader.
After Reader choosing Book(s), Site Admin will be see the list of books picked by all Readers.
He'll then ship  the book to their address (offline) & update the status as "Shipped".
of course Readers should be able to see the list of all the books they've chosen along with its status.

How do I accomplish the rest?


texts:
I have just built a view for one of my modules.
In there, I have this line; %of Applicants Admitted`

I already installed modules like "Locale", "Content Translation" and "Internationalization" is already enabled.
But I dont understand how these modules will translate this text to other languages.
When I put it in t('') how will I know that it will translate it correctly. Can I manually enter the translation?

Thanks


texts: How to print custom date format in Twig?

texts:
How can I print a custom date format in Twig?  First of all my I am trying to edit the field.html.twig of the field called field_publication_date, in that file I find this variable {{ item.content }} which prints   Jun, 12/06/2016 - 12:29.

This is what I have tried: {{ item.content.field_publication_date|format_date('M') }}


texts: Can I turn a regular content type into a Commerce product display?

texts: I have an existing working site with lots of content. I've come to the realisation that I could actually sell this content. So is there a way to turn my existing content type into a product display for Drupal 7 Commerce or would you recommend to export all these nodes and create a new product display type and add them back in?


texts: How to add a custom link to login form block with hook_form_alter

texts: How to add a link with custom path to my login block with hook_form_alter. I 've created a custom module but i dont know what to add to my hook_form_alter function.


texts: Request body to post a new comment using REST API

texts:
I have a comment type and content type with field from type of that comment type.
I also using Rest and Rest UI modules. I want to insert new comment on specific node using rest API using POST request.

In the REST config page, I have this service enabled

What I want to do, what is the request body should be to insert new comment successfully through Postman.


texts: Form API-passing on the NID in a hidden field?

texts:
So, here's my issue. I have a university course page. I want to display a list of students currently weight listed for the course, and give the option for the student to add their name to the weight list.

I've outputted the current student weight list through a custom template file just fine. I've also made a one button form through a custom module that simply calls a submit function. Then I call that form on my node template. That part works all fine.

Then, all I need for this form to work is the current User's UID (which can be called easily from my form submit function in my module). And the NID that their name should be attached to. Where I'm having difficulty is the NID part. I can't figure out how I can add that to my custom form built through my module with Form API.

Right now, I'm setting a variable and calling that variable in the submit function.The problem there is it will screw up the system if more than one student is looking at different pages and submits it. So there needs to be way that I can set the current NID that the form sits on, then call it through my submit handler.

I've been searching google up and down for this, and I can't figure out how to set a hidden field with the current NID the form is on.

Any help would be greatly appreciated.

Edit: Here is my code currently for reference:

function wl_add_form($form_state) {

 $form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Add Name to List'),
  '#submit' => array('wl_add_form_submit_function'),
);

  return $form;
}

//Add me to weight list functions
function wl_add_form_submit_function($form, &$form_state) {

//dpm($form);
  //Handle the student add
  global $user;
  //get the User ID
  $userID = $user->uid;
  //get the NID from the node variable we set in the node-course template:

  $nid= variable_get($wlNID);
  $node = node_load($nid);
  $count = count($node->field_course_weight_student);
  $node->field_course_weight_student[$count]['uid'] = $userID; // another user
  node_save($node);
  drupal_set_message(t('Your name has been added to the weight list'));

}


texts: Slideshow background images in Background

texts:
I'm building a site in Drupal 7. Using the JCarousel module I'm trying to create something similar to this:

http://dale.no/

It's simple enough to create a full width slideshow and adding text over images is not too bothersome with a few adjustments to CSS.

But is it possible to make the images into backgrond CSS images, the same as on the dale.no site? The reason is, when you resize the browser, or use a different size monitor, I would like the centre of the image to remain in the centre of the browser. At the moment, on a square monitor, the centre of the images are cropped by the right hand side of the view port.

Is this possible with this module? Are there are other modules that can achieve this?


texts: Too many "insert" queries to the "cache_views" table.

texts:
I have a bad performance in my website.

Checking the database queries I see that there are too many "insert" queries to the "cache_views" table.

How can I start to trace this problem?


texts: Show advanced search form outside fieldset

texts:
When I search for a keyword in core Drupal search, it shows a results page with a link named Advanced search that hides a fieldset with more form options. I want it to be shown in the basic search form, not only on search result page, and it should be expanded by default.

Note: I want all this with core search in Drupal 7.


texts: Correct way to alter markup as html within theme_preprocess_container?

texts:
On my node edit form I've got a field widget that needs some information added to it. Before my alterations, the kint dump of $variables['children'] looks like:

However, after manually setting $variables['children'], the dump looks like:

Before alteration, html renders correctly. However, afterward it is all just rendered as a string with the HTML displaying on the page.

I've tried using the create() method instead that's shown as available under:

...but it doesn't do anything at all.

I've also instead tried changing $variables['element']['display']['#markup'], but that doesn't have any visible effect.


texts: How do I add a Site Information variable and make it multilingual?

texts:
So I've used form alter to add in a site information variable (which auto-saves because it's a system_settings_form), but I can't seem to get it to show up as multilingual.

Here is my form alter to add the field:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function omm_form_system_site_information_settings_alter ( &$form, &$form_state ) {
    // Add field in Site Information area of admin configuration.
    $form['site_information']['site_pretitle'] = array(
        '#type' => 'textfield',
        '#title' => t('Site Pre-Title'),
        '#description' => t('This will appear above the website name on all pages.'),
        '#default_value' => variable_get('site_pretitle', ''),
        '#weight' => '0',
    );
}

Edit: I've solved this already, but need 8 hours to post the solution because I'm new.


texts: Taxonomy term doesn't show up in admin/structure/taxonomy/manage/tags/overview

texts:
I migrated a Drupal 6 site to Drupal 8.  Current running version is:  8.5.3
I created 4 terms in the Tag taxonomy and referenced in the content type Article.

The terms, however, do not show up in the overview page.

They are in the database.

They are also visible when creating nodes.

How do I fix this?


texts: Allowing Automatic Logins from a Range of IP Addresses

texts:
I'd like to implement the following functionality in my site:

Give an entire organization access to our Drupal 7 site from a specific range of IP addresses.

The way it would hopefully work is this: users in the organization, from any of the computers in their organization (in the ip range) would be able to go to our site and be automatically logged in.

Other users with individual accounts in our system should not be restricted from logging into our site.

Anyone know how to accomplish this?


texts: How to get the current field value in Ajax callback?

texts:
I 've a problem with Drupal 8 ajax callbacking. I created a multivalue field for country - region listing as new field type using a custom module. In first selectlist I loaded all country codes and I set this field as multivalued.

I wrote the below code in FieldWidgetType Class.

     public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  $element['value'] =  array(
      '#type' => 'select',
      '#title' => 'Select Country',
      '#name' => 'value',
      '#options' => array(
        0 => t('- Select Country -')) + $termNameArr,
      '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
      '#ajax' => [
              'callback' => array($this, '_regions_ajax_callback'),
              'event' => 'change',
              'progress' => array(
                 'type' => 'throbber',
                 'message' => t('Please wait.Fetching data...'),
                ),
             ],
      '#suffix' => ''
    );
    return $element;
    }

I have to load regions of the selected country in an another select box using ajax. The selectbox should populate with the regions of selected country in change event of country select box item (here I'm calling ajax). Or else, can ajax simply return the selected country value to append in span (.email-valid-message) specified in #suffix.

My current callback to return at least the selected country name is:

    public function _regions_ajax_callback(&$form, &$form_state) {
      $response = new AjaxResponse();
      $element = $form['value'];
      $default_value = isset($element['#default_value']) ? element['#default_value'] : NULL;
      $value = $form_state->getValue($element['#name']);
      $changed = $default_value == $value;
        if ($changed) {
       $response->addCommand(new HtmlCommand('.email-valid-message', $value));
       }
    return $response;
    }

I used namespaces

    use Drupal\Core\Ajax\AjaxResponse;
    use Drupal\Core\Ajax\HtmlCommand;

What am I doing wrong? How can I change my callback function to get current field value? Did I miss to add any namespace?


texts: How hard is it to move a live site to mongoDB when its traffic hits high? Is it easy to built a Drupal site on it? How is the learning curve for a developer who is quite comfortable with Drupal7 and php.


texts:
I have to search the entered text in a drupal table and if there is a match for the keyword get all the fields corresponding to that keyword. I have executed the query and I have the fields to be printed in a array called $column_name.

How can I display these fields to the user in the form of a table?

function module_form_submit($form, &$form_state) {
$text = $form_state['values']['text_field'];
$query = db_select('table_name', 'n');
$query->fields('n', array('field_1','field_2','field_3'));
$query->condition('n.field_0', $text, '=');
$column_name = $query->execute();


texts: Determining the $POST variables of a submitted form

texts:
I have a form on my site. Users fill out the form and submit it. When I want to target one of the fields in the form with a custom module I'd target it with something like the following:

$form['customer_profile_billing']['field_organization'];

But, if I want to target the value a user entered - after they clicked submit, in a custom module, what would be the proper syntax to use, or how would I figure out what my $POST variables are?


texts: Fetching title of articles with taxonomy terms which are its siblings

texts:
I am making a view that gives the title of an article. It has a term reference field. Taxonomy tree is somewhat like:

A

a
b
c

B

1
2
3

So I want to make a view that work in such a way that when one is on the taxonomy term page "a", he could see all the relevant title of taxonomy term 'a','b' and 'c'.

This is the query that the view has generated.

SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, node.created AS node_created, node_counter.totalcount AS node_counter_totalcount
FROM
{node} node
LEFT JOIN {field_data_field_categories} field_data_field_categories ON node.nid = field_data_field_categories.entity_id AND (field_data_field_categories.entity_type = 'node' AND field_data_field_categories.deleted = '0')
INNER JOIN {taxonomy_term_data} taxonomy_term_data_field_data_field_categories ON field_data_field_categories.field_categories_tid = taxonomy_term_data_field_data_field_categories.tid
LEFT JOIN {taxonomy_term_hierarchy} taxonomy_term_data_field_data_field_categories__taxonomy_term_hierarchy ON taxonomy_term_data_field_data_field_categories.tid = taxonomy_term_data_field_data_field_categories__taxonomy_term_hierarchy.tid
LEFT JOIN {node_counter} node_counter ON node.nid = node_counter.nid
WHERE (( (taxonomy_term_data_field_data_field_categories__taxonomy_term_hierarchy.parent = '46' ) )AND(( (node.status = '1') AND (node.type IN  ('article')) AND (node.language IN  ('en')) )))
ORDER BY node_created DESC, node_counter_totalcount DESC
LIMIT 7 OFFSET 0

But is still not working.


texts: Where and why are style tags removed in the render process?

texts:
I have a block (in Drupal 8) that renders a field of a node. This is my build function:

public function build() {
  $node = $this->getNode();
  $build = array();
  $markup = array();
  $current_lang = \Drupal::languageManager()->getCurrentLanguage()->getId();

  if ($node && $node->hasTranslation($current_lang)) {
    $node = $node->getTranslation($current_lang);
  }
  else {
    $node = false;
  }

  if ($node) {
    $fieldsToRender = array(
      'field_slider',
    );

    $viewmode = 'default';
    $entityType = 'node';
    $display = $this->getEntityViewDisplay();
    $viewBuilder = \Drupal::entityTypeManager()->getViewBuilder($entityType);

    foreach ($fieldsToRender as $field_name) {
      if (isset($node->{$field_name}) && $field = $node->{$field_name}) {

        $displayComponentSettings = $display->getComponent($field_name);

        if (!is_array($displayComponentSettings)) {
          $displayComponentSettings = array();
        }

        $fieldRenderable = $viewBuilder->viewField($field, $displayComponentSettings);
        if (count($fieldRenderable) &&! empty($fieldRenderable)) {
          $rendered = render($fieldRenderable);

          if ('' !== $rendered) {
            $markup[] = $rendered;
          }
        }
      }
    }

    if (count($markup)) {
      $build = array(
        '#type' => 'markup',
        '#markup' => implode("", $markup),
      );
    }
  }

  return $build;
}

When I dpm($rendered) after $rendered = render($fieldRenderable); it gives me the wanted markup, in which at some point is an inline style tag that comes from inside a paragraph's template.

For some reason though, the inline style tag is removed in the final block output. I thought it was maybe due to the filters in the page.html.twig but just rendering the region using {{ page.regionname }} makes no difference.

So, where (and why) does Drupal strip that style tag?

PS: I also noticed in the block version of the field strips the twig debug comments, while the above mentioned dpm output still contains them. So I guess it has something to do with how the block handles the build function's returned markup...


texts: How do I pass variables to a view builder's renderer?

texts:
I'm creating a module that will render a few nodes before getting back the result and print it as PDF. (I can't use wkhtmltopdf; I wish I could.)

So far, I managed to make my controller/action use the template I wanted, and anything I write in the template file is showed with die($html). However, I can't find any example of how to pass variables to the view; I tried a few things, but I got nothing, excepted 500 errors.

This is the code I am using.

public function nodeAction(NodeInterface $node) {
  // Here, I define a variable named $responses that contains a lot of datas as arrays
  $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  $build = $view_builder->view($node, 'cnas_pdf');
  $html = \Drupal::service('renderer')->renderPlain($build, ['var' => $response]);

  // No error in this configuration, but "var" is nowhere to be found
  die($html);
}


texts: User Registration Disable Email Verification

texts:
The issue is for non admins to only view a particular part of the user section. The current password and email address fields need to be hidden. I've tried the field permissions but that doesnt give an option.

Writing the hook makes sense to hide both the fields but the validation is what I'm having issues with. If I add optional mail or the mail control modules, I'm thinking its going to throw a few other things off.


texts: Drupal7 template suggestions for node is not working

texts:
I created a new content type named job. Now I want to use custom node template for this content type.

I created file name node--job.tpl.php and cleared the cache, but it doesn't pick that file, it is picking only node.tpl.php file.

Anybody have any idea about this?


texts:
I'm attempting to create an unordered list using a render array in a custom block in a custom module.

I understand if I wanted to wrap things in div I could always use the 'container' type. Like so

    $content = [
        'container'    => [
            '#type'       => 'container',
            '#attributes' => [
                'class'      => ['container'],
            ],
            'item 1'      => [
                '#type'       => 'html_tag',
                '#tag'        => 'p',
                '#value'      => 'Item 1',
            ],
            'item 2'      => [
                '#type'       => 'html_tag',
                '#tag'        => 'p',
                '#value'      => 'Item 2',
            ],
        ],
    ];

But I'd like to be able to use an unordered list like so

    $content = [
        'container'    => [
            '#type'       => 'html_tag',
            '#attributes' => [
                'class'      => ['container'],
            ],
            '#tag' => 'ul',
            'item 1'      => [
                '#type'       => 'html_tag',
                '#tag'        => 'li',
                '#value'      => 'Item 1',
            ],
            'item 2'      => [
                '#type'       => 'html_tag',
                '#tag'        => 'li',
                '#value'      => 'Item 2',
            ],
        ],
    ];

What I'd like that to produce is

Item 1

Item 2

But instead it produces

Item 1

Item 2

Is there a way to create an unordered list using render arrays?


texts: parameter for getting body content of drupal node

texts:
I'm using Services module for rest services.

When i am passing this url

    $base_url/rest/node?fields=title,nid&parameters[nid]=18

I got this result

       <result is_array="true">
          <item>
             <title>Speed alert</title>
             <nid>18</nid>
             <uri>http://localhost/xxz/drupal/rest/node/18</uri>
          </item>
       </result>

Now, Is there any parameter like(body or content ..) to retrieve only body content of the perticular node(i.e node/18) via rest.


texts: How to check all checkboxes in a Views exposed filter by default?

texts:
I'm using the Views and Better Exposed Filters modules to allow users to select age ranges like this:

This view functions as a search page.  However, users are confused because if they simply hit Apply, all age groups are searched even though no age groups are checked.  For this reason, I would like to show all age groups as selected by default to make it clear that all age groups are searched by default.

How can I do this?


texts: How to use hook_views to add calculation to a field?

texts:
In a custom module (assoc), I have a custom Content Entity (Person) with these fields:

$fields['lastname'] = BaseFieldDefinition::create('string')
$fields['firstname'] = BaseFieldDefinition::create('string')
$fields['email'] = BaseFieldDefinition::create('email')
$fields['cellphone'] = BaseFieldDefinition::create('telephone')
$fields['balance'] = BaseFieldDefinition::create('integer')

I use Views to display a table of the persons. Here is the corresponding Views preview:

Before displaying the output, I'd like to add some value to the field 'balance':
balance = balance (of content entity) + somecredit - somedebit
'somecredit' and 'somedebit' being calculated by a query to the database.
What is the hook_views I should use ?
And how do I do?


texts:
I am writing a module that enables admins to create entities. One of the fields on the entity is a cut-off date.

For each entity within the cut-off date a block is produced. I do this by means of a EntityFieldQuery inside hook_block_info.

The user can then configure those blocks to appear on certain paths.

This approach seems to be working, but I'm a little unsure:

is it safe (i.e. reliable)? I'm unsure how drupal handles all the config for blocks - if the block does not exist any more is its config all deleted?
is it an efficiency nightmare? Currently it's only searching a handful of entities for in-date ones, but I'm interested to know if there could be a more efficient way because I guess this will run for every single page load.

Thanks,


texts: Access $display_submitted in page template

texts: Is there a way to access a node's $display_submitted Boolean value from within a page.tpl.php?


texts: "Undefined index: #parameters" and other error in custom module

texts:
Original question at the bottom. Quick summary, I needed a way to remove the comma character from views exposed filter queries. Below, I was given an example of custom module to do this using validation, which I used and barely modified. However, I'm getting the errors:

Notice: Undefined index: #parameters in search_helper_form_alter() (line 6 of /Applications/MAMP/htdocs/drupal-7.12_old/sites/all/modules/search_helper/search_helper.module).

Notice: Trying to get property of non-object in search_helper_form_alter() (line 6 of /Applications/MAMP/htdocs/drupal-7.12_old/sites/all/modules/search_helper/search_helper.module).

Since I've never written a module before, I'm not sure how to interpret these errors. I'd really appreciate any suggestions. Here's the code.

<?php
function search_helper_form_alter(&$form, $form_state, $form_id) {
    switch($form_id) {
        case 'views_exposed_form':

        if ($form['#parameters'][1]['view']->name == 'views_exposed_form_address_search_page') { // name of the view
            // display array, you have to enable devel module
            //$output .= dsm($form);

        $form['#validate'][] = 'no_commas';
   }
  break;
 }
}
function no_commas($form, &$form_state) {
  $form_state['values']['d'] = preg_replace(",", ' ', $form_state['values']['d']);
}
?>

Original question: I've been trying to set up a location search using views exposed filters and various methods of storing information. The problem inevitably arises that users obviously will want to search for a location using a comma (San Diego, CA or Portland, OR), but the comma isn't stored with the locations anywhere. So, if they search for San Diego or they search for California it works fine, but when they search for both using comma separation, they query returns no results. Is there a way to remedy this? The best way to do this, it seems, would be to ignore the comma within the query somehow. It's been driving me crazy for quite some time now how to get this working. Any help would be appreciated.


texts:
i must render entities but it render the node title / author / creation_date etc... and i want to show only fields of my node. In D7 we can set a #access property to not render the field but in D8, i don't know how to do this. Can you help me please ?

I render my entities by this way :

// Get all content observable
            $query = \Drupal::entityQuery('node');
            $query->condition('status', 1);
            $query->condition('type', $ctype_observable);
            $query->condition('field_scm_tag', $this->getPluginDefinition()['tag']['machine_name']);
            $entity_ids = $query->execute();
            $entities = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($entity_ids);

            // render the entity
            $view_mode = 'default';
            $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
            foreach ($entities as $nid => $entity) {
                $build = $view_builder->view($entity, $view_mode);
                //kint($build['#node']);
                dsmr($build['#node']->get('title'));
                $build['content'][$nid]['#markup'] = render($build);
            }


texts:
I'm building a tool that contains a few clickable regions. Each region has a link with class="use-ajax" data-dialog-type="modal" pointing at a custom form route.

Everything is working great and I'm able to get the data from the form and store it. I, however, need the user's selection in this modal form to be reflected in the region they initially clicked.

I'm at a loss aside from storing their selections in localStorage or something and populating that region when they close each modal. That seems a little hacky though. Is there a cleaner way of accomplishing this that I'm missing?

      Click to select


texts: Restricted access on certain files in Open Atrium

texts:
I have a situation where I have individuals that belong to a certain group and they want to have a sub-folder in the documents subspace that is restricted to only a few members of that space.

In my research I have come across a private file system that you can configure/set up, but that solution is not ideal as we still want to keep all the documents for that space in one central location.

Is it possible to break permissions down to level of special access on individual folders/files?

Information:

Using latest version of Open Atrium.
Have no other modules installed.
Current users are used to working with SharePoint as their CMS.

I apologize if I am missing something obvious or have holes in my basic understanding of Drupal, as I have been forced to dive in head first with out testing the waters.


texts: Drupal 7: Adding a save button to save content to user profile page

texts:
I want a signed-in user to have the ability to save an image (that is being displayed in some kind of slideshow or gallery) and have it appear on that users profile page. So the image will be on the same site, maybe added by another user or the site admin and then any other user would be able to click a save button and have it added to their own profile. That image being saved (when being saved to the users profile) should have a link that returns you to the gallery from which you saved it.

How to do this?


texts:
I'm showing my users a random number ({{ random() }}) in a twig which is being rendered in a view. But when I refresh a page it just shows me the same number.

I tried several things but they all failed:

Disabled caching in admin/config/development/performance
Disabled cache in views advanced settings
tried to use cacheexclude module
I even disabled twig cache!

How can I completely disable cache for specefic twig or specefic view?

Update:

By the way in response header there is a header called x-drupal-cache:HIT. (It's MISS for the first time and then HIT after first load) Why?

Update 2:
I uninstalled Internal Page Cache too. the x-drupal-cache is gone now but the page is still being cached! I literally disabled everything but still no luck to show a random number in twig in a view..

This is my response header if it helps:

cache-control:must-revalidate, no-cache, private
content-encoding:gzip
content-type:text/html; charset=UTF-8
date:Wed, 28 Feb 2018 14:26:47 GMT
expires:Sun, 19 Nov 1978 05:00:00 GMT
server:nginx
status:200
strict-transport-security:max-age=15768000
vary:Accept-Encoding
x-content-type-options:nosniff
x-drupal-dynamic-cache:UNCACHEABLE
x-frame-options:SAMEORIGIN
x-generator:Drupal 8 (https://www.drupal.org)
x-ua-compatible:IE=edge

Solution:

I uninstalled Internal Cache module and ALSI big pipe module too.


texts: Configuration Management together with git-flow

texts:
Using multiple branch/developers strategy for developing features causes some issues with built-in Drupal configuration management.

Our scenario is the following:

Create new feature and export config using drush
Commit changes and configuration into git
Move to another branch and start working in another feature
Export config using drush (also exports config from the features added in the previous branch)
Cannot move easily between branches as some content types are missing

What is the best way to use feature branches in a multiple developer team without creating this overhead?


texts: How do I convert a document to a preview image?

texts:
Possible Duplicate:
  How can I convert first page of a pdf as its thumbnail?

I have a file field which allow users to upload document types like pdf, doc and txt. Now I want to convert first page of each document to a Thumbnail. I want this action either for CCK display and Views Field.
I already found some solution ( 1 , 2 , 3) but the two first are for Drupal 6 and the third one is just a php solution which I don't know how to make it work in my drupal7 system?
Now what should I do to make these type of thumbnails in Drupal7?


texts: How do I show the username field in the user edit form?

texts: I need to show username textfield in user edit form. Normally, it shows only for administrator user. How do I show this for all users' edit form?


texts: Permissions/access caching per node and per user

texts:
UPDATE: Narrowing this a bit. I need to, for either (a) all nodes of a given type or (b) all nodes on a specified list of node id's or (c) all users on a list of iser id's, clear the cached permissions because, due to changes not necessarily made on a given node, a user's access permission may have changed.

I have built and published a module (Access by Reference) that grants update access to nodes based on edit permissions on nodes referenced in the target node.

I am concerned that the module will not work as intended if permissions cache interferes with recognizing changes made elsewhere (eg, rights to the referenced node are changed)

What I would like to do is clear permissions caches relating to particular nodes and/or particular users or roles.  I've been studying the Cache Contexts for several days but the light bulb has not yet lit.  I'd appreciate some guidance.


texts:
I have a File field for uploading pdfs. When editing the page, I remove the current pdf and upload a new pdf. The new pdf is uploaded to the server and add to the /sites/default/files folder and I can access the new pdf. However, the page still references the previous pdf that was uploaded.

I check the database and noticed that the new pdf was added to the files_managed and the files_usage tables but NOT the files table. Any idea why this would be and how I can get the File field to reference the latest uploaded pdf?

In a template, I have a db query for the file id, when I print the fid on the page, it shows the outdated file id instead of the new file id.


texts: How to migrate update only recently updated nodes?

texts:
We have an organic group(OG) based blood bank application on Drupal 7 which is performing well. We are currently working for a D8 upgrade. We want to onboard two blood banks(OG) first on the new upgraded system and subsequently add others.
The problem is that we have a lot of nodes for some content types and the fields related to these nodes changes daily. When we complete migration of data, we will have to initiate update of nodes that have changed. If we simply execute all with the --update flag it will take far too long and this process will have to repeat.
Is there a way we can only migrate --update recently updated nodes, lets say, nodes having changed timestamp greater than last month and value greater than their corresponding created timestamp.
I have thought about getting the newly updated nids using a custom query and presenting these nids as ids under --idlist flag. Are there any other options?
Thanks.


texts: Views Refresh Results are Scrambled Syntax

texts: On several beta builds recently that use Views, when I am configuring a new page or block view,  when the results are refreshed manually or automatically I am getting a scramble of code/script/syntax garbage instead of a proper Drupal Views admin page with query results. I have a number of other modules installed and have been unable to determine where there might  be a conflict and process of elimination has been more miss than hit. Returning to the main Views admin page and attempting to configure my primary view fine, and the rest of my beta site runs fine. Has anyone encountered view refresh/results during configuration that are just a scramble of syntax output? What solutions? Any known conflicts?


texts:
I have a drupal multisite install so that two sites can share the same codebase. In a custom module that both sites use, the ajax works on one site but with the other site it returns the error status 200. What my module does is that it creates a new "article" node programmatically.

I read somewhere that this is a crossdomain ajax problem, even though both sites are really on the same hard drive of the same server.

The views module, which also uses ajax, works on both sites with no problem.

How can I make the ajax work? I'll give up the multisite way if it creates more problems than it solves

Update: here is the jquery code :

(function ($) {
    Drupal.behaviors.addArticle = {
        attach: function (context, settings) {
            var addstuffAjaxLink = $(".addsomething");
            addstuffAjaxLink.click(function(e) {
                var ajaxpath = 'addstuff/ajax';
                $.ajax({
                    type: "POST",
                    url: ajaxpath,
                    data: {'from_js': true},
                    dataType: "json",
                    success: function (data) {
                        if (data.message) {
                            var message= data.message;
                            alert(message);
                        }
                    },
                    error: function (xmlhttp) {
                        alert('An error occured: ' + xmlhttp.status);
                    }
                });
            });
        }
    };
})(jQuery);

and this is the custom module php code:

<?php
/**
 * Implements hook_menu().
 */
function addstuff_menu() {
  $items = array();

  $items['addstuff/ajax'] = array(
   'title' => 'Add Stuff',
    'page callback' => 'addstuff_callback',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}
/**
 * Menu callback.
 */
function addstuff_callback() {
    if ($_POST['from_js']) {
        global $user;

        $newnode = new stdClass();
        $newnode->uid = $user->uid;
        $newnode->name = $user->name;
        $newnode->language = LANGUAGE_NONE;
        $lan=$newnode->language;
        $newnode->status = 1;
        $newnode->promote = 0;
        $newnode->sticky = 0;
        $newnode->created = timestamp;
        $newnode->title = 'New Article';
        $newnode->type = 'article';

        $newnode->field_body = array(
            $lan => array(
                array(
                    'value' => 'Click HERE to add some text.',
                    'format'=> 'full_html',
                    'safe_value' => 'Click HERE to add some text.',
                )
            )
        );
        node_save($newnode);
        $response = array(
            'message' => 'Article Created',
        );
        return drupal_json_output($response);
        exit;
    } else {
        $response = array(
            'message' => 'There was an error',
        );
        drupal_json_output($response);
        exit;
    }
}
/**
 * Implements hook_init().
 */
function addstuff_init() {
  drupal_add_js(drupal_get_path('module', 'addstuff') . '/addstuff.js');
}


texts: Upload Image in system_theme_settings form using Zen on Domain Access System

texts:
I want to upload the image as the background in the settings page of the zen theme.

In zen , It's easy to add an extra field in the theme-settings.php and it's worked at the single site system.

However,I want to add this feature to the domain access Website.

And I got some error message.

I just write the code as belowed:

$form['background_file'] = array(
    '#type'     => 'managed_file',
    '#title'    => t('Background'),
    '#required' => True,
    '#upload_location' => file_default_scheme() . '://theme/backgrounds/',
    '#default_value' => theme_get_setting('background_file'),
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),
    ),
  );

picture above appeared correct.

But when i push the upload button.

I got the error message belowed

Notice: Undefined index: system_theme_settings in drupal_retrieve_form() (line 806 of /Library/WebServer/Documents/official/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'system_theme_settings' not found or invalid function name in drupal_retrieve_form() (line 841 of /Library/WebServer/Documents/official/includes/form.inc).
Notice: Undefined index: var in variable_realm_form_system_theme_settings_alter() (line 618 of /Library/WebServer/Documents/official/sites/all/modules/variable/variable_realm/variable_realm.module).
Notice: Undefined index: background_file in file_ajax_upload() (line 271 of /Library/WebServer/Documents/official/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /Library/WebServer/Documents/official/modules/file/file.module).

and i really don't know how to fix that.

I just referenced the content below and i can't find the answer.

https://stackoverflow.com/questions/7739345/drupal-7-retain-file-upload
https://stackoverflow.com/questions/11515221/is-there-a-proper-drupal-7-form-api-managed-file-tutorial
http://www.rahulsingla.com/blog/2011/06/drupal-7-handling-file-uploads-and-moving-files-to-the-public-file-system
Is there a way to add managed_file field to theme-settings.php?

Does someone fixed this situation before?

thanks a lot.


texts:
I'm generating a URL with Url::fromUri() method.

Is there a way to add automatically an "active" class, like D7, if the page is the same of the URL?

Obviously without check manually the value of the generated URL and the page.


texts: Storing variables in a theme outside preprocessing

texts:
I have some variables that I want to store in my theme, but I cannot always use theme_preprocess() to set and subsequently gain access to them.

What is the best way to do this?

I would like to not use a module, but with my experience in the past, a module has a hook_install() where an can use variable_set(); Is there anything similar for a theme?


texts:
I have added TinyMCE to work with one of my text formats, and I added the different alignment buttons. When I try to center some text it adds "text-align: center" to the p... but when I save it, it goes back to normal. I would like to fix that to be able to align text and images. I installed a module called WYSIWYG Filter and added "text-align" in Text properties... still doesn't work. I also added "p[style|text-align]" to the "HTML elements and attributes" section... still doesn't work.

Any ideas of what could I be missing?
...I'm using Drupal 7 BTW


texts: how to add a serial number column in a view?

texts:
I created a view in drupal and needs some serial numbering as the first column which is not there in the content type on which I created the view. My question is how to add that serial number field in this view like this

cand_name | phone_num | email id

is my view

I want it like this..

sno | cand_name | phone_num | email id

hope I am clear, write comments if it needs still clear explanation.

Thanks in advance


texts: Custom button for CKEditor not showing up in node creation page

texts:
I want to add a simple custom button to CKEditor in Drupal 8. So far I followed the Instructions here and here, and my custom button is showing up on the configuration page under Configuration > Content authoring > Text formats and editors, where I added it to the Basic HTML and Full HTML presets.

However, when I want to create a new article, the button is not being shown in the editor toolbar.

I can verify by JS console outputs that my plugin is being loaded by CKEditor, and the init function actually runs. The button just does not appear. I appreciate any pointers. I have seen this question, where somebody seems to have a similar problem, but I don't really understand the accepted answer as it seems to be specific to CKEditor templates. So my question is: why does my button show up in the configuration page, but not in the node creation page, although the corresponding JS is being run?

I have not implemented any hooks in my module.

info.yml of my module

name: Glossarion
type: module
description: >
  Some description. I'll think about it later.
core: 8.x
version: 0.1
package: CKEditor
dependencies:
  -ckeditor

.php of my Drupal plugin

class Glossarion extends PluginBase implements CKEditorPluginInterface, CKEditorPluginButtonsInterface {

public function getDependencies(Editor $editor) { return array(); }
public function getLibraries(Editor $editor) { return array(); }
public function isInternal() { return FALSE; }
public function getConfig(Editor $editor) { return array(); }
public function isEnabled(Editor $editor) { return TRUE; }

public function getFile() {
  return drupal_get_path('module', 'glossarion') . '/js/plugins/glossarion/plugin.js';
}

public function getButtons() {
  return [
    'glossarion' => [
      'label' => t('Insert a Word from Glossarion'),
      'image' => drupal_get_path('module', 'glossarion') . '/js/plugins/glossarion/icons/glossarion-editor-icon.png',
      'command' => 'insertTimestamp'
    ]
  ];
}
}

.js of my CKEditor Plugin

'use strict';

CKEDITOR.plugins.add('glossarion',{
  icons: 'glossarion-editor-icon', // %REMOVE_LINE_CORE%
  init : function( editor ) {
    console.log("Glossarion init is being called");
    editor.addCommand( 'insertTimestamp', {
        exec: function( editor ) {
            var now = new Date();
            editor.insertHtml( 'The current date and time is: <em>' + now.toString() + '</em>' );
        }
    });
    // do I have to add the button here again? Seems to have no effect
    editor.ui.addButton( 'Timestamp', {
        label: 'Insert Timestamp',
        command: 'insertTimestamp',
        toolbar: 'basicstyles,0'
    });
    console.debug(editor);
  }
});


texts: Views reverse relationship with groupwise max

texts:
In my view I need to show only one (most recent) related entity from the base entity of the view. Specifically I work with crm-core contacts which work with crm-core activity. Each contact has one or more activities, and in the view I need only the most recent activity.

The problem is that the reference field is NOT from the contact to its activities but rather from an activity to its contacts. (This is how it works in CRM-Core)

If the reference was the other-way-around (from contact to activities) I would use views_handler_relationship_groupwise_max.

Did anybody implement the same like views_handler_relationship_groupwise_max but for reverse references? Something like a combination of views_handler_relationship_groupwise_max with views_handler_relationship_entity_reverse


texts:
I need to know if there is a way to create a content type and within the content type to create a field which this field should be segment.

For Example :

at the beginning i will have an image,  this will be the default image.
and in case i will choose an option like to display only for authenticated user another image field will be opened , and in the display all unauthenticated users will see the default image and authenticated users will see the second image.

Is there something like this ?

Thanks


texts: How do I programmatically save "2019-11-04 07:30:00+01"?

texts:
I have "2019-11-04 07:30:00+01" as datetime value. I am not getting how to handle  the "+1" part in a Drupal 8 date field.

I am using this code, but it's not giving me any value.

use Drupal\Core\Datetime;

$userTimezone = new DateTimeZone(drupal_get_user_timezone());
$gmtTimezone = new DateTimeZone('GMT');
$myDateTime = new DateTime($item['start_date'], $gmtTimezone);
print_r($myDateTime);
die;


texts: How to know that the user has completed a quiz?

texts:
Is there any function to pass the user id and the quiz node id and get true or false if the user has completed the quiz?

Or I have to write sql query for this?


texts: Subscribe/Unsubscribe link to a group's content type using Notifications & OG

texts:
We're using the Notifications module with Organic Groups (in Drupal 6). We have been writing our own UI module for Notifications so that it is simpler to use and more tailored for our client's needs. One of the remaining tasks is to include a link in the groups that a user can click on to subscribe/unsubscribe to a group's content type.

Does anyone know what structure the subscribe URL needs to be to allow this?

I know for a normal thread it is: notifications/subscribe/[uid]/thread/nid/[nid] and notifications/unsubscribe/[sid].


texts:
I need to add a class of the user's role to my page. Ive tried the following but it doesn't work, and it seems from the comments its not working for others aswell.

function THEMENAME_preprocess_page(&$vars) {
  if ($vars['user']) {
    foreach($vars['user']->roles as $key => $role){
      $vars['class'][] = 'role-' . drupal_html_class($role);
    }
  }
}

http://grasmash.com/article/drupal-add-current-users-role-body-classes


texts: How to make a form alter for uploads via the media library modal

texts:
By default the 'name' basefield is hidden on media entity forms and a name is automatically generated from the file name. The media name is displayed and is searchable in the media library.
This approach is fine for images, but in the case of documents I would prefer that editors provide a proper document title. I have therefore made the name field visible on the entity form.
This works fine when creating media at the path /media/add/document but when uploading media via the a node form, the media library modal pre-populates the name field with the generated name. The problem here is that editors will often submit the form without providing a proper title.
I would rather not add another field when a valid basefield already exists. Moreover, I have raised this as a core issue, but it is not getting anywhere fast.
I am not a coder. So how should a I go about creating a form alter to clear the generated text?
Please see screenshot


texts: Displaying Ubercart order history for customers in their "my account" page

texts:
I currently have a small store set up with Ubercart where customers can purchase the items I have listed. They go through the process of purchasing and then receive an order confirmation email. On this email their is a link to "Check Order Status". That is what I want however, when the link is clicked they are taken to their "My Account" page and nothing is displayed.

Question: Because Ubercart gives this link I assume their is some sort of information that can be displayed (ie order history/status). Is their an area in the configuration that I can insert the information or is it even possible.


texts: Programmatically created content type module title not working

texts:
I created a module with a .info, .module and .install file that can be installed by customers. This module file to create content types from node consists basically atm of:

/**
* Implements hook_node_info()
*/
function mycontent_node_info() {
  return array(
    'mycontent' => array(
        'name' => t('My content'),
        'base' => 'mycontent',
        'description' => t('You can define your objects here'),
        'has_title' => TRUE,
        'title_label' => t('Object title')
       )
    );
}

/**
* Implement hook_form()
*/
function mycontent_form($node, $form_state) {
   return node_content_form($node, $form_state);
}

The problem is as follows:

I want to use entity translation. This works fine but the title module. It ist automatically installed, so the standard title of nodes can be replaced by clicking 'replace', but the default language is not filled.

E.g. if default language is German, the title is not saved. When I translate in English, the English title is saved. When I debug I can see that the complete (German or English) form is taken, the value of the form state are identical except the content itself and the language values 'de' and 'en'.

If I change en as default language then english title is not saved.

Because i can not see anything in the issue tracker of the title module I hope that I have to add anything to my code.

Thx in advance

maen


texts: Error - External URLs do not have an internal route name

texts:
I can't access to my site because of this error:

  UnexpectedValueException: External URLs do not have an internal
  route name. in Drupal\Core\Url->getRouteName() (line 554 of
  C:\Users\user\Documents\Sites\camp\core\lib\Drupal\Core\Url.php).

  This is the function that I have in line 552 to 558.

public function getRouteName() {
if ($this->unrouted) {
  throw new \UnexpectedValueException('External URLs do not have an internal route name.');
}

return $this->routeName;
}

The last thing I have done it was update 2 nodes that I have created and a View of that content type.

The nodes I have changed the text (just text, didn't put URL or so) and added a photo storage locally

That content type has 2 fields, body and image

On view I deleted the field body and then added again

I have deleted the view, nodes and content type and I still having that error

I don't know if this help but I have installed these modules:

video embed field, views infinite scroll, superfish, pathauto, libraries, flexslider and entity reference revision.

Today I installed the module paragraphs but I uninstalled after the error

Any ideas?

This is the second time that happened to me with this site, the first time I lost some work because I have backed up an older version, but I don't want to lose some work again.


texts: CMS Vs Framework? Is Drupal A CMS, Framework, or CMF (Content Management Framework)?

texts:
After Reading a Blog post: http://www.palantir.net/blog/drupal-not-cms  It made me curious about the current classification as CMS Vs Framework.

Please use Facts, where possible to justify your response.

CMS

A Content Management System (CMS)is a computer program that allows publishing, editing and modifying content as well as maintenance from a central interface. Such systems of content management provide procedures to manage workflow in a collaborative environment. These procedures can be manual steps or an automated cascade. CMSs have been available since the late 1990s.
CMSs are often used to run websites containing blogs, news, and shopping. Many corporate and marketing websites use CMSs. CMSs typically aim to avoid the need for hand coding, but may support it for specific elements or entire pages. Source: http://en.wikipedia.org/wiki/Content_management_system

Web Application Framework:

A web application framework (WAF) is a software framework that is designed to support the development of dynamic websites, web applications, web services and web resources. The framework aims to alleviate the overhead associated with common activities performed in web development. For example, many frameworks provide libraries for database access, templating frameworks and session management, and they often promote code reuse.

Source: http://en.wikipedia.org/wiki/Web_application_framework

If you would not consider Drupal 7 a Framework, do you think Drupal 8 would be?


texts: Install Vanilla Wordpress to Drupal to use Vanilla Forum

texts: any one knows how to install vanilla forum to drupal. I try to search a good article but could not success.I need step by step to do this.


texts: Correct way to add a working exposed filter (date) to a view displaying calendar entities

texts:
I'm using Views 7.x-3.11, Date 7.x-2.8, and Calendar 7.x-3.4.  The view displays calendar entities in the calendar format with pagination.  When I add an exposed filter for month and year the view defaults back to the contextual filter; pagination works fine.

I've observed that when the pagination is used, the url is like: /calendar?date=02-2015.  When I use the exposed filter the url is like/calendar?date_filter[value][month]=2&date_filter[value][year]=2015.

I've considered using hook_views_query_alter but I'm not sure how to handle if there is switching between pagination and exposed filters.

Am I missing a configuration option?  If I do need to alter within code, what would be the best hook to do so within?

A paste of the view is here http://pastebin.com/WsxFze5z (page display).


texts: How do modules end up in the profiles directory in distributions?

texts:
I'm building a basic distribution and I cannot find any information on how contributed modules that are included in a distribution get placed into the drupal-root/profiles/profile-name/modules directory.

I've looked at a number of distributions, both hosted on drupal.org and not, trying to find some line(s) of code that does this, but there doesn't seem to be any. It has got to be happening "automatically" somehow, but it isn't working for me. When I add modules to my make file, they always end up in sites/all/modules.

I've spent hours trying to ask Google this question but every form I can come up with just gives me information on how to install a module, or how to move modules from the profile of a distribution into sites/all/modules - both of which I am well aware of...

So, can anyone direct me to documentation that can help me out? I'm sure it is out there, but I've hit a wall trying to find it.


texts: Devel Krumo outputting all variables in a list format and not in an expandable clickable list

texts: When I do a dpm() on an array my devel krumo output is showing a list of the variables. Previously it was in a clickable expanding list where I can hide and show the child arrays. What settings did I miss to fix this?


texts:
Soon I will be starting to develop a car dealer website using Drupal.
I want users to be able to select make, modal and other stuffs.
The main thing is the search; I will be using the Views module, with exposed filters, and taxonomy terms.

Is there any module which can do this?


texts: Programatically insert field value of for a taxonomy term

texts:
I have a taxonomy vocabulary called, school and the machine name is field_school_name. The vocabulary has a field called school id (machine name:field_school_id). I am able to add a verb successfully using the following code. How do I add the field value programatically? I want to add '1234' as the school id associated with the verb 'ABCD' I created.

$new_term = \Drupal\taxonomy\Entity\Term::create([
    'vid' => 'field_school_name',
    'name' => 'ABCD',
]);

$new_term->enforceIsNew();
$new_term->save();