texts: How to prevent image files being duplicated while importing nodes with the Feeds module?

texts:
I have a large catalog import where the items often refer to a single common image (such as "brand_logo"). When I import the images via CSV parser, if the item refers to the same image file, an incremented duplicate is created.

Example: Using the example files supplied with the module, I modified 2 books to use the same image file, which are imported to files/field/image/ as 51JQbhO0MmL.jpg and 51JQbhO0MmL_0.jpg.

This causes the images directory to balloon to 20 times the size it should be (lots of shared images).

Honestly, what I would prefer to do is to upload the images to the site separately (manually, via FTP etc.) and just import the links to the images, but I haven't figured that one out either.

(The data (files) is not being replicated, just the images are replicated.)


texts: Is it possible to replace page arguments with new ones in a view exposed filter?

texts:
I'm creating a views filter with the exposed form.

After its submitting a new page is loaded with arguments like these (I use the Acquia Dev desktop)

http://pal.dd:8083/en/cities?country_id=2&region_id=4

I want to make the string shorter, for example, like this

http://pal.dd:8083/en/cities?geo=2_4

And in the query() method transcribe this argument and get country and region value from it.

I'm wondering, is it possible to do it inside the view filter class?

I tried to manipulate with the values of the exposed form in the submitExposed function, but I didn't manage to achieve the positive result.

Has anybody run into it?


texts: Load Bootstrap CDN only if not is loaded before from another project

texts:
I want to load Bootstrap CDN but only if is not loaded before. How can I do this?
Today I'm loading on Libraries.yml like this:

And it works. But the problem is: in some cases the Drupal site already have another project that loads Bootstrap CDN and it is a conflict.
Is there a way to load Bootstrap CDN only if not exists?


texts:
I created a bootstrap sub theme and and have enabled display suite.  I have enabled ds extra fields and chose a layout for my content type for full view display.  When going to the full view page of my content none of the ds fields are showing.

I have enabled title, author, post date, submitted by but none of these are showing.  Is there something special you must do to get ds to work on a subtheme?


texts: How can I check if the cart has shippable products?

texts:
How can I check if the cart has any shippable product in Ubercart 3 for Drupal 8? Previous version had uc_cart_is_shippable() method which Drupal 8 module does not seem to have by default.

Is there a separate/additional module to get this function working? Or how else can I check if the cart has a shippable product?


texts: Using fields of referenced node as filters in views

texts:
I have two content types location & business. Business type has an entity reference field address which is referencing location.
Now I want to use fields of location content type as filters in views to display some business nodes. I have tried relationships & contextual filters but no result appears. Can anyone help ?

EDIT(adding more details):  Actually i want to create a search page displaying list of business nodes. But i want to give an additional exposed filter to user for changing the city. City field is part of location content type. Location & Business content type are related using entity reference as explained above. So how can i use this city field as filter in views. Hope this helps!


texts: custom style to a region of a flexible layout

texts:
I want to use panel fields in views. So I created the flexible panel layout in custom layout. Added some style to it i.e rounded corner, fonts etc.
But when I save the layout no style appears in preview mode, even the settings button is gone from the panels. So while using in views no style shows up.

 (settings button is not showing)


texts: Why theme scripts.js is not working, how to attach it

texts:
I started learning Drupal 8 and encountered problem when I wanted to use scripts.js file globally. I am just testing out code to change background color and write something to console, but script file is not working. source/scripts.js is minified to build/scripts.js which is included in libraries.yml and global is included in info.yml. What am I doing wrong? Maybe I don't understand new Drupal 8 Javascript API?

libraries.yml

  global:
  version: VERSION
  css:
    base:
      css/base/base.css: {}
    layout:
      css/layout/layout.css: {}
    component:
      css/components/components.css: {}
    theme:
      css/theme/theme.css: {}
      css/theme/print.css: { media: print }
  js:
    js/modernizr.js: {}
    js/build/scripts.js: {}
  dependencies:
    - core/drupal
    - core/jquery

info.yml

libraries:
  - core/normalize
  - offer42/global

source/scripts.js

(function (Drupal, $, window) {

  // To understand behaviors, see https://www.drupal.org/node/2269515
  Drupal.behaviors.offer42 = {
    attach: function (context, settings) {

      $(context).find('.block-offer42-branding')(function () {
          $(this).css('background-color', '#000');
          console.log("workinh");
      });

      // Execute code once the DOM is ready. $(document).ready() not required within Drupal.behaviors.

      $(window).load(function () {
        // Execute code once the window is fully loaded
      });

      $(window).resize(function () {
        // Execute code when the window is resized.
      });

      $(window).scroll(function () {
        // Execute code when the window scrolls.
      });

    }
  };

} (Drupal, jQuery, this));


texts: Drush 8 throws unknown error on Drupal 8 install

texts:
UPDATE: I have managed to update Drush using Wim Mostrey's help as seen below. Drush is now at version 8, and continues to work with my Drupal 7 sites, but when I try to use it on my Drupal 8 site, I get this:

Drush command terminated abnormally due to an unrecoverable error.
Error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home1/[uname]/public_html/_d8/core/lib/Drupal/Component/Serialization/Yaml.php, line 54 Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home1/[uname]/public_html/_d8/core/lib/Drupal/Component/Serialization/Yaml.php

Does anyone know what this issue is?

Original Question: I want to upgrade from Drush 6.5 to 8, even though current Drush is ver 9 because I want to keep backwards compat. I'm not understanding the instructions on github very well, and concerned about it getting gummed up. Is there a clear, simple guide for this?


texts:
I have a view with no fields but a special format (An openlayer map). I would like to wrap the whole output (a map) with a static link. Typically I would like something like:

        /*the map*/

Is this achievable?

EDIT
My view doesn't use fields, so I can't use custom texts fields.


texts: Is it possible to output the Devel generated query log in some way? By default, it prints to the bottom of the page which is fine until I need to send the results to someone else to review.


texts:
I have a config entity with a form which extends Drupal\Core\Entity\EntityForm, which has a public form() and a public save() methods. They both work fine and dandy. I want to validate some information before saving the form. As far as I can tell there's a validateForm() method already built in via the class it extends.

I can't seem to find much information on how to do that. I've tried the obvious, simply setting a return false in the validateForm method but it doesn't seem to be called at all.

I don't have much experience with Drupal in general so I'm obviously doing something wrong.

If anybody could point me in the right direction here, I'd be grateful.

I'd also like to keep the field values in case of an error. I can only assume that that happens by default, but then again I may be wrong.


texts: Modify values that are received via Feeds_ex

texts:
I've setup Feeds_ex module using JSONPath. One of the value I import is language code and it has next format: [language-country], i.e. [en-US] or [en-UK].

Right now I do import full value 'en-US', however I need to get only 'en' and get ridd of '-US'.

What is the good/best practice to modify value that I receive from Feed?

Thanks.


texts: Does the Context module check block visibility settings?

texts:
I am using Drupal 7.14 and the Context module (7.x-3.0-beta4).

I set block visibility settings and the Context module doesn't seems to be checking them before rendering. Only context conditions are validated before rendering a block.

I would like to use PHP code as visibility conditions to render a block, but Context module is not respecting block visibility settings.

Is it a bug? Or context module is designed to respect only Context Visibility settings but not block visibility settings that are enabled in a particular context.

Any idea ?


texts: Unable to install the “H5P.Scorm.h5p” library: “The uploaded file was not a valid h5p package”

texts:
Thanks to jackrabbithanna’s help on this other question I seem to be 1/2 way to getting H5P related libraries installed in my Drupal 7.59 install. I am attempting this on macOS High Sierra under MAMP 4.5 (PHP 7.1.12) and MAMP 3.5.2 (PHP 5.6.10).

But like I said, I am 1/2 way there; not fully there. I am able to get the H5PEditor.ScormFile (1.0.8) library installed, but not H5P.Scorm (1.1.16).

The libraries in question are as follows:

H5PEditor SCORM
H5P SCORM/xAPI

To help this process, I have now devised a bit of a Bash scripting process to get the h5p packages built from the source GitHub repos. Here is what I do…

The H5PEditor.ScormFile (1.0.8) Bash dance:

cd ~/Desktop/

git clone https://github.com/pavloshevchuk/h5p-editor-scorm

cd ~/Desktop/h5p-editor-scorm

find . -type f \( -name '.DS_Store' -o -name '.gitignore' -o -name 'LICENSE' -o -name 'README.md' \) -exec rm {} \;
find . -type d -name '.git' -exec rm -rf {} \;

mkdir H5PEditor.ScormFile && mv {scripts,styles,*.json} H5PEditor.ScormFile

echo '{
  "title": "H5PEditor.ScormFile",
  "language": "en",
  "author": "Pavlo Shevchuk",
  "license": "cc-by-sa",
  "preloadedDependencies": [
    {
      "machineName": "H5PEditor.ScormFile",
      "majorVersion": 1,
      "minorVersion": 0,
      "patchVersion": 8
    }
  ],
  "mainLibrary": "H5PEditor.ScormFile",
}' > h5p.json

zip -r ../H5PEditor.ScormFile.h5p *

The H5P.Scorm (1.1.16) Bash dance:

cd ~/Desktop/

git clone https://github.com/pavloshevchuk/h5p-scorm

cd ~/Desktop/h5p-scorm

find . -type f \( -name '.DS_Store' -o -name '.gitignore' -o -name 'LICENSE' -o -name 'README.md' \) -exec rm {} \;
find . -type d -name '.git' -exec rm -rf {} \;

mkdir H5P.Scorm && mv {css,js,*.json} H5P.Scorm
mkdir content && mv icon.svg content

echo '{
  "title": "SCORM/xAPI",
  "language": "en",
  "license": "cc-by-sa",
  "preloadedDependencies": [
    {
      "machineName": "H5P.Scorm",
      "majorVersion": 1,
      "minorVersion": 1,
      "patchVersion": 16
    }
  ],
  "mainLibrary": "H5P.Scorm",
  "embedTypes": [
    "div"
  ]
}' > h5p.json

zip -r ../H5P.Scorm.h5p *

And with those two things done I now have two H5P files ready to go: H5PEditor.ScormFile.h5p and H5PEditor.ScormFile.h5p.

But while installing H5PEditor.ScormFile.h5p proceeds as expected, the same can’t be said for H5PEditor.ScormFile.h5p. I get the following Drupal system information message:

  For security reasons, your upload has been renamed to H5P.Scorm_.h5p.

Followed by this “great news”:

  The uploaded file was not a valid h5p package

Screenshot attached below. Any insight is appreciated.


texts: Can you make a node title \ heading link to it's NID?

texts:
I'm looking for a way to click a node's title to refresh it's very page. For example, if the current node is node/1 and I'll click it's title \ H1 the page will be refreshed...

Tried to go to > structure > Content types (desired content type) > edit > edit display, but I couldn't find an option to edit the Page-heading \ h1 there.

I must say I'm looking for a non-modular solution (preferably without customization also).

Thanks.


texts:
I'm trying to use a Google font, which requires adding either a <link> or <style> section inside the <head> per the below instructions. I am using a subtheme and can modify the  section directly in html.html.twig, if that's the right way to do it.

However, I noticed <head-placeholder>, <css-placeholder>, and <jss-placeholder> inside <head> and I am wondering if those are intended to be used to insert code from somewhere else.

What's the best practice for adding to <head>?


texts:
I am using panels with a Node template to override the view of a content-type Employee.

At the moment I am using pathauto to give a clean url of /Employee/[Employee-Name].

I'd like to use the panels selection criteria to have an alternative view of that node template by using a path such as /Employee/[Employee-Name]/View2

How would I go about generating the second alias pattern?


texts: Ignoring accents/diacritics in apachesolr

texts:
I have a site that's in English, but there's a fair amount of French text on it. So, there are some special characters like è, é, á, etc.

I don't want to worry about those diacritics at all when searching (using solr 4), so that, say "any e gives you every e"

Right now, I have it so if you search for non-diacritics, you get all the related diacritics (search for "siecle", and get "siècle"), but if you search using diacritics it won't find anything (search for "siècle" returns nothing.)

I've been up and down between playing around with mapping-ISOLatin1Accent.txt and using:

<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>

and

<filter class="solr.ASCIIFoldingFilterFactory" preserveOriginal="false"/>

But nothing I've tried seems to have any change to this. I assume I have to add this to both  AND  in schema.xml, but I'm not sure which fieldtypes to do that in. There are fieldtypes of:

text_ws

"text field that only splits on whitespace for exact matching of words"

text

"A text field that uses WordDelimiterFilter to enable splitting and matching of words..."

text_und

"An unstemmed text field - good if one does not know the language of the field"

I've tried every combination I can think of, and cleared/rebuilt the index each time, but nothing. A search including diacritics always fails.

After looking through the admin site for Apache, it looks like the ASCIIFoldingFiltorFactory is being added to the index analyzer, but NOT the query analyzer for the fieldtypes of text, but I don't know why; I added it the same way to both analyzers.


texts:
In my project I need facet search as block view that need to be included in content region. So I created View as block and added facet block in header of the view. Also need infinite scroll, so enabled ajax in view. So issue is that facet search ajax and View ajax causing conflict so that the query parameters are duplicating in URL.

http://localhost.com/sample-page?q=/sample-page?q=/sample-page?filter[0]=category_filter:171&_wrapper_format=drupal_ajax&filter[0]=category_filter:171&filter[1]=category_filter:173&filter[2]=category_filter:174

Is there any workaround to fix this? Any patch is available for this ?


texts: Can't delete entities using entity_delete_multiple()

texts:
I was studying how  to work with entities following http://www.bluespark.com/blog/drupal-entities-part-3-programming-hello-drupal-entity.

I downloaded the module, created by the author of that article. Then I wanted to delete entities, using the following code.

entity_delete_multiple('basic', array(1,4) );

But it didn't delete anything. I though that the delete method should be implemented, and added it into the class.

class BasicController extends DrupalDefaultEntityController{

  public function delete($basic) {
    var_dump(1);exit;
    db_delete('basic')
      ->condition('basic_id', $basic->basic_id, '=')
      ->execute();
    field_attach_update('basic', $basic);
    module_invoke_all('entity_delete', 'basic', $basic);
  }
};

It doesn't work: 1 is not printed.

How do I delete an entity with fields?


texts: Set a datetime field configured as date-only

texts:
I'm developing a module where I have to set a user profile date_field. I tried several methods to implement this but not one worked for me.
This is the code I am using.
private function updateUser($user_import,$uid = null) {
  if (!$uid) {
    return false;
  }

  $roles = $this->matchRoles($user_import->roles);
  $birthday = $this->birthdayDate($user_import->profile_geburtsdatum);
  $language = \Drupal::languageManager()->getCurrentLanguage()->getId();

  $user = \Drupal\user\Entity\User::load($uid);
  // $user->setPassword($this->randomPassword());
  $user->setEmail($user_import->mail);
  $user->setUsername($user_import->name);
  $user->enforceIsNew(false);

  // Optional settings
  $user->set("init", $user_import->init);
  $user->set("langcode", $language);
  $user->set("preferred_langcode", $language);
  $user->set("preferred_admin_langcode", $language);

  foreach ($roles as $role) {
    $user->addRole($role);
  }

  $user->set("field_profile_geburtsdatum", array('#default_value' => $birthday));
  $user->activate();
  $user->save();

  drupal_set_message("UPDATE: User " . $user_import->name . ' ( '. $user_import->mail . ')');
}

private function birthdayDate($import_date) {
  $date = null;
  if (!empty($import_date)) {
    $date = strtotime($import_date->day.'.'.$import_date->month.'.'.$import_date->year);
    $date = date('Y-m-d 00:00:00',$date);
    $date = new \Drupal\Core\Datetime\DrupalDateTime($date, 'Europe/Berlin');

    /* $date = array(
         'year' => date('Y',$date),
         'month' => date('m',$date),
         'day' => date('d',$date),
       );
     */
  }

  return $date;
}


texts: Views search for labels in select list fields with exposed filters

texts:
I created page with Views 3 where users can find other user by entering data in several exposed filters.

That works great, but I have case where user must be able to to enter text, to search by label in select list field. (It has key | label structure )

When I expose that filter, it only gives me results on propper key values, but when label is entered, there is no result.

For example if i have 167 | Mathematics value,
and i enter 167, it lists users who have choosen that value from select field,
but if i enter "Mathematics", there are no results.

I do not see a kind of option to "search for labels" in select list, and filter result by that.

Is there a way to accomplish this ?

Thanks!


texts: Why is loading a field value from a group of nodes taking 30 seconds plus?

texts:
I have a D7 site with around 300,000 nodes. I am passing this function an array of 300-500 nids. Sometimes the function runs in under a second. Sometimes it takes 40 seconds or more! I can't figure out what causes the slow runs. How can I get the query consistent and fast?

function _load_field_values_for_nids($field_name, $nids)
{
  $field_info = field_info_field($field_name);
  $field_id = $field_info['id'];

  $map = array();
  $nodes_without_required_field = [];

  // Load up the properties from the node table.
  $sql = 'SELECT * FROM {node} WHERE nid IN (:nids)';
  $nodes = db_query($sql, array(':nids' => $nids))->fetchAllAssoc('nid');

  // Attach the single field to all nodes.
  field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));

  foreach ($nodes as $nid => $node) {

    if (isset($node->{$field_name}['und'])) {
      $map[$node->nid] = $node->{$field_name}['und'][0]['value'];
    } else {
      $nodes_without_required_field[] = $node->nid;
    }
  }

  $absent_count = count($nodes_without_required_field);
  if ($absent_count > 0) {
    watchdog("vwyw_load_fields", $absent_count." nodes did not have field, \"".$field_name."\" ");
  }

  return $map;
}

I noticed this SIX-SECOND query on the main /admin/content page (which took 12+seconds to load):

Here is the expanded XHProf output regarding that Count query:

I think this might be a mysql configuration issue rather that the particulars of a query. For instance, I think this query should run very quickly but it takes a second and a half:

The next time (same page load) it took 120ms and the time after that, 4.8sec!

UPDATE

Here is the XHProf output sorted by duration for a simple admin page that calls the function:


texts: Allow anonymous user to browse all the non-admin pages of the site anonymously

texts:
I want to allow anonymous user to access all the pages depending on a particular session set. These pages can be:

Node - both published and unpublished
Views pages
Taxonomy terms
custom hook menu urls etc
I am able to handle node pages using hook_node_access. But is there any common hook and any other approach that allows me to grant access for all the pages.
Also, for views if there is no permission for anonymous user, I should be able to grant permission depending on a session set.


texts: How do you get the current destination URL query parameter in Twig?

texts:
Does anyone know to how to get the drupal destination in twig file?
At the moment I an getting the destination parameters in a preprocess function.
// Get destination params.
$variables['destination_params'] = \Drupal::destination()->getAsArray();

Then in the twig file:

You can try logging in to see if you have access.

Thanks!


texts: How can i use DB Connection of another site of my multisite?

texts:
Following situation:
I have a multisite with several sites. The codebase is the same but every site has his own database. Now i'm creating a module where i want to make adjustments in the databases for all sites at the same time. So i have to be able to make database connections to the other sites.

I already was able to get the settings from the other sites with that:

$sites = glob(DRUPAL_ROOT . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR);

foreach ($sites as $site) {
  $site_path = str_replace(DRUPAL_ROOT, '', $site);
  $siteName = str_replace('/sites/', '', $site_path);

  if (is_readable($site . '/settings.php')) {
    $siteConfigs[$siteName] = [];
    $settings = [];
    $databases = [];
    $app_root = DRUPAL_ROOT;

    require $site . '/settings.php';
    $siteConfigs[$siteName]['settings'] = new Settings($settings);
    $siteConfigs[$siteName]['databases'] = $databases;
  }
} ```

How can i use DB Connection of another site on my multisite installation?
I tried different things like:

foreach ($siteConfigs as $siteConfig) {
  Database::addConnectionInfo('default', 'default', $siteConfig['databases']['default']['default']);
  $db = Database::getConnectionInfo();
  var_dump($db);

}

But it always returns just the current site.

Thanks for any advice!


texts: Drupal 8 Configuration Entity translateable

texts: I was able to set up a Configuration Entity in Drupal 8. I was wondering if it was possible to flag that entity as translateable? I basically need the text in that configuration to map to all the languages we support in the site.


texts: Taxonomy term title not displayed as page title in Panels when paged

texts:
I have use case where for some terms, on the term pages (where nodes with that term are displayed) where for selected terms, I need to display an image instead of the title. To (try to) do this, I've done the following steps:

Add field_image to the vocabulary.
Upload images for selected terms
Enabled the built in taxonomy term panel page.
Created a content pane in the built in taxonomy term view that passes the tid.
Created a term view with a content pane display with term name and field_image as fields.
Hide term name from display, and set term name to be displayed in the No Results settings for field_image.
Add the content pane to the panel page display above the content pane from the taxonomy term view.

This all works great - on the first page. However, once I use the pager (from the view) to go to any subsequent pages, the page title (i.e. the term name or image) disappears. Looking at the page source, you can see that the panel pane with the term title (step 5 above) is not added at all, which makes sense, since there aren't multiple pages of term titles.

Is there a way to do what I need with the Views and Panels UI, or will I need to wield some code fu to replace the name with the image selectively?

Thanks.


texts: how to index unpublished nodes to apache solr

texts:
I want to display unpublish nodes to some of the user roles.

The apachesolr by default index only publish nodes.

Is there a way of indexing unpublished nodes to the apache solr index?


texts: "Edit layout" form missing revision log message field

texts:
When I edit the layout for a given node it is missing a log message field in the revision area. Is anybody else seeing this or am I alone? In trying to diagnose:

Where that particular revision log field would be defined to check if it's defined at all. If it's not then this is probably a core bug that should be addressed.
If it does exist, where this particular form is defined to make sure that the revision log field is actually being included in the form definition.

Any insights on the above? I'm using the lightning distribution, so it's possible that there's some sort of override going on there, but I figured I should be checking in core first just in case.

The overall goal here for bounty award is to have a functional revision log message field on the form.


texts: Drush command not found after Drush completely installed

texts:
I installed Drush 8 with composer.

composer require drush/drush:~8

Unfortunately, error drush command not found after Drush completely installed.

Why's the drush command can't be use?

Installing Drush for Drupal 8 with Composer

https://www.youtube.com/watch?v=ZqY_XsCTmAc


texts: Access denied for user anonymous for node retrieve service

texts:
I have installed services module and added a service. And then, enabled the retrieve and index resources for node. I also enabled the permission to view the published content for anonymous users. cache is also cleared. When i call the retrieve or index service, i am getting the below response.

  http://example.com/endpoint/node/1.json

Response:

["Access denied for user anonymous"]

Is there any thing i missed here?

Version D7 - Services 7.x-3.20

Update:
It was issue with domain module. Domain strict module was enabled. After disabling, it started working.


texts:
can I theme output of includes/pager.inc using drupal template system?

I want invert page links, I don't want any edit on pager.inc or CSS.

maybe invert items passed to theme_pager function


texts: How do I write a custom migrate destination plugin in for a node type?

texts:
I've got a node type in Drupal 8 that uses field collections (from the module of the same name).  The Field Collections module doesn't yet have a working migration destination plugin, so what I'd like to do is use some kind of post-processing to (ugh) brute-force the field collection data into the nodes (note that I've tried the -dev version of Field Collection, and the destination plugin doesn't appear to be functional).  Note that my source is an SQL database and not a Drupal instance.

Here are the relevant files:

The migration definition file:

id: fm_quiz
label: FM Quiz
migration_group: quizzes
source:
  plugin: fm_quiz
  key: source
destination:
  plugin: fm_quiz
process:
  type:
    plugin: default_value
    default_value: quiz
  title: title
  uid:
    plugin: default_value
    default_value: 1
  sticky:
    plugin: default_value
    default_value: 0

The destination plugin:

<?php

/**
 * @file
 * Contains \Drupal\fm_quiz\Plugin\migrate\destination\FMQuiz.
 */

namespace Drupal\fm_quiz\Plugin\migrate\destination;

use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use Drupal\migrate\Row;

/**
 * @MigrateDestination(
 *   id = "fm_quiz"
 * )
 */
class FMQuiz extends EntityContentBase {

  /**
     * {@inheritdoc}
     */
  public function import(Row $row, array $old_destination_id_values = array()) {
    $node = $this->getEntity($row, $old_destination_id_values);
    print_r($node);

    return [$node->id()];
  }

}

At the moment, Drupal doesn't seem to want to recognize that this migration exists as written.

If I change the destination to "entity:node", then it imports the nodes as expected.  If I change the destination in both files to "entity:node:fm_quiz", then Drupal says that "Migration fm_quiz did not meet the requirements" (and provides no other information).

Am I doing something wrong, or is what I'm trying to do just not possible right now?  Do I need to just make an end run around the migration system?


texts: How do I alter the Price Component Title in Commerce Userpoints Discount without altering the module?

texts:
It seems that when a user adds a Userpoints Discount line item to their shopping cart it appears in the footer as 'Royalty', which will be totally confusing to users.

On line #382 of commerce_userpoints_discount.module there is this code:

function commerce_userpoints_discount_commerce_price_component_type_info() {
  return array(
    'userpoints' => array(
      'title' => t('Royalties'),
      'display_title' => t('Royalties'),
      'weight' => 1000,
    ),
  );
}

Without hacking this module, is there a way I can change this description? In my case, we will be using -two- Userpoints currencies (depending on the type of product the user orders) and we would like the description in the footer to be that userpoints description.

What I've already tried is to create my own hook with a higher weight. My hope was that my hook would take precedence over the default, but apparently not. Perhaps I don't understand 'hooks' well enough yet. If so, could someone tell me how to make -my- hook take precedence?

function my_module_commerce_price_component_type_info() {
  return array(
    'userpoints' => array(
      'title' => t('My Userpoints Currency'),
      'display_title' => t('My Userpoints Currency'),
      'weight' => 2000,
    ),
  );
}

In short, we want the Price Component title to match the currency type of Userpoints on the line item.


texts: Is there any Menu Module to show thumb image, content tile when mouse over on menu item

texts:
I want to create a main menu bar for my drupal blog, like shown in image

Means, when i mouse over on the menu item, it should show, node thumb image, content title.

is there any modules available to do this. I tried in google to find like this modules, no luck. Please any one give suggestion how to do this.


texts: How to Create a wall of activities (like Facebook wall) in my site, for each user?

texts:
I am building a social network site.
My plan is that every user would be able to write articles, tips, upload pictures, comment to others, like other posts etc.

My question is how can I aggregate all the user different activities in to one page (e.g. wall), so the user and all the other users can see all the activities in one page (similar to facebook wall)?

Thanks in advance.


texts:
I am using views to show a list of items from a vocabulary, I want a link under each item to the friendly url for the full view. Currently I am using the rewrite results in views like this:

Find out more about [name]

How can I get the friendly url that is setup in pathauto i.e. /partners/google?


texts: How to not have an image in a facebook share

texts:
I have a problem

Although many have the problem with not have the right image, I'm trying to have no image at all. I have ads on the page that get chosen because the content type has no image.

I have tried to do put in a "[none]", (then a random field from another content type), in the image field under open graph in meta tags, it's still not working.

I simply want to share the text itself without the image of the ads, and if you have a better solution, please mention.

Thanks!


texts:
I would like to add one extra field to existing default cart table form.

I need to output a field behind the product title (it is a field containing info about product type)

The field is part of the product content type. Idea behind this is: Ubercart shows by default only the title of product in cart form; i have created subtitle field in product content type, which describes the article in detail, as sometimes product titles are the same.

I have suggestion to use hook_form_alter but cannot find any examples how i can implement this hook in custom module to achieve this.

I am on Drupal 7 - 7.x-3.1 Ubercart.

Thanks for any clues !


texts: How do I prevent ajax ReplaceCommand from adding style attribute to the element?

texts:
In my ajax callback I'm trying to change the class of a button.
However, after changing the class a style attribute has been added dynamically to the button.
How to avoid this:

$form['bindFields'] = array(
        '#type' => 'submit',
        '#value' => t('Save'),
        '#attributes' => ['id' => 'bindFieldsBtn','class' => ['hiddenselect']],
        '#submit' => ['::submitForm'],
    );

in my ajax callback:

$form['bindFields']['#attributes']['class'] = ['shownselect'];
        $ajax_response->addCommand(new \Drupal\Core\Ajax\ReplaceCommand('#bindFieldsBtn', $form['bindFields']));
        $ajax_response->addCommand(new InvokeCommand('#bindFieldsBtn', 'change'));

the result adding display:block which I don't need

<button id="bindFieldsBtn" class="hiddenselect button js-form-submit form-submit btn-success btn icon-before" data-drupal-selector="edit-bindfields" type="submit" name="op" value="Save" style="display: block;">

Save


texts: Create a new template view for a specific vocabulary name

texts:
I'm in need of some help for my Drupal 7 site. Right now I am using the stock taxonomy view (/taxonomy/term/%) that came with views to display a listing of some specific nodes. It works great.

Now I would like to create another page that will display a different view listing of nodes under a different vocabulary term. I'd like to template to be different also.

I'm having trouble wrapping my head around how to best do this. I am using Panels for some of my pages so could I use that? I've tried to activate the panels page that overrides the taxonomy, but I can't because I am using views already to generate a page. Can I clone my current view and set a filter for a specific vocabulary and use that?


texts: Composer killed when installing a module

texts:
I am actually running Drupal on a LAMP (XUbuntu 20-04 with 4 GB RAM in VirtualBox)
At the beginning of the installation I had no problem with installing dependencies using composer
But since yesterday every composer command gets killed like in the following code (entity print installation):

igpde@igpde-VirtualBox:/var/www/html/d8igpde2$ composer require dompdf/dompdf
Using version ^0.8.6 for dompdf/dompdf
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Killed

I thought it could be a memory problem but in the php 7.4 client installation:

I read -1 should mean no limit

; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = -1

Any Id how I could solve this problem?

Thanks in advance for you suggestions

Running with the vvv flag:

igpde@igpde-VirtualBox:/var/www/html/d8igpde2$ composer -vvv require dompdf/dompdf | tee composer.log
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/var/www/html/d8igpde2): git branch --no-color --no-abbrev -v
Executing command (/var/www/html/d8igpde2): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/var/www/html/d8igpde2): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/var/www/html/d8igpde2): hg branch
Executing command (/var/www/html/d8igpde2): fossil branch list
Executing command (/var/www/html/d8igpde2): fossil tag list
Executing command (/var/www/html/d8igpde2): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /home/igpde/.config/composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading /var/www/html/d8igpde2/vendor/composer/installed.json
Loading plugin Drupal\Composer\Plugin\ProjectMessage\MessagePlugin
Loading plugin Drupal\Composer\Plugin\Scaffold\Plugin
Loading plugin Drupal\Console\Composer\Plugin\Extender
Loading plugin Composer\Installers\Plugin
Running 1.10.9 (2020-07-16 12:57:00) with PHP 7.4.3 on Linux / 5.4.0-42-generic
Downloading https://packages.drupal.org/8/packages.json
Writing /home/igpde/.cache/composer/repo/https---packages.drupal.org-8/packages.json into cache
Downloading https://repo.packagist.org/packages.json
Writing /home/igpde/.cache/composer/repo/https---repo.packagist.org/packages.json into cache
Reading /home/igpde/.cache/composer/repo/https---packages.drupal.org-8/drupal-provider-2020-3.json from cache
Reading /home/igpde/.cache/composer/repo/https---packages.drupal.org-8/drupal-provider-2020-2.json from cache
Reading /home/igpde/.cache/composer/repo/https---packages.drupal.org-8/drupal-provider-2020-1.json from cache
...............................................
Reading /home/igpde/.cache/composer/repo/https---repo.packagist.org/provider-sabberworm$php-css-parser.json from cache
Killed

the preceding output is very long
It waits a lot of time before declaring Killed. looks like a time out!
except for the last reading every Reading ... happens fast


texts: How can I implement AJAX form submission?

texts:
My task is to submit a contact form via AJAX and then to show a "Thank you for submission!" message, loaded in place where the form was. So I need to ajaxify existing contact form.
I found some examples of how to validate form fields using AJAX in D8, but I can't find any example of how to implement an ajax form submission and load some content via AJAX then.
How can I implement my task? How should I alter the contact form to add the required functionality?


texts: How do I add an image field to my node.tpl.php template using render($content['field_example'])?

texts:
I am creating a Bootstrap sub-theme and want to customize my node.tpl.php template. I have an image field with a machine name of 'field_poster'. According to the default node template:

$content: An array of node items. Use render($content) to print them all,
or print a subset such as render($content['field_example']). Use
hide($content['field_example']) to temporarily suppress the printing of a
given element.

So, doesn't this mean I can add print render($content['field_poster']); to my node.tpl.php and it will output the image, right? Well, I've tried that and it does nothing!
How can I get my image field to render in my template?
Update
My field_poster was set to display within a Field Group in Display Settings. This changes how things work in the template. See below for my solution.


texts: How to get into a Drupal 7 site using only Drush without touching code or anything else?

texts:
I'm working on a acquia site and right now the dev environment is replicated from the prod. I want to be able to get in as admin on the dev site, but every time i hit the /user path it redirects me back to the prod site. I tried doing a drush uli admin but that doesnt work neither as I still get redirected back to prod. However, I am logged in as admin on the prod by doing a drush uli admin.

Without touching any of the code/files to get me logged into the dev site and only using Drush. How can one get in logged as admin?

Keep in mind there's no way to get to the /user path on dev as it redirects you once you land on there. And I'm not sure which modules/files is doing this functionality.

I was thinking of copying the cookie session from the prod database and then copy it into the dev database to simulate myself as being logged in, but I'm not sure how to go about that or what else might be needed.


texts: how to load my css and js first on drupal 7

texts:
I'm using Omega theme as base theme and created subtheme. I disabled the "responsive grid" in subtheme.

It works perfectly in screen width 960px as "DEFAULT (960PX) LAYOUT SETTING (Normal)".

When i load the same website in Wide screen more than 1200 px, first it loads "DEFAULT (960PX) LAYOUT SETTING (Normal)" after it override my CSS which i wrote of Wide screen.

How to load my CSS and JS first to make sure the CSS will work for wide screen as well.


texts: Why does node_add_body_field() lock down 'body' field instances to the 'node' entity type?

texts:
For a current project our taxonomy terms need a text field with a summary; naturally as there's already a body field available on nodes, I thought I'd just use that.

Confusingly, 'body' doesn't appear in the list of existing fields when managing fields for the taxonomy term. No problem thought I, I'll just use field_create_instance() and add it manually. Drupal objected:

  Attempt to create an instance of field body on forbidden entity type taxonomy_term.

So I thought I'd get clever. I loaded up the field config, added taxonomy_term to the array of entity_types, and tried to update with field_update_field(). Nope:

  Cannot change an existing field's entity_types property.

It turns out node_add_body_field() does this unconditionally:

$field = array(
  'field_name' => 'body',
  'type' => 'text_with_summary',
  'entity_types' => array('node'),
);
$field = field_create_field($field);

I (perhaps naively, not sure yet) disagreed with Drupal's various assessments, so I went into the database and manually added taxonomy_term to the list of allowed entity types for the body field. Works great, I haven't noticed any ill-effects so far, and the body field is where I expect it to be.

So I guess my question is two-fold:

What reason could there be for the node module locking down this field to a single entity type?
Can I expect to see any bad effects from this further down the line?


texts: Is it possible to have term permission vocabulary id's match taxonomy vocabulary id's when creating a feature

texts:
I am attempting to create a feature to be used in an install profile that exports a vocabulary and the permissions that are associated with the vocabulary. The problem that I am running into is that the vocabulary vid's on my development site do not match the vid's when running an install profile. Features exports the vocabulary and when imported the next available index in the table is used to create the new vocabulary being imported by the feature. Term permissions use the vid, so when you export the permissions with a feature they look something like:

// Exported permission: edit terms in 4.
  $permissions['edit terms in 4'] = array(
    'name' => 'edit terms in 4',
    'roles' => array(),
    'module' => 'taxonomy',
  );

When I run my install profile the vocabulary I exported is imported with vid 1. So when it attempts to add the permissions for vid 4 it throw an integrity constraint error. I could change the features permissions code to align the id's but this does not bode well when I need to release a new feature that uses vocabularies and their permissions on top of an existing site that already has some vocabularies associated with it. I wanted to check here first before submitting an issue with features. Does anyone know a trick on how to get vocabularies and their permissions exported properly with features?

I was originally using features 7.x-1.0-rc2 then attempted to rectify the issue with 7.x-1.0-rc3 as there are a number of threads with similar issues but not quite the same issue as I am having.


texts: Automatically filling field in related content type

texts:
I have two similar content types on a Drupal 8 site: groups and projects. Groups can have child projects, but a project does not necessarily have a parent group. I have an entity-reference field on the Project content type, where a parent group can be added.

However, as I am setting up many different views, I would like these child projects to be added to the Groups nodes when users add parents to the Project nodes. In other words, I want to automatically update the field "Projects" on the related node of the "group" type.

How would I go about doing this? I see most people recommend showing a block on the node, but I would like to use this field in various views, so that won't work.


texts: How to check node table for entry by current date before inserting new node?

texts:
How can I check the database table for specific node entries by date before inserting a new node?

I want to check the node table for any node with the current date, if found, I want to delete the old one and insert a new node.

How can I achieve this.


texts:
What happen when you drush up update a module with Drush because of security issue and the module contain few patches for other features?

The reason why I'm asking is because I have patched few modules and now they have security update which does not contain the features that I wanted.

What is the best practice to update a module that have a security updated and you have patch this module ?


texts: if empty statements in views fields or field templates

texts:
Normally, my situation is easily solved using views rewrite feature. However, in this case I am unable to use views rewrite because I have data attribute tags in the field wrappers that are stripped out by views. So I need to handle this at the template level. I have no problem with the field data itself, but with the field wrappers. I need to use php if statements in either views-view-field.tpl.php or views-view-field.tpl.php to enclose the wrapper html too along with the field. But i can't figure out the php syntax to use to accomplish this. I need to be able to show the field data plus wrappers if the field has content, but show some empty field without the wrappers if there is no data.

so far i have tried things like views-view-field.tpl.php

<?php if ($output): ?>

<?php print $output; ?>

  <?php elseif ($empty($output)): ?>

      <?php print $empty; ?>

  <?php endif; ?>

How can i revise my if statements to it works in either fields or field.tpl.php?


texts: Locking access to /user redirect if logged out

texts:
We have a Drupal 7 site that uses a bespoke login module for ordinary users. Certain (administrative) user rôles, however, must use the core login form at /user to log in, as they have escalated privileges. Regular users get a login form at / (redirected from any URL when not logged in) and cannot log in at /user; administrative users cannot log in at /, but must use the form at /user — these two forms ask different login questions.

We would like to be able to restrict the /user login form to a whitelist of IP addresses, so that only users coming from known IPs can use this form to log in. This would seem simple, at a first glance, as we could use Apache to reject requests for ^/user$ coming from non-whitelisted IPs, except that Drupal also uses /user as a redirect to the currently-logged-in users's profile page and this link appears in a handful of locations in our site.

Now I don't want to go hacking through Core, but I can't see how I can enforce the whitelist for anonymous users, whilst allowing any authenticated user to access their own profile page on the URL /user.

Should I go through everywhere that we link to /user (including the menu block) to substitute in the user's profile ID, or is there some more-elegant solution that I'm just not seeing?

All suggestions gratefully received  :o)


texts: How can one add inline JavaScript in the validation function for the Form API?

texts:
I found that there is a way to add javascript files in the form validation function as stated in "drupal_add_js not work in form validation failed".

However, I would like to know how to add javascript using the drupal_add_js function with the inline option. I would just like to execute some javascript code while I am in the validation function of the Drupal Form API.


texts: Does it make sense to set a constant like THEME_IMAGE_DIR?

texts:
Doesn't it make sense to assemble the theme's image path once, in a constant (eg THEME_IMAGE_DIR) and use this throughout the theme? This seems like too obvious, maybe I'm missing something...

Where would the ideal place for this initialization be? Module, theme, dark side of the moon? Inspired by Clive's answer

Declaration:

global $base_path;
$theme_path = drupal_get_path('theme', 'my_theme_name');
define('THEME_IMAGE_DIR', $base_path . $theme_path . '/images');

Usage:

$content['something'] = '<img src="' . THEME_IMAGE_DIR . '/inner-book.gif" />';


texts: Override or extend function of a contributed module

texts:
i need to modify the submit function of the module custom_search (8.x-1.0-beta3).

I need to set a Cookie every time the guest user search something, how can i override or extend the submit function?

It looks like not represent a hook. The function is: custom_search_search_page_submit located in the file custom_search.module and called by the custom_search_form_alter function that implements hook_form_alter()

/**
 * Search pages settings form callback.
 */
function custom_search_search_page_submit($form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $pageId = $form_state->getValue('id');
  // Save settings, and path as well so we can use it to retrieve the correct settings later.
  \Drupal::configFactory()->getEditable('custom_search.settings.results')->set($pageId . '.path', $form_state->getValue('path'))
    ->set($pageId . '.search', $form_state->getValue('custom_search_search'))
    ->set($pageId . '.advanced.visibility', $form_state->getValue('custom_search_advanced_search'))
    ->set($pageId . '.advanced.collapsible', $form_state->getValue('custom_search_collapsible'))
    ->set($pageId . '.advanced.collapsed', $form_state->getValue('custom_search_collapsed'))
    ->set($pageId . '.advanced.criteria', $form_state->getValue('custom_search_criteria'))
    ->set($pageId . '.advanced.types', $form_state->getValue('custom_search_types'))
    ->set($pageId . '.advanced.languages', $form_state->getValue('custom_search_languages'))
    ->set($pageId . '.info', $form_state->getValue('custom_search_info'))
    ->set($pageId . '.filter.position', $form_state->getValue('custom_search_filter_position'))
    ->set($pageId . '.filter.label', $form_state->getValue('custom_search_filter_label'))
    ->set($pageId . '.filter.any', $form_state->getValue('custom_search_filter_any'))
    ->save();
}


texts: Need help getting sum of fields on Commerce Line Items

texts:
I have a field called line item weight on every line item.
i want to sum up the line item weight fields to get a result we are calling total order weight

I'm thinking I should use rules to do this, but I am not sure how to go about looping through the line items to get the sum of the order.

If it helps, I already have one rule in place that upon adding a product to the cart,
takes the product weight, multiplies by the quantity and fills the value into the line item weight field.


texts: How can I disable all outgoing emails from a site all at once?

texts:
There are some automated outgoing emails from my Drupal site like by core system mail, ubercart, webform and Rules.

The reason is that I also have a test site which is exactly the copy of the production site. And I would like to disable all the outgoing emails so that no mails will be sent from the testing one by mistake.

I have installed "phpmailer" "mime mail" "mail editor" modules.

Is there an out-of-box way to do this?


texts: How can I force Composer to install a dev branch over a stable release?

texts:
I am experimenting with Bootstrap 3 in Drupal 8 and I want to stay on the dev branch of bootstrap.

In my composer.json, I wrote the following line based on Drupal Packagist:

"drupal/bootstrap": "8.3.*@dev",

However, when I run composer update, it downloads 8.3.0-beta2 (2015-Dec-19) instead of the latest dev release (2016-Feb-20).

Gathering patches for root package.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing drupal/bootstrap (8.3.0-beta2)
    Downloading: 100%
    Downloading: 100%

To make sure it wasn't some caching issue, I ran:

composer selfupdate
composer clear-cache
composer update

But it did the same thing-- install beta2.

How do I force it to download the dev release instead?


texts: Using EntityFieldQuery to order nodes in an OG Group using node_comment_statistics table

texts:
I have an EntityFieldQuery to fetch nodes of a certain type which belong to an OG group in a Drupal Commons instance.

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', array('post', 'document', 'link'), 'IN')
    ->propertyCondition('status', 1)
    ->fieldCondition('og_group_ref', 'target_id', $panel_args[0], '=');

I was wondering if it was possible to also add the condition to order the nodes by most recent comment using the information from the node_comments_statistics table and the last_comment_timestamp.

Is this possible with EFQ since their are no joins? Or will I have to fall back to a basic Drupal Query?


texts: How to add content in custom menu block?

texts: I have own menu type "Footer menu". When I add new content, "Footer menu" is not display in Menu setings. Where is the problem?


texts: Where is the best place for cache bins (Drupal 7)?

texts:
At Drupal 7, I have read about various solutions for storing the cache bins and avoiding having them at the standard drupal database.
The methods are:
- Memcache
- Mongodb
- APC
- Filecache module?
any other method that you know?

What are the advantages/disadvantages of each method and the corresponding performance gains?


texts:
I have a map setup with Openlayers and mapbox. I need to set the default zoom level to be in-between 1 and 2. So something like 1.5, as 2 is too zoomed in and 1 is too zoomed out.

I have entered different values under 'zoom level' within 'center & bounds', but only whole numbers seems to have an effect on the map.

Does anyone know of a way to set a default zoom level that is not a whole number? So something like 1.5 ?

I am using Drupal 7.

Thanks you help is much appreciated.


texts: Simple&efficient slider module for the following purpose

texts:
I'm looking for a recommendation of a rather simple, conventional, D7 carousel\rotator\slider module that will let just to replace images (without many advanced techniques).

What I do need this module to have, and doesn't very much compromise about, is these features:

Pointers (Left and right) to move between pics.
Small dots that reflect the current picture being shown.
Text that "comes" into the center of the picture from different
directions, and that Ican have full management of it's appearance
(Font-Family, size, color, etc).

Thank you very much for your help!


texts: How do I load a form with a specific form display (form mode)?

texts:
On a custom page I'm trying to load an user edit form with a specific form display.
I'm able to load the form however I can't figure out how to load the form with the specific display.

This is what I have now:

public function content($substep) {

    $user = \Drupal::entityTypeManager()
      ->getStorage('user')
      ->load(1); // loading user 1 for test purpose

    $form_state = new FormState();

    $form = \Drupal::entityTypeManager()
      ->getFormObject('user', 'default')
      ->setEntity($user);

    return \Drupal::formBuilder()->getForm($form);
}

Anyone has an idea?


texts: The user-profile.tpl.php file won´t be recognized in my Drupal 7 installation

texts:
I´ve created a file user-profile.tpl.php in a Drupal 7 installation. I´ve updated the site from Drupal 6.
I have old core profile fields and I´ve installed the new profile2 module.

I´ve inserted that user-profile file into my theme folder and flushed cache.
I want the profile to show all the core profile fields and the new profile 2 fields.

The thing is that it won´t show any field at all. It just shows the user picture.

After a lot of trying and error, I´ve tried deleting all the content inside user-profile.tpl.php file, and adding into it just "hello world". It won´t be printed out. And the profile picture is still there.

So, how do I get the file to be recognized? Should I set something at my template.tpl.php file?

Thanks for your help!!

Rosamunda


texts: Core files updated, but getting "No Pending Updates" message

texts:
This is my first time developing for Drupal, and it came time to update the site. I followed all the instructions in the update.txt file by doing the following:

backed up files and databases
put site in maintenance mode
deleted old files and installed new ones
ran update.php

The problem I'm running into is that update.php is telling me that there are "No Pending Updates". However, when I take my site out of maintenance mode and flush my cache, I'm still getting messages that I need to install security updates. Is this just a problem with my alerts system, or is there something I'm missing in the update?

Thanks, in advance, for helping a Drupal Noob.


texts:
I crated a view to show a list of registered users such as as name, email, job etc. one of the fields I am also listing is a private link so other members of the site would be able to contact that user.
Authenticated users can see the link and send a private message, but what I would like to to is to allow anonymous users to see the private message link but when they click on it they should be redirect to the login form. Is there a way to do that? I´ve been googling around and can´t find an answer.

I would really appreciate if you can help me to find a way to to this.

Thanks in advance


texts:
How can I add through the form API an image upload field with the cropping functionality implemented by this module?

http://drupal.org/project/imagefield_crop/

I'm using Drupal 7. I need to implement an image upload field with cropping functionality. If there's another module that does the same job as Image Crop and plays more nicely with the form API, that's fine.


texts:
I've got a Views Page showing Article teasers. There are lots of Articles in the db and I'm only showing 5 per page in the View, but the Pager is not showing up at all. Here is my Views configuration, am I doing something wrong? Is there a bug?

The preview in the Views screen does not show a Pager at the bottom of the content teaser and it also doesn't show on the real page.

Any ideas?


texts:
I'm trying to create a field widget that is similar to the normal term reference widget with one key difference. The user needs to be able to add multiple new taxonomy terms at the same time, this may demonstrate it better:

I've got to a point where the functionality is similar to what the taxonomy/options/list modules provide (i.e. the checkboxes/radios are shown, saving etc.)

Here's important bit of the code I'm using in hook_field_widget_form():

 $element += array(
    '#type' => $multiple ? 'checkboxes' : 'radios',
    '#default_value' => $multiple ? $default_value : reset($default_value),
    '#options' => $options,
    '#value_key' => $value_key,
    '#element_validate' => array('options_field_widget_validate'),
    '#properties' => $properties,
  );

What's throwing me here is that $element isn't your usual form array so I'm not sure how to add the textfield and and button - especially as their values aren't meant to be saved. What's the best way to add these fields to my widget?

As for adding the Javascript needed, am I right in thinking I should use #ajax that calls a function that rebuilds the #options for the checkboxes?

Thanks in advance!

EDIT -
My initial question was quite vague, here's some more details on what I've tried:

  $element += array(
    '#type' => 'fieldset',
    '#delta' => $delta,
  );

  $element['value'] = array(
    '#type' => $multiple ? 'checkboxes' : 'radios',
    '#default_value' => $multiple ? $default_value : reset($default_value),
    '#options' => $options,
    '#value_key' => $value_key,
    '#element_validate' => array('options_field_widget_validate'),
    '#properties' => $properties,
  );

  $element['text'] = array(
    '#type' => 'textfield',
    '#title' => t('Add another'),
    '#weight' => 5,
  );

This a is an amalgamation of various examples I've seen, and seems to get me closer. The problem is when I submit the entity form I get the following error:

  Notice: Undefined index: tid in taxonomy_field_is_empty() (line 1402 of modules\taxonomy\taxonomy.module).

I've taken a closer look at this function and it's expecting $item to have the structure $item = array('tid', 2). When using the above code there seems to be a delta coming from somewhere and the structure of $item ends up being $item = array(0, array('tid', 2). I can't work out where '0' is coming from?

ANOTHER EDIT

I've been able to fix the above error with the following code by altering $element like so:

$element += array(
    '#type' => 'fieldset',
    '#process' => array('taxonomy_free_entry_ignore_parent'),
);

and adding the function:

function taxonomy_free_entry_ignore_parent(&$form, &$form_state, $complete) {
  array_pop($form['#parents']);
  return $form;
}

When I save the entity I'm getting a message telling me it's been saved. When I check the table for the field, it isn't being saved. What am I doing wrong?


texts: How can I include a .inc file before hook_node_access runs?

texts:
I'm currently including a .inc file in hook_init(), but now need to call a function from that include inside of hook_node_access(). I've just discovered that, because hook_node_access() runs very early on, my file is not included. I then tried to do it inside of hook_boot() because the documentation suggests that it runs sooner, but it's still not available to me. I'm temporarily including the file in my .module outside of any function via a simple

require_once DRUPAL_ROOT . '/sites/all/modules/...

but would prefer not to do it this way.


texts: How do I filter a view with a field on a group the current user is in?

texts:
The site I'm working on will have many OG groups, each with a list of topics relevant to their members. I would like to show content to the logged in user that is about their group's relevant topics.

I started by creating a vocabulary (Topic) and two content types (Group and Post). Group and Post both have a term reference field that lists Topic terms (groups have topics that are relevant to the group, and posts have topics about which they're written).

How can I create a view that shows only posts with at least one Topic term in common with the logged in user's group's Topic list?


texts:
I am using Colorbox module through views to display some catalog nodes using colorbox. When someone clicks on a catalog link it opens in colorbox.

Now my client wants to display the link to the latest catalog in a splash screen whenever someone visits the website.

I have used Splashify module to display splash screen and entered the new catalog image with link to the relevant catalog node.

Problem is that the width of the colorbox is not changing accordingly. Means when someone clicks on the catalog image in a splash screen which is perfectly loaded in a colorbox, the colorbox loads the catalog node but the size of colorbox remains the same.

The link which I am using within colorbox is http://patelbrothers.com.pk/catalog/moonlight?width=1000&height=500&iframe=true


texts: Can I use Apache 2.2.15 with mod_rewrite enabled?

texts:
I currently am running Centos 6 which only comes with Apache 2.2.15.  Yeah, I know it is about time for me to upgrade...  I get the following warning:

  The minimum version of Apache needed to run Drupal without mod_rewrite
  enabled is 2.2.16. See the enabling clean URLs page for more
  information on mod_rewrite.

I have mod_rewrite enabled. Am I okay as is? I don't care about pretty URLs at the moment as I am just learning about Drupal, and will upgrade my OS someday soon.


texts: Main menu links not operational on front page when anonymous

texts:
I have two links to 'published content' in main menu. This menu is displayed on all pages, including front page.

When I am logged in as admin, those links work well, but when I am logged out (=anonymous), those links are displayed, but not operational. It is as if they were plain text only.

Yet, when I access content directly with the proper URL as anonymous, those links do work properly in the corresponding page.

So, why don't they work on the front page when using anonymous mode? I have checked page source and the code is the same. I have checked permission and View published content is allowed for anonymous users.

Want could be the cause of this issue?

Update

For the records, I have also asked a question here. I tried to solve this issue with a Drupal Navigation Menu, but only the Home link works, not the other link.

To solve this issue, I have created my own menu manually. It works, but...

Update II

I am using a simple plain vanilla system with panels everywhere. The theme is Versatile. I have header, footer, left, right mini-panels + central content in a default page variant. The right mini-panel just displays an instance of Main Menu. In fact, I have not created users. The site is meant to be used by anonymous people.

Update III

The issue only happens when the following CSS is applied:

.NCK_Menu {

    font-size: 103%;
    height: 240px;
    width: 120px;
    background-color: #5E88D0;
    margin: 10px 9px 10px 7px;
    padding: 7px;
    border:none;
    -webkit-border-radius: 1px;
    -moz-border-radius: 1px;
    border-radius: 1px;

}

It does not make sense !!!


texts:
I am after a "reminder" module, which will enable the site users to subscribe to nodes/content types in order to receive reminders of closing dates and notifications of when the node has been updated/changed.

Any help would be greatly appreciated.


texts:
One of the site has fairly large cachetags table at over 418K records. Is there a way to limit the size of this table.
This table is not cleared on cache clear.
Since Drupal 8.4 there has been a way to limit the size of cache tables, as noted in change record. However, these settings do not affect the size of cachetags table. I tried adding the following to the settings.php file, but these don't work.
$settings['database_cache_max_rows']['cachetags'] = 50000;
$settings['database_cache_max_rows']['bins']['cachetags'] = 50000;

Is it safe to limit or purge the cachetags table?
Is there a way to limit the size  of cachetags table without resorting to manually truncating the table?


texts: Import Drupal Database, Excluding Database Connection Parameters

texts:
Another developer and I have the same Drupal theme installed.  The other developer is the one doing the development work and I'm simply trying to import his updates into my theme so I have the latest and greatest and can see how the work is progressing.  I am able to IMPORT his EXPORTED database, however, his MySQL database connection parameters are different in that he's not using a password, and my MySQL database connection parameter INCLUDES a password.

The way I am importing his export, is simply by using PhpMyAdmin, I first DROP all the website's Tables, and then simply IMPORT his EXPORT.

QUESTION IS: Which tables should I NOT Drop, and when he does his EXPORT, which Tables should he NOT Export... so I receive everything I need to get all the updates into my database, but don't have a problem with database connectivity?


texts:
I want to combine two fields (say first name and last name) of a particular type of node so that the name displays correctly and I still have the individual fields to work with in different areas.

I saw this post What is best way to combine multiple fields in template preprocess?  that explains how to combine two fields, but one I declare this new combined variable, how to I get it to display as the node?

Do I need to edit my node.tpl file?  Should I have a node.tpl for this particular content type?


texts: "languages" is not found in regional settings

texts:
I installed drupal commons 7.3.4,

I want to ADD an additional language. I try to follow this manual:

https://docs.acquia.com/articles/adding-another-language-your-drupal-7-site#language

go to Configuration > Regional and language > Languages

But there's no "Languages" section under "Regional settings"

I tried to enter the URL manually, but it brings me to "regional settings".

I enabled

Locale
content translation
Entity Translation
Variable admin
Internationalization
...

i also flipped-flopped in the air, and prayed to budhha.

but there's no "Languages" in Regional settings.

What am I missing?


texts: Commerce - added options/attributes for some products within a product type

texts:
I am developing a restaurant / takeaway site with e-commerce functionality.

I have figured out how to do such things as adding extras to a product such as extra cheese or extra pepperoni. My only issue is that I have some dishes/products within a product type that offer an option of salad or chips, or salad, rice or chips.

I have tried using the Commerce Product add-on module which attaches a product type onto another product type but the issue with this is that it only allows for checkboxes or a list where more than one option can be selected OR none at all.

I need that the customer must pick an option.

Can anyone with good commerce knowledge help me out here or point me in the right direction at the least as I am stuck for options.

Thanks.


texts:
(Spin-off of Remove/Hide the block if the View is empty?. I find the other question a bit confusing, and want to reduce it to the essential question.)

When rendering a view programmatically, and there are no results, there is still some HTML returned from $view->render().

This can be desirable in the following cases:

There is a "No results behavior".
There are exposed filters, which need to be shown independent of the view result.
The view is using AJAX, so it could happen that new content appears dynamically.
Perhaps other reasons?

I want to write generic code that renders a view, but completely hides it if there are no results, and no other reason to show it.

So far I have this:

$view = \views_get_view($view_name);
if (NULL === $view) {
  return [];
}
$success = $view->set_display($display_id);
if (FALSE === $success) {
  return [];
}
$view->set_arguments($args);
// See https://www.drupal.org/node/525592#comment-1833824
$view->override_path = $_GET['q'];

$view->pre_execute();
$view->execute();

if (empty($view->result) && empty($view->empty)) {
  // @todo Also check for exposed filters!
  return [];
}

$markup = $view->render();

$view->post_execute();

if (FALSE === $markup) {
  return [];
}
return ['#markup' => $markup];

So the question is: Which other checks should I add when looking if the view is empty? (the place with the @todo).

How do I check if there are exposed filters?
Which other criteria are relevant?


texts:
I use URL Alias an have set to construct the URL based on 2 tokens:

[node:token1]-[node:token2].html

Those two tokens are connected with a hyphen "-".

Sometimes the second token (token2) is not present (empty) and in this case I want to show only token1, without hyphen, but it creates even then:

http://token1-.html

How can i configure it to show only:

http://token1.html

Thanks!


texts: Contact Us works on local machine, but not on bluehost.com

texts:
How can I track down why an email is not generated from my new web site when I click Contact on the Contact page?

I turned on maillog and devel. What I get is
    maillog =>
        ... (Array, 6 elements)
 ... (Array, 6 elements)

Subject (String, 23 characters ) [Website feedback] test
From (String, 22 characters ) sam.stamport@gmail.com
To (String, 22 characters ) sam.stamport@gmail.com
Reply-To (NULL)
Header (Array, 7 elements)
Body (String, 128 characters ) admin (http://columbiablooms.org/users/admin) s...
    Krumo version 0.2.1a | http://krumo.sourceforge.net
    [Click to expand. Double-click to show path.] Called from
    /home5/columck5/public_html/sites/all/modules/maillog/includes/maillog.mail.inc
    , line
    90

Your message has been sent.

Error message:

  Unable to send e-mail. Contact the site administrator if the problem persists.


texts: How to upload enterprise blog picture programatically in drupal 7

texts:
I used "enterprise blog" module for user blog postings. From external php file, I have to upload user picture programatically (i.e., for App). I have configured bootstrap perfectly and user_load($uid) is working, means drupal functions are working properly, but when I am trying to upload picture programaically "file_save($file)" is not working. Please check the below code and give me any suggestions to upload enterprise blog picture.

 $tmp_photo_realpath = "images/".$userimgname;
      $tmp_photo = "images/".$userimgname;
      $file = new stdClass();
      $file->uid      = $uid;
      $file->status   = 0; // mark the file as temporary
      $file->filename = basename($tmp_photo_realpath);
      $file->uri      = $tmp_photo;
     // $file->filemime = image_type_to_mime_type(exif_imagetype($tmp_photo_realpath));
      $file->filesize = filesize($tmp_photo_realpath);
     $infofile = explode("/",$tmp_photo);
    $infoext = explode(".",end($infofile));
    $imgext = end($infoext);

  // The file should be an image
  $errors = array();
  $errors += file_validate_is_image($file);
  $errors += file_validate_image_resolution($file, variable_get('user_picture_dimensions', '100x100'));
  $errors += file_validate_size($file, variable_get('user_picture_file_size', '30') * 1024);

  // Make sure file extension is a valid image
  if (!in_array(strtolower($imgext), array('jpg', 'png', 'gif'))) {
    $errors[] = ' invalid image file extension.';
  }

  if (count($errors)) {
    drupal_set_message(t('Profile Image Import:') . ' ' . $errors[0], 'warning');
    // Clean up (set fid to avoid error messages)
    $file->fid = 0; file_delete($file);
  }
  else {
    // We'll need a valid file id on the file object; file_save() will give us one
    $file = file_save($file);
    // Update user account (fid is not empty, status is temporary -- image
    // will be moved to proper directory and assigned to the user)
    $fields['field_enterprise_blog_picture'] = $file;
    $account = user_save($account, $fields);
}


texts: I am creating a new Drupal website.  I want to create a menu tab that links to the My Blog section.  What URL link do I use for this?


texts: Path Breadcrumbs shows edit link in front end

texts:
I have an issue with my Drupal site where the link to edit the path to breadcrumbs is showing in the front end even when people are not logged in.
It looks like this:
Edit path breadcrumbs

Home>>page

The Edit path breadcrumbs links leads to: /admin/structure/path-breadcrumbs/edit/******/main?destination=*****
My site is on Drupal 7.78
Path Breadcrumbs 7.x-3.4
Path Breadcrumbs UI 7.x-3.4
Any idea why this could be?
Thanks,


texts: A custom route to an entity form will not pass the entity

texts:
I want a custom route to the normal user form. So, I've added an entry to the routing file that directs my custom route to the canonical form of the User entities:

my_profile_form:
  path: '/user/{user}/my-profile-form'
  defaults:
    _form: '\Drupal\user\ProfileForm'
    _title: 'My profile form'
  requirements:
    _role: 'administrator'

When I try to open /user/1/my-profile-form with my browser, I see the following error message:

  Error: Call to a member function getEntityTypeId() on null in Drupal\Core\Entity\EntityForm->getBaseFormId() (line 106 of ...web/core/lib/Drupal/Core/Entity/EntityForm.php)

It seems that with my custom route the form does not know who the user is.

What magic must happen to inform the form about the user?


texts: PDOException: SQLSTATE[42S02] when changing password using Drupal Commons 7

texts:
I'm new in using Drupal Commons 7. I've been trying to register a user in the membership site that I'm making but this comes out whenever the user tries to change his password:

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table '[name].oauth_common_consumer' doesn't exist: SELECT c.csid AS csid, c.consumer_key AS consumer_key, c.secret AS secret, c.configuration AS configuration, pc.created AS created, pc.changed AS changed, pc.uid AS uid, pc.name AS name, pc.context AS context, pc.callback_url AS callback_url FROM {oauth_common_consumer} c LEFT OUTER JOIN {oauth_common_provider_consumer} pc ON pc.csid = c.csid WHERE (c.csid = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => ) in DrupalOAuthConsumer::loadById() (line 173 of /home4/[name]/public_html/profiles/commons/modules/contrib/oauth/includes/DrupalOAuthConsumer.inc).

How can this be fixed?


texts: Changing language on taxonomy term invalidates terms path

texts:
I have a multilingual site in Swedish and English language. Some terms had language unspecified. I changed the language to English for English terms and Swedish for Swedish terms.
Now when I try to access the terms using taxonomy/term/33 or any other number, it gives 404 Not found error.

Does pathauto module has anything to do with it?

How can I fix this? Thank you for your help.


texts:
When I run drush without sudo I get the header plus: drush is designed to run via the command line. Drush with sudo works as intended.

I have read that: You do not need root-level permissions to use Drush: it'll work as long as the user invoking it has direct access to the Drupal installation directory.

This does not seem to be true in this case. Even when I su to the exact user that owns the Drupal installation, I still cannot run Drush without the error message.

drwxr-xr-x 10 ouruser www-data     4096 May 18  2012 html

Is there something incorrect about permissions or is there another problem going on?


texts:
How to create custom node background color from role id
e.g. admin - red
manager -green
auth user - blue, automatically?

Find examples (template.php)

function themename_preprocess_node($variables) {
  $account = user_load($variables['user']->uid);
  //$account = user_load(array('uid' => $node->uid));
  $user_roles = $account->roles;
  if (in_array('administrator', $user_roles)) {
    $my_class = 'user-admin';
  }
  elseif (in_array('authenticated user', $user_roles)) {
    $my_class = 'user-author';
  }
  elseif (in_array('test user remove', $user_roles)) {
    $my_class = 'user-power-author';
  }
  elseif (in_array('VIP', $user_roles)) {
    $my_class = 'vip-author';
  }
  if (isset($my_class)) {
    $variables['attributes_array']['class'][] = $my_class;
  }
}

This doesn't work


texts: How to debug TransactionOutOfOrderException: in DatabaseConnection->rollback() in database.inc?

texts:
I'm just trying to create an order in code like this:

$selected_month = $form_state['values']['month'];
$selected_year = $form_state['values']['year'];
$order = commerce_order_new($form_state['values']['user'], 'checkout_checkout');
commerce_order_save($order);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$product = commerce_product_load($form_state['values']['product']);
$line_item = commerce_product_line_item_new($product, 1, $order->order_id);
commerce_line_item_save($line_item);
$order_wrapper->commerce_line_items[] = $line_item;
dpm($order_wrapper->value());
$order_wrapper->save();

This in inside an form submit callback, so I have all the data needed like productId, userId, etc., but suddenly it stopped working. Apache says nothing and can't see MySQL logs but i contacted my provider and says that there is no logs either.

I'm using commerce_addressbook, but not using commerce_coupon or commerce_discount. Not altering the order_id in rules.

Looks like some kind of order_id problems but not sure, it looks like the second order_save (with wrapper function or commerce_order_save) tries to save the order but with the same order_id.

In the database the order is created with its line item

I've tried to clear all the caches, same result.

A thing which i find strange to me, is its revision id, in the database even tought order_id is 160, for example, its revision id is 552.

Another strange behaviour i found is that the commerce_order_total is not set at all, the row in the table is created but with 0 amount.

Same result for both saving functions, tried both but it is always in the second call of the order save, I comment that line and it works.

Commenting that line works, but of course no line items, but the rows are created for both entities, commerce_order and commerce_line_item. I mean, i see them in the data base but in the edit page of that created order, there is no line items

Here is the content of $order_wrapper->value():


texts: Clearing cached CSS when updating live web page

texts:
I'm responsible for my company's webpage, and I'm having caching issues when updating it with the new CSS files. The CSS files are collected and minified as they should be, but when I update them, they should be cleared, so the page looks like it should.

How do I clear the cached CSS files in Drupal 7?


texts: Ajax problem on node edit page trigger whole submit

texts:
I'm facing a very strange problem on one website.

First of all with the module media (I'm using the last version of the module). When click on "Remove" an image, an ajax request is triggered and seems to go through the entire form submit, displays a message above the field but doesn't remove the image.

If I click on "Remove" again then it works normally.

Now when I click on a "Add more" button like for a multiple field_collection, it works fine the first time for the field I click. If I click on an other multiple field (an other field_collection) then nothing happens. I don't know if both problems are related.

When I look into the network, I see Ajax queries with all the datas (some differences like the form token), the response is just not the same.

I'm on jQuery 1.4.4 on admin pages and using the Shiny theme. Drupal is 7.41 and hosted on NGINX 1.6.2-5

I've looked into all the "form_alter" I had, to see if something got altered. I even deactivated all my custom modules, but the problem is still there.

Any clue would help :-)


texts: drupal 7 plugin for creating multilingual subtitle for jwplayer videos

texts:
I am using Drupal 7, and using JWPLAYER for my video. Is there any plugin in Drupal 7 which allows me to create subtitle in multiple language.

I am trying to avoid third party tools (like dotsub etc) where I need to upload my videos to their end in order to make subtitle. Is there any plugin which will help me to create multi language captions for my videos in Drupal 7.


texts:
I want to use the title of the block as a hyperlink (or maybe adding an image) and I do not know how can I do this.

I've been looking to block.tpl.php. I know I can modify the template the way I want.

Maybe the way to do it is defining custom variables, such as $block->mycustom.

If the variable is defined there is a link, if not, nothing. The problem with this approach is that I don't know where this variable should be defined.

Is that correct, or am I totally mistaken?

I am interested in an answer for Drupal 7.


texts: I am using the drupal2drupal UI for a D7 to D7 migration. Is there anyway I can export the setting for the migration including the connection string and the field mappings so that we can repeat the exact migration on another server without having to repeat the UI setup?


texts: Using EntityFieldQuery with Address Field

texts:
I have a custom content type with a postal_address field provided by the module addressfield. postal_address fields are one field in the custom content type. This one field is comprised of many subfields like: country, name_line, and postal_code.

How can the core function EntityFieldQuery be used to retrieve nodes of my custom content type based on their postal code value (a subfield of the postal_address field)?

Specifically, I do not know what to put in the code below instead of the text: what_goes_here:

$query  =  new EntityFieldQuery();

$entities  =  $query->entityCondition( 'entity_type', 'node' )
  ->propertyCondition( 'status', 1)
  ->propertyCondition( 'type', 'consumer_store' )
  ->fieldCondition( 'what_goes_here', 'value', $postal_codes )
  ->execute();


texts: Can anyone help me translate this Javascript code line the Drupal Way?

texts:
I need to convert this code line (it focuses the cursor to the first input of a form) to Drupal behaviourism. Can anyone help me put it the Drupal bushido way?

jQuery("input:text:visible:first").focus();


texts: How do I add fields to the sidebar menu when creating/editing nodes?

texts:
I would like to add to the sidebar menu on the create/edit node pages. How would I do this?

I would like to do this in order to make the content creating/editing a little cleaner and easier to understand for content editors.

See attached pic...

Thank you.


texts: Find and display most recent referencing entities

texts:
I have 2 different node types. The first one describes a factory and the second one describes a measurement of the water inside the factory. The measurement content type has an Entity Reference field that points to the factory that the measurement is associated with.

What I want to do is print a list of all the factories in a table format and a specific column that will contain a field from the latest measurement that references to the specific factory.

For example:

Factory 1

field 1
field 2
field 3

Factory 2

field 1
field 2
field 3

Measurement 1

Refers to Factory 1
Integer Field
Date Created: 21/5/2013

Measurement 2

Refers to Factory 1
Integer Field
Date Created: 22/5/2013

Measurement 3

Refers to Factory 2
Integer Field
Date Created: 10/2/2012

Measurement 4

Refers to Factory 1
Integer Field
Date Created: 23/5/2013

What I want to print:
    Factory 1 || field 1 || field 2 || field 3 || Integer Field (from Measurement 4)
    Factory 2 || field 1 || field 2 || field 3 || Integer Field (from Measurement 3)

Notice that I'm only printing the Integer field from Measurement 4 since it is the latest measurement for the specific factory. I started writing some custom code and looked into EntityFieldQuery but I can't understand how to use it in conjunction with Entity Reference.


texts:
I am using Session Limit module for restrict user to login into site from multiple browsers at a time.But here i am facing a problem is if user close the browser with out logout,then the session will not closed and the user is not able to login from same browser also.

To avoid this problem I set

ini_set('session.gc_maxlifetime', 0);
ini_set('session.cookie_lifetime', 0);

But it does not work for me. If I close my browser even though the user session has not  closed.


texts: Module to create a custom field in all the content types

texts:
I am building a module to insert a custom field in all bundles of the node. I have encountered many difficulties, any help they can give me, I would appreciate it very much.

The custom field I am creating is used to save a tocken automatically or manually. - field_custom_tocken -

If a new bundle is created, the field_custom_tocken field must be added automatically to the new bundle. To generate the token it is necessary the id of the entity (nid), or that the tockent is inserted by the user.

I have used Drupal Console, create the field type, the widget and the formatter. This does not generate the field, the drawback is that you have to manually add the field to the bundle.
drupal generate: plugin: field

In this documentation the field is created and added to a specific bundle, I use part of this documentation. field.storage.node.field_brand_information.yml

I have this:

this creates the field.
modules/custom/custom_tocken/config/install/field.storage.node.field_custom_tocken.yml

# field.storage.node.field_custom_tocken.yml
langcode: en
status: true
dependencies:
  enforced:
    module:
    - custom_tocken
  module:
    - node
    - text
id: node.field_custom_tocken
field_name: field_custom_tocken
entity_type: node
type: string
settings: {  }
module: core
locked: true
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

This should create the custom field in the existing bundles, when the module is installed, but it does not work :(

/**
 * Implements hook_install().
 */
function ide_d8_url_shortener_install() {
  $entity_type         = 'node';
  $bundle              = '';
  $field['field_name'] = 'field_custom_tocken';
  $field['label']      = 'Tocken';
  $field['entity_type']= 'node';
  $field['type']       = 'string';
  $field['settings']   = array();

  $bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type);
  $arr_bundles = [];

  foreach($bundles as $key => $value) {
    $bundle = $key;
    $fields       = \Drupal::entityManager()->getFieldDefinitions($entity_type, $bundle);

    if ( !isset($fields['field_short_url']) ) {
      entity_get_form_display($entity_type, $bundle, 'default')
        ->setComponent($field['field_name'], $field )
        ->save();

      entity_get_display($entity_type, $bundle, 'default')
        ->setComponent($field['field_name'], $field)
        ->save();
    }
  }
}

Any help you can give me I would appreciate it.


texts:
New to Drupal but am interested in it as an option to transition to from a hand coded site. This site is primarily a location searchable venue index, with venues having various categories.

In Drupal I have set up my content type 'Venue' and have added the location module to store the venue addresses and other contact details.

Now I am wanting to import my existing data which I have ready in a CSV.

To do this I understand I should use the feeds module which I have now installed (along with ctools and job_scheduler).

Now under Structure-> Feeds importers -> Add importer I can create and configure my CSV import - Great!

Unfortunately I can't see any option under Processor to associate my CSV address fields with the location module fields. What am I missing here?


texts: Modify data structure of a view REST export

texts:
I need to build a sitemap.xml with a REST export with a view.
By default I get this data structure with a REST export.

<?xml version="1.0"?>
  <response>
    <item key="0">
      <field1>...

How can I modify the tags of this structure? I need to get this tags.

<?xml version="1.0" encoding="UTF-8"?>
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
      <loc>...

These tags must be changed.

<response> > <urlset...
<item> > <url>

Do I write a custom serializer for the REST export or a specific encoder? How do I proceed?


texts: How to create a payment form / pane directly from order_id

texts:
Study case : customers already have the ability to pay only a deposit. So they 'll have to come back and pay the order balance later.

How can I create a payment form ?

where they will be able to directly submit a payment form and proceed to off-site payment to pay order balance
without coming from cart/checkout process, (as it has already be done in deposit payment another day)

This will be linked from the user/%/orders/% page.

Is there any commerce API function that could fit that issue ?
I had a look at commerce_payment_order_transaction_add_form($form, &$form_state, $order but I could not find any doc to implement it, .

Thank you

PS : related issue: Commerce partial payment


texts: How to fetch the status of profile flag?

texts:
I have a profile flag called "keep my photos private" using which user can flag his content and can keep it private. I want to fetch the status of the flag by the specific user. I have tried php code but its not working.

global $user;
$user_uid=arg(1);
$flag=flag_get_flag('keep_photos_private');
print "Flag Name : ".$flag->title;
print "User : ".$user_uid;
if($flag->is_flagged($user_uid)) {
  print "flagged";
}
else {
  print "not flagged";
}

Is my code wrong?


texts: Including files in template.php. failed in some cases (when using some contrib modules)

texts:
In template.php, in theme__preprocess_page function, I am including files (as my template.php grew big, I decided to separate some operations for readability) like this:

 function THEME_preprocess_page(&$variables) {
// .. skipped non-related code
 include  $_SERVER['DOCUMENT_ROOT'] . "/" . path_to_theme() . "/template_includes/file1.inc";

}

But sometimes some contrib modules complain about this. Currently I have an issue where Print module gives the following message:

Warning: include(): Failed opening
'/var/www/drupal/sites/all/modules/contrib/print/template_includes/file1.inc' **for inclusion** (include_path='.:/usr/share/php:/usr/share/pear') **in THEME_preprocess_page() (line 80 in** /var/www/drupal/sites/all/themes/THEME/template.php).

What causes paths mess?


texts: How can we display permissions to users?

texts:
Is there any way we can display user permissions (e.g. delete all nodes) to a user role inside a view?

Permissions would be change-able with check-boxes.


texts: Getting 404 for original video files, called with file_create_url

texts:
I am facing a strange problem.

Environment

Drupal 7.23
Video Module
File system Writable (public download method)

When i trued a custom HTML5 Player from MediaElementjs its not loading video. But when i try with a video file from external server its also working.

Take a look at the Screens. Please let me know if you need any more information.

Note : I can't get the file directly with the browser as well. When i try file_create_url and place the link in browser, still no luck.


texts: Referencing a field from Event in Computed Fields

texts:
Background: I am creating a task list for hosting events. The list is the same for each event only the date of the event will change. The due date of each task is based on the event date minus the number of days before it must be completed. (ex. Task 1 is due 5 days before Event so if Event is 7/30/15, Task 1 is due 7/25/15)

I am referencing a date field from an Event node. I am trying to calculate a due date for multiple tasks based on the Event date in Open Atrium. I have used "Field Reference" to get the date which displays on the task. When I try to reference the field in computed fields it does not display. When you do a Field Reference, does it save the information differently than a field that is created at the node?

I have tried to reference the referenced field using these two methods without any luck.

$events_date = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_event_date');

$event_date = $entity->field_event_date[LANGUAGE_NONE][0]['value'];

Also if there is a better way to solve this problem please let me know.


texts: Is it possible to notify users by e-mail when receiving a private message except when a specific user sends a message?

texts:
I also opened a thread on this on Drupal.org but since it's been awhile I thought I'd try asking here.

Use Case: In general, I want users to receive notifications for new private messages.  I can do this using the included submodule for e-mailing private messages.

So that the private message inbox has a message when users log in for the first time, I used the Rules module to automatically send a "welcome" private message upon registration on behalf of an administrator account. However, this triggers the "send e-mail on private message" behavior.  Since users already are receiving a "please validate your e-mail address" e-mail, I don't want them to receive a second e-mail notifying them that they have received the "Welcome" private message.

Is there a way to prevent messages from certain users (or, alternately, certain messages) from triggering the e-mail notification?

I also looked into implementing this using rules instead of the included submodule but this would mean I couldn't use the functionality for reducing the number of notifications (currently, I have it set to not send additional e-mails if the user has yet to log in and read the first e-mail in a thread from a given user).


texts: Drupal 7 hook_fom_alter not working for custom fields

texts:
I have added custom field for email address in my content type.
I want to assigned default email address to this field. Following is my code.

function request_order_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'request_order_node_form') {
    dsm($form);
    $form['field_your_email']['#default_value'] = 'sam@gmail.com';
  }
}

But I am not getting default value in my field.


texts: For what website size does the deploy module make sense?

texts:
I have a website that I am in the process of developing that I hope to grow to 1,000 active users or so by the end of the year.

I'm using the Features module to manage deployment, and a local-> dev-> staging-> production workflow courtesy of Pantheon.

Up to this point in my development, I've only been adding exportables that can be handled by Features.  However, I'm reaching the stage where I actually want to start allowing user-generated content which will not be managed by Features.

I've looked at the Deploy module, but it is 1) still under development for D7 and 2) has a quite involved setup.  I know that some of the big sites (Examiner, etc.) are using Deploy module workflows.

Are there use cases in which small sites would want to use the Deploy module?


texts: How do I add an item to the Bootstrap Simple Carousel on Drupal 8?

texts:
I'm having problems configuring the Bootstrap Simple Carousel module on Drupal 8.

I see that I can add carousel items at /admin/structure/bootstrap_simple_carousel and I've created the carousel block and given it a region.

But how do I get the items to display in the carousel block? At the moment it's just an empty block. I can't for the life of me figure it out!

Thank you in advance for help.


texts: Count the no of people who viewed a particular blog

texts: Is there any module that could count the no of people who viewed a particular blog?


texts:
Can anybody help me with this, any help is appreciated.

I want to create a news blog where any anonymous user can put the news post, but for posting news article,
the user must provide their valid email, the verification mail should be sent to that user. News should only be posted after only the email is verified.