texts:
When I attempt to use Drush 8.0.3 on a clean Drupal 8.1.1 install, I receive the following error:

  Command pm-list needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.

This is on a Digital Ocean server running Ubuntu and nginx.

Drush status:

root@*********:/var/www/html/drupal/sites/default# drush status
Drupal version         :  8.1.1
Site URI               :  http://default
Database driver        :  mysql
Database hostname      :  localhost
Database port          :
Database username      :  drupal
Database name          :  drupal
PHP configuration      :  /etc/php5/cli/php.ini
PHP OS                 :  Linux
Drush script           :  /usr/local/bin/drush
Drush version          :  8.0.3
Drush temp directory   :  /tmp
Drush configuration    :
Drush alias files      :
Drupal root            :  /var/www/html/drupal
Drupal Settings File   :  sites/default/settings.php
Site path              :  sites/default
Sync config path       :  sites/default/files/config_JYMyTTYRsOD-Wxu0fI7lfugHI6rk2DbhO5g-jrfjsPyy46mmesB1aTpSuq2RAUIOUC4N2q_IkQ/sync

Oddly (to me, at least) I can clear caches:

root@***************:/var/www/html/drupal/sites/default# drush cr
Cache rebuild complete.


texts:
I have a content type leg and this hook_menu :

$items['leg'] = array(
    'title' => t('Choose Leg'),
    'page callback' => 'drupal_get_form',
    'access arguments' => array('create leg content'),
    'page arguments' => array('mymodule_leg_select_form'),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 0,
);

$items['leg/select'] = array(
    'title' => t('Choose an existing leg'),
    'page callback' => 'drupal_get_form',
    'access arguments' => array('create leg content'),
    'page arguments' => array('mymodule_leg_select_form'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 1,
);

$items['leg/add'] = array(
    'title' => t('Create a new leg'),
    'page callback' => 'drupal_get_form',
    'access arguments' => array('create leg content'),
    'page arguments' => array('leg_node_form'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
);
return $items;

Here is the code snippet from mymodule_leg_select_form() which is called as MENU DEFAULT LOCAL TASK :

$form = array();
$result = db_query('SELECT nid, title FROM {node} WHERE type = :type AND status = :status ORDER BY title', array(':type'=>'leg', ':status'=>1));
$options = array();
foreach($result as $row){
    $options[$row->nid] = $row->title;
}
$form['leg'] = array(
    '#type' => 'select',
    '#title' => t('Leg'),
    '#options' => $options,
    '#required' => TRUE,
);

$form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Ok'),
    '#weight' => 1,
);

return $form;

The node form is not rendered correctly as you can see in the screen shot. I have two fields - field_from and field_to. They are not rendered in the form. The menu path "leg/select" which is default local task did work and correctly rendered my custom form.

The problem only is to integrate node add form in the second tab.
How can I fix this error ?


texts: How would you assign a taxonomy term on user registration programmatically?

texts:
I'm struggling to figure out how to programmatically assign a taxonomy term to a user in Drupal 7.

I have a term reference field [field_event_location] on the user registration screen. What I want to occur is to have an Administrator (role) create a new user and assign the meeting manager (role) to a set term.

Once the meeting manager(role) creates a new customer(role) through the user registration form, the term reference field will be automatically set to the term associated with the meeting manager user that was previously set by the Administrator.

I haven't found a contrib module that does this, so I was starting down the path of creating my own module using HOOK_user_presave

 /**
  * Implements hook_user_presave
  */

  function mycustommodule_user_presave(&$edit, $account, $category) {
    global $user;
      if(isset($account ->is_new) && !empty($account -> is_new)) {
        $roles = user_roles(TRUE);
         if(in_array('meeting manager', $user->roles)) {
          //set user they are creating to the role of 'customer'
             $rid = array_search('customer', $roles);
             $role = user_role_load_by_name('customer');
             $edit['roles'][$rid] = 1;
         //assign the customer to the same location as the venue admin
           $edit['field_event_location'][LANGUAGE_NONE][0]['target_id'] =  field_get_items('user', $user, 'field_event_location', LANGUAGE_NONE);
      }
    }
 }


texts: drupal_add_js() does not add .js file from libraries folder

texts:
I have a page callback where I want to add a colorbox library by this code:

drupal_add_js('sites/all/libraries/colorbox/jquery.colorbox-min.js', 'file');

The file exists, path is right. But in html is this file not included. Why it does not work?


texts: FormValidator doesn't validate selects with options changed via ajax callback

texts:
I have a custom form with 2 select fields, first (Country Select) has an ajax callback which when is triggered the options from second (Country Currency) callback are changed. Options are replaced in select list but on  submit or selecting another country the validation is not passed.

The error I get is on line #362 in FormValidator.php

  An illegal choice has been detected. Please contact the site administrator.

  elseif (!isset($options[$elements['#value']])) {
    $form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.'));
    $this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']));
  }

Current options were changed but select is still keeping the value from previous options and \Drupal\Core\Form performRequiredValidation() method throws above error.

Any ideas how to fix/avoid this are welcome.


texts: Straightforward method to get related items view from Solr

texts:
I have a Drupal 6 site with an Apache Solr search index.
I'm trying to create a block that displays 'related content', much like Stack Exchange sites have 'related' in the sidebar of questions.
The modules Apachesolr_views seems like a good candidate, but it's current development status and issue queue is less than inviting.
Does anyone have suggestions of a straightforward way to implement this?


texts: Warning: Illegal string offset '#access' in views_handler_field_field->set_items() line 862 views_handler_field_field.inc

texts:
I'm having an error that I can't find an answer for, and was wondering if someone out there can help.

The error i get is...

Warning: Illegal string offset '#access' in views_handler_field_field->set_items() (line 862 of .../sites/all/modules/views/modules/field/views_handler_field_field.inc)

I have created a view, that is showing a multiple value result of a photo gallery from 10 nodes of the same content type. Basically I have a content type for venues, and each venue can upload an unlimited number of photos for their venue. This view sits on one of the main national pages, and shows all photos from all venues.

Looking at line 862, the error is in the following bit of code

  // field_view_field() adds an #access property to the render array that
  // determines whether or not the current user is allowed to view the
  // field in the context of the current entity. We need to respect this
  // parameter when we pull out the children of the field array for
  // rendering.
  if (isset($render_array['#access'])) {
    $items[$count]['rendered']['#access'] = $render_array['#access'];
  }

Can anyone help me and shed a bit of light on this? It looks like a permissions problem if a user doesn't have access to the content, but my permissions are no different than they have been for the last 10 drupal sites I have built.


texts: default value only set after clearing the cache

texts:
I'm trying to set a default value to a HS select but It's working only after clear the cache or for authenticated user .

Here's the code

'#default_value' => array($_SESSION['location_current_tid']);


texts: Can I get the raw value of arbitrary tokens?

texts:
This site I'm working on is using tokens in such a way that the escaped (check_plain()'d) values provided by the tokens as is is problematic (they're getting double-escaped). Is there some way to specify that I want the raw values for those tokens? I tried just appending ":raw" to the token name, but that didn't seem to work.

I could just write my own tokens for this purpose which only provide the raw values, but I want to see if that's really necessary first.


texts: How to fetch the existing value of a form field in the form?

texts:
I have a minimal form with a single field to add an image to an entity and a save button. I have used managed_file to add the image.

After adding the image from form the image gets saved in db.

Next time the user opens the form, it shows blank field and after adding a value current one gets replaced. What I want to do is user should see the existing value of the field when reopening the form.

How do I do this?

[Edit]:

Code for my form is:

// Form Definition
function custom_profile_form($form, &$form_state){
  $form = array();
  $form['picture'] = array(
    '#title' => t('File'),
    '#type' => 'managed_file',
    '#description' => t('The uploaded file will be processed.'),
  );

  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
  );

  return $form;
}

// Form Validation
function custom_profile_form_validate(&$form, &$form_state) {
  $file = file_save_upload('picture');
  $file->status = FILE_STATUS_PERMANENT;
  $uploaded = file_save($file);
  $upl = file_move($uploaded, "public://");
  $form_state['storage']['fid'] = $upl->fid;
}

// Form Submission
function custom_profile_form_submit(&$form, &$form_state) {
    global $user;
    $user1 = user_load($user->uid);
    $file = file_load($form_state['storage']['fid']);
    $edit = array(
      'picture' => $file,
    );
    user_save($user1, $edit);
}


texts: db_query() is not returning results from a valid query

texts:
In short:  db_query of a SELECT statement is returning no results.  However, running the SELECT statement in phpMyAdmin vs the database returns thousands of results.  I'm using Drupal 6.

What I'm trying to do:  The site I'm working on gets thousands of spammers hitting it each day and creating accounts.  The accounts are worthless to them, because if they do not pay, they don't get to do anything but log in.  I want to safely remove these accounts.  Therefore, I'm selecting the accounts based on certain criteria and then want to iterate through each and use the Drupal delete user function to remove the user from Drupal.  Right now, I'm just trying to print the info that returns so I can see if I get the correct results before moving on to the delete, which is a simple 1 line addition.

Here's the code:

include_once './includes/bootstrap.inc';
include_once './includes/database.mysql-common.inc';

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$query = "SELECT u.uid as id, u.name as name, u.mail as email, ur.rid as role, FROM_UNIXTIME(u.created) AS created, FROM_UNIXTIME(unix_timestamp()-1209600) AS deadline FROM {users} as u LEFT JOIN {users_roles} as ur ON u.uid = ur.uid WHERE (ur.rid < 3 OR ur.rid IS NULL) AND u.uid > 350 AND u.created < (unix_timestamp()-2419200) ORDER BY u.uid";

$results = db_query($query);

print $query;
print "
";
print db_num_rows($results);

foreach ($results as $row) {
        print "
";
        print "ID: " & $row['id'];
        print "Name: " & $row['name'];
        print "E-Mail: " & $row['email'];
        print "Role: " & $row['role'];
        print "Created: " & $row['created'];
        print "Deadline: " & $row['deadline'];
}

For Posterity's (and other people finding this question) sake, here's the final code:

include_once './includes/bootstrap.inc';
include_once './includes/database.mysql-common.inc';

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$query = "SELECT u.uid as id, u.name as name, u.mail as email, ur.rid as role, FROM_UNIXTIME(u.created) AS created, FROM_UNIXTIME(unix_timestamp()-1209600) AS deadline FROM {users} as u LEFT JOIN {users_roles} as ur ON u.uid = ur.uid WHERE (ur.rid < 3 OR ur.rid IS NULL) AND u.uid > 350 AND u.created < (unix_timestamp()-2419200) ORDER BY u.uid";

$results = db_query($query);

print "Users To Delete:  " . db_affected_rows($results);

while ($row = db_fetch_array($results)) {
    print "
";
    print "Deleting: ";
    print " ID: " . $row['id'];
    print " Name: " . $row['name'];
    print " E-Mail: " . $row['email'];
    print " Role: " . $row['role'];
    print " Created: " . $row['created'];
    print " Deadline: " . $row['deadline'];

//delete the spam user cleanly
user_delete(array(), $row['id']);

    print " Completed.";
}

I setup a CRON job to run this weekly to do the clean-up.  There's no reason it can't be run more or less often, though.


texts: How to add js in view created by interface

texts:
I want to create a new button control in my ip_geoloc leaflet map. So, i created a view by using the drupal interface -> /admin/structure/views/view/markers_admin/edit

And now i want to set a custom JS wich execute only in this view. I've create a module to create custom form. And my goals are when the user click on the button control in the map, a modal pop with a form with lat/lng field to add dynamically the marker on the map.

I searched everything (how to create a modal -> colorbox, how to create a custom button, how to add the marker...) but i don't know how to attach the javascript to this page.

I've tried to implements these hooks (4th comments) in my custom module but this not work : https://www.drupal.org/node/1993228

Can you help me ?


texts: How to make a calendar tab for every user showing user's events?

texts:
I followed the tutorial Calendars for Organic Groups - A simple tutorial for D6, and successfully created a calendar for every group in my site showing its events. I also managed to show the calendar as a tab in every group homepage using the path node/%/calendar.

Now I want to create a second calendar page, shown as a tab in every user profile page, which will provide the user information about all the events that are registered in the groups the user is a member of. I created a second view, and configured it to show all the events of the site.

How can I limit this view to only show the events from all the groups? How can I add its page as a tab in every user profile? Is there a way to limit the access to this tab to only the user that owns the profile?


texts: How to make XML sitemap to work after transfer from localhost?

texts:
My XML sitemap module was installed and enabled long time ago when I just started to make my website on WAMP/ localhost.....

Now the site is live and on real host and domain; but sitemap is still on:

http://localhost/zen/sitemap.xml with 1050 links....

Error loading stylesheet: An unknown error has occurred (805303f4)http://localhost/zen/sitemap.xsl

And I don't see any option to change it's path....

What should I do?

Can I somehow correct it's path or I have to reinstall?

If I reinstall, what happens with all settings?


texts: Webform add data along with submitted values

texts:
I'm using Webform 6x 3.11 and have passed a nodeID into a hidden field called hidden_key. I have created a custom module to implement hook_form_alter() whereby I am trying to add additional data (along with the data that is being submitted) to the submission results.

This additional data is based on some calculations performed on the value in the hidden field, ie: getting some details about the node based on the nodeID. Here's what I currently have:

<?php
    function custom_form_proc_form_alter(&$form, &$form_state, $form_id) {
        if ($form_id == 'webform_client_form_33') {
            $form['#submit'][] = 'custom_form_proc_submit';
        }
    }

    function custom_form_proc_submit($form, &$form_state) {
        $node = node_load($form_state['values']['hidden_key']);
        $pool_title = $node->title;
        $pool_category = $node->field_category[0]['value'];

        // ?????
    }
?>

Where you see my ????? is where I am stuck. Along with whatever data gets submitted with the form, I would like to add these 2 custom fields to the submission results so that it looks like:

Fullname: Mr So-and-So
Email Address: someone@test.com
Pool Category: $pool_category
Pool Title: $pool_title
Availability: Yes

I would really appreciate your help! Thank you!


texts:
I'm developing a custom theme and even though I have placed the "user login" block in a region, I can't find it and now I'm locked out.

My site is on Drupal 8.


texts: Get number of items in cart of current anonymous user

texts: I need to get the number of items in cart of current anonymous customer on the site. I am using Drupal 7 and Drupal Commerce.


texts:
I'm trying to figure out how to use twig templates with views. at the moment I'm just using twig in the view itself but I'm sure I can use twig files to overwrite the styling of the view.

e.g.

        {{ field_category }}
        {{ title }}

I'm using this in the rewrite field of the block view with one field hidden.

How can I translate this to a twig file?

Edit1; I'll try to explain my issue in more detail. I've been working with the page.html.twig file which overwrites the default homepage used by Drupal. I'm wondering if I can do the same with blockviews. Can I overwrite the default layout, meaning html layout, divs, classes, ID's using a Html.twig file for the view?


texts: How can I log in as admin to my Commerce-kickstart demo site?

texts:
I am new to Drupal and I have completed the installation process for Commerce Kickstart in my XAMPP environment.

When I try to access the admin page of my sample commerce-kickstart demo eshop, I get an error like so:

  error 403 access denied

I am using the predefined Username (admin) and password and PHP 5.3.6.

Can anyone help me to get logged in as admin?


texts:
I need to slightly modify some URLs that are in a "Link" field on a custom entity type.
In a mytheme_preprocess_myentity I've found that field with $variables['elements']['field_my_url'][0] I get this output in Kint

I've tried using a number of methods on the #url object but I don't think I'm doing it correctly... I'm just confused on how to modify it at this point.
How can I change the external URL to which this particular field is pointing?


texts: Reference View in Entity Reference field

texts:
I have a content type that has an entity reference field allowing you to link to other pages and add a custom image, for nice big CTAs.

However, it's come to light that some of the links may need to be to Views that show content as a list or map.

The ER field has autocomplete enabled and it can't find the view by its URL e.g /my-view

Is there a plugin that would allow the field to find Views? Or do I have to change the content type and add a Link field instead?


texts: Moving nodes from dev to production (a simple use case)

texts: I want to use the backup_migrate module to move some nodes from dev to production (production is still off-line). But the node is split over so many tables...and I also added custom fields (image field) to the node. How do I use backup_migrate module to move the tables? How do I know which tables to move? Should I just move the entire db? then what would be the point of using features to export my configuration? Thank you.


texts: Is it possible to create an iCal stream from Open Atrium's calendar feature? If so, how?

texts:
I'm getting mixed signals around whether or not its possible to create an iCal feed from the Open Atrium Calendar Feature.

When I try creating a new view or adding a feed to an existing view, I don't see the option for an iCal feed...just RSS :(

Can someone point me in the right direction?

Some background: http://drupal.org/node/348871


texts: Fatal error: Call to undefined function entity_view_mode_prepare() /sites/all/modules/field_collection/field_collection.entity.inc on line 600

texts:
I get this error as I was doing my work. How do I fix this fatal error?

  Fatal error: Call to undefined function entity_view_mode_prepare() in
  .sites/all/modules/field_collection/field_collection.entity.inc on
  line 600


texts: Script blocked by provider because of execution time

texts:
Have moved my services to the new provider.
Never had such a problem before but now my new provider seems to stop/kill/hang processes running for longer then 30s.

The problematic module seems to be:

Localization update 7.x-2.0 Provides automatic downloads and updates for translations.

Once I run it, the whole service hanged so had to manualy disable it in the database.

It's a big problem for me as I used to run it periodically to update translations.

The question is if is there any way to configure it to do not exceed the given 30s time limit?


texts: How do I include PHP classes having the same name as Drupal classes?

texts:
I'm working on a custom module connecting Drupal and another website.
The other website is hosted on the same server so I decided to includes the classes in order to interract with it. (Using webservices is not an option for different reasons.)

Unfortunately I need to include one master file containing classes with the same name as Drupal classes; so I'm facing multiple errors.

Is there a way to use namespaces when we cannot force calls with namespace\functioname() inside includes files?


texts:
I am using Drupal commons distribution for a community site. The site has many private groups. When a user is browsing a private group and they click on a profile link (or user picture linking to profile) it will currently take them to the standard profile page, ie:

/users/joe-smith

I want the user to instead be directed to:

/groups/the-green-family/users/joe-smith

This will allow me to display the user profile without making the user feel like they left the group pages.

I can figure out how to handle the custom profile page, but how do I alter all of the user profile links? I tried hook_link_alter but it doesn't seem to be processes. What hook should I be using to do this?

Thanks!


texts: get user id from username or email without logging in

texts: I want to get the user id and role before the user is logged in.  If i have the email or username, what function can I use with D8 to get the user id ?


texts: Organic Groups Permissions and Site-wide Roles

texts:
I currently have a Drupal 6 site set up using Organic Groups and OG User Roles. This is important because we have mainly public groups, however some pages in the groups are restricted by a user's role, such as staff or student. In this way, a page can be private to its group members, and additionally visible by those users who have the staff or student role.

OG User Roles has not been upgraded to Drupal 7 and we are attempting to find a replacement. OG 7 does provide integrated roles for groups, BUT it does not include the ability to set viewership based on these roles. Public / Private is too black and white, we need much more granular settings for our editors.

I have looked at Content Access, but we have about 20 roles on our site, and our editors would be overwhelmed by the options. Additionally, Content Access does not provide a way to prevent an editor from assigning "edit" or "delete" permissions, which is an issue for us.

We only want editors to be able to say "For this group page, this site-wide role can see this page." Very similar to the existent OG audience selection, but including site-wide rules as OG User Roles does currently in D6.

Is there any solution for this in D7 with Organic Groups?


texts:
I have a callback function for downloading images that are called when a link is clicked. So I need to push the image name in a gtm datalayer. But no js is getting called when the file is downloaded. Is there any way to achieve this? Below is example of the flow I'm trying to achieve.

Created url in routing.yml

test.item.download:
path: '/test/{item_id}/download'
defaults:
  _controller:
    '\Drupal\test\Controller\TestController::itemDownload'
requirements:
  _permission: 'access content'

TestController.php

public function itemDownload($item_id) {
  $response = new Response(NULL, 404);
  //download file code
   ....
  $response = new BinaryFileResponse($file_spl_info, 200, $headers);
  return $response;
}

Href is given in twig file when the download link is clicked.

Basically, after the return of response, I need to push the file name in the data layer through my js. Is it possible to call js and push the file name in the data layer?


texts: How do I add attibution links to 'teaser thumbnails' in Drupal blog posts?

texts: I'm running a professional blog on, I believe, Drupal 6.17. It allows me to include a 'teaser thumbnail' of an image with each blog post. However, many times I want to use free stock photos from sites such as flickr and freedigitalphotos.net as that teaser. However, these sites require you to include a link back to the photographer's page along with an attritbution on the same page as the photo. I'm not sure how to do that with Drupal's 'teaser thumbnail' option.


texts:
I have a search page created with embedded filters in Drupal 8 View. In the list of fields I have a fields - [Field_program_id]. I also have a button 'Learn more' when clicking this button I want to pass the [field_program_id] and show the details of the Programs in that page. Not sure where to start. Any guidance?!

My view looks as below:

The '968' is the Program ID. Upon clicking the learn more, I want my url to be https://myproj/search?nodeid=[field_program_id]

and in this page I want to show the details again. Any help?!


texts: How to mark the fields of a view shown in a table as already read?

texts:
I have a view that displays the results as a table, and also contains an exposed taxonomy filter. I need a way to know when a certain field in a row has a value that has already been "seen". A row with a "seen" value is less useful compared to "unseen" rows. Therefore, the table needs to visually distinguish between seen and unseen rows, perhaps by highlighting seen rows, or fading them.

How could I determine when the field has a value that has been "seen", and then style rows with a "seen" value differently?


texts: trending topics view based on read counts

texts:
I am trying to setup a view where it shows the most popular articles and couldn't find any answer to this. My readers will all be anonymous as it's my company's blog.

Looking forward an answer as this is pretty useful on blogs!

Cheers!


texts: Run Drupal in localhost then migrate to online once it's finalized

texts:
Possible Duplicate:
  How to migrate from test environment to production environment?

I'm sure a lot of template designers work in localhost before going online. My question is what's the best way to take your installation online once you're done playing around with it? Do you redo everything or do you just copy your localhost db then import it online?

I'm using XAMPP in case it matters. :-)


texts: How do I handle a dynamic domain i.e. www.(dynamic|.*).(com|org|ca|etc ...)

texts:
So here is the deal, I recently started working on a site, actually three sites that have been split into three drupal installations.  These sites have the same function but different appearance.  So my thought was to merge them with different themes.  Now I have a new issue, two of the three sites are going to allow for others to use their own urls.  So www.hiya.com would point to my www.example.com.

Each of these new domains is in our db with what theme it is supposed to be.  My first impulse is to look up the site, and change theme in hook_theme().  There are some logic differences but worst case scenario I would just use a session variable to deal with those

I am new to drupal and wanted some thoughts, opinions, criticisms, wild accusations, etc...


texts: images not loaded with 503 resource not available

texts:
I have set up Redis (3.2.6) on Debian 8 and I am using redis 8.x-1.0-beta to make the connection. I am facing a strange error that happens every few days.

Drupal 8.2.7 will not serve few images (not all) and instead return a "503 resource not available" error in the browser inspector; I run redis-cli flushall to clear all cache and the images start loading again.

Upon inspection, the Redis cache is not full and Drupal log does not show anything strange.

Now Drupal gives me this error.

  Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException: Image generation in progress. Try again shortly. in Drupal\image\Controller\ImageStyleDownloadController->deliver() (line 148 from /var/www/vhosts/alphanews.live/httpdocs/docroot/core/modules/image/src/Controller/ImageStyleDownloadController.php).

I suppose that the images get broken upon uploading and then Redis cache gets the broken image cached.

There are similar Drupal 7 reports about wrong server configuration in relation to HTTPS access to the images causing this kind of problem as it can be seen here and here.

How do you prevent this error ? Is there any specific redis setup ? or is there any specific solution to this problem ?


texts: Group audience versus group content visibility

texts: Can someone explain me what is the difference between group audience and group content visibility?


texts: Logging URLs in the PHP-FPM Access Log - possible Clean URL Conflict

texts:
I have set up an access log in PHP-FPM under pool.d/www.conf, and I noticed that the log usually constructs the URL as "index.php" with all query parameters, EXCEPT for 'q,' which is the URL. I know that this is removed by the server for clean URLs, so would anyone know how to collect this?

Looking at the access log format instructions, it seems like there should be a header specifying location. I'll see if I can find one in Charles Web Proxy.

Here are the relevant config file sections:

from NGINX site config:

location / {
    # try_files $uri @rewrite; # For Drupal <= 6
    try_files $uri /index.php?$query_string; # For Drupal >= 7
}

location @rewrite {
    rewrite ^/(.*)$ /index.php?q=$1;
}

...

location ~ '\.php$|^/update.php' {
    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
    # Security note: If you're running a version of PHP older than t$
    # latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
    # See http://serverfault.com/q/627903/94922 for details.
    include fastcgi_params;
    # Block httpoxy attacks. See https://httpoxy.org/.
    fastcgi_param HTTP_PROXY "";
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_intercept_errors on;
    # PHP 5 socket location.
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    # PHP 7 socket location.
    #fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

from /path-to-php5/fpm/pool.d/www.conf

; The access log file
; Default: not set
access.log = /var/log/php5-fpm/$pool.access.log

; The access log format.
; The following syntax is allowed
;  %%: the '%' character
;  %C: %CPU used by the request

...

;  %e: an environment variable (same as $_ENV or $_SERVER)
;      it must be associated with embraces to specify the name of the env
;      variable. Some exemples:
;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e

...

;  %o: output header
;      it must be associated with embraces to specify the name of the header:
;      - %{Content-Type}o
;      - %{X-Powered-By}o
;      - %{Transfert-Encoding}o

;  %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
access.format = "%R|%u|%t|%m|%r%Q%q|%s|%f|%{mili}d|%{kilo}M|%C%%"


texts: How do I call a controller method from a twig template and passing arguments to it?

texts:
I know I can pass variables to templates using render arrays.

$theme = 'block-AcademicDisplay';

return array(
  '#theme' => $theme,
  '#content' => $content,
  '#url' => urlencode($url),
);

How can I pass variables and call controller methods from that template? On that template, when clicking on some buttons or links, I would like to call a controller method and pass it 2 parameters.


texts:
I need to find all FieldItemList's with a certain field type.

/* @var FieldItemList $field */
foreach ($p->getFields(FALSE) as $field_name =>  $field){
  kint($field->getPluginId()); //NOPE
  kint($field->getFieldDefinition()); //NOPE
  kint($field->equals(array('MY_FIELD_TYPE'))); //NOPE
}

I would expect there is a simple way of finding out the field type of a FieldItemList.


texts:
I am using Views to display some comment for specify node.

The SQL query on Views pane:

SELECT comment.uid AS comment_uid, comment.cid AS cid, comment.created AS comment_created, 'comment' AS field_data_comment_body_comment_entity_type
FROM
{comment} comment
INNER JOIN {node} node_comment ON comment.nid = node_comment.nid
WHERE (( (node_comment.nid = '1330' ) )AND(( (comment.status <> '0') AND (node_comment.status = '1') )))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0

I try to copy above sql to phpmyadmin:

SELECT comment.uid AS comment_uid, comment.cid AS cid, comment.created AS comment_created, 'comment' AS field_data_comment_body_comment_entity_type
FROM
comment
INNER JOIN node_comment ON comment.nid = node_comment.nid
WHERE (( (node_comment.nid = '1330' ) )AND(( (comment.status <> '0') AND (node_comment.status = '1') )))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0

But phpmyadmin throw an error to me:

Error Code: 1146. Table 'daxuebao.node_comment' doesn't exist

I try to search drupal node_comment table at google, But I get nothing.


texts: Custom Filter Stops working after count of filter value 1013, in Apache Solr Search

texts:
I am using Search API Mutli module to search on multi indexes all together. I need to implement custom permissions on search result set which basically is a filter by node id user has permission to view, for which I implemented hook_search_api_multi_query_alter, the code looks like
function mymodule_search_api_multi_query_alter(SearchApiMultiQueryInterface $query) {
  // Get current user connections to filter search search results by.
  global $user;
  $connections = get_allowed_users($user->uid, array(1), 'requester_id');
  $related_nodes = get_allowed_nodes($user->uid);
  $filter = $query->createFilter('OR');
  foreach ($related_nodes as $related_node) {
    $filter->condition("test_content_index:nid", $related_node);
  }
  foreach ($connections as $connection) {
    $filter->condition("test_users_index:uid", $connection);
  }
  $query->filter($filter);
}

The two helper functions used in the hook get_allowed_nodes() get_allowed_users() returns allowed uids and nids which the current user is allowed to view, then with help of custom filter I am trying to filter the search results and everything work as expected till count of $related_nodes is less than 1013. The time count reaches to 1014 I get no results found in search result.
I am using apache_solr as search server.


texts: Is there a way to pass additonal php.ini settings to a drush command?

texts:
I want to specify additional php.ini settings to a drush invocation in the manner they would passed using -d option if drush was a php script that could be passed to PHP using the -f parameter.

On looking at drush  shell script - /usr/bin/drush - I see that it executes the drush.php script in that manner.

Is there a way to add more of those through the command line?


texts: Is it possible to force Views to collect a minimum count of nodes per group?

texts:
I have a View that collects nodes of a certain type, grouped by term.

Term 1
 Node 1
 Node 3
 Node 4
 ...
Term 2
 Node 2
 Node 5
 ...

Can I force Views to list exactly 10 nodes per each term, rather than total of ten per entire query?


texts: I have logged a bunch of slow queries. Now I am wondering how should I find them in Drupal. Any ideas?


texts: How to make the Admin interface language switch based on node content?

texts:
How can I make the Administration interface language be the same as the Editing content?

By example. If I edit a French content, I would like my interface in French.
If I edit an English content, I would like my interface in English.


texts:
I have updated a module from Drupal 6 to Drupal 7, but the following code doesn't work anymore. I have updated the .info file, but the module still doesn't work.

function header_image_block($op='list',$delta=0,$edit=array()) {
   if ($op=='list') {
     $blocks[0] = array(
       'info' => t('Header image'),
     );
     return $blocks;
   }

   elseif ($op == 'view') {
     $block = array(
       'subject' => 'Header Images',
       'content' => changeHeader(),
     );
     return $block;
   }
}

function changeHeader() {
  $output = '';
  $output = '';
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    $node = node_load($nid);
    $path = $node->field_head_img[0]['filepath'];
    if ($path != '') {
      $output = '';
    }
  }
  return $output;
}


texts: Photo-swipe is not loading in my website

texts:
I'm using drupal -7 with mobile_jquery(https://drupal.org/project/mobile_jquery) as theme

and PhotoSwipe .

The PhotoSwipe is not working in the gallery page.When we click on the thumbnail ,the image will not load first time and show the blank screen with below message

  undefined

and we can see path of the image in the address-bar.When we refresh the page the PS will work.But something missing ...
website: http://www.w3qatar.info/aldarmobi .

properties >> please click on any property and you can find more images >> Click on any image to see the PS.

I don't know what is the reason for this.Please help me to solve this issue.

Please suggest me any other image gallery module which works on ios,android devices.


texts: Exclude certain taxonomies from url reachbility

texts:
I have the following structure example.com/taxonomy/term/334 and there are several terms that I don't want to be reachable by domain.

I use the autopath module, so for example it could be I want example.com/status/green and example.com/status/red so to say every example.com/status/* to be reachable, but example.com/media/blu-ray and example.com/media/dvd or example.com/media/* not.

Any ideas how this can get realized?


texts: What is the 'Drupal way' to create a menu callback and display a rendered page of JSON?

texts:
I have created a new menu item and a callback function.

  ...
  $items['user/%user/enquiries'] = array(
    'title' => t('Enquiries'),
    'page callback' => '_client_enquiries',
    'access callback' => 'user_access',
    'access arguments' => array('view enquiries'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1
  );
 ...
 function _client_enquiries() {
   return t('Enquiries');
 }

I am now going to CURL some json from a published google spreadsheet, and cherrypick, and then print some of it out in a table. My question.. what is the drupal way to do this? I think it would be to create a custom theme function which makes my processed json data available to a template, which I can somehow load onto my menu callback and output. If that is the case, could anyone give me some pointers/examples or a point in the right direction.


texts: How to publish unpublished nodes programmatically

texts:
I have some unpublished nodes, for which I have their node IDs. How can I programmatically publish them?
Is it correct to achieve it in custom module using a query like the following?

db_query("UPDATE {node} SET status = 1 WHERE nid = %d", $nid)


texts: What is the syntax for using a contrib module's service from within a hook implementation?

texts:
I'm trying to get a list of objects from AWS using the S3fsService from the S3 File System module from within a hook_cron() implementation. The following code works:
// Fetch list of files in S3.
$config = \Drupal::config('s3fs.settings')->get();
$s3 = \Drupal\s3fs\S3fsService::getAmazonS3Client($config);
$iterator_args = ['Bucket' => $config['bucket']];
$iterator = $s3->getIterator('ListObjectVersions', $iterator_args);

…but I'm getting a message saying Deprecated function: Non-static method Drupal\s3fs\S3fsService::getAmazonS3Client() should not be called statically….
How should I be calling it differently?
Thanks!


texts: How to perform a comparison in a rule to check all values of a multi-select list?

texts:
I'm stuck with a simple problem, maybe someone can point me in the right direction...

I have a ContentType with a field, let's say it's a list of hobbies. It's a Checkboxlist, multi-select.

Users have an additional account field to select their favourite hobby (a single-select selectbox)...

Now, when a new content of that type is generated I wan't to send an email to all users who have a selected hobby from the list, selected as favourite in their profile.

--

I used "Fetch entity by property" to get the users with one of the selected hobbies.

I configured it that way:

Entity type - Value: User
Property - Value: Hobby (this is a single value, cause a user can only select one hobby)
Value - Data selector: node:hobbies:0 (and there is the problem: I can only compare it with the first value of the multi-select hobbies list)

Result: It triggers only correctly for the first selected hobby.

--

How can I configure it to take every selected value?


texts: Can I disable a cookie from a contrib module, in this case fontawesome I believe

texts:
I have a D8 site v8.9.6 and have some questions on cookies.
I would prefer not to have any cookies on my site unless they are really required for a properly functioning website. With all things going on like GDPR and APP I prefer to have this as clean as possible.
In order to find out which cookies are in use I checked Chrome DevTools and it shows me just 1: _ga with source of fontawesome.com (I installed the FontAwesome module).
First question, can I disable this cookie somehow?
Second question is related to Dropdown Language, a module that gives me a dropdown select list for the user to select its language of choice. I can't find anything in the documentation about how this tracks the user's choice and I don't see anything in DevTools (cookies, session), so this is not working with cookies?


texts: Creating Number fields (integer and decimal) manually in code for custom forms

texts:
I need to manually render a number field in Drupal 7 on a custom form. I have created the following field definition:

$form['num_seats'] = array(
  '#type' => 'textfield',
      '#title' => t('Number of Seats'),
      '#required' => TRUE,
      '#number_type' => 'decimal',
      '#field_name' => 'num_seats',
      '#element_validate' => array ('number_field_widget_validate'),
      '#field_parents' => array(),
      '#language' => $language->language,
      '#field_prefix' => '$',
      '#size' => 14,
      '#maxlength' => 12,
      '#default_value' => $location ? $location['num_seats'] : $node->field_workshop_num_seats[$node->language][0]['value'],
);

However submitting the form produces an error of the form:
"preg_replace() [function.preg-replace]: Compilation failed: range out of order in character class at offset 14 in number_field_widget_validate() (line 391 "

If I use 'integer' instead of 'decimal' for 'number_type', it works fine.
I checked Number module's code and could see this is bcause of regex not being created correctly from field definition.

So my question is how can I manually render Fields outside of regular Drupal entity_type context (i.e. outside node/user etc. forms) in a custom form whose submission gets stored to a custom table.


texts:
Im doing a website for photos. The photographer uploads all the images and drupal generates a thumbnail and a resized image.

What i'm trying to do is to put a link , so the final user can download all the original files in a zip files.

Can you guys help me out?


texts: I would like to have a multi image upload in my form with an option to sort images and provide optional title/alt. This functoonality is present in the image widget field widget plugin and so instead of writing a lot of new code I am wondering if there is a simple way to use it as form element somehow?


texts: Modal with content depending on opening hours

texts:
I need the user to enter opening hours for their helpline in the CMS along with two sets of text, one that will be displayed if the user views it during their opening hours & another which is displayed outside of their opening hours.

This content needs to be displayed in a modal on specified pages when a link is clicked (a 'modal box' is like a JavaScript overlay on the page).

The way I have been trying to approach the problem (taken from a suggestion else where on Stack Exchange) was to use the Office Hours & Colorbox Node modules together. Unfortunately unless I've misunderstood what Colorbox Node does or how it works I cannot get it to open a modal at all, I can't actually get it to do anything.

Below are the steps I've taken to install the Office Hours & the Colorbox Node modules so hopefully someone can spot what I've done wrong. I am more than open to other suggestions to solve this problem though.

Using the two modules mentioned my plan was to create a custom template which would read the current date & time, compare it to what has been entered into the Office Hours module then display the appropriate text from one of two text area fields in the CMS.

Created fresh Drupal 7 install
Installed Office Hours 7.x-1.4 module (https://www.drupal.org/project/office_hours)

2a. Installed required module Date api 7.x-2.9 (https://www.drupal.org/project/date)
Installed Colorbox node 7.x-3.5 module (https://www.drupal.org/project/colorbox_node)

3a. Installed required module colorbox 7.x-2.10 (https://www.drupal.org/project/colorbox)

3b. Installed required module Libaries 7.x-2.2 (https://www.drupal.org/project/libraries)
Created new content type with the Office Hours field
Created new node setting the new office hours
Created test page with link to office hours page, link has class of "colorbox-node" which should show a modal?

This is what the link tag currently looks like:

Test link


texts: Installation profile - Can I create nodes via yml files? What's the best practice for it?

texts:
I've created an installation profile for Drupal 8, which creates content types, taxonomies, blocks and stuff I need for new projects via yml files. Now I also want to create some default nodes.

I could use hook_install() or the module "default content" to create some nodes, but I'd like to know, if there is a better way for it.

Since we can create content types, taxonomies, blocks, etc. with yml files, I was wondering if it is possible to also create nodes with it.

So my questions are:

Is there a way to create nodes via yml files?
What would be the best practice for it?


texts: How can I report to Drupal what is the translation in a language of a string passed to t()?

texts: I'm using Drupal 7. I see that the t() function is responsible for translating terms. Where do I go to find the list of translatable terms? For example, suppose I have t('hello world') in my code.  What file do I edit to tell Drupal 7 that the French version of "hello world" is bonjour toute le monde?


texts:
editing node.tpl.php, I want to create a conditional statement based on the node's taxonomy which will not print the submitter info and de-links the title from the node.

How would I get the value of the node's taxonomy when it passes into node.tpl.php?

I've tried $sTaxonomy = $node->taxonomy and doing a strpos($sTaxonomy, 'static') and a in_array('static', $sTaxonomy) which neither returned true (or not false). I've tried attaching 1-3 terms on the content and trying both methods without luck.


texts: How to get nid of all nodes that are displayed inside a view?

texts:
I have view named 'xyz' set on example.com/xyz. I want to access nid of nodes that are shown by 'xyz' and show them on example.com/abc. I want to do it in a custom module. What hook i can use?

I tried to look into views API but no ups there.


texts: How to remove wrapper when rendering page region?

texts:
$sidebar_second = render($page['sidebar_second']); print $sidebar_second;

generate by default

How can i remove these wrappers ?


texts: How to define positive AND negative depth on taxonomy filter in views' module?

texts:
I am looking for a way to have an exposed filter in a view, based on the option "has taxonomy terms with depth", that can look for a term in a positive and a negative depth.

An example : I want that when "EUROPE" is selected, all contents that have "WORLD" or "SPAIN" "ENGLAND" Show-up in the results.

Does anyone has an idea ?

Thank you in advance.


texts:
I'm using hook_preprocess_node in a module. In that, I check whether the node type, and on satisfying the condition I'm doing a theme_hook_suggestions. My tpl.php files are inside my modules template folder, It is not taking the tpl file I have suggested. I have searched a lot, but didn't find any solutions

Any solution would be apprecaited
Here is my code

/**
 * Implements hook_preprocess_node().
 */
function mymodule_preprocess_node(&$varaiables) {
  if (isset($varaiables['node'])) {
    $node = $varaiables['node'];
    $field_template_list = $node->field_template_list[$node->language][0]['value'];
      if ($node->type == 'event') {
        $varaiables['theme_hook_suggestions'][] = 'module_name_' . $field_template_list;
      }
   }
}


texts: Block value in a view row design template

texts:
I have a block value which I need to access in a views row design template. I need to check the value of the block content in this template.

Does anyone know how?


texts: Facet blocks are not appearing, when indexed view block is called programmatically with views_embed_view

texts:
I have made an indexed view of my products. In that view, i have a page and a block. If I output the block from drupal/admin/structure/block the block view is shown together with the facet blocks.

Due to some conditions, I prefer to output the indexed view block programmatically, via page.tpl.php, and views_embed_view(), the indexed view block is shown correctly but then the facets are not displayed. Here is my code:

//level 2 webshop/categorie/subcategorie
            elseif( count($url_array)==4 && $url_array[1]=="webshop"){
                // if ($url=="/webshop/auto"){
                $tax_arr=taxonomy_get_term_by_name($url_array[3],"product_categorie");
                $tax=reset($tax_arr);
                $tax_chi=taxonomy_get_children($tax->tid);
                $tax_chi_tids = "";
                $counter=0;
                foreach ($tax_chi as &$child) {
                    if ($counter == 0){
                        $chtid =$child->tid;
                    $tax_chi_tids .=$chtid ;
                    }
                    else{$tax_chi_tids = $tax_chi_tids."+".$child->tid;}
                    $counter ++;
                }
                //echo views_embed_view('product_categorieen', 'block_1',$tax->tid);
                echo views_embed_view('view_products_index_product_hh','block_1',$tax_chi_tids);
            }


texts: How can I delete taxonomy terms for a specific node type?

texts:
I had a taxonomy vocabulary (Tags) shared across all of my content types including those like forum and blog that could be user created. I'd like to remove the terms / Tags from all node types except story. Story can only be created by site authors. Is there an acceptable way to do this?

I tried deleting the tag field from the content type. However, it does just that.  The field isn't part of the type, but the terms remain assigned to the existing nodes.

If I were going to do this programmatically with a MySQL script, are there tables other than taxonomy_index, field_data_taxonomy_vocabulary_, and field_revision_taxonomy_vocabulary_ that I'd need to delete rows from? It seems like I could generate a list of nids I want to remove terms from, and then delete the corresponding rows from those 3 tables.

Thanks in advance for any help. I'd be happy to provide additional information.


texts: jQuery conflict issues with client embed code

texts:
I am trying to use jQuery.noConflict so that I can use a 3rd party chat system that uses jQuery. This chat system loads in 1.72 while my current installation of drupal is using 1.12. After some hours of debugging and moving scripts around while trying to use noConflict(), I am at my wits end.

I believe the issue is that while trying to implement the 3rd party "click to chat" system for the client, it breaks IPE. This is being added via an embed field in a custom module I created. This embed field is being outputted via a twig variable in html.html.twig after

    {{ page_bottom }}
    <js-bottom-placeholder token="{{ placeholder_token|raw }}">
  </body>
  {{ embed|raw }} //Embed code here
</html>

My current error is as follows while trying to "edit" with the IPE.

jquery-ui.js:905 Uncaught TypeError: Cannot read property 'call' of undefined
    at a.(/web/anonymous function).(anonymous function)._trigger (https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js:905:38)
    at a.(/web/anonymous function).(anonymous function)._trigger (https://www.example.com/web/core/assets/vendor/jquery.ui/ui/widget-min.js?v=1.12.1:4:1094)
    at a.(/web/anonymous function).(anonymous function)._createWidget (https://www.example.com/web/core/assets/vendor/jquery.ui/ui/widget-min.js?v=1.12.1:4:3317)
    at new a.(/web/anonymous function).(anonymous function) (https://www.example.com/web/core/assets/vendor/jquery.ui/ui/widget-min.js?v=1.12.1:4:661)
    at HTMLDivElement.<anonymous> (widget-min.js?v=1.12.1:4)
    at Function.each (jquery.min.js?v=3.2.1:2)
    at r.fn.init.each (jquery.min.js?v=3.2.1:2)
    at r.fn.init.a.fn.(/franchise/anonymous function) [as draggable] (https://www.example.com/web/core/assets/vendor/jquery.ui/ui/widget-min.js?v=1.12.1:4:2374)
    at n.render (BlockView.js?v=8.4.5:95)
    at n.<anonymous> (LayoutView.js?v=8.4.5:146)

This currently renders the IPE completely broken. What would be the correct way to implement a 3rd party system that loads its own version of jquery, while not being able to change the source code of this 3rd party system?

This is what I have read/tried so far:

https://api.jquery.com/jquery.noconflict/

https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview

Similar but I also tried this:

https://stackoverflow.com/questions/2812359/mootools-and-jquery-conflict-despite-dollar-safe-mode


texts:
I made a content type programmatically with the entity_translation module. There are about 250 fields.

240 fields are not to translate because their values are identical. So I only want to use entity_translation for about 10 fields.

Now i have a lot of checkboxes and select fields. This are all associative arrays. Out of the box the values are shown in English for German and English urls.

E.g.:
Select list: ("keyA" =>''valueA", "keyB"=>"valueB") shows "valueA" or "valueB" as result for the field in the node.
I want the t-function included to use a *.po file for translation.
Thus t('valueA') has to be implemented before rendering the field?

How can I do this?

THX in advance,


texts: How can I set the site root page to a landing page instead of user login?

texts:
I'm using a custom bootstrap 3 theme as my default theme which sets the user_login page. When I go to the root of my site, this is the page that appears. How do I change the root of my site to display a page other than user_login?

Specifically, we are trying to add a landing page and we would like https://oursite.com/ to display the landing page instead of the login page (which is also accessible thru https://oursite.com/user/login)

All the suggestions I've seen so far just say to create a node and redirect to something like https://oursite.com/landing, but we would like http://oursite.com/ to be the landing page instead of having to redirect to another page.


texts: Cannot find /libraries for installing ckeditor module

texts:
I'm trying to install the CKEditor Codesnippet module. I've downloaded the source but I don't know how to install it.

In the module page istructions are:

  Download the plugin from http://ckeditor.com/addon/codesnippet at least version 4.5.11.

  Place the plugin in the root libraries folder (/libraries).

  Enable CodeSnippet in the Drupal admin.

  Configure your WYSIWYG toolbar to include the button.

I cannot find the /libraries folder. Should I create it in the root folder of Drupal installation or somewhere else?


texts:
I have a taxonomy vocabulary "categories", and decide that one of the terms should no longer be used (because I introduced another field which covers this information).

I could delete the term, but then some existing content would no longer have a category.

What I would like is to "deprecate" the term, such that

existing content can continue to reference the term.
the term is still visible in things like search facets.
the term can no longer be assigned in a term reference field.
(optional) editing an existing node which references the old term will fail form validation on save, and force to change the term.


texts: Reply form not showing for ajax_comment module installed for Open social distribution

texts:
recently I've installed Open Social Distribution and installed the ajax_comment module to enable ajax comments and reply but unfortunately the reply link never appear at the home page that shows all posts
here is a screenshot of a post showing in home page:


texts: Can't pass variable from theme hook or controller to custom template

texts:
On Drupal 8, I want pass a variable to a overrides template from my controller OR from the hook theme.
I do several tries :

from my .module file :

function ms_story_theme($existing, $type, $theme, $path) {
  $theme = array();
  $theme['page__ms_story__global'] = array(
    'variables' => [
      'toto' => "toto", //try one
    ],
    'base hook' => 'page',
    'render element' => 'elements',
    '#tata' => 'tata', //try two
  );
  return $theme;
}

from my .php controller file :

class customController extends ControllerBase {
  public function map_global($name) {
    return [
      '#type' => 'markup',
      '#theme' => 'page__ms_story__global',
      '#markup' => $this->t("Implement method: hello with parameter(s): $name"),
      '#tutu' => "tutu", //try three
      'variables' => [
        "tyty" => "tyty", //try four
      ],
    ];
  }
}

But when I want display all available variable from my overrided template file (via {{ kint() }} ), I don't see anywhere variables I want add. Variables 'toto' 'tata' tutu' and 'tyty' aren't present in the array structure displayed via kint (I cleared all cache of course)

Where is my mystake ?

Bonus question : how can I add a variable who use not any cache ? (the variable is calculated again every time the user load page ?


texts: How do I do a file upload with other form data in Drupal 6?

texts:
I have this in my form function:

$form['#attributes'] = array('enctype' => 'multipart/form-data');
... other form fields
$form['form']['form_file'] =  array (
    '#type' => 'file',
    '#name' => 'form_file',
    '#attributes' => array ('class' => 'textarea_crmform'),
 );

and when I call file_save_upload in my submit function, I am doing this:

if ($file = file_save_upload('form_file'))

But it never gets into the above if statement.


texts: DBTNG Migrate: SQLite -> PostgreSQL fails because of custom fields

texts:
I am trying to migrate a website from a development setup that uses SQLite as a database backend to a production environment, where PostgreSQL is used as a DBMS.

My research so far has led me to the DBTNG Migrator Module, that promises to migrate a Drupal site to/from any database system the abstraction layer supports.

This is the database configuration in my settings.php:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'drupal',
      'username' => 'db_user',
      'password' => 'db_pass',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'pgsql',
      'prefix' => '',
    ),
  ),
);

$databases['sqlite']['default'] = array (
  'database' => 'sites/default/files/site.ht.sqlite',
  'driver' => 'sqlite',
  'prefix' => '',
);

Both databases are correctly being displayed in the DTNG Migration UI. However, when I run a Migration check for SQLite -> PostgreSQL, I get the following error message:

field_data_field_custom does not existing in default

field_custom is a custom field I defined in the development site.

Is there way to migrate my complete drupal setup, including custom fields and content types to PostgreSQL, using DBTNG Migrator?


texts: How to properly configure the Mega menu module?

texts:
first of all I would like to point out that I speak very poor English,
sorry in advance for the poor quality of the translations...
(Google Translate)
I recently encountered several problems with the Drupal mega menu module, also called "we-megamenu", when creating my theme on drupal 8.
Characteristics of this site:

Drupal 8.9.3
localhost by wamp server

Drupal mega menu visual in my situation :

Firstly, I can't automatically center my submenus in relation to the screen, so I have to manually manage the positioning of each submenu in relation to the parent menu, I am looking for a way to position the submenus not relative to the parent menu, but just relative to the screen (without using postion: fixed)
Currently :

I specify a custom class on my submenu items :

Then afterwards, manually I come to modify my sub-menu by means of the css, there are two options for this:

/*
    * OPTION n°1
    * Modification of the horizontal position of each megamenu
    * Because I have not found a solution so that they are all in the same place
    */
    .menu1 {
        left: -1224px;
    }

    .menu2 {
        left: -1297px;
    }

    .menu3 {
        left: -1412px;
    }

    /* OPTION n°2
     * Automatic positioning
     * However the menu follows the scroll of the page
     */
    .menus_deroulants {
        position: fixed !important;
        top: 23% !important;
    }

Secondly, I don't understand why when I click on a sub-menu that I have grouped, it is in turn unfolded ??
I would like it to be just a clickable link like its child elements.
Exemple :

I set my sub-menu as a group, in order to display its sub-menus directly without having to click ...

Then when I click on this one on my page, I get this :

He created a new submenu of this submenu for me, and I don't understand why? ...

Thanks in advance for your answers, I hope you will help me solve these problems, even if I am doing my research on my own in the meantime.


texts: Using Views as a report in a custom module

texts:
I'm new-ish to module development. I just need to be pointed in the right direction.

I have a custom module that I think would benefit from a report. The report should show up in the admin reports menu. (I already know how to use hook_menu to display "Hello world!" as a report in the reports menu.)

It seems to me that the easiest way to compile the data for the report would be to use Views. But where do I go from here? How do I programatically use a View as one of the reports my module provides? (Or am I wrong in assuming that this can be done or is a good way of doing things?)

To be clear: I am not talking about my module providing a default view that shows up in the views menu, but using the data from a View as a report.

What I want is the same result as this idea, but programatically in my module.


texts: How to prevent the conversion of text URL to link on a single URL?

texts:
I have a page that I am adding, and for my purposes I want to have a text-only URL without an automatic link, but only for that one link, one this specific page. I need to be able to add full html content to the page, and I would prefer if other URLs on the page automatically became links.

I have tried putting other tags around the URL and HTML-escaping certain characters in the URL, but it still gets converted to a link.

Is there a way to prevent a specific URL from becoming a link?


texts: How to show related nodes in a view block based on taxonomy terms?

texts:
I have two Content Type, Apartments and Events.
Both have a Term reference field (field_location).

I want make a view block that displays in the nodes of Apartments Content Type some fields of Events Content Type based on field_location term.
If in Apartments the field_location is Rome the block must display only the field of the nodes Events with field_location Rome.

How I can do it?

Thank you in advance.

  SOLVED


texts:
I've created a frontpage which uses a the 34/33/34 panel layout and linked different contents to it (another pages). By checking the code using Firebug i see that teasers on this front page inherited the H2 class settings for header text, so they appear with the same text size just as they appear in full content view.

I'd like to customize the size of the header texts of the teasers on the front page. Any suggestion welcomed!

Thanks!


texts: Security review: Some files and directories in your install are writable by the server

texts:
I am running Drupal 8 on a vps running latest ispconfig/apache fastCGI.

Security review module reports: "Some files and directories in your install are writable by the server." and basically lists all my files.

Now all files are set with the correct permissions: 644 for files, 755 for directories.

I suspect the problem is file ownership.
Ispconfig creates a new user for each site and they belong to a client group.

So for this site all files belong to: web65:client0

which means: owner is web65 and group is client0

And I noticed the www-data user is a part of the client0 group.

Is this the problem? That the webserver is a member of the client group?
And what would be the best fix?
I suspect this is a problem for all ispconfig users?

Any ideas?


texts:
I have a webform with id 32.

I created a template (which works fine) in my theme/templates folder named webform-form-32.tpl.php.

I also created a preprocess function in my template.php file. My theme is called emuse and my hook is:

function emuse_preprocess_webform_form_32(&$vars){
}

but this doesnt get called. Can anyone help me out ?


texts: How to set up a view containing a list of events ordered by date

texts:
I want to have a list of Events on the front-end like this:

Upcoming (Newest on top)
<Event1 title> @ <Event 1 Date>
<Event2 title> @ <Event 2 Date>
.
.
Past (in reversed order)
<Event3 title> @ <Event 3 Date>
<Event4 title> @ <Event 4 Date>

So I created a content type: event:

Title
Description
Start_Date

And a view: events with the filter criteria Type = event.

This gives me a list of all events created. But where to go from here? I created a new views-view--events.html.twig but I don’t know how to retrieve the Start_Date value. Also I think this should/can be done somewhere else?

Thanks!


texts:
I have enabled 2 languages on the site (Russian and English). The conflict is only happening at the home page where the URL alias is /. All the strings at sitename.ru/ are in English (the ones I would expect on sitename.co.uk), except for blocks. Language seems set to Russian, if that is the language set for the blocks.
All the other pages (sitename.ru/pagename) are working correctly.

Here are some screenshots of page configuration, modules list and language configuration from admin.

How do I make it work on / for all languages based on their TLD?

Please advise


texts:
I wanted to attach a form to my node, in wich the subject would be already filled with the nodes title.
I was trying something with webforms and views but didnt get any results. Any Ideas?


texts: What's the difference between the container and html_tag render elements?

texts:
What is the difference between render elements of #type html_tag (set to div) and container in Drupal 8?
Is the container render element, a simpler version of html_tag? Easier for processing to preprocess container elements?
I note that:

historically, html_tag was for void elements in the  tag in Drupal 7.x.
if the container element is used a form, it adds the form-wrapper/js-form-wrapper class and an HTML ID if it has #array_parents.

Perhaps my theories are correct (easier to leave be for historical reason / form element reasons)?
PHP:
  use Drupal\Core\StringTranslation\TranslatableMarkup;

  $variables['myhtml_tag'] = [
    '#type' => 'html_tag',
    '#tag' => 'div',
    '#attributes' => [
      'class' => 'my-container-class1',
    ],
    'child' => [
      '#markup' => new TranslatableMarkup('Some Container text1.'),
    ],
  ];

  $variables['mycontainer'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => 'my-container-class2',
    ],
    'child' => [
      '#markup' => new TranslatableMarkup('Some Container text2.'),
    ],
  ];

HTML:

Some Container text1.

Some Container text2.


texts:
after hours trying to solve this issue by myself and searching for solutions in Google I thought that maybe someone may already faced this.

Scenario:
I am running drush site-install
The installation goes well until it hits a hook_cron (don't really know why) and tries to instantiate a a class. If I run drush cron on an installed site it works as a charm as is only when I am installing the site that this happens.

I use PSR-0 to bootstrap the namespaces and the implementation looks much like this:

/**
 * Implements hook_boot().
 */
function MY_MODULE_boot() {
  //Autoload classes PSR-0
  $namespaces = array(
    'COMPANY\MY_MODULE'     => array(__DIR__ . '/lib'),
  );
  MY_MODULE_register_class_namespace($namespaces);
}

/**
 * Registers a class namespace with the Composer autoloader
 *
 * @param  array  $namespaces
 */
function MY_MODULE_register_class_namespace(array $namespaces = array()){
  static $loader = null;
  if (!$loader) {
    $loader = require_once realpath('.') . '/vendor/autoload.php';
  }

  foreach ($namespaces as $namespace => $namespace_path) {
    $loader->add($namespace, $namespace_path);
  }
}

This is the error I get in the console:

Drush command terminated abnormally due to an unrecoverable error.                                                                                [error]
Error: Class 'COMPANY\MY_MODULE\Repository\MYCLASSRepository' not found in
<path to module>, line 588

I would really appreciate any help with this one.
Thanks in advance and sorry about my English.


texts: Sorting Views result rows based on an array of node IDs

texts:
I have a View of song nodes, and each node has a programmatically calculated total number of points associated with it. (For background: song nodes are referenced in a custom field_chart_items field on a chart node, hence the $chartHistory node query seen in the hook below. The custom field includes a numeric Position that's entered on the chart node, and a numeric Points total that's hidden from view and calculated based on Position in a chart_field_entity_presave() hook.) I'm trying to sort the View's results by points, with highest points totals listed first.
In a views_pre_render() hook, I calculate the points total for each row and place it into an array, $songAndPoints, that contains the song's nid and points total. The array is sorted so that the song with the highest points total comes first – therefore, the order of the nids in the array is the order in which I want my results to appear.
Can I programmatically reorder the $view->result array based on the array of nids I'm getting? My attempt below, using a uasort() callback, doesn't work, but I'm not sure if or how I can do what I'm looking for (or if, perhaps, it needs to happen in a different hook).
<?php
/**
 * Implements hook_views_pre_render().
 */
function MODULE_views_pre_render(&$view) {
  if ($view->current_display === 'DISPLAYID'
    && $view->id() === 'VIEWID') {
      $entity_type_manager = \Drupal::entityTypeManager();
      $node_storage = $entity_type_manager->getStorage('node');

      foreach ($view->result as $key => $song) {
        $node_type = 'chart';
        $songNID = $song->nid;

        $chartHistory = $node_storage->getQuery()
          ->condition('type', $node_type)
          ->condition('field_chart_items', $songNID, 'IN')
          ->condition('status', 1)
          ->execute();

        if ($chartHistory) {
          foreach ($chartHistory as $chartNID) {
            // ...
            // Various calculations to get points total, $songPoints, for each song.
            // ...
          }
          $songAndPoints[$key] = ['points' => $songPoints, 'nid' => $songNID];

          // Sort based on point values.
          arsort($songAndPoints);

        } else {
          $songAndPoints[] = ['points' => 0, 'nid' => $songNID];
        }
      }

      kint($songAndPoints); // Array with original row number as key and two values, points and NID, sorted with highest points first. This is how I want to sort the results.

      uasort($view->result, "MODULE_sort_by_points_total");
  }
}

/**
 * Custom uasort() callback to sort view results by points totals.
 */
function MODULE_sort_by_points_total($left, $right) {
    $order = ['704', '712', '707', '713', '711', '709', '708', '883', '882', '715', '714', '710', '705']; // TEMPORARY: Hardcoded list of node IDs in order; should be replaced by something like array_column($songAndPoints, 'nid'), but hardcoded values don't work either.

    $flipped = array_flip($order);
    $leftPos = $flipped[$left]->nid;
    $rightPos = $flipped[$right]->nid;
    return $leftPos >= $rightPos;
    // via https://stackoverflow.com/questions/17324708/php-array-multisort-not-sorting-my-multidimensional-array-as-expected/17325584#17325584
}


texts: Allow users to submit content that is approved before it is published

texts:
I want to allow users to submit the content to my site, but the content must be first approved, and then it can be published.

Is there a module that do this? Which code should I write for such module, if one doesn't exist?


texts: Showing nested links in Drupal but still add classes to list elements

texts:
Very new to Drupal and a bit confused.

In order to render a menu in my theme I've been using this:

print theme('links', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links'))));

That works a treat and gives me an extra class on the first and last list items, which I need for styling. It doesn't, however, show any of the nested sub menus.
So I found this that again, worked like a charm Show all nested menu links in Drupal 7 and shows all the top-level links in the main menu and the nested ones too.
This doesn't give me the extra classes on the first and last list items which I need.
Is there any way to use the code from the answer above and give the extra classes on the list items?

Thanks muchly


texts:
I'm attempting to append two fields with some text in the middle. Using the changed date and a plain, core, text field, I can do something like this, and it works:

{{ node.changed.value|date('m.d.y') ~ ' | By, '}}{{ content.field_author_name.0 }}

However, if I attempt to do that in a single tag, the changed date, and the 'By' text is output, but I don't get the author name field.

{{ node.changed.value|date('m.d.y') ~ ' | By, ' ~ content.field_author_name.0 }}

Is that not valid twig syntax, or is there something else needed to get that to work in a single statement?


texts: Import Book content and structure from another drupal website

texts:
I am looking to implement an 'Open Government Guide' on my website.

Here is a link to one of the books that I would like to copy

My question is - How do I copy both the Book Content and Book Structure from another Drupal site that I do not have admin access to? Ideally I would be able to do this for all 50 States.


texts: View that displays both Media files and nodes

texts:
I have run into a problem where it seems like you can't display Media module Files alongside regular nodes. I have a filter that is set to show content of type Webform. I wanted to be able to have an OR operator and show Files of type Document (plus a tag of type "form") so I could show "paper" forms with web forms, but alas, it doesn't appear possible. This filter option

isn't present unless I choose "Files" when setting up a new view

Some magic must be happening when "Files" is chosen, but it isn't apparent to me.


texts: How do I get the count of all messages in the inbox?

texts:
How can I get the count of all the inbox messages, with the Private message module?

Below the inbox messages, I need to display the count of total messages, such as:

  10 of 55

_privatemsg_get_new_messages() is the function to get new messages in Drupal 5.

Is there any function to get the count of all messages in Drupal 6?


texts:
I installed chosen module and the library v1.8.3.

Jquery update is 1.10

Libraries is installed and enabled as well.

I get this error on the console when I try to use a select list with chosen:

Uncaught TypeError: this.selected_item.off is not a function

Does anyone know how to solve this?


texts: Can you stop embedded Flickr Images from following their link if the user clicks the image, thus leaving your Drupal website?

texts:
Using Drupal 7.37, Omega4-SubTheme
Acquia Dev-Desktop Stack (Development)
Windows 7 HP

Using Media Module with the Flickr provider Module installed, the Media_YouTube, and the Media_SoundCloud providers installed as well (along with their dependencies).

I set up some dummy-content via a customized Create-Content node. Added Flickr-Images as a field-type bundled with various tags to distinguish properties of my Media-Files for later categorization.  I have other Media-File-Types and their Providers installed as well (Media_YouTube, Media_SoundCloud) and they work fine without adding outbound-site-leaving-links.

Then I set up Views to output all the content of the website along with respective fields.  All this works and displays small representations of the media in a table along with my added fields.

In this Views display, Flickr embedded-images show up fine and can be styled, but unlike YouTube-Videos or SoundCloud_Audio-Files, Flickr-Embedded-Images will leave the website when clicked.  Both YouTube and SoundCloud do not exhibit this behavior and instead only play their respective Media.

Is there anyway to block, stop, or (best) redirect the Flickr-Images to show their associated node rather than linking to Flickr?

I have tried every configuration Option I can find.  I have tried options in the Create-Image-Content node GUI but I see nothing to suppress the outbound-links.  I have tried the Views-Display GUI, but again, I see nothing in the Views-Settings that suppresses the outbound-links.  And I have also tried the Administration>>Configuration>>Media>>File-Types setting for my Image-File-Types (this control-panel is very mysterious).  In none of these locations can I come across something which shuts-off this outbound behavior.

I have spent much time trying all kinds of option-permutations and searching for any kind of documentation but have come up with no solution.

Is there an option-solution or a css-workaround or do I have to abandon the Flickr-provider-module because this is its hard-wired behavior?


texts: How to alter the URL path alias generated by content type programmatically?

texts:
Our current url pattern is [node:menu-link:parents:join-path]/[node:title]. What we need is a way to not to include the parent menu link items and only include the child menu link items.

For example:

The expected output is the following:

When Any menu link is placed at the same level as "Fourth level 1" (under Top level), it should be ".com/Second-level1/Third-level-1/Fourth-level-3"
Current issue is that the URL is generated as ".com/Top-Level/Second-level1/Third-level-1/Fourth-level-3"
We want to remove Top level, Top level 2, top level 3, etc removed from URL path alias.
Depending upon the placement of the menu link item, it should always contain the menu links 1 level above (if applicable)
The expected url pattern for third level 2 (under Top level/Second level 1) is ".com/second-level-1/third-level-2"

Updated:

I ended up write a custom module to call the hook_alter using the pathauto that just removes the first part of the URL before the node save event.


texts: Create user permission with specific role?

texts:
How do I give the "create user profile" permission to a role? I have the manager role and I want to give permission to to it to create an editor or manager user. I don't want to show all the roles on the user create or edit page.

Is there any module for achieving this?


texts:
I have a view that lists a set of taxonomy terms. When the user clicks on one of the taxonomy terms  in the view it sends them to a results page showing a list of all the content types that have this taxonomy term. The problem is views made this results page without any options for me to change it. Right now it only shows the title field and a read more link. I would like to add more of the content types fields to the result. For example the content type has images One thing i would like to do is add the image field to that results page so each result has an image. How do you add fields to the views results page that is after the user clicks the term on the taxonomy view.

Current view shows a list of taxonomy terms. When user clicks on one of the taxonomy terms in the view it will send them to a page showing a list of content that are associated with that taxonomy term. I want to edit the list of content that is associated with the selection, not the list of taxonomy terms.


texts: Searching through nodes and outputting the details on gmap

texts:
I have a gmap that is displaying all the information of real estate listings that I put in.

Now I want a text search that basically searches through the nodes and outputs the information in the same map and filter it basically.

So if I search for 2 bedroom in Boston in a simple text search. (Hopefully the search will have auto complete)

It will only show me the two bedrooms in boston I selected. (Boston is a node type) not part of gmap.

Basically I need a text search to filter the map listings which I dropped on it.

I don't want spatial searching.

Help!


texts: is it possible to have two input fields per label in a Drupal form?

texts:
I've got a Drupal 6 form API question which may or may not be possible, or a good idea.

Is it possible to have two input fields per label?

I'm familiar with this format:

$form['example_textfield'] = array(
'#type' => 'textfield',
'#title' => t('text here'),
'#size' => 30,
'#maxlength' => 32,
'#required' => TRUE,
);

As the way to make one label with one field, but is it possible to have one label and two input fields? and create something like:
label: {input field} {input field}

If there is a way to do it, how would I get the two values into the DB table?

Is such an approach even a good idea?
or should I stick to the single label/single input field method demoed above?


texts: View/Page with form to insert data and display it

texts:
I need to create a View/Page or whatever to display a form. This form only could be viewed by registered users, and on it, the user could insert different data (text, images, etc) and then this data need to be displayed on another view/page/section of the web.

I think this is very simple to do it with Drupal, but I'm a little lost, and I need a guide or some advice to go ahead.


texts: Sometimes an item is not added to the cart, despite message "xxx was successfully added to the cart"

texts:
I have built a custom module for my D7 site that shows a dialogue when the user opens the cart. In the dialogue a few more items are suggested to the user. If the user chooses to tick the box in front of such items, and then click a submit button, the items are added to the cart with the help of an axios request.

This is the axios part in the front end (the variable products holds the SKUs of the chosen items in an array):

  axios.post("/add/related_product", {
    products: products,
  }).then(function (response) {
    if(response.data === 'READY'){
      setTimeout(function() {
        window.location.reload();
      }, 200);
    }
  });

In the backend I have the following callback function, that handles the post request:

// callback to add selected products progammatically to cart
function _related_products_ajax(){
  global $user;
  // If the user is anonymous, force a session start.
  if(!$user->uid > 0) {
    drupal_session_start();
  }
  $order = commerce_cart_order_load($user->uid);
  $order_id = $order->order_id;
  //recieve id's for selected products
  $items = json_decode(file_get_contents("php://input"), $assoc = true);
  if($items['products']){
    foreach($items['products'] as $sku){
      if ($product = commerce_product_load_by_sku($sku)) {
        $line_item = commerce_product_line_item_new($product, 1, $order_id, $data = array(), $type = 'product');
        drupal_alter('commerce_product_calculate_sell_price_line_item', $line_item);
        rules_invoke_event('commerce_product_calculate_sell_price', $line_item);
        $line_item = commerce_cart_product_add($user->uid, $line_item, TRUE);
        commerce_cart_order_session_save($order_id, $completed = FALSE);
        commerce_order_save($order);
      }
    }
    drupal_json_output('READY');
  }else{
    drupal_json_output('FAILED');
  }
}

When adding products to the cart the normal way with the add-to-cart button on product pages, the item in question is always added to the cart, no exceptions.

One obvious cause would be the axios way of using "promises", and that the callback function above sometimes don't get called. But since the Drupal message "Item successfully added to cart" is shown after the page is reloaded, I guess that is proof that the backend is actually called and that the promise is fulfilled. Also, the first argument after then() in the axios snippet wouldn't be called if the promise wasn't fulfilled.

Is there anyone out there that have an idea why items sometimes don't get added with my custom module? It can happen both for logged in and for anonymous users. It seems to me that it's more likely to happen the first time a new user attempts to do this (but not sure about that).


texts:
I have developed a D7 website locally (WAMP), now I want to move it to a production server.

The production server has a SVN repository, so when I want to move my local files to the server I do a commit of all the changed files.
To sync the databases I get a dump of the local DB and I import it in the DB on the server.
First of all, is this a proper way to move my site to production or is there a better workflow?

The problems I encounter are these:

When I enable caching and aggregation on my local site and then sync the two databases, when I go to the production site it's like all my stylesheets are gone. There's no css styles applied whatsoever.
When I disable caching and aggregation and sync the databases, the styles are back but it's like it's the design of a month ago. The design of the local site doesn't resemble the design of the production site. When I look at the page source, I see the CSS files getting called as: pages.css?mmtwln. What does this ?mmtwln mean?
I can't login to the admin pages on the production site. When I enter my username and password nothing happens but the page getting refreshed. No error message, no red border around the textboxes. The rewrite module is enabled on the production site. I also set the $base_url and $cookie_domain in the settings.php (I have a multisite configuration, should $base_url and $cookie_domain go in sites/default/settings.php or sites/mysite/settings.php?).

If anyone can help me with any of these questions, or point me in the right direction I'll be forever grateful.


texts:
In performance I have caching turned off, yet if I update a value in the DB  directly I have to flush the cache to see changes on my site. Why is that?
(ex: using phpmyadmin and changing a value)

I'm inserting/updating values to my DB externally from another server that is not using Drupal. (using mysql)

How can I make my Drupal website automatically reflect the changes when the DB values change?


texts:
I'm trying to change the Views SQL operator from = 'String' to LIKE 'String%'.

I thought the best way to do this was through function hook_views_pre_execute(&$view) at the bottom of views.module. I tried that, but any way I edited the query it would throw an error.

For example, I tried str_replace:

function views_views_pre_execute(&$view) {
    if ($view->name == "schools")
    {
        $view->build_info['query'] = str_replace("location.city = :db_condition_placeholder_3","location.city LIKE '".$view->build_info['substititions']['%2']."'",$view->build_info['query']);
    }
}

I expected this code to edit the query so it would search location.city LIKE 'Calgary%', but instead I got Fatal error: Call to a member function addMetaData() on a non-object in [...]/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1306.

I read the documentation, but it looks like when they refer to Wildcards like %1 and %2, they're referring to arguments passed as contextual filters, as opposed to an SQL LIKE %...% wildcard.

What am I doing wrong?


texts: How to find out if a Rule is successfully executed or not?

texts:
I am using Drupal7. I have created a custom event for a rule using hook_rules_event_info(). I have added a Rules Action for the Rules Event "Flag a node".

When I invoke the Rules Event in code, using rules_invoke_event(), I have to know whether the Rules Action is executed successfully or not.

How can I identify if the Rules Action fails and handle the failure situation gracefully? Primarily I need to know how to identify whether the rule is successfully executed or not?


texts:
In my twig theme - I'm attempting to test the value of the field "field_left_image_front" - which is either "Yes" or "No"

{% if content.field_left_image_front.0 == "Yes"  %}

{% else %}

{{ content.field_left_title.0 }} {{ content.field_left_image_front.0 }}

{{ content.field_left_body }}

{% endif %}

A few bits of info:

field_left_image_front is a select list/list item in the CMS
I'm testing the value by outputting it in h1 tag - so I can see that it's "Yes"
Despite being "Yes", it's outpitting the text description and ignoring the image.

Is there something I'm doing wrong with the conditional?


texts: How do I create an AND filter for the same field

texts: I am having a problem with a view filter. I have one field called Category. The field contains a comma separated list of id numbers that represent different categories. I want to create a filter that will filter out all records that contain one id number, but not another. So my filter is Category=5601 AND Cateogry<>5612. Whenever I create this filter, the result ends up as OR instead of AND.


texts: How to display/hide reference term field on node add

texts:
I have a groupcontent type 'post' that can be posted in two grouptypes 'A'and 'B'

My groupcontenttype 'post'has two vocabularies:

One when posted in grouptype 'A' Vocabulary: practice
One when posted in grouptype 'B' Vocabulary: theory

With a hook_form_alter i like to hide/display my reference term fields based on when my og_group_ref points to grouptype A or B.

Help appreciated.

Thanks


texts:
I think that was drupal 6 where the user menu e.g.:

-Login

will turn into:

-Log out

link when the user is not logged in and when the user is logged in respectively.

I do not know how to make this behave like this in Drupal 7.

Any ideas?


texts: "[node:flag-vote-count]" displays the token name, not the number

texts:
I have a problem in the Flag module with the [node:flag-vote-count] token. I googled for a solution, but I couldn't find one.

On my content page, the Flag module displays the token name (i.e. [node:flag-vote-count]) on the node creation preview page, instead of a number.

I am putting the token on the Flag -> Edit -> "Flag link text" field. Meaning inside the flag itself. [node:title] is working perfectly fine there.

Someone can help me here?


texts: multidomain, multilanguage, keep indicization, multiheadache

texts:
I am trying to figure out how to migrate a website with multidomain and multilanguage settings, keeping SERPs.

PREFACE:
I have 17 website all identical, except language, in pure html. All 17 website got good SERP positions...
site.com
site.de
site.fr
site.ch
site.co.uk
site.pt
site.ca
...

PROBLEM:

I have installed drupal, create the template and fill up the CMS with all content necessary. I have used the i18n module to translate the website. Basically I have one node for each content.

node/1 ABOUT US
node/2 QUI SOMMES NOUS
node/3 CHI SIAMO
node/4 QUIENES SOMOS

They are linked so when I click on the languageflag the content change based on the languauge:
site.com/fr/qui-somme-nous.html
site.com/en/about-us.html
site.com/es/quienes-somos.html
site.com/it/chi-siamo.html

The old web pages are structured like this:

site.fr/qui-somme-nous.html
site.co.uk/about-us.html
site.es/quienes-somos.html
site.it/chi-siamo.html

and now the source of enormous headache...

How can i set up drupal in order to got on the same drupal installation the different topdomain and different multilanguage content, keeping the search engine position?

Hoping to have enough explain my situation.

Cheers


texts: How to import the exported yaml of a view

texts:
When attempting to import a view's exported yaml, the following message is received:

The configuration cannot be imported because it failed validation for the following reasons:
Configuration menu_export.export_data depends on the menu_export extension that will not be installed after import.
Configuration menu_export.settings depends on the menu_export extension that will not be installed after import.

There is no such dependency in the yaml, and there is no D8 menu_export module.


texts: How to check "Show as expanded" by default on the Add menu item page

texts:
I need the 'Show as Expanded' checkbox on the Add menu item page to be selected by default.

I created a module, 'expand_menu_items', and tried a hook_form_alter function to get the id, apparently it's 'menu_link_content_menu_link_content_form'.

I know I'm looking for #default_value, there are a couple and tried setting them to 'TRUE' but it's not having an effect on the page (xdebug shows the value as true). What could I be doing wrong?

Similar questions exist here:

Drupal 8 Menu always show as expanded - Though I may use the sql query to fix existing menu items, I'm more concerned with new menu items.
How to set the default "Show as expanded" to true in a custom menu item - This seemed promising, although in this case, all the menu items were added by end users.

Here's the function code:

function expand_menu_items_form_alter($form, FormStateInterface &$form_state, $form_id) {
if ($form_id == 'menu_link_content_menu_link_content_form') {
    // $form['expanded']['#default_value'] = true; // Doesn't work.
    $form['expanded']['widget']['value']['#default_value'] = true; // Doesn't work either.

}

}

Attached below is an image to the form page in question.


texts: Referring two file systems in a single site

texts:
I have production and staging environment that use the same file system (Amazon S3). I need to change the user profile picture saving path of my staging environment to local file system and other files to be saved in S3.

Is that possible?


texts: Is there a way to mock a procedural function from common.inc in a test without an external library?

texts:
I am trying to mock the render() function from common.inc in a test.

I am aware that render() could be substituted with a renderer service, but in this specific case I can't/couldn't refactor the code itself. Nor can I use an external lib for it.

Is there a way to do this in a native way, using PHPUnit only?


texts: Updating duplicate Flags AND one or more Views blocks on a page on Flag click

texts:
I have a page where I have several carousel views that can, at times, show the same item/node in each carousel. Such as a most downloaded and a most viewed. I have two different flags (bookmarks and cart) I need to update across the page as well as views blocks that lists out all of the flagged items for each of these.

So as I have been working on just how to do this I have run into some stumbling blocks. First of all I can hook into the flags JS API to initiate this, which is fantastic. I can even identify all of the flags of the type that has been acted upon which apply to the updated flag.

However I have ran into the following problems:

When looping through all of the identical items with say the bookmarks flag I don't seem to have a way to differentiate it from the other flags on the page that need to be updated. My concern is that by looping through all of them I will inevitably leave the flag I clicked on in the same state and all of the other duplicate flags on the page in the new state.

$(document).bind('flagGlobalAfterLinkUpdate', function(event, data) {
  //Your code here
});
I want to prevent the flags JS from showing the popup messages on each click such as "item added to bookmarks" and instead pass that to jGrowl. I know how to generate it in jGrowl, I just need to figure out how to capture that message and show it my way.
Finally I need to update the related views block on the page when this is done. Say the bookmarks list block.

So what I would like to know is first, how do I deal with updating the same item's flag on multiple places on the page when it has duplicates?
Secondly I want to know how to capture that message and redirect it to my tool (jGrowl).
Lastly is how do I update a view block on a page with AJAX?

I want to do all of the updates without reloading the entire page.

Currently I am running this on Drupal 7 with Views 3 and using Nice Messages to generate system messages in a Growl-like format.

Thanks,
Patrick


texts: Implement user editable personal pages with subpages

texts:
So I would like to have this structure:

/users/jhon
# A page (default blank) which can be edited by jhon

/users/jhon/project
# A page which can be created and edited by jhon and
# should be linked to in a menu in /users/jhon

/users/jhon/project/sub-project
# The same as above and should be linked to
# in a menu in /users/jhon/project

So I was starting to work on the profiles, but it don't feels like the right way..