texts: Delete node references for some content types only

texts:
Unless there's a method I'm unaware of, node references are not related to their node's content type. I need to delete referenced nodes when the target ids are not of a certain content type. Here's my code so far.

// Get My content type nodes.
$nids = \Drupal::entityQuery('node')
  ->condition('type', 'my_content_type')
  ->execute();
/** @var \Drupal\node\NodeInterface[] $nodes */
$nodes = Node::loadMultiple($nids);
foreach ($nodes as $node) {
  // Select the related nodes from each node.
  $result = \Drupal::database()->select('node__my_reference_field', 'n')
    ->fields('n')
    ->condition('entity_id', $node->id())
    ->execute();

  // Determine what content type the related node is.
  while ($record = $result->fetchAssoc()) {
    $query = \Drupal::database()->select('node_field_data', 'nfd');
    $query->fields('nfd', ['type']);
    $query->condition('nid', $record['my_reference_field_target_id']);
    $type = $query->execute()->fetchField();

    if ($type != 'content_type_one' || $type != 'content_type_two') {
      \Drupal::database()->delete('node__my_reference_field')
        ->condition('entity_id', $node->id())
        ->condition('my_reference_field_target_id', $record['my_reference_field_target_id'])
        ->execute();
    }
  }
}

If this line

if ($type != 'content_type_one' || $type != 'content_type_two') {

were

if ($type == 'content_type_one' || $type == 'content_type_two') {

the related nodes of content_type_one and content_type_two are deleted. Using != removes all the related nodes on the node. I only want to remove the related nodes that are not of content_type_one and content_type_two.

What am I missing?

@Jaypan here's the exact code that takes nine minutes to run.

function my_module_update_8008() {
  // Get the nodes.
  $nids = \Drupal::entityQuery('node')
    ->condition('type', 'my_type')
    ->execute();

  /** @var \Drupal\node\NodeInterface[] $nodes */
  $nodes = Node::loadMultiple($nids);

  foreach ($nodes as $node) {
    // Delete references on the nodes that are not news or story.
    foreach ($node->get('field_entity_reference')->referencedEntities() as $entity) {
      drush_print($node->id());
      if (!in_array($entity->bundle(), ['news', 'story'])) {
        $entity->delete();
      }
    }
  }
}

drush_print() is for debugging purposes. During the run of this code, a $node->id() prints every 1 or 2 seconds. As you well know, to run an update_N hook from the command line, use

drush php-eval 'module_load_include('install', 'my_module'); my_module_update_8008();';

Anyway, it's 160 nodes x ~20 node references for each node. So the drush_print() helps me understand where the time is going.

Thanks for your help. I didn't mean to sound ungrateful. I think referencedEntities() and $entity->bundle() and the like are great, but I find them too slow. Once I have the field table populated with only the records I need, drush cr gets the referenced nodes to print in the text fields on the admin. I'll post my query code when I get it working again.

Btw, it's getStorage() not loadStorage() with entityTypeManager(). Thanks again.


texts: Clicking any administration menu link results in empty overlay screen

texts:
I've created a Drupal site which behaves rather strange - whenever I click an item in the administration menu or use a contextual link to edit a page, the half-opaque overlay shows, but no editing window opens on top of it as it should  (not just "not immediately", but never).

Once I'm in "overlay mode", if I click a menu item, the linked page opens as it should, on top of the overlay. From here, all items work as intended, except when opened in a new tab - that will also only show an empty overlay page.

When the overlay is eventually closed again (for example, by clicking the home link to return to the front page), the error described above will reoccur the next time an administrative link is clicked.

Can anyone assist me in finding the source of this problem? Please let me know if you need additional information.

The site was built on 7.53 originally and is now updated to 7.54 (up to date). No changes to the .htaccess file have been made, therefore all of my changes are within the /sites/ directory.

I'm using these contrib modules: Chaos tools, CKEditor, Views, Views UI, Webform

My administration theme is Seven.

I've set up other Drupal 7 sites on the same environment and didn't have this problem, so I clearly I did something different here. I have no idea where to start looking, though, and wasn't successful in finding other questions or external info covering anything even remotely related.


texts: How can I print a field value in node.html.twig?

texts:
I want to print a field value in node.html.twig. When I use {{ content.field_test }}, it prints the full HTML markup of the field.

How can I just print the field value?


texts: Grouping Content Panes in Views For Theming

texts:
I've created a view for a specific content type. This view has a number of Content Panes associated with it.

I need to apply a row template file to about half these panes but the only tpl name suggestions the "Theme: Information" section gives are shared across all panes.

Is there a way to delineate certain panes for templating purposes? Machine name kind of works but I don't want to end up with views-view-fields--machine-name-1.tpl.php, views-view-fields--machine-name-2.tpl.php, ....

Thank you!


texts: Is there a way to restrict some pages like node/add, /user/login and more?

texts:
Can we restrict some page like

node/add
/user
/user/register - as I dont have login/registration page at all
/user/login
node/200 or node/500 - so that may be of any content type

and it should be unlimited. I need to show Access denied page when somebody accessed those pages.

Though I can use programmatically drupal_access_denied() function, do we have any other option on this.


texts: What is the best way to access css and js from drupal 8 theme

texts:
I am integrating angular 2 in a drupal 8 theme. Angular 2 needs to access multiple CSS and js files for the components.

If I include it using the libraries it gets concatenated and gets exported into files directory. I need concatenation for other resources. Is their a way to avoid concatenation for just one library alone.

The solution I took was to hardcode path to assets. Like /themes/themename/app/main.js etc...

Is this okay? Will it work in multi site as well?


texts: Where is the 'Access Rules' in Drupal 7?

texts:
I want to restrict site registration by email domain.

It used to be under Administration → User Mgmt.

I can't see any similar, or has this functionality been removed from the standard module set?


texts: How can get five star rating data in drupal 6 services views?

texts:
i am using drupal 6.x, added five star(fivestar module) rating functionality to a node in my site.
Everything working fine but i want to users rated data in drupal json services for mobile development, In json services i m getting nodes every data except rating.. so can you please help me. How can i get the users rating data in json services(Services_view module).

Thanks in advance.


texts: How to restrict anonymous users without ajax error risk?

texts:
I want to restrict anonymous users from viewing the site accept few pages. There are few modules. I was using require login module. It was working perfectly as it redirected anonymous users to login page, but after some time past, I was getting an ajax error mentioned in my previous question. So I had to uninstall require_login module.

Is there any other way to have such functionality without having a risk of ajax errors?

The previous question was closed so here is the screen shot


texts: How can I set my Feed importer to unlimited?

texts:
I'm trying to import a list from SharePoint 2010 to Drupal 7 but it only imports/creates 10 nodes, while there are more items in the list.

I've tried adding $conf['feeds_process_limit'] = 0;  in the settings.php and clearing the cache, but no luck.

Also tried to change define('FEEDS_PROCESS_LIMIT', 50); in the FeedsProcessor.inc file.

It doesn't matter where I change a number, it sticks to 10. And I can't find any setting that's 10.

Best regards,
Stefki


texts: Ajax form submit - how to recognize if form contains errors in ajax callback?

texts:
I have a simple form with ajax submit:

function activit_registration_form($form, $state) {

  $form["ajax-start"] = array("#markup" => "
");

  // ... some form elements are here

  $form["submit"] = array(
      "#type" => "submit",
      "#value" => t("Odoslať"),
      "#ajax" => array(
          "callback" => "activit_registration_form_ajax",
          "wrapper" => "registration-form-ajax",
          "effect" => "fade"));

  $form["ajax-end"] = array("#markup" => "
");

  return $form;

}

Ajax callback:

function activit_registration_form_ajax($form, $state) {

  return $form;
}

Validation:

function activit_registration_form_validate($form, $state) {

  if(!valid_email_address($state['input']['email'])) { form_set_error('email', 'email'); }
  if(strlen(strval($state['input']['name']))<3) { form_set_error('name', 'meno'); }
  if(strlen(strval($state['input']['tel']))<6) { form_set_error('tel', 'tel'); }

}

Ajax callback is now returning the same form, but I would like to achieve returning just a simple string instead of the form when form does not contain any errors.

What is the best way to recognize if a form contains errors or not in ajax callback?


texts:
I am trying to add a menu item to a custom menu programmatically in Drupal 6 and have almost gotten it but ran into a weird problem. I can add the item to the menu using the code: drupal_execute('menu_edit_item', $item_array, 'add', NULL, array('menu_name' => $menu_name));
drupal_flush_all_caches();
This somewhat works, but for the link to actually show up in the menu I have to either save the page twice, or save the page and clear the cache from Admin > Performance. Does anyone know why I need to flush the caches twice, or is there a better way to do this? Let me know if you need any more information, I included what I thought was relevant but I may have left something out.


texts: "The website encountered an unexpected error." on front page only

texts:
We are encountering this error:

Error

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

On frontpage only and if the user is anonymous. If logged in, we can view the front page but if not, we see this error.

This is the error message from the error log.

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'node.entity_id' in 'where clause': SELECT COUNT(*) AS expression FROM
  (SELECT 1 AS expression FROM {node} node WHERE (node.nid =
  :db_condition_placeholder_0) AND (node.type IN
  (:db_condition_placeholder_1)) AND(( ( EXISTS (SELECT na.nid AS nid
  FROM {node_access} na WHERE (( (na.gid = :db_condition_placeholder_2)
  AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid =
  :db_condition_placeholder_4) AND (na.realm =
  :db_condition_placeholder_5) ))AND (na.grant_view >=
  :db_condition_placeholder_6) AND (node.entity_id = na.nid) )) AND
  (node.entity_type = :db_condition_placeholder_7) )OR (node.entity_type
  <> :db_condition_placeholder_8) )) subquery; Array (
  [:db_condition_placeholder_0] => -1 [:db_condition_placeholder_1] =>
  evite [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3]
  => all [:db_condition_placeholder_4] => 0 [:db_condition_placeholder_5] => flag_friend
  [:db_condition_placeholder_6] => 1 [:db_condition_placeholder_7] =>
  node [:db_condition_placeholder_8] => node ) in
  EntityFieldQuery->execute() (line 1154 of
  /var/www/vanille/includes/entity.inc).


texts: Drupal, Displaying a Content list of a User from their Profile, accessible by anyone via Views

texts:
I am running Drupal 7 and I would like to know how to create a View that displays as a tab on a users profile that displays all of his or her created content. This is what I have so far, but it only shows the tab for the logged in user, no one else can access it.

I got most of the code from here.


texts:
How to use #states in add node form?
I don't experience any problems when use them with exposed filters (on user side), but cannot do the same when additing new nodes.
I tried the following code:

function custom_module_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    $form['field_coordinate']['und'][0]['#default_value'] = t('1');
    $form['field_name_tag']['und']['0']['#states'] = array(
      'invisible' => array('select[id="edit-field-location-tag-und"]' => array('value' => '1')),
    );
  };
}

Where is my mistake?


texts: menu_tree_page_data() is not loading sub-menu items

texts:
I have created a menu that has a handful of top level items and some sub-menu items.  it is similar in structure to my "main menu". It is my understanding that each top level menu item is an array, which also contains an array of menu items that are "below" that menu item.

When I print out the array of the menu it will not show the sub-menu items. Am I doing something wrong?

$mm = menu_tree_page_data('menu-second-menu');
print_r($mm);

My ultimate goal is creating X amount of individual menus, and display them in various places throughout the theme.

When I print the array values for the "Main Menu", which is assigned to a block and working, I do see the sub-menu items right where I'd expect them to be.


texts: Commerce Payflow Link - User authentication failed

texts:
I keep getting User authentication failed from the Payflow server Response.  I've verified the password (even have gone as far as resetting it) and I still get the same result.

I'm currently working on upgrading a D6 Ubercart site to D7 Commerce (if I can get past this one road block).  I've created a new user through Paypal Manager for this module and gave it the role of API_FULL_TRANSACTIONS as suggested.  Verified the user name and password but I'm still having problems authenticating apparently.

Maybe I'm not setting Payflow Link up correctly on the Commerce side?  Are there any walk through or videos? Any help is greatly appreciated.


texts: How to create template suggestion for image like IMAGE--BLOCK-TYPE or IMAGE--FIELD-TYPE

texts:
I'm struggling to make template suggestions like IMAGE--BLOCK-TYPE or IMAGE--FIELD-TYPE.
I have three different block types(image1, image2, image3) with one image field(field_image_1, field_image_2 and field_image_3).
And I don't know how to get suggestion like
image--block_image1.html.twig
image--block_image2.html.twig
image--block_image3.html.twig

or
image--field_image_1.html.twig
image--field_image_2.html.twig
image--field_image_3.html.twig

Is there any way to pass variable between the two hooks below?
  function full_nature_theme_suggestions_block_alter(array &$suggestions, array $variables) {

    global $block_id;

    $block_id = $variables['elements']['#id'];

  }

and
  function full_nature_theme_suggestions_image_alter(array &$suggestions, array $variables) {

    $suggestions[] = 'image__'.$block_id;

  }

Please help!


texts:
How do I rewrite views field result programmatically? I want to change the link basing on another field value.

I have a field called room typ,e which is a reference to taxonomy terms (Bedroom / Meeting Room). The second field is the node ID, which I want to use to give the link of the page (there are two different page: Enquiry and Booking). If the selected term is Bedroom, I want to link the Booking page; if the selected term is Meeting room, the link should be Enquiry. I want to change the link text for Meeting room: It should be Enquire Now and Book Now.


texts: User Register page is different if there is a destination parameter in the url

texts:
I'm trying to find where to go in Drupal to find out how a user register form is displayed.

If the url is user/register, a person is routed to a standard registration form.

However, if the url is user/register?destination=voucher, then that person is routed to a user registration form that mimics our popup modal registration form, however, is not in a popup. This is not the regular registration form.

I want to find where this is set so that if a destination parameter is in the url, to go to the standard registration form.


texts: Restoring tempstore with another session ID

texts:
I am building the functionality of sign in during payment checkout in Drupal 8, and I am storing all the values in Drupal 8's tempstore variable. I am capturing the session id for this anonymous user. After the user is signed in, his session ID changes, and I am not able to load the tempstore with the session ID of anonymous user. Is there a way to restore the private tempstore by another tempstore session ID?

So, the submit function of my custom sign in form looks something like this:

$anonymous_session_id = session_id();

$user = user_load_by_mail($form_state->getValue('username'));
$uid  = $user->get('uid')->value;
user_login_finalize($user);

$temp_store = \Drupal::service('user.private_tempstore')->get($anonymous_session_id . '_com_reg');

When I do $temp_store->get('some_value'); it does not give me any result since I am not able to restore the values. Can someone please help in this?


texts: Vews Load More remember scroll position and take user there after coming back from single node

texts:
im using this plugin for lazy loading images Views Load More.

So i have page with photos that links to individual nodes, and im using lazy load on it, its a view that loads 15 items per batch, there are some pages that have 1000+ images.

Than when user scrolls and clicks on one image and lets say he is on 135th image, it will link to a related node, on that node i have button "back" and what im trying to accomplish is that user returns on same position where he was before clicking on item in list, so in our case its on ~135th position. Same thing i want to accomplish with browsers back button.

Is this possible to do with this plugin?


texts: Drupal updating form fields on file upload

texts:
I am trying to update form fields based on an uploaded file. Specifically, the text that is displayed on the webpage.  If the user then presses a submit button, these values are then passed to hook_node_submit() and saved in the database. I'm using hook_form_alter() to perform these updates, and I have found that I can change the default_value of a field when the webpage is first loaded. However, when the upload button is pressed by a user, and hook_form_alter() is called again, the same operation does not work. For instance,

function mymodule_form_alter(&$form, &$form_state, $form_id){
   if ($form_id == 'mymodule_node_form'){

       // I can change the default value here
       $form['field_myfield']['und'][0]['value']['#default_value'] = "Some Value";

       // Check to see if the upload button has been pressed
       if (array_key_exists('clicked_button', $form_state))){
           $trigger = $form_state['clicked_button']['#value'];

           if($trigger == 'Upload'){

               // Try to change the default value here.  The value is changed in $form,
               // but the field is not updated on the website.
               $form['field_myfield']['und'][0]['value']['#default_value'] = "New Value";

               // try changing the value after_build
               $form['#after_build'][] = 'mymodule_after_build';
           }
       }
    }
}

function mymodule_after_build($form, &$form_state){
    $form['field_type']['und'][0]['value']['#value'] = 'New Value';
    $form_state['values']['field_type']['und'][0]['value'] = 'New Value';
    return $form;
}

Do I need to perform some sort of refresh on the form? I briefly looked at AHAH, is this something that I need to use?

I am new to Drupal so I apologize in advance if there is something fundamentally wrong with this approach.  Any help is greatly appreciated.

Edit:

I added some code trying to use an after_build function to change the cck values.  This still doesn't change the value that is rendered on the website.


texts: Making tags in Taxonomy-view appear dynamically?

texts:
Background

I've created a Taxonomy-view that shows about 5 terms each time from a vocabulary of about 40 terms.

My desire

I need that in every page refresh, 5 different tags will be shown Randomly/dynamic, and not the same tags that appear there time and again.

I want to do it with the Views module itself, without further contribs.
I don't want to customize anything manually, rather using only the UI.

Clarification note

I'm not talking about random sorting of the existing 5 tags, rather I mean that each page refresh will bring different 5 tags, that are (generally) different from those in the previous refresh.


texts:
I'm facing a problem with commerce product title length. I want to increase the lenght over 255. What I've tried so far is:

Change DB field from varchar to text
Change the maxlength of the form field
Change the formfield to a textarea

Any of the form changes lead to an error. Any idea how to increase the length?


texts:
I would retrieve the value of a field of the first row, like this:

rows[0].field_name..

but the 'array is too large and kint breaks.


texts:
I have this code:

function THEME_form_user_login_alter (&$form, &$form_state){
  $form['actions']['submit']['#ajax'] = array(
        'callback' => 'ajax_process_form',
        'wrapper' => 'user-login',
        'effect' => 'fade',
        'speed' => 'fast',
        'method' => 'replace'
    );

};

It work when i click on the submit button, but when i press ENTER Ajax doesn't get triggered.. Is there a way around that?

Edit: I tried to enable ajax on all fields and set keystroke to True, but then only one field is sent so i get an error as the form process script is expecting two fields.


texts: Overriding Drupal.Ajax.prototype.setProgressIndicatorBar & Drupal.Ajax.prototype.success

texts:
In drupal 7 you could override the drupal.ajax callbacks by replacing the code and adding it into your custom js file through a thread like this;

How to override Drupal.ajax.prototype.beforeSend?

However, I can't seem to find any documention for drupal 8 in modifying either of the callbacks  Drupal.Ajax.prototype.setProgressIndicatorBar or Drupal.Ajax.prototype.success.

Can anyone shed some light on this?


texts: In a managed_file upload field, how do I prevent an overflow with long file names?

texts:
I have a form using the field type of managed_upload. Things are working fine accept when the file name is long.

Given the snippet of code, below. Might there be a way to override CSS or inject any CSS to keep the fieldset or this span from overrunning the sidebar_second region?

  $form['file_fs'] = array(
    '#type' => 'fieldset',
    '#title' => t('Files'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );

  $form['file_fs']['file'] = [
    '#title' => t('Documents'),
    '#type' => 'managed_file', ,
    '#upload_location' => 'private://',

  ];


texts: Quiz: Multiple choice question - Able to have the question correct with any correct answer

texts:
I am using Quiz Module / Multiple choice. In one question, I have two answers correct and I'm hoping to have the question marked right, if any of the answer is chosen.

Right now, if both answers are chosen, only then the question is marked as correct by the module.

Thanks.


texts: Populate a field in form alter with user name and one with user ID

texts:
can someone tell me why this works

function justatest_form_alter(&$form, $form_state, $form_id) {

  global $user;
  if ( $form_id == 'node_test_form'){
    $form['field_owner']['widget'][0]['value']['#default_value'] = 'test';
  }
  return $form;
}

but this doesn't

function justatest_form_alter(&$form, $form_state, $form_id) {

      global $user;
      if ( $form_id == 'node_test_form'){
        $form['field_owner']['widget'][0]['value']['#default_value'] = $user->uid;
      }
      return $form;
    }

I'd also like to know how I get the current users name too, if someone can assist with that it would be much appreciated.


texts: What's the correct way to redirect the user when a Batch API job finishes?

texts: I've got a form that starts a batch job. What's the right way to redirect them after it finishes? Calling drupal_goto() in my finish function?


texts: How to create dependent exposed filters in a view

texts:
I have three drop-down boxes just like ex:

1. class list (ClassI, ClassII...)
2. subject list (Hindi, English...)
3. chapter list (H-ChapterI, H-ChapterII, E-ChapterI, E-ChapterII...)

When a user clicks on class list drop-down, there will be two option (ClassI, ClassII and so on...). When I select ClassI in a subject list (Hindi, English and so on...) will become as same. When I select on Hindi in chapter list related to Hindi (HChapterI, HChapterII) all chapter will come. This is what I want in my view filter.


texts: What is the Internationalization Views module for?

texts:
In what kind of use cases would one want to use the Internationalization Views module?  I just discovered this module for the first time today, but documentation on it is sparse.

Since it is already possible to translate the fields and rewrites that are used in Views with the standard i18n module, what does this add?


texts:
I am using Drush to update modules.
When I run the command php -v it correctly shows I am running version 5.5

I then use the command drush rf followed by drush up to perform any updates.

I am using the Schema.org Metatag module which requires php version 5.
The website is running php version 5.5.37

The default CLI version on Hostgator shared server is 5.4.45.
That is what I was originally using for drush. When I received the message below I found the path to use php 5.5 but I am still getting the same message.
So I can't figure out how it still sees php ver 5.4.45 and how to resolve this so it doesn't keep disabling that module.

When Drush runs an update I get the following message:
Schema.org Metatag requires at least PHP 5.5. (Currently using PHP   [warning]
5.4.45)

And then it disables the Schema Metatag module.

NOTE:
When I run command drush status:
PHP configuration: opt/php55/lib/php.ini
Drush version is 8.1.11

Thanks

Extra information

.bash_profile

PATH=$PATH:$HOME/bin
export PATH
alias composer="/opt/php55/bin/php ~/bin/composer.phar"
alias drush="/opt/php55/bin/php ~/.composer/vendor/bin/drush.php"

.bashrc

 alias php='/opt/php55/bin/php'
 alias composer='/opt/php55/bin/php ~/bin/composer'
 export DRUSH_PHP='/opt/php55/bin/php'

php -v returns PHP 5.5.37
which php doesn't return anything
drush status returns PHP configuration /opt/php55/lib/php.ini

But, when I use Drush to update a module I still get: Schema.org Metatag requires at least PHP 5.5. (Currently using PHP [warning] 5.4.45)


texts: We have Drupal 7 running on PHP 5.6. Do we upgrade to PHP 7 first, or do we first upgrade Drupal?


texts:
I want to load one last post's title and call value of CCK fields. I defensibly don't want to use views module. so How can I call those CCK Fields?

anyway is this code correct to load one last post from all terms?
I wish there was a way to do it with node_load()

<?PHP
$output = '';
$terms = "*";
$count = 15;
$qry = "SELECT n.title, n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid in ($terms) AND n.status=1 AND n.promote=1 ORDER BY n.created DESC";
$result = db_query_range(db_rewrite_sql($qry), 0, $count);
$output = node_title_list($result);
echo $output;
// echo [cck_field1_value];
// echo [cck_field2_value];
?>


texts: Ajax callback is not working on views exposed filters

texts:
I am implementing dependent filters in views exposed filter for content:datasource search(Solr search). I have a requirement that in exposed dropdown field when a category is selected, by ajax i need to fetch the sub-categories and show up in another dropdown.For this I tried like below but its not going to callback function only. There is nothing logging in the network console also. Can anyone help me here to resolve.

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;

function module_form_alter(&$form, &$form_state, $form_id) {
$form['field_categories']['#ajax'] = array(
        'callback' => 'module_get_subcategories',
        // 'callback' => '::module_get_subcategories',
        'event' => 'change',
        'wrapper' => 'edit-field-subcategory',
        'progress' => array(
          'type' => 'throbber',
          'message' => NULL,
        ),
      );
}

function module_get_subcategories(&$form, FormStateInterface $form_state) {
   $response = new AjaxResponse();
   $message = 'test';
   $response->addCommand(new HtmlCommand('#edit-field-subcategory', $message));
   return $response;
}


texts: What's the difference between "Contexts" in CTools/Panels and in Context module?

texts:
I've been wondering this for a while and always assumed they were different things, but the fact that the Context module uses CTools for its Plugin API kinda confuses me even more...

Can someone please break it down for me please? Thanks!


texts: Openlayers PDO PDOException: Column not found: 1054 Unknown column 'identifier'

texts:
I installed openlayers 3.X and used it a little bit. Then I uninstalled openlayers 3.x and installed openlayers 2.x.

Now when I click on openlayers > maps I get the following error.

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'identifier' in 'where clause': SELECT t__0.* FROM
  {openlayers_projections} t__0 WHERE (identifier IN
  (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0]
  => EPSG:4326 ) in ctools_export_load_object()

  (line 462 of D:\wamp\www\whaymeat\sites\all\modules\ctools\includes\export.inc).

How can I solve this error?


texts: Showing a message while downloading a file from hook_form_submit

texts:
I have a form which creates a csv file and starts a download if it is successful. I also attempt to show a success message at this point but it never shows up because I use drupal_goto to download the file and since it is a file download the page does not refresh:

drupal_set_message("Student accounts created. Please keep the roster CSV filed that has just been download for your future use.");

drupal_goto( file_create_url($file->uri));

Another problem here is that any warning messages from previous failed validation (in hook_form_validate) remain on the page even after success. How Can I the page to refresh while starting a download from hook_form_submit?


texts: removing the 'title' field from custom content types

texts:
I've created a content type to manage people, but in addition to the 'first name' and 'last name' fields that I've created, there's a 'title' field that seems to be present because its a Node module element.

Is there any way to, say, auto-fill it with something and hide it so that users who add content don't have to worry about it? It seems so redundant to have them fill out 'title' in addition to first name and last name.


texts:
I am just getting into drupal features and wanted to make sure I understood something.

I updated my drupal features. Used Git Flow to finish the branches and create a release.
I pulled the new release branch to the staging server.

My question is after I checkout the release branch and run drush fl - I see the features I worked on and committed as overwritten.

I  know on my local if I want the changes I run drush fu to update them. However I thought I remembered that it is the opposite on the staging server. I did run drush fd to get the diff but still learning to read that better.

Thanks!


texts: How can I get form values like first name, last name, email and password in hook_user_insert() in Drupal 8?


texts: How to access node arguments while making an ajax request?

texts:
I have a webform with a file upload field. When I upload a file in this field, without submitting the form, the file is uploaded using AJAX. Now, I want to make some modifications during this call.

Now, the arguments accessed using arg() give ajax arguments. Whereas I need to access the current node's nid when this AJAX request is being made. But arg() is of no use, as it is giving ajax arguments, e.g. arg(1) gives "ajax".

Now, my question is how do I access my node's nid during this AJAX call?

For more clarity, here are more details for what I'm trying to do:

I want to rename the file being uploaded using ajax. For this, I'll modify the $_FILES variable. But the renaming is to be done according to a pattern which includes the current node's nid.


texts: Should I pass the $form parameter when building system_settings_form?

texts:
Usually I refer to core for best practices. When I was building a system settings form I copied and repurposed the following core implementation.

This define the path for the system setting form that gets invoked via drupal_get_form()

  $items['admin/structure/menu/settings'] = array(
    'title' => 'Settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('menu_configure'),
    'access arguments' => array('administer menu'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 5,
    'file' => 'menu.admin.inc',
    );

And this is the function that build the form:

       /**
        * Menu callback; Build the form presenting menu configuration options.
        */
        function menu_configure() {
          // The form definition is here ..
          //.....

        return system_settings_form($form);
       }

So my question is why isn't the $form param passed to the form function menu_configure()?
There are other examples of system settings forms in core, called via the drupal_get_from() that do not have the $form parameter in the parameter list. So is it optional in this case?


texts: I have created a menu tab with views and I want to show that tab only on a certain content type. How can I do this?


texts:
I am building a demo site, trying to learn commerce kickstarter.
I figured out a lot of it but i wanted to add something more to the items.

If you click this link : http://www.sigmaphoto.com/product/sd15-digital-slr-camera
I don't own that or promote that site , i found it on drupale commerce kickstarter showcase.
My question is how can i create tabs that are like under the pictures.
OVERVIEW | TECH SPEC | ACCESSORIES

Do you need to create a view or is there a field that you can add so you can input the data in the content type ?


texts: Where is the code of a new view i've created?

texts:
i'm using drupal 7 with starter theme of zen. i've created a view on a block, now i need to customize some parts of html / css in order to add just media query (css part) and add a <a> tag with display:none for desktop version and display:block for mobile. SO i need to modify html AND css of this view. I'm searching for the php file of this view and i didn't find it.

Any help please ?


texts: How to create static pages that are translatable?

texts:
How to create Drupal 8 static pages that are translatable (3-lingual site)?

I already have HTML code and about 15 static pages which some have dynamic content (latest news etc).

What's the best approach in Drupal?
Do I create lots of blocks with my html or something else?


texts: Fields attached to Workflows do not get saved

texts:
Using Drupal 7.41 and workflow 7.x-2.8, when you attach fields to a Workflow, the fields do not get saved with the workflow field.

It's easy to replicate: Create a workflow, add a field to that workflow in admin/config/workflow/workflow/manage/workflowname/fields (ex: field_confirm), attach a workflow field to a node type (ex: article, I'm using workflowfield here), create an article and set a workflow state & comment. Upon saving the article, the workflow state and comment get saved (see workflow tab) but no field_confirm data gets saved or displayed. The data is not in the database either - the table field_data_field_confirm / field_revision_field_confirm remains empty.

Is that feature not ready yet? Or am I missing something? I tried with workflownode and it didn't seem to work either.


texts: How do I enable "View All" access to an Organic Group Content Type?

texts:
I have a Setup such as following:

- Organic Group - Institution
- Organic Group Content - Query

I want the following:
1. Allow group members to only view the Queries created by themselves (i.e. View Own).
2. Allow the group administrators to View all Queries in their group.

How do I achieve this?

I tried using the Content Access Module and gave the Query Content Type "View Own Permission", this solves the first problem but doesn't allow the group administrators to View all Queries.


texts: Anonymous user's can't views/download files uploaded via file field

texts:
I have a node with a File field and i am using public file system. I have uploaded a file via File field and checked the mark "display" in the list of attached files to node, but still, anonymous user's can't even view it (also they can't download it), till i check this permission:

But i think it's security vulnerability. Is drupal 7 file access system broken? Or am i missing something?

Manage display page


texts: How can I re-populate file_usage and file_managed tables?

texts:
I have a commerce website. I am also consuming a web service and creating corresponding products, including matching products with another table's rows. I have the below code. It ran several times and I ended up deleting file references from file_usage and file_managed tables because the table had over 300.000 rows. The code used to work before I deleted did so. Since then I tried several things, including running a bare minimum. Since then, I've been pulling mt hair. What can I do to re-populate those tables?

<?php
$req = Drupal::httpClient()->get('http://www.example.com/path/to/web/service');
$res = $req->getBody();
$res = json_decode($res);
foreach($res->Data as $r) {
  $query = Drupal::database()->select('excel', 'e')->fields('e')
    ->condition('stokkodu', $r->StokKodu);
  $or = $query->orConditionGroup()
    ->condition('grupindex', 1)
    ->condition('grupindex', NULL, 'IS NULL');
  $results = $query->condition($or)->execute()->fetchAll();
    foreach($results as $result) {
      $imagename = "public://urun".$result->gorsel;
      $images = \Drupal::entityTypeManager()
        ->getStorage("file")
        ->loadByProperties(["uri" => $imagename]);
      $image = reset($images);
      if (!$image) {
      $image = File::create([
        'uri' => $imagename,
      ]);
      $image->save();
      $logoname = "public://urun/logo/".$result->logo;
      $logos = \Drupal::entityTypeManager()
        ->getStorage("file")
        ->loadByProperties(["uri" => $logoname]);
      $logo = reset($logos);
      if (!$logo) {
        $logo = File::create([
          'uri' => $logoname,
        ]);
        $logo->save();
      }
    }
  }
}


texts:
There is a plugin being used that extends WidgetBase in Entity Browser module (which extends PluginBase from core).

There is an abstract class that extends WidgetBase, and type hints an argument to a class:

  /**
   * EntityFormProxy constructor.
   *
   * @param array $configuration
   *   Plugin configuration.
   * @param string $plugin_id
   *   The plugin ID.
   * @param mixed $plugin_definition
   *   The plugin definition.
   * @param mixed $event_dispatcher
   *   The event dispatcher.
   * @param mixed $entity_type_manager
   *   The entity type manager service.
   * @param mixed $widget_validation_manager
   *   The widget validation manager.
   * @param \Drupal\lightning_media\MediaHelper $helper
   *   The media helper service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_type_manager, $widget_validation_manager, MediaHelper $helper) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_type_manager, $widget_validation_manager);
    $this->helper = $helper;
  }

I have implemented a service provider class to override the definition of MediaHelper to point to my own class. This results in a fatal error of "expected instance of \Drupal\lightning_media\MediaHelper, instance of Drupal\mymodule\MediaHelper passed". The only cure here was to remove the type hint in the argument list.

Is there a way in Drupal to change this so a type is not specified in the argument list?


texts: Encrypting db password stored in settings.php

texts:
The db password in settings.php is stored as plain text.
Is there any way to encrypt that password?

My client says its a security risk even though the file permissions is as should.


texts: Show select on product display even for 1 referenced product

texts:
In Drupal Commerce (D7), when multiple products are referenced by a product display, they appear on the product display as a select list, but I can also choose radio buttons.

The trouble is, some of my products displays reference one product and some reference multiple. If I only reference one product, there is no select list or radio button. In other words:

Product 1: "black", "red", "blue"
Product 2: "red"

On product 1's page, there will be options for all 3 colors
On product 2's page, there will be no color options.

Even though you can't choose from more than one options with product 2, I still want the select list/radio button to display so customers know what color option is available.

How would I do this?


texts:
I'm working on some code for a custom Drupal 7 module the problem is i'm dealing with many arrays and strings. I have tried to use print(), and print_r() to output values so i can see what i'm working with but nothing is printed to the screen. Is Drupal 7 preventing this from happening? How do other Drupal 7 module developers output values? for example in JavaScript i can use console.log() and for PHP i would normally use print(), print_r(), and echo. But looks like Drupal is not permitting this from working in my PHP code.

UPDATE:

In my module i have .inc file inside this file i have a method called list_builder($delta){} Inside this i have a switch() to handle different lists based on the $delta. This method is being executed on the cron_hook. It processes data from some outside sources and builds a json file. I'm at the point of building my json output but dealing with a lot of variables and need to be able to look at the variables at each spot in the process to know what data i'm dealing with while i build the output. I'm looking for a way to diagnostically test/display variables as i work on this module. I'm looking for a universal solution that works no mater what i'm doing.


texts: I uploaded my website here . But when I check the url it doesn't change when I click another page. I used the Rewritebase in my .htaccess to have clean urls. The url should be like kantoorleenknegt.be/contact ....


texts: How can I Display 'Items per page' in pager instead of the exposed form

texts:
I want to show 'Items per page' bellow the pager, I found viewsxtras, but it's just a placeholder and does not contain any code.

I'm using drupal 7 and views 3.x.
How can I do this?


texts:
Is there a way to identify a paragraph in Drupal 8. Like is there a function to get the type as paragraph in code level?

I need to get it from a form alter function. My requirement is to get all the paragraphs in a form. Or identify the paragraph fields.


texts: Why am I not able to pass a variable to my JavaScript code?

texts:
I'm hoping someone can shed some light on this for me. I've been building my first Drupal 8 custom block via a custom module. It was all going well until I've tried to pass some values into javascript. I'm working on some morris.js graphs, and want to display data from a database.

I've tried numerous variations, but can never get the variable to work. BTW, I'm not great at Javascript, so that might be where the flaw lies.

Here is the library definition:

 morris:
  css:
    theme:
      /libraries/morris/morris.css: {}
  js:
    /libraries/morris/morris.min.js: {}
    /libraries/raphael-master/raphael.min.js: {}
    js/custom.js: {}
    dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once

Here is the relevant part of the block file:

 $build['#attached']['library'][] = 'module_machine_name/morris';
$build['#attached']['drupalSettings']['module_machine_name']['morris']['memGraph'] = $graph_total;

And here is the js file:

     var infoo;

    (function ($, Drupal, drupalSettings) {
      Drupal.behaviors.module_machine_name = {
        attach: function (context, settings) {

            infoo = drupalSettings.module_machine_name.morris.memGraph;

        Morris.Bar({
      element: 'graph',
      data: [
        {x: '2011 Q1', y: infoo, z: 2, a: 6},
        {x: '2011 Q2', y: 2, z: null, a: 1},
        {x: '2011 Q3', y: 0, z: 2, a: 4},
        {x: '2011 Q4', y: 2, z: 4, a: 3}
      ],
      xkey: 'x',
      ykeys: ['y', 'z', 'a'],
      labels: ['Y', 'Z', 'A']
    }).on('click', function(i, row){
      console.log(i, row);
    });

        }
      };

})(jQuery, Drupal, drupalSettings);

Can anybody help? Thanks


texts: How to add a checkbox to form builder component settings form?

texts:
I have webform and formbuilder modules installed.

In the file field settings form I want to add an extra checkbox field just like the required field but I am unable to do that.

I can add it to the webform_component_edit_form like the following

$form['validation']['check'] = array(
      '#type' => 'checkbox',
      '#title' => t('Check'),
      '#default_value' => ($component['check'] == '1' ? TRUE : FALSE),
      '#description' => t('Check this option if the user should be able to upload files.'),
      '#weight' => -1,
      '#parents' => array('check'),
    );

But it is not displaying in the formbuilder file settings edit form form_builder_field_configure.

Is there any way to add a field to form_builder_field_configure form and save with the node just like other fields?


texts: Not working for node reference with more than two levels

texts:
Please help. I am able to make it work using taxonomy heirarchy but not using node reference. I would prefer node reference as you can add extra fields to these items like description, geo points etc..

Here is my set up:

[ City -> Developments -> Projects ]

e.g.:
(city) (development) (project)
Dubai -> Arabian Ranches Development -> Al Reem Project

And lots of cities that relates to their own set of developments -> again with their own sets of projects.

Development Node contains node reference to City (not heirarchical)
Project Node contains node reference to Development (not heirarchical)
and finally,
Property Item Node which contains the heirarchical node reference to Development, but when I reference it to 'Project' (which should be the case) it disappears upon selecting it!

I do not know what is wrong please help!


texts:
I added only my custom jquery mobile theme, made .info file, html.tpl.php, page-front.tpl.php, added jquery update module, and everything are loading fine.
But when I want to click to some link, example "#some", nothing happens. I double check all code, but seems that something is overlaping.

You can see that admin toolbar menu is bolded for some reason:

other effects work fine, but non of links that start with "#" don't work.


texts: Drupal commerce based recommendations engine

texts:
I want a shop where experts join the shop and each expert recommends his favorite products.

Expert's user profile will show his recommended products.
Users can vote recommendations up and down, much like happens in amazon.
The product's page will show the recommendations for that product.
The expert will also be an affiliate.

Possible architecture:

Commnets may be themed to be recommendations, together with voting stars.
Affiliates may be added with the Post Affiliate Pro integration.

Questions:

From your experience, what are the best modules / drupal commerce extensions to support this scenario?
Is there another, internal affiliate solution?

Thanks

Amnon


texts: Send mail notification when node of given type gets created

texts:
Use case: a small site where I want to warn all users by mail whenever a new content of a particular type is created. I thought I would try Rules+Actions to handle this.

I'm working on a vanilla Drupal 8 test site on my workstation, so there is just "Article" and "Basic Page".

I've installed the Rules module ok. I've looked at several videos explaining how this works in Drupal 7 and they looked reasonable straightforward. Now I'm trying to do something in D8 and finding it less than obvious.

Specifically, I've created the rule to fire when new content is created, and now I'm on a page editing Condition, where I want to specify that the node type is "Article". Using "Data selection" mode in the "Entity" field I select "node.type". This seems logical, but what on earth do I put in "Type"? No matter what I put I get a message something like this: "Data selector node.entity for context Entity is invalid. Unable to apply data selector 'entity' at 'entity' " - which is about as unexplicit as you can get.

Maybe I'm jumping the gun and Rules is not usable yet? Or maybe I've just not understood it at all...

But I would really appreciate if somebody could explain to me what seems quite straightforward in principle. How do I add a condition to my Rule that will cause the rule to fire only on a specific content type?


texts: change weight of fileds programmaticaly in drupal 7

texts:
I have a registration form with different attribute like

Captcha and security questions which are coming from different modules.

I want to change the display order of form elements.

and i am using this code in my custom module

function tenantwallet_form_user_register_form_alter(&$form, &$form_state){
    $form['#pre_render'][] = 'tenantwallet_form_alter_weight';

}
function tenantwallet_form_alter_weight($elements){

    $elements['field_first_name']['#weight'] = -50;
        $elements['field_last_name']['#weight']= -49;
        $elements['field_company_name']['#weight']=-48;
        #field_company_number, field_secondary_number, field_mobile_or_landline,field_gst_number, field_share_my_info, field_company_logo,field_facebook_id, field_mobile_conformation_code,field_date_of_birth,, field_gender, field_id_proof,field_secondary_id_proof, field_mobile_number,field_promo_emails_notifications,field_sugar_id, captcha,
        $elements['captcha']['captcha_widgets']['#weight']=-50;
        $elements['pass']['#weight']=-47;
        $elements['questions'][0]['question']['#weight']= 45;

    return $elements;
}

But this is not working. Can anybody tell me how to solve this.
Thanks


texts:
I have installed Disqus on localhost and want users of a particular role type only to be able to comment. Basically, there are free and premium users but I wish to allow only the premium users to be able to comment using Disqus.
The comments should be visible to every role type but the ability to comment should be given to only the premium users and the administrator.
It would be great if someone could help me out with this !


texts: How to use term id in content paths using path auto?

texts: How can I use term id instead of term name in path auto?I have a category field in my content type named "field_article_category" and there is a token [node:field_article_category] for it but it is replaced by term name not term id.is there anyway to get term id instead of term name?


texts: How to make Drupal 8 use only relative URLs?

texts:
I'm trying to get my site to use only relative URLs, like in the question drupal.stackexchange.com/questions/105932

EDIT 3:
It seems like Drupal 8.0.3 and beyond will do this by default:

https://www.drupal.org/node/2650374

But I've changed the code for Drupal 8 to this by getting rid of the deprecated function:

function custom_file_url_alter(&$uri) {
  global $base_path;

  $scheme = file_uri_scheme($uri);

  if (!$scheme || $scheme == 'public') {
    if (!$scheme) {
      $path = $uri;
    }
    else {
      ////$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
      $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme);
      $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);
    }

    // Clean up Windows paths.
    $path = str_replace('\\', '/', $path);

    $uri = $base_path . ltrim($path, '/');
  }
}

The problem is, whenever I add even just an article with an image (or any content type with a file in it) I get an error like this: 'Uncaught PHP Exception InvalidArgumentException: "The URI '/sites/default/files/field/image/h.jpg' is invalid. You must use a valid URI scheme." at /srv/www/example/core/lib/Drupal/Core/Url.php line 301, referer: http://example.com/node/add/article. I'm also getting this error when visiting a page that links to certain uploaded files.

The documentation says that this hook is called whenever the file_create_url method is called, but I don't know enough about Drupal to understand what scenario this method is being called which is causing Url.php to get mad at me.  For what reasons does Drupal call file_create_url, and why are almost all scenarios working for me while some are freaking out about no scheme being used?

Any extra information or guidance about this will be appreciated.

EDIT:

Here are some examples of $uri as it comes into the function (1) and as it leaves (2) .

1: 'core/themes/stable/images/core/icons/5181c6/pencil.svg'
 2: '/core/themes/stable/images/core/icons/5181c6/pencil.svg'
 1: 'public://css/css_Ys2L0rGQLjkWZQC7f9g5LiLUni8xUQvB1HqJHn3TKK4.css'
 2: '/sites/default/files/css/css_Ys2L0rGQLjkWZQC7f9g5LiLUni8xUQvB1HqJHn3TKK4.css'
 1: 'public://field/image/h_0.jpg'
 2: '/sites/default/files/field/image/h_0.jpg'

The h_0 example is one that happened after I created an article with the h.jpg image, which crashed and prevented creation of the article.  I've noticed that when I upload the image using the form, the little ajax thing that happens and shows you the preview of the image doesn't work when I use this file_url_alter code.  So, something is trying to call file_create_url when saving the image in the first place, and then, since the image is not properly saved, it can't be added as a field of the node.

Also, I've printed a backtrace, and it seems the crash happens after ThemeManager.php's render function calls template_preprocess_file_link(), which, in file.module, tries to do this:
$variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options));

...which caused the error I mentioned in the first place.

EDIT 2:

I've made this work by modifying one line of core.  I changed the last line of template_preprocess_file_link() in file.module from $variables['link'] = \Drupal::l($link_text, Url::fromUri($url, $options)); to $variables['link'] = $url;. This makes all URLs relative without any noticeable issues.  Does anyone know how to achieve this without hacking core? Or, does anyone know what negative effects doing this might cause?


texts: How to add a variable to a twig field template?

texts:
On a node page I would like to add the node title to the output alongside another another field (the example field).

I have created a new field--field-example.html.twig but am unable to access the node title variable as it is not available in the field template.

I need to add the variables into the theme preprocess: themename.theme.

How do I add the variable in themename.theme and what would be the corresponding entry in the field--field-example.html.twig ?


texts: Views Exposed filter text search for multiple value field

texts:
I have 6 fields (in Profile2) I want to combine into an exposed "Global: Combine field filter":

Field 1 = text field with 1 value (text)
Field 2 = text field with 1 value (text)
Field 3 = text field with 1 value (text)
Field 4 = text field with 1 value (text)
Field 5 = long text field with 1 value (long text)
Field 6 = text field set to unlimited number of values (text)

That last one is the problem. I want the user to be able to add several distinct values in this field, and I want to be able to create a combined field text search that includes the text from all of these fields, including all the separate values in Field 6.

If I isolate Field 6 and give it it's own exposed filter search field, it works fine. But if I try to make it one of the combined fields (using the Global: Combine fields filter), searches don't see the various text values in Field 6.

[BTW, I'm using Better Exposed Filters, though I don't think they are in use for the Global: Combine fields filter.]


texts:
Can someone please help me figure out why i am getting the following errors only after the first drop down is changed the second time and every time after that. the functionality is as desired.  The second drop down loads correctly, but i get the error messages anyway:

Warning: array_values() [function.array-values]: The argument should be an array in _field_filter_items() (line 513 of C:\TFS\Technology Management\Web Properties\ec_landingpages\DEV\modules\field\field.module).
Warning: Invalid argument supplied for foreach() in list_field_validate() (line 392 of C:\TFS\Technology Management\Web Properties\ec_landingpages\DEV\modules\field\modules\list\list.module).

function try_ajax($form, $form_state) {
    $options_first = $form['field_property']['und']['#options'];

    $selected = isset($form_state['values']['field_property']['und'][0]['value']) ? $form_state['values']['field_property']['und'][0]['value'] : key($options_first);

    $form['field_property']['und']['#ajax'] = array(
        'callback' => 'ajax_example_callback',
        'wrapper' => 'logos-div',
    );

    $form['field_logo'] = array(
        '#type' => 'select',
        '#title' => 'Logo',
        '#states' => array(
        'visible' => array(
            ':input[name="field_property[und]"],dummy-element' => array('!value' => '_none'),
        ),
        ),
        '#prefix' => '
',
        '#suffix' => '
',
        '#weight' => 2,
        '#options' => get_logo_images($selected),
        '#required' => TRUE,
        '#validated' => TRUE,
        '#default_value' => isset($form_state['values']['field_logo']) ? $form_state['values']['field_logo'] : '',
    );

    return $form;
}

function ajax_example_callback($form, $form_state) {
    return $form['field_logo'];
}


texts: search_api facet_api: multiple query, single index, single page

texts:
I have single index in search_api, on my page I render several views over this search index. On the breakpoint when I want to render my facets in search_api_current_search() I got an array of searches.

I know what element to render, but how can I render facets from this particular search query?

I render the facets using

$adapter = facetapi_adapter_load('search_api@' . $index);
$p = $adapter->buildRealm('somerealm');
$children = element_children($p);

where $index is the search index, but all the queries on the page using this index, and assumes that it uses the last search query.


texts:
I have a field that I created using hook_field_extra_fields, and I want it to have a cogwheel like in the image below, so that I can customize it. Right now the only format setting for the field is "Visible". Any ideas on how to enable the formatter settings for that field?

Note that I am also using display suite.


texts: Error in Italian localization for datepicker

texts:
Well, this is very funny :)

I have a datepicker localized in Italian. It works correctly, except that, apparently, the abbreviation for Wednesday was translated as it were a personal pronoun, since noi is the Italian translation for we.

The abbreviation for Wednesday is correctly set in core/assets/vendor/jquery.ui/ui/i18n/datepicker-it.js, but this file is not inserted in the HTML, so I suppose the translation is taken somewhere else.

In my libraries dependencies I have the following code.

dependencies:
  - core/jquery
  - core/jquery.once
  - core/jquery.ui.datepicker
  - core/drupal.locale.datepicker

Without the last line, the date picker is in English.

Am I doing something wrong?


texts:
I installed Secure Pages on a site, where I need to secure admin and user login pages. In general, it does its job, but when the user first tries to log in, and goes to the /user page, that page is not redirected to the secure page. The form action attribute is rewritten to the corresponding https link though.

Do you have any ideas why this could be happening?

In Secure Pages config, I use 'Make secure only the listed pages' option, and tried 'user', 'user*', and 'user/*'. Base urls are blank, but I tried filling them in. There are entries in 'ignore pages', but I tried removing them.

Another thing I noticed is that it works when the user is logged in. Could be a permission issue, but I did not see any relevant permission.


texts: how to automatically fill in an entity reference field using rules in Drupal 7?

texts:
Since I'm not a coder I'm using the Rules module to automatically create a node of type B when a user creates a node of type A. That works. I used 'create new entity' of 'type B' 'after saving new content of type A'. It also sets a unique name for the title of the newly dynamically created entity. And that's works great. In addition, I've also set the author of the 'entity-created' to a 'generic author' by simply using a specific uid (I just used a specific number as the value so they will always have the same author, that's fine).

So this all works.
In my next step of actions I want to fill in the entity reference field in the node created of content type A with the title of the 'entity-created' of type B. And here's where I'm stuck.

I tried:
set data value: node:field-entityref:title
new value for the specified data: [entity-created:title] (that should be different from the [node-created:title])
But that doesn't work. I tried many different things as well but it seems that I can't grab that title of that new entity that was dynamically created by Rules.
I tried to 'fetch entity by property' but that also doesn't fill in the title in my entity reference field on the node of type A. I don't know why. I hope someone can help me out in my last step. Cheers!


texts: galleria Slideshow images does not display

texts:
I have created an eva view, to display a group of gallery albums. Within my content type on manage displays am using a default galleria formatter and in my eva view I have a Grid of different image albums.
All I get is the album thumbnails. Tried to clear the cache but still.
I went through the galleria read me, and I believe I have done everything that they said one needs to do to get galleria working.

I am using Drupal 7 and have installed the followings:

Initially installed
Galleria Jquery plugin(libraries) 1.4.2
Galleria module (7.x-1.0-beta3)
but didn't work
I then added the following modules
Views Slideshow: 7.x-3.1
Views Slideshow: Galleria: 7.x-3.2

Am I missing something?


texts:
I have created a 'Content Type' names it Stories. And have created 30 new pages for each stories using the same Content Type. Now how can i add Previous and Next Button under each stories?

Any Article or Video tutorial will be appreciated

Thank You,
Mazhar
P.S I am using D8


texts: "Explanation or submission guidelines" missing

texts:
In editing a content type on a Drupal 8 site, I added text to the Explanation or submission guidelines, but when I surf to the node create/edit form, the text is nowhere to be seen.

Is this a bug, or are there extra steps involved that aren't documented in the UI?


texts: Dynamic loading using Tabs module and CCK Fieldgroup tabs

texts: I am currently using the Tabs and CCK Fieldgroup Tabs modules to display views in a tabbed format on nodes of a custom type. However, pages take a long time to load because the content in every tab is loaded at once. I want to dynamically load each tab only when it is clicked. How can I accomplish this? For example, look at the first node on this page


texts: Access custom block in page.html.twig template

texts:
I've added a custom block (which is an image) in the HEADER section of a view. I want to show this image at the top of my page but currently it appears in content views-view.html.twig.

How can I access to this image in page.html.twig?


texts: Change print $node_url To a Link Fields Value

texts:
Hello i would like to change the destination of a url in a node.tpl (in a view) from this-

<a href="<?php print $node_url; ?>">

to something like this-

where the field viewslink is a link field in the node itself.

I know i could do it if the view used fields but it doesnt its using a content teaser.

Anyone got any advice?

Thanks

sites/all/themes/other_sub/templates/nodes/node--view--portfolio-block.tpl.php

<li class="<?php print str_replace(',-', ' ', str_replace(' ', '-',strip_tags(render($content['field_portfolio_category'])))); ?>">
    <?php print render($content['field_portfolio_image']); ?>

        <a href="<?php print render($content['field_viewslink']); ?>">

<?php print $title; ?>

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


texts: How do I create a list of Nodes within a list of taxonomy terms, within a node?

texts:
I want to make an awards event where users can log in and nominate their products in specific categories.

I have a node: "Awards Event" where the details of the event are defined
I have a taxonomy: "Awards Event Categories" - these are the categories which can contain multiple nominated products. These categories will be used for multiple awards events. Within 'Awards Event' node the admin defines which of these categories will be available in this particular event.
I have nodes: "Products" - these are controlled by the users who'll assign them to a category

Basically what I want is a way to build a list of which products are nominated in each category within each Award Event.

Is there an easy way to accomplish this?
I could just simply add a new field within the product node where the taxonomy term can be selected - but this would require me to add that new field each time an awards event is created. I'd prefer if there was a more automated way.


texts: Override templates for one view page or block

texts:
I am trying to figure out if there is a way to override the base templates for one view.
I created a page with a view called 'Promotions'.
I need to override the views-view-field.html.twig, views-view-fields.html.twig, and views-view-unformatted.html.twig for just the one view/page.

I read about putting it into your custom theme's template folder in it's own folder that mimics the page name.
In my case, following the example it was views-view-fields--promotions--page.

The overrides work but they work for all the views (pages and blocks) that I created.
Can you narrow it down to just one view/page?


texts:
There is a menu plug in called ddmegamenu http://www.dynamicdrive.com/dynamicindex1/ddmegamenu.htm

I want to integrate in drupal 7 menu system. I don't know form where to begin
i tried drupal megamenu module, but it is not giving same effect as ddmegamenu.

can anyone guide me how to format menu tree to apply ddmegamenu to my theme..


texts:
I don't know if this is possible but could I do something like

<?php

  $foo = current_path();
  print $foo;

?>

in page--foo.tpl, then something like

function MYMODULE_form_user_register_form_alter(&$form, &$form_state) {
    function name() {
        global $foo;
        if $foo == 'user/register/foo' {
            unset($form['account']['mail']);
    }
  }
}

in a custom module. I'm trying to make fields unique to roles without using profile2. Getting this error when I try it though:

  Parse error: syntax error, unexpected '$foo' (T_VARIABLE), expecting
  '(' in
  /var/www/html/drupal/sites/all/modules/custom_forms/custom_forms.module
  on line 71

Using Auto Assign Role for the path.


texts: How to compare custom product bundles in Drupal Commerce

texts:
I am a Drupal Commerce newbie, and would like advice on how to accomplish a particular project requirement.

I have two kinds of products - Panel and Converter. Each project has a mix of those panels and converters. The type and amount of each panel and converter comes from a custom module. Each of these converters and panels have different prices.

I'm supposed to create a view with the top 5 combinations of converters and panels, sorted by price and allow the user to select the one they want, which then goes into the cart.

I hope that all made sense...

Does anyone know of any tools, modules, or methods that I could look into to accomplish this task? I feel like I'm looking for the ability to create dynamic product bundles, that are then able to be put into a view to compare. Is that even possible?

Thanks for the help

NOTE: I am just beginning this part of the project, so if this is easily accomplished with ubercart or some other ecommerce module, I'm open to that as well.


texts: How do I create a page consist of more than 100 lines, by custom module?

texts:
I created a page which consist of HTML tags. The code for that is the following one:

function mynewpage_menu() {
  $items['mypage'] = array(
    'title' => 'my page title',
    'page callback' => 'mypage_page',
    'access arguments' => array('administer page'),
  );
  return $items;
}

function mypage_page() {
  $output='html code here';
  return $output
}

Is it the right way to generate a page if i have more than 100 lines? What if I have iframe , img and canvas tags and what if I want to include paths and hyper references?

In what other ways can I generate a page containing 100 HTML tags?

Update:
Am I right in associating mynew-page.tpl.php with the following theme function?

function mymodule_theme() {
  return array(
    'mypage' => array(
      'variables' => array('account' => NULL),
      'template' => 'mynew-page',
    ),
  );
}


texts: How to customize drupal node using 'PANELS'

texts:
I am trying to implement the "PANELS" module in drupal 7.31 to customize a page display.

Panels Module : 7.x-3.4

Drupal version : 7.31

I have created courses(as a product) using "COMMERCE" module. I am able to display the LIST Courses
using Panels. But I am also want to customize the course detail page(User click on course and then redirect to detail page).

You can see list of courses using Panels on here:

Now I want to customize the detail page where all details show from Database using Panels.

You can also see Course Detail page here:


texts: Views Taxonomy Term Argument With Multiple Terms

texts:
Hello I am having a torrid time creating a views block. Let me try to explain without rambling on about nothing as I usually do.

I have a content type (links) which uses the same vocab as my other content type (posts) When viewing a Post I was hoping to display any links that have the same terms.

Ive set it up with an Argument Taxonomy: Term ID. It all works as hoped when I have just ONE term on a post but when I have more than one term things start to get a bit strange.

Actually I should mention that I am using Load default argument from node page and just doing it on term id. I am not using Allow multiple terms per argument box. this returns no results (for nodes with multiple terms)

If I change the Argument type: to term id's seprated by ....+ etc I do get a return but it only shows links for one of the terms. Funny enough the term results are for the term that I dont want to use. I have changed the term weights and everything to try and change it to show the links for the term I was hoping for but I dont seem to be able to influence what terms results appear in the views box I have made.. Its got me tearing my hair out.

Can anyone understand my gibberish and offer any solutions?


texts: Send variable to the user profile in Drupal 6

texts:
I am developing a module for Drupal which provides a login form and after submission user cURL to login in with those credentials on another website.

If all goes well, the module redirects the user to their profile and should present the information cURL fetched. This is where things go wrong.

What I'm trying to do is get the $account variable through the username. This is all in the module_name_form_submit function:

$account = user_load(array('name' => check_plain($user)));

And then append the data I want to display to it:

$account->content['module_name'] = array(
    '#title' => t('Module Title'),
    '#values' => get_info()
    );

If I do a print_r before the redirect, sure enough, the data is there as it should. But after the redirect:

$form_state['redirect'] = "users/{$user}";

I no longer have access to that same data. So the question is, how can I set that variable in a permanent way and access it after the redirect in the user profile page? (I'm trying to avoid sessions).


texts:
I have created nodes and added taxononmy

Under views i want taxonomy seperarte. it is showing

A, B, C, A , B

A, B , C are my taxnomy terms

i want A , B, C are in tabs  as a taxonomy

Any idea


texts: D7 views list of nodes with node reference count

texts:
I have two content types A and B. The content type B has a node reference to A.
I would like to create a views list which show nodes of A with no. of node count of B.
It is very similar to a list of nodes which comment count for each.


texts: How do I expose display routes from a specific view as REST API?

texts:
I have set up some displays in a Categories view, all with their own path. I want to expose all displays from that view with a REST API.
I've already set up a module with a path, but how do I get the paths to the individual displays?
$view = Views::getView('categories'); gives me the view (probably with my desired displays), but I am quite stuck there.
Most of the answers I find online are pretty much outdated.


texts: Problem in rendering double-field in other node

texts:
I think I have a problem with keys and values of a list field in the rendering phase (on Drupal 7).

Let's me go in detail.

Model part:

We defined a CCK "double field" for a "profile2", with multiple values allowed.
This field is composed by a select and a text-field, but I'm interested only to the "select" part in this moment (its behavior seems to be the same of a simple list field).
Then we defined values in the list as K1|V1, K2|V2, etc.

Render part:

We defined a theme template for this field; there we verifies values by comparing the key: $val = $item['first'] (to take it) and if ($val=="K1") {...}... and everithing works fine, because tamplate receives keys of the list (inside first key of the #object array of the renderable array).
In a node page I have to show the same information and I would like to use the same template file (instead of replicate the code). So I tried to use render( ) Drupal function, and it needs for a renderable array... but the only function I found to get it was field_view_field( )... and it doesn't work as I expect.

The problem is that this function doesn't return field keys (e.g. K1), but values (e.g. V1)... so templates is not able to work properly.

I know I can write differently my template (e.g. if ($val=="K1" || $val=="V1"), but I think this is can't be the right solution, because code should alway depend from keys (and not values, that may change over time).

So I'm wondering what is the Drupal way to achieve a renderable array in which there is the keys and not the values of a list element.

Thank you


texts: in drupal 7, how to get node id from node title?

texts:
Possible Duplicate:
  How to load a node based on its title?

I know the node title, and I want to get node id from the node title, I tried 2 ways but not working properly

// get node title from the url
$title = arg(2);

$node = node_load(array('title' => $title));
$nid = $node->nid;

print $nid;

errors are saying that Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() , Trying to get property of non-object

2

 $items = entity_load('node', FALSE, array(
            'type' => 'article',
            'title' => arg(2),
    ));

but then what I should do ?


texts:
I have a custom form with a field...

function mh_integration_connect_form($form, &$form_state) {
  $form['#method'] = 'get';
  $params = drupal_get_query_parameters();
  $form['cat'] = array(
    '#type' => 'select',
    '#title' => t('Categories'),
    '#options' => $categories,
    '#default_value' => $params['cat'],
  );
}

as $param is not set before the form is submitted, so it show error for "Notice: Undefined index: cat".
I am wondering if we can set this default_value conditionally,

if(isset($params['cat'])) {
    '#default_value' => $params['cat'],
}


texts: I want to enable my users to add their birth days in their profile. The users should select the date either from a calendar or insert them in three different fields of day,month, and year manually...The image should make it clear:


texts: How can I change the title tag in header of just one page?

texts:
I tried Page Title module however it seems that it can configure page titles only on the content type level.

I can make a temple for this page and write the title directly in there but I don't feel like overriding the template file just for the title tag.

Is there any other way to set the title to just one specific page (node view page)?


texts:
$array = Array(
  [a001] => Array(
    [0] => Array(
      [id] => 1789823
      [start] => 2014-09-29
      [end] => 2014-10-02
      [status] => 1
    )
  )
)

function to insert reservation:

    foreach ($array as $room_id => $item) {
      foreach ($item as $reservation) {
        db_insert('reservation')->fields(
          array(
            'room_id' => $room_id,
            'id' => $reservation['id'],
            'start' => $reservation['start'],
            'end' => $reservation['end'],
            'status' => $reservation['status']
          )
        )->execute;
      }
    }

I have an multidimensional array $array and it has about 30000 records of $reservation index. Using looping method above in my personal computer, it takes about 30 minutes to insert all of reservation, my PC spec is (dual core, memory 2GB).

Is any better implementation to do insert job?


texts: render($page['content']) in the wrong place!

texts:
Ok I'm having this really weird problem with my Drupal 7 site. I have edited my page.tpl.php file. Following is the html where this oddity occurs

<?php echo $title; ?>

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

Bestselling

                           <?php print render($page['right']['views_bestsellers-block']); ?>

Poll

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

So far everything looks fine. But when opened in the browser print render($page['content']); prints outside the table before it! I have checked this through firebug.

I have also edited a node.tpl.php file and everything is fine inside it.

Can anyone suggest what is going on?


texts:
I made a view with views data export contrib module, thanks to I download a CSV file of some information, for example, I want to export peoples data in CSV format from a view, as I show with the followed screen:

Well, I need to download this file, and save it into drupal filesystem, in particular into public file, or attach it to an email, for example. In fact, when I click on path that I defined for the view, I can download the file normally, but when I want to attach it to an email or download it from a controller method, or so on, the file is empty or it is not created.
Views Data Export contrib module doesn't provide drush command to execute the download, and I do not think that is the best method to do this.
How can I do this?


texts: How to deal with SalesforceException: HTTP Method 'PATCH' not allowed

texts:
I've the the Salesforce module mapping in place integrated with Commerce module and I've the following SalesforceException when purchasing the order:

SalesforceException: HTTP Method 'PATCH' not allowed. Allowed are HEAD,GET,POST

What's happening and how to deal with or debug this problem?


texts: Generate Drupal Calendar or Fullcallendar from arbitrary view

texts:
I have successfully used the Calendar and Fullcalendar modules to generate calendars from a content type.

What I can't get to work is getting dates calculated using a Views PHP field into a calendar. The settings for Fullcalendar only appear to allow specification of a 'bone fide' Date field as the dates to display in the calendar.

I am sure this must be possible. I would be grateful for any pointers.


texts: How to prevent login if a condition is not met

texts:
I am working on a Drupal 6 site (which I did not make and am not in charge of the general IT architecture at this company).

The site is on an intranet and they regularly import all users from an external source to Drupal users. The requirement is to restrict access to a subset of the imported users.

So:
When a user logs in if they are on the authorized list then proceed else deny access

I realize this isn't the most effective way of doing things and I would have done in differently, personally. But I am stuck having to do it this way.

What I have working so far:

I have feeds and data modules to import a CSV of authorized users
I am using hook_user() in my module to check if the user is on the authorized list

the problem:

I have all the above working but I can't figure out a clean way to log the user out or terminate the session when they are not found on the list. When I use this it causes errors:

function mymodule_user($op, &$edit, &$account, $category = NULL) {

  switch ($op) {
    case 'login':
        $strID = $account->uid;
        $strName = $account->name;
        if ($strID <> 1) {
            if (!mymodule_checkACL($strName)) {
                global $user;
                $user = array();
            }
        }
    break;
  }

Any better way than this? Sorry if the question seems a little basic, I'm new to this.

Thanks


texts: Have Value Selected but Label Showing in Views Display Plugin

texts:
I am working on a custom Display plugin for Views. In my buildOptionsForm() method, I have the following:

$form['inherit_yaxis'] = [
  '#title' => $this->t('The title'),
  '#type' => 'radios',
  '#options' => [
     1 => $this->t('Inherit primary of parent display'),
     0 => $this->t('Create a secondary axis'),
  ],
  '#default_value' => $this->getOption('inherit_yaxis'),
  '#description' => $this->t('The description'),
];

In the optionsSummary(), if I do this:

$options['inherit_yaxis']['value'] = $this->getOption('inherit_yaxis');

It shows 1 or 0 rather than the label that I want ('Inherit primary of parent display' or 'Create a secondary axis').

What should be on the other side of $options['inherit_yaxis']['value'] = so that the label shows but the value stays either 0 or 1?


texts: How to display the node id as a field (with label)

texts:
This question is really simple, i need to use the node id as an identifier and so i need to display it whenever a certain content type is shown. What's the best way to do this?
i need to display the node with label and so on, i just don't want to make a custom field for something that's already a field.


texts: search result not in prioritize order drupal 7

texts:
Hi i am new to drupal 7 and also to sql query builder format.i have a requirement to search the string. in that i hav to display exact matched string at the top followed by related matches. i explode a string with space and searched a each word exist or not.the code as follows.

$keys -> contain the search term

 $keys = preg_replace('!\*+!', '%', $keys);

$keys = explode(' ', trim(str_replace(array( '\'', '"', ',' , ';', '<', '>','!','_','-','+','@','#','$','%','^','&','.'), ' ', $keys)));;

 $query = db_select('file')->extend('PagerDefault');
 $query->fields('file', array('fid','filename'))
  ->fields('fs', array('e_id','f_subtitle_value'));

 $subquery = db_select('field_data_sub','fs');
 $subquery->Fields('fs', array('e_id','f_subtitle_value'));
 $subquery->condition('fs.e_type', 'node','!=');

 $query->leftjoin($subquery,'fs','file.fid = fs.e_id');
 $db_or = db_or();
foreach ($keys as $key) {
if(!(empty($key))) {
 $db_or->condition('filename', "%$key%", 'LIKE');
 }
}

$query->condition($db_or);
  $query->condition(db_and()->
          condition('filemime', 'image/jpeg', '!=')->
           condition('filemime', 'image/png', '!='));

i tried union all - wrote two query and combine it.. it fetches output but the exact searched result came twice . is that a gud way or else is there any other way.. please suggest the best way :)


texts: Using search_api and search_api_views how do I display images?

texts:
Drupal-7. search_api_solr 7.x.1.4 search_api_views 7.x-1.11

I have an index of documents and associated commerce products. The commerce product has an image in it. I can get views to display an index of the image url, but not display the images.

The image is displayed fine with a sql backed (non-solr) view.


texts: How to allow users to post content and easily overrule its default access settings?

texts:
On our website, we have a content type ("news"), which includes both public and private items. Normally, posts will be viewable by authenticated users only. However, I want to allow people to post content that is viewed publicly. The way I would prefer to do this is with a simple checkbox during node creation, which allows the node to be public, and viewable for anonymous users.

So far, I've tried the Content Access module, but the interface it provides is too complicated; I only need a checkmark for "allow anonymous to view".


texts: Trying to filter a View based on a Paragraph entity reference

texts: I want to filter a View by content type 'Article' and only content that is referenced to a specific node id 123. I have a Paragraph in Article content type. Inside the Paragraph is an entity reference 'my_field' to content and also a few other text fields. In my View I added a relation: Paragraph referenced from my_paragraph_field. I can now add a normal View field - my_field and use the relation. But it doesn't display results of the field. I can also add a filter - my_field and make it equal to nid '123'. But it doesn't filter on the result? How can I make this work. Is this related to this issue. I can create a new View that displays Paragraphs and I can filter on that reference field without adding a relation.


texts: How to use user profile fields location fields in a rules component?

texts:
I have a case where users will register with the site from foreign countries. I'd like to be able to let the admin know to update the geocoding settings for the country that they register from.

I'm working with rules, location and User-location, and Gmap. What I have so far is this:

{ "rules_email_admin_update_geocoding_" : {
    "LABEL" : "Email Admin to update Geocoding",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "site:current-user" ], "field" : "field_location_opt_out" } },
      { "AND" : [
          { "data_is" : { "data" : [ "site:current-user:field-location-opt-out" ], "value" : "0" } }
        ]
      }
    ],
    "DO" : [
      { "component_rules_send_email_to_admin" : {
          "subject" : "Update Geocoding Configuration ",
          "body" : "A new user [site:current-user] has registered with location information, check to see if the user\u0027s address is outside of the US and if the geocoding settings need to be updated to show the user on the map. Go to admin\/config\/content\/location\/geocoding and see if their country is configure. ",
          "from" : "admin@phisigmarho.org"
        }
      }
    ]
  }
}

This sends an email to the admin when the location-opt-out field is false, that is that the user entered location information. The issue is that I can't drill any further into the location information than the fact that the user hasn't opted out. This works ok for new users, but I will need to have another rule when a registered user updates their address. This leaves me with a problem, because I can't check the actual values in the locations fields.

So, what's the next step? can I access those values with a php snippet, and if so, how?

UPDATE: So, this appears to be an issue with how Rules interacts with the Fields API.Rules Fields


texts: Prevent logged in users from seeing other registered users information

texts:
I'm using Drupal 8 and I have a security requirement to prevent authenticated users from seeing other authenticated users' profiles.

I have a view which customizes the user profile page of each authenticated user. Each logged in user can see their own profile by accessing the path /user-profile/userId.

Now if the user decided to randomly change the userId in the URL, they cannot access other users' profiles, since, in the view I have set the 'Filter Criteria' to current user. Which works perfectly.

However, if a user decided to randomly change the userId in the path /user/userId they will have access to other users information. What I need to do is to prevent them from accessing /user/userId.

It's important to mention that the users are free to change their own information using the URL /user/userId/edit

Any suggestions?


texts: Eliminate Views Entity Reference Duplicates. I have some titles the same on purpose

texts:
I have a view with an entity reference pulling in what I need from a content type. There are, on purpose, titles that are the same.

Is there a way to compare what is output and then only show one of the titles?

I am showing these in a select list.

This is not duplicates, as they are separate entries... so using the Query Settings > Distinct isn't the correct solution in my case.


texts: How is DRUPAL_CACHE_PER_USER handled for anonymous users?

texts:
If a block is set to use DRUPAL_CACHE_PER_USER for caching, will the block be unique for each anonymous user, or the same for all anonymous users?

For reference from API docs:
hook_block_info
DRUPAL_CACHE_PER_USER

Looking at includes/common.inc source it appears to be based on uid, so I'd assume it would use the same block for all anonymous users (uid = 0), but wanted to double-check in case I could use this instead of DRUPAL_NO_CACHE (doing geolocation-driven results in the block).

elseif ($granularity & DRUPAL_CACHE_PER_USER) {
  $cid_parts[] = "u.$user->uid";
}

(lines 6084-6086)


texts: How to populate field X with value of field Y in Organic Groups?

texts:
I want to use rules in order to populate Organic Groups field X value with the value of field Y. Keeping in mind these fields are Organic Group fields.

Field X is a 'long text & summary' field, while field Y is a normal 'text field'.

I'm trying to use Rules Actions to achieve this but no luck so far.

Any suggestions?


texts: Drupal 7 cannot use ckeditor with IMCE to browser file on IE 11

texts:
I try to use the ckeditor with IMCE to upload the image on IE 11, however, it show permission denied when I browser file, I have tested on chrome and firefox, it all work, does anyone know why??

Thanks


texts: Store entity with entity reference field?

texts:
I want to create an ECK programmatically, I can create it but the issue is with the entity reference fields that being empty

The interesting issue is that when I try to edit the created entity, just some fields are accessible none of entity references.

The more interesting issue is when I try to see the list of that entity page is broken and show this error to me.

  Error: Call to a member function label() on null in Drupal\eck\Controller\EckEntityListBuilder->buildRow() (line 43 of modules\contrib\eck\src\Controller\EckEntityListBuilder.php).

I tried these codes:

  // Define entity type and bundle.
  $entity_type = "attendees";
  $bundle = "attendees";

  // Get definition of target entity type.
  $entity_definition = \Drupal::service('entity.manager')->getDefinition($entity_type);
  // Load up an array for creation.
  var_dump($entity_definition);
//  die();
  $entity_data = [
    'title' => 'this is test new',
//    'field_address' => $studentRecord['field_address'],
    'field_student_account' => 10,
    'field_students' => 48,
    'field_enrollment' => 270,
    'field_status' => 'Active',
//    'field_description' => "tsetestsetstes",
     // Use entity definition to set the appropriate property for the bundle.
    $entity_definition->getKeys()['bundle'] => $bundle,
  ];
  $new_entity = \Drupal::service('entity.manager')->getStorage($entity_type)->create($entity_data);
  $new_entity->save();
  var_dump($new_entity->id());
  die();

here are the valid values for another that created from the front end.

#values: array:12 [▼
    "id" => array:1 [▼
      "x-default" => "15"
    ]
    "type" => array:1 [▼
      "x-default" => "attendance"
    ]
    "uuid" => array:1 [▼
      "x-default" => "9a1fd3ec-3d7d-4926-a1d2-fcafc8fce3c2"
    ]
    "langcode" => array:1 [▼
      "x-default" => "en"
    ]
    "title" => array:1 [▼
      "x-default" => "group lesson"
    ]
    "created" => array:1 [▼
      "x-default" => "1561802666"
    ]
    "changed" => array:1 [▼
      "x-default" => "1561802705"
    ]
    "default_langcode" => array:1 [▼
      "x-default" => "1"
    ]
    "field_enrollment" => array:1 [▼
      "x-default" => array:1 [▼
        0 => array:1 [▼
          "target_id" => "271"
        ]
      ]
    ]
    "field_status" => array:1 [▼
      "x-default" => array:1 [▼
        0 => array:1 [▼
          "value" => "Inactive"
        ]
      ]
    ]
    "field_students" => array:1 [▼
      "x-default" => array:1 [▼
        0 => array:1 [▼
          "target_id" => "69"
        ]
      ]
    ]
    "field_student_account" => array:1 [▼
      "x-default" => array:1 [▼
        0 => array:1 [▼
          "target_id" => "27"
        ]
      ]
    ]
  ]

And this is the data that comes with programmatically creation.

EckEntity {#1106 ▼
  #values: array:8 [▼
    "id" => array:1 [▼
      "x-default" => "16"
    ]
    "type" => array:1 [▼
      "x-default" => "attendees"
    ]
    "uuid" => array:1 [▼
      "x-default" => "1048d24d-ffc7-4243-81c1-b26b5e9e9ecb"
    ]
    "langcode" => array:1 [▼
      "x-default" => "en"
    ]
    "title" => array:1 [▼
      "x-default" => "this is test new"
    ]
    "created" => array:1 [▼
      "x-default" => "1561806843"
    ]
    "changed" => array:1 [▼
      "x-default" => "1561806843"
    ]
    "default_langcode" => array:1 [▼
      "x-default" => "1"
    ]
  ]

this is my fields map

And this is the form display setting


texts: Error copying file. Is there a permissions issue?

texts:
I have a process that fetches a file, then moves it (overwriting if already exists). The copy part fails, and I cannot determine why.
Here is some PHP I am using to reproduce the issue I am seeing (with output functions from Devel module):
$source = 'temporary://someFile';
$destination = 'public://profile_pictures/someFile.jpg';

# Get name of Linux user running this
$username = posix_getpwuid(posix_geteuid())['name'];
dpm($username);   # nginx

dvm(file_exists($source));       # TRUE
dvm(file_exists($destination));  # TRUE

# File permissions
dpm(substr(sprintf('%o', fileperms($source)), -4));       # 0600
dpm(substr(sprintf('%o', fileperms($destination)), -4));  # 0644

# Try Drupal's copy
$r = file_unmanaged_copy($source, $destination, FILE_EXISTS_REPLACE);
dvm($r);  # FALSE

# Try PHP copy that Drupal uses internally, to see the error
dvm(copy($destination, $source));  # TRUE    ( Copy backwards works... )
dvm(copy($source, $destination));  # FALSE   ( But this doesn't work.  )

The last line gives the following error:

Warning: copy(public://profile_pictures/someFile.jpg): failed to open stream: "DrupalPublicStreamWrapper::stream_open"

So copying backwards works, but it won't copy from temporary:// to profile_pictures. Also, if I delete public://profile_pictures/someFile.jpg first, then it works.
Permissions of files and folders:
drwxrwx--- www-data www-data temporary://
-rw------- nginx    nginx    temporary://someFile
drwxrwxr-x www-data www-data public://profile_pictures
-rw-rw-r-- nginx    nginx    public://profile_pictures/someFile.jpg

The temporary directory is a sub-folder of public://. The nginx user is in the www-data group.
Is this a permissions issue? Looking at Drupal's requirements, I don't see what I am doing wrong.


texts: How to change calendar entry background based on taxonomy?

texts: Folks, I'm trying to figure out how to style my calendar. I was able to add color stripes based on my taxonomy, but the background of calendar entries is still that ugly yellow #ffc. What I'd like to do is to make the background the same color as the taxonomy color, only brighter/semi-transparent - for example, if the taxonomy color is #00ff00, I want to se the background of that calendar entry to #e0ffe0. I'm pretty new to Drupal and really can't figure out what's the right way to do it.


texts: How to merge WYSIWYG fields from separate nodes

texts:
I would like to know if it is possible to merge the contents of two separate WYSIWYG fields from separate nodes to create a new node containg both.

Does anybody know of a module that performs this function or something similar, or would this require the writing of a new module?

The use case is for a newsletter, the WYSIWYG fields being populated by articles, and saved to separate nodes. The end result would be a node that contained all articles in a single WYSIWYG field.


texts: User registration form change Username to name

texts: I want to change the label of a registration form from 'Username' to name. I had used 'String overrides' module. But its not effecting. Is there any way out. please help me out.


texts:
Google Webmaster's tool tells me on a site that "Request timed out or site is blocking Google". On that site. I am wondering how to fix this.

Probably relevant info: I'm using Varnish in front of nginx and also user use iptables and DDoS deflate. The site is large but works pretty smoothly, with load less than 2 most of the times. The standard Pressflow 6 robots.txt is there and accessible through browser.

I am not quite sure how to figure out what blocks googlebots and how to fix the problem. So appreciate your hints.