texts: How to properly duplicate image for "clone" form?

texts:
I have a form for cloning entries. Basically it works the same way as entry add form, it saves under brand new ID, but is pre-filled with data from existing entry.

For data like text and references, this is easy. Problem starts with images. I do not want to reference one image in multiple entries, it would not be convenient for reasons that are out of scope of this question. So I wrote simple function:

function _file_copy_by_id($fid) {
  $source =  file_load($fid);
  // Copy to the same place, let the Drupal care for renaming
  $result = file_copy($source, $source->uri, FILE_EXISTS_RENAME);

  return $result->fid;
}

And in my form I made image field look like that:

'DimensionImageFile' => array(
  '#type' => 'managed_file',
  '#title' => t("Image"),
  '#title_display' => 'invisible',
  '#upload_validators' => array(
    'file_validate_extensions' => array('gif png jpg jpeg'),
    'file_validate_size' => array(variable_get('mymodule_image_size', 5 * 1024 * 1024)),
  ),
  '#upload_location' => 'public://mymodule/image',
  '#theme' => 'preview_upload',
  '#default_value' => _file_copy_by_id($product_data['DimensionImageFile']),
),

Now, it looks OK when form is rendered:

In the database, it looks OK too. Exported entry:

INSERT INTO `file_managed`
(`fid`, `uid`, `filename`, `uri`, `filemime`, `filesize`, `status`, `timestamp`, `origname`)
VALUES
(426, 16, 'test.jpg', 'public://mymodule/image/test_3.jpg', 'image/jpeg', 37237, 1, 1391088561, 'test.jpg');

No entry in {file_usage} - just as expected.

File is there, with number added properly, but when I try to save, all I get is:

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

If I will add "fake" usage, like this:

function _file_copy_by_id($fid) {
  $source =  file_load($fid);
  // Copy to the same place, let the Drupal care for renaming
  $result = file_copy($source, $source->uri, FILE_EXISTS_RENAME);
  file_usage_add($result, 'mymodule', 'clone', 0, 1);
  return $result->fid;
}

form works all right. But files are reported as used. That's bad, because if user will decide to remove and replace them, cloned ones should get deleted as soon as possible, and the fact they are reported as being used prevents cleanup deletion.


texts:
I have created a views page which displays teasers of specific content type.

When creating content I am also uploading an image which we want to display on the background of the relevant teaser.

So every teaser has its image on the background.

Looking forward for professional guidance in this regard.


texts:
I am writing a custom module to add surcharge values to a commerce order at the time of UPS shipping calculations. I am trying to find a way to access the total weight of the order.

I thought I would be able to access the weight from the array returned by:

entity_metadata_wrapper('commerce_order', $order);

Unfortunately it's not present in the data that I can see.

Does anyone know how I can access the total weight of an order or are these generated dynamically when the UPS shipping process is called?


texts: Exist any way to integrate Google Rich Snippets in D6?

texts:
I have a dilemma with the topic of Google Rich Snippets in drupal 6.
Looking, no module to do so (Yes in Drupal 7, but work with drupal 6) and looking not find any solution. (I use Fivestar on my site)

So my dilemma is whether or, if it can implement this in Drupal 6 ... And that way you can do.

Someone to do? Someone could find a solution? I'm not as expert in Drupal but I want to know whether and in what way. It is urgent.

Thanks :D


texts: Notice: Undefined index: highlighted in include() (line 124 of page.tpl.php

texts:
I keep getting this error in a fresh drupal install with fusion and a custom fusion subtheme:

Notice: Undefined index: highlighted in include() (line 124 of /home/username/public_html/modules/system/page.tpl.php).

Would anyone happen to have any clue as to what is causing this?


texts:
I have used the following code to insert values to database

$query = \Drupal::database()->insert('node__field_ssl_cert_fields');
$query->fields([
  'entity_id',
  'revision_id',
    'delta',
    'field_ssl_cert_fields_privatekey',
    'field_ssl_cert_fields_csr'
]);
$query->values([
  $nid,0,0,$pkeyout,$csrout
]);
$query->execute();

When I printed the query it is as follows

INSERT INTO {node__field_ssl_cert_fields} (entity_id, revision_id,
delta, field_ssl_cert_fields_privatekey, field_ssl_cert_fields_csr)
VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4)

Here node__field_ssl_cert_fields is the table. entity_id, revision_id, delta, field_ssl_cert_fields_privatekey, field_ssl_cert_fields_csr are fields.

What will be the fault?


texts: How to define Views filters and relationships for custom Civicrm contact fields that are indexed via Search API?

texts:
I followed the steps on skvare to index CiviCRM contacts via Search API, then to have Views list the contacts with the search box as an exposed filter.

I need to expose a filter that filters results based on what membership type the contact has. That might require a relationship, which is currently not an option in Views for me, so I might have to write a custom relationship handler as well as the custom filter handler. I have been trying to find the code to read to use as a guide but I have been unable to figure out whether these handlers are being defined in CiviCRM, Views, Search API, or the Civicrm Entity module which I'm also using.

How do you define a custom relationship and filter handlers for custom fields on CiviCRM contacts being displayed via Search API, CiviCRM Entity, and Views?


texts: How to display messages from a block separately from $messages in page.tpl.php

texts:
I have a webform which works as a newsletter subscription form: it displays a textfield for an email and a button. When the button is clicked, a notification message is displayed on top of the page where any other messages are usually displayed.

However because the webform is a block and it's displayed in the sidebar, it would be more usable if the message is displayed right above the block, where visitor's focus currently is, instead of top-middle of the page. Is this something possible to implement?

To generalise: is it possible to display messages from different blocks/modules in different sections of the page instead of the unified $messages variable?


texts: Form API ajax calls reload attached JS using behaviors

texts:
I have leaflet map attached to my form, this is the container div I used:

$form['general']['map'] = array(
  '#markup' => '

',
);

Everything works fine and map's being loaded. I also added an image upload functionality in bottom of my form like this:

$form['detailed']['img'] = array(
  '#type' => 'managed_file',
  '#upload_location' => 'public://map-images/',
  '#required' => TRUE,
  '#title' => 'Image',
  '#default_value' => $complain['image'],

);

When I click on ajax upload button after selecting the image file, it throws an error and nothings happen:

  Uncaught Error: Map container is already initialized.

Seems like uploading file is forcing leaflet.js to reload map container. My guess is ajax is reloading and rendering the whole form all over again.

How's that possible and what's the easiest fix for this? Thank you.

Edit:
How I added initializing function, look like this attached js is being recalled everytime I click on upload image ajax button:

(function($, Drupal) {

  // Custom functions and variables can go here
  Drupal.behaviors.moduleName = {
    attach:function() {
      map = new L.Map('ngmap', {center: new L.LatLng(37.472, 57.327), zoom: 13});
      googleLayer = new L.Google('HYBRID');
      map.addLayer(googleLayer);
    }
  };
}(jQuery, Drupal));


texts: How to list the uploaded files (image file) of unsaved nodes?

texts:
From the question What happens if a user uploads an image but doesn't save the node? and its answer, there is a table called file_managed and for any uploaded file (an image in my case), it sets 0 in status column, and if the image node is saved, it is set to 1. During each cron run, all files with 0 status will be removed.

I am using bulk_file_nodes module to upload the images. Unfortunately, this module sets the status 1 for uploaded files and no matter if their node is saved or not.

I need to accomplish what Drupal core does for unsaved nodes of uploaded files. To do so I have to list those files. There are about 30000 images and about 2500 nodes in my website that are uploaded by people and it is growing very fast every day.

The brute force method is to check the entire fid column of field_data_field_image table of the database for every file (in fact for every fid of file_managed) to see if that file is attached to a node or not, I think it is not a good solution at all.

Is there any way else to handle this?

thanks


texts: In editing content, can I show source formatted HTML

texts:
Might there be a way to show properly formatted HTML when in CKeditor's source view? Is there a way to color code the HTML and Javascript source for my more advanced content editors?

I have turned on Apply Source Formatting which has helped some.


texts:
I tried everything to turn the cache off. Even when using drushs command "cr" it does not help.

I used this guide:
https://www.drupal.org/node/2598914

I cannot work like this. I also turned on devels theme rebuild on page view feature. Although I don't understand what is meant with this here:

  Rebuild the theme information like the registry
  While creating new templates, change the $theme.info.yml and theme_ overrides the theme information needs to be rebuilt.

Example:

function theme_preprocess_taxonomy_term(&$variables) {
    kint("1");
}

When changing the number even "drush cr" does not help. I got to refresh like 4 times until the browser shows the change.
Its not like that with kint - also "var_dump()" needs it's 4,5 times.

Could anybody please tell me what to do?


texts: How can I limit the days returned in the date module to today's and future dates only?

texts:
I have the Date module installed on Drupal 7 (version 7.x-2.5) and I am attempting to disable the selection of past dates within the date popup.

$form['ratesDateSelect'] = array(
    '#title' => 'Arrival Date',
    '#type' => 'date_popup',
    '#default_value' => '',
    '#size' => 21,
    '#maxlength' => 100,
    '#date_flexible' => 0,
    '#date_year_range' => (date('Y')) . ':+5',
    '#attributes' => array('autocomplete' =>'off','readonly' => 'readonly'),
    '#description' => '',
    '#value' => array('date' => $date),
    '#date_format' => 'D d M Y',
    '#required' => FALSE,
);

I have limited the popup to return this year and five years into the future, but I also need to restrict it so that people cannot select past days.

I have managed to do this in another project using pure javascript, using the datepicker param: minDate: 0


texts: How to display term images instead of term names in the term selection process?

texts:
I have a content type with a term reference field (check boxes widget, vocabulary: Category) from which every user has to choose one term to be attached to his node.

I have also added an image field to the Category vocabulary to attach a default image to each term.

How can i display the term images and the term names instead of only the term names in the term selection process when creating the node? Is there a module out there?

Or maybe using hook form alter. Any guidelines?


texts: Show / Hide login menu item not connected to node

texts:
I have a login menu item that links to the login page of my website. I want to have the menu item disappearing when someone is logged in and an a sign out button appearing in its place.

Since the menu item is not connected to a node, i cannot alter it's visibility based on node access rights. I found Menu Item Visibility module but it is beta and it does not seem to be maintained. Is there a way to do this via Drupal?

If I have to make a custom module or js can you give me a link of a tutorial on how to do this?


texts: Admin menu bar covers part of the screen while working in mobile mode

texts:
I think that the image I attached says it all - a part of the screen is covered by admin menu in mobile view from my pc (this is the default firefox mobile view).

It's extremely problematic when I need to check something that is at the fold of the page, i.e at the top part of the page beacuse it also being covered and I have no where to scroll-up to, and must logout to view it or check through another browser and this can be tiresome sometimes.


texts:
What is the difference between the 2 fields as follows:

Content: Abbreviation
This is an alias of Field: Abbreviation.

Field: Abbreviation

And if they are the exactly the same, why is Drupal listing them twice?
Check the attached screen shots for more details.


texts:
In a multi-site configuration in Drupal 8 with (N) cloned (carbon copies) sites, is there any way an individual site can pull the content from other sites in the network into a View on its instance?

For example, in a view on Default, pull content from site 1, site 2, and/or site n.


texts:
I am using drupal 7 and would like an images search/tab on my site. I am thinking of adding an alt field for each image which will then be searchable. I would like the image search results to be displayed as they do in google images.

Any help would be greatly appreciated.


texts: No display changes from hook_menu_get_item_alter()

texts:
I have a string of subsites that need very special menu handling, beyond the normal menu router capabilities. I need to decide in real time (absolutely real time, thus no way to store it in the menu_router table) which menu items I want to display. The obvious solution would be to hook into hook_menu_get_item_alter(). That's what I do, setting $router_item['access_callback'] = FALSE for all menu items I want to suppress. When checked after hook_menu_get_item_alter(), they get changed all right. However, by the time they reach the display stage in theme_menu_link(), all access variables are reverted to TRUE, thus all menu items appear all right. Drupal 7.25.

Any ideas?

Addendum: hook_node_access() is out of question for two reasons: views should be handled as well and user #1 should see the same results as anybody else.

Thanks,
Gábor


texts: Embed a view with 2 contextual filters (user id and taxonomy term)

texts:
I am working on a filtered block view, where I would like to set an extra argument from the template.

Right now I have a page with a URL like this: http://www.page.com/place/test

"test" is a node(nodetype1), and I already use a contextual filter to get the user id form "test" to filter only nodes (of type "nodetype2") by the user of the node "test" to my view block.

Now I would like to filter the view block even more by a taxonomy term in the contenttype2. Problem is that the taxonomy term is not in the URL!

I use:

views_embed_view($view_name, $display_id, $argument);

But I cant use a URL like: http://www.page.com/term/contenttype2 because I lose the "test" pagename to get user id from.

How can I use both filters at once?


texts: Google indexes the page using the domain alias

texts:
I have a Drupal 8 page which is indexed from Google without any error. The front page is a node configured as a front page in the Basic site settings (admin/config/system/site-information) using the path alias /front or de/heim.

The point is that the path alias for the front page should be the root (e.g. example.com) which is it. So, everything is working fine if I navigate the page.

Why is the path alias shown in Google search results, and not the root domain?  It shows example.com/en/front or example.com/de/heim, not example.com.

I have never seen this problem before using Drupal 6 or Drupal 7.


texts: How do I make the same variable available to all my theme files?

texts:
In mytheme.theme I have the following:

function mytheme_preprocess(&$variables) {
 $current_path = \Drupal::service('path.current')->getPath();
 $result = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
 $variables['currenttab'] = explode('/', $result)[1];
}

This function is extracting the first dirname from my url, for example, httttp://server/dirname/pagename it sets currenttab to 'dirname'.

It is working reasonably well, but I notice that if I click around on my site in a specific way, occasionally I get a page where the sidebar template has the correct {{ currenttab }} but the navbar has the {{ currenttab }} value from an older page.

I thought this theme preprocess would make {{ currenttab }} be the same in all my theme templates, but that does not appear to be the case. Once this problem appears, I can reload the page many times and it persists. I think this is related to the order in which I change urls.

What is going on here?


texts:
I have a view with a custom filters form, which is submitted via AJAX.
In the AJAX callback function, I am setting some arguments to the view and render it manually:

$view = views_get_view('products_gallery');
$view->set_display('page');
$view->set_arguments($url_args);
$view->execute();
$commands[] = ajax_command_replace('.view-products-gallery', $view->render());

The results come back OK, but the load more button does not work and points to system/ajax?page=1.

How can I fix the load more button so that it points to the current page and it loads the next results?


texts: How to show reset button in a view only when filter is applied?

texts:
I have created a view with four exposed filters. In exposed form settings, I added a reset link and used auto submit option. Filter and reset works fine without error, but I want to show the reset button only when the filter is applied. If no filter is applied, there should not be reset button.

I have searched, but I didn't find any solution.

How can I achieve this?


texts: Drupal in subfolder, clean urls and images (htaccess not quite right)

texts:
I have my Drupal installation in a subfolder and it's working ok, but there's one problem. New images can't be generated from image styles unless clean urls are turned off.

This is my .htaccess in the root:

Options -Indexes
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
# Redirect all user to without WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

#files
RewriteCond %{REQUEST_URI} ^.*\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteRule ^(.*)$ /drupal/$1 [L,QSA]

#url 's
RewriteCond %{REQUEST_URI} !^/drupal
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]

The htaccess in drupals folder is just as normal, just uncommented RewriteBase /drupal.

I understand what the problem is, the files are redirected directly to where they are, not going through Drupals system, which becomes the case when clean urls are turned off. But this is the only version of a htaccess file that works, and I've tried several. If I rewrite the files to /drupal/index.php?q=$1 images in the stylesheet and the logo and other images like that aren't displayed.

Would appreciate any help!


texts: How to fix the unresolved dependency in the Flag module about Flag Friend?

texts:
I am trying to update my modules and I am getting this error line:

  Fatal error: Class 'RulesEventHandlerEntityBundle' not found in
  /home1/kctd/public_html/community/sites/all/modules/rules/modules/node.rules.inc
  on line 147.

I am in the Update.PHP screen (see photo near the bottom) and I have a few unresolved dependencies. I would normally retro install some of those modules, but when I try to check manually, or even go to my modules screen, I get the error listed above. I am locked out.

What should I do?


texts:
I have 2 sites running Drupal 8; the first one is a Drupal 8 beta 10 site, while the second one is a Drupal 8.0.5 site.

I made many changes to content types, but almost all the fields are identical (such as body, date, entity reference).

How can I import all the content from the first to the second one? In Drupal 7, I could use node_import, which doesn't exist in Drupal 8.


texts: As the image shows, the "Last >>" page button is not well adjusted, so i want to remove one item from this pager but can't figure out where can i find it to edit. I don't think it's configurable in apachsolr? Can anybody help me with this?


texts: How to perform automated testing of an entire site after core changes?

texts:
I'm looking for a module which will test an entire site with each OS update, or Drupal core update. E.g. go through each node and let me know there are any 404 returned for JS or CSS files, broken links, any white screens of death, etc. And if possible if the response time of the site has drastically decreased.

I've done some search and can I only see references to SimpleTest used or unit testing. I'm looking at using Selenium at the moment.

How are other people testing sites after a core changes?


texts: How to use a set of global and per subsite permissions in a multisite installation?

texts:
Use case:
I have a multisite installation in which I want to define a global configuration to be available to all subsites. I define this configuration in the default site. For this example let's say that is:

a role editor
a content type Article
a content type Page

Now..

In all subsites that role editor need to have the permission "Use the toolbar". A global permission.
In subsite-a, I want to allow the editor to only add nodes of type Article
In subsite-b, I want to allow the editor to only add nodes of type Page

To add to that, let's say in the future I need to add a permission to the global set, I want to be able to import that set of permissions to all subsites without overriding any individual subsite permissions.

Currently I am using config_split and added user.role.editor.yml to the conditional section but I can't seem to make it work with the scenario described above.

Question:
How to maintain a global set of permissions and per site set of permissions without the global config overriding the config of the subsite? They need to rather extend each other so to say.

Any suggestions/help?


texts:
I have a custom content type named 'product'. Every content of type product has a serial number of the product as the title.
But while displaying the title I want to override it from two of the CCK fields of the product.
Please take a look at this page.

I want to concatenate Manufacturer and Chip and display it as the title. I am a beginner in Drupal.


texts: WYSIWYG error when using managed_file and AJAX

texts:
I have a form that has both a managed_file element and a text_format element. Both are encapsulated in a wrapper div (using #prefix and #suffix). On submit, an AJAX callback is executed and both elements are populated with data.

However, when the form is rebuilt, the WYSIWYG editor disappears. The following error is displayed in the javascript console of my browser: Uncaught [CKEDITOR.editor] The instance "edit-text-value" already exists.

When I remove the managed_file element, the form works as it is supposed to. It probably has something to do with the Drupal behaviours not being executed properly (managed_file widget?), not removing the editor instance.


texts: How to Inject entity object in EntityForm

texts:
We are trying to recreate https://www.drupal.org/project/menu_editor for Drupal 8. So our idea is to extend MenuForm and then override the form in our own way to achieve what menu_editor for Drupal 7 provides.

We created a custom module called menu_editor and there we created a route.

  entity.menu.power_edit_form:
  path: '/admin/structure/menu/manage/power_edit/{menu}'
  defaults:
    _form: '\Drupal\menu_editor\Form\MenuEditor'
    _title_callback: '\Drupal\menu_ui\Controller\MenuController::menuTitle'
  requirements:
    _permission: 'access content'

Inside MenuEditor, we extend MenuForm.

namespace Drupal\menu_editor\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Menu\MenuLinkManagerInterface;
use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Utility\LinkGeneratorInterface;
use Drupal\menu_link_content\MenuLinkContentStorageInterface;
use Drupal\menu_ui\MenuForm;
use Drupal\system\MenuInterface;

/**
 * Class MenuEditor.
 */
class MenuEditor extends MenuForm {

  var $menu;

  public function __construct(MenuLinkManagerInterface $menu_link_manager, MenuLinkTreeInterface $menu_tree, LinkGeneratorInterface $link_generator, MenuLinkContentStorageInterface $menu_link_content_storage)
 {
   // Trying to inject menu as suggested in https://drupal.stackexchange.com/questions/219431/entity-form-additional-arguments but not sure how we can get menu object over here
   $form_object = \Drupal::entityTypeManager()->getFormObject('menu', 'edit');
   $form_object->setEntity($this->menu);
   parent::__construct($menu_link_manager, $menu_tree, $link_generator, $menu_link_content_storage);
 }

 /**
  * {@inheritdoc}
  */
 public function getFormId() {
   return 'menu_editor';
 }

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, MenuInterface $menu = NULL) {
   // Can get menu object over here but not sure how I can pass this in constructor.
   $this->menu = $menu;
 }

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state) {

   parent::submitForm($form, $form_state);
 }

}

Whenever we are running this code, we get the following error.

  TypeError: Argument 1 passed to Drupal\Core\Entity\EntityForm::setEntity() must implement interface Drupal\Core\Entity\EntityInterface, null given

I do understand that using $this in the form will not help, since the constructor is called before, but I am not sure how to accomplish this.


texts: How do I update the unit price of an order item on Add to Cart in Commerce 2.x?

texts:
I added an event subscriber for add to cart event. There I defined a function to react on add to cart event. Everything works fine as my eventsubscriber is being called. I want to update the unit price of product which is being added to cart. Below is the code I used but it is not working. Price of the product is not updating to the price I am setting.

public function updateProductPrice(CartEntityAddEvent $event) {
    $unit_price = new Price('15.00', 'EUR');
    $event->getOrderItem()->setUnitPrice($unit_price,TRUE);
  }

I have tried with both overide TRUE and FALSE but nothing works.


texts: Drush command can't find Drupal module function

texts:
I created sample command in Drush.

I put it to sites/all/drush.

I am on my site root and calling this command works ok. But when I try to call any Drupal function in drush_MY_COMMAND function I am getting:

  Error: Call to undefined function

Could someone give me any hint how to solve this issue?


texts: Is it safe and correct to run Drush under the same user account that the webserver runs on?

texts:
I've found following informaion:

  It's usually considered best practice to run Drush under the same user account that the webserver runs on (such as www-data). Some modules, such as XML Sitemap, Advanced Aggregator and cTools, often try to alter or generate files.

I also have some problem with Ctools cache.
I can use following command to run Drush under the www-data user:
sudo -u www-data drush....

But is it safe and correct to run Drush under the same user account that the webserver runs on?


texts: How to change upload destination from private to public?

texts:
On a Drupal 7 installation I have an image gallery (set up with the media gallery module). I set the upload destination to private to protect those images for anonymous users. Unfortunately it turned out, that the performance of private images is that poor, that the gallery became quit unusable.

So I decided to switch the destination to public for the node type. But as there already exist nodes of the mentioned type (I assume that my be the reason), the options of the node type's filed, where to set the destination is greyed out:

Is there any way to change the destination for existing nodes?


texts:
i am new to context module and based on some tutorial i have used context. Now my problem is,

Currently, I have created one context which will show default header logo in all the pages. Now got new requirement to show different logo on the node pages with selected taxonomy terms.

For this i created one more context and used taxonomy conditions with selected taxonomy terms for the different header logo. when i visit the page, i got two logos in the header section, so i edited the first context and added the taxonomy condition and selected those taxonomy terms and set the "No" to "Set on node form" option.

You know whats happens, the default logo gets disappear from all the pages but still showing two logos in the node pages with the selected Taxonomy terms pages.

I am not sure what condition to set to show in all the pages except in those selected taxonomy terms pages. Could you please someone guide me on this.


texts: How to boost relevance of Search API solr with the value of a certain field?

texts:
I am using Search API solr on my site. To get better search results I would like to boost the relevance by the value of a certain numeric field.
Say, all items have a field A, which is numeric. Now I want to boost the relevance of those itemes by the value of field a, so that, if As value is higher the relevance of the item becomes higher too.
I have absolutely no idea how to do this. Maybe with

hook_search_api_solr_query_alter()

But I did not find documentation how to use it. Please hint me in the right direction.


texts: Migrate error: Call to a member function count() on a non-object

texts:
I am trying to implement a user migration with the migration module but am getting this error:

  Fatal error: Call to a member function count() on a non-object in
  E:\wamp\www\website\sites\all\modules\migrate\includes\migration.inc
  on line 946

here is my migrate class:

abstract class CakeBaseMigration extends Migration {
  public function __construct($arguments) {
    parent::__construct($arguments);

    $this->team = array(
      new MigrateTeamMember('Chris', 'chris@somewhere.com',
          t('developer')),
    );

    Database::addConnectionInfo('for_migration', 'default', array(
      'driver' => 'mysql',
      'database' => 'databasename',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
      'prefix' => '',
    ));

  }
}

class CakeUserMigration extends CakeBaseMigration {
  public function __construct($arguments) {

    parent::__construct($arguments);
    $this->description = t('Lagacy cakePHP system customers');

    $query = Database::getConnection('default', 'for_migration')
    ->select('customers', 'c')
    ->fields('c');

    $this->source = new MigrateSourceSQL($query);
    $this->destination = new MigrateDestinationUser();

    $this->map = new MigrateSQLMap($this->machineName,
        array('id' => array(
          'type' => 'int',
          'not null' => TRUE,
          'description' => 'Account ID.'
        )
        ),
        MigrateDestinationUser::getKeySchema()
    );

    $this->addFieldMapping('username', 'name');
    $this->addFieldMapping('pass', 'password');
    $this->addFieldMapping('mail', 'email');
    $this->addFieldMapping('created', 'modified');
    $this->addFieldMapping('roles')
    ->separator(',')
    ->defaultValue(DRUPAL_AUTHENTICATED_RID.',4');

  }
}

running the drush command drush migrate-audit --allsays that that cakeUser is missing a source and destination.

I don't get it, Setting the database and running the query at devel/php returns the expected rows from the database.

Any help on this would be fantastic :)


texts: How can a view page work with multiple word term name

texts:
I have user views page with path /members/%.
(url as members/term-name).It shows if I use CONTEXTUAL FILTERS with term id but I need url with term name. Anyway , go back to story:
academician,math, math teacher, math students are terms.
It shows all members if path is members/math  or members/academician. No problem with one word term name.
But it doesn't show any member if url is members/math-teacher or members/math-student.
So it works with math terms but not with math teacher.What am I missing ?


texts: How do I filter a text field, based on content type?

texts:
I've built a custom filter that parses images that were inserted into the node body field. I am trying to have the filter render image sizes based on the content type of the node being created/edited.

I cannot seem to find a way to get the content type of the node being create/edited. I assumed that it would be in one of the callbacks of hook_filter_info(), but it doesn't appear to be there.

Is there a way to filter a text field, based on the content type, or better yet - how do I communicate a setting from a content type to a filter?


texts:
I have a content type that, on the node page, displays taxonomy term fields, which in turn link to the automatically generated taxonomy term view for that term.

I would like to overwrite the output of these links, which I have attempted to do in the code below.

The problem is that the URL comes out malformed as: /our-work%3Ftid%3D4 rather than /our-work?tid=4. Note that the argument 4 is just an example.

What could be the solution here? Some thoughts:

Am I using the right hook?
urlencode() doesn't seem to work here.
Using Drupal's l() function seems to output HTML, not a processed URL.
Using Drupal's url() function doesn't seem to work either, I get the same output when I build the options array, etc.

function ep3_misc_node_view_alter(&$build) {
    if ($build['#bundle'] == 'work') {
    // We cycle through this array for just integer indexes, since there are also string indices.
        for ($i = 0; isset($build['field_tags'][$i]); $i++) {
            $tid = $build['field_tags'][$i]['#options']['entity']->tid;
            $build['field_tags'][$i]['#href'] = check_plain('our-work?tid=') . $tid;
        }
    }
}


texts: How to integrate with the jQuery Mobile framework?

texts:
I saw that Wordpress integrates a special plugin to transform Wordpress themes in mobile themes with an integration of the jQuery Mobile framework.

Is it possible to make for Drupal 7? Exist a module that can change or integrate with jQuery Mobile?


texts:
I have a site that has a lot of menus. One of them is the main menu that has few items. These items link to main areas of the site, and each of these main areas has one specific menu. When I'm on a landing page of one of these main areas, the item of it on the main menu is active, but when I'm on an internal page of one of these areas, the item on the main menu is not active.

Is there any way to make it active automatically?

I tried using menu_position but it seems not be working.


texts: I am using Drupal 7 and I have content type events. It has many node pages created used by events content type.Event names and years are fields in event content type. I want to create years as tabs.When clicks years(tabs)it will show all events names happened in that year. I don't know how to create tabs using views.


texts: Use my existing jquery function in drupal 7

texts:
I have my function like this in jquery

$(document).ready(function(){

    // set the map-wrapper width and height to match the img size
    $('#map-wrapper').css({'width':$('#map-wrapper img').width(),
                      'height':$('#map-wrapper img').height()
    })

    for (i=0; i<$(".pin").length; i++)
    {
        // store initial tooltips contents within an array
        var tooltipContent = new Array();
        tooltipContent[i] = $(".pin").eq(i).html();

        // set tooltip direction type - up or down
        var tooltipDirection = 'tooltip-up';
        if ($(".pin").eq(i).hasClass('pin-down'))
        {
            tooltipDirection = 'tooltip-down';
        }

        // append the tooltip
        $("#map-wrapper").append("
\

" + tooltipContent[i] + "
\

");
    }

    // show/hide the tooltip
    $('.tooltip-up, .tooltip-down').mouseenter(function(){
                $(this).children('.tooltip').fadeIn(100);
            }).mouseleave(function(){
                $(this).children('.tooltip').fadeOut(100);
            })
});

But i am unable to use it in Drupal 7 . So what changes do i need to make for it.


texts:
The Error:

 PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, value) VALUES ('1', '1', 'mydata', '35')' at line 1: INSERT INTO {mytable} (uid, tid, key, value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => mydata [:db_insert_placeholder_3] => 35 ) in MyClass->save_myData() (line 145 of /path/to/my/stuff/my.class.php).

My Code:

db_merge( 'mytable' )
    ->key( array( 'uid' => $this->user->uid, 'tid' => $data['tid'] ) )
    ->insertfields(array(
           'uid' => $this->user->uid,
            'tid' => $data['tid'],
            'key'      => $key,
            'value'    => $value
    ) )
     ->updateFields( array( 'value' => $value ) )
     ->execute();

I've tried this with just the basic ->fields() but my latest iteration here involves specifiying the inserted fields and updated fields separately (just ran across this while googling and thought it might help.  Same error though.

Originally I was trying to use

db_query( "REPLACE INTO goal_data(uid,tid,key,value) VALUES( :uid,:tid,:key,:value)", array(
                ':uid'      => $this->user->uid,
                ':tid'      => $data['tid'],
                ':key'      => $key,
                ':value'    => $value
            ) );

It too was throwing an error saying that there were in invalid number of placeholders or something similar.  There wasn't. The error was basically:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

Any thoughts on what I'm doing wrong?  I don't get it, trying everything here and just keep getting errors.

Here's my table structure (very simple).

CREATE TABLE IF NOT EXISTS `mytable` (
  `uid` int(11) NOT NULL,
  `tid` int(11) NOT NULL,
  `key` varchar(255) NOT NULL,
  `value` longtext NOT NULL,
  PRIMARY KEY (`uid`,`tid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


texts: How to put select option value into particular category in webform module?

texts:
I am using webform module and added a select field.

My option values are

  One|Sample 1
  Two|Sample 2
  Three|Sample 3
  Four|Sample 4
  Five|Sample 5
  Six|Sample 6

But I want these three fields in a particular category named Sample list 1

  One|Sample 1
  Two|Sample 2
  Three|Sample 3

Sample List 2:

  Four|Sample 4
  Five|Sample 5
  Six|Sample 6

Note: I don't want to show it in groups <>.

I want a select list which consists of Sample List 1 and Sample List 2
In a single select field I want to store both of option values into their respective select lists.


texts:
I have created a glossary with views. The View (page) contains all published nodes of the content type "glossary-term". This content type consists of only Title and Body field. The view alphabetically lists the entire content of the nodes. On this view page I attempt to put references in the form of anchor links like this:

Term A

lorem ipsum lorem ipsum lorem ipsum lorem Term C ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Term B

lorem ipsum lorem ipsum lorem ipsum lorem ipsum Term A lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Term C

lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem Term B ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

In my CKEditor I can only insert anchors within nodes. For example, I could create an anchor in node "Term A" and reference it to the title of "Term A". But this obviously doesn't make sense. I need to reference to another node on the views page.

Hope you understand what I mean. Does somebody know how to accomplish that?


texts: Show parents at first level then child in each page

texts:
So I made a view and attached it to head of another view, what I want is at the second view page only shows the parent, but when a user click on the parent term, it now show the child terms of that parent.

Parent 1
--Child 1
--Child 2
Parent 2
--Child 3
--Child 4

For instance if anyone click on parent 1, now the view that is attched show Child 1 & Child 2

I found a similar question here but no answer there.


texts: How do I use contextual filters and relationships to show related articles?

texts:
So, I've been trying to get this figured out for most of the day. I had it essentially working in the previewer at one point, but now it doesn't seem to work at all.

Use case: each node published with the content type "Article" comes with a Taxonomy field for included tags. What I'm trying to do is to create a block that appears under the article with a series of thumbnails that link to other articles. These articles in turn are related based on the tags used in each article.

So, the question is:

What would be a good way to set this up using Contextual Filters and Views to have the View itself automatically see the field_tags used as a Taxonomy term reference in an Article, and have it automatically display the output based on the tags of each article?

I've tried setting up the Contextual Filter to be aware that the terms would be in the Content Type: Articles via the Relationships filter, but frankly I'm kind of stumped as to what I need to do to even accomplish this.


texts: How To Set Order State Completed after Notification?

texts:
I am Writing a Payment Gateway(Onsite) Plugin For Commerce 2,
I am Stuck with Checkout Flow Step Transitions.
Let Me Explain:
I am extending the OnsitePaymentGatewayBase and in the createPayment() Method
I am setting the payment states to 'pending' [if the payment gateway accepted the request]and the payment state is setting well(no issues with payment state),
Since My Payment Gateway is Async I need to implement onNotify() to change the payment state to 'completed'.
My Issue:
Since Payment Gateway is Async(payment notification will be sent after a day) My order Sates also be needed to be in 'Pending' or something similar states but when I use default checkout flow I am getting the order completed even before the notification is processed. means after I checkout the order state is 'completed',
What I want:
I want the order state to pending or review ..etc even after the checkout.
only after the processing of notification the order state to be 'completed'
Or Simply:
How can I set Order state to Pending or Review or darft..etc  and Not 'completed'
Only after receiving the Notification from Gateway, I have to set order state to completed
Github LINK


texts: Ckeditor toolbar not entirely showing up

texts:
I have just moved my site from local machine to production, the wysiwyg editor based on ckeditor no longer show the complete toolbar. I have a minimal list of element.
Can someone help, am trying everything, edit profile, check if all files are uploaded, i don't see any problem !


texts:
I have created a views that works as a slider (title, image, read more).

And now I need some slideshow sow it rotates the views content from newsest to oldest with some transition animation.

I want to use the existing Views I have created and styled already, just to fade out fade in or some more fancy animation.

Any advice how to do that? Any views additional module that can do that?


texts: How to send user password during registration?

texts:
How to send user password during registration.
I have to send html email when user register in the site using rules module in drupal 7 and i have to send the username and user password in that mail.
i used [account:name] and [account:password] or [user:password] but i did not get the user password on my mail.


texts:
Is there an easy way to get node's view mode from entity.view?

function classier_preprocess_views_view(&$vars) {
    $vars['rows'][0]['#rows'][0]['#view_mode'];
}


texts:
I am developing a network of websites for our nonprofit organization.

As with any membership site, we have some members who simply do not get along and often, their back and forth "drama" will detract from the other member's positive, supportive experiences.

Rather than simply banning members who can't get along with each other, we'd like to set up a way for members to flag a member and "mute" them, so that instead of seeing their content, they will see a message like "You have muted this member and cannot view their post. To unmute the member, visit your profile page." or something to that effect.

There was a module for 6 that is  ported to 7 called Ignore User, but it doesn't seem to be in a stable release for 7.

It seems to me that there has to be some way to do this with flags, rules, and views -- but I admit it is a bit above my knowledge level.

Has anyone ever done something like this on a Drupal 7 site? Can you help me make this work? I really do feel it will make a big difference for our chapters and minimize some of the "drama" we have to deal with on a regular basis.

Thanks
Heather


texts: How can I send an HTML email from an Ajax callback?

texts:
I want to send an email to the user who forget username.
I created a functionality that handle with Ajax like send request to controller where I using a query to check whether user exist or not. if user exist I want to send email to used with his user name.
Is there any module that i can use to send email in this way
public function ForgotUsername() {
  $mail = \Drupal::request()->query->get('mail');
  $database = \Drupal::database();
  $username = $database->query("SELECT name from users_field_data where mail='$mail'")->fetchField();

  if (!empty($username)) {
    $module = 'modulename';
    $key = 'forgotusernamerecovery';
    $to = 'example@example.com';
    $langcode = '';
    $params = ['username' => 'Abc'];
    drupal_mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE);

    $message = "
Successs
";
  }
  else {
    $message = "
notmatched
";
  }
  $response = new AjaxResponse();
  $response->addCommand(new HtmlCommand('.selector', $message));
  return $response;
}


texts: How to display field description right after field label?

texts: I'd like to display field descriptions in user profile2 page. Not below the form items but right after field labels. I tried to use hook_form_alter() in template.php of the theme but I could'nt figure out how to do that.


texts:
I have three templates

field--field-custom.html.twig
field--field-custom1.html.twig
field--field-image.html.twig

I also have a teaser template containing all three fields like that:

<div{{ content_attributes.addClass('node__content', 'container') }}>
    {{ content }}
</div>

I want to have the first two templates in a bootstrap div, for example

col-sm-6

and the third template in the other div

col-sm-6

If I include the second template in the first template file it just repeats the field instead of rendering the intended field (both templates are name suggestions of the same file).
What can I do in order to have both fields in the same template file?


texts: Change order of breadcrumbs elements in hook hook_system_breadcrumb_alter

texts:
I want to add another element to breadcrumb.
I have:
Home > Node Title
I want to add another link between the two elements like:
Home > Link to view > Node Title

I have tried with hook_system_breadcrumb_alter like the following:

/**
 * Implements hook_system_breadcrumb_alter().
 */
function MyModules_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context) {
  if ( $route_match->getRouteName() === 'entity.node.canonical'){
   $node = $route_match->getParameter('node');
   if ($node instanceof  Drupal\node\Entity\Node && $node->getType() === 'my_node_type'){
     // Get the listing view url.
     $listing_url = Url::fromRoute('view.my_view_id.my_display_id');
     // Add the listing url to breadcrumbs.
     $breadcrumb->addLink(Link::fromTextAndUrl(t('Link to view'), $listing_url));
   }
  }
}

But i get Home > Node Title > Link to view instead of Home > Link to view > Node Title
My question is how can i change the order of the last two breadcrumbs elements?


texts:
Usually, when I make a views block list, and I want it horizontal, I would just add CSS styles to the block itself.

#block-views-something li
{
  display: inline;
  list-style-type: none;
  padding-right: 20px;
}

Having to do this for each block is a pain. I know Views 3 lets me add a class to the view to style the list, but I have never been able to do it. I have tried HTML List, and adding classes to Page: Style options Row class, and Wrapper class or even List class. I have tried it with a dot like .mystyle and without the dot 'mystyle'.

In fact, I just get myself into a right old mess. Could anyone advise me the simplest route to take to add the class to whatever box I should add it to?


texts: Create Feature running into timeout error

texts:
When clicking on Create Feature I get an timeout with the message

  Maximum execution time of 300 seconds exceeded in C:\xampp\htdocs\mysite\sites\all\modules\contrib\features_override\features_override.export.inc on line 382

When I disable the Feature Overrides Module it works again. Turning it on again I get the same error.
Any hints on how to find the real problem behind this?


texts: how to create template of user register, login and forget password in drupal 8?

texts:
How to create template of user register, login and forget password in drupal 8 can we create template same as we created earlier in drupal7 ?

I want to open these forms in popup on clicking links


texts: How do I migrate only the items that previously failed?

texts:
I have a migration class that has imported 2000 items correctly, but failed to import 40 of them.

Now I have corrected the import class, but I don't want to do a rollback and a full reimport/migrate.

Is there a possibility to import/migrate only the 40 failed items?


texts: Programmatically set the front page per site?

texts:
I have a site that is using a 'fake' multi-site instance (I think, someone else implemented it). We created 3 directories in sites:

sites/site1
sites/site2
sites/site3

and in each settings.php inside these directories it includes the original settings.php from the default directory.

I am overriding the theme successfully in these files by doing $config['system.theme']['default'] = 'theme2';

When I try doing $config['system.site']['page']['front'] = '/node/239';
it works only on cache flush.

For example if I am on site 1 I see the front page set in the UI.
Then when I switch to site2.example.test I still see the default front page instead of what is on /node/239.
When I flush the cache, the reverse happens; site 2 homepage shows /node/239 and so does site 1.

I have also tried setting this in an event listener:

public function kernel_request(Event $event) {
    $config = \Drupal::configFactory()->getEditable('system.site');
    $site_path = \Drupal::service('site.path');
    $site_path = explode('/', $site_path);
    $site_name = $site_path[1];

    if ($site_name === 'site2' && $event->getRequest()->getPathInfo() == '/') {
      $config->set('page.front', '/node/239')->save();
    }
    else {
      $config->set('page.front', '/home-content')->save();

    }
  }

This now does the right thing, but only after loading the page and then refreshing.

Could anyone tell me what the "correct" way of doing this would be that wont be cached?


texts: Pagination in external api consume custom module

texts:
I created a custom module in order to consume an external api call in my drupal project following this question.
The module is working fine, but I need to have a pagination in the received results which will pass as a variable in the api call:

http:/example.com/api.ashx?q=documents&page=1

How is possible to achieve that? In case I receive all the data from the api is it possible to "separate" them somehow with pagination operation?

Thanks in advance


texts: How do I mock the "file_system" service?

texts:
How do I mock the file_system service in PHPUnit?

The issue is being reproduced when \Drupal::service('file_system') is executing in the test suite environment.  If \Drupal::service('file_system') is removed the class loads the assertions in the test class run perfectly. My belief is that this service needs to be mocked. (This could be completely false. I am really unsure).

The terminal error displayed when running the test is the following.

  Drupal\Core\DependencyInjection\ContainerNotInitializedException: \Drupal::$container is not initialized yet. \Drupal::setContainer()

This is the class method that executes the Drupal 8 service.

 /**
   * @inheritdoc
   */
  public function setBasePath($path = Null) {

    if ($path !== Null) {
      $this->directories['base'] = $path;
    } else{
     $this->directories['base'] = \Drupal::service('file_system')->realpath(file_default_scheme() . "://");
    }
  }

This is the test class that is going to test the above class in the future. Right now it compares a string only.

/**
 *
 * @group react_forms
 */
class DirectoryStructureTest extends \Drupal\Tests\UnitTestCase {

  /**
   * @var object
   */
  private $objToTest;

  /**
   *
   */
  public function setUp() {
    $this->objToTest = new DirectoryStructure();
  }

  public function testGetDirectories() {

    $this->assertEquals('this', 'this');
  }

  /**
   * Once test method has finished running, whether it succeeded or failed,
   * tearDown() will be invoked. Unset the unit created object.
   */
  public function tearDown() {
    unset($this->objToTest);
  }
}


texts:
I am aware that the question is (almost) a duplicate of the following question #21991, which has been posted back in 2012. But that question is NOT related to Drupal 8, where UUID is in core.

References:

Drupal 8 Core API
Drupal 8 Core Module Documentation

The Drupal 8 Core Module Documentation does not list UUID.

I wonder if I could leverage Drupal 8's core UUID module to migrate and map relational data imported from a different environment, which has unique keys generated by Firebase.

Update:

It has been kindly pointed out that UUID is not a module.

It seems to make UUID records per default for entities (aka nodes) and apparently can be used to map entity references.

Can I make use of this when I introduce external data, that already has unique IDs?
So I have the "node" IDs and can map with the UUIDs?

Update based on further comments:

The goal is to use UUID with entities and the REST module.
Respectively, it seems sensible to do so when importing external relational data, that already has unique IDs.

I just try to understand how UUID works, what it can do and what not, how I can generate and validate UUID's, what I need to be aware of, if I introduce external ID's.


texts:
I have nodes with text and images in the body field. I wish to remove the images from the teaser texts, currently created with the "Summary or Trimmed" field display option.

Is there a hook or similar for altering the field before it's output in the teaser? Or would this require writing a custom field formatter?


texts:
function mymodule_views_pre_render(Drupal\views\ViewExecutable $view) {
    if ($view->current_display == 'current_display' && $view->id() == 'view_id') {
            $sort = array(21, 20, 22, 23, 25, 24, 19, 18);
            $new_sort = array();
            foreach ($view->result as $key => $result) {
                 $new_sort[array_search($result->tid, $sort)] = $result;
            }
            ksort($new_sort);
            $count = 0;
            foreach ($new_sort as $key => $result) {
                $view->result[$count] = $result;
                $count += 1;
            }
        }
}

I've got a view which render some results I need to reorder. I don't want to use Weight, cause it's still used somewhere else.
$sort is the new order I need.
So for each results, I check his tid, match him with the key in the sort and push him in a new array. For example, for $result->tid = 22 :

$new_sort[array_search(22, $sort)] = $result;

returns

$new_sort[2] = $result;

The code above is correct as my var_dump is. But results are still displayed in the default order. Did I miss something to make my new order efficient ?


texts:
I just noticed this, and I can't find an explanation.

I can go to node/1/45645645/klzkelfkzlef/47z4e5fz56e4f/etc and it'll just show node/1 instead of a 404 page.

The same happens with taxonomy/term/%term/stuff

Somehow, if it doesn't match a valid path (/edit for example) it falls back to just a view of the entity. How? Like, where does this happen?

Is this normal hook_menu behavior? node/%node exists and node/%node/edit exists, so node/%node/random may not exist but it'll use the callback for node/%node anyway?


texts: Return more than one value from custom views field

texts:
I created custom views fields that calculate a percentage and number based on referencing nodes to current item. So of all 10 nodes 5 of them are referencing to this item.

So output will be 50%, I also have a field that output the numbers so 5/10.

These two fields have the same calculation so to make it more lean I want to try and output both values from one custom views field. It should be possible the link field can output title and url. Is there a way to do this with my custom field. So instead of two fields:

{custom_score_precentage}
{custom_score_number}

I want one field with two outputs:

{custom_score.precentage}
{custom_score.number}

At this moment I use the following in the render function:

return $percentage;

or

return $number;

I tried something like:

    $result = [
        'precentage' => $percentage,
        'number' => $number,
    ];
    return $result;

But the options I want don't show in the view replacement patterns. How can I do this?


texts: How to use $page object to put code inside existing wrapper, and altering module file

texts:
I'm editing Supersized module:

First question is: is there anything that can help me to alter module file (supersized.run.inc) that will follow drupal principles (not editing directly module files), and putting edited file somewhere in my theme folder.
I'm figuring it out how to use $page object to put code in a specific place in DOM. Default code (supersized.run.inc line 162):

if ($settings['components']['thumb_links'])
{
$page['content']['region-content']['block-system']['supersized']['thumb_tray'] = array(
'#type' => 'markup',
'#markup' => theme('supersized_thumb_links'),
);
}

I'm looking for some resources how to figure it out cause my change:

$page['content']['region-content']['supersized']['thumb_tray']

until I put
['block-system'] after ['region-content']:

$page['content']['region-content']['block-system']['supersized']['thumb_tray']

The supersized 'thumb_tray' html content is still in region-content:

         ...


texts: Errors when creating invoice + Invoice module

texts:
I'm having trouble creating invoices with the Invoices module. I want to create an invoice for the user when he is registrating. The problem is I need to generate an invoice and fill in the values, but I don't know how to do this.

I have created a Rule with the Rules module. My rule looks like this:

The problem is now when I want to registrate I get this errors:

Notice: Undefined property: stdClass::$invoice_number in invoice_node_presave() (line 437 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice.module).

Notice: Undefined property: stdClass::$user_defined_invoice_number in invoice_node_presave() (line 439 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice.module).

Notice: Undefined property: stdClass::$invoice_invoice_number_zerofill in _invoice_get_formatted_invoice_number() (line 410 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice_helpers.inc).

Notice: Undefined property: stdClass::$invoice_invoice_number_prefix in _invoice_get_formatted_invoice_number() (line 411 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice_helpers.inc).

Notice: Undefined property: stdClass::$template in invoice_insert() (line 784 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice.module).

Notice: Undefined property: stdClass::$invoice_description in invoice_insert() (line 797 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice.module).

Notice: Undefined property: stdClass::$pay_limit in invoice_insert() (line 799 of /Applications/MAMP/htdocs/xmed_dp/sites/all/modules/invoice/invoice.module).
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'tid' at row 1: INSERT INTO {invoice_invoices} (iid, nid, leading_zeros, prefix, description, tid, pay

How can I make sure these values are generated?


texts: Id given for a field_set is not persistent in drupal 8

texts:
I gave a id for a field_set from content type management in drupal 8 :

But after given id and update  when i taken again its not taken effect , after typing save also it doesn't worked . Any idea ??


texts: Port of Ubercart "Dependant Atributes" or "Chained Attributes" modules

texts:
Do you know of a Drupal 7 version of either of these modules?

Ubercart dependant atributes
Chained Attributes and Options

I've spent a couple of days trying to find an appropriate solution.


texts:
I'm getting a lot of "Missing text format: 1." errors in my log. It seems to point to a bug where text formats used to get referenced by number in D6 (['format'] = '1') but now are referenced by a name in D7 (['format'] = 'plain_text').

How would I find where does bugs are?

Or a more general question: how can I get more details about error messages in the Drupal log?


texts: Does Drupal resave the photo even if it's already the correct size as your Image Style?

texts: Does Drupal still recompress the photo even if the file you uploaded is already the same size as your selected Image Style? In the event that it does recompress it, is there a way to prevent it? Image quality is at stake in this case since it saves it in JPG.


texts: How can I find (programmatically) which fields have been edited on a piece of content?

texts:
I want to have a computed field pull in the name and content of a field after it has been edited. I would also like the computed field to contain the content that was edited before edit (if that makes sense?). So what code do I need to find which field has been edited?

I also found this in the node_form drupal api:

// Changed must be sent to the client, for later overwrite error checking.
$form['changed'] = array(
  '#type' => 'hidden',
  '#default_value' => isset($node->changed) ? $node->changed : NULL,
);

Is there a way I access this 'changed' value to check if a piece of content has been changed?

p.s. I am new to drupal and php, so stating your answer in simpler terms with more explination is greatly appreciated.


texts:
I want to show a block with related nodes. The function getRelatedArticles() is a complex one and I can't build it with views. Is it possible to use the method viewMultiple() and output the list as item-list? If not, what would be the best practisce becide looping over the array and build the render array for each node? Something similar to the following code (which obviously does not work):

class RelatedArticleBlock  extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {

    $related_nids = $this->getRelatedArticles();

    $nodes = Node::loadMultiple($related_nids);
    $block['content'] = [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#wrapper_attributes' => [
        'class' => [
          'row',
        ],
      ],
      // I want to do something like:
      // '#items' => \Drupal::entityTypeManager()->getViewBuilder('node')->viewMultiple($nodes, 'teaser'),
    ];

    // I would like to avoid the following, build each node on it's own.
    foreach ($nodes as $node) {
      $block['content']['#items'][] = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, 'teaser');
    }

    return $block;
  }
}


texts: reformat a select list into ordered list

texts:
I have a module "custom search" installed and its producing the taxonomy list as a drop list "select list", is there a way that i can hook into that list and reformat it to be an ordered list.
this is what I have so far

<select class="custom-search-selector custom-search-vocabulary form-select" id="edit-custom-search-vocabulary-2" name="custom_search_vocabulary_2">
<option value="c-all" selected="selected">-Any-</option>
<option value="c-10">  Algeria</option>
<option value="c-27">  Bahrain</option>
<option value="c-8">  Eygipt</option>
</select>

to be

-Any-

Algeria

Bahrain

Eygipt


texts: Ubercart: direct access to product/sku page

texts:
Drupal 7.32 and Ubercart 3.6

To access a node we use an URL like http://www.example.com/?q=node/17014

I would like been able to access products with
http://www.example.com/?q=sku/12345 or something similar, where 12345 is sku code.

This can make external links to products a lot better!
How can I do this?
Thanks


texts: how do you restrict directory path to role?

texts:
How would you go about restricting a specific directory path to a role?

www.example.com/example1/example3/example4

How do you restrict role access to the directory example1 so that example3 and 4 are restricted automatically?

Thanks!


texts:
My entity defines an access control handler (a subclass of \Drupal\Core\Entity\AccessControlHandlerInterface) as well as a delete form (a subclass of \Drupal\Core\Entity\EntityConfirmFormBase).

The access handler designates certain entities as uneditable, and returns \Drupal\Core\Access\AccessResult::forbidden() on the "update" and "delete" operations for those entities.

This has the correct effect of hiding the "Edit" and "Delete" operation from the entity list.

Unfortunately, it doesn't do the same when visiting the forms directly via their URLs.

What am I doing wrong here? How do I actually block access to the forms?

Edit: The 404 was because I had the wrong URL for the edit form; turns out it's actually for all operations.

Do I need to call $this->entity->access($this->operation) myself in buildForm()?


texts: hook_cron() doesn't get any value from taxonomy_get_tree()

texts:
I am using the following code, but it doesn't work.

  function mymodule_cron() {
    // ...

    _update_user_categories($uid);

    // ...
  }

    function _update_user_categories($uid) {

      $articleCategories = array();
      $user = user_load($uid, TRUE);

    // Fill array with user access categories
      foreach ($user->field_article_category['und'] as $index => $tid) {
        $articleCategories[] = $tid['tid'];
      }

    // Generate SQL statement for Multi record insert
      $values = array();
      $accessValues = array();
      foreach ($articleCategories as $index => $value) {
        $accessValues[] = $value;
        $terms = taxonomy_get_tree(2, $value);
    // Loop for all children to add them in the $accessValues;
        foreach ($terms as $term) {
          $accessValues [] = $term->tid;
        }
      }
      $categories = array();
      foreach (array_unique($accessValues) as $index => $value) {
        if ($value) {
          $values[$value] = "($uid,$value,'taxonomy')";
          if (!in_array($value, $categories)) {
            $categories [] = array('tid' => $value);
          }
        }
      }

      $insValues = implode(', ', $values);
      if (!empty($insValues)) {
        $sqlDel = 'DELETE FROM {workbench_access_user} WHERE uid = ' . $uid;
        $sqlIns = 'INSERT INTO {workbench_access_user} (uid, access_id, access_scheme)         VALUES ' . $insValues;
        db_query($sqlDel);
        db_query($sqlIns);
      }
      $edit = array(
        'field_article_category' => array(
          'und' => $categories,
        ),
      );
      user_save($user, $edit);
    }

No data is returned by taxonomy_get_tree(). user_save() is not working, but it works when called outsite hook_cron().

What am I doing wrong?

taxonomy_get_tree($vid, $tid); returns empty array if i called my function from hook_cron

but if i called it from any others place it works.


texts: How to set Form API's password_confirm in/visible depending on prior select list input?

texts:
Neither visible nor invisible seems to work on password_confirm. Am I doing something wrong? What else can I try? This is my current code for a subadministrator form, where I'ld like to display the password_confirm only after a user is chosen:

$form['user_select'] = array(
  '#type' => 'select',
  '#options' => array('' => '- ' . t('None') . ' -') + _get_users_by_role('Subadministration'),
  '#required' => TRUE,
  '#description' => t('Chose account'),
);

$form['confirm_password'] = array(
  '#type' => 'password_confirm',
  '#required' => TRUE,
  '#description' => t('Type same password in both fields'),
  '#states' => array(
    'invisible' => array(
      ':input[name="user_select"]' => array('value' => ''),
    ),
  ),
);


texts: Is there any way to count the number of items in cache?

texts: In Drupal 6, I used to be able to look up the number of items via {cache_MODULENAME} table direct in SQL. Is there any way to look it up via the cache API?


texts: restrict profile field to module and admin in drupal 6

texts:
I am using profile for storing some more information for users. but I want one field of profile be only editable by administrator and my own module code and viewable by own user and administrator.

I guess I have to set visibility of field to '  Hidden profile field, only accessible by administrators, modules and themes. '

but I don't know if it is right or not.

Thank you.


texts: How to adjust prices depending on quantity and attributes using Drupal Commerce?

texts:
I am using Drupal Commerce, and have a question about some of the available price/quantity modules. As an example, if people want to buy 1-5 pictures, the price is $49/each, if 6-10, than it is going to be $39 per each.

I found Commerce Price Table (1st) and Commerce Pricelist (2nd) modules for that. Looks like 2nd is more functional, but it is very "new" ... Not sure which one I should go for.

Or should I consider some other module(s) that are also popular for that? Or can I do it right from Drupal Commerce?

What I am actually looking for: a way which can adjust the price depending on quantity and attributes.


texts:
In the context of Drupal 8 and Commerce 2, I need to create about 1000 orders on behalf of my users.

What are the necessary fields to provide in a CSV so that the orders are created properly?

The store, products, and payment gateways are all set up and work as expected
I have a view set up to export sample orders so I can see field syntax and values
I'm intending to use Feeds to import the master CSV

I assume we will need at least OrderNum, Date, Type, Customer, Email, State, Total, OrderItems, PaymentGateway, Placed, TotalPaid, and TotalPaid (currency_code), but this is guesswork.

Is there a schema or other sort of definition I can use?

I am definitely trying to avoid custom modules and other programmatic approaches (as outlined in similar questions).


texts: Redirect to page in form submit and use the form data in new page

texts:
How to redirect in drupal 7 in form submission, I need to use the submitted data in next redirected page but below video_subtitle_view function is not printing anything

How do i do it

/**
 * Implements hook_menu()
 *
 */
function video_subtitles_menu() {
  $items = array();
  $items['player/video_subtitle/view'] = array(
     'page callback' => 'video_subtitle_view',
     'access callback' => 'user_access',
     'access arguments' => array('administer video_subtitles status'),
  );
  return $items;
}

    function video_subtitle_view($form, &$form_state){
    //    print 'video_subtitle_view';
        print_r($form);
        print_r($form_state);
    }

function video_upload_subtitles_form_submit($form, &$form_state) {

     $form_state['redirect'] = 'player/video_subtitle/view';
//     $form_state['redirect'] = array(
//            'player/video_subtitle/view',
//             array(
//                    'query' => array(
//                    'form' => $form,
//                    'form_state' => &$form_state,
//                   ),
//              ),
//      );

}

function video_subtitle_view($form, &$form_state){
//    print 'video_subtitle_view';
    print_r($form);
    print_r($form_state);
}

do i need to pass the form data as parameter??


texts:
I wanted to access the keyword being searched in the Apache Solr. Thus i used the hook_apachesolr_process_results Hook to access the $query variable.
But I am unable to access the keyword as it is inside a SolrBaseQuery [params:protected] object.
It throws a error saying Fatal error:  Cannot access protected property SolrBaseQuery::$params
Is there any way of accessing the protected parameters of Apache Solr or is there any other approach to get the keyword being searched.


texts:
I want to add the login form to a custom page I've created using a custom module, but I dont know how?

Shouldn't there be a form to use like get_drupal_form?

Using Drupal 7.


texts: How to add extra eventlistener to menu object in attached library

texts:
This is my first Drupal 8 project and I'm running into a problem figuring out how to attach an extra event handler to an object.
I am working on a custom theme using Radix as base theme. I am using Superfish as menu module.
One of the issues is that Superfish creates an extra 'root' menu called 'Menu' that is shown when the Bootstrap hamburger menu is clicked. You subsequently need to click on 'Menu' to show the actual (accordion) menu.
I found a snippet of code in an issue: https://www.drupal.org/project/superfish/issues/2891228 that hides the 'Menu' toggle, but I cannot get it to work.

I have setup a library definition and created a 'script.js':

import "popper.js";
import "bootstrap";

(function($, Drupal) {
  Drupal.behaviors.helloWorld = {
    attach(context) {
      console.log("Hello World");
    }
  };

  Drupal.behaviors.myMainMenu = {
    attach(context) {
      console.log("myMainMenu: " + context.toString());
      $(".navbar-collapse", context).once('myMainMenu').on(
        "show shown shown.bs.collapse show.bs.collapse",
        () => {
        console.log("navbar-collapse");
        if (!$("#superfish-main-accordion").hasClass("sf-expanded")) {
          console.log('no expand');
          $(".superfish-main-toggle")
            .click()
            .hide();
        }
      });
    }
  };
})(jQuery, Drupal);

I know the script runs, because I see 'Hello World' and 'myMainMenu' + some glob several times in the console. But I never manage to get the other console messages.

I also know the code in the if statement is correct, because, if I run it manually in the console, it works as intended.

What should be the correct code?


texts: How to use negative number as argument value in a drush command?

texts:
I'm trying to create a drush command that need negative and positive numbers as argument, all works fine with the positive numbers, but once I tried to use the negative number I get this error:

[error]  Unknown option: --1.  See `drush help mw-reorder` for available options. To suppress this error, add the option --strict=0.

Is like there is no way to use a negative value because drush think that this is an option.

I looked inside the drush code but I didn't found anything.

Maybe the solution is use a special option in the command to says that the argument will be consider as a negative value or I'm missing something here?


texts: How to make content private and only for certain roles to see

texts: I have a content type called collection and 2 user roles: role1 and role2. role1 users can create collections. What I want to do is to allow role1 users to indicate whether they want their collection remain private (in which case only logged in users and hence role2 users can see it) or let it remain public, in which case anonymous users can see the content. Each collection is really just a collection of pictures. I am using Drupal 6.


texts: Allow .svg logo uploading in theme settings

texts: How can I allow using .svg files for the logo field, in the theme settings?


texts: How to display exposed sort in views using one drop-down widget?

texts:
By default Views 3.0 module for Drupal 7 uses two drop-downs to display exposed sort. First drop-down to select field name, and other one - to select sort direction.

How do i can exposed sort in one drop-down?


texts: Creating argument to filter multiple NID's in a single filter-criteria

texts:
I'm having a rather simple Views issue in Drupal 7, Views version 3.11.7

I'm creating a View of Node-teasers so I need to filter it by the desired nodes NID's.

As you could see in the following image, I just typed their numbers but surly nothing happened.

What should I type there that the filter would work?


texts:
I am creating a site for a complex organization of authors, editors, and publishers. Basically, each author is responsible for 1-5 pages and can only create drafts of these pages. Similarly, editors can only edit and approve pages to which they are assigned. There are max 5 publishers who are tasked with editing, publishing, creating new pages and navigation items, and assigning authors and editors.

If we have about 50 authors and 50 editors, how do we set up permissions and workflow for this site on Drupal 8?

One solution is to have Workbench Access set up to work on Taxonomy where each page is tagged with an author term and an editor term. We would then have to set up one term for every user and two fields on each page. Is there a more direct approach?


texts:
I have a website with three languages (Polish, English, and French) with English being the default. English and French should use a URL like domain.com/en and domain.com/fr; Polish should use a separate domain, domain.pl.

How can I achieve this?
I've seen suggestions to use hook_language_negotiation_info(), but it's not working for me at all.


texts:
I want to create an archive page for a custom content type.  Essentially list them all on a single page.

I understand that I need to create a module, and implement hook_block_info() and hook_block_view().  What I don't know how to do is to retrieve content so I can loop it out. In wordpress there is query_posts($post_type = mycustomcontenttype). Is there an equivalent in Drupal 7?

I do not want to use the Views module for this.


texts: Is it possible to execute a function on a user object in Twig?

texts:
You can use hook_entity_load to add fields to the user object like so:

function mymodule_entity_load($entities, $type)
{
    if ($type == 'user'  )
    {
       foreach($entities as $e) {
         $e->myField = 'hello';
       }
    }
}

That will allow me to do this in twig:

{{ user.myField }}

This is quite useful, but it would be  great if I could do this:

{{ user.getActivity() }}

Or more specifically:

Members

    {% for activity in user.getActivity()  %}

{{ activity.time }}

    {% endfor %}

Is there a way to add a "function" in this way?


texts:
How to translate the output of format_plural which returns a new translatable string every time the count increased.

I put the translation with @count but it returns an array like @count[NUMBER]
the NUMBER increased and for every NUMBER we have a string that need translation.

The translation work if I put @count[NUMBER] and didn't work for NUMBER-1 nor NUMBER+1

How to translate all strings with one translation?

The code comes from download_count module

And here is the piece of code

if (isset($file->downloads) && $file->downloads > 0) {
$output .=     format_plural($file->downloads, 'Downloaded 1 time',     'Downloaded @count times');

}

Finally I need to translate plural strings form the translation interface drupal provides and fix the raised number of strings

I have .po files and had changed the plural-forms as that comment then import the file but nothing changed so I need help to fix it.

Thanks in advance


texts: Additional Configuration to disable anonymous session cookies?

texts:
I am running a clean install of Pressflow 6.28. I have set the following configurations:

Cache Mode: Normal;
Min Cache Lifetime: 5 minutes;
Page Cache Max Age: 1 day;

I have installed no contributed modules and have disabled all optional modules that ship with Pressflow.

I am seeing inconsistent behavior with setting session cookies with anonymous users. Sometimes a session is not set, but most of the time it is. When I login and logout, session remains set. If session is not being set and I run 'drush cc all' it begins to be set. I am wondering if there is perhaps some additional configuration I may be missing.


texts: I want to show a popup for access denied page. Is there any module available for this? I know I can create a custom module for this but I want to know if there is any module available for this.


texts:
I recently manually upgraded to Drupal 8.4, from 8.3 because I couldn't get drush to work. I'm now trying to install drush locally as this seems to be the recommended way from the drush documentation. (I removed the global install of it I had), but I get the following errors (below).

[www public_html]$ composer require drush/drush
Using version ^8.1 for drush/drush
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - drush/drush 8.1.0 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.1 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.2 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.3 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.4 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.5 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.6 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.7 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.8 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - drush/drush 8.1.9 conflicts with drupal/drupal[No version set (parsed as 1.0.0)].
    - Conclusion: don't install drush/drush 8.1.14
    - Conclusion: don't install drush/drush 8.1.13
    - Conclusion: don't install drush/drush 8.1.12
    - Conclusion: don't install drush/drush 8.1.11
    - Conclusion: don't install drush/drush 8.1.10
    - Conclusion: don't install drush/drush 8.x-dev
    - Installation request for drupal/drupal No version set (parsed as 1.0.0) -> satisfiable by drupal/drupal[No version set (parsed as 1.0.0)].
    - Conclusion: remove symfony/console v3.2.8
    - Installation request for symfony/dependency-injection (locked at v3.2.8, required as ~3.2.8) -> satisfiable by symfony/dependency-injection[v3.2.8].
    - Installation request for drush/drush ^8.1 -> satisfiable by drush/drush[8.1.0, 8.1.1, 8.1.10, 8.1.11, 8.1.12, 8.1.13, 8.1.14, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.1.7, 8.1.8, 8.1.9, 8.8.x-dev, 8.x-dev].
    - Conclusion: don't install symfony/console v3.2.8
    - drush/drush 8.8.x-dev requires symfony/console ~2.7 -> satisfiable by symfony/console[2.7.x-dev, 2.8.x-dev].
    - Can only install one of: symfony/console[2.7.x-dev, v3.2.8].
    - Can only install one of: symfony/console[2.8.x-dev, v3.2.8].
    - Installation request for symfony/console (locked at v3.2.8, required as ~3.2.8) -> satisfiable by symfony/console[v3.2.8].

Installation failed, reverting ./composer.json to its original content.


texts:
With Pathauto, is it possible to use the url of a node's term as a token?

In case it makes a difference im using the Taxonomy Menu module aswell. Thanks

UPDATE - The taxonomy is hierarchical. So if I have:

Food/Pizza/Margareta

Then if a node is tagged with 'Margareta' I need the path to be:

Food/Pizza/Margareta/node


texts: Password protection for section of a drupal website

texts: I am planning out a Drupal website, and it will have a password protected section.  All users will need a username and password to access content, but client wants to issue passwords by company (group).  For example, ABC company might have 20 employees, and they can all use the "ABC" username and password (issued by client) to access and read articles/content online. DEF company will use the "DEF" username and password, to access the same content.  What is the best module to accomplish this?


texts: Change node author on node save with rules

texts:
I have a very simple rule with Event "Before saving content" and Elements "Content is of type (page)" and would like the action to be something similar to "Change node author to UID X", which would be the UID I want.

I can't seem to be able to achieve that with the actions exposed. To test my rule I've been trying to display a message on the site when triggering the rule and it works just fine.

Any idea how to do that without having to write code?

This is on Drupal 7 (latest) with latest stable Rules version.


texts: How to save custom theme settings in a subtheme?

texts:
I've created a subtheme of the Premium Responsive theme. It was working fine until I tried to change some of the advanced theme settings within the subtheme's Appearance page. The parent theme adds settings for configuring social icons, a slideshow, etc., but unchecking some of the custom options and submiting the form resulted in a message saying "The configuration options have been saved", but the settings were returned to checked.

At first, I thought I needed to copy the theme-settings.php to my subtheme and customize it, but that results in two sets of settings displaying on the Appearance page, one for the parent theme and one for the subtheme (plus, still neither set of settings would stay unchecked when I submitted the form). This seems odd, since the Creating a sub-theme documentation, says "Theme settings set via advanced theme settings' theme-settings.php are not inherited."

So, how am I supposed to set custom theme settings within a subtheme? Do I need to implement a theme-settings.php file within the subtheme or not?


texts: Is is possible to call a function inside a .inc file of a module via drush eval?

texts:
I have a module with additional (.inc) files containing functions I need to run via Drush. I know it is possible to run drush eval, but when I try to do it for those functions I get the following error:

  PHP Fatal error:  Call to undefined function my_module_my_function() in /usr/share/php/drush/commands/core/core.drush.inc(1037) : eval()'d code on line 1

This command works (the function is in the .module file).

drush eval 'my_module_cron();'

This command does not work (the function is in the .inc file).

drush eval 'my_module_my_function();'

Is there any workaround, besides moving the function in the module?


texts: How to remove non breaking space from body/value in migration process?

texts:
I am successfully migrating the content from Drupal 7 to Drupal 9. However, I am getting some extra non-breaking spaces I'd like to remove.

I tried using a basic str_replace plugin, but that doesn't work.

What am I doing wrong? What else should I look into?


texts: Why is "drush make" installing a library in /sites/all/libraries instead of /libraries?

texts:
I am trying to allow prospective users to demo my module on simplytest.me, however, it requires an external javascript library. I recently created a drush make file for the D7 version of this module, and it is working fine. The D8 version is downloading the library, but placing it in drupalroot/sites/all/libraries instead drupalroot/libraries. Is there a way to change this behavior? Here is my make file.

api=2
core = 8.x
projects[drupal][type] = core
libraries[flot][download][type] = get
libraries[flot][download][url] = https://github.com/flot/flot/archive/master.zip
libraries[flot][destination] = libraries
libraries[flot][directory_name] = flot

I tried using libraries[flot][destination] = /libraries but that did not change the behavior.

Edit: I changed to a make.yml file, but this does not even download the library.

api: 2
core: 8.x
projects:
  - drupal
libraries:
  flot:
    destination: "libraries"
    directory_name: "flot"
    download:
      type: "get"
      url: "https://github.com/flot/flot/archive/master.zip"


texts: how to edit multiple menu itmes on menu management page

texts:
Is there a way to edit multiple menu items on menu management page. I have a site with lots of menu items under one menu, if I want to change the parent of multiple menu items I will need to drag each menu item individually to the parent. Is there a way we can select multiple menu items and change there parent.

And is there a module which allows us to collapse and expand the menus as per our requirement.

Some thing like Taxonomy Manager Module.


texts: How to add value to a field in a node through code?

texts: I have a field that I need a value assigned to, I want this field to be populated with a particular value when the node is being saved. Where should the code be placed? And how would I go about accomplishing this?


texts:
I am connecting views to an external database and everything works fine if my views handler is a string but not as a date, here is my view definition:

$data['Punches']['Punch_Date'] = array(
   'title' => t('Punch Date'),
    'help' => t('Employees Punch Date'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_date',
    ),
  );

If I change views_handler_field_date to views_handler_field I can see the records in my view. The date coming from mysql looks like

2013-08-27

I would also like to format that date to look like

08-27-2013

The biggest problem is that I want to be able to filter between dates, thanks for any help that can be given.


texts: Are there cases where a third-party module would need to use its own file similar to xmlrp.php, cron.php, or authenticate.php?

texts:
Drupal 7 comes with some files (authorize.php, cron.php, update.php, xmlrpc.php) that bootstrap Drupal, and execute specific tasks.

Are there any cases where a module would need a similar file to bootstrap Drupal, and execute specific tasks? What are the pros of using this method instead of using a menu callback?
Why does Drupal use cron.php, but it uses a menu callback for the batch operations?


texts: Update from 8.1.3 to 8.1.7 gives me a fatal error on most pages

texts:
After attempting to update to version 8.1.5 I received the

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

error on many pages. I also get the following error in Recent Log Messages;

"Drupal\Component\Plugin\Exception\PluginNotFoundException: The "2" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of   /home/username/public_html/domain/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Any ideas what could be causing this or how to fix it?

Update 2016/07/20

I just tried once again to update from 8.1.3 to 8.1.7 and am getting the same errors. My 8.1.3 site was stable with no errors.

Specifically, the site has the following issues after updating and after running update.php several times.

non-admin users can't log in; they receive the white screen of death upon login attempt, and can't even navigate to a different page than the default user page. The can only successfully logout using /user/logout to get back to the working frontpage and other working content pages.
when logged in as admin, eveything seems to work except for the "extend" and "people" admin tabs, which result in a wsod.

The reports details show the following information after an unsuccessful attempt to access;

Type php

Date Wednesday, July 20, 2016 - 08:09

User admin

Location http://www.domain.com/admin/people

Referrer http://www.domain.com/admin/config/people/accounts

Message Drupal\Component\Plugin\Exception\PluginNotFoundException: The "2" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /home/username/public_html/domainfolder/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Severity Error

Hostname @@@.@@.@@@.@@@

Operations

Type
page not found

Date
Wednesday, July 20, 2016 - 11:34

User
admin

Location
http://domain.com/quickedit/metadata

Referrer
http://domain.com/node/preview/aabc334a-08fb-4d6a-8672-281dbe7a56e6/default

Message
/quickedit/metadata

Severity
Warning

Hostname
113.37.159.155

Operations

Type
php

Date
Wednesday, July 20, 2016 - 11:25

User
admin

Location
http://domain.com/node/add/lesson

Referrer
http://domain.com/speakraku

Message
Warning: mkdir(): File exists in Drupal\Component\PhpStorage\FileStorage->createDirectory() (line 165 of /home/username/public_html/domain/core/lib/Drupal/Component/PhpStorage/FileStorage.php).

Severity
Warning

Hostname
113.37.159.155

Operations


texts: Email-only subscription form with mailchimp module?

texts:
I have a mailing list in MailChimp and I recently installed the mailchimp module in my Drupal 6.0 site.

The subscribe form for anonymous users has first name and last name input elements, as well as an (empty and ugly) interest groups div.

Is there a way, using the mailchimp module, to present simply an email+button subscription form block?


texts:
How do I include the full body field in the RSS feed for a taxonomy term?

I tried enabling the default taxonomy view in Drupal, but it doesn't let me select any fields in the field list area.


texts: How to set file upload directory by parent node content type and node id

texts:
I am trying to set the upload directory for a file field to contain the content type (and node id) as part of the path.

The desired path for my public files field is publication_documents/pub/content_type/node_id_of_node_this_was_uploaded_to/filename

I have tokens installed, but it doesn't seem to offer me tokens related to the parent node in the upload directory setting:

Slide 30 of This slideshow seems to indicate that it is possible, but how can I do it?

In case it matters, I'm using the media and file_entity modules.


texts: Which Apache module is required by Drupal system

texts: Could anyone advise which Apache module is required by Drupal system?


texts: help to understand files in sites/all/default/files/js folder

texts:
I'd like to understand what are the ....js.gz files located in sites/all/default/files/js.

I thought they are cached js files.

But if I clear all caches (drush cc all) these files still remain there.

I've made a capture of the folder:


texts: how to hide view block when other view block not giving any search result?

texts:
I have created a view(ABC) in which search criteria: "country type content" and other filter is "promoted to front page"."Promoted to front page" filtering content using cck boolen field(yes/no).

Another view(XYZ) has search criteria:  "country type content" only.

When  promoted to front page cck field is empty or null my first view(ABC) will hide
same as I want to hide second view(XYZ) If first view is hidden.

Both the views i placed at same region "Header".

How to hide (XYZ) view, if (ABC)view has no content or hidden?


texts: Drupal 6 Content Types fields not saving

texts:
I am using Drupal 6 and I am somewhat new to it.

I've been running into a strange behavior.

I have created a new Content Type that have 4 new fields and when I try to make a new Content using this Content Type everything is saved except for the new fields.

Each times that I save the Content the new fields comes out as empty.

I have been looking on search engines without luck, is it a known behavior, is it a bug or is could it be a mismanipulation?

What should I be checking to debug this situation?

The additional fields in question:

Label                     Name                      Type
========================================================
Product Subtitle          field_subtitle            Text
Product Overview          field_overview            Text
Product Features          field_features            Text
Product Specifications    field_n_specifications    Text

These were defined using the UI at: /admin/content/node-type/[content-type-name]/fields

The fields appear correctly when editing/adding new content as well in the listing of the fields in the content type management section.


texts: How do you target a specific type of content?

texts:
I have the content type (node), article, page, recipe.
The code below can be used to flag any type of content.
How do you target a specific type of content ?
For example I only want to flag the article and recipe content type.
<?php

/**
 * @file
 * Holds hook implementation for the Admin Task Notify module.
 */

use Drupal\flag\FlaggingInterface;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\user\Entity\User;
use Drupal\comment\Entity\Comment;

/**
 * Implements hook_node_update().
 */
function admin_task_notify_node_update(Node $node) {

    $flag_id = 'moderate_node';
    $flag_service = \Drupal::service('flag');
    $flag = $flag_service->getFlagById($flag_id);
    $account = \Drupal\user\Entity\User::load(1);
    $flag_service->flag($flag, $node, $account);

}


texts: How to set alias pattern of node's source alias?

texts:
When I translate a node I want that node's path alias to be like it's source node's path alias.

So in the url pattern for the translation nodes I use the token:

  [node:source:url:path]

which according to this thread should be fine. But, it actually generates the alias "/node-402-0", although the source node has a path like "/welcome".

I have the feeling that in the token module the wrong language is being looked into.

Am I missing something?


texts:
Hello I'm currently working in the template.php file to preprocess a view and i'm experiencing strange things:

This relates to a field collection field:

  $collect_field = $value->field_field_screenshot[0]['rendered']['entity'];

Without being logged in this code fails with

  Notice: Undefined index: entity

If logged in everything is fine...

Somebody could imagine what is happening here?