texts: Field formatter module throws cannot declare class error

texts:
I am trying to write a custom module, which defines a field formatter plugin, but when I visit the Manage display page, I get this error:

  Fatal error: Cannot declare class Drupal\my_formatter\Plugin\Field\FieldFormatter\MyFormatter, because the name is already in use in /var/www/sites/drupalroot/web/modules/custom/my_formatter/src/Plugin/Field/FieldFormatter/MyFormatter.php on line 0

I've compared my module to several other working field formatter plugins and can't seem to figure out what I'm missing.

My module directory is laid out like this:

web/modules/custom/my_formatter/
├── my_formatter.info.yml
├── my_formatter.module
├── src
│   └── Plugin
│       └── Field
│           └── FieldFormatter
│               └── MyFormatter.php
└── templates
    └── my-formatter.html.twig

My info file:

name: My Formatter
type: module
description: 'Do some fun stuff.'
package: Field types
core: 8.x
dependencies:
  - field
  - file

And my MyFormatter.php file:

<?php
/**
 * @file
 * Contains \Drupal\my_formatter\Plugin\Field\FieldFormatter\MyFormatter.
 */

namespace Drupal\my_formatter\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase;

/**
 * Plugin implementation of the 'my' formatter.
 *
 * @FieldFormatter(
 *   id = "my",
 *   label = @Translation("My Formatter"),
 *   field_types = {
 *     "file"
 *   }
 * )
 */
class MyFormatter extends FileFormatterBase {

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    foreach ($items as $delta => $item) {
      $elements[$delta] = [
        '#theme' => 'my_formatter',
        '#my_var' => 'Hello',
      ];
    }
    return $elements;
  }

}

Any help would be greatly appreciated.


texts: How to embed fields from a view to another view´s exposed filter

texts:
I am stuck with this problem. I created a view (type=term) with exposed filter. Thanks to http://leanderlindahl.se/en/dynamically-filter-content-drupal-view/ I managed to display the exposed filter as a list of "buttons."

Now I want to display fields of content with these taxonomy terms in the exposed filter.

My knowledge of php is very limited, sorry for newbie mistakes. I learn new things every day.

my .module:

function exposedfilter_buttons_form_alter(&$form, &$form_state, $form_id) {
if ($form['#id'] == 'views-exposed-form-test-lektori-page') {
$form['#attached']['js'] = array(
  drupal_get_path('module', 'exposedfilter_buttons') . '/js/exposedfilter_buttons.js',
);
$links = $form['tid']['#options'];
$newlinks = array();
$my_value = views_get_view_result('lektori', 'block_1'); //trying to obtain results of the second view

foreach ($my_value as $key => $result) { //trying to assing results to $key
}
foreach ($links as $tid => $term_name) {
if (taxonomy_term_depth_get_by_tid($tid) == 1) {
   $newlinks[] = array('data' => '' . $term_name .'  ' . $key . /*so we directly see its value for control */' '. $my_value[$key]->node_field_data_field_workshop_lektor_title . '', 'class' => array('pop-filter-label'));
}
}

$prefix = theme(
  'item_list', array(
  'items' => $newlinks,
  'type' => 'ul',
  'attributes' => array('id' => 'pop-filter-list'),
  'container_id' => 'scope-list-wrapper',
));

$form['links'] = array(
  '#type' => 'markup',
  '#value' => $prefix,
  '#markup' => $prefix,
);
}
// extra submit form handle
$form['#submit'][] = 'exposedfilter_buttons_form_submit';
}
// handle form submition
function exposedfilter_buttons_form_submit($form, &$form_state){
$values = $form_state['values'];
}

What I need: $my_value[$key]->node_field_data_field_workshop_lektor_title should have $key obtained as a value 0 or 1 or 2.... so it will display correct name according to $key.

Image to make things more clear:

Any help is highly appreciated.


texts:
I am Drupal newbie and I 'm trying to develop a feature to refer users in my Drupal Blog Entry content.

Please see screenshot with example: http://prntscr.com/2p5dtv

Browsing for solutions, I found this module, but I am not sure how I can use it to achieve my goal.

Any help will be very useful. Thanks.


texts: Drupal 7 and taxonomy views - sorting by number in URLs

texts:
How can I tell Drupal 7 that 99 should go AFTER 100 when sorting items (descending) according to a number in URL or in Title?

I have this taxonomy view for magazine articles. Published issues range from 90 to 120, for now. Sorted ascending, the list goes from 100 to 120 and then 90, 91, and so on. Descending, I get 99, 98, 97.... 91, 90, 120, 119 and so on.

Sorting by posting date is not an option, since we're moving to the new Drupal site lots of old content and new issues will be loaded before very old ones.


texts: How can I customize the display of messages sent with privatemsg?

texts:
Use case: When a user is viewing a private message (from the privatemsg module), I would like to display the following:

a picture field from the user's profile (not the user's profile picture)
a link to flag the user (to report potential abuse)

Senders should see values for recipients and recipients should see values for senders.  How might I go about implementing this?

What I've found out so far:

Out of the box, privatemsg cannot be overriden by Panels.  The Panelizer project is not able to add panes on, either.  There is a Privatemsg Panels sandbox project for which some work has been done but I need a more mainstream, maintainable solution.

Work on the D7 version of Privatemsg Views is currently stalled.


texts: How do you programmatically modify a programmatically created content type?

texts:
I'm creating a Drupal 7 site that has many content types which are defined programmatically. It is quite likely that, after launch, I will be required to slightly modify some of the content types. During development, whenever I need to make a change, I just uninstall the module, make the changes in code, and reinstall it. In a production environment where the data needs to be kept stable, this is clearly not acceptable.

How can I modify one of my existing content types programmatically? Also, how would I apply this update?


texts: How can I get pragmatically all certain actions from Rules and Components?

texts:
On rules settings page (admin/config/workflow/rules) and components page (admin/config/workflow/rules/components) you can specify action (like 'send e-mail') for each of rule or component.

How can I get pragmatically all certain (e.g.: 'send e-mail') actions from Rules and Components?


texts: In webforms, how do I send the current user an email automatically?

texts:
I'm trying to send an email to the logged in user who filled out the form without having them enter their email.

The form is made with webforms 8.x-5.x which has a lot of functionality.

I've only tried doing it non-programmatically through the interface by adding an email and using the "custom to email address" where i attempted to use the token: [current-user:mail] which did not work.

I've made a separate email handler for anonymous users, which just uses the email they fill in.


texts: Drupal duplicate filename throws AJAX error

texts:
I am using the managed_file in a form to upload a file to Drupal. As you know Drupal saves the name of this file into its database and stores it in the path you give.

Unfortunately, when a user uploads a file which has the filename of a previously existing file, he receives an AJAX error that arises from SQL. Even though Drupal manages to store this file with a different name in the folder, I can't prevent the AJAX error.

Is there a solution for this?

Thanks.


texts: Wanna save text_format custom form in comment

texts:
I'm using a custom form in CTools Modal to alter comment.

$form['subject'] = array(
   '#type' => 'textfield',
   '#title' => t('Title'),
   '#default_value' => $comment->subject,
);
$form['comment_body'] = array(
   '#type' => 'text_format',
   '#default_value' => $comment->comment_body['und'][0]['value']
);

All is good. I get my comment title and my comment body which is pushed in ckeditor field. My submit :

$comment = comment_load($form_state['values']['cid']);
$comment->comment_body['und'][0]['value'] = $form_state['values']['comment_body']['und'][0]['value'];
$comment->subject = $form_state['values']['title'];

comment_submit($comment);
comment_save($comment);

The subject is goodly saved from my form but for the body, it save an empty value.

Ps: when I change text_format for textfield, it work.


texts:
I have a maybe rather silly question. I have a test website and a live website (both Drupal 7)

In the test website I have setup translations for my main-menu using the module "Menu Translation" (it is a sub-module of i18n) and at mydomain.com/admin/structure/menu/manage/main-menu I see a third column with the option to "translate" the menu options in the first column.

At my live website I want to do the same, but can't figure out what setting I have to change in order to get these " translate" links appear in the same page?

The settings in the testwebsite are done more than half a year ago and  I cant remember how I did that. The Multilangual option -> Translate and Localize is set for the main-menu on both sites.

This is what my live website looks like [1]: http://i.stack.imgur.com/p0L2y.jpg
 This is what my test website looks like [2]: http://i.stack.imgur.com/1BvNz.jpg

I assume that this has nothing to do with the "reset" link? (no idea what the purpose of that link is)


texts:
Is there any theme record count? Like: "Showing 1 to 10 of 186 records".

So that the user sees the number of pages and total number of records of a query (EntityFieldQuery).

Something made my drupal like theme pager, that we use like this:

//...
$query = new EntityFieldQuery();
//...
$query->pager(10);
//...
$content .= theme('pager');
//...


texts: how to access webform submission data from a custom content type

texts:
I 'd be grateful if someone could help with this..
I have a webform, let's call it input form, which, when submitted, triggers an external application to run on my server.  That application uses some of the submission data (reading from webform_submission_data table) and after some time produces an output in the form of XML.
Now, through the use of feeds module, I read that XML data and produce a node, of a certain content type, let's call it results CT ..
I have a twig template for the results content type, and output is nicely presented to the user.
So far, so good.
Now my problem is this.  I need to show both input and output in the same results page.
I tried to use Webform Content Creator module and indeed I have nodes with submission data - let's call this input data CT.
However, at the time of input form submission, I don't have the results yet.  And I want to link the two together, obviously upon the creation of the results node.
I tried to reference each content type, using Corresponding Entity References so that when a results node is created (automatically through feeds) it would link to the corresponding input data CT.  I thought that if I can achieve that connection, then I would be able to access the 'input' data through the results page template.
However, I can't make this connection to work - the 'entity reference' field that I use on the results CT, wants an 'entity ID' - and I can't find that.  Remember that nodes are created automatically, I don't have a user creating nodes via a select form or autocomplete text field.
I am trying to figure out how to do this through the sid (submission id) which seems to be a unique key for every submission, and I have this on both my content types .. So ideally I would like to use the sid that I have on my results template, and use that to get the submission data I need.
(obviously) I am not very familiar with the drupal API - I am however comfortable with twig .. I don't know if (and how) I could pass that information through a pre-process function to be available in the results template..  Is there a simpler way to do it?
Could I link two content types based on a custom field (say a unique number, like sid ??).
Ideally, in a few words, what I want is this:
I have a CT (results) with various fields, one of which is sid.  That sid corresponds to a (unique) submission id.  How can I access data relevant to that submission id from within the results twig template?  So I can then present both input (submission data) and output (results) in the same page.
PS - Perhaps one solution would be to refactor the whole logic, and use one CT for both input/output.  Insert some data upon form submission, and then, when results are ready, edit (i.e. fill-in) the rest of the 'output' fields via feeds.  Then all data are in one CT.  However I would rather avoid this as it's quite a big change ..  Shamefully enough, I might just re-enter input data through the XML again - it wouldn't be a problem - but it's a really crap solution  ..
I 'd be really grateful if someone could help .. I hope I explained the whole situation adequately enough ..


texts:
following this tutorial I create a Panel Page for the taxonomy term to display all the content related to the taxonomy term and it works.

But I need to have in all the nodes related to the taxonomy terms in the url and children.
So I sobstitute taxonomy term ID contex filter with taxonomy term ID (with depth) and do not work anymore -.-

This is the contex filter's setting

If I try this view block in view page [putting 'taxonomy-name' as argument] it works but not in the panel page.
Where is my mistake?

I don't know if this can help. This is the contex of panel page [I setup the view to take argument from URL.. but maybe it can help]


texts: How to embed a quicktab instance in a page?

texts: How do I can embed a qiucktab instance in page? I'm not going to create a region and assign the quicktab into that region. is there anyway to do such thing without using region?


texts: Newly created node type is always disabled

texts:
I have created a new node type using a custom module on Drupal 7. However when I check the content type under the structure menu item it isn't listed. Looking in the node_type table, I see that it is listed as disabled. My question is how do I get the content type to be enabled?

Here is my content type creation function located in mymodule.install file:

// define the node type
  $type = array(
    'type' => $machine_name,
    'name' => $t($parameters['name']),
    'base' => 'room_reservations',
    'module' => 'room_reservations',
    'description' => $t($parameters['description']),
    'has_title' => TRUE,
    'title_label' => $t($parameters['title_label']),
    'custom' => FALSE,
    'locked' => TRUE,
    'disabled' => FALSE,
  );

// set other node defaults not declared above
  $content_type = node_type_set_defaults($type);

// add the body field
  node_add_body_field($content_type, $t($parameters['body_label']));

// save the content type
  node_type_save($content_type);

I believe this is correct but it obviously doesn't work. Any ideas


texts: Why are my nodes not showing up in a Panel?

texts:
I am experiencing something strange: the nodes in my Panels are not showing up anymore. When adding content to my Panels, I can select Existing node, pick the right node title (e.g. Test article) and save the Panel without any problem:

But, afterwards, the node is not printed on the according Panel page:

However, everything worked fine in the past and a quick test on a fresh website shows that there is no bug in the Panels module. Also, other entities like Views are displayed just fine. I have already checked some things that might cause the problem:

The node template at Structure/Panels is enabled, but that doesn't matter: disabling it does not change anything.
The node in the Panel does neither have a style, nor any visibility rules.
My custom modules do not interfere with the printing of nodes or panels.
Clearing the caches doesn't change anything.
All users have permission to view published nodes; visiting the node's full page works fine:

Do you have any idea what might be causing the problem?


texts: Taxonomy Terms node count of different content type

texts:
Hi I have a issue for which I searched everywhere but not getting any solution,

I have two content types Store and Deals with the following fields
Store is having the fields
1.Store-title
2.Logo
3.Categories--> Added as a taxonomy term field.
4.Outlets

When I am adding a node of type store I am selecting the corresponding category terms with it and saving.

Other content type Deal having the fields
1.Title
2.Store-title---> This field is of content type Store and is added here as a node reference.
3.Outlets

When I am adding a node of type deal I am selecting a store here( In deals content type, store-title is added as a node-reference), and selecting its outlets.

Issue:
I need a counter on the category terms, the counter should be based on  number of deals added to that particular store node on respective categories.

Hope you understand the issue,
I have seen the issue of same type where node counter is displayed but they show the count of nodes of the same content type where that taxonomy term is added like here http://www.brightwebsitedesign.com/how-to-use-views-aggregator-to-create-taxonomy-term-count-block,
But I have a bit different,  taxonomy is added to stores, but I need the count of deals( another content type) on the taxonomy term.
If you still need more clarification please let me know.

This is very urgent
Any help would be much appreciated!


texts:
My question is basically how to access values that the user entered in previous forms. For example, I am using drupal commerce and as the user sees a product, fills some text field values and clicks add to cart and then finishes the checkout. At the end of the checkout how can i access programatically  the values that he entered in the first stage of the process?

One way I think it might work, is to add a submit handler in the  original product form that "grabs" the values when he clicks add to cart and then save them to a session. Is this the correct way ?  Is there any other way like querying  the db or something?

I do not want to display to the user anything, I just want to work "behind the scenes".For  Example after the checkout is complete, I want to call the hooK_commerce_checkout_complete and by using the values that he entered in the first place modify and save a pdf (I know how to crate the pdf with  the tcpdf lib what i do not know is how to  call the values as i said earlier).

If this were Java the values would correspond to an instance variable and i would have access through the corresponding get method. Surely there must be something equivalent for this in php/drupal.

I would appreciate any advice or links to the proper documentation on how to do that.

PS I am most interested on accessing commerce  line items  and the value of their fields but i should probably start with the easy ones first!

Thanks in advance


texts:
I want to deactivate the system path which comes with Drupal.
I've installed the pathauto, so when I create a new page, it automatically changes domain.com/node/12 to domain.com/books/jacks-journey

But both page exist. I only want the /books/jacks-journey to exist and deactive the /node/12. Is it possible to do that?


texts: I want to move a forum thread with all the posts from one server to another. What is the most convenient way to do so?


texts: Make view exposed filter shows results related to previous filter in view

texts:
About my form:
In my project, i'm having a form where project name field is select(drop down) and i have to enter a field(example "sub-project"). Then i will submit the form with project name from select(drop down) and i will type my sub-project name.

View Form:
Here, while showing the form results as table i want two exposed filters. they are
1. Project name(As select box in filter field)(**No problem in this part)
2.Sub-project name(As select box in filter field)(**Problem)

Question:
Now, if i select project name in filter(Example: Project Auro) then automatically i want the sub-project field(2nd exposed filter) to show the sub-projects as drop-down which are only related to Project Auro, that i submitted in form.

Please assist me, and Thanks in advance if you guide me in this problem.


texts: $file->original: Where does it come from?

texts:
I am attempting to write a patch for the Redirect module that automatically creates a redirect from the old file path to the new one, whenever a file is updated.

I added a hook to redirect.module:

function redirect_file_update($file){
      /**
     * Creates a new redirect from old file to new one when the new one has a different URI.
     */

  if (empty($file->original)) {
    $file->original = entity_load_unchanged('file', $file->fid);
  }
  if ($file->uri !== $file->original->uri) {
    $redirect = new stdClass();
    redirect_object_prepare(
        $redirect,
        array(
        'source' => file_create_url($file->original->uri),
        'source_options' => array(),
        'redirect' => file_create_url($file->uri),
        'redirect_options' => array(),
        )
    );
    module_invoke(
      'redirect',
      'object_prepare',
      $redirect,
      array(
        'source' => file_create_url($file->original->uri),
        'source_options' => array(),
        'redirect' => file_create_url($file->uri),
        'redirect_options' => array(),
      )
    );
    module_invoke('redirect', 'save', $redirect);
  }
}

and I verified with a dpm() that $file->original exists as expected when I'm working with files in the GUI.

But when I run tests it doesn't work. According to hook_file_update() docs, it should be called whenever file_save() is called, but it appears that the code inside my redirect_file_update() is never being called, entity_load_unchanged() is returning the exact same object as plain old $file, and my $file objects don't have an 'original' property as far as the test knows, even after saving. Here's the testing code:

function setUp(array $modules = array()) {
  parent::setUp($modules);

  $this->admin_user = $this->drupalCreateUser(array('administer redirects', 'access site reports', 'access content', 'create article content', 'edit any article content', 'create url aliases'));
  $this->drupalLogin($this->admin_user);
}
  // Test whether replacement of a file redirects the old file URI to the new one.
  function testFileReplacementRedirects () {
  // Create a few test files and save them.
  $files = $this->drupalGetTestFiles('image');
  foreach ($files as $file) {
    file_save($file);
  }
  // Get a list of all the files we just created.
  $fileQuery = new EntityFieldQuery();
  $files_list = $fileQuery->entityCondition('entity_type', 'file')
    ->propertyOrderBy('fid')
    ->execute();
  // Pick out two files to use for our test.
  $test_file_one = file_load($files_list['file'][1]->fid);
  $test_file_two = file_load($files_list['file'][2]->fid);

  // Move file one to file two's URI
  $old_url = file_create_url($test_file_one->uri);
  $new_url = file_create_url($test_file_two->uri);
  $test_file_one = file_move($test_file_one, $dest = $test_file_two->uri, $replace = FILE_EXISTS_REPLACE);
  // Load the old module's URI and see if it redirects to the new one.
  $this->drupalGet($old_url);
  $this_page = $this->drupalGetHeaders(TRUE);
  $this->assertEqual($this_page[0]['location'], $new_url, 'Redirected from ' . $old_url . ' to ' . $new_url . '.');
  $this->assertEqual($this_page[0][':status'], 'HTTP/1.1 301 Moved Permanently', 'Status: ' . $this_page[0][':status']);
}

What is going wrong?


texts:
Can a block span more than one region in a theme? Sometimes I would like content to do this, depending on the page.

I'm aware (and heavily use) Panels which are great but I thought it would be worth considering other solutions.


texts: Where does Webform store the YAML form design data?

texts:
I have looked in the database and can see the form_submission_data table but the actual form design (field names and datatypes) I can't locate.
I know you can access this from the front end but I want to re-create forms from a previous version.
This is for a new Drupal8 site migration from Dr7.


texts: How to use subtotal for calculating shipping

texts:
I am using Commerce 7.x-1.13 module on my website. I would like to calculate the shipping based on the order total. However, every time I refresh my checkout page, the shipping fee will be increased because the "order total" includes product price, tax, and shipping fee. Does anyone have any idea that I can calculate shipping only based on the product price?

Below is my shipping rule(if order subtotal<9, shipping=5% of subtotal; else shipping=9):

{ "rules_shipping_ground" : {
"LABEL" : "Ground",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [
  "rules",
  "rules_conditional",
  "commerce_line_item",
  "commerce_shipping"
],
"ON" : { "commerce_shipping_calculate_rate" : [] },
"IF" : [
  { "entity_has_field" : {
      "entity" : [ "commerce-line-item" ],
      "field" : "commerce_shipping_service"
    }
  },
  { "data_is" : {
      "data" : [ "commerce-line-item:commerce-shipping-service" ],
      "value" : "standard"
    }
  }
],
"DO" : [
  { "data_calc" : {
      "USING" : {
        "input_1" : [ "commerce-line-item:order:commerce-order-total:amount" ],
        "op" : "*",
        "input_2" : ".5"
      },
      "PROVIDE" : { "result" : { "5oftotal" : "5% of total" } }
    }
  },
  { "CONDITIONAL" : [
      {
        "IF" : { "data_is" : { "data" : [ "5oftotal" ], "op" : "\u003E", "value" : "900" } },
        "DO" : [
          { "commerce_line_item_unit_price_amount" : {
              "commerce_line_item" : [ "commerce_line_item" ],
              "amount" : [ "5oftotal" ],
              "component_name" : "flat_rate_standard",
              "round_mode" : "1"
            }
          }
        ]
      },
      { "ELSE" : [
          { "commerce_line_item_unit_price_amount" : {
              "commerce_line_item" : [ "commerce_line_item" ],
              "amount" : "900",
              "component_name" : "flat_rate_standard",
              "round_mode" : "1"
            }
          }
        ]
      }
    ]
  }
]

}
}


texts:
I find out title is not exists in page.html.twig, and there is a file page-title.html.twig to theme title, then in block section we should use block title. ( ** I don't want use this strange structure for title,really I  didn't find out why Drupal do this  !!!).

any way
I want to provide it by myself, maybe hook_preprocess_page is solution,any body know how can I add title variable to page variables ?


texts: How to confirm that drush-based cron is being called from crontab?

texts:
I don’t know whether this is a docksal-specific question or a general cron one, but likely the latter.

I’ve set up a crontab for docksal (see https://blog.docksal.io/running-scheduled-events-with-docksal-43fc69d7b29b):

0 */3 * * * drush --root="/var/www/docroot" core-cron

My question is how tell if it’s actually working. I don’t see anything logged in at /admin/reports/dblog. I also tried enabling the syslog module, but I’m not seeing a syslog file at /var/log as described, using fin bash and cding to that directory.

I don't whether I should expect to see something, but would prefer I did. Otherwise it's like trying to check if the refrigerator light has gone off when you've closed the door.


texts:
I've got multiple newsletter purposes: some newsletters are for publicly available content and other newsletters are for example for journalists only or retailers only.

Is it possible to have each type as a Simplenews newsletter category? It doesn't seem to be out of the box, but I'm thinking it should be possible right?

My dream scenario would be to have these newsletter categories on admin/config/services/simplenews:

General news (open for all)
System news (mandatory for registered users)
Press releases (admin approval required)
Retail news (admin approval required)

Any suggestions on how to achieve this?

The long term idea is to add similar user roles for the restricted newsletter subscribers enabling restricted content, wholesale prices etc.


texts: How to keep/access copy of original Feed file when using HTTP Fetcher?

texts:
I've created Feeds importer to parse remote XML feed using HTTP Fetcher fetcher and I've created content type for that importer and Attached to it in Settings.

So my feed and import works fine after I've created importer node based on remote Feed URL.

However I would like to keep original remote XML feed file (fetched from the provided URL) similar as this happens for File upload fetcher to have a record/copy of it.

Is it possible? How?


texts: How do I programmatically update or delete menu items?

texts:
I have seen the post on how to create menu items programmatically in Drupal 8, but how do I update or delete menu items in D8?

Clarification: by programmatically I mean dynamically so yaml config files are not going to help.


texts: Create a form for editing a single field of an entity

texts:
I need to find a way for users just to edit a specific node field. We have a quite large content type and in a review process we would like some fields of a node to be editable for the revisioning user and some not. To avoid that the revisioning user needs to scroll through a large node form it would be very handy if he/ she would find a link on node detail page close to the text of the field where he/ she is pointed to a form just showing the field.

I found "Editable Fields" and "Quickedit" module which work not so well in our project due to some JavaScript conflicts. Additionally they do not really meet our needs as our main aim is not to make nodes editable on detail page. We just want to show a reduced form to the user for one specific field.

Does anyone has a solution how to create such a form? I think of something like calling the path "custom-form/[NID]/[REVISION_ID]/[FIELD_NAME]" which is connected to a page callback which renders a form for field [FIELD_NAME] in node [NID] of the corresponding revision version and validating and saving the input respecting the field's widget settings.


texts: Adding components to a feature via Drush

texts: I understand using 'drush fu' to look for changes to any components of an existing feature, but is there a way to add a component to an existing feature using drush? Right now I have to use the /admin tools to recreate, download the files, upload, etc. Would be nice if there was a way to do this process via drush.


texts: Function in template.php to override Profile2

texts: How can I make Profile2's overrides (profile2.tpl.php) work? Do I have to include a function "mytheme_preprocess_page" with "theme_hook_suggestions" in template.php?


texts: how do I get Rounded Corners to work on a ddblock in drupal 7?

texts:
I am trying to make the borders of a dd-block that I am using round. They are round in Firefox 5.0, but anything earlier than that, or in any other browser, it doesn't work. I have the CurvyCorners module installed, and I have the CSS set up to make it round. the problem is, that in chrome, only the header is round, and nothing else. and in Internet explorer, everything is round, except the dd-block, making it look like the dd-block is overlapping, and going over and past the corners of the region that it is in (being the Content region).
here is a copy of the CSS that is supposed to be making it round (I used 4 different classes/blocks at the same time just for a single dd-block, and it still won't work!):

#block-ddblock-7 {
    margin-left: -10px;
    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
   border-radius: 20px;
}

#block-ddblock-7 .slider {
     border-radius: 20px 20px;
    -moz-border-radius: 20px 20px;
    -khtml-border-radius: 20px 20px;
    -webkit-border-radius: 20px 20px;
    -o-border-radius: 20px 20px;
    width: 553px;
    height: 332px;
}

#ddblock-container clearfix ddblock-processed .inner {
     border-radius: 20px 20px;
    -moz-border-radius: 20px 20px;
    -khtml-border-radius: 20px 20px;
    -webkit-border-radius: 20px 20px;
    -o-border-radius: 20px 20px;
    width: 553px;
    height: 332px;
}

.slider ddblock-processed  {
    border-top-left-radius: 20px 20px;
    border-top-right-radius: 20px 20px;

    -moz-border-top-left-radius: 20px 20px;
    -moz-border-top-right-radius: 20px 20px;

    -khtml-border-top-left-radius: 20px 20px;
    -khtml-border-top-right-radius: 20px 20px;

    -webkit-border-top-left-radius: 20px 20px;
    -webkit-border-top-right-radius: 20px 20px;

    -o-border-top-left-radius: 20px 20px;
    -o-border-top-right-radius: 20px 20px;
}

what is it that I am doing wrong?

this is a picture of basically what it looks like. the part in blue is the "Content" region, and the part in orange is the ddblock:


texts:
I'm trying to custom-migrate D7 to D8 articles with references to file(images), taxonomy terms, and users(uid). Do i have to migrate the whole group all these entities belong to with

drush migrate_import --group=mygroup

to keep the references all right?

Or is it somehow possible to run one subsidiary migration and still keep the references, i mean

drush migrate_import mymigration

?


texts: Single User Table for multiple drupal sites

texts: I am having many drupal sites hosted in same server. But under different subdomain. I want a user registered in one site to be by default registered in other sites too. Optionally each site can have different profile fields. Is this possible?


texts:
We have nodes with a lot of inline images in them. And we are looking for a solution on how to lazyload inline images in Drupal 8.

We are trying to get the Blazy module to lazyload them but it is not working that smoothly since we have a ton of posts already and can't manually apply the src-data attribute and class to all existing images.

This is how I am trying to get blazy to lazyload all images, but it is not working. Any ideas on what we are doing wrong? We are open to all recommendations.

Apply lazyload / blazy to all images.

1) In mytheme.libraries.yml I added the following:

dependencies:
- blazy/load

2) In MYTHEME.info.yml I added the following

libraries:
- 'mytheme/global-styling'
- 'mytheme/local'

3) In MYTHEME.theme I added the following:

/**
* Implements hook_page_attachments_alter()
*/
function MYTHEME_page_attachments_alter(array &$attachments) {
  $attachments['#attached']['library'][] = 'blazy/load';
}

What is wrong?

Currently getting this error:

  Fatal error: Cannot use assign-op operators with overloaded objects
  nor string offsets in
  /core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php on line 138


texts: How to use CiviCRM contact data latitude and longitude in drupal gmap formatted view

texts:
Environment
Drupal 7.67
civicrm 7.x-5.13.4
GMap Module 7.x-2.11
Location 7.x-3.7
Views 7.x-3.23

What is working
I have CiviCRM contact data for organisations which has been successfully geocoded using google
I have view in Drupal that can access and display this contact data in a table including company names and latitude and longitude
I can display a google map in the contact record in CiviCRM, so I know the Lat & Long is correct

Problem
When I change from a table to a gmap format in the view no map is displayed,

View setup

  Format Format:GMap | Settings Show:Fields | Settings open Add Fields
  CiviCRM Website: Website URL (Website) CiviCRM Contacts: Contact ID
  CiviCRM Contacts: Organization Name (Retailer) CiviCRM Address: Full
  Street Address (Address) CiviCRM Address: Postal Code (Postcode)
  CiviCRM Phone Details: Phone (Phone) CiviCRM Tags: Name (Name) CiviCRM
  Custom: Organisation Fields: LALG Member Benefits (LALG Member
  Benefits) CiviCRM Address: Latitude (Latitude) CiviCRM Address:
  Longitude (Longitude)

GMap format settings

  Grouping field Nr.1

  You may optionally specify a field by which to group the records.
  Leave blank to not group. Macro [gmap ] Enter a macro. If left
  unchanged, it takes the default settings from
  /admin/config/services/gmap. See the documentation on GMap macros.
  Data Source

  Latitude field -> Latitude

  Format must be degrees decimal. Longitude field -> Longitude

  Format must be degrees decimal. Marker handling

I am also log messages when executing the view:

  php   Fri 7 Jun - 10:43am Notice: Array to string conversion in strtr()
  (line...  gjw
  php   Fri 7 Jun - 10:43am Notice: Array to string conversion in strtr()
  (line...  gjw
  php   Fri 7 Jun - 10:43am Notice: Array to string conversion in strtr()
  line...   gjw
  php   Fri 7 Jun -> 10:43am Notice: Array to string conversion in strtr()
  (line...  gjw

Details

  Type  php Date    Friday, 7 June 2019 - 10:43am User  gjw
  Location https://ref.lalg.org.uk/admin/structure/views/view/retailers/edit/retailers?destination=retailers
  Referrer  https://ref.lalg.org.uk/retailers Message   Notice: Array to
  string conversion in strtr() (line 1835 of
  /var/sites/r/ref.lalg.org.uk/public_html/includes/bootstrap.inc).
  Severity  notice


texts: Context for panel not activating for custom menu item

texts:
I'm loading a group node from a custom menu item I've created in a module. The reason I've created a custom menu item is because I wanted to use a different path than the one associated with the node.

I have a panel with a selection rule set to all group nodes. The custom menu item works and loads the group node, however, the panel is not being activated. I think it is something to do with the way I am loading the node from my hook_menu function which is preventing the context from being activated. The code I'm using is:

function mymodule_menu() {

$items['course/course-1/resources'] = array(
    'title' => 'Resources',
    'access callback' => TRUE,
    'page callback' => '_getpage1',
    'page arguments' => array(1),
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'menu-course-menu',
    'weight' => '1',
);

return $items;

 }

function _getpage1($arg1) {
    $path = drupal_get_normal_path("course/" . $arg1);
    $node=menu_get_object('node',1,$path);
    return node_page_view($node);
 }

Is there anything I need to add to activate the context for the group?

Many thanks,

Ben

ADDTIONAL INFORMATION:

I have two variants set up.

For the first:

Selection rule: Node is an OG group AND path matches "course/*/resources".

Context: No context is set

Relationship: OG Group from node

For the second:

Selection rule: Node is an OG group.

Context: No context is set

Relationship: OG Group from node

The first variant is supposed to be activated for the same group node when the path "course/course-1/resources" is used, and the second is supposed to be activated when the path is simply "course/course-1". At the moment only the second variant is being activated. When the path "course/course-1/resources" path is used it just shows the Course 1 group node in it's default layout with no panels being used.


texts:
I am trying to optimize a Drupal 7 site. I noticed the Expires header is set to just 6 hours, although according to my .htaccess file, it should be 2 weeks. Then i found out mod_expires module is not enabled. Now i have two questions:

Since i don't have the necessary rights, is there a way to set the Expires header without enabling mod_expires?
What is setting the header to 6 hours?

EDIT: Another strange thing is that the header is not there at all for some of the css files.

Also the settings in my /admin/config/development/performance is as follows, if related to this:

Cache pages for anonymous users: checked
Cache blocks: checked
Minimum cache lifetime: none
Expiration of cached pages: 1 day


texts: Error while adding any field in custom content type

texts:
I am unable to add any field in my custom content type, when I click on save button or click on upload after adding images it gives me the following error and for the text field the error is simply Exception thrown without a stack frame in unknown on lne 0, after this a white screen appears. :

After this website appears to be blank until I import the database again.
UPDATED
After adding following lines of code in the bottom of settings.php,

error_reporting(-1);  // Have PHP complain about absolutely everything
$conf['error_level'] = 2;  // Show all messages on your screen, 2 =   ERROR_REPORTING_DISPLAY_ALL.
ini_set('display_errors', TRUE);  // These lines just give you content on WSOD pages.
ini_set('display_startup_errors', TRUE);

I got the errors appears instead of white screen:


texts: How can I add a custom form to the output of a controller class?

texts:
I have a controller in my custom module.  Inside this controller I need to render a whole bunch of different things (some basic html, multiple forms, etc).  My main problem is I can't figure out how to

Properly load a Drupal 8 custom form
Then get that form into an acceptable format to pass to the #markup output of the controller.
Keep in mind this form is mixed in with other html that will be a mish-mash of lots of stuff not shown here (I've trimmed it down to show a basic example)

My controller code looks like this currently:

<?php

namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;

class SingleNodeProcessor extends ControllerBase {

  public function processSingle($nid) {
    $markup = '
' . $this->t('My custom Form Is below but there will be alot more html than just the form. So this is just an example.') . '
';

    $form = $this->formBuilder()->getForm('Drupal\my_module\Form\MyFormClassGoesHere', $nid);
    $markup .= $form; //this is a render array, how do I turn it to html so it can pass to #markup??

    return [
      '#type' => 'markup',
      '#markup' => $markup,
    ];
  }
}


texts: Set default form values after AJAX callback

texts:
OK I know this question has been asked multiple times from people in different ways but I haven't been able to pinpoint my exact use case or solution.

I have a registration form that I want to prefill the default values after the user selects an option from a select list. After they select an option, AJAX fires off to see if the user is in our CRM, and runs a series of code to look up information. I then want that found information to show in the various form fields on the page.

Couple key things to point out that I often find in other solutions that do not work for me:

The user is NOT submitting. They are still doing work on the form, the first form field sets up their experience going forward.
Setting the field info in $form_state['values'] doesn't work. Nothing is set.
Settings the field info $form_state['input'] does work, but then if a user changes any of the values in the fields, that new change isn't set.

Here is a stripped down example of what is being done.

function ces_user_registration_form_commerce_checkout_form_registration_alter(&$form, &$form_state, $form_id) {
    foreach ($form['registration_information']['register_entities'] as $name => $data) {
        foreach($form['registration_information'][$name] as $subname => $subdata) {
            $form['registration_information'][$name][$subname]['register_for']['#ajax'] = array(
                'wrapper' => 'commerce-checkout-form-registration',
                'callback' => 'ces_user_registration_form_register_for_ajax_callback',
                'method' => 'replace'
            );
            // run our code for comparing user values with CRM
            // return object with CRM data
            // below are example static value settings that I have

            // This works after AJAX is called, but the field isn't visually filled in for the user,
            $form['registration_information'][$name][$subname]['field_first_name']['und'][0]['value']['#default_value'] = "travis";

            // This works after AJAX is called, but changes to the field are not saved or recognized so we save their old value
            $form_state['input']['registration_information'][$name][$subname]['field_first_name']['und'][0]['value'] = "travis";

        }
    }
}

and the callback

function ces_user_registration_form_register_for_ajax_callback($form, &$form_state) {
    foreach ($form['registration_information']['register_entities'] as $name => $data) {
        foreach($form['registration_information'][$name] as $subname => $subdata) {
            if(!empty($form_state['values']['registration_information'][$name][$subname]['register_for']) && $form_state['values']['registration_information'][$name][$subname]['register_for'] == 'registration_registrant_type_me' ){

                // I tried moving the CRM code down here instead, but no changes
                // run our code for comparing user values with CRM
                // return object with CRM data
                // below are example static value settings that I have tried

                // doesn't work
                $form['registration_information'][$name][$subname]['field_first_name']['und'][0]['value']['#default_value'] = "travis";

                // doesn't work
                $form_state['values']['registration_information'][$name][$subname]['field_first_name']['und'][0]['value'] = "travis";

                // doesn't work
                $form_state['input']['registration_information'][$name][$subname]['field_first_name']['und'][0]['value'] = "travis";
            }
        }
    }
    return $form
}


texts: call from form alter - undefined function error

texts:
I try to use code for redirecting after submitting a form, but I am getting the below error:

  undefined function my_search_form_submit_funtion in form.inc.

Why do I get this error? Thank you.
The module name is utility.

function utility_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    $form['#submit'][] = 'my_search_form_submit_funtion';
  }
}
function my_search_form_submit_function(&$form, &$form_state) {
  $search_str = $form_state['values']['search_block_form'];
  $form_state['rebuild'] = TRUE;
  drupal_goto('search', array('query' => array('search_api_multi_fulltext' => $search_str)));
}


texts: How to check a user's current userpoints balance with Rules?

texts:
I am interested in creating a rule that checks a user's userpoints and then the rule performs an action.

Currently the Rules module doesn't have such condition. I read that this is possible to do with a Rules Component, that is used as a Rules Condition.

Could someone help me on this please?


texts: Show login or register to anonymous user fro flag

texts:
I created flag for nodes and trying to show a login or register link to anonymous users instead of the flag button on a node page (panels). A redirect to the signup form would be ok as well. I tried the Flag anonymous module but it doesn't work for some reasons.

Are there any other ways to realize this functionality?


texts:
I want to create a product catalog in drupal 8 commerce 2.

I have some products created, I also created a database index and in the view (Home>Administration>Structure>Views) I want to show 'rendered entity'(product teaser) instead of fields, because the variation field contains image, color, size... and I just want to display image, title and price in the catalog.

I tryed creating a new content type with a field 'Remote ID' but I have an error enabling this field, PluginNotFoundException, and I didn't found any solution.

So, I don't know how to create a teaser for a product without create a content type (or fixing the PluginNotFoundException).


texts: Is it possible to get Views data in the views-view.html.twig file?

texts:
I see this template just uses

{{ rows }}

Is it possible to get values from the views fields in this file?


texts:
If I install all updates from site_name/update.php, and after change the system.schema_version from 7005 to 7003 using (to reinstall updates 7004 and 7005)

UPDATE system SET schema_version = 7003 WHERE name = 'test';
I then try to run site_name/update.php but it not run because the fields that hook_update_N() adds already exists. And I see when access update.php after error that 2 updates exists.
After I restore system.schema_version to its initially value (7005)

Are the updates 7004 and 7005 now installed or not?


texts:
I have made and installed a new module, called searchIcon.
The problem is I want to edit the default value "Search" next to the search form.
I tried the code below, but it does not seem to work.
<?php

/*
 * Implementation of hook_form_alter()
 */

function searchIcon_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'search_block_form') {
        $form['actions']['submit']['#value']= 'TESTSEARCH';
    }
}

?>

How could I change the text "search" to e.g. "TESTSEARCH"?


texts: Connecting to a database from another application

texts: What is the proper way to do a remote connection to my Drupal database from a remote application? I am trying to integrate IPB with Drupal so I would like to modify my Drupal database from IPB.


texts: how to make a field in a view be the link destination to another field?

texts: I am trying to create ads on the sidebar to my site. I have created a content type that has 2 fields; an image field, and a link field. I now want to display the ads in a view by having the image appear, and when you click on the image, it brings you to the link that was specified by the link field. I know how to do this in a block with HTML, but I want to do it dynamically through a view. Is there any way to do this?


texts: Add images from external URL in WYSIWYG Editor

texts:
I am new to Drupal 8, and having some trouble with inline images.

Need

I store my images on Flickr, and want add them as inline images (in editor) in articles on my Drupal 8 site. I also need to set captions, and alignment for those images.

I don't need Drupal to manage the image files for me.

Problem

Drupal 8 uses a customized CKEditor Image Upload dialog, which does not support inserting images from a URL and only supports uploading images to the web server.
When I double clicked on a Flickr image added via HTML code, the image dialog won't show up.

My current workaround

In Configuration -> Text formats and editors:

Disable image uploads;
Turn off the filters Track images uploaded via a Text Editor, Caption images and Align images;
Allow align attributes for , allow
 and
 tag. (Or just use Full HTML and don't filter tags)

Hard-core the image () via Source in CKEditor;
Switch to WYSIWYG, double click on the image. Now the origin CKEditor image dialog (not the Drupal one) will show up which allows me to add captions or set alignment.

Further Observations

Images added this way will have code like

Caption

 even in editing mode.

Images managed by Drupal (if Caption images and Align images are on) will have alignment and caption added as data-caption and data-align attributes on  (no
 in editing, but will expand into that structure when viewing).

My Questions

How to disable the DrupalImage and DrupalImageCaption plugins (at core/modules/ckeditor/src/Plugin/CKEditorPlugin)? (I guess disabling them will solve this problem once for all.)
Are there any better ways to achieve my needs, for example a media library module that can support a range of image storing services. (But that will also need some hack into the CKEditor, right?)


texts: How can i set this redirect only for anonymous users?

texts:
namespace Drupal\project_extras\EventSubscriber;

use Drupal\Core\Url;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

class RedirectAnonymousSubscriber implements EventSubscriberInterface {

  public static function getSubscribedEvents() {
    // This announces which events you want to subscribe to.
    // We only need the request event for this example.  Pass
    // this an array of method names
    return([
      KernelEvents::REQUEST => [
        ['redirectMyContentTypeNode'],
      ]
    ]);
  }

  /**
   * Redirect requests for my_content_type node detail pages to node/123.
   *
   * @param GetResponseEvent $event
   * @return void
   */

  public function redirectMyContentTypeNode(GetResponseEvent $event) {

    $request = $event->getRequest();

    // This is necessary because this also gets called on
    // node sub-tabs such as "edit", "revisions", etc.  This
    // prevents those pages from redirected.
    if ($request->attributes->get('_route') !== 'entity.node.canonical') {
      return;
    }

    // Only redirect a certain content type.
    if ($request->attributes->get('node')->getType() !== 'specific_content_type') {
      return;
    }

    // This is where you set the destination.
    $redirect_url = Url::fromUri('entity:node/10');
    $response = new RedirectResponse($redirect_url->toString(), 301);
    $event->setResponse($response);
  }
}


texts:
I have a Google map loaded through the Google Maps API with markers generated from node locations.

How can I cause content to be loaded via AJAX when one of the markers is clicked.

For example, if the marker is clicked, it would replace another div on the page with information from that node gathered via a db query.

Currently I have the following js which will fire the alert when the marker is clicked

google.maps.event.addListener(marker, 'click', function() {
    //alert(marker.nid);
    $.post('search-map/ajax/marker.nid',{
        nid:marker.nid
    });
});

The "search-map/ajax/marker.nid" URL corresponds to a URL added through hook_menu

$items['search-map/%/%'] = array(
    'page callback' => 'mymodule_map_marker_click',
    'page arguments' => array(1,2),
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM
);

And then I'm trying to get this callback function to run, which as a test, just should replace the contents of a div with some test output:

    function mymodule_map_marker_click($ajax, $building_nid) {
        if ($ajax == 'ajax') {
            $commands = array();
            $output = 'test';

            $commands[] = ajax_command_invoke('.search-listings__listings', 'html', array($output));

            ajax_deliver(array('#type' => 'ajax', '#commands' => $commands));

        } else {
            // if ajax disabled
            return array(
            );
        }
    }

I get this response visible in Firebug, but no action happens on the page:

    [{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"mytheme","theme_token":"-CJtCsEvk1Nlzi_mfwSlDTCUoeOv7yyIBHLItpFSIC4"}},"merge":true},{"command":"settings","merge":false},{"command":"invoke","selector":".search-listings__listings","method":"html","arguments":["test"]}]


texts: How do I pass a variable via drupal_goto()?

texts:
So I have a function having http://link/to/$id as destination link.

It works when I use Targeted.

But I need to change it to submit form because I need to pass more than one $id. So, I thought it was good to use drupal_goto() rather than the link option.

drupal_goto('mymodule/option/$id');
drupal_goto('mymodule/option/'.$id);
drupal_goto('mymodule/option/', $id);

Those are not working. It always go to http://link/mymodule/option without passing $id variable. How do I do this correctly?


texts:
I'm having a hard time understanding Views and Entity Reference in the context of the Project Management modules.

I have created Project and Task Content types. For each of the Tasks I have chosen a Parent Project. I installed PM Gantt, but it does not list more than one project. I am trying to create a view to simply list all projects followed by that project's associated tasks, if any. Some projects will not have tasks.

How can I do this?


texts:
I want to make my entity fieldable and manageable from admin area with manage display and manage field admin ui. I have read few tutorials, but I still not understand how to do it? This question is related to my other question. Here is my entity code.

function statuses_entity_info() {
  $backupControl = module_exists('entity') ? 'EntityAPIController' : 'DrupalDefaultEntityController';
  return array(
    'status' => array(
      'label' => t('Status'),
      'plural label' => t('Statuses'),
      'description' => t('A status update.'),
      'entity class' => 'StatusEntity',
      'controller class' => module_exists('statuses') ? 'StatusesEntityController' : $backupControl,
      'base table' => 'statuses',
      'load hook' => 'statuses_load',
      'uri callback' => 'statuses_uri',
      'module' => 'statuses',
      'entity keys' => array(
        'id' => 'sid',
        'label' => 'message',
      ),
       'bundles' => array(
        'status' => array(
          'label' => t('Status'),
        ),
      ),
      'view modes' => array(
        'full' => array(
          'label' => t('Status message'),
          'custom settings' => FALSE,
        ),
      ),
      'entity cache' => FALSE,
    ),
  );
}

function statuses_entity_property_info()  {
  $info = array();

  $info['status']['properties']['sid'] = array(
    'label' => t('Status ID'),
    'description' => t('The ID of the status'),
    'type' => 'integer',
    'schema field' => 'sid',
  );

  $info['status']['properties']['sender'] = array(
    'label' => t('Status sender'),
    'description' => t('Sender uid of the status message'),
    'type' => 'integer',
    'schema field' => 'sender',
  );
  $info['status']['properties']['recipient'] = array(
    'label' => t('Status recipient'),
    'description' => t('Recipient uid of the status message'),
    'type' => 'integer',
    'schema field' => 'recipient',
  );
  $info['status']['properties']['type'] = array(
    'label' => t('Type'),
    'description' => t('Type of status message'),
    'type' => 'text',
    'schema field' => 'type',
  );
  $info['status']['properties']['created'] = array(
    'label' => t('Created'),
    'description' => t('UNIX Timestamp of creation date'),
    'type' => 'integer',
    'schema field' => 'created',
  );
  $info['status']['properties']['message'] = array(
    'label' => t('Message'),
    'description' => t('Status message'),
    'type' => 'text',
    'schema field' => 'message',
  );
  return $info;
}

function statuses_uri($status)  {
  return array(
    'path' => 'statuses/' . $status->sid,
  );
}

class StatusesEntityController extends EntityAPIController  {
//TODO
}

if (class_exists('Entity')) {
  class StatusEntity extends Entity {
    public function __construct(array $values = array(), $entityType = NULL)  {
      parent::__construct($values, 'status');
    }

    public function buildContent($view_mode = 'full', $langcode = NULL) {
      $content['sender'] = array(
      '#markup' => 'Sender Markup TEST',
      );
      $content['recipient'] = array(
        '#markup' => 'Recipient Markup TEST',
      );
      $content['created'] = array(
        '#markup' => 'Created Markup TEST',
      );
      $content['message'] = array(
        '#markup' => 'Message Markup TEST',
      );
      $content['sid'] = array(
        '#markup' => 'sid Markup TEST',
      );
      $content['type'] = array(
        '#markup' => 'type Markup TEST',
      );
      return entity_get_controller($this->entityType)->buildContent($this, $view_mode, $langcode, $content);

    }
  }
}


texts: Display node content with frontend theme in admin route

texts:
I need to display content with the frontend theme in an admin page to get a preview.
I get the content and built it with the ->getViewBuilder('node') but the template used is coming from the admin theme and the created template in the frontend theme node--newsletter.html.twig is not taken into account.

Is there a way to see the node view mode with the frontend theme instead of the admin theme ?
Thank you.


texts: Conditionally change the image field style and wrapping it in a div

texts:
The Article content type has been classified by taxonomy vocab Topic, where each Article's node has one topic.

For some usability and design requirements, I want Articles belongs to a specific topic to render the image field in different image style when it is on the full display mode.

I used the code in node--article.tpl.php:

if ($node->field_topic['und'][0]['tid'] == 154){
     // In some preprocessor...
    $images = field_get_items('node', $node, 'field_image');
    if(!empty($images)) {
      $image = field_view_value('node', $node, 'field_image', $images[0], array(
        'type' => 'image',
        'settings' => array(
          'image_style' => '200x260',
          'attributes' => array('class'=>'center-text')
        )
      ));
    }
    // Testing wrapping the image
    $variables['image'] = "----".$image."----";

    // Now, in your .tpl.php
     $content['field_image'] =  $image;
     }
  print render($content)

The above code renders the image with HTML code like the following:

<img typeof="foaf:Image" src="http://example.com/path/to/image/10_0.jpg?itok=COlIqejP" width="200" height="260">

However, it works fine but has two limitations:

1- I could not able to figure out how to enclose  the image inside a div with css class to style it using CSS. The img tag is supplied only i.e without any wrapping divs or spans!

2- Using it from node--article.tpl.php is not recommended and I have a custom module, but I don't know the suitable node's hook that allows me to perform this task.


texts: How can I create Menu items through hook_install()?

texts:
Like it was said in subject, how would I do that?

I need to create menu items once after module install and have the ability to edit them if needed.

module.link.menu.yml won't give me that ability.

Anybody have suggestions?


texts: Dynamic profile2 fields - User can add more fields while registration

texts:
how to add dynamic user registration fields . I need a phone number field which can be added by users during registration by pressing "add more" button as many times he wants .

Is it possible ? or any other approach ?

thanks


texts:
I would like to get a value from the reference node of the node_id
I used this code for PHP code in Contextual filter...

$node = menu_get_object();
if ($node->type == 'trailer_videos'){
       $mynode = node_load($node->nid)->field_trailer_video_of[und][0][target_id];
return $mynode;
}

The result is CORRECT!! but the page itself throw 2 errors:

Notice: Use of undefined constant und - assumed 'und' in eval()
Notice: Use of undefined constant target_id - assumed 'target_id' in eval()

Whats wrong with my code above????


texts:
For most of my projects i am using Devel module. Recently i looked at other module Profiling - it also provide integration with views and Panels. I was thinking to use this, as mentioned here it is stable but still lacks the Views and Panels support. So not sure i should use it or not (i am using views and panels).

Is there anybody who used this module and found it working (without bugs) ?

OR

You would recommend other module?

Thanks in advance.


texts:
I am trying to do a simple ajax request when the document is ready. Along with that, I also want to provide a function that is an onclick event.

Here is my code:

(function ($) {

  Drupal.behaviors.user_alert_get_message = {
    attach: function(context, settings) {

            $.ajax({
               type: "GET",
               url: "/admin/user-alert/get-message",
               success: function(data){
                   $('div#block-user-alert-user-alert').html(data);
               }
             });

        $('div.user-alert-close a', context).click(function() {
          alert(1);
        });
    }
  };
}(jQuery));

The click function does not fire. The ajax does. What can I wrap the ajax in so it only does this on page load, or, is that assumed through attach?

I also tried an onclick on the a tag, but Firebug said the function was undefined, even when it was defined as function (function name) in the .js file.

Edit:

If you have a click event that accepts an argument, how can I pass that in?


texts: Back button form in node linking back to view

texts:
I think the user who asked https://drupal.stackexchange.com/questions/49853/how-to-setup-go-back-button-in-views is trying to do a similar thing.

Is there a way within the Views module to add one to the node content output content from a view?

I don't want to use the Back Button module for this; I would prefer to use the Views module, if possible.


texts: What is the correct way to attach an arbitrary field from a different content type to an existing form?

texts:
I have a content type with a title and item id fields. The item ID field is a simple decimal and has unlimited entries. It acts as a reference to another field on a different content type.

In hook_form_alter(), I attach an AJAX callback to each existing item ID element. When the AJAX callback is called, I add the values that already exist from the other content type (image, a couple taxonomy terms), and two input elements to the results div. The two inputs are fields that exist on the other content type.

The way I do this is by loading the node whose item ID value correlates and adding it to the form (using a custom view type that only displays the fields I want). As for the inputs, I use drupal_get_form() to get the other content type's node form and copy the input element arrays into the form that I'm modifying. (This is the part that feels like cheating.)

On the page, everything displays fine. The problem is the form submission. When the new input elements try to validate, it fails. I've dug into the source code and discovered that the field does not exist in the $form_state array. That is to say, the corresponding $form_state['field'][$field_name] is missing.

My suspicion is that, upon splicing the form elements into the new form, the '#parent' and '#array_parent' arrays are not being updated correctly, despite being sure to add $form_state['rebuild'] = TRUE to hook_form_alter().

Is there a more correct way to add an arbitrary field from a different bundle to my form?

I considered using field_attach_form(), but I can't wrap my head around what the $entity argument should contain.

PS. I plan to handle the additional fields in a hook_node_prepare(), as I doubt shoving them into this content type would work!


texts: How can I remove "submitted by"? I already try to remove it on admin/structure/types/manage/page, but i still see "Submitted by...".


texts: MailChimp: Disable Tracking for Opens and Clicks

texts: Is there a possibility to disable the tracking for opens and clicks? I know that this can be changed within mailchimp but can I disable this option with the Drupal mailchimp module somehow?


texts: Ways to have lots of blocks on a site which is easy to manage

texts:
I am building a new site and the client has about 400 pages under about 5 main categories. Each of these 5 sub-categories has further sub-categories.

My client want to put a block onto each page which has unique content, which is editable.

Let's say that the block is pulling in the content type 'news'. This would be about 400 (ish) blocks - if done just through the blocks UI.

I know about context and view relationships (although not a great deal), but I was wondering if there was anyone out there who had thought on the very best way to approach this idea.

What ways are there to curate this content and make it easy for the client to find what they want to edit?

Is there a whay which has worked for you to go about this set-up, something that experience shows is a good idea, that I might not have thought of?


texts: I want to display images in grid view. I have designed a view which can display each album in grid view. Here album is a content type. The problem is that inside album I can see list view of images. I have selected unlimited number of value  in image filed under album content type. Below is the screenshot-


texts:
How do I combine two fields using the Views Global: Combine Fields Filter using an "Or" statement? For example, if my  filter combines Field A and Field B and my content is has Field A->Option A, Field B-> option C, it would show up when my filter is set to A OR C.

Desired results:

Field A
 - Option A
 - Option B
 - Option C

Field B
 - Option A
 - Option B
 - Option C

Combined Filter select Menu: Option A
 Expected result, content shows.

The default behavior seems to require that value is present in both field not either.


texts: How do I change my site time to test my recurring payments?

texts: I am testing the recurring framework in Drupal commerce on my local mamp environment and I want to test the recurring payments. How to I trick my Drupal site into thinking it's a day later so it will trigger the recurring payment?


texts: How can I prefill taxonomy tags for a new node being created through the node form?

texts:
I have created a cck node type and associated a tagging taxonomy vocabulary with it. When users create new content, I would like to be able to prepopulate the node form.

For example, if the node type were 'cars' and one term was 'antique', I want to be able to create new instances of cars with the tag 'antique' already populated in the editing form.

I have gotten as far as creating a path such as 'node/add/auto?tid=3' ... but how do I then take that tid and use it to prepopulate the vocabulary tags field in the auto_node_form?


texts: Any ways to create count column like mysql "COUNT(*) as counted" Column with d7's db_select()?

texts:
hello everybody i have to make tableselect form with some extra fields. To make table sortable I have to show which DB fields is used for the column in header:

$header = array(
    'uid' => array('data' => t('UID'), 'field' => 'u.uid'),
    'name' => array('data' => t('Name'), 'field' => 'u.name'),
    'mail'=>array('data' => t('Mail'), 'field' => 'u.mail'),
    'last_access' => array('data' => t('Last Access'), 'field' => 'u.access'),
    'login_count' => array('data' => t('Login Count'),'field'=>'a.count_logins'),
    'join_date'=>array('data' => t('Join Date'), ),
    'post_count'=>array('data' => t('Posts Count'),),
    'comment_count'=> array('data' => t('Comment Count'),)
  );

then I created a query for this:

$query = db_select('users','u');
  $query = $query->extend('PagerDefault')->extend('TableSort');
  $query->leftJoin(db_select('mycustom_report','r')->fields('r',array('count(*)    AS  count_logins','uid'))->groupBy('uid'),'a','a.uid=u.uid');
  $uids = $query
    ->fields('u',array('uid','name','mail','access'))->fields('a',array('count_logins'))->where('u.uid!=0')
    ->limit(50)
    ->orderByHeader($header)
    ->execute()
    ->fetchAll();

this query gives me this error

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'r.countAScount_logins'

any ways to create count field with db_select method in drupal? db_query() seems does not support ->orderByHeader() method

my full query which works fine looks like:

select u.uid,u.created,u.name,u.mail,u.access,counted_login,counted_post,counted_comment
  from users as u
          left join (select r.uid, count(*) as counted_login  from mycustom_report as r group by r.uid ) as d on u.uid = d.uid
          left join (select r.uid, count(*) as counted_post from node as r group by r.uid ) as p on p.uid = u.uid
          left join (select r.uid, count(*) as counted_comment from comment as r group by r.uid ) as c on c.uid = u.uid;


texts: CKEditor removes HTML/CSS when switching to plain texteditor and back

texts:
My CKEditor seems to remove formatting in a table when I switch from plain text editor back to rich text editor even though the additional formattibn was added in the rich text editor - it seems to persist whenb I switch to plain text but gets removed when I go back to rich text - I have tried around and Disabled the ADVANCED CONTENT FILTER under /admin/config/content/ckeditor/edit/Full but that did not seem to help,. How can I get my changes to persist even past text editor style switches?

EDIT 1

My configuration under /admin/config/content/formats/full_html looks like below but it still doesn't seem to work correctly (yes, I also cleared my caches):

and I selected Disabled /admin/config/content/ckeditor/edit/Full - ADVANCED CONTENT FILTER

EDIT 2
Now after all these changes , on another page my content doesn't seem to properly display anymore: link http://www.lslib.ca/content/skwlax-wellness-centre problem:
under
 I have a colorbox image declared:

 and it wouldn't show up anymore in HTML and I have no idea why...


texts: when mouseover on username display popup views

texts:
How to display popup ajax information of user when user mouseover on username or picture of users with views.
i want fetch information from profile user with ajax no hidden.
such as Facebook or LinkedIn


texts:
I've completed installation without error messages, but when I visit the site and attempt to log in, I can't, and I don't receive e-mails sent to reset the password.

Here are the details:

Using XAMPP 5.6.3 under Windows 7. Installing Drupal 7.36.

Site URL: localhost/Drupal7 (entered for "Site name" on "Installing Drupal" page of installation script)
Database user name: d7db_010_drupal7
Database name: (same as database user name)
Site user name: D7_010_Drupal7 (entered for "Site maintenance account Username" on "Installing Drupal" page of installation script)
Site e-mail address: D7LocAdmin@mydomain.com (not the actual domain)
Passwords for two above user names: 10-char pws generated by www.passwordsgenerator.net

Database d7db_010_drupal7:

- Table users has two records:
    * User ID 0: All other fields either empty, null, or 0
    * User ID 1: name = D7_010_Drupal7, pw = hash, mail and init both = D7LocAdmin@mydomain.com, created = 1428953185, login = 1428953512 (See note on timestamps below.)
- Table users_roles has one record: User ID = 1, Role ID = 3
- Table watchdog has 55 records, mostly about installing and enabling modules, and:
    * Event ID 52: uid = 1, type = user, msg = Session opened for %name., location = http://localhost/Drupal7/user, timestamp = 1428953513
    * Event ID 53: uid = 0, type = access denied, msg = user/1, location = http://localhost/Drupal7/user/1, timestamp = 1428953513
    * Event ID 54: uid = 0, type = user, msg = Password reset instructions mailed to %name at %email., location = http://localhost/Drupal7/user/password, timestamp = 1428953546
    * Event ID 55: uid = 0, type = user, msg = Password reset instructions mailed to %name at %email., location = http://localhost/Drupal7/user/password, timestamp = 1428953571

Note that value of "login" for user 1 in the table "users" is one second before the timestamp of events 52 and 53.

Actions I took when installation completed:

Went to localhost/Drupal7. Prototype page came up.
Entered site user name and its password. Nothing happened. No event for this in table "watchdog".
Clicked on link for "Request new password". In form that came up, clicked on "Log in" tab. Entered site user name and its password. Result: "Access denied". This is event 53
Clicked on "Request new password" tab. Entered "D7_010_Drupal7" and clicked button. Result: "Further instructions have been sent to your e-mail address." This is event 54. No e-mail received.
Clicked on "Request new password" tab. Entered "D7LocAdmin@mydomain.com" and clicked button. Result: "Further instructions have been sent to your e-mail address." This is event 55. No e-mail received.

I sent myself an e-mail at the site e-mail address to test that it's working and I received it.

Can someone see:

(a) Why I can't log in

(b) Why I'm not receiving the e-mails

or tell me what to inspect or test further to find out?

Thank you.

===============================

Update

In order to check that the problem is not with characters in the user name or with using the wrong password, I reset the name and password to "hello" and "there". I did the following:

Ran php on "scripts\password-hash.sh there"

The response was

password: there hash: $S$DK0K/McRjrM9f7D/OwExsr8Fk.8uaU1U4CC030GbqjAArbEMIFg/

Ran the following two queries on table "d7db_010_drupal7":

UPDATE users SET name = 'hello' WHERE uid = 1;

UPDATE users SET pass = '$S$DK0K/McRjrM9f7D/OwExsr8Fk.8uaU1U4CC030GbqjAArbEMIFg/' WHERE uid = 1;

Entered "hello" and "there" on the login on the main page. Again, nothing happened.
Went to "localhost/Drupal7/user" and entered "hello" and "there". Result: Access denied.
Repeated the last step above in case of mistyping. Result again: Access denied.

Grrr!


texts:
A couple months back I successfully setup a development site to learn about the Drupal 8 REST API with version 8.0.x using the REST UI module for configuration. When I heard about the improvements to the REST Services in Drupal 8.2 I was pretty excited (from my understanding it is now possible to access configuration data such as content types and taxonomy terms) so I setup a new install using version 8.2.1. However, understanding the configuration for 8.2 is pretty daunting, and since it's so new there are very little resources around the setup and configuration.

I was able to locate this resource and I imported the example configuration provided, but was still unsure on how to configure other REST Endpoints.

I used the default configuration provided in the above resource. It looks like this:

langcode: en
status: true
dependencies:
 module:
   - basic_auth
   - hal
   - node
id: entity.node
plugin_id: 'entity:node'
granularity: resource
configuration:
 methods:
   - GET
   - POST
   - PATCH
   - DELETE
 formats:
   - hal_json
 authentication:
   - basic_auth

How do I edit the configuration once it's imported via the configuration manager?
Where can I find the available plugin_id's so that I can configure other resources? Where can I learn more about plugins?
How would I begin to implement my own REST endpoint?

I know this is a lot to ask, but at the time of writing there is little to no information covering these topics so I figure other people might be confused as well. I would like to create a guide on this, but that would first require that I understand it first.


texts:
I like having site alias defined for easy Drupal management for backing up, syncing dev site with live etc.

But I am afraid of having great loses if I mistyped the drush command having order of site aliases interchanged.

drush sql-sync @dev @live

Instead of:

drush sql-sync @live @dev

Other possibilities include:

drush rsync @dev @live

Is there any option that I can set while defining site aliases that make a site ready only in drush commands? I tried to find one, including drush source code, but didn't succeed.

Of course, outside of drush I can create separate user account that only have ready only access to the site. Also extra database user with no CREATE/UPDATE permissions.


texts: Entity References Auto create between Nodes

texts:
I have node 1 has a reference to node 2 & node 3
how can I make node 2 & node 3 have a reference automatically (because they have the same reference with node1)?


texts: Relationship to content in term view causes duplicate and missing results

texts:
I have these terms, nodes and comments. So 'NodeA' and 'NodeB' are tagged with 'Term1'. Both 'NodeA' and 'NodeB' have new comments.

Term1
-NodeA (has new comments)
-NodeB (has new comments)
Term2
-NodeC (no new comments)
-NodeD (no new comments)
Term3
-NodeE (no new comments)
-NodeF (has new comments)
Term4

I need to make a view that looks like this:

Term1 – new comments!

Term2

Term3 – new comments!

Term4

If I make a term view is stars out ok:

Term1

Term2

Term3

Term4

However when I add a relationship 'Taxonomy term: Content with term' then add the field 'Content: New comments' using this relationship, then I get this:

Term1
New comments: 1

Term1
New comments: 1

Term2
New comments:

Term2
New comments:

Term3
New comments:

Term3
New comments: 1

I get a result for each node, not 1 result for each term. I also get no result at all for the term with no nodes. Is there a solution within views for this?


texts: How to appened a new 'class' attribute to a custom field ? - twig drupal 8

texts:
Just started to work around with Drupal 8.

I want to add class "center-block" to the field_product_image.

How do i do this guys?
below is the twig code

   {% if content.field_product_image| render %}

    {{ content.field_product_image }}

    {% endif %}

        {{ content.body }}
        {{ content.field_features }}


texts: display list of pages of content type using views + edit and delete option

texts:
I've installed the Views Bulk Operations module (VBO). Using this I want to create a block/page to  load all the pages of particular content-type. But it should include options like update + check boxes, edit/delete. See the screenshot below.

I couldn't find the built in view 'content', so I've to create from scratch. Please give me solutions.


texts: How do I find or set the apropriate form for base scheme fields?

texts:
In my custom entity I want to set a base scheme field, which is an integer. The field has a minimum of 0, a maximum of 360 and a default of 180.

I tried this so:

    $fields['pan'] = BaseFieldDefinition::create('integer')
  ->setLabel(t('PAN'))
  ->setDescription(t('Horizontal Positioning'))
  ->setSettings(array(
    'default_value' => 180,
    'min_value' => 0,
    'max_value' => 360
  ))
  ->setDisplayOptions('view', array(
    'label' => 'inline',
    'type' => 'default',
    'weight' => -3,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'number',
    'weight' => -3,
    'settings' => array(
      'default_value' => 180,
      'min' => 0,
      'max' => 360
    ),
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

Neither the form is limited nor the input is limited when I post.

How can I get the correct type for my form and the correct settings? How can I look for them? Where?

Edit: solution is the following:

    $fields['pan'] = BaseFieldDefinition::create('integer')
  ->setLabel(t('PAN'))
  ->setDescription(t('Horizontal Positioning'))
  ->setDefaultValue(180)
  ->setSettings(array(
    'min' => 0,
    'max' => 360
  ))
  ->setDisplayOptions('view', array(
    'label' => 'inline',
    'type' => 'number_integer',
    'weight' => -3,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'number',
    'weight' => -3,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);


texts: What function should I use to truncate a string?

texts: What function should I use to truncate a string in Drupal 5?


texts:
Whenever I want to enable/disable modules I am given different errors like the one below. These error messages change every time disable/enable a module.

"Fatal error: Out of memory (allocated 31981568) (tried to allocate 311296 bytes) in /homepages/4/d364988985/htdocs/sites/all/modules/views/modules/node.views_default.inc on line 278"

I have already done the following steps:

created a php.ini file with the following line:

memory_limit = 512M

put it into the Drupal root folder

This fixed the major problem of the whole site showing an error.

The host that I am using is 1and1. Is there a way that this can be fixed?


texts: I want to show the limited amount of products using JCarousel module?

texts: I am using Jcarousel module for products to show the front page. So I want to show the limited amount of products. I mentioned in views  Use pager: Display a specified number of items | 5 items .But it doesn't work it.. It shows the all produtcs in the front page.. How to configure it..


texts: Headless Drupal 8 - cookie authentication

texts:
I am successfully using a headless Drupal 8 setup that I am querying through Drupal 8 core REST API with basic auth from jQuery AJAX. Now I need to get closer to production conditions, so I started trying to use cookie-based authentication. Problem is that the exact same query that successfully POSTed content using basic auth now returns an HTTP 403.

Is there any working example of a POST request to create an article with cookie authentication? Am I missing something?

I have a fresh Drupal 8.3.1 install with REST UI, Serialization and HAL modules enabled. The REST endpoints are configured through REST UI. The /node/{node} endpoint is set up to allow all requests in all formats with cookie auth. Taxonomy and user endpoints are configured likewise.
The queries (POST & GET) to REST API are made from AJAX calls from jQuery. These queries work fine with basic auth. This is a query example.

$.ajax({
      url: 'my_drupal/entity/node?_format=hal_json&foo=bar,
      method: 'POST',
      headers: {
        'Content-Type': 'application/hal+json',
        'X-CSRF-Token': csrfToken, // I got that token by first GETting my_drupal/rest/session/token
        'Authorization': 'Basic ' + btoa(this.credentials)
      },
      data: JSON.stringify(node),
      success: function (node) {
         // success logic here
      }
    });

Please note that I already tried removing the Authorization header with no luck.

Monitoring HTTP requests, I do see the Drupal authentication cookie being sent along with my POST request.


texts: How can I override template_preprocess_file_link function?

texts:
I want to print file size near file link in file-link.html.twig template.
To do so I need something like {{ filesize }} variable avaiable in template.

I tried to override template_preprocess_file_link() with an override function in mytheme.theme like mytheme_preprocess_file_link() but I get this error:

The website encountered an unexpected error. Please try again later.
Error: Class 'File' not found in tofacile_preprocess_file_link() (line 12 of themes/custom/mytheme/mytheme.theme)

It seems like a class missing... should I add "use Drupal\File\SomethingXXX" declaration??

Thanks

This is my code:

<?php

/**
 * @file
 * Functions to support theming in the Tofacile theme.
 */

function tofacile_preprocess_file_link(&$variables){
  $file = $variables['file'];
  $options = [];
  $file_entity = $file instanceof File ? $file : File::load($file->fid);

  // @todo Wrap in file_url_transform_relative(). This is currently
  // impossible. As a work-around, we currently add the 'url.site' cache context
  // to ensure different file URLs are generated for different sites in a
  // multisite setup, including HTTP and HTTPS versions of the same site.
  // Fix in https://www.drupal.org/node/2646744.
  $url = file_create_url($file_entity
    ->getFileUri());
  $variables['#cache']['contexts'][] = 'url.site';
  $mime_type = $file
    ->getMimeType();

  // Set options as per anchor format described at
  // http://microformats.org/wiki/file-format-examples
  $options['attributes']['type'] = $mime_type . '; length=' . $file
      ->getSize();

  // Use the description as the link text if available.
  if (empty($variables['description'])) {
    $link_text = $file_entity
      ->getFilename();
  }
  else {
    $link_text = $variables['description'];
    $options['attributes']['title'] = $file_entity
      ->getFilename();
  }

  // Classes to add to the file field for icons.
  $classes = [
    'file',
    // Add a specific class for each and every mime type.
    'file--mime-' . strtr($mime_type, [
      '/' => '-',
      '.' => '-',
    ]),
    // Add a more general class for groups of well known MIME types.
    'file--' . file_icon_class($mime_type),
  ];

  // Set file classes to the options array.
  $variables['attributes'] = new Attribute($variables['attributes']);
  $variables['attributes']
    ->addClass($classes);
  $variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options));
}


texts: Add user email and username under the "View" tab at /user/%

texts:
Using Drupal 7 and I would like to display the username and email under the view tab of the /user page.

Out of the box it only shows the user History, which I find a bit meaningles. I think that a user should see all his info under the view tab (including username and email) and then when he wants to edit it he can click on the edit tab.

Would be nice if this could be done with a block or similar so that this does not apply to the admin user.

Thanks!


texts:
Although in Performance, the Block caching is disabled but I've a block created by Clock module(http://drupal.org/project/clock) when accessed as anonymous user it does not update the clock on every page reload.

I've even tried clearning browser cache but it works fine when logged in. For registered users it seems block caching is disabled.

The Clock block is there in this site: http://bit.ly/PKI2M8 - please scroll to bottom-most right block titled 'Rail Time'.

How can I disable caching of this block?


texts: Default to "no limit" for maximum number of options in field type select

texts:
The number of cities and sectors "small cities" in Moldova is around thousand,so we have already exceeded the arbitrary 100 limit without half-trying.

The limit causes problems when we translate the options.

We get message translations were saved successfully, however going back to translation noting is saved.

Looking into server logs we found out there is a problem with max_input_vars in php.ini

  2016/02/02 11:37:26 [error] 1310#0: *199007 FastCGI sent in stderr:
  "PHP message: PHP Warning:  Unknown: Input variables exceeded 1000. To
  increase the limit change max_input_vars in php.ini. in Unknown on
  line 0"

We updated the php.ini file and set the max_input_vars = 5000. After that the Error above disappeared, however we are still unable to save the translations and there is no error in the server console logs.

Is there anything we can do about this problem.


texts:
How to use contextual filter in view by rest calls? I cant get it to work whole day.

I made View with "Provide a REST export". I added contextual filter. But it doesnt work.

Thanks


texts: Is there any hook or event that is fired when user data is set/updated/deleted

texts: I am using the user.data service to store additional data for users. I would like to trigger some custom functionality each time the user.data is changed. I can't find any hook or event that I could use. Is there any way to achieve this?


texts: How do I create a flag so each user gets to set one flag on one instance of a content type?

texts:
I want to create a non-global flag which each user can use to 'flag' one (and only one) instance of a specific content type.

I have a view which displays a list of content with fields, including a flag link.  I would like to set up my flag (or a rule with a flag) so that if a user clicks on a flag link, all other flags that that user has set (for that specific flag type) are reset.

This will be used for a 'favorite' type of flag, which can only be set on one instance of a specific content type.


texts: How to delete a value from a multi-value entity reference field with EntityMetadataWrapper

texts:
I have multiple values in an entity reference field.  I want to delete one of those values, but ::clear doesn't seem to work.  I basically just want to do an unset, like:

$wrapper->field_entityrefs[3]->delete();

or something clean like that.  What is the best way?


texts: How can I set a field's #value in a custom Form AJAX function?

texts:
I have a managed_file field type that has its own build-in #ajax command and I need to add an additional custom command that will populate a hidden field on the form.
So far I have a custom managed file class that extends the core managed_file ajax callback. From this class I can populate the hidden field's #value using:
   public static function uploadAjaxCallback(&$form, FormStateInterface &$form_state, Request $request) {

            $response = parent::uploadAjaxCallback($form, $form_state, $request);

            $fid =1;
            $form['fid'] = array(
              '#type' => 'textfield',
              '#prefix' => '
',
              '#suffix' => '
',
              '#value' => $fid,
            );
           $response->addCommand(new ReplaceCommand('#fid', $replace ));
           return $response;

The problem is that this value, although visible in the browser is not actually set in the $form object when I examine it in my custom form.
I've tried setting and returning the field in the ajax callback and it sort-of works but it removes the other fields from the form so only my fid field exists. I believe that if I return the $form['fid'] field from the extended ajax callback that is called from a managed_file field it is overriding the expected return for the managed_file field and replacing it with my custom field.
   return $form['fid'];

So, how can I set a field's #value from my custom ajax callback where it's actually set in the form and not just visual in the browser source?


texts: How do I add a user as a field in Drupal 7?

texts:
References claims that it is now deprecated in favor of Entity Reference.  But I can't quite connect the dots on how an Entity Reference can point to a specific user.  Ideally, I would have this field simply be the user that originally submitted the node.

Basically, all I want is a "File" content type that includes the user who uploaded the file.  I feel like I am over-complicating it.  Please help.


texts: Include external html to a Twig template in Drupal 8

texts:
Hi I need to include some external html code to be included as part of a template.
I tried by using twig include:

{% include 'http://external-url' %}

but Drupal launches the following error:

Twig_Error_Loader: Template "http://external-url" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "http://external-url" in the Drupal theme registry.)

I used to have:

{% include directory ~'/partials/header.html.twig' %}

where header.html.twig contained the necessary html. But as that html will be updated by third parties, I need to include from external url.

Any way to do that? Maybe I could add the url to the Drupal 8 RegistryLoader some way?

Thanks


texts: How to change the pagination of related entities displayed on a taxonomy term page?

texts:
On a default taxonomy term page, related contents are automatically paginated by 10.

Let's say those related contents are always nodes and we always display the default teaser view mode.

How can I change the number of node teaser by page without using a module or a view?


texts:
I am trying to change the way "Search results" header is rendered in D8. Unfortunately HTML is hardcoded in SearchController and not themeable. I figured I could use hook_block_view_alter to change the $build['search_results_title'], but the hook implementation from my theme never gets called:

function labweb_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
  if (isset($build['search_results_title'])) {
    unset($build['search_results_title']);
  }
  kpr($build);
}

Any ideas? It seems that this hook never gets called...


texts:
I'm trying to display a form in a template (not my first choice, but I'm restricted in what I can do here) and I'm having some trouble figuring out how to do it.

I'm trying to tie into the Ubercart Addresses module to allow the user to select from one of the countries available to them.

I believe this information is located in uc_addresses_get_address_form

What I'm trying to do is as follows:

<?php  print render(drupal_get_form('uc_addresses_get_address_form'))?>

But this doesn't seem to add the form information I want.

How do I get this information into a template file?


texts:
I have drupal 7.54 that are placed in  /var/www/html which I use as main site.
Also I have drupal 8 (for testing) that are placed in /var/www/html/drupal8  where I have drush.

And there is some problem. When I tried to launch command "drush status" it gives me information about drupal 7. And it happens regardless directory of drush.

How to specify version of drupal on which drush must operate?

And I want to notice that I installed drush not via composer but just downloaded and unzipped it.


texts:
I am trying to create a new menu link. But the system doesn't allow me to do so.

The path 'New' is either invalid or you do not have access to it.
The path 'testss' is either invalid or you do not have access to it.


texts: Using Entity Field Queries with "does not contain"?

texts:
I have an EFQ that selects all nodes with titles not equal to 'panda'.

$query = new EntityFieldQuery;

$results = $query
 ->entityCondition('entity_type', 'node')
 -> propertyCondition('title', 'panda', '!=')
 ->execute();

How would I go about changing this query to give me only nodes whose titles don't contain the word 'panda' at all?


texts: Exposed select filter type with content type

texts:
In my newly installed Drupal 8 project i have created a content type named "Hardware Type" (with several fields, like name, usage, requirements ), for which I have added a bunch of items, and another content type called "Hardware", with several fields (including "Hardware Type", taken from my previously created content type).

Now, I have a view for "Hardware", where I use an exposed filter, with different fields for "Hardware Type", "Price", "Manufacturer".

Currently, the "Hardware Type" is a a simple input[type="text"], where I can add IDs from "Hardware Type" and filter the list. What I want is this input to be a select element with a list of "Hardware Type" elements.

Is this possible with what Drupal 8 provides or do I have to create a module? I installed the alpha version of Better Exposed Filters and I making a mess with Reference Views but it looks like I need some basic step stones to figure out this apparently simple feature integration


texts: Access Paragraph fields programmatically in custom module

texts:
I have a Product content type with these fields; title, body, and one entity reference revisions(Paragraph: field_select_module).
I am creating a custom REST API(custom module) to export the fields in the JSON. I am able to print the title and body. Could someone help me to print the paragraph fields which have title and image(Media) and title and image will repeat 3 times. It should be inside this array 'product_list' => array(),
Here is my controller.
<?php

namespace Drupal\drupalup_json_api\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\node\Entity\Node;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\paragraphs\Entity\Paragraph;

/**
 * Controller for export json.
 */
class JsonApiController extends ControllerBase {

  /**
   * {@inheritdoc}
   */
  public function data() {
    $json_array = array(
      'data' => array()
    );
    $nids = \Drupal::entityQuery('node')->condition('type','product_main_categories')->execute();
    $nodes =  Node::loadMultiple($nids);

    foreach ($nodes as $node) {
      $json_array = array(
        'id' => $node->get('nid')->value,
        'title' =>  $node->get('title')->value,
        'content' => $node->get('body')->value,
        'product_list' => array(

        ),
      );
    }
    return new JsonResponse($json_array);
  }
}