texts: Getting a list of nodes of a specific type (eg, forum) via REST API

texts:
I am using Drupal 7, with the Services module. I have the REST API enabled.

I have successfully done a user.login, and have retrieved the session id and session name, and then constructed the Cookie from same.  I can successfully get a list of ALL nodes using this:

curl -i -X GET \
  -H Cookie:SESS02cbaaadbeeef=Dw8dsijhd9usdkjlb4Plsz_dipuJumGww \
  -H Accept:application/json \
  http://myserver/rest/node

How do I get the list of nodes of a specific type? Eg, nodes of type=forum ?

I tried

curl -i -X GET \
  -H Cookie:SESS02cbaaadbeeef=Dw8dsijhd9usdkjlb4Plsz_dipuJumGww \
  -H Accept:application/json \
  http://myserver/rest/node?type=forum

But that gave me the same list of all nodes.

Edit.  this is what worked for me:

curl -i -X GET \
  -H Cookie:SESS02cbaaadbeeef=Dw8dsijhd9usdkjlb4Plsz_dipuJumGww \
  -H Accept:application/json \
  'http://myserver/rest/node?parameters\[type\]=forum'

Thanks to burnsjeremy.


texts: Multiple Custom Modules Using Same External JS Lib (e.g. Angular)

texts:
I've been pulled onto a Drupal 8 project with multiple custom modules that need to use Angular.js. What is the best way to provide the Angular files to each module?

Right now, each module references the remote Angular files hosted by googleapis.com in my-module.libraries.yml.

my-module:
  version: 1.x
  js:
    https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js: { type: external, minified: true }
    https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-sanitize.min.js { type: external, minified: true }
    js/my-module.js: {preprocess: false}
  dependencies:
    - core/jquery
    - core/jquery.ui
    - core/jquery.ui.accordion

However, I would prefer to host the Angular files locally and list them as dependencies just like jQuery.

I know I could put the Angular files in the module itself, but then each module would need its own copy.

Whatever is the proper way to do it, my goal is to host the Angular files locally and reference them from each module that depends on Angular.


texts:
I am trying to create/work on an Address target plugin for the Feeds module. I have tried applying this Address target patch (shown below) from this related issue. However, the Address field on the content type to which I am mapping feed sources does not appear as a target. I did try clearing the cache.

However, when I move this code, which attempts to create an Address field Feeds target, to the Feeds module, changing the namespace appropriately and placing it in feeds/src/Feeds/Target/Address.php, the Address field does appear as a target.

Question: Why is the patch below, written in the same style and using the same techniques as the other Feeds target plugins, not being discovered, even though the annotation seems to be correct to result in discovery? (Particularly given that it is discovered when it's patched into the Feeds module.)

Possibly relevant is: What changes in annotation discovery when a module is looking in other namespaces? I would think it should be discovered using AnnotatedClassDiscovery as defined in the D8 documentation, since it seems to have the appropriate annotation.

Edit: In case it's relevant, I have also tried removing both the prepareValue and prepareValues functions from the target class, per the Feeds maintainer's comments on the linked issue.

Here's the patch in question:

<?php

namespace Drupal\address\Feeds\Target;

use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\feeds\FieldTargetDefinition;
use Drupal\feeds\Exception\EmptyFeedException;
use Drupal\feeds\Exception\TargetValidationException;
use Drupal\feeds\Plugin\Type\Target\FieldTargetBase;

/**
 * Defines a address field mapper.
 *
 * @FeedsTarget(
 *   id = "address_feeds_target",
 *   field_types = {"address"}
 * )
 */
class Address extends FieldTargetBase {

  /**
   * {@inheritdoc}
   */
  protected static function prepareTarget(FieldDefinitionInterface $field_definition) {
    return FieldTargetDefinition::createFromFieldDefinition($field_definition)
      ->addProperty('langcode')
      ->addProperty('country_code')
      ->addProperty('administrative_area')
      ->addProperty('locality')
      ->addProperty('dependent_locality')
      ->addProperty('postal_code')
      ->addProperty('sorting_code')
      ->addProperty('address_line1')
      ->addProperty('address_line2')
      ->addProperty('organization')
      ->addProperty('given_name')
      ->addProperty('additional_name')
      ->addProperty('family_name');
  }

}


texts: Drupal versus with Omni Update: Should I move from Drupal to Omni Update?

texts:
Use Case

Current (aging) IT website built on Drupal 5.
Most people hate this website because the theme is awful and adding content is painful.
An upgrade to Drupal 6 and a theme / module updates are what are needed. (Not considering Drupal 7 until more modules are available.)
Some of our leadership thinks we need to switch platforms anyway.

Argument

What are the pros of sticking with Drupal versus switching to Omni Update?
What are some pro Drupal buzzwords that nontechnical manager-folk will understand?
What is your best argument for selling Drupal to a prospective client?


texts:
I have 4 language versions on my website.
Is there a way to define a language fallback order?

For example, if I'm on a node page and the language is set to English and there's no English translation I'd like Drupal to look for French, then German, then Spanish translation.


texts: Hide the number of products on the shopping cart when it is empty

texts:
I copy the file "commerce-cart-block.html.twig" in my sub-theme. Currently it displays my shopping cart with the number of products inside.

I want that when there is no product in it, the shopping cart remains displayed and the number disappears.

How to do this ?

      {{ count }}

  {% if content %}

        {{ content }}

        {{ links }}

  {% endif %}


texts: How to show loader image before popup screen of color box module in drupal 7

texts:
I used color-box module in my current drupal project for showing user details in popup after click user image. It will take some time to show details so I want to show loader images before this. I tried to override this using drupal.behaviors but cannot get proper output. If any idea how to handle this situation then please help me for same.

Thank you.


texts: Why is the output from getDefinition($type) different from getStorage($type)->getEntityType()?

texts:
In a Controller, when calling: $this->entityTypeManager()->getStorage($type)->getEntityType(), I do not have the exact same return value as: $this->entityTypeManager()->getDefinition($type).
They both return the same class (in my tests, it was ContentEntityType), but the only difference is in the entity_keys definition. Here is a diff of var export highlighting the diff between the two calls:
--- a/fromStorage.txt
+++ b/fromStorage.txt
@@ -19,6 +19,7 @@ Drupal\Core\Entity\ContentEntityType::__set_state(array(
     'uuid' => 'uuid',
     'langcode' => 'langcode',
     'published' => 'status',
+    'test' => 'entity_key_value',
     'revision' => '',
     'bundle' => '',
     'default_langcode' => 'default_langcode',

The test entity key was added after the module was installed (a custom entity). Only the $this->entityTypeManager()->getDefinition($type) call returns this entity key. The remaining of the entity definition is 100% the same.
At first, I thought that an entity update was needed, but the entity update manager detects no update to apply. Clearing the caches did not help either. Why the inconsistency? Am I missing an update call somewhere?


texts:
I have 2 content types: schools and courses.

On the schools content type, I created a field called 'Courses At This School' which is an entity reference field to the courses content type.

So, I edit a school and then I can add which courses the schools runs based on nodes I created on courses.

I now need to create a block view but cannot get my head around how to do this. This block will be placed on the schools node pages and will show which courses the schools run so I'll need a contextual filter too.

I have tried playing around with this but I am getting nowhere. Do I create a view and filter by courses or schools?


texts: How do I create a table when a module is installed?

texts:
I want to add a custom table when a module I develop is installed. The code I am using doesn't seem to work, as the post table isn't created.
What is wrong with the code I am using?
/**
 * Installs the database schema.
 */
function mymodule_install() {
  drupal_install_schema('post');
}

/**
 * Uninstalls the database schema.
 */
function mymodule_uninstall() {
  drupal_uninstall_schema('post');
}

/**
* Creates the tables using the schema API.
*/
function mymodule_schema() {
  $schema['post'] = array(
    'description' => 'description pour la table post',
    'fields' => array(
      'pid' => array(
        'description' => 'post id',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'title',
        'type' => 'varchar',
        'not null' => TRUE,
      ),
      'body' => array(
        'description' => 'body',
        'type' => 'varchar',
        'not null' => TRUE,
      ),
      'created' => array(
              'description' => 'created',
              'not null' => TRUE,
              'mysql_type' => 'timestamp',
            ),
      'primary key' => array('pid'),
    ),
  );
}


texts: Module that allows access to node based on roles

texts:
Is there a module that lets me simply select the roles that can have access to a node as I create it?

For example, I have a role named "BUG", I want BUG to be able to access node/5, but not any other role (including authenticated users).

I've been looking and looking and can't find anything.


texts:
I would like to have a different user template for each role, but I can't figure it out how do do it.

I've added a preprocess function in my themename.theme like this:

function ras_preprocess_page(&$variables) {

    $variables['role'] = \Drupal::currentUser()->getRoles();
}

and then used role in my user.html.twig like this:

{% if role == 'administrator' %}

Hello, admin

{% elseif role == 'anonymous' %}

Hi, stranger

{% endif %}

But it doesn't work as I would expect.


texts: In Drupal 7 With Latest CKEditor, Media upload button not working

texts:
If i do install Wysiwyg + CKEditor 3.6.6.1 ( 2013.02.20) + Media module in Drupal 7 then the upload functionality works on ckeditor. Here is my screenshot:

But, if i install CKEditor Drupal 7 Module + Media Module then the upload functionality do not working on ckeditor. Here is my screenshot:

So, how i can enable the Upload section in Media Module? Thanks


texts: How to reuse the same str_replace-like function pathauto is configured to?

texts:
Use case: Custom module to alter CONTENTTYPE_node_forms to hide some of many entity reference options when adding/editing a node. Then via a custom validate I set $form_state['values']['path']['pathauto'] = 0 and want to set the $form_state['values']['path']['alias'] depending on the parent item of the chosen entity reference since unfortunately Pathauto doesn't provide tokens for that. Finally the alias should look like that: parent-entity/entity/$form_state['input']['title'].

I builded that pattern by hand now and I'm asking me after I couldn't find anything, if I also have to rebuild the whole str_replace/preg_replace pattern of Pathauto or if there's a way to reuse the same pattern Pathauto is using for replacing spaces, special characters etc.?

Or is there maybe any other intelligent alternative to set a path alias pattern like that?


texts: How can we retain dropdown list value, when we select the option?

texts:
I want to retain dropdown list value, so that when ever someone select the option from the dropdown list should retain that value after performing the action.

/*
 *implements hook_menu().
 */

function dropdown_page_menu(){
  $items = array();
  $items['page/layout/%'] = array(
    'title' => 'Select Layout',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('dropdown_page_select_form'),
    'access arguments' => array('access content'),
    );

  return $items;
}

/**
 * Implements hook_block_info().
 */
function dropdown_page_block_info() {
    $blocks = array();

    $blocks['dropdown_page_select_form'] = array(
        'info' => t('Select Layout'),
    );

    return $blocks;
}

/**
 * Implements hook_block_view().
 */
function dropdown_page_block_view($delta = '') {
    $block = array();

    switch ($delta) {
        case 'dropdown_page_select_form':
            $block['subject'] = t('Select Layout');
            $block['content'] = drupal_get_form('dropdown_page_select_form');
            break;
    }

    return $block;
}

function dropdown_page_select_form($form, &$form_state){
  $options = array(
    'select' => t('Select'),
    'layout_1' => t('Layout 1'),
    'layout_2' => t('Layout 2'),
    'layout_3' => t('Layout 3'),
    );

  $form['choice'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#title' => t('Select your layout'),
    '#default_value' => $form_state['choice']['type']
    );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value'=> t('Go'),
    );
  return $form;
}

function dropdown_page_select_form_submit($form, &$form_state){

switch ($form_state['values']['choice']){
  case layout_1 : {

    //echo 'hi';die;
    drupal_goto("layout_1".$options);
    break;

  }
  case layout_2 : {
    //echo 'no';die;
    drupal_goto("layout_2".$options);
    break;
  }
  case layout_3 : {
    drupal_goto("layout_3".$options);
    break;
  }
  default: {
    print 'Select it!';
  }
}

  drupal_set_message(t('Your layout %input', array('%input' => $form_state['value']['choice'])));
}


texts: Permissions to see all users products, not just the orders on UberCart

texts: I am trying to figure out what permission in ubercart to set that would allow a user to see just the products they put in.  It show them orders but not a list of their own items. Any help?


texts:
I've created views as XML data document using Views Datasource which looks like:

<?xml version="1.0" encoding="utf-8"?>
<node><node>
<title>My title</title>
<field_feed_description>My description</field_feed_description>
</node></node>

How do I now change generated XML name tags?

For example I want to rename field_feed_description name into something else.


texts:
I'm creating a new D8 theme and am having trouble making Drupal load the CSS that is a part of my theme. I have disabled cache and am sure I'm getting the up-to-date output.

Here's my mytheme.info.yml:

name: Mytheme
type: theme
description: 'This is a description.'
core: 8.x

libraries:
  - mytheme/global-styling

libraries-override:
  system/base: false

regions:
  header: Header
  content: Content  # the content region is required
  menu_primary: 'Menu - Primary'
  menu_secondary: 'Menu - Secondary'
  footer: Footer

Here's mytheme.libraries.yml

global-styling:
  version: 1.0
  css:
    theme:
      css/global.css: {}

and this is the top of my html.html.twig file:

<!doctype html>
 <html lang="en">
 <head>
   <title>{{ head_title }}</title>
   <head-placeholder token="{{ placeholder_token|raw }}">
   <css-placeholder token="{{ placeholder_token|raw }}">
   <js-placeholder token="{{ placeholder_token|raw }}">
   {{ page.head }}
   {{ page.styles }}
   {{ page.scripts }}
</head>
...

The content in the YAML files is not tabbed, spaces are used.

I already spent several hours trying to figure out what's wrong and why the global.css is not being linked in the header of the html page, but I have no idea. I'll be gratefull for any help.

EDIT: I found out that my CSS do load when I use this:

{{ attach_library('mytheme/global-styling') }}

but I thought the point of referring to global-styling inside mytheme.info.yml was that I don't have to do that. Did I understand that correctly?


texts: drupal 6 status report, automate via drush?

texts:
We run around 100 drupal sites, and I want to automate a weekly check that will scan all of the admin/performance/status report pages. I had a look at drush status and it doesn't give me the same information as the web interface does.

Has anyone done this and how did you go about it? Ideally I want to just email weekly to the dev team if there is an alert on any particular site


texts: Problem uploading files and images containing spaces in the filename

texts:
In Drupal 8 I have fields of type File and Image, inside Content types and forms. These fields stores files inside the "public" folder.

When I upload files with a name containing spaces, for example a file named "example with spaces.pdf", the file is correctly uploaded but once uploaded it is no more available.

The image below is just after uploaded an image containing spaces in the filename. Note that all seems correct:

When I save and publish the content I get this:

And returning back in the edit panel the thumbnail is no more available:

Same problem above trying to upload files inside a field of type File.

The file's url becomes something like this:

localhost:8888/sites/default/files/2016-05/example%20with%20spaces.jpg

But I'm redirected to the home page trying to open such url. Maybe there is a bug in Drupal when translates the url encoded filename in the real one.

If the filename has no spaces, or if the file is uploaded inside the "private" folder, there are no problems.

Any idea about how to solve this problem?

EDIT

I can reproduce the error with following steps:

Download Drupal

$ drush pm-download drupal --drupal-project-rename=drupal

Install Drupal

$ cd drupal
$ drush site-install standard \
--db-url='mysql://[db-user]:[db-pass]@localhost:[db-port]/drupal' \
--account-name=admin --account-pass=password \
--site-name="Drupal" \
--site-mail=noreply@example.com

Start Drupal

$ drush runserver

Create a new 'Article' and upload an image with spaces.

Maybe is there something wrong in steps above? Or a bug in the drush's built-in server?


texts: Is it possible to change the "view type" from a "content view" to a "search view"?

texts:
I have recently installed the Search API module and associated modules to build a better site search.

My current search function is basic out of the box search but there are is lot of custom HTML and CSS to make the search results look good. Therefore I am wondering if I will have to manually redo everything when making a dedicated "search view" (a type of view enabled by the Search views module) or if it there is some way to clone/copy my previous "content view" but change it's type.

I have looked for answers and it was not possible in Drupal 6 but I am running Drupal 7.


texts: How to filter options in a select element based on taxonomy?

texts:
I have a taxonomy (Bioregions) of regions in our country. It has a few extensions which are used in different contexts (A user may come from "outside NZ", an event may be "nationwide" or "online"). We achieved this by creating a second taxonomy, bioregion_use (terms of user, event), which has been applied as a field on Bioregions. See this question for details.
So now I am wondering how to use this to filter out the  elements which are not wanted in the context of the form being used (create/edit user vs create/edit event).
I've gotten as far as guessing it might involve hook_form_alter()

Edit: The filtering to options only tagged with "event" will be needed in several forms, e.g. create/edit event plus exposed filters on views-generated pages - so is there a way to avoid creating a separate function for each form where this occurs?


texts: How to manage patches in composer when they're merged into the module?

texts:
I'm building a Lightning BLT project and recently the deploy:build failed because the features module merged a patch composer.json was set to apply.

Is there a way to indicate to composer that the patch is already applied and to skip it?

Edit

Is there a way for composer to know programmatically, perhaps from the module code itself, that the patch has been applied?


texts:
In my author_pane template, I get my user´s names trimmed as it was back then in Drupal 6.
So I went to the api page (as I did in my D6 installation) and I see that the code that used to work in Drupal 6 isn´t there anymore in Drupal 7.

This was the code I´m looking for:

function theme_username($object) {

  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($object->name) > 20) {
      $name = drupal_substr($object->name, 0, 15) . '...';
    }
    else {
      $name = $object->name;
    }

How may I ensure in D7 that my username´s names aren´t being trimmered at 20 character´s length?


texts:
I am Using menu token module to access pages related particular user, I am getting issue while selecting path in token menu using replacement patterns. can any one explains on what basis it will take the link and direct to the page. i tried to use [node:content-type:name], As there are so many content types created in my site, so how it will take the specific content type which is related with the node.

kindly suggest me if there are alternatives for this.. i am fed up by trying this whole day.


texts:
im trying to access some variables of my view but i fail terribly:
My modulefile looks like this:

$io= views_get_view('nameofmyview');
dpm($io);

Drupal tells me:

  Fatal error: Call to undefined function views_get_view()

What am i missing?


texts: Adaptivethemes and panels - how to create custom layout?

texts:
I am building my site using panels , mini panels on every page.
In addition, I am using the panels everywhere modules.
The theme I am using is: "Adaptivetheme".

I every page I built (using page manager and panels), I chose a panels layout of "AT responsive panels" 3 or 2 columns, depends on the page.

can I change the ratio of the columns of the layouts, so it will be, for examples 20/55/25, instead of the default 25/50/25?


texts: First AJAX request is working very well, next takes too much time

texts:
I'm working on ajaxing my site, for a long time now.
I found a method that's working for me, but only the first AJAX request is working the right way; the next request takes at least twice the time.

I thought, that it behaves like that because I load the whole scripts from a template file with every request. I removed the print $scripts from that template file; the result is that the requests take the same time took before.

This is the content of the files I am using.

my_ajax.module

function my_ajax_init() {
  drupal_add_js(drupal_get_path('module', 'my_ajax') . '/my_ajax.js');
}

function acquia_slate_preprocess_page(&$vars, $hook) {
  if (isset($_GET['ajax']) && $_GET['ajax'] == 1) {
    $vars['template_files'][] = 'page-ajax';
  }
}

my_ajax.js

Drupal.behaviors.my_ajax = function (context) {
  $('#content-group-inner a').live('click', function (e) {
    $('#content-group-inner a').not('.my_ajax-processed').addClass('my_ajax-processed');
    var url = $(this).attr('href');
    $('#content-region-inner').empty().html('');
    $('#content-region-inner').load(url, 'ajax=1', function () {
      Drupal.attachBehaviors('#content-region-inner');
    });

    return false;
  });
};

page-ajax.tpl.php

<?php print $styles; ?>
<?php print $setting_styles; ?>

<?php if ($local_styles): ?>
  <?php print $local_styles; ?>
<?php endif; ?>
<title><?php print $head_title; ?></title>

<?php if (arg(0) != 'admin') { ?>

<?php } ?>
<?php  print $scripts; ?>

<?php print theme('grid_block', $tabs, 'content-tabs'); ?>

    <?php if ($title): ?>

<?php print $title; ?>

    <?php endif; ?>
    <?php if ($content): ?>

        <?php ?>
        <?php print $content; ?>
        <?php print $feed_icons; ?>

    <?php endif; ?>

<?php print $closure; ?>


texts: How can i set a pagination in detailed pages? for example i have 10 pages in common blogs and the main page contain only the description about the content.When we click on the title of the page or readmore then it will displaying the detail of specified content here i want to set the pager how is it possible?


texts:
When I use contextual filters in a view, I can select an option to display a summary when the argument is not present. If I do it, it shows a list of node IDs instead of titles. For example, I get the following output, where the first number is the node ID, and the second number is the count of nodes.

1256 (12)
4323 (723)
5643 (34)

I want is to rewrite the output and replace the node ID with its title. ViewExecutable has a $args property I can check to know when the argument is not present.

How could I achieve this in a hook? In Drupal 7 I could use hook_views_post_execute(). I modified $view->result and changed it on my own.

I tried to do the same with Drupal 8 and the same hook, but hook_views_pre_render() gets a ViewExecutable object, and I don't know how to change it. I used the following code.

function MYMODULE_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'myidoftheview') {
    $results = $view->result;
    foreach ($results as $result) {
      \Drupal::logger('myview')->notice('<pre>'.print_r($result,TRUE).'</pre>');
      // What code should I write here?
    }
  }
}


texts:
Hello ive been trying to work out how to do this for years and ive a feeling its one of them eureka moments when i go 'oh aye thats how you do it'. I think thats why i have never been able to find anything on it.

Using Views 3 my lists look like this when using total views and total comments-

and i would like to get rid of the label for a wee pic like this-

Could anyone point me in the right direction?

Thanks


texts: Edit a config variable of a custom module in controller

texts:
Is it possible to edit/create a config variable of a module in a controller created in the same module?

For example:
module_name/src/Controller/MyController.php:

class MyController extends ControllerBase {

    public function x($y) {
        $config = \Drupal::config('module_name.settings');
        $config->set('var1', $y)->save();
    }
}

Update:

module_name.module:

function module_name_page_attachments(array &$page) {
  $config = \Drupal::config('module_name.settings');
  var_dump($config->get('var1'));
}

module_name/config/install/module_name.settings.yml:

var1: 0

module_name/src/Form/moduleNameSettings.php:

class moduleNameSettings extends ConfigFormBase {

    protected function getEditableConfigNames() {
        return [
            'module_name.settings',
        ];
    }

    public function submitForm(array &$form, FormStateInterface $form_state) {
        parent::submitForm($form, $form_state);
        $config = \Drupal::config('module_name.settings');

        $this->config('module_name.settings')
            ->set('var1', $config->get('var1'))
            ->save();
    }


texts:
i am writing a simple multistep form using ctools on drupal 7. Everything seems to work but i have a one last problem before i finish the task. How can i access the custom user fields (or fieldset i am not sure about the terminology). I've tried to do that by using the function below but it doesn't works and the property is always empty;

function helper_get_default_value_from_profile($fieldset, $key){

  $uid      = helper_is_user_logged_in();
  $account  = user_load($uid);
  $profile  = profile2_load_by_user($account, "cv");

  if(!property_exists($profile, $fieldset))
    return 0;

  if(empty($profile->$fieldset))
    return 0;

  $fieldset_ref = $profile->$fieldset;
  $id           = $fieldset_ref["und"][0]["value"];
  $fieldset_data = field_collection_field_get_entity($id);

  if(!property_exists($fieldset_data, $key))
    return 0;

  if(empty($fieldset_data->$key))
    return 0;

  $user_prop = $fieldset_data->$key;
  return $user_prop["und"][0]["value"];
}


texts: How to hide custom fields on the menu item form?

texts:
I've added two new fields to the menu item form (admin/structure/menu/item/{ID}/edit):

function modulename_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  $fields = [];

  if($entity_type->id() == 'menu_link_content') {
    $fields['show_mobile'] = \Drupal\Core\Field\BaseFieldDefinition::create('boolean')
      ->setLabel(t('Show in mobile menu bar.'))
      ->setDescription(t('Toggles the display of the menu item in the menu bar at the bottom of pages in mobile view.'))
      ->setDisplayOptions('form', [
        'type' => 'boolean_checkbox',
        'weight' => '0',
        'settings' => [
          'display_label' => TRUE,
        ],
      ])
      ->setDisplayConfigurable('form', TRUE);

    $fields['svg_icon'] = \Drupal\Core\Field\BaseFieldDefinition::create('string')
      ->setLabel(t('Mobile Menu Bar SVG Icon'))
      ->setDescription(t('Select the icon you want the menu item to use in the mobile menu bar.'))
      ->setDisplayOptions('form', [
        'type' => 'string',
        'weight' => '0',
        'settings' => [
          'display_label' => TRUE,
        ],
      ])
      ->setDisplayConfigurable('form', TRUE);
  }

  return $fields;
}

But now I run into the issue, that I only need these fields for the main navigation menu, and thus want to remove or hide these on all other menu item forms.

Preferably I would like to keep it all to the module that adds the fields, and not have to create a custom admin theme just to visually hide them.

What should I look at to figure this one out? I've tried googling a lot of different combinations of the question, but have yet to find anything that remotely looks like a solution.

Many thanks in advance to anyone who can point me in the right direction.


texts: Count content views show in number with icon

texts:
I have enabled Count content views in Statistics.

The bottom of article show "3 reads".

I checked the code, the code is 3 reads

Because the number and word is together, I can't change word "reads" to an "eye" icon.

How do I show the number with icon.

Below is the effect I want


texts: Put eform's label and textfield(input) separate

texts:
I'm working on creating a table with eForm in Drupal 8.

Since label and textfield(input) stick together, can I insert label and textfield(input) into separate <td>?


texts: How to use "IS NULL" and "IS NOT NULL" Operators in JSON API Collections?

texts:
I am creating an API with Conditions and Operators. For '=' and '<>' operators its working fine. But for "IS NULL" and "IS NOT NULL" operators the response is 400: Bad Request.

{{URL}}/jsonapi/node/CONTENT_TYPE?filter[filter1][condition][path]=TAXONOMY_FIELD.drupal_internal__tid&filter[filter1][condition][value]={{TID}}&filter[filter1][condition][operator]=IS NULL

Request:

Response:
The error says: Filters using the 'IS NULL' operator should not provide a value.

Should the operators be encoded ? If yes, then which encoding should be used and what is the encoded string for these operators ?


texts:
I'm working with Views 3, and I'm trying to figure out how to best accomplish the following scenario:

On my front page, I'd like to have my articles set up as follows:

On the left, a large thumbnail is shown for the latest article. This accounts for the Title, Author, Post date, and a short summary with a comment count.

To the side, I have a block created in Views that would show the previous three articles with smaller thumbnails, author information, post date, summary, and comment counts.

What I need to know is this: How can I set up both Article views so that:

-The view on the left only shows the absolute latest article.

-The view on the right always excludes the latest article from the listing.


texts: Acquia Dev Desktop Installation error-unable to realloc 1073741832 bytes

texts:
i was installing "Acquia Dev Desktop " on my windows 7 PC. Link to Acquia dev desktop https://docs.acquia.com/dev-desktop

During the installation process it showed the error message

  Fatal Error Installer-Unable to realloc 1073741832 bytes

Can anyone tell me whatscausing the problem and how can i fix it.

Acquia does not have a free support forum


texts: How to get environment variables in a service container?

texts:
According to the Symfony documentation, env() parameters were introduced in version 3.2, allowing to use environment variables in service container configuration:

# app/config/config.yml
doctrine:
    dbal:
        host: '%env(DATABASE_HOST)%'

However, when I try using this functionality in Drupal I get an exception stating:

The service XXX has a dependency on a non-existent parameter "env(DATABASE_HOST)"

Looking at the stack trace I only see references to the default ResolveParameterPlaceholdersPass and not to ResolveEnvPlaceholdersPass

I'm using Drupal 8.6.5 which uses symfony/dependency-injection v3.4.20


texts:
I have two website with drupal 6. One was in production mode while the other one was cloned formthe production site to implement a new theme. As of now the new website is made production website and new contents (users,products,orders) are being added to it.

However my question is, I want to import the content from the old website database into new production one and I am facing some collisions with the primary key of it. How can I get the data into new database from the old one?

Please suggest the best way to to achive it also the database tables I need to get imported.I am using ubercart for the shop functionality.

Any help will  be appreciable.


texts: We excluded some modules from drush update (--lock=module_name). Is there a way to get a list of locked modules? A drush command or a file with the list?


texts:
I have the following Drush command:

  /**
   * @command mycommand
   */
  public function myCommand() {
    $this->io()->success('MY TEST');
  }

If I type in CLI:

drush mycommand -> Formatted, but no colors

drush mycommand --ansi -> Formatted AND colors

Why does not colorize it in the first place?
Running composer for example uses color without an issue.

My system

UBUNTU 16.0 server VM (through PUTTY terminal)
Drush 9.5.2
Drupal 8.6.2
PHP 7.2


texts: I have created custom content type for upload the details. I have used hook_form_alter to set the node title as "Upload". When I edit the node in node/%/edit the title remains "Upload". I want the title to be "Edit" .How to do this?


texts:
I would like to make a custom module that integrates with webform (7.4).

I need to have a combo field which could be added to a form as one field but consists of 4 text areas.

I have found a discussion on this topic here -> http://drupal.org/node/965068 but first its confusing how he does it at the end he just says he figured it out, but also this is a solution for 6.3 and i need for the 7.4

Any help would be greatly appreciated.


texts:
I want to exclude some pages from the sitemap.

I go to these pages/nodes, edit them, then go to the XML sitemap tab and set it to 'Exclude'.

I then save and clear cache.

But when I look at my sitemap.xml file nothing is changed - the page URLs are still present.

How do I remove them?


texts: What is wrong with this drush command in Drupal 7 Ubercart 3 to delete orders in bulk via command line?

texts:
I am trying to delete my Ubercart 3 orders in bulk via the command line with just a one liner:

for XX in {1..12}; do drush ev 'uc_order_delete($XX)' -v; done;

It beats having to do it via the bulk operations in views. I'm not sure whats wrong with my command as it says I have an Undefined variable when i put $XX in quotes.


texts:
I have a select box that I want to populate with a particular taxonomy programmatically. If i was was to use a taxonomy vocabulary how would i populate a particular select box in my form. My form is generated using the from api and not using content types. If for example I was to have a vocabulary called countries. I have a select box which currently is configured like this

 $form['status']['currentstatus'] = array (
 '#values' => array(t('red'), ('green'))

 );

$form['status']['currentStatusList'] = array (
    '#title' => 'current status',
    '#type' => 'select',
    '#options' => $form['status']['currentstatus']['#values']
);

Instead of just adding the values I would like to pass a vocabulary.

I have manged to get the vocabulary data
but a zero is placed before the terms.

the code I figured out for the box is the same as yours. I even pass the id for the vocabulary. I will have a play with it thanks for your help


texts: Drupal 7 Commerce - How would you increase or decrease a checkout total price depending on payment type?

texts:
I want to be able to provide alternative payment methods during checkout, but I also want to be able to discount or add on top of the total checkout price by a percentage depending on what the user chooses to pay with. How can this be done? I know you would use rules, but which sections would i need to edit?

** edit - I was able to edit up the the "pricing rules" page, but now i get an error for Order Total. I want to be able to mutltiply the order total as seen below. I'm not sure what to put after the colon : of order total.


texts: How to add extra tab in common browsing widget in drupal commons

texts:
Here i working in Drupal Commons.7.x and i need to add extra tab in that common browsing widget (Common Browsing Widget) section in common drupal.How to achieve to add extra tab in common browsing widget in common drupal.Here my need to in that image
Here i tried to change using

  structure => View => Common browsing Widget (Poll,Q&A,Event and etc.,)

. Need to add extra tab with content.how to achieve it.Kindly guide me.!


texts: Getting "On Behalf Of" in ubercart email confirmation

texts:
I am using ubercart in my site.  After making the payment we are getting two emails.  One is for the user and another for admin.  In the amin email I am getting "On Behalf of" and id of the developer who developed this app.  How to change it.

Any help is greatly appreciated.


texts: How to resolve error 'Unresolved dependency System ...' encoutered when trying to upgrade Drupal core?

texts:
I'm trying to update Drupal core from 7.28 to 7.36. (not using Drush)

When running update.php I get:

  Unresolved dependency  System (Version >=7.33 required)
  Relation requires this module and version. Currently using System version 7.28

It seems like the Relation module wants a version 7.33 or higher, and yet it won't let me upgrade to a version 7.33 or higher. Not quite sure how to get past this.

Relation ver. 7.x-1.0-rc7  (It didn't seem to have any trouble when I upgraded to 7.28).

How can I resolve this?


texts:
Has anyone tried migrating fields with multiple source data rows? In my case, Im migrating values of commerce file field (https://www.drupal.org/project/commerce_file). It only migrated 1 id where it should have multiple id's. I've checked the query in the source database, it outputs correctly, my problem is upon migration.

Here's what I did.

$query->addExpression('GROUP_CONCAT(file.field_file_fid)', 'file_id');

/* … */

$this->addFieldMapping('commerce_file', 'file_id')
        ->sourceMigration('PrivateFile')
        ->separator(',');
$this->addFieldMapping('commerce_file:file_class')
        ->defaultValue('MigrateFileFid');
$this->addFieldMapping('commerce_file:preserve_files')
        ->defaultValue(1);


texts:
How do I get the page title for use in a theme? I'm using Drupal 8.

I've tried searching the Drupal web site and I looked at a few questions on here and I can't seem to figure it out.

Here is what I'm trying in my template_preprocess_page:

  $request = \Drupal::request();
  $route_match = \Drupal::routeMatch();
  $variables['page_title'] = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());

However, {{ page_title }} does not work. It seems as if the value is null.


texts: How to check if the current page is a 404 error from a module/template?

texts: How to check, in D7, if the current page is returning a 404 error from a module/template?


texts: AJAX error when ctools_modal_command_dismiss() is called

texts:
So I'm having a problem with dismissing a Ctools modal within a form submit's callback function. Once I have processed any submit data, I'd like to dismiss the modal without redirecting the page (easy enough), but each time I click the submit button with ctools_modal_command_dismiss() included in the callback function, I'm presented with an AJAX error such as below:

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows.

I'm stumped as to why this is happening. The modal works perfectly without the dismiss function.

function pay_rise_menu() {
  $items = array();
  $items['pay_rise/%ctools_js'] = array(
    'page callback' => 'pay_rise_modal_email_share',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
  );

  return $items;
}

function pay_rise_modal_email_share($ajax) {
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');

    $form_state = array(
      'ajax' => TRUE,
      'title' => t('Share by email'),
    );

    $output = ctools_modal_form_wrapper('pay_rise_modal_email_share_form', $form_state);

    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }

    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('pay_rise_modal_email_share_form');
  }
}

function pay_rise_modal_email_share_form($form, &$form_state) {
  $form = array();

  $form['recipient'] = array(
    '#type' => 'textfield',
    '#title' => t('Recipient'),
    '#attributes' => array(
      'placeholder' => 'Recipient email...',
    ),
  );

  $form['body'] = array(
    '#type' => 'textfield',
    '#title' => t('Message'),
    '#attributes' => array(
      'placeholder' => 'Message...',
    ),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#ajax' => array(
      'callback' => 'pay_rise_modal_email_share_form_callback',
    ),
  );

  return $form;
}

function pay_rise_modal_email_share_form_callback($form, &$form_state) {
  $values['message'] = $form_state['values']['body'];
  drupal_mail('pay_rise', 'share', $form_state['values']['recipient'], 'en', array('values' => $values));
  $form_state['ajax_commands'] = ctools_modal_command_dismiss('Thanks. Your message has been sent.');
}

The above is invoked once the following link is clicked:

l('email', 'pay_rise/nojs', array('attributes' => array('class' => 'ctools-use-modal icon-mail')))


texts: Adjust number of posts that appear on front page

texts:
I currently only have one story that posts to the front page. How do I add more?

I know it's a really n00by question but I have google and visited many different links and they all say to go to the content administration page... but then where?


texts: How do I manually update without using Drush nor Composer?

texts:
Is it possible to upgrade Drupal from 8.3.7 to 8.4 without Drush or Composer?

Even though I have used composer I am not comfortable with using terminal/console command lines operations. So far used composer to install and remove modules. That's about it.

Looked at manual update options. There are no instructions yet for this method.
https://www.drupal.org/docs/8/update/update-core-manually-via-gui-option-1

This is what I am planning on doing.

Download and extract Drupal 8.4 zip.

Backup database  through PHPMyAdmin and website before
proceeding.
Put site in maintenance mode by going to
configuration -> maintenance mode
Remove ‘core’ and ‘vendor’   directory project dir.
Upload the core directory from the Drupal 8.4 version
downloaded.
Upload .htaccess,composer.lock and composer.json files from the downloaded Drupal to project.
Upload vendor directory from the download
Drupal version to your project.
Go to site.com/update

Am I missing something? Or should I figure out the composer route?


texts:
I am using Drupal 6.27, created my own module, used hook_perm() in my module. Now the question is - did i do that in the right way?

/**
 * Implementation of hook_block().
 */

function adminka_block($op = 'list', $delta = 0, $edit = array()) {
  switch($op) {
    case 'list':
      return array(
        'adminka_simple_block' => array('info' => 'adminka simple block', 'cache' => BLOCK_NO_CACHE),
      );
    case 'view':
      switch($delta) {
        case 0:
          if (user_access('view adminka')) {
            $block['subject'] = t('My admin panel');
            $block['content'] = 'Добавить ' . variable_get('content_type_name', false) . '
';
            $block['content'] .= 'Выход';
            break;
          }
      }
      return $block;
  }
}

Because i didn't found another way to restrict that block visiblity only to users with user_acess('view adminka').


texts: How to solve colorbox node error "no url found on element"

texts:
I'm building a website and on one of the pages: http://xenofilia.thedrupalchecklist.com/thevilla/1

I get a strange error: "no url found on element". When I scan the course code I think it is from colorbox node module, but I'm not sure as I do not know how to debug.

No errors are displayed in the Drupal watchdog en when i click on the images all 14 images are just displayed normally with colorbox node.

How to solve this error?


texts: Filter by end date if it exists, if not then filter by start date

texts:
I have a view of events, which has a start date and an end date (2 separate fields as the end date was added later). The end date is optional. I want to show events that are either in the future or are currently ongoing. So somehow I need to check if the node has an end date - and if so apply the filter on that, but if not then use the start date instead.

Is there any way to achieve this? Maybe I'm looking at in the wrong way.


texts: Using exposed filters as part of the rendered page's title

texts:
I'm using exposed filters in a Drupal 7 site. I'd like to make the selected items from those filters part of the titles. Is there a way I can get the text value of those selected filters and use that text as part of the title?

Settings are as allowed:

I'm also using Better Exposed Filters in this view.


texts:
I need a function that checks a condition; for example, if $a == $b it should return the access denied page to the current user.

What function should I use?


texts: One node on multiple pages with tabbed navigation between fields

texts:
I would like to create a Product content type with multiple fields and then showing those fields on seperate pages, let me give you an example:

I create a product type content named "Car" that has fields like "Mileage", "Color", "Year" and so on. When you open this content's page, you see the "Mileage" by default and you have a few tabs with "Color", "Year" that you can click to show those fields.

One possible solution I found is to use the Field Groups module, but I am looking for another one because the different sections will be heavy, lots of images and styling and I worry about that jQuery show, hide implementation will result in laggy, slow experience for the visitor.

Also it would be ideal if we could have a different URL for the sections like, car/mileage, car/color and so on.

Is there a rock solid solution for this?

Thank you.


texts: How to force drupal to use English version of the field?

texts:
I have bean block with a list (list_block) of other bean blocks (content_block) which I use in slider. I have multilingual site, so I have 2 languages English and Spanish. Each content_block has translation (so it has both English and Spanish variants). So the problem is:

I have an empty field Description in one of my content_blocks and it's empty only for English version, but it has data in Spanish version. So when I go to see the slider (with the list of content_blocks) on my homepage in English version I see Spanish value of this field but not empty value. When I add English value to that field the problem disappearing and English value appears in the slider. So why this happening? And how to force Drupal to use English version of the field even if it has no value but it has Spanish version of the field ?


texts: How do I correctly load user_profile_form() to use in my theme?

texts:
I am trying to theme the user profile edit page using user_profile_form() and need help how to achieve this. In my template.php I have the following code:

function marinelli_theme($existing, $type, $theme, $path) {
  $hooks['user_profile_form'] = array(
    // Forms always take the form argument.
    'arguments' => array('form' => NULL),
    'render element' => 'form',
    'path' => drupal_get_path('theme','marinelli'),
    'template' => 'templates/user-profile-edit',
  );
}

function marinelli_preprocess_user_profile_form(&$variables) {
  global $user;
  $form_id = 'user_profile_form';
  $form_state = array();
  $form_state['build_info']['args'] = array($user);

  // Load user.pages.inc and ensure it is automatically reloaded if
  // this form is rebuilt via AJAX or other means.
  form_load_include($form_state, 'inc', 'user', 'user.pages');

  $variables['rendered'] = drupal_build_form($form_id, $form_state);
}


texts: Move block level configuration also in Features

texts: I am building features. Can I add blocks ans block level configuration in Features?


texts: How can I create dynamic options based on the existing bundles from hook_drush_command()?

texts:
I want to create dynamic options based on the entity types (returned by entity_get_info() function) inside the hook_drush_command(). There's no bootstrapped Drupal available at all, so the db_query() entity_get_info() functions aren't available. How can hook_drush_command() get site information?

(The module is inside the ~/.drush/mymodule directory.)


texts: How to allow for redirecting on same URL with different query strings?

texts:
I'm using Drupal 7. I have about 120 urls with different query strings, and Drupal is not allowing me redirect on same url with different query strings/parameters.

For example:

I have to redirect from this url blog/its-time-occupy-it?page=1 to blog/its-time-occupy-it. See more example given below;

(from url) blog/about-author?page=1  -> (to url) blog/about-author
(from url) blog/about-author?page=2  -> (to url) blog/about-author
(from url) blog/about-author?page=3  -> (to url) blog/about-author

Any suggestions to give me solution to fix this issue?


texts: Automatic Nodetitles IF php statement in between other tokens in title

texts:
I have an automatically generated title of an address with an if empty statement in the middle of the other tokens:

[node:field_street], [node:field_number],
<?php
$floor= '[node:field_floor]';
$ground = '[node:field_ground_floor]';
if (empty($floor)) { return $ground; }
else
{ return ' Floor '.$floor; };
?>,
[node:field_location_address:postal_code], [node:field_location_address:city]

but the token after the php statement is not displayed. If I put the php statement at the end after all other tokens, everything is displayed. What am I doing wrong?


texts:
Custom twig template is just this:

  {% for product in products %}

{{ product.title }} Image {{ product.description }}

  {% endfor %}

My custom module sends an array of products, which are something like this

array(1) { [0]=> array(3) { ["title"]=> string(9) "Product 3" ["image"]=> string(56) "/sites/default/files/2019-11/128px-Small_Storage_Box.png" ["description"]=> string(22) "Description 3" } }

And I am sending it from a controller like this:

return array(
  '#title' => t('Return products list'),
  '#products' => $products,
  '#theme' => 'return-products',
);

In my .module file I've defined hook as:

<?php
function return_products_theme($existing, $type, $theme, $path) {
  return array(
    'products' => [
      'variables' => [],
    ]);
}

I know data is there in an array, it just doesn't go inside twig template. Even if I type some Test it won't be shown.


texts: Unable to delete file from node in drupal 7 using services

texts:
I want to delete a file from android app. I am hitting this url (mysite/endpoint/file/fid) with DELETE method and I get following response:

1

The response comes with 200-ok  status but file has not been deleted.

Anyone who knows please let me know what is the problem.
Thanks


texts: Add an attribute to $variables from a Controller

texts:
I need to add an attribute to the body tag from a controller. Adding a body tag with hook_preprocess_HOOK() is not a problem.

/**
 * Implements hook_preprocess_HOOK().
 */
function MY_MODULE_preprocess_html(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'my.route') {
    $variables['attributes']['class'][] = 'my-class';
  }
}

However, I only want to add the attribute when the node object, which is already in the controller, meets a second condition which is:

if ((\Drupal::routeMatch()->getRouteName() == 'my.route') && ($this->moderationInformation->hasPendingRevision($node))) {}

I don't have $variables in the controller so how can this be done?


texts: How to get the contents created by a User?

texts:
How to get all contents from which the current user is author?
 $currentUser = \Drupal::currentUser();
 $user = User::load($currentUser->id());
//get the contents from which $user is author?


texts: Fields are rendering white space at either side

texts:
I am rendering my node fields using:

<?php print render($content['field_website_link']); ?>

On the front end this is printing as:

Visit Website →

For some reason it is adding the same whitespace around the rendered field. The field format is plain text and their is no whitespace in the actual field. This is the same for all text fields.

Any ideas?

Thanks Robert


texts: How to hide specific fields and the according label in a view, based on field permissions?

texts:
I have a view called Profile that displays some of the user fields. Amongst these is a Name field (field_name). I'd like to hide this field except for the administrator and the user himself/herself. I installed the Field Permissions module, wich nicely gives me the opportunity to mark the field as private. When this is checked, the Name's value disappears in my Profile view, but the according label is still there - and that's not very nice.

How can I hide the label aswell?


texts:
Using Drupal I need to recreated node that only display title and body.

Why ? I want to used my theme as e-mail template without re-creating a website manually. So I have to remove any menu, block, header, footer that is display it. Every time a new article is done they can export the page using their drupal theme but only showing the title and body to be send in an e-mail.

Any idea how to do this ?


texts: How do I make the output of a View a particular Field?

texts:
Right now my View is outputting a list of Nodes by their title. I've added a 'subtitle' field to these node's Content Type and I would like to use this as my outputted result instead.

I've gone to the 'Fields' section of my View but cannot find my newly added Content Field among the options there (have cleared cache and rebuilt registry).

Would anyone know how to achieve this?

(ps: why is it called 'Views'? Wouldn't 'Queries' be more accurate?)


texts:
I created an entity via Entity Construction Kit, Initially I wanted to use rules to create the new entity but the entity is fielded and the fields don't get exposed in rules (as of now, someone is trying to work on a patch for that), but in the interm I wanted to write a simple function that creates a entity, which I assumed would be somewhat like creating a node programmatically, but I've been at this for like 4 hours and I haven't gained an inch, I have entity_create and entity_save but they don't do much and I can't find any documentation on it.

What I'd like to see is how to create an example entity from a bundle made with eck, or through code, that is fielded.

Thanks so much

Edit: The last thing I need to figure out is how to specify the name of the fields that are attached to the entity so I can enter values for those as well.

$values = array('uid' => 1, 'field_receipt_prod_ref' => 1, 'type' => 'receipt');
$new_ent = entity_create('receipt', $values)->save();


texts: I have a views with 6 images per page. When I click on image lightbox shows only those 6 images on current page. I want lightbox to show all images of current node, how can I do this?


texts: I want to migrate Webforms from one environment to another, how should I got about?

texts: We have developed a couple of webforms on a development environment, which we now want to transfer to test. How can I tackle this other than retyping the form?


texts: Sending HTML email replies using Webform in Drupal 7

texts: How can I get Webform to send an HTML-formatted email?


texts: Controller is loading twice after search form is submitted

texts:
I created a custom module that I consume an external api. I have also created a custom form (its action points to controller url) which filters the data. However, when I press the search button and the controller is loading, despite I get the right results immediately the controller is reloading and consequently I loose the filtered results.
How I can stop this behaviour?
This is my code so far:
  public function submitForm(array &$form, FormStateInterface $form_state) {

    $ada = $form_state->getValue('ada');
    $sector = $form_state->getValue('sector');
    $sub_sector = $form_state->getValue('sub_sector');

if ($sub_sector=='') {
  $subject_unit=$sector;
} else {
  $subject_unit=$sub_sector;
}

    $datefrom = $form_state->getValue('datefrom');
    $dateto = $form_state->getValue('dateto');

    $params=[
    'type'=>$subject_unit,
    'datefrom'=>$datefrom,
    'dateto'=>$dateto,
    'freetext'=>$freetext,
    'ada'=>$ada
  ];

}

controller:
class DiafaneiaController extends ControllerBase {

  public $filters=[];

  public function getList(Request $request) {

    $filters = \Drupal::request()->request->all();

    $data = array();
    $response = $data = $result = null;

    $page = pager_find_page()+1;
    //echo 'pageNo:'.$page;

    if (function_exists('diafaneia_reponse')) {
      $response = diafaneia_reponse('https://diafaneia.hellenicparliament.gr/api.ashx?q=documents&pageSize=20&pageNo='.$page.'&sector=0216896c-4d26-49de-b896-a2b600ab3843', 'GET',$filters);
    }

    if ($response) {

      $result_docs = json_decode($response);
      $data = array();

      // # add all the data in one multiple dim array
      $data['title'] = 'products to consume REST API';
      $data['docs'] = $result_docs;

$num_per_page = 10;
$offset = $num_per_page * $page;

// Now that we have the total number of results, initialize the pager.
pager_default_initialize($result_docs->TotalRecords, $num_per_page);

$render = [];
$render[] = [
  '#theme' => 'diafaneia_list',
  '#data' => $data,
  '#type' => 'remote',
];

$render[] = ['#type' => 'pager'];

    }
    return $render;
  }


texts:
I am using Drupal 7.12 and are missing the field type "integer". I only have the fields

Boolean
List (Text)
List (Float)
LIst (Integer)
Long Text
Long Text and Summary
Node Reference
Text

Maybe I am overseeing here something very basic, but it should be there AFAIK.

Thx for help,

n3rd


texts: How do I store my client's passwords securely and make them retrievable?

texts:
I am building a site that holds information about my client's computers. One piece of information I want to store is the password for an account on each computer. I want my authenticated users to be able to log on to my site and, if they have the right permissions, be able to see these passwords (maybe by clicking a 'show password' button).

The problem with this is that I can't store just the hashed versions of these passwords in the database because obviously then there is no reliable way of getting them back to plaintext, and I don't want to store the passwords as plaintext in the database either (unless access to this part of the database is strictly password protected by my authenticated user's passwords, which I don't know how to implement), so I was wondering if anyone has any suggestions of securely providing this functionality?

Making the passwords secure and retrievable in Drupal seems mutually exclusive to me so if anyone knows of any external services that might work then I would be very interested in hearing about them as well.

I am using Drupal 7.41.


texts: How to render random image on every refresh page

texts:
I have got a content type and an image field.

How can I render the field with a random image at every page refresh.


texts: How can I add an entity reference to a list entity refences of a node with rules?

texts:
I have a node with a entity reference field with multiple values.

How can I add an entity reference to a this list with rules?


texts: How should I configure the wysiwyg filter to align the images?

texts:
This is how my configuration in the wysiwyg filter looks like (in Drupal7):

a[!href|target<_blank|title],
img[src|align<bottom?left?middle?right?top|alt|border|class|height|width|float],
div[align<center?justify?left?right],
p[align<center?justify?left?right],
br,span,em,strong,cite,code,blockquote,ul,ol,li,dl,dt,dd

However my configuration does not work for aligning images.

I have reviewed my code and the alignment is done using the "style" tag:

<img src="" alt="" style="float:right" />

I tried the following configuration for the image but that does not work either:

img[src|align<bottom?left?middle?right?top|alt|border|class|height|width|float|**style**],

Here is another attempt that did not work:

@[style]

And I also tried like so:

img[*],

Another attempt is what is detailed in this alternative: http://screencast.com/t/jUOwMxmpu

So what is the right configuration for the images to be aligned? What is my error?


texts: Filter by specific field when webform exports

texts:
I have a webform with a field_custom field. I need to download the submissions filter by this field.
I saw in the download page this:

Can I do the same programmatically with a plugin or something else to filter by my field(field_custom)?


texts:
I got a multilanguage configuration with language detection based on URL(/en /fr). Drupal behavior redirects everything to so it would have those two prefixes or, if setup, it will ignore the prefix for a language while keeping for the other.

In my situation I need to keep the prefix for both language except for root page.

Ex:

example.com/en -> will load english homepage
example.com/fr -> will load french homepage
example.com/ -> has to load english homepage but without redirect to /en

So, how can this be achieved?


texts: Add role to user after joining organic group with rules

texts:
I'm trying to add a user role to a user who has become a member of a group. The workflow is like this:

User requests to join group.
Request is approved by group administrator.
User is a member of the group.
User gets an additional role.

I've tried to make a rule which would be able to do this, but although all the settings seem correct after joining the group the user doesn't get the additional role. See below a screenshot of my rule settings:


texts: Let users choose from pre-defined user set options for creating a node

texts:
I want to provide the ability for users to make and save a set of pre-defined options when they create a node.

They can then choose from their predefined set of options when creating future nodes.

(At the moment I allow users to create nodes with a custom form, I could possibly switch to the standard add node method but I'd prefer not to, unless it's a lot easier.)

Has anyone on here tried this before? At a high level, how did you go about trying to save user presets?


texts: Is there a ready made gruntfile available for Drupal Bootstrap Child Theme (SASS)

texts:
This applies to Drupal 7.

I am fairly new to grunt and can't really make much sense of out of a gruntfile. I've just started with a drupal child theme (which has been created off bootstrap SASS startkit).

Can you point out a readymade grunt file which I can use to watch and compile my scss (output as css) and minify js.


texts: Lost setting of the custom field when editing a page

texts:
I created a content type with my own custom field as described in Why do I get this error when I save my custom field?

The insertion of an item with this content type works, but when I want to modify the article I verified that I lose my custom field setting (it's a select box).

What is the method to keep the setting?


texts: What's the best way to theme a content type? Is there an effective way? Can I just use my page template, resave it with a different name and do it that way?


texts:
The issue I am having is that when I try to preview the content of a node I have created by clicking the 'Preview' button the page just refreshes and the preview.

What I have tried

Looking into permissions to do with viewing unpublished content.


texts:
I am using Drupal 8 and want to use custom query to get details like below:

$db = \Drupal::database();
$query = $db->select('sinica_grade_summary','sgs');
$query->fields('sgs', ['id', 'coursename', 'average', 'grade', 'term', 'schoolname']);
$query->condition('sgs.uid', $id, '=');
$query->groupBy("sgs.coursename");

Getting this error :

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1055 'lmhd8.sgs.id' isn't in GROUP BY: SELECT sgs.id AS id, sgs.coursename AS coursename, sgs.average AS average, sgs.grade AS grade, sgs.term AS term, sgs.schoolname AS schoolname, COUNT(sgs.id) AS count FROM {sinica_grade_summary} sgs WHERE (sgs.uid = :db_condition_placeholder_0) GROUP BY sgs.coursename ORDER BY id DESC LIMIT 11 OFFSET 0; Array ( [:db_condition_placeholder_0] => 28 ) in Drupal\resume\Controller\ResumeController->sinica_academic_detail()

I used mariadb10, there is no sql_mode been used

mysql  Ver 15.1 Distrib 10.1.13-MariaDB, for osx10.11 (x86_64) using readline 5.1

MariaDB [(none)]> SELECT REPLACE(@@SQL_MODE, ',', '\n');
+--------------------------------------------+
| REPLACE(@@SQL_MODE, ',', '\n')             |
+--------------------------------------------+
| NO_AUTO_CREATE_USER
  NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+

Here is table structure

    CREATE TABLE `sinica_grade_summary` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(10) unsigned NOT NULL,
  `studentid` int(10) DEFAULT NULL,
  `courseid` int(10) DEFAULT NULL,
  `leadcourseid` int(11) DEFAULT NULL COMMENT '对应 courseid 关系',
  `coursename` varchar(64) DEFAULT NULL,
  `teacher` varchar(64) DEFAULT NULL,
  `teacher_email` varchar(32) DEFAULT NULL,
  `average` varchar(64) DEFAULT NULL,
  `grade` varchar(64) DEFAULT NULL,
  `status` varchar(64) DEFAULT NULL,
  `createtime` int(11) DEFAULT NULL,
  `markingperiodid` int(11) DEFAULT NULL,
  `durationid` int(11) DEFAULT NULL,
  `term` varchar(64) DEFAULT NULL,
  `gradelevel` varchar(32) DEFAULT NULL,
  `schoolname` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sinica_uid` (`uid`),
  KEY `sinica_term` (`term`) USING BTREE,
  KEY `sinica_subject` (`coursename`)
) ENGINE=InnoDB AUTO_INCREMENT=623 DEFAULT CHARSET=utf8mb4 COMMENT='The data table for user entities.';

How to fix this problem?


texts: Adding markup to fields in block plugins

texts:
I'm attempting to create a block plugin that renders nodes retrieved from a query. I'm able to successfully get the node id's and field values from the query but I'd like to wrap each item in divs and classes but I'm not sure where to start.

public function build() {
    $query = \Drupal::entityQuery('node')
        ->condition('type', 'blog_post')
        ->sort('created', 'DESC')
        ->range(0,3);

    $nids = $query->execute();
    $build = [];

    foreach ($nids as $nid) {
        $node = Node::load($nid);
        $build[] = $node->field_image->view();
    }

    return $build;
}

This is able to render a list of images. But I'd like to be able to have control so I can output something like

Body Text

Body Text 2

Body Text 3

Instead of what Drupal wants to output automatically from the view() function.


texts: How do I modify the individual links on comments (reply, delete, any others I add in Flags, etc...)?

texts:
I'm in my sub theme's comment.tpl.php, and I have print render($content['links']) - how do I access the individual links within that?  I tried doing a print_r to see if it was a bunch of nested arrays - it appears it is(?) - but I can't seem to dig into those arrays to get the individual links?  I tried $content['links']['comment']['#links']['comment-reply'] for example (based on the structure returned form the print_r) to get just the reply link, but I get nothing.

Ultimately what I'm trying to do: Due to various modules and some flags I have 5 links on every comment: reply, delete, edit, flag, and like.  I want to group edit, delete, and flag (and any other future miscellaneous) into a little dropdown menu at the top of the comment.  Then put reply and like in individual styled buttons at the bottom.  I was planning to just handle the menu and buttons using Bootstrap since that's my theme base, but I can't "get to" the individual links to add the classes and markup I need.  Additionally I want to change the displayed text, capitalize Reply for example and add some inline icons for edit, delete, etc.

I've come across theme_links, but that page is over my head.  Sounds like maybe I need to understand this?  If so I don't even understand where to start to apply it - I searched across all files in my base theme (Bootstrap) and found nothing with that name to start from?

Where and how should I be trying to do all this?


texts: Why ajax form submit stop working after set form submit #id?

texts:
My question is related to https://drupal.stackexchange.com/questions/98501/why-ajax-form-doesnt-work-after-paging-by-views-infinite-scroll

I try to do workaround by setting my own submit button id.

   $form['mymodule_submit'] = array(
      '#type' => 'submit',
      '#value' => $value,
      '#ajax' => array(
        'callback' => 'mymodule_like_form_ajax',
      ),
      '#attributes' => array(
        'class' => array($class),
        'id' => 'mymodule-like-form-' . $node->nid),
      )
   );

But in this case ajax submit doesn't work at all...
What am I doing wrong here?


texts: Page manager, Panels and theme suggestions

texts:
Page manager and theme suggestions

I have two types of layout

custom_2col_brick
custom_1col_landing

and I need to render the page according to the selected layout.
basically, I needed two page template for each layout. something like the following:

page__custom_2col_brick.html.twig
page__custom_1col_landing.html.twig

Is there a way to do this?

In Drupal 7 I could do it as follows, but panels_get_current_page_display is not working in Drupal 8

/**
 * Implements hook_preprocess_page().
 *
 * @see page.tpl.php
 */

function THEME_preprocess_page(&$variables) {

    if (module_exists('ctools') && module_exists('page_manager')) {
        $display = panels_get_current_page_display();
        $layout = (isset($display->layout)) ? $display->layout : false;

        /* layout e.g column_one_fluid, column_three_fluid etc. */
        $fluid   =  $layout ? preg_match("/\s*.+_fluid$/", $layout) : false;

        /* layout e.g column_one_landing, column_three_landing_fluid etc. */
        $landing =  $layout ? preg_match("/\s*.+_landing$|\s*.+_landing_fluid$/", $layout) : false;

        $variables['page_fluid'] = ($fluid) ? true : false;
        $variables['page_landing'] = ($landing) ? true : false;

        if($fluid) {
             $variables['theme_hook_suggestions'][] = 'page__fluid';
        }
        if($landing) {
            $variables['theme_hook_suggestions'][] = 'page__landing';
        }

    }


texts: How do I change the base URL to use a more user-friendly domain?

texts:
I want to change my domain name from reallylongandnotuserfriendly.example.com to you.example.com.

Is there a setting that could expose these change to the public, without actually changing the real domain name?


texts: Access multivalued field collection tokens in webform email

texts:
I tried this token [webform_submission:source-entity:field_campaign_email_collaterals] but this results in following html

field_campaign_email_collaterals 0 (Edit|Delete),
field_campaign_email_collaterals 1 (Edit|Delete),
field_campaign_email_collaterals 2 (Edit|Delete)

How can I get actuall value of this field collection, or else if there is any way to get individual field inside this field collection?


texts: Call Drupal behaviour when AJAX form is submitted?

texts:
I have a form with an AJAX callback. I need to run some JavaScript when the form is submitted. Ive got this working by following the tutorial below:

http://www.jaypan.com/tutorial/calling-function-after-ajax-event-drupal-7

However I already have a JavaScript file in the module and I would prefer to put my code in there. This file is loaded on page load so I think I would need to listen for an event and run when this was detected. Can I use the AJAX callback to trigger an event thats within a Drupal behaviour?

function after_ajax_form($form, &$form_state)
{
    // First we create a form element with AJAX enabled
    $form['ajax_example'] = array
    (
        '#type' => 'select',
        '#title' => t('Change me'),
        // Note that I am setting the value and the display of the elements to be the same, for convenience sake in our callback function
        '#options' => array(t('Select something') => t('Select something'), t('Something selected') => t('Something selected')),
        '#prefix' => '
',
        '#suffix' => '
',
        '#ajax' => array
        (
            'callback' => 'after_ajax_ajax_callback',
            'event' => 'change',
        ),
    );

    // Next we add our JavaScript file, named after_ajax.js. This file
    // lives in the /js folder inside our module:
    $form['#attached']['js'] = array
    (
        array
        (
            'type'  => 'file',
            'data' => drupal_get_path('module', 'after_ajax') . '/js/after_ajax.js',
        ),
    );
    return $form;
}

function after_ajax_ajax_callback($form, &$form_state)
{
    // First, we initialize our $commands array. This array will
    // contain each of the commands we want to fire for our
    // #AJAX callback:
    $commands = array();

    // Next, we create our insert function that will insert our updated content
    // back into the page. To do this, we use the system provided
    // ajax_command_html() function. We pass this function two values:
    // 1) Our AJAX wrapper (that we defined as the #prefix and #suffix of our form element)
    // 2) The rendered HTML that needs to be inserted into the wrapper in the page.
    $commands[] = ajax_command_html('#after_ajax_element_wrapper', render($form['ajax_example']));

    // Next, we will use the system provided ajax_command_alert() function as an example to show it's
    // working:
    $commands[] = ajax_command_alert(t('ajax_command_alert() is working'));

    // Next we will include a custom function that we will call ourselves in our JavaScript file:
    $commands[] = array
    (
        // The command will be used in our JavaScript file (see next section)
        'command' => 'afterAjaxCallbackExample',
        // We pass the value that the user selected in the select element to our
        // JavaScript function:
        'selectedValue' => $form_state['values']['ajax_example'],
    );

    // And finally, we will return all of our commands to the system to be executed:
    return array('#type' => 'ajax', '#commands' => $commands);
}

(function($, Drupal)
{
    // Our function name is prototyped as part of the Drupal.ajax namespace, adding to the commands:
    Drupal.ajax.prototype.commands.afterAjaxCallbackExample = function(ajax, response, status)
    {
        // The value we passed in our Ajax callback function will be available inside the
        // response object. Since we defined it as selectedValue in our callback, it will be
        // available in response.selectedValue. Usually we would not use an alert() function
        // as we could use ajax_command_alert() to do it without having to define a custom
        // ajax command, but for the purpose of demonstration, we will use an alert() function
        // here:
        alert(response.selectedValue);
    };
}(jQuery, Drupal));


texts: How do I load a library using xautoload and libraries?

texts:
I am trying to load the facebook SDK (drupal 7) but I am getting the error

Error: Class 'Facebook\Facebook' not found in
FbPageSyncProcessSubmission::fbpagesync_facebook_sdk_initialize() (

My method

First download the facebook api  Facebook API as recommended

cd web/sites/all/libraries
mkdir fbpagesync
composer require facebook/graph-sdk

Install xautoload

drush dl xautoload && drush en -y xautoload

In my custom module declare the library

function fbpagesync_libraries_info() {
  return [
    'fbpagesync' => [
      'name' => 'PHP SDK for Facebook APIs',
      'vendor url' => 'http://developers.facebook.com/',
      'download url' => 'https://github.com/facebook/php-graph-sdk/master.zip',
      'xautoload' => function ($adapter) {
       $adapter->composerJson('composer.json');
     },
      'path' => 'vendor/facebook/graph-sdk/src/Facebook',
      'version arguments' => [
      'file' => 'vendor/facebook/graph-sdk/src/Facebook/Facebook.php',
      'pattern' => "/const VERSION = '([\d.]*(?!-dev$))/",
      'lines' => 60,
    ],
  ],
  ];
}

It looks OK in libraries_load/libraries_detect

array (
 'name' => 'PHP SDK for Facebook APIs',
 'vendor url' => 'http://developers.facebook.com/',
 'download url' => 'https://github.com/facebook/php-graph-sdk/master.zip',
 'xautoload' =>
   Drupal\xautoload\Libraries\SerializableClosureWrapper::__set_state(array(
   'closure' =>
   Closure::__set_state(array(
  )),
 'moduleName' => 'fbpagesync',
 'libraryName' => 'fbpagesync',
)),
'path' => 'vendor/facebook/graph-sdk/src/Facebook',
'version arguments' =>
  array (
  'file' => 'vendor/facebook/graph-sdk/src/Facebook/Facebook.php',
  'pattern' => '/const VERSION = \'([\\d.]*(?!-dev$))/',
  'lines' => 60,
 ),
'info type' => 'module',
'module' => 'fbpagesync',
'machine name' => 'fbpagesync',
'download file url' => '',
'library path' => 'sites/all/libraries/fbpagesync',
'version callback' => 'libraries_get_version',
'files' =>
array (
),
'dependencies' =>
array (
),
'versions' =>
array (
),
'integration files' =>
array (
),
'callbacks' =>
array (
  'info' =>
array (
  0 => 'libraries_prepare_files',
),
'pre-detect' =>
array (
),
'post-detect' =>
array (
  0 => 'libraries_detect_dependencies',
),
'pre-dependencies-load' =>
array (
),
'pre-load' =>
array (
),
'post-load' =>
array (
),
),
'post-load integration files' => false,
'installed' => true,
'version' => '5.6.3',
'loaded' => 0,
)

The calling code is

use Facebook\Facebook;

...

public static function fbpagesync_facebook_sdk_initialize($reset = FALSE) {
 $settings = variable_get('fbpagesync_settings', []);
 $facebookInit = new Facebook([
    'app_id' => $settings['app_id'],
    'app_secret' => $settings['app_secret'],
    'default_graph_version' => 'v2.2',
  ]);
}


texts:
I using image field with insert module to upload image.
After select an image and upload, I press "insert".
The image appears in body but the script of image doesn't have class "caption".

<img src="/sites/default/files/apple.jpg" title="Some description image here" height="260" width="500">

How do I add class "caption" into image?


texts: How to access values from earlier steps in multi-page Webform?

texts:
I'm using Webform 4. It uses Drupal's tokens, not it's own % tokens like it used to in version 3, and pretty much all what I found was about webform 3.

Say I want to make multi-page subscription form. On first page there is only an email field. On second one, I want a markup that will say something like:

  Detailed subscription configuration for molot@example.com

Similarly, I'd like to be able to use them as default values for future fields, like asking user for billing address, and then for delivery address.

Are there any tokens for that? What I did for now is:

function mymodule_token_info() {
  $type = array(
    'name' => t('Webform submitted values'),
    'description' => t('Tokens related to $_POST[\'submitted\'].'),
  );
  $tokens = array();
  if(isset($_POST['submitted'])) {
    foreach($_POST['submitted'] as $key => $val) { //discard $val now
      $tokens[$key] = array(
        'name' => $key,
        'description' => "\$_POST['submitted']['$key']",
      );
    }
  }
  return array(
    'types' => array('webform_submitted' => $type),
    'tokens' => array('webform_submitted' => $tokens),
  );
}

function mymodule_tokens($type, $tokens, $data, $options) {
  if($type == 'webform_submitted') {
    $replacements = array();
    foreach ($tokens as $name => $original) {
      //Hide errors below. We don't care if it really exists yet. If empty, so be it.
      @$replacements[$original] = (string)$_POST['submitted'][$name];
    }
    return $replacements;
  }
}

It works, but it only shows values from one step earlier, so requires some dirty tricks with hidden fields to carry email value across multiple steps. I admit - it was just quick and dirty. Is there any built-in way to do it, or properly maintained contributed module for this? Or a way to make this code work independently of $_POST['submitted'], to make it carry values across many steps and to make it's tokens (from available Webform elements) visible on token list in edit windows?


texts: Access Denied on Drupal 8 image styles despite correct permissions

texts:
I have a functioning D8 site that has recently started displaying odd behaviour. Image styles are no longer generating correctly.

The sample.png used in the image styles config page generates fine (including if I delete the file manually from the image styles dir).

I have recursively set 0775 (dirs) and 0664 (files) to the entire sites/default/files directory, but the error persists. Error log just shows "access denied" - nothing more informative.

Drupal version is 8.1.9.

Any ideas? The site looks pretty lame right now!


texts: How can I install composer packages with drush make?

texts:
How does one include composer package in a drush make file?

The more general answer, the better. There's already a composer drush module allowing drush dl to handle composer packages, but that requires a shell command for every dependency.

Given our future use of Symfony, composer and other Symfony bundles is likely to become more important in the future.


texts: How to Use Exposed filter of Taxonomy term with depth in Taxonomy View

texts:
I have a question which is similar to How to use taxonomy terms(with depth) on a views exposed filter?

But problem in my case is that I am using views of type Taxonomy, here I don't get option in Filter "Taxonomy Term: Has content with depth".

I have my Taxonomy like :
-Country
  -State 1
    -City 1
    -City 2
    -City 3
  -State 2
    -City 4
    -City 5
    -City 6

I want exposed filter which has 3 select boxes like : -Country- -State- -City-
- State and City boxes fillup by Ajax based on Country selected.

Then the view should be updated based on the selected filters.
i.e If I select State 1 then I should get results of all the Cities below it and even of State 1.

Please note that I am not using View of type content, My view type is Taxonomy.

Can anyone suggest me how should I get this working?

Thanks in advance!


texts: How to migrate content edits in Drupal from staging to live environment

texts:
I have stagging environment where I used to add and update contents first and than move it to live site once the changes passed by the QA.

I can't use the backup and migrate module because of the larger size of the database.

Also can I make the process automatic so that every day I won't need to manually migrate the content from stagging site to live site.


texts: How to use url alias in views for taxonomy terms?

texts:
On a Drupal 7 site with pathauto installed I'm using a view to show all taxonomy terms of a given node. The terms are linked to the term's page. The problem is, that the path of those terms does not use the url alias' that are set for the terms. Is there a way (without programmatically rewrite the view) to use alias in a view?

I know about the globalredirect module, but a redirect is not a clean solution here, in my opinion. And I do not understand why the pathes aren't replaced by there aliases in a view, can someone explain please?


texts: Can "drush make" command use cached temporary files?

texts:
With Drush 6.2.0, after using

$ drush make build_my_project.make my_project/

more than once, it results in

  ..
  Found makefile: drupal-org.make
  Install location /private/tmp/make_tmp/profiles/openhotel/modules/contrib/omega_tools already exists. Do you want to overwrite it? (y/n): y
  omega_tools-7.x-3.0-rc4 downloaded.    ...

which means the module already exists in

  /private/tmp/make_tmp

I tried to force assuming no to all questions

$ drush make build_my_project.make my_project/ --no

which doesn't work, it still answers yes to all questions. How can I avoid downloading all projects every time I make a build?


texts: How can I save arrays of values in the database?

texts:
I am trying to save multiple values from a textarea to a database table.

I use the following code, but I feel it is the wrong way.

foreach ($user_emails as $key => $value) {
  $insert_banned_emails = db_insert('banned_users');
  $insert_banned_emails
    ->fields(array(
      'email' => $value,
    ))
    ->execute();
}

Is there a different way for achieving the same result?


texts: How do I count the number of items of same product class in cart?

texts:
I'm a newbie to PHP, I and can't figure out how to do this.

I'm trying to alter the  price of each items depending on the quantity of the items of same product class in the cart. Let's say I have a product class "fruit" and 10 items like "apple" ,"orange", "banana" and so on. And no matter which combination, I would like to make the first item $10, the second one $0, the third one $0. So I tried this code by using UC Custom Price but doesn't work.

$firstPrice = 10;
$secondPrice = 0;
$thirdPrice = 0;

if ($item->qty = 1) {
  $item->price = $firstPrice;
}
elseif($item->qty = 2) {
  $item->price = $secondPrice;
}
elseif ($item->qty = 3) {
  $item->price = $thirdPrice;
}

It obviously seems that $item->qty is the quantity of a single item (the same node).  So how can I call do this with the number of the items of this product class "fruit "in the cart?  $item->price is the final price which will be used.


texts: Simple way to add a class to the body when creating/editing an entity

texts: In Drupal 8.4, I am trying to add a class to the body (like Drupal 7 had) when the page viewed is a node (or entity for that matter), something like [entity]-[create or edit], so that, when a user is editing or creating a node, a class like page-node-edit gets added to the body classes array.


texts: Where is the code that filter web and email addresses into links?

texts:
Under full html, drupal states: "Web page addresses and e-mail addresses turn into links automatically."

I'm curious to know where this behaviour is coded and how I would hook into it if I need to modify it slightly


texts: Best Practices? Create dynamic links with static titles on node full view page

texts:
As with anything drupal, there are a million different ways to do something. I am asking this question for 1) Because I actually have to do something similar and 2) Because I would like to know all the different ways this could be achieved and the pros and cons of each. Is creating a custom field the way to go or should you just dump some dynamic code in the node-album.tpl.php template? Which way is the most flexible? Which is the most non-coder friendly?

Scenario: You have two content types (say, photo and album) where photo has a file field for an image and album is a collection of photo nodes.

If a user is viewing an album node type, how would you go about creating a "add photo" link on the full node view to add a photo to that specific album? Using the entity reference prepopulate module.

So how would you give users a way to click on a link/button for:

http://www.domain/node/add/photo?field_album_reference=[node:nid]


texts: Dynamically generated radio buttons share name

texts:
foreach ($questions as $question_index => $question) {

      $form['questions'][$question_index]['answer'] = [
        '#type' => 'radios',
        '#title' => '',
        '#default_value' => 1,
        '#options' => $options,
      ];

    }

I am generating a form like this, but the radio buttons share the same name. I find that weird since I am wrapping it in a dynamic wrapper.

I know that I could add something along: [$question_index]['answer_' . $question_index]

But, is it possible to make it rely on the grouping/container instead?


texts: How do I name a mimemail-message.tpl.php template to be used with a specific webform?

texts:
I cant seem to get the naming of the mimemail-message.tpl.php correct in Drupal 7. I know the naming scheme says "mimemail-message--[module]--[key].tpl.php" but either I'm not understanding what the brackets represent or I'm doing something else wrong.
I've tried:
mimemail-message--webform--mywebformname.tpl.php
mimemail-message--webform--250.tpl.php

Just mimemail-message.tpl.php works, but I need different template layout depending on which webform is used.
Also, is mime mail not supposed to make use of webform-mail-250.tpl.php at all?


texts: Getting the auto summary from a node body

texts:
I load an Article node with node_load() and I'd like to get the summary for the Body field. I know that I can access it with $node->body[$node->language][0]['summary'] but unless the user explicitly adds a Summary Body, then this field is empty.

I know that drupal will automatically generate a "trimmed body" if they don't add a Summary Body. How can I access that trimmed body?

EDIT:

I'm not interesting in render()ing the content, I just want the text. My module is generating a json feed for an external source.


texts: Modify Drupal's search to show custom fields

texts:
I have some fields (say, pictures or whatever) in my custom content-type and I want them to appear in search results. How do I do that?

I know how to edit template files such as search-result.tpl.php provided by the search module. In this page, there is a single variable called $snippet which contains search result but as a rendered HTML output. How do I modify it/show my custom fields in search results?

I would like to have full control to contents of the files, rather than just rendered HTML for them. My Search display page requires customization a lot, so without getting each field individually, I won't be able to produce desired output.


texts: How can I promote content by number of hits (reads)?

texts:
I would like to create some kind of an algorithm to my website like Reddit might have or even other websites. The algorithm, probably powered by the Rules module, should be able to promote content to the front page by number of hits (reads or visits), or comments a node receives.
I can't seem to find any solution with the Rules module. Any help?!


texts: Can't install modules in a sub site --- Seeing Ajax error

texts:
Background

I have a Drupal 7.38 folder subsite (i.e yoursitesname.com/test). The site was installed with softaculous, and has only few core modules enabled. When I come to install the last version of Views, or alternatively, References, I get this error:

You can see from the first screen that the error tells me to continue to the "errors page" and this is what I see when I continue

Already tried and didn't help

Some of the solutions were found in Google search:

Flushed all caches.
Installing from a downloaded file, instead of a link in Drupal.org.
giving 755 permissions to all the homefolder files (including .HTaccess and all files in sites/default folder).
Changing PHP version for main folder (i.e yoursitesname.com) from PHP 5.3.29 to PHP 5.5.26

Any suggestions?


texts: How to relate the user table with the fboauth table to show up who's logged in through fb?

texts:
I have created a view which shows up the user details like username, email, active(user), accepted challenges in a tabular format. Now i want to include a column to it which shows up the users who uses their fb account to login to the website.I have used fboauth module to allow users to login to the website through their fb account and i am unable to add a relationship which relates the users table and the fboauth table. Can anyone suggest me a way to resolve this?

I am using drupal 7


texts: How do I migrate the content of a specific type?

texts:
I wanted to backup all the contents of specific content type, and I want to install those data in different machine. Can anyone suggest me some good module which could help me do this?

I have tried the Backup module, and the Migrate module, but they back up the entire database. I want to backup specific contents alone but I couldn find any modules to do that.

I could use either the Node Export module or the Feed module to back up specific content. Node export gives various options like you can export the data to CSV, XML or in text format which can be then imported using node import.


texts: Delete original image after uploading and generating image styles

texts:
I need to delete the original image file after it has been used as source for generating the defined image styles. I'm fine with the generated images and want to delete the original because of space issues.

I could imagine a drush or cron job which periodically deletes the originals, but I think that would have some negative implications.

Any cleaner solution?


texts: In D6, how can I hide a block from users who have submitted a certain webform?

texts:
I am doing a survey and have created a block to display a notification to site visitors to ask them to click a link to answer the survey. I want the notification to show up on all pages until they answer it. But once they've answered the survey, I'd like to hide it. Below is the code I am using now. What do I need to add? Thanks much! :)

Along the way, if there is a better way to set these alerts, let me know.

Cheers,

Tobias

<?php
drupal_set_message('
Click here to complete a brief survey
', 'sticky error');
?>


texts: How to circumvent #lazy_builder callback error

texts:
In a node_form_alter() hook, I am trying to add comments + comment form at the end of the node edit form by using the following code:
$node = $form_state->getFormObject()->getEntity();
$form['comment_ui']=$node->get('field_comments')->view();

But I endup with the following error message:
DomainException: When a #lazy_builder callback is specified, no properties can exist; all properties must be generated by the #lazy_builder callback. You specified the following properties: #tree, #parents, #array_parents, #processed, #required, #attributes, #title_display, #description_display, #errors, #id, #sorted. in Drupal\Core\Render\Renderer->doRender() (line 335 of core/lib/Drupal/Core/Render/Renderer.php).

Note: I could display the form comment alone (without the rendered comments) with the following code:
$values = [
  'entity_type' => 'node',
  'entity_id' => $node->id(),
  'field_name' => 'field_comments',
  'comment_type' => 'comment',
  'pid' => NULL,
];
$comment = \Drupal::entityTypeManager()
  ->getStorage('comment')
  ->create($values);
$form['comment_form']=\Drupal::service('entity.form_builder')->getForm($comment)


texts:
I installed tinyMCE with IMCE in my Drupal 7 site. I'm finding a way to show different buttons in tinyMCE editor by each content type. For example, the image button is displayed for the Article content type, but it will not be displayed for my custom content type.
Is there a way to set this up with the existing module?


texts:
I'm looking for a module to export/migrate a books (with all child pages) from a Drupal ( 6.x) Installation to another.

Thank you in advance for your kind replies


texts: How to wildcard cache clear in Drupal 8?

texts:
In Drupal 7, we used to be able to do this:

cache_clear_all('state:', 'cache', TRUE)

which would delete any cache bin entires that started with the string state: (matching cache IDs such as state:info and state:nebraska).

The change record at https://www.drupal.org/node/1272696 even notes this use case in the Drupal 7 example, but does not actually provide an example of how to replicate it in D8.

It seems that we're supposed to use cache tags, which seems like a more more expensive conversion considering the simple use case. I don't see any matching methods that would apply in CacheBackendInterface. Note, this is not about deleting all items in a cache bin, which is clearly covered by deleteAll().


texts: How to make an editable catalog on Drupal?

texts:
I'm trying to make something like an catalog (e.g. an address book) on my site, in which the user can interact with the fields, like adding, editing and removing entries, I'm thinking about putting each of those entries as a content type node and then using views to display and modify them... Is there any known problem with this approach? could you suggest another one?

I want it to be dynamic, on click the selected entry expands allowing for editing and automatically saves the content...


texts: Stop Mini Panels adding --1/2/3 etc to blocks

texts:
I'm using mini panels in a build and am annoyed that when using a mini panel it adds for example a --1 to the block id in the HTML which makes it really hard to style with CSS.

Is there a way to turn this off so I just get the original block ID?