texts: Start with multiple entity reference items

texts:
In Drupal 8, I have created an entity reference to an "author" taxonomy on a content type. The form display settings are set to autocomplete. By default it starts with one field and you can click "Add another item" to add more. Yet usually we are adding content with multiple authors, so to make the form more user-friendly, would it be possible to start with four fields by default?

To add clarity to the question, the field currently starts like this by default:

I want it to start like this:

Any suggestions?


texts:
I made a custom form. After submitting you are redirected to a custom page and get a message there. So far nop.

Then I made a custom block that renderw this form into a block region. Everything appears well.

However when submitting this same form, no redirection. I am on localhost and suspect that the form is not submitting in this block. After submit I see all values in the url of my page, just like the method is GET. When I check the code the method is POST, just like the original form, also Drupal added some classes which are the same as in the form.


texts: Set the value of a hidden form component

texts:
I have a Webform in drupal 7. I want to add a hidden field porgramatically to it, and I would like to set the value of this field per form.
I want to achieve all these in a custom submit function, as I want to use the sid (serial ID) of the Submission, to generate a unique ID for each Submission.
At the moment everything is working, except to set the value.
I googled it a lot, tried out hundreds of codes but non of them worked in my case.

Here is my code:

<?php
$form['#submit'][] = 'webform_custom_submit';

function webform_custom_submit($form, &$form_state) {
  if ( !array_key_exists('my_uniq_id', $form['#node']->webform['cids'] ) ){
    $components = array(
      0 => array(
        'name' => 'My Unique ID',
        'form_key' => 'my_unique_id',
        'type' => 'hidden',
        'weight' => 1,
        'pid' => 0
      )
    );
    webform_ensure_record($form['#node']);
    foreach ($components as $component) {
      $component['nid'] = $form['#node']->nid;
      $form['#node']->webform['components'][] = $component;
      webform_component_insert($component);
    }
  }
  $my_uniqe_key = generate_some_unique_key_function();
  //Here I wan't to set the value of the component 'my unique ID', but nothing worked yet
  $form_state['my_unique_id']['#value'] = $my_uniqe_key;
}

Thanks for the help, I'm sure I could find the answer somewhere, but I tried it 3hours long...

Here  is the $form and $form_state written out with dpm from my webform_custom_submit function.

And here are some codes, I tried already:

<?php
$form['values']['my_unique_id'] = $my_uniqe_key;
$form['values']['my_unique_id']['#value'] = $my_uniqe_key;
$form['values']['my_unique_id']['value'] = $my_uniqe_key;
$form['submitted']['my_unique_id']['#value'] = $my_uniqe_key;
$form['my_unique_id']['und']['0']['value']['#value'] = $my_uniqe_key;
$form_state['values']['my_unique_id'] = $my_uniqe_key;
$form_state['values']['my_unique_id']['#value'] = $my_uniqe_key;
$form_state['values']['my_unique_id']['value'] = $my_uniqe_key;
$form_state['my_unique_id']['und']['0']['value']['#value'] = $my_uniqe_key;
$form_state['values']['my_unique_id'][LANGUAGE_NONE][0]['value'] = $my_uniqe_key;
drupal_array_set_nested_value($form, array('submitted', 'my_unique_id', '#value'), $my_uniqe_key;);
form_set_value( array('submitted','my_unique_id'), array(0 => array('value' => $my_uniqe_key;)), $form_state) ;

$cid = $form['#node']->webform['cids']['my_unique_id'];
$form_state['values']['submitted'][$cid] = "static text";


texts: Deleted all the content... but it's all still there?

texts:
I wanted to start from scratch so deleted all the content from my Drupal site. Now I am getting the following error:

Notice: Undefined index: name in system_sort_modules_by_info_name() (line 949 of /Applications/XAMPP/xamppfiles/htdocs/drupal/modules/system/system.admin.inc).

Also, even though I deleted all the content, it is still appearing under the Menus. Do I need to manually remove it from the menus as well? I was hoping that deleting the nodes/content would automatically remove it from the menus...

I deleted the content by going to Administration » Content, selected all the pages/nodes and them selected the "delete selected content" option.


texts: Prevent sites from receiving modules installed by other sites in a multi-site instance

texts:
Can I prevent a site from receiving modules installed by a different site in a multi-site instance? In other words, can site A in a multi-site instance not receive a module installed by site B?

I am aware that in a multi-site instance, modules that are installed for one site is installed for other sites. For other sites to use said module, it must be enabled in its respective site. In my scenario, I do not want a module to appear at all for a given site, even if it was installed by a different site.
I am aware that configuration can take place to install site-specific modules. My question is the reverse: preventing modules for a specific site rather than installing modules for a specific site.


texts:
I wanted to add a library to a specific paragraph bundle. I know I can do {{ attach_library('my_theme/my-library-name') }} using twig, but that means I have to create a file for each bundle. The goal is to be able to use just the my_theme.theme file to add the library.

Question

How to add library to Paragraph bundle using hook_preprocess_theme?

Here is what we tried, but it didn't work even after cache clear.

function mytheme_preprocess_paragraphs(&$variables) {
  $elements = $variables['elements'];
  $paragraph = $elements['#paragraph'];
  if(isset($paragraph) {
    $paragraph_bundle = $paragraph->getParagraphType()->id();
    switch($paragraph_bundle) {
      case 'my_bundle':
        $variables['elements']['#attached']['library'][] = 'my_theme/my-library-name';
        break;
    }
  }
}


texts: I'd like some help how to clear the cache using an external script. I have a script that adds nodes each night, and I'd also like it to clear the views cache so - without having to make out by myself the MySQL query.


texts: Show original price and discounted price?

texts:
I'm using this module: Commerce Discount to create products discounts. In the products list view I'd like to show both prices: the original price and price with the discount. How can I do this?

I found this module:   https://drupal.org/project/commerce_price_savings_formatter but it doesn't seem to work with the Commerce Discount module.


texts:
Is there a way to exclude titles in bulk? I want to exclude title of several nodes all at once.

I'm using Exclude Node Title to remove node titles to the display. However, I can only edit it one by one by opening and editing each nodes.

What I want is to update nodes by bulk if possible.

Thanks!


texts: Is Drupal cache as set in the core enough for simple sites?

texts: Let's imagine a site which is almost completely static. There are news which are rarely updated and from time to time some new content in the form of more news. If there are only anonymous users apart from the admin... would the cache retrieval be so fast as simple HTML pages? I ask this because I have tested the config above with cache on and it goes very slow in comparison with HTML saved counterparts and I am not sure if it is a misconfiguration.


texts:
I placed the following function in my custom module.

function MYMODULE_node_update($node) {
  if ($node->type === 'page') {
    $node->title = 'test';
  }
}

When editing and saving a node of content type page nothing happens. What can be the issue?

Problem solved. It seemed to be caused by the following:

my custom module wasn't ending with ?> and above all my module name was custom_site.module and my hooks started with custom. This didn't give problems before with my other hooks so I never noticed. (This helped: https://drupal.stackexchange.com/a/111272/85560)

My module name now is custom.module and now custom_node_presave() works.


texts:
I have a content-type called "Member", which has four taxonomy terms.

Now in my block, i want to display entries in a different DIV for each taxonomy.

For example all items with the taxonomy "Boss" should be placed inside the first DIV, items with the taxonomy "Manager" should be placed in the second DIV, and so on..

How can i achieve this?


texts: ICalendar and Outlook opeing as node For Add to Cal Module Even After Clearing Caches

texts:
I installed the Add to cal module and enabled it.

Created a View using with fields or Event Date,Location and Title.

Thus when I added Event Date fields to the View and While Configuring i Choosed Formatter to Add to Cal.
The Add to Cal Works fine For Google and Yahoo calendar But When I choose The ICalendar or Outlook Option , corresponding node file gets open eg:- [website name]/node/207/field_date1/addtocal.ics but doesnt downloads the ics file.

I tried Clearing the Cache Varnish Cache as it hosted on the Acquia.com and also the Performance cache but that seems to not work.


texts: Setup different pager settings for same view

texts: Is there a way to display the same view with different pager configurations? For example have the same set up with 3 items for the homepage and full paged for a news list page? Thanks!


texts: & or + character in document attachment causes page not found

texts: I have a Drupal 7 implementation with clean urls implemented.  If I attempt to open a file attached to a content page that has an ampersand or a plus in the document name it causes a page not found error and the file will not open.  Any ideas on how I can resolve this?


texts: How to output data from module to a page. What are my options?

texts: I have some code in a module that returns some data. I want to output it in a particular place on the page: Would a block, ctools plugin for panels or a template file be the best option and how would I choose?.


texts:
Hi I am using #ajax in my custom form. I need a response handler function for my form in jquery. How can i acheive this goal?

For example:

$form['changethis'] = array(
'#type' => 'select',
'#options' => array(
  'one' => 'one',
  'two' => 'two',
  'three' => 'three',
),
'#ajax' => array(
  'callback' => 'ajax_example_simplest_callback',
  'wrapper' => 'replace_textfield_div',
 ),
);

Here i have the ajax_example_simplest_callback in php. I need a response handler in js.


texts:
I have a content type video. It has some fileds for file meta data and a file upload field. Upload and display works fine.

Now I want to add a second video file to this content type. This file can either be uploaded or selected from a select field.

So you can select a previously uploaded file or add a new one. The select box should show all files that where added for any post with content type video.

Any ideas how to do this? I am using drupal 6.


texts:
I am using organic groups and I want the owner/reviewer of the group to be able to access an unpublished group content created by members of the group.

I know I can give "View any unpublished content" rights to a global user role, but this will be to strong (I have different reviewers for different groups and single reviewer should not have access to unpublished content of all the groups).

I want to give that right to the specific role in the group and "Organic groups global permissions" simply does not have that option.

I am familiar with hooks system but I am not sure how to approach the issue.
Any ideas?


texts: Node language in views contextual filters

texts: I have a multi-lingual site. On the article page has a block with other articles. How to bring in the article section with the same language as the current node? Interested in is the use of contextual filters. Option of using the language of the current user filter is not suitable.


texts: How do i specify a style for a single exposed filter?

texts:
I have a View where i show some exposed filters; i would like to apply a particular CSS class only to a specific exposed filter.
I have seen that if i copy the views-exposed-form.tpl.php inside my theme directory and call it views-exposed-form--MYFORMNAME.tpl.php i can control the html code; i don't think it s a good thing to put code with

 if($widget->id==MYID) {}

inside the template ... which is the correct way to assign a style to an exposed filter?


texts:
How I can show Like & dislike button on a view in drupal 8?

If the view is of content type then Like & dislike show but with all fields of content.

If we select views as a field type then there is no option to add Like & dislike.


texts:
I need to log out a user on browser close. I did following things but it's not working.

Copy default.services.yml to services.yml in the same directory and change the cookie_lifetime value 2000000 to 0.

cookie_lifetime: 0

and add the following line in settings.php

/**
 * Load services definition file.
 */
 $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/services.yml';

Am I doing anything wrong here?

  Update

After debuging a lot I found a weird issue, it is working on Firefox, Sarafi but not on Google Chrome.

Google Chrome showed "Session" in the expires column of session cookie. I was expecting some date/time. I later found out Chrome shows "Session" in expires when cookie time is less than the current time.

I am using google chrome Version 59.0.3071.115 (Official Build) (64-bit)


texts:
I have 2 problems with drupal.org/project/views_load_more & exposed filter:

When I change the exposed filter selection, it only filters the result which is in first lot (e.g if I have given a limit of 8 and then change exposed filter selection it filters among those 8 results only).
I get duplicate records; if I remove the load more limit I get distinct records

Please help.


texts: How to embed a view or a rendered node into a field group

texts:
I'm afraid my question is a bit to general because I don't quite know where to start.  I still really don't have my head wrapped around the drupal 7 theming system.

Scenario

I have two content types:

Type main
Type secondary (this type has a required entity reference field, referencing Type main

The display on Type main has a set of 2 horizontal tabs htabs group named group_expandables.

Desired Outcome

What I would like to happen is, if an entity of Type secondary has been added referencing this node; add a third horizontal tab containing the Type secondary node and make it the default.

Initial Approach

These are the steps I thought through that should probably happen on page load for a node of type Main:

Look for a Type secondary node referencing this node, return if not found
If found, build up a new render array for the Type secondary node htab.  I was thinking it would be easiest to build this display in views, and load in the view, but doing it in a template file would probably work too.
Once the variable has been for the new htab, insert it in the htabs  render array and modify the render array to remove the open by default indicator on the old default tab.

So far I have used hook_preprocess_page to grab the $variables['page']['content']['system_main']['nodes'][nid]['#fieldgroups']['group_expandables'] and add a new group name to its children, clone one of the htab field groups and append it to the ['#fieldgroups'] array, and modify the elements that referenced the old htab and replace them with the name for the new tab.  Once I figured out that I needed an entry in #group_children too, I actually got the tab to appear in the group, but I haven't had any luck getting content to show up in it yet.

Question

Here are the places I'm really hung up:

Is hook_preprocess_page the best place to start this?
Is my general strategy for how to go about this sound?
How would I build my desired content into the new htab?

I'm sorry for the broad nature of the question, any pointers would be greatly appreciated.


texts: Huge delay on first request due to many slow SQL queries

texts:
Possible Duplicate:
  Performance Problem: Delay on first request

The first page of my site takes up to 15 secs to load and then the site become responsive. If I leave the site for 20 min or so, the first request is very long again.

Following recommendations found on this similar question, I checked the Devel query logs and there is a whole bunch of queries related to field_sql_storage_field_storage_load taking more than 250ms.
I am not sure it is purely related to field_sql_storage_field_storage_load though as there is another language_list query with a simple SELECT * FROM languages ORDER BY weight ASC, name ASC taking 186ms.

My questions are: why do I encounter such delays and how can I reduce them?


texts: Drush was not able to start (bootstrap) the Drupal database - MySQL Access denied error

texts:
I've installed Drush 7 using Composer and working with Drupal 8 and 7 on Ubuntu 12.04 with PHP 5.4.31, mysql 5.5.38

Drush will dl modules and themes just fine but when I want to en a module then it gives me the Drush was not able to start (bootstrap) the Drupal database.

So upon further investigation I did this:

$ drush -v -d sql-cli
Starting Drush preflight. [0.02 sec, 1.15 MB]                        [preflight]
Cache HIT cid:                                                           [debug]
7.0-dev-commandfiles-0-87f720da39665f2c425de5e651f2ac4d [0.05 sec,
1.19 MB]
Bootstrap to phase 0. [0.2 sec, 3.19 MB]                             [bootstrap]
Bootstrap to phase 0. [0.28 sec, 3.19 MB]                            [bootstrap]
Found command: sql-cli (commandfile=sql) [0.28 sec, 3.19 MB]         [bootstrap]
Calling hook drush_sql_cli [0.56 sec, 3.21 MB]                           [debug]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.56 sec,    [bootstrap]
3.22 MB]
Initialized Drupal 8.0-dev root directory at                            [notice]
/home/wavesailor/My_sites/bootstrap-business [0.62 sec, 3.52 MB]
Cache HIT cid:                                                           [debug]
7.0-dev-commandfiles-1-67528d048330f8c38ed66ea20e647906 [0.62 sec,
3.52 MB]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.63 sec,    [bootstrap]
3.57 MB]
Initialized Drupal site default at sites/default [0.63 sec, 3.57 MB]    [notice]
Cache MISS cid:                                                          [debug]
7.0-dev-install_profile-66ecfeb9791a023150773849f1550c5d [0.64 sec,
3.57 MB]
Cache HIT cid:                                                           [debug]
7.0-dev-commandfiles-2-027a7d06ad1248d56c7499a21fb8d2df [0.65 sec,
3.57 MB]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.65[bootstrap]
sec, 3.57 MB]
Calling proc_open(mysql --defaults-extra-file=/tmp/drush_ST3u9r --database=bootstrap_business --host=127.0.0.1 --port=3306);
ERROR 1045 (28000): Access denied for user 'my_username'@'localhost' (using password: YES)
Returned from hook drush_sql_cli [0.87 sec, 3.72 MB]                     [debug]
Command dispatch complete [0.87 sec, 3.71 MB]                           [notice]
Peak memory usage was 5.21 MB [0.87 sec, 3.7 MB]                        [memory]
$

It seems it cannot connect to the database so I did the following:

$ drush sql-connect
mysql --user=my_username --password=my_password --database=bootstrap_business --host=127.0.0.1 --port=3306
$ mysql --user=my_username --password=my_password --database=bootstrap_business --host=127.0.0.1 --port=3306
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 286
Server version: 5.5.38-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

I can connect manually to the database with the connection string given by drush.

So then I deleted the .drush folder in my home directory but that did not help.
I did try this for both Drupal 7 and 8 sites.

So then I downgraded to drush 6 (composer global require drush/drush:6.*) and drush then worked flawlessly with Drupal 7 sites. I then upgraded to drush 7 (composer global require drush/drush:dev-master) and it stops working again

Any ideas on how to solve this??


texts:
I upgraded my server from php 5.3 to php 5.5 based on this link.
I disabled the apc.so in php.ini, disabled apc module.

Drupal 7 multi-site.
/home/default/public_html is the root folder for
/home/domain_1/public_html,
/home/domain_2/public_html,
/home/domain_3/public_html,
/home/domain_4/public_html

three of these domains work as usual; visitors links all work and admin can log in and administer the three websites

the fourth site reports an error:
visitors cannot see the site - the WOD is really
Fatal error: Call to undefined function apc_delete() in /home/default/public_html/sites/all/modules/apc/drupal_apc_cache.inc on line 289

I cleared bootstrap cache and cleared the variable but to no effect.
drush cc all, drush rr, and drush cron core did not improve this situation.

What else should I look for? Any other suggestions?


texts: Redirect to previous non drupal page after login

texts:
I have installed Drupal 7 on azeem.com, and I have installed a forum software on azeem.com/qa. I am trying to use Drupal as single sign on site.

When I am at azeem.com/qa, and I click on login page, it takes me to the Drupal login page with a URL like http://azeem.com/user/login?redirect=qa%2Findex.php%3Fq%3Dnode.

After giving the username and password, I successfully logged in, but instead of redirecting me back to http://azeem.com/qa, it takes me to http://azeem.com/user/1.

How can I redirect back to the page where I was before logging in?


texts: I've given my newly created user the permission to "Administer menus and menu items " however, when I log in as the new user I cannot administer the menus... Why might this be? The user doesn't have the permission to administer blocks, if that makes any difference?


texts: How can render a Block on a Contact form Page

texts:
I want to render a Block on a special content type page and on the contact form page. All works fine, but i didn`t found any way to print the Block also on the contact form page.

i use in the page.tpl.php:

if(isset($node) && $node->type === 'page') {
   ....
}

Hope someone can help! Thx


texts: how can I have Infinite pager in mini_page views?

texts: I need my minipager to go infinite. I mean when it get to the last record to jump to the the first one. If it goes to the last one jump to the first one? How can I achieve this. I am using views to display my information. But I just want it to use it in a particular view. I don't want it to be default for all my views.


texts: I am using Display Suite search as default search module. Is there a way to add the contents of blocks to the search results?


texts: I'm using Drupal 7 and i've got 3 file field in content. I don't want see generic file, url file etc... I want spesific bg image on all my file field. How can i do this?


texts:
I have same webform in three different languages. In First two languages, after submit, page is refreshed, and confirmation message shown: "Your email was sent".

But in third language, after submitting, drupal redirects to

/node/14/done?sid=17

And confirmation message is shown as following:

Thank you, your submission has been received.

How can i force my third language webform, to do same thing as webforms in previous two languages? Webform/email settings are same for every webform.


texts: hook function not deleting nodes when calling node_delete

texts:
I have a cron job where I need to do a node_delete().

From what I can tell the delete occurs okay if I run the cron job manually from the status report page, but if I try to run the cron from inside a call to a module_cron function it looks like the delete fails.

Is there some way to give the cron the access to delete nodes with node_delete?


texts: Prevent anonymous users from accessing "node/" node/%nid and taxonomy/term/%tid

texts:
So far, I have been reading some similar questions but I haven't found an elegant and simple way of doing this (if there is any). As I say in the question title, I don't want anonymous users to access the complete list of nodes (in node/) nor a particular node (under node/%nid), nor even a particular taxonomy term. :)

My approach to this is as follows. As far as I know, I can override the default node/%nid system page using a variant in Drupal panels. I actually did this and, if the user is not logged in, when he/she tries to access the node/%nid he/she will see a log in box. For the list of nodes, I removed from the front page all of the nodes and none is shown. I would expect to do with taxonomy/term/%tid the same as I did with node/%nid but, for a strange reason, Drupal panels is not able to create the variant (not sure if it is a bug).

Anyway, I would like to know if you have a more elegant or simpler approach to this (no matter if using panels or not).

Thanks in advance for your help!


texts: Custom webform validation handler not getting called using Event subscriber

texts:
I am trying to implement a custom validation for webform. I need to validate if user entered email is valid or not. For that I have altered the webform using event subscriber and assigned a validation handler. But validation handler is not getting called. The configured webform is ajax enabled. Below is my code.

namespace Drupal\mymodule\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;

/**
 * Altering drupal forms with hook_event_dispatcher.
 */
class ContactWebFormFormAlterEventSubScriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      HookEventDispatcherInterface::FORM_ALTER => 'hookFormAlter',
    ];
  }

  /**
   * Altering form array from here.
   */
  public function hookFormAlter($event) {
    if ( strpos( $event->getFormId(), 'webform_submission_contact_us' ) !== false ) {
      $form = $event->getForm();
      $form['#validate'][] = '::mymodule_webform_submission_contact_us_validate';
      $event->setForm($form);
    }
  }

  /**
   * Altering form array from here.
   */
  public function mymodule_webform_submission_contact_us_validate(array &$form, FormStateInterface $form_state) {
    $email = $form_state->getValue('email');
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
      $form_state->setErrorByName('email', $this->t('Email address is invalid'));
    }
  }
}


texts:
I want to add a "add translation now" button on nodes and other entities too. I'm using the Entity translation module, and I added two languages to the site.

I thought about getting the original translation and then loop through the translation data, checking if there is more than just the original language inside.

Is there a better way to do this?


texts: Unable to load css files using ['#attached'] or drupal_add_css

texts:
I'm attempting to attach several css files to a Drupal 7 module. All files have identical read/write/execute and owner permissions. I haven't had trouble with one of the three files but I can't get the other two added (checked the loaded stylesheets in developer tools). Here's what I've tried:

<?php
function usspd_search_main_form($form, $form_state) {
  $form['#attached']['css']['css1'] = '/sites/all/libraries/data_search/bootstrap_tagsinput/bootstrap_tagsinput.css'; //failed
  $form['#attached']['css']['css2'] = '/sites/all/libraries/data_search/tagme/tagme_jquery-ui.css'; //failed
  drupal_add_css('/sites/all/libraries/data_search/bootstrap_tagsinput/bootstrap_tagsinput.css'); //failed
  drupal_add_css('/sites/all/libraries/data_search/tagme/tagme_jquery-ui.css'); //failed

  $form['#attached']['css']['css3'] = drupal_get_path('module', 'usspd_search') . '/theme/usspd_search.css'; //works
  return $form;
}

My best guess is that there's a class conflict and instead of overriding, the attachment just fails. Is there any way to declare priority? Otherwise I'll have to add the css from both files inline.

Additionally, I'm able to call everything fine when added as raw HTML to a basic page. It shouldn't be a pathing issue.

<link rel="stylesheet" href="/sites/all/libraries/data_search/bootstrap_tagsinput/bootstrap_tagsinput.css">
<link rel="stylesheet" href="/sites/all/libraries/data_search/tagme/tagme_jquery-ui.css">


texts: How do I load templates within templates?

texts:
Ok so I am writing a custom module and am trying to undestand how Drupal manages theming output.

I have registered my theme function, ie

mymodule_theme() {
    return array(
        'mylist' => 'templates/mylist-template',
        'arguments' => array('data'=>NULL)
    );
}

The mylist-template contains a HTML table with a heading row, such as:

        ID
        Name

    <?php print $rows; ?>

As you can see here I want to output x number of rows using another template file such as list-rows.tpl.php, ie:

    1
    My Name

How do I achieve this? At the moment I have a menu item with my table function, let's say:

 function mymodule_table() {
     $output = theme('list','');
     return $output;
 }

This works fine but im not sure how I would implement my rows


texts: I have the Nodeblock and the Contextual links modules installed. They work fine, but I want to add the "Edit node" link in the contextual links for node blocks. For views, there is a "Edit view" link, but not for nodes. Is there a way to do that, maybe with a preprocess block function?


texts: Adding group manager email to "membership pending" text

texts:
When a user tries to join a private group in Drupal Commons she will see the following text:

  Your membership request is pending review by a group organizer.

We'd like to give the user the ability to email (or otherwise contact via form) the group manager. Is it possible to update this text to add an email (to authenticated users only of course)?

Update: It appears I may be able to accomplish this by hook_preprocess_field

function hook_preprocess_field(&$variables) {

  if ($variables['element']['#field_name'] == 'group_group') {
        $variables['element'][0]['#markup'] .= "Group Mgr Email Placeholder";
  }
}

Though after a drush cc all && drush cron, the page content remains the same. Am I using the wrong function?

Update 2: Well I now have a placeholder for email by using item instead of element. Next I'll move onto extracting the group managers and their emails to show to pending users.

$variables['items'][0]['#markup'] .= " [[ place holder for emails]]";


texts: How to add a menu under Webform Results?

texts:
In Drupal 7, I know we can use Views to add sub menu or menu tab on "My Workbench". The form result I have in "mydomain.com/node/99/webform-results" contained Submissions, Analysis, Table, Download, and Clear sub-menus. How can I add another sub menu next to "Submission"? I have tried to use the same method from Workbench, but it does not seem to work.

My new sub-menu setting in Views

Type: page
path: /node/99/webform-results/details
menu: Menu Tab: Navigation


texts:
We would like to be able to restrict access to buy products.

A product could be members-only
Users who are already members should be prevented from buying membership again until near expiry.

If there is no access to buy, the "add to cart" button should not be shown.  There also needs to be a check during checkout, for example in case the a member added a membership to the cart as anonymous then logged in, they still should not be able to buy membership.

We don't want to restrict access to view products.  Non-members should be able to see the benefits of membership, and what extra things they could buy.  The price should still be visible for products that cannot be bought (so we can't hide the entire "Add to Cart" form as that's where the price comes from).

Please can someone explain how to achieve this?


texts: Change form values with Javascript and submit to an AJAX'ed View?

texts:
In Drupal 8, you can trigger a refresh for a View by invoking:

$('.view-name').trigger('RefreshView');

The view I am trying this on has an exposed form on the page. I notice it does not respect the form values when triggering this event - is there another one I can use or does this sort of assignment:

    // date button
    $('button.c-sortby__date').bind('click', function() {
      var old_sort = $('input[name="sort_by"]').attr('value');

      $('input[name="sort_by"]').attr('value', 'changed');

      var order = $('input[name="sort_order"]').attr('value');

      // if the sort was relevance before, force DESC
      if (old_sort == 'search_api_relevance') {
        order = 'DESC';
      } else {
        if (order == 'ASC') {
          order = 'DESC';
        } else if (order == 'DESC') {
          order = 'ASC';
        }
      }

      $('input[name="sort_order"]').attr('value', order);
      $('form#views-exposed-form-acquia-search-results').submit();
    });

not work?

Note: if the view config is not AJAX set, the above Javascript works when triggering the submit() event of the form.


texts: What is the best way to get array in some drupal data

texts:
By example, I get this array :

content_device
    ...
    fields_examples
        und
            0
                sub_field_one
                sub_field_two
                ...
            1
                sub_field_one
                sub_field_two
                ...
            2
                ...
            ...

And currently, if I want modify a subfield, I do this :

content_device['fields_exemples']['und'][1][sub_field_two] = ...

Is there a best way (drupal or php way) for get a sub data more cleany ?
I mean (sorry for my poor english writing x) ), I find the "['und'][1]" heavy. If I get the fields_examples array, can I get the sub-arrays '0', '1', '2' ... without use the 'und' in this example ?

My example isn't very explicit, but I know I have some array in my website who contain sub-sub-sub-...-array in sub-sub-...-array in ... in array.
And often, an array contain one only sub-array. So if I want get the sub-sub-array, I find the 'only' sub-array very useless, and he complicates the code.

I hope I was clear x)


texts: Printing fields in theme: Undefined index: safe_value

texts:
I want to print my fields in tpl.php files as cleanly as possible. To do this, I have used the following code in my template.php file:

function print_field($field_name, $format = 'safe_value') {

if (arg(0) == 'node' && is_numeric(arg(1))) {
  // Get the nid
  $nid = arg(1);

  // Load the node if you need to
  $node = node_load($nid);
}

$field= field_get_items('node', $node, $field_name);

if ($format == 'url') {
    print file_create_url($field[0]['uri']);
} else {
print $field[0]["$format"];
}
}

Now, I can print my fields in my tpl.php file in a clean manner, without any unnecessary mark-up or labels:

<?php print_field('field_section') ?> -- Prints the field with safe formating

<?php print_field('field_title', 'value') ?>  -- Prints the field in Raw

<?php print_field('field_intro_image', 'url') ?> -- Prints the image url of a field

It all works fine, but I get this error message:

Notice: Undefined index: safe_value in print_field() (line 19 of template.php).

How I can resolve this?

Also, is it possible to just enter value or url in my tpl.php file without wrapping them in quote marks?


texts: How to remove default 'search' text form search form

texts:
I can't seem to figure out how to get rid of the default text "search" on my search form (located here: http://dev.mysourcewise.com/media-center)

I can confirm the following works in Chrome's console:

jQuery("#edit-search-block-form--2").val("");

However, when I try adding it using Drupal.behaviors or even with the following code in my theme's template.php file, it doesn't work (even though I can confirm the javascript is loaded in the footer):

  drupal_add_js('jQuery(document).ready(function () { jQuery("#edit-search-block-form--2").val("");',
array('type' => 'inline', 'scope' => 'footer', 'weight' => 1000)
 );

I have tried other methods as well, and nothing is working except entering the the above in the browser console.


texts: How to add page argument in hook_menu for dynamic callback function?

texts:
I'm using groups for my website and I would like to create functions that will work for every group.
I've created a tab configuration for every group like this.

$groups = group_load_by_type('community');
foreach($groups as $key => $value) {
  $items[CONFIG_GLOBAL_ADMIN_PATH . '/groups/' . $key] = array(
    'title' => $value->title,
    'description' => 'Group ' . $value->title,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('myModule_group_settings_form'),
    'access arguments' => array('administer site configuration'),
    'file' => 'myModule_group.admin.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
  );
}

It's working pretty well this way, I have the config for all the groups at the path/groups/groupID which is what I want.

But I would like to add an argument to my function myModule_group_setting_form($form, &$form_state) and do something like this:

'page arguments' => array('myModule_group_settings_form', $key->title),

and change my function to this :

myModule_group_setting_form($form, &$form_state, $groupName)

In my function, I'm using variables so the groups can hide some informations if they want.
Actually if I want to do this, I have to create a function for every group and do something like this :

'page arguments' => array('myModule_group_' . $key->title . '_settings_form'

And I have to create a new function every time I have a new group. Since I don't have static groups, and I may have to create others in the future, this way doesn't suits me.

Thanks for your help :)


texts: Correct use of the context module to overtake the blocks assignments page?

texts:
Currently I'm using the regular blocks page to make assignments to the head/footer regions as those are relatively static. But one issue im running into is that I need to assign the "main content" block into a region or else I can't save the block page.

This poses a problem as I'm also using the context module to make block assignments such as view blocks in the content area. Since the "main content" block is assigned in the regular blocks page, I can't get context to place blocks above the main content block.

Is there a way to just just context entirely over the blocks page?
How do you resolve the "main content" blocks being as a required block assignment on the blocks page?


texts:
I need to delete entries about anonymous user login from the sessions table.

I read what reported in
https://techcommons.stanford.edu/topics/drupal/sessions-table-cleanup.

Which PHP setting in the page above ensures automatic removal of anonymous user login entries from the sessions table handled from Drupal? Do the suggested settings have any effect on that database table?


texts: managed_file upload clearing $form_state

texts:
I am having an annoying problem whereby $form_state['values']['region'] and $form_state['values']['country'] are being cleared when I upload an image via the managed_file field. This is causing a "...tid cannot be null" error upon DB insertion (of course because the values are now null after managed_file upload). If I disable the managed_file field everything works as it should but of course I need the upload!

I am relatively new to Drupal and thus not quite understanding why this is acting like it is. Can anyone help me out as this is driving me nuts!

My form

function myforms_company_add_form($form, &$form_state, $node) {

  $form['#prefix'] = '
';
  $form['#suffix'] = '
';

  if(!isset($form_state['values']['region']) && !isset($form_state['values']['country'])) {
      $selectedRegion = array_shift(taxonomy_get_parents($node->field_company_region['und'][0]['tid']))->tid;
      $selectedCountry = $node->field_company_region['und'][0]['tid'];
    }
    else {
        $selectedRegion = $form_state['values']['region'];
        $selectedCountry = $form_state['values']['country'];
    }

$form['region'] = array(
    '#title' => t('Region'),
    '#type' => 'select',
    '#required' => TRUE,
    '#options' => _get_region_list('region'),
    '#prefix' => '

',
    '#suffix' => '
',
    '#default_value' => $selectedRegion,
    '#ajax' => array(
      'callback' => 'region_ajax_callback',
      'wrapper' => 'wrapper',
     ),
  );

  $form['country']['wrapper'] = array(
    '#type' => 'markup',
    '#prefix' => '
',
    '#suffix' => '

',
  );

  if (isset($selectedRegion)) {
    $form['country'] = array(
        '#title' => t('Country'),
        '#type' => 'select',
        '#required' => TRUE,
        '#options' => _get_country_list($selectedRegion),
        '#default_value' => $selectedCountry,
        '#ajax' => array(
            'callback' => 'region_ajax_callback',
            'wrapper' => 'wrapper',
        ),
      );
   }

  $form['company_logo'] = array(
    '#title' => t('Logo'),
    '#type' => 'managed_file',
    '#upload_location' => 'public://my-files/',
    '#required' => FALSE,
    '#default_value' => $node->field_company_logo['und'][0]['fid'],
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
    '#prefix' => '
',
  );

  return $form;

}

Then my callback

function region_ajax_callback($form, &$form_state) {
  return $form;
}


texts:
I have Node with taxonomy terms.
Example

Term A
Term B
Term C

and user role like this

Role 1
Role 2
Role 3

Using Taxonomy Access Control(TAC) I can limit Role 1 can add all terms, Role 2 only add Term B, Role 3 only add term C.

With CSS I can hide disabled options, so when Role 3 want to add content. ex: Role 3 will only see Term C.

But how can I make Term C autofilled when Role 3 want to add. Right now Role 3 must choose or fill two options, nothing and Term C.

Any ideas?


texts: Can Ubercart be adapted to print a letter?

texts:
When an order is received through Ubercart, the details can be viewed and printed, but can the print order option be expanded to do more? When I ship product, I like to include a personalised letter in addition to the standard order form.

Can I craft such a letter, so that it prints out after the order page, showing letterhead, date, customers address, and separate envelope?


texts: Programmtically add image to custom image field User

texts:
I can't figure out how to add image to a custom image field on a sepcific user.

    $f = file_save_data($user['thumbnailphoto'][0], 'private://profile/'. $data['name'] .'.jpg', FILE_EXISTS_REPLACE);
    $fid = $f->fid;

    //Add to virtual map 'Profile images'
    $file_entity = file_load($fid);
    $file_entity->status = 1;
    $file_entity->field_folder['und'][0]['tid'] = 180;
    file_save($file_entity);

    $user = user_load(334);

    $details['field_profile_picture'] = array(
                                        'und' => array(
                                            0 => array(
                                            'fid' => $fid,
    )));

    $u = user_save($user, $details);

But nothing get saved? Field_profile_picture is just an image field.

Thx!


texts: In views, how to create link to field visible through relationship connection?

texts:
I don’t want to link to the original piece of content (which is a join table) but to the content type which is referenced in the join table.

Using: Views, Entity Reference, Entity Tokens, Token.

I have these content types:
- Person (firstname, lastname, etc.)
- Story (field_story_title, orig copyright, description, etc.) Note: [content:title] is automatically generated and not used.
And this content type which functions as a join table
- PersonStory (field_personstory_person_id, field_personstory_ story_id, relationship [e.g. author].)

The view has Content: Type (= PersonStory)
Relationships have been created
- Story from field_personstory_story_id
- Person from field_personstory_person_id

The view successfully finds Story Title (field_story_title) and Person Name (using [Global: custom text] in concatenation of field_person_lastname, field_person_firstname, etc).

I created a link:
- Added field [content:path] above Story Title on the field list. Checked "Exclude from Display" and expanded "Rewrite results" and only checked "Use absolute link" for this field.
- Added field field_story_title, expanded "Rewrite results" and checked "Output this field as Link" with the Link path: [path] .

The view looks just fine with the field_story_title appearing as a link.

However, clicking the link goes to the record in PersonStory instead of the record in Story. @skorzh suggested that I investigate replacement pattens in the Rewrite results, but I don't see any tokens which connect to the fields in Relationships in the View.

I’ve tried many different patterns and tokens and nothing has worked in details of [field_story_title]. I don't know what the replacement pattern should look like. Is it possible to join replacement patterns? How do I determine what the url should be?

My latest attempt is
[site:url:join:/]/[content-type:name]/[node:field-story-title:name]
but it's not working, naturally.

Thanks.
(Entire post has been updated to reflect my current (lack of) progress)


texts:
I've created a module with a custom block that extends BlockBase. To the block form I added multiple textfields and select boxes, by simply specifying the formatter in the '#type' configuration.

My next step is to add a button that links to internal/external content and I've tried adding different types, such as 'link' but without any luck.

I found LinkFormatter, but I can't figure out how to use it properly with block forms.

What has to be added to the blockForm method in order to create a link field (just like the link field that's selectable within a custom block type):

My current code:

public function blockForm($form, FormStateInterface $form_state) {
  //...
  $form['link'] = [
    '#type' => 'link',
    '#title' => $this->t('Link title'),
    '#url' => 'Hmm?',
    '#options' => ['external' => TRUE]
  ];

  return $form;
}


texts:
I have an OpenAtrium distribution installed on Drupal 6. As you may already know OpenAtrium already implements a search feature. What I'd like to do is change the following form:

by adding another button alongside the Search one (there are other modifications that I'd like to do but it doesn't matter this is just the final goal).

The problem is that I don't know what is the PHP page that builds that form. All I know is that page.header.inc prints the content of that form:

 ...

<?php print $space_tools ?>

 ...

As you can imagine $space_tools contains the entire menu and also the form. But who's the one who builds the $space_tools variable? Is there an OpenAtrium API that I can read somewhere?

This is the result HTML which I'd like to change:

<form action="/openatrium/XXXXXX/" accept-charset="UTF-8" method="post" id="atrium-search-form">

        Search XXXXXXX: *
        <input type="text" maxlength="128" name="search" id="edit-search" value="" class="form-text required fluid">

    <input type="submit" name="op" id="edit-submit" value="Search" class="form-submit">
    <input type="hidden" name="form_build_id" id="form-31ea0a19166f0619050f7ac923ebf331" value="form-31ea0a19166f0619050f7ac923ebf331">
    <input type="hidden" name="form_token" id="edit-atrium-search-form-form-token" value="aaf2e5374720acee5769fcafb6421e35">
    <input type="hidden" name="form_id" id="edit-atrium-search-form" value="atrium_search_form">

</form>

Thank you. Almost forgot, here where I work imgur is blocked by the proxy so I can't tell if the image has been uploaded or not.

EDIT: This is driving me crazy I looked up over the entire OpenAtrium folder for the word "atrium-search-form" and no result at all inside files. How can this even be possible lol? Unless the ID is built upon different variables, in that case I don't know what to do...


texts: My Ajax call for my submit button does not work?

texts:
I am building a form with the form builder but I can't even get my button to use its ajax function to callback. Instead of doing a normal ajax call on the page, it reloads the entire page.

What am I doing wrong here? The DPM function doesn't even run, so i'm assuming i'm not even triggering the ajax call, but I have copy pasted the function name into the callback, so i'm not sure why its not triggering on submit?

  $form['suggested_actions']['list']['mentorship'] = array('#type' => 'container');
  $form['suggested_actions']['list']['mentorship']['text'] = array('#type' => 'markup', '#markup' => '');
  $form['suggested_actions']['list']['mentorship']['text']['#markup'] .= 'Mentorships - Unconfirmed';
  $form['suggested_actions']['list']['mentorship']['button'] = array('#type' => 'button', '#button_type' => 'submit');
  $form['suggested_actions']['list']['mentorship']['button']['#name'] = 'Mentorships';
  $form['suggested_actions']['list']['mentorship']['button']['#attributes'] = array('data-title' => array('Mentorships'), 'class' => array('SA_Button'));
  $form['suggested_actions']['list']['mentorship']['button']['#value'] = 'Confirm Mentorships';
  $form['suggested_actions']['list']['mentorship']['button']['#ajax'] = array(
      'callback' => 'erc360_completeness_report_suggested_actions_mentorship_ajax',
      'wrapper' => 'mentorshipunconfirmed',
      'method' => 'replace',
      'effect' => 'none',
  );

  function erc360_completeness_report_suggested_actions_mentorship_ajax($form, $form_state){
      dpm("The AJAX FUNCTION has ran...");
      return $form['suggested_actions']['list']['mentorship']['text']['#markup'] = 'confirm';
  }


texts: Why is the default Search module not returning partial results?

texts:
Drupal 7 default Search module not returning partial results

I.E. I have a series of SKU #'s:

S0160-0003
S0160-0004
S0160-0005
S0160-0006

Searching for S0160 returns no results. I only get results when I search for the exact SKU number.

Any recommendations as to how to fix this?


texts:
I'm trying to embed an iframe in another site (or rather the other site requires an iframe be embedded showing my Drupal site). I am getting the error:

Load denied by X-Frame-Options: https://example.com/audio/embed/44?autoplay=1&auto_play=true does not permit cross-origin framing.

Request headers:

Host: www.example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://cards-dev.twitter.com/preview/html?authenticity_token=6c647c45ab69f55e843ef827a95377d1b39aab85&url=https%3A%2F%2Fwww.example.com%2Fpodcasts%2Fwho-goes-vegas-stays-vegas-making-mike-american-again&platform=Swift-12&authenticity_token=6c647c45ab69f55e843ef827a95377d1b39aab85&authenticity_token=6c647c45ab69f55e843ef827a95377d1b39aab85
Cookie: AMP_ECID_GOOGLE=amp-F76p47lSL8DdI7QAfmPw264-1cM51dzy1g2eqpVFbsVsDjqrf-h27aVLhYsKepvC; SSESSbc77b3dd795094a7a765da9aeed8de88=JhaX78fzqbvJgmHT02ebpBDJNwN56qgE1sqg45knj_Y
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1

Response headers:

Accept-Ranges: bytes
Cache-Control: must-revalidate, no-cache, private
Content-Encoding: gzip
Content-Language: en
Content-Type: text/html; charset=UTF-8
Date: Mon, 17 Apr 2017 19:02:53 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Server: LiteSpeed
Set-Cookie: SSESSbc77b3dd795094a7a765da9aeed8de88=JhaX78fzqbvJgmHT02ebpBDJNwN56qgE1sqg45knj_Y; expires=Wed, 10-May-2017 22:36:13 GMT; Max-Age=2000000; path=/; domain=.www.example.com; secure; HttpOnly
Surrogate-Control: no-store, content="BigPipe/1.0"
Vary: Accept-Encoding
X-Accel-Buffering: no
X-Content-Type-Options: nosniff
X-Drupal-Dynamic-Cache: HIT
X-Firefox-Spdy: h2
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=edge
x-generator: Drupal 8 (https://www.drupal.org)

Does anyone know how to permit X-Frame-Options so that an iframe with Drupal content can be shown on another site?


texts: Which is the cache I have to clear to refresh list of view blocks?

texts:
I created a new block (a view block) but it is not available to use in other modules (like panels). If I clear all cache then it shows up.

I don't want to clear all caches but only the right one to get the same.


texts: Create new table in existing module without affecting existing table data

texts:
I have my custom module myCustomModule in drupal 7 website along with installation file to create table.

I Have already saved lot of content in table but I need to create a new table in same module without affecting the previous table data.

if I add something new in .INSTALL file, I have to uninstall and install module which will remove the existing data content from my table.

Is there a way to create new table for existing module without affecting existing table data.

How do I update my module structure without affecting previous things.

[or last option for me is to create a new module and have separate table but I dont want to create so many modules ]

Please help , I need to do it for Drupal 7

EDIT

I followed this link and tried below and cleared cache after updating my code

/**
 * Create new database table {new_table}.
 */
function my_module_update_7101() {
 $schema['new_table'] = array(
     'description' => 'Table for storing information about static media asset .',
        'fields' => array(
            'aid' => array(
                'type' => 'serial',
                'not null' => TRUE,
                'description' => 'Primary Key: Unique aggregator static media asset ID.',
            ),
            'asset_title' => array(
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
                'description' => 'Title of the static media asset title',
            ),
            'asset_file_path' => array(
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
                'description' => 'CDN url path for asset.',
            ),
            'status' => array(
                'description' => 'status field for the static media assets',
                'type' => 'int',
                'length' => 1,
                'not null' => TRUE,
                'default' => 1,
            ),
        ),
        'primary key' => array('aid'),
    );

  db_create_table('new_table', $schema['new_table']);
}

It does not seem to update my table


texts: How to execute a specifc job after some time interval like 5 minutes?

texts:
I want to perform a job after 5 minute, I explain what I mean with an example:

"I connect to bank gateway, register my order there,they give me transactionId and told me  I should verify transaction after 5 minute,

I wrote register (register_my_order) and verification (verfiy_myorder) code, but I want set interval 5 minute between them.
My Pseudocode:

transctionId= register_my_order(myorder)
delay(5minute)
verfiy_myorder(transctionId)

One of my solution was using rule scheduler (a sub-module of Rules),

I try below solution but not worked

Create a rule component and get transctionId as parameter
In action run my verfication fuction with provided parameter as transction Id

then in my code between register_my_order(myorder)  and verfiy_myorder(transctionId) I create  rule task schedule with below code

    //$result = rules_invoke_component('rules_run_after_5_minute', 'param1');
     $state = new RulesState();
    $state->addVariable('tref', 'test', array()); //tref is name of parameter and test is passed parameter to it
    // 3rd parameter is called $info it must be an array, but i don't know it's function
   $task = array(
    'date' => time(), // timestamp
    'config' => 'rules_run_after_5_minute', // it is my component machine name
    'state' => $state,
);

$result=rules_scheduler_schedule_task($task);

any idea that how can I create task schedule programmatically and work correctly ( my code create it but not getting  run  )


texts:
Content created by Role A should not be published and only moderator should be able to publish it.
Content created by A should publish automatically.

How can this be accomplished in Drupal?

Cheers


texts: Drush 9.2 - not working well / not installing with Composer

texts:
I am using Ubuntu 17.10 running Apache 2.4 on a Vultr instance. Using virtual host for my.example.com website. Installed Drupal 8.5.1 per recommended Drupal-Composer/Drupal-Project. Apache docroot points to the "web" folder containing Drupal core (ie, where Drupal's update.php lives, among other things). The project root folder is one level up, containing the composer.json file.

File permissions: the project root folder itself is owned by user:www-data; same for Drupal root (web, and below). Drupal status is fine. It looks like Composer installed the /vendor folder [in the project root] as user:user.

I have seen so many errors, it's hard to know where to start. So far I have not discovered any underlying logic to them. The goal is simple: to get Drush working on my install, which is nothing special. Even on Windows, I can get Drush half-working.

After the install, Drush was at least recognizing its own existence. (At one point, I had the drush.phar helper globally installed, per the instructions from that website.) But "drush status" was claiming that it couldn't find Drupal -- even with the -uri flag, and even with the alias set up in example.site.yml contained in /project-root/drush/sites.

Drush status was looking at something that pointed to a deleted docroot folder, but I couldn't find the relevant config, and the only possibility was a path entry in that section of the composer.json file. Which I fixed, but that didn't help Drush.

Per the Drush docs, I tried running the drush command from Drupal root, pointing to /vendor/bin; and also in the /vendor/drush/drush folder. Getting permission denied in all cases. [Why? I'm the user running the command, in folders that I own as the user! Does Drush need www-data group permission?]

Adding a path command to ~/.profile [the Ubuntu file for .bash_profile] didn't help.

The permission denied error was in addition to the error re "command not found" -- when I'm in the very folder where I know the command file is located. I tried "chmod +x" on both the /vendor/bin version of drush, and the vendor/drush/drush/ version [just the "drush" single word file, not the "drush.php" file], but that didn't solve the problem. I reverted those back.

[And why is the folder structure so convoluted? Why the middle /drush?]

So, then, I thought that maybe it was a Drupal-Composer issue. So composer did allow for removal of drush/drush. And I deleted all the left-behind drush folders in my user home and in the project folder.
Went to re-install Drush using Composer, per the Drush install docs: "composer require drush/drush"

Which fails for me. The main culprit seems to be a symfony/var-dumper conflict [many versions] with symfony/http-kernel [many versions] -- it's several screens full of the attempted reconciliation, with this conclusion:

Can only install one of: symfony/var-dumper[v3.4.8, v4.0.8].
Installation request for symfony/var-dumper (locked at v4.0.8) -> satisfiable by symfony/var-dumper[v4.0.8].

updating for symfony/http-kernel (with dependencies): nothing to update

updating for symfony/var-dumper (with dependencies): nothing to update

In composer.lock, the entry for SHK does have a "conflict" parameter that mentions SVD. But I don't know how to fix that [if that is in fact the source of the "lock" statement above].

I run a simple website, so probably don't need Drush to move to D8 -- except that others seem to get it working and find it helpful -- and I'd like to join that club.


texts: How to determine the route for the add node page of a custom entity type?

texts:
I have a node type question that I want users to be able to create rapidly.  So, after adding a question, I want them to be redirected to /node/add/question to immediately do it again.
This is my code so far:
function MYMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  switch ($form_id) {
    case 'node_question_form':
      foreach (array_keys($form['actions']) as $action) {
        if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
          $form['actions'][$action]['#submit'][] = 'MYMODULE_node_form_submit';
        }
      }
      break;
  }
}

function MYMODULE_node_form_submit(array &$form, FormStateInterface &$form_state) {
  // https://drupal.stackexchange.com/a/250474/5147
  \Drupal::request()->query->remove('destination');
  $form_state->setRedirect('node.add_page');
}

This redirects to /node/add, but I want to redirect to /node/add/question.  I tried digging through the route options in PHPStorm but I couldn't find anything that gets to the create page for a custom content type.


texts: Module Secure Page for SSL: from https to http lose session

texts:
I have a problem:

I work on Drupal 7 with Drupal Commerce Kickstart (Kickstart2 distribution). I have installed the module SecurePage to manage which pages are under https and which under http, I want under ssl only:

user/*
checkout/*
admin/*

I follow this help :  FOLLOW LINK

The problem is that if I switch from one page in https to one page in http, I lose the session, the same problem occurs in the registration steps, after the user registration are complete the user will be redirected to the homepage of the shop, with no messages system like "Check in your email etc ..."

Does anyone have a solution for this?
Thanks.


texts: File uploads for non-administrators fail

texts: I've got a file field on a profile type. The allowed file extensions is .pdf. When I try to upload a pdf file with the admin account it works very well, but when I try to upload with another authenticated user, the message "An illegal choice has been detected. Please contact the site administrator" appears.


texts: How do I redirect from /index.php/event/* to /event?

texts:
I have old links, for example the following ones.

index.php/event/nr1
index.php/event/nr2

If users are coming on index.php/event/*, they should be redirected to
/event.

How can I achieve this?


texts: How to resolve 'Fields pending deletion' and force deletion of said field?

texts:
I'm stuck with an uninstallable module. Drupal insists that there are Fields pending deletion and that the module can not be uninstalled. I've run cron zillion times already as advised for such situations but without success. Cron runs fine, but drupal insists that still, Fields pending deletion.

Visiting /admin/reports/fields gives no clues - the fields provided by that module are not listed. I even tried using drupal console to uninstall module with --force switch, but also without success.

I also tried drush field-info in hope to get some clues, but that's apparently not yet implemented as drush 8.1.2 gives fatal error:

  Call to undefined function field_info_fields().

How do I make drupal delete those fields that pending deletion? Do I have to do this manually in database?

I've seen few tables like field_deleted_data_f5e7b87e32 or field_deleted_revision_be01eddd10 but they are all empty. Is that even relevant?


texts: Custom date format (instead of %date) for WebForm e-mail title?

texts:
I have an webform with e-mails adresses that I want to send notifications to.

I want to make the title of the e-mail as e.g. "new message 2017-03-20".

I have tried with pattern suggested under another field (e-mail body):

new message %date

But it output the formatted date:

new message sunday, march 25, 2017 - 17:54

Is there a way to put here date in yyyy-mm-dd format without chaning the global date formatting on the website?

I also tried to add something like the pattern that is not listed under field:

new message [entity-fetched:field_event_date]

but it does not get replaced at all (I get message with that literal title):

new message [entity-fetched:field_event_date]


texts:
I have one cck content type and two fields in this content type 1. is First name 2. is Last name i am trying TODO when i fill this these fields and click on save button Automatically create Forum topic with the name of first name text box value.
 how it is possible ? plz help
i am using Drupal 6


texts: Theming: Is this a valid way to go about it

texts:
Total newbie at Drupal. Is it valid to say that I could code a page in pure html/css and then start adding the php variables needed to eventually make the page.tpl.php?

Or should I go about it by creating the tpl.php file differently?

That feels possible but all the reading I've done hasn't explicitly said it that way.


texts: How to disable Rich Text Editor in image field caption ?

texts: I am using Image Field Caption module. It provide a image caption field but I don't want any rich text editor appearing for the caption field. How to disable that for any specific field?


texts: How can I give a list_string BaseFieldDefinition in a content entity a default starting value?

texts:
I have an entity with a list_string field in my content entity that outputs to the entity form as a list of checkboxes. IE:

$fields['colors'] = BaseFieldDefinition::create("list_string")
  ->setSettings([
    'allowed_values' => ['blue' => 'Blue', 'red' => 'Red', 'green' => 'Green']
  ])
  ->setLabel('Color')
  ->setDescription('Select color')
  ->setRequired(TRUE)
  ->setCardinality(-1)
  ->setDisplayOptions('form', array(
    'type' => 'options_buttons',
    'weight' => 2,
  ))
  ->setDisplayConfigurable('form', TRUE);

Is there a way for me to give this field a default starting value. IE, when the user creates a new entity, red and green start out selected on the form?


texts: How do I disable Commerce cart order refresh to preserve custom prices on line items?

texts:
The goal is to allow the user to select the quantity they want, hit Add to Cart, then have the script separate the Line Item into individual Line Items with the Quantity of 1. I have accomplished this using Rule which works great but we also use Commerce Pricing Attributes which allows you to alter the price of a product before adding to cart. The altered price does not carry through to the split Line Items using this Rule. My script so far does keep that price.

This works for the first time the cart is loaded. The second time the cart is loaded, the original price is not applied to the added line items. Instead they remain in tack but get their default price applied.

Here is the shopping cart when it's first loaded after clicking the Cart link in the popup message. Everything appears OK with price across all items.

Here is what it looks like when I refresh the page, update cart, proceed to next step - pretty much anything that will trigger the commerce_cart_order_refresh().

As you can see the original item retains it's altered price, but the others that were added now default back to their original price.

Here is my code:

function ces_line_items_commerce_cart_line_item_refresh($line_item, $order_wrapper){
    // set the global user
    global $user;
    // load the entity wrapper of the line item
    $line_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
    // get the quantity of the line item
    $quantity = (int)$line_wrapper->quantity->value();
    // get the product id to use later
    $product_id = $line_wrapper->commerce_product->product_id->value();
    // set the altered price or current price of line item
    $newPrice = $line_wrapper->commerce_unit_price->amount->value();
    // get the original line item
    $old_line_item = $line_wrapper->line_item_id->value();
    // load the original line item -- need to do this for rewriting later
    $original_line_item = commerce_line_item_load($old_line_item);
    // set our index
    $i = 1;
    // only do the following if the original line item has a quantity above 1
    if($quantity > 1){
        // loop until we are 1 below quantity
        while($i < $quantity) {
            // it the product can be loaded
            if ($product = commerce_product_load($product_id)) {
                // create new line item
                $new_line_item = commerce_product_line_item_new($product, 1, $order_wrapper->order_id, $original_line_item->data);
                // make sure to include any additional price calculations
                drupal_alter('commerce_product_calculate_sell_price_line_item', $new_line_item);
                rules_invoke_event('commerce_product_calculate_sell_price', $new_line_item);
                // reload the line item
                $new_line_item = commerce_cart_product_add($user->uid, $new_line_item, FALSE);
                // set unit price
                $new_line_item->commerce_unit_price['und'][0]['amount'] = $newPrice;
                // set base price
                $new_line_item->commerce_unit_price['und'][0]['data']['components'][0]['price']['amount'] = $newPrice;
                // set base total amount
                $new_line_item->commerce_total['und'][0]['data']['components'][0]['price']['amount'] = $newPrice;
                // save new line item
                commerce_line_item_save($new_line_item);
                // add line item to order wrapper
                $order_wrapper->commerce_line_items[] = $new_line_item;
            }
            // increment our index
            $i++;
        }
    }
    // alter line item quantity back to 1
    $original_line_item->quantity = "1.00";
    // save line item
    commerce_line_item_save($original_line_item);
}

So what I need is the ability to disable commerce_cart_order_refresh from trying to default everything back.


texts: Adding custom form to form_alter -- help please

texts:
I've been trying for awhile to add a custom form to a custom module so as to make it show in drupal profile Edit page. Using the normal $form['submit'] messes up the other forms in the page, so tried to use $form['#submit'][] and append the second submit handler, but still no luck. Hoping someone can see what i am doing wrong.

Here is the code i have so far:

function custom_module_form_alter(&$form, &$form_state, $form_id) {
 if ($form_id == 'user_profile_form' && user_access('delete mods', $form['#user'])) {

$modlist = getcurrentmods(); // this function returns an array of usernames

$form['modlist']['mods'] = array(
'#type'=>'select',
'#options' => $modlist,
'#multiple' => false,
'#weight' => 30,
'#size' => 10,
'#id' => 'modlist',
'#prefix' => '
',
'#suffix' => '
',
 );

$form['#submit'][] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array('_modlist_delete_callback'),
'#weight' => 32,
'#attributes' => array(
    'class' => array('submit-inline'),
),
'#ajax' => array('callback' => '_modlist_delete_callback',
'wrapper' => 'dropdown-modlist',
'effect' => 'fade',
'method' => 'replace',
  ),
 );

  }
}

The dropdown with the user list shows up fine, however the submit button doesn't.


texts: Hook or any other extension place for changing the input format order in form display?

texts:
I want to change the order of the input formats (e.g. input format "rich text" comes before "text" in content type "article") in the node form field display. Could you recommend me a hook or any other place for my own code extension, please?

I do not want to use the better formats module for this, because I need this only for a few fields and this module is not stable, yet.

I have tried hook_field_widget_form_alter(), but it seems for me to be not the right place.


texts: Why isn't my custom Form API #states applied in my webform yaml editor working?

texts:
I have the need to set visibility state of a checkbox option in one question (Table checkbox select) based on the value of another checkbox in the same table. I also have other scenarios where I would need same functionality but across different questions in the same webform.

I know I can easily do it between two different questions ( 2 different elements) with the built-in conditional logic UI in webform but no such UI option for my case now (afaik) so I'm trying to set it via the custom one and this is my first time with form states and custom condition in webform so I appreciate your kind help so greatly.

I went through trials and errors and the code wasn't being saved till I, thanks to @jrockowitz 's tip, learnt that I was using php code where I need to use yaml code since I'm using the yaml source editor (shown in the screenshot below). When I fixed that, my custom code would save and it reflects as entered in the webform source yaml. However, the custom condition is still not working as expected and I'm still not sure why.

I'm adding the code in the Edit source box accessible via clicking its link on the form "Conditions" tab.

I got the selectors for the involved question options from the "Available selectors" list by clicking on the "Help" link under "Learn more about Drupal's Form API #states." on the "Conditional Logic" for the element editing tab in my webform.

This is a sample full yaml code for the form with a sample question and what I want to achieve but not yet working:

some_question:
  '#type': tableselect
  '#title': 'some question'
  '#options':
    q1: 'q1 (hide if q2 is checked)'
    q2: 'q2 (hide if q1 is checked)'
    q3: q3
    q4: q4
    q5: q5
    q6: q6
    q7: q7
  '#states':
    ':input[name="some_question[q2]"]':
      invisible:
        ':input[name="some_question[q1]"]':
          checked: true
    ':input[name="some_question[q1]"]':
      invisible:
        ':input[name="some_question[q2]"]':
          checked: true

What am I missing here ?!

For those who maybe aren't familiar with the UI edit source, this is a link with info and screenshots : https://www.drupal.org/node/3012686
Note: As per @leymannx 's kind advice, I re-wrote the whole question to rid it of my dump of updates with my trials and errors. I hope it's now cleaner, clearer and more worthy of up-votes :)


texts:
I'm trying to install a module via the new Drupal Console on Drupal 8.

I chmodded my modules directory to 777 without success.

drupal module:install admin_toolbar

[ERROR] Unable to install modules admin_toolbar due to missing modules admin_toolbar


texts:
I am using Notify module for new content notification to registered users.

The email send by notify module is in plain text format. I want to theme the email and add image or video thumbnails for embedded videos.

I searched the web but couldn't find a solution. Can someone help me, please?

Thanks


texts: How to email the webform content to current page author email "Token [current-page:node:author:mail] is not working any more"

texts:
I have a content type topic, and a Webfrom "contact" as block which is available for topic content type only.

Any registered user can create topic, and I want to use the Webfrom to contact the topic author.

In the past I had a hidden field inside Webfrom with a  token [current-page:node:author:mail] to send the Webform information to the current page author email "topic author".

After updating the Webfrom to version 7.x-4.9 the Webfrom stop sending email.

It looks like [current-page:node:author:mail] is not available any more.

I will be grateful if someone help me with identifying the right token to access the current page author mail. or suggest alternative way to achieve the same functionality.

Thanks


texts: Views content pane - return half the results

texts:
I'm trying to work a view into a panels layout and would like to break up the list of results with another type of panel in the middle. Is it possible to create a views content pane returning the first half of all results, then a second views content pane returning the second half? Or is there another way to do this?

I can imagine some options using a custom template for the view, but I'd prefer to do this through Drupal config if possible.


texts: What is a point of relationships in view of index (search_api)?

texts: What is a point of relationships in view that is showing an search_api index, if you can resolve relationships at search_api level - when you are choosing fields to index? Is there any?


texts: what is the hook when a commerce order is updated?

texts:
I am searching for a hook name when a commerce order is updated ?

Indeed I have programmed a module that it must perform some operations when a commerce order is modified. for example when order status is changed or when a line item in selected order is changed.

do you know what is the hook name when a commerce order is modified ?


texts: Drupal 8 - Check if language prefix is present in url or not

texts:
Is there a way in the drupal 8 api to figure out if a language prefix is present in the url or not? Cause I need this information in order to display a custom language switcher if no prefix exists in the url. So for language detection I only have the prefix enabled.

Unfortunately this code is not working for me:

$languagecode = \Drupal::languageManager()->getCurrentLanguage()->getId();

Cause it always returns me a language. When no prefix is present in the url it returns me (as excepted) the fallback language.

Has someone a similar situation or can help me here?


texts: How to output content type title on page.tpl.php?

texts:
So I am using this code to output nodes title:

<?php print render($title_prefix); ?>
<?php if ($title): ?>
<?php print $title; ?>
<?php endif; ?>
<?php print render($title_suffix); ?>

What code do I need to output the content type's name (i.e. content type is Article, so output 'Article' inside each Article content type node page next to node title, above or below it)?


texts:
Trying to schedule a content type to be unpublished on a specific date. Using the scheduler module everything is set up seemingly correct. When I run Cron the update fails,

Updater Content - Publishing status complete. Results: No updates were performed. 1 updates were invalid
When i go to Scheduled Updates Overview and run scheduled updates manually it works just fine.

Why is Cron Failing?


texts:
I've been trying to set up a debug environment for Drush using Eclipse(Kepler), in order to find out why the difference of the result of running hook_install() between via Web UI and via "Drush en".  My LAMP stack is ZendServer(6.0.1), and I am using ZendDebugger. So far it works fine for Drupal debugging.

I followed this post: http://blokspeed.net/blog/2012/04/debugging-drush-with-eclipse-and-xdebug/ to begin the setup.  The Eclipse prompts for the root folder for Drush to run and it seems to be picked-up by Drush, but on console Drush still complains that it needs a higher bootstrap level to run:

Command pm-enable needs a higher bootstrap level to run - you will       [error]
need to invoke drush from a more functional Drupal environment to run
this command. [0.58 sec, 12.04 MB]

The directory                                                            [error]
/Users/r8d/dev/git/drupal/sites/10088.localhost does
not contain a valid Drupal installation [0.59 sec, 12.04 MB]

Where /Users/r8d/dev/git/drupal is the Document root of this Drupal site and the settings.php is indeed located within sites/10088.localhost.

I compared the $_SERVER variables and have found these values are different from running Drush directly from command-line in the 10088.localhost folder:

From command-line:

Array
(
...
[SCRIPT_FILENAME] => /usr/local/zend/share/pear/drush/drush.php
[SCRIPT_NAME] => /index.php
[PWD] => /Users/r8d/dev/git/drupal/sites/10088.localhost
…
)

The index.php is where the Drupal bootstrap starts.

But, in Eclipse:

Array
(
...
[SCRIPT_FILENAME] => /usr/local/zend/share/pear/drush/drush.php
[SCRIPT_NAME] => /usr/local/zend/share/pear/drush/drush.php
[PWD] => /usr/local/zend/share/pear/drush
…
)

I then tried to make an Environment variable PWD in the debug setting to hopefully override $_SERVER['PWD'] but in vein.

The debugging does work for Drush itself, though. I can step within Drush till it ends with error. Just that, although Drush does pick up the --root argument, hence the error message, it seems not seeing settings.php, which is vital in order to debug the hook_install() in the Drupal site.

Besides all these findings, I also find PHP executable also matters.  I use the php executable that comes with ZendServer at /usr/local/zend/bin/php, with /usr/local/zend/etc/php.ini and SAPI Type set to CLI.  If I switch to /usr/local/zend/bin/php-cli the drush command will run like no argument is taken, although it uses the same php.ini.

Is there anything I am missing? What should I do to get the drush debuggin work? I am meanwhile still digging the difference of environment settings with Eclipse. Thanks in advance for those who try to understand the situation and give advices!


texts: Class not dynamically loaded in custom module

texts:
I have a very simple Drupal 7 module in which I want to load a custom class. I'm not able to load the class and I get the following error when I enable the module:

Fatal error: Class 'Drupal\testmodule\TestClass' not found in www/sites/all/modules/testmodule/testmodule.module on line 4

Here are the contents of my module files:

testmodule.info

name = "Test Module"
core = 7.x
files[] = src/TestClass.php

testmodule.module

<?php

function testmodule_init() {
  Drupal\testmodule\TestClass::go();
}

src/TestClass.php

<?php

namespace Drupal\testmodule;

class TestClass {
  function go() {
    print 'Foo!';
  }
}

Please could anyone help me understand why Drupal 7's dynamic-loading code registry is not working as documented here: https://www.drupal.org/docs/7/creating-custom-modules/writing-module-info-files-drupal-7x#files ?


texts:
I have this on my template:

  <?php print render($page['left']); ?>

And no matter how many blocks I add to the left sidebar region, nothing prints.

Any ideas?


texts: Resolving mysql error Integrity constraint violation: 1062 Duplicate entry '' for key 'uri':

texts:
I'm getting the integrity constraint violation error (as shown below). There indeed exists a row in file_manage table with uri=''.

So my question is can I simply delete this row entry from the table without any side affects? Additionally how this empty row could have been added here.

Error Output when I do "drush cron":

WD node: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0,                     [error

:db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => 0
    [:db_insert_placeholder_1] => 1
    [:db_insert_placeholder_2] => 1398243826
)
 in drupal_write_record() (line 7166 of D:\WORKAREA\work\htdocs\gij\includes\common.inc).

And here is the table row with empty uri:

mysql> select * from file_managed where uri='';
+------+-----+----------+-----+----------+----------+--------+------------+----------+
| fid  | uid | filename | uri | filemime | filesize | status | timestamp  | origname |
+------+-----+----------+-----+----------+----------+--------+------------+----------+
| 3356 |   0 |          |     |          |        0 |      1 | 1389353548 |          |
+------+-----+----------+-----+----------+----------+--------+------------+----------+
1 row in set (0.00 sec)


texts: How to create a block to remind special dates as stored in user profiles?

texts:
I'm looking for a way to remind special dates per user profile. I mean remember birthdays, marry dates, graduations.

The idea is to display in the home page a block with all those reminders for all the users.

Any suggestions?


texts: Loop over first three items of a list in Rules

texts: I have a list and need to loop only over the first 3 elements of that list in Rules, but I cannot find the option to do this. It seems to be more complicated than I had thought.


texts:
I have a content type with a paragraph field. That paragraph field has two paragraph fields which I will refer to as subparagraphs.

I want to print one of the two subparagraphs depending on the flag set in the preprocess function.

Paragraph: field_banner_header

Subparagraphs: field_banner_header_single, field_banner_header_multi

Twig:

<div class="callout-options">
    {% if callout_options == 'Single' %}
        {{ content.field_banner_header[0]['#node'].field_banner_header_single.value }}
    {% else %}
        {{ content.field_banner_header[0]['#node'].field_banner_header_multi.value }}
    {% endif %}
</div>

I have a preprocess hook that stores the value ('Single' or 'Multi') of a bool in callout_options:

function cse_preprocess_node(&$variables) {
  $node = $variables['elements']['#node'];

  if ($node->getType() == 'unit_landing_page') {
    $variables['callout_options'] = $node->get('field_active_callout_tab')->value;
  }
}

On page render, I get the following error:

  drupal.js?v=8.4.6:13 Uncaught Quick Edit could not associate the
  rendered entity field markup (with
  [data-quickedit-field-id="paragraph/426/field_banner/en/default"])
  with the corresponding rendered entity markup: no parent DOM node
  found with [data-quickedit-entity-id="paragraph/426"]. This is
  typically caused by the theme's template for this entity type
  forgetting to print the attributes.

I could be wrong, but this seems to be telling me that I am referencing the subparagraph incorrectly.

What is the correct syntax for printing a subparagraph?


texts: How can I debug entity queries in Drupal 8?

texts:
Is there an out-of-the-box solution for printing the query of an entity query in Drupal 8?

Right now I'm using kind of a hack, adding:

->addTag('debug')

and then in a custom module:

function mymodule_query_alter($query) {
  if ($query->hasTag('debug')) {
    mymodule_query_debug($query);
  }
}

and then the debug function:

function mymodule_query_debug($query) {

  $sql = (string) $query;
  $quoted = array();
  foreach ((array) $query->arguments() as $key => $val) {
    if (is_array($val)) {
      $val = implode(', ',$val);
    }
    $quoted[$key] = \Drupal::database()->quote($val);
  }
  $sql = strtr($sql, $quoted);
  $sql = str_replace('}', '', $sql);
  $sql = str_replace('{', '', $sql);
  print_r($sql);
  die();
}


texts: Using Drupal 8's Migrate API, how can I map a nested (hierarchical) taxonomy term to the imported entity?

texts:
We have a vocabulary of nested (hierarchical) category terms on a site and are using the Migrate API (via CSV) to import product entities that each have a category term.

The problem is that some of the nested term names are repeated so the importer would not know which nested term to use. For example:

PARENT 1--Child 1
PARENT 1--Child 2
PARENT 2--Child 1
PARENT 2--Child 2

As you can see, the term "Child 1" is used twice, but with different parents.

I can see two possible solutions but I don't know how to go about achieving them. So any help would be appreciated.

1) Would it be possible to include the hierarchy in a delimited field on the CSV and let Migrate create and nest all of the terms and then map the product entity term referring to the last term automatically.

For example. "Parent 1, Child, 1, Child 2"

2) Or, using a source plugin and TWO fields on the CSV, where one is the product category term and the other field is the parent and somehow have Migrate know which parent term ID to use for the category?

Currently, the category YML looks like this:

 field_prod_category:
    -
      plugin: explode
      source: WebCategory1
      delimiter: ','
    -
      plugin: entity_generate
      source:
      value_key: name
      bundle: product_categories
      entity_type: taxonomy_term
      ignore_case: true


texts: Fivestar 'Rate' Graphics not showing correctly

texts:
I'm using Fivestar 'rate' across 3 separate web projects. It works fine on 2, but as shown in the graphic link below, has issues on one. I've tried to no avail to figure out what the issue is and compared all other modules across the other installs but I can't see what is causing it. I'm using the latest version of Fivestar, checked file permissions etc, etc. The Fivestar rating is as a field within a Content Node Panel Page.

Of course the images should just show Five Stars and not a "Give it x/5" five line-wide list with rating (4/05 etc) on it.

Has anyone else had this issue and how did you fix it. Any other suggestions welcome.

Thanks in advance.


texts: Sort by weight using \Drupal::entityQuery()

texts:
I want to get all taxonomy term in $lang language, following snippet works correctly and return all terms of $lang code.

    $query = \Drupal::entityQuery('taxonomy_term');
    $query->condition('vid', "news_category");
    $query->condition('langcode', $lang);
    $tids = $query->execute();
    //$terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids);
    return new JsonResponse($tids);

Then I want get results in order that in the taxonomy list they are, try to sort them with $query->sort('weight','ASC'); but with following snippet the results are  the same before adding sort.

    $query = \Drupal::entityQuery('taxonomy_term');
    $query->condition('vid', "news_category");
    $query->condition('langcode', $lang);
    $query->sort('weight','ASC');
    $tids = $query->execute();
    //$terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids);
    return new JsonResponse($tids);

Does anybody know where the problem is? How can I get terms in order they are in  taxonomy list?


texts:
There are two URL's on which I want to suppress a VIEW , Below are the urls's :

http://mysite.com/drupal/?q=searchpanel&body_value=
http://mysite.com/drupal/?q=searchpanel

How can I stop a view to appear on above link .

Thanks for any help in this!


texts: Display term description below a field widget based on the selected option on node edit form

texts:
I am trying to show a block (or the term description) on the node edit form when a user selects the term.

An example:

User is creating a node with a "location" vocabulary. They select their state (parent term), then a region in the state. A block or the term description will display directly below the dropdown for the parent term (their chosen state). If they select another state, another block or term description will come up for that state.

Basically each term in the vocabulary will have subtle but different submissions guidelines and I would like to inform the user during the node creation process as to the guidelines for each state.

I am not sure if I should create a "state submission guidelines" content type then Entity Reference it, build a view and embed it or try to get the term description or another field attached to the term to show. How does one make dynamic node edit forms?

I am running Drupal 7, Display Suite, Views, CSHS, Rules as the main stack.

EDIT: I am also using Conditional Fields if that can be utilized.

Thanks.


texts: Best Way to share content across a UK and USA website

texts:
I am creating a website that will have a US and UK section and we are going to separate the two via the addresses ....com/uk and ....com/us.

Some of the content will be the same and some of it will differ.  The menu structure will also differ.

The site is relatively small and about half of the content will be shared between the two and half of it will be unique.

We have had had a look at the language/internationalisation modules and they seem a little bit overkill for our needs.

It seems that the best way to achieve this for the shared content is to have a "Shared Page" content type that is never seen, but then a View that accepts a contextual filter in the url (the title) which displays the body of the node at both uk/title and us/title.

However I read somewhere that it is not a good idea to use views to display only a single node and that they should be used only for lists etc.

Is this the case?  If so what method should I use if I want to display a single node at two locations?


texts: Procedure For Cloning Commerce Collection Taxonomy View Page?

texts:
We are creating a store with Commerce Kickstart2. We need to duplicate the functionality of the Collection taxonomy. Essentially, we need -exactly- what the collection field does, but we need another one to organise products in a different way.

I've created a new Taxonomy term called 'Specialty'. I've successfully added that field to the Products. They can be searched and displayed and if I type in

/specialty/whatever-term

...I get a basic taxonomy term page of the correct products.

What I want to do is clone the View called 'collection-products' to a new view 'specialty-products' which does -exactly- the same thing, but for the new vocabulary 'Specialty'. I took a wild stab at it:

I copied/renamed the PHP file for the view into my theme folder

views-view--specialty-products--page.tpl.php

Edited that php replacing 'specialty' for all the vars 'collection'.
I cloned the collection-products view and replaced the 'collection' field with 'specialty' where necessary.

So (naturally) this does nothing.

Can someone provide guideance on where I went wrong or how to proceed from here?


texts: Add additional CSS class for particullar field in a node

texts:
I'm trying to add additional CSS class to a field after the field is added. But not for all fields of that particullar content type, but only for those, that editor would like to. Like a module Formatter_field lets user to chose the field format - I have an image field and couple of different image formats, which I can chose after I upload an image which formatter_field.

I cannot find anywhere a solution, how to add additional css class to the same field.

For example:

User uploads an image via image field, using formatter_field he/she choses image format from image_cache and then adds CSS class wich adds border. Then adds another image to the same node (as image field is set to "unlimited"), choses different format and adds different CSS class, which gives different border to that image. And all this in one node.

update:

In my exact case I want to create a horizontal gallery, where images and texts are shown inline horizontally in such a way, that some of the pictures are bigger, some are smaller and are aligned in different heights and sometimes between those pictures there are text blocks with explanations about the works. Like in on a real gallery wall. :) Would be great that all one gallery is one node as it is easier to edit.


texts: How do I save patched core after new upgrade?

texts:
I had to apply custom patch on Drupal 7 core and now I'm afraid that after rolling a new minor-upgrade over, it'll overwrite my changes.

Is there any way for me to preserve my changes even after upgrading to a new minor patch of core (in case that this patch haven't been applied to that version I'm upgrading to ), like creating a patched folder or something and make sure that my core stays operational?


texts:
I'm looking for a way to export Taxonomy vocabs and their associated terms. So far I've found and tested:

Taxonomy Export -- Exports to code using features but doesn't import.

http://drupal.org/node/755986 -- My brief testing with this patch showed mixed results.

Does anyone have any other module suggestions or code solutions? I could write it all into a hook_install and then use hook_update to update but it doesn't seem like an elegant solution especially for 500+ terms.


texts: Creating Image Captions using File Entity module

texts:
The purpose is to create image captions to all images uploaded in Drupal.

What I did:

installed media 2.0 / file entity 2.0 alpha2
added a new field called 'captions' in the image file types:
admin/structure/file-types

Now I can add captions in the body field images.

I need the captions to be visible for other fields like image upload field.

How to exposed file_entity's fields in the content type form fields?