texts: How to implement StackMiddleware for a redirection correctly?

texts:
I'm working on a redirection (for unauthenticated users) for my Drupal 8 site. Currently, the redirection works however, the redirection persists even after user is authenticated. I found this article piece helpful to point me in the right direction:

"Drupal 8 has two level cache, page cache and dynamic page cache. The issue you are having is more likely to intercept the page cache.
Add new class which implements 'HttpKernelInterface' and register 'http_middleware' with higher priority than 200 (280 will do)."

My problem is related to intercepting the page cache, so I am currently trying to implement the 'HttpKernelInterface' and register 'http_middleware' but unsuccessfully.
I created a custom module (example_module for example sake). My example_module.services.yml file:

services:
  example_module.event_subscriber:
    class: Drupal\example_module\EventSubscriber\RedirectAnonymousSubscriber
    tags:
      - { name: event_subscriber }
  example_module.stack_middleware:
    class: Drupal\example_module\EventSubscriber\StackMiddleware
    tags:
      - { name: http_middleware, priority: 210, responder: true }

Then in the same module I have a src/EventSubscriber/RedirectAnonymousSubscriber.php file like so:

<?php

namespace Drupal\example_module\EventSubscriber;
namespace Drupal\example_module\StackMiddleware;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
 * Event subscriber subscribing to KernelEvents::REQUEST.
 */
class RedirectAnonymousSubscriber implements EventSubscriberInterface,HttpKernelInterface {
  private $redirectCode = 301;

    /**
  * The wrapped HTTP kernel.
  *
  * @var \Symfony\Component\HttpKernel\HttpKernelInterface
  */
  protected $httpKernel;

  /**
  * Creates a HTTP middleware handler.
  *
  * @param \Symfony\Component\HttpKernel\HttpKernelInterface $kernel
  *   The HTTP kernel.
  */
  public function __construct(HttpKernelInterface $kernel) {
    $this->httpKernel = $kernel;
  }

  /**
  * {@inheritdoc}
  */
  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
    // Only allow page caching on master request.
    if ($type === static::MASTER_REQUEST && $this->requestPolicy
      ->check($request) === RequestPolicyInterface::ALLOW) {
      $response = $this
        ->lookup($request, $type, $catch);
    } else {
      $response = $this
        ->pass($request, $type, $catch);
    }

    return $response;
  }

  public function checkForRedirection(GetResponseEvent $event) {
    $is_authenticated = \Drupal::currentUser()->isAuthenticated();
    $route_name = \Drupal::routeMatch()->getRouteName();

    if (!$is_authenticated && $route_name !== 'user.login') {
      $response = new RedirectResponse('https://google.com', $this->redirectCode);
      $response->send();
      exit(0);
    }
  }

  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('checkForRedirection',30);
    return $events;
  }
}

Do I need both an EventSubcriber and StackMiddleware to accomplish this redirection and intercepting of page caching?
Do I have to create a separate custom module to implement my StackMiddleware class? How do I use my redirection code (which I know works) with this StackMiddleware class so I can intercept the page cache and have it run on every page(so it always checks to see if user is authenticated)? Any help appreciated. Thanks!


texts: Why is the header missing from a taxonomy view?

texts:
I have two views the first was created with no page or block and all defaults for "show" were kept. I have a header on that view and it shows fine.

The other view was created with no page or block but show was changed from "content" to "taxonomy" and I selected my vocabulary from the next option box. I have a similar header to this view (both use a panel pane) but the header for the taxonomy doesn't show. If I add a footer it will output fine but the header never renders on the page. Is there a known issue for headers and a taxonomy view?


texts: I have a view in drupal 7 and I have created a template of this view. Now I need to call image here.


texts: No Drupal Site Found when clearing cache

texts:
I installed drush using composer following the instructions here: http://docs.drush.org/en/master/install/

When trying to run drush cc all I get this error:

  No Drupal site found, only 'drush' cache was cleared.[warning] 'all'
  cache was cleared. [success]

I added this line:

export PATH="/Applications/MAMP/bin/php/php5.6.2/bin:$PATH"

to my .bash_profile and restarted bash and MAMP. Still no luck. Any ideas?

This is my drush status:

 Drupal version         :  7.36
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  localhost
 Database port          :
 Database username      :  root
 Database name          :  srod
 PHP executable         :  /usr/bin/php
 PHP configuration      :
 PHP OS                 :  Darwin
 Drush script           :  /Users/srod/.composer/vendor/drush/drush/drush.php
 Drush version          :  7.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Applications/MAMP/htdocs/srodsite
 Site path              :  sites/default

I'm running it from Drupal project folder.


texts: List all nodes by logged in user in a custom module

texts:
I am creating a module in Drupal 7, where I need to have a list of all nodes created by a logged in user of specific content type. How can I achieve this? It is easy to do it in view but I need to do it in a custom module. Can anybody help?

Thanks


texts: How do I find the user whose field is equal to the email address?

texts:
I am trying to fetch a Username where a field equals the value of another field.

On my content type, I have an Entity Reference fields that creates a select list of email addresses.

In Rules, reacting on Creating/Updating nodes in this content type, I am trying to Fetch a User Entity where the value the select list field equals the user's email.

How can I do that?

What I have tried:

I first chose to "Fetch Entity by Property".

The Value is "User", the Property was set to "Name", and the Value was set to the title of the Entity Reference field in the first screenshot (The title of each node in the select list is an email address)

The Fetched Entities are called "fetched_user".

When trying to Add a Variable, it shows multiple values, so I assume I would need to make a loop first.

So I created a loop:

I am very lost on what to do next. Can anyone help me?

Thank you.


texts: pass argument as a wildcard to node/add/Article/560012

texts:
Case :

I do have a Article-share content type , it does contain a node reference to type "Article" , now this is my scenario :

user selects a node of type Article
he redirects to node/add/Article share
now in this form I want the selected coupon shows up in the form automatically so the user wont need to fill this field again

Some more deails:

I have a content type called "Article-Share".
This type has a reference field to Node type "Article".
I want my content creation form for type "Article Share" to use wildcards to automatically fill "Article Link".

Any suggestions how I can do so?


texts: hook_views_query_alter creating additional OR statements

texts:
I am  attempting to add some "OR" statements to my Drupal view (to accomodate a grouping of taxonomy terms).

I am able to replace a tid one for one without an issue using the following code:

function customedm_views_query_alter(&$view, &$query) {
      if ($view->name == 'course_catalog') {
            dpm($query);
            foreach($query->where[1]['conditions'] as &$condition){
                if ($condition['value'] == 422){
                    $condition['value'] = 311;
                }
            }
        }
}

The problem is, I need to replace this value with several values (311,316,and 326)

I've tried replacing the $conditions variable with the proper or statement e.g.:

$condition = "WHERE field_data_field_course_subject.field_course_subject_tid = '311' OR field_data_field_course_subject.field_course_subject_tid = '326'";

Or creating a second $query->where[] array with the seemingly appropriate entries into the array:

function customedm_views_query_alter(&$view, &$query) {
      if ($view->name == 'course_catalog') {
            dpm($query);
            foreach($query->where[1]['conditions'] as &$condition){
                if ($condition['value'] == 422){
                    $newconditions = array(
                    conditions => array(
                        array(
                            field => 'field_data_field_course_subject.field_course_subject_tid',
                            value => 311,
                            operator => '='
                            ),
                        array(
                            field => 'field_data_field_course_subject.field_course_subject_tid',
                            value => 326,
                            operator => '='
                            ),
                        array(
                            field => 'field_data_field_course_subject.field_course_subject_tid',
                            value => 316,
                            operator => '='
                            )
                        ),
                        args => array(),
                        type => "OR"
                    );
                    $query->where[] = $newconditions;
                }
            }
        }
}

Neither of these approaches seem to product the desired outcome (though I was able to verify that the array creating approach created the appropriate fields in $view->query... can someone show me how I can add OR statements to my query using this hook?


texts: Drupal Add Media button is not showing up on editor

texts:
I have installed the media module and uploaded videos.
But I don't see the Add media button on the editor to browse and insert the videos from the library.
Is that it should be enabled ?


texts: How to programmatically display a webform in a block based on user selection

texts:
I am developing a module which generates custom blocks based on some configuration done by site admins in a module-specific config page. For each block I would like the admins to be able to nominate a webform (from a select dropdown), which would then be displayed in the block.

What I don't understand is how to match up the webform selection process with the webform display process. In the module-specific config page, I would generate the options by querying the node table for all nodes of type 'webform', display the titles of the webforms in the select element, and then save the nid of the chosen webform.

However this nid doesn't seem to be much help to me when it comes to my_module_block_view, where (as I understand it) in order to display a webform I need to do something like

$block['content'] = module_invoke('webform','block_view','client-block-N');

where N is the nid of the node to which the webform is attached, NOT the nid of the webform itself ? Incorrect statement - see correction below

So I'm unsure how to request the webform that the users have selected, as all I know about it is its nid?

What I'm seeing:

On my test Drupal, I have a webform with nid = 1, and content items of nid 2 and 3. Whether I specify 'client-block-1','client-block-1', or 'client-block-3' in my call to module_invoke, I am seeing no webform displayed.

Does anyone have any suggestions how I should proceed with this?

All help greatly appreciated.

CORRECTION

In the code example above, N should be the node id of the webform.


texts: What's the upgrade path for Embedded Media Field from Drupal 6 to 7?

texts:
I swear I've tried everything, and this is the very last piece that's keeping me from launching my upgraded site -- most of my nodes have video and/or audio in emfields.

The straight Content Migrate route kept on throwing errors every time it encountered and aborting the import. I edited the module to send the error messages to watchdog instead of the screen, but it still doesn't work -- it creates the tables in the DB but they're empty.

Someone out there must have achieved this ... any clues would be MUCH appreciated, I'm at my wits' end.

I've got the following installed:

Embedded Media Field 7.x-1.x-dev
Content Migrate 7.x-2.x-dev
Media + File Entity + Media Field + Media Internet Sources 7.x-2.0unstable6
7.x versions of all my Media: providers

I tried with the stable versions of all of these and switched to dev when those didn't work.


texts: Search API Solr Autocomplete no results when more than x Nodes indexed

texts:
I encounter a strange behavior on a site I'm working on.

I use Search API views exposed form for autocomplete.
My nodes reference nodes of another content type. The title of this referenced node's should be returned by autocomplete. This works all fine until more than 22 nodes are indexed. It seems like it does not matter which nodes are indexed, when 22 are exceeded the autocomplete will not return any results anymore.

I also tried to index the field as different types but the outcome is the same.

If i type in the term and click search the results are fine. I also ran the query in Solr's backend which returns the result as well.

Log's of Drupal and Solr show nothing.

Any suggestion on what and how to debug this?


texts:
I've attached an entityform object to content type on my site, the content is an organic group with users and administrators.

I want to extend the current emailing functionality of entityform -which currently emails an administrator, and the user who submitted it- to include the administrators for the organic group which this instance of the entityform is attached to.

As far as I can tell, when an entityform is submitted, it doesn't track which node it is connected to, it simply throws all the results for that type of form into a big pool, so I was struggling to try to create a rule that would get all the users from that organic group.

My alternative solution was to simply use hook_form_FORM_ID_alter, and add an additional submit handler to the form, and then write the email script out from there, it was mostly a last resort but that's where I'm upto.

However, this is where I'm stuck, for whatever reason, it just does not respond to my submit callback.

function mymodule_form_review_entityform_edit_form_alter(&$form, &$form_state) {

  $form['#submit'] = array(
    'entityform_edit_form_submit',
    'mymodule_notifty_review',
  );

}

I would so hope that I'm just being an idiot and getting the syntax or the code wrong to define my own submit handler, but when I dpm out the $form, it does acknowledge that there are 2 callbacks in the array. Is this a correct way to amend the callbacks for the form submit?

(Before anyone suggests Webform, I've already been down that route, and in terms of things this form needed to have, Webform couldn't do everything EntityForm can)


texts: How NOT to delete original account picture when uploading a new one?

texts:
When a user updates his account picture (default "picture" field,) his existing picture is deleted and replaced with the new uploaded picture. This is normally done by default.

How, using Rules (or any other way,) do I prevent the system from deleting the original stored picture so that the old and new picture reside in the same directory?

Thanks. :)

Update: Someone suggested making the field multiple value. I do not want users to be able to upload several account pictures. All I want is that a newly uploaded picture will indeed replace the old one but the old picture not to be deleted. Like I said in a comment below, the Heartbeat module takes a snapshot of the account picture. When users uploads a new picture, the old picture in the snapshot no longer displays (of course, it was deleted!) and a blank empty space is shown instead. Keeping the old picture would solve this issue.


texts: Select List value in an If statement - Computed Field

texts:
I have created a select list field in my Entity Form.

Select List : none||none and AM||AM and PM||PM

In my computed field, I want to know what did the user chose by using IF STATEMENT

example:

if($halfday == 'AM')
{
//action
}

I tried to use array_pop (example code :

$halfday = array_pop(field_get_items($entity_type,$entity,'field_halfday'));)

but it does not work for me. What PHP code should I use? Any suggestions?


texts: How can I grant anonymous users access to the locale language select form without hacking core?

texts:
I am attempting to override the user registration from at user/register to allow users to select their own language upon login.

Based on this helpful answer, I came up with this override:

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

  $form['locale']['language'] = array(
    '#type' => (count($names) <= 5 ? 'radios' : 'select'),
    '#title' => t('Language'),
    '#default_value' => $user_preferred_language->language,
    '#options' => $names,
    '#description' => $mode ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."),
  );

However, it doesn't work because of the following code in locale.module:

  $form['locale'] = array(
    '#type' => 'fieldset',
    '#title' => t('Language settings'),
    '#weight' => 1,
    '#access' => ($form['#user_category'] == 'account' || ($form['#user_category'] == 'register' && user_access('administer users'))),
  );

Simply deleting && user_access('administer users') from locale.module and clearing the cache makes it work, but if I do that I'm hacking core.

How can I remove the bit about && user_access('administer users') without hacking core?


texts: Image cache doesn't generate images using nginx

texts:
So I'm trying to set up thumbnails for articles written in drupal 8. The thumbnails won't generate though. so I just have 404 image errors.

/dl/sites/default/files/styles/large/public/Regular_Photo/xwing_0.jpg?itok=KE4FXSCU

I have this in my nginx set up

 location @drupal {
    # Allow CORS for ooyala.com
            add_header 'Access-Control-Allow-Origin' *;
            rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2 last;
    }
    # Caching entry for filetypes
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }
    # redirect server error pages to the static page /50x.html
    #
    #error_page 500 502 503 504 /50x.html;
    #location = /50x.html {
    #       root /usr/share/nginx/html;
    #}

    # CGI for /dl/
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
            #set $php_root /mnt/nfs_data/RebelFleet/app;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_intercept_errors on;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;

    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    location ~ /\.ht {
            deny all;
    }

    # Assist with CSS styles issues
    location ~ ^/dl/sites/.*/files/styles/ {
            try_files $uri @rewrite;
    }
location ~ /\.ht {
            deny all;
    }

    # Assist with CSS styles issues
    location ~ ^/dl/sites/.*/files/styles/ {
             try_files $uri $uri/ @drupal;
    }

At the moment, it doesn't create any thumbnails and not sure why it's not working. I don't get any errors in any logs.


texts:
I would like to know if there is a way to simply not save elements from a form. I know that we can hide elements with hide(), or #type = hidden/value, etc., but I would like to remove then completely from the form saving process.

I'm building a lot of "partial" forms (small part from a big one) and every time that I want to build a small form, with 2 fields, Drupal processes 20 fields and I have to hide the others 18 fields. It doesn't make sense for me.
I'm sure that Drupal can handle this better than hide and I'm missing something.

Example:
Complete form: name, age, city, country, phone
Form #1: name, age
Form #2: city, country

I would like to build a form like the #1 (with name and age only) and save it without loosing the data from city, country and phone BUT without hiding fields, valuing them nor with #access = FALSE.

Let me know if I'm still not clear enough. THANKS!!


texts: What consequences does "references in call_user_func_array are deprectated" have on form api?

texts:
The documentation on call_user_func_array has a note, part of it quoted below

  Before PHP 5.4, referenced variables in param_arr are passed to the function by reference, regardless of whether the function expects the respective parameter to be passed by reference. This form of call-time pass by reference does not emit a deprecation notice, but it is nonetheless deprecated, and has been removed in PHP 5.4.

The function drupal_retrieve_form uses call_user_func_array in building the form, and has this comment shortly before the call:

  We need to pass $form_state by reference in order for forms to modify it,
  since call_user_func_array() requires that referenced variables are passed
  explicitly.

While I haven't hit any serious issues running PHP 5.4, it sounds to me like anything that builds a form and then relies on getting back a modified form_state will break on 5.4. I may not entirely understand what's happening here however.

What are the consequences for Form API of this PHP 5.4 change?


texts: Is there any way to sort Drupal's content list in the admin area alphabetically by title? I am using Drupal 6.


texts: How I can create a condition to page variant (page_manager)?

texts: I made a plugin condition but don't appears in the options conditions of selection criteria in my page variant. What i need to do to create my custom selection criteria in page variant?


texts:
How to fix search result "Access denied You are not authorized to access this page"?
Have tried to change permissions and search module configuration, nothing helps...


texts: how do i programmatically set the ANONYMOUS USER permissions on a site install profile?

texts:
I am having trouble figuring out how to set permissions for users I personally did not programmatically create in my site installation profile. Can someone please help?

I would like to set 'View published content' as true for the ANONYMOUS USER user role in the .install file.

I am using the code below to grant permissions; but I do not know how to access permissions for the ANONYMOUS USER role.

       // Create the roles.
$roles['Content editor'] = array(
    'name' => 'Content editor',
    'weight' => $weight++,
    'permissions' => $base_permissions,
);
foreach ($roles as $role) {
    $role_object = new stdClass();
    $role_object->name = $role['name'];
    $role_object->weight = $role['weight'];

    // Save the role.
    user_role_save($role_object);

    // Grant permissions.
    if (!empty($role['permissions'])) {
        user_role_grant_permissions($role_object->rid, $role['permissions']);
    }


texts: Display Months in dropdown for filtering

texts:
I want to create a view over a content type. Over this page I want a select list of Months to filter the content by month.

Is there any module or how can I achieve this by view?


texts: Ajax callback on Views exposed form filter

texts:
I'm trying to add an #ajax callback method to my views exposed form filter select box.
But it seems the form have some issues with the callback.
My code is pretty simple
/**
 * Implements hook_form_FORM_ID_alter() for views_exposed_form.
 */
function mymodule_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) {
  if ($form['#id'] == 'views-exposed-form-viewid') {
    $op = ['hi' => 'hi', 'all' => 'all'];
    $form['test'] = [
      '#type' => 'select',
      '#name' => 'test',
      '#empty_option' => 'none',
      '#options' => $op,
      '#ajax' => [
        'callback' => '_my_call',
        'event' => 'change',
        'wrapper' => 'edit-output-test',
        'progress' => [
          'type' => 'throbber',
        ],
      ],
    ];

    $form['callfield'] = [
      '#type' => 'select',
      '#options' => [],
      '#prefix' => '
',
      '#suffix' => '
',
    ];
  }
}

function _my_call(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $message = 'test';
  $response->addCommand(new HtmlCommand('#edit-output-test', $message));
  return $response;

}

When I try to change the 'test' select box from view edit screen I get the below error
"Symfony\Component\HttpKernel\Exception\HttpException: The specified #ajax callback is empty or not callable. in Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse() (line 67 of /var/www/mypoc/docroot/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php)."
When I change the filter from the front end I get the following error
"An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports."
And I see a lot of similar issues -
Ajax callback is not working on views exposed filters
Ajax submission leads to => An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports
Any working example would be great!
Thanks.


texts: Products not getting categorized under different collection items

texts: We are developing an e-commerce site for selling of different products like earphones, music cds, musical instruments, storage devices like hard disks etc. But the problem is that if we click on earphones tab then as expected only earphones should appear but we are getting images of musical instruments, storage devices also. This is happening for other tabs also. So, basically the products are not getting categorized. Any solution??


texts: Drupal Site No Longer Rendering a Specific Theme - How to Troubleshoot?

texts:
I have a Drupal 8 instance running on a Ubuntu 16.04 virtual machine through Apache2 to test with and learn Drupal.

Up until today, everything has worked correctly, but on starting my VM this morning the theme is no longer rendering and I can only see a bare HTML page which just seems to show the development toolbar.

None of the permissions on my Drupal directory have changed, nor has my Apache config, and I don't seem to recall any updates being run on the VM.

So far I have tried:

Restarting Apache
Restarting the VM
Restarting the host machine
Checked permissions of the Drupal installation
Changed to a different theme
Refreshed the page and cleared the cache
Cleared all caches through the Drupal UI

After changing to a different theme, those ones would render, but after changing back to the theme I want, it just shows the bare HTML again. The theme I'm wanting to use is Drupal 8 - Parallax and I haven't changed any of the HTML, CSS or Javascript for it.

What are the steps to troubleshoot this issue?

EDIT
After further investigation, it seems to just be the "Home" page that isn't rendering properly. My other pages like FAQ, About Us, etc, are loading normally but the landing page of my site isn't displaying the theme when it was before. My Apache config for how I'm serving up the page is below.

<VirtualHost *:80>
        ServerName 192.168.1.239
        ServerAlias drupal-test.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/drupal

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The issue occurs when I go to drupal-test.com, drupal-test.com/node or the use the IP address of the server, which should take you to the front page of the site.


texts:
I'm migrating images from URLs and I'm mapping the image field with this code:

$this->addFieldMapping('field_image', 'titlePhotos')
     ->xpath('/photo/@URL');
$this->addFieldMapping('field_image:source_dir')
     ->defaultValue(DRUPAL_ROOT . '/sites/default/files/images');
$this->addFieldMapping('field_image:file_class')
     ->defaultValue('MigrateFileUri');

I want to overwrite files if they already exit when running the migration for the first time and on update.

I'm using Drupal 7.


texts:
In order to generate full path of images(URL) on views for rest endpoint on my decoupled Drupal project I'm using Image Url Formatter module, everything works correctly until I decide to put the website on HTTPS, In console I see
Loading mixed (insecure) display content
“http://core.domain.com/sites/default/files/styles/874x492/public/gallery/2017-01/1-907331.JPG?itok=MKfQSWFh” on a secure page

it's because this formatter return HTTP Instead HTTPS for image URLs.

In the situation like this that the websites should work on HTTPS and HTTP both, I advise  my team using //domain.com  instead of http://domain.com or https://domain.com in all endpoint URLS

Now I looking for a solution to return all images URL from http://.... to //... . if I had few views I could benefit REWRITE feature of view but I have a lot of views rest export endpoint.

What is your solution for this requirement?


texts: What would the correct way to add a conditional propertyCondition in an EntityFieldQuery

texts:
Please consider the following EntityFieldQuery. I would like to add a conditional parameter depending on the user's permissions. I'd expect the query would combine these statements and return both visibilities. However it ends in an empty result set. (Removing one of the statements gives the expected result).

$query = new EntityFieldQuery();
...
if(user_access('access public')) {
  $query->propertyCondition( 'visibility', 'public' );
}
if(user_access('access private')) {
  $query->propertyCondition( 'visibility', 'private' );
}
...

So how could I make both conditions apply without blocking each other?


texts: New fields are not showing in Re-use an existing field

texts:
I am using Drupal 9 and I have a page where I will be using a lot of the same fields (e.g. links, subtitles, paragraphs) throughout the page.
I created my first field for subtitle in /admin/structure/types/manage/page. I want to create my second subtitle field, but since it uses the same settings as the first I want to choose Re-use existing field, but there is no option there.
Do I have to do something else to enable the field to show in the Re-use an existing field menu?


texts: Call to undefined function views_embed_view() in php/php.module error

texts:
I have a Drupal 7 based website that is multi-site. There is one sub domain ,say sub.example.com which is a Drupal installation with out any module or content type and the example.com it self and they both use the same core.

when I go to sub domain address this error

Fatal error: Call to undefined function views_embed_view() in /home/A_NAME/public_html/modules/php/php.module(80) : eval()'d code on line 18

is reported but the example.com works well. why while they both use the same core but different databases this error is reported?

Furthermore, I was trying to move a website from different server to this sub domain, so I only transferred the database of the old website to the sub domain database. from that time on this error is reported.


texts: Views Sort Criteria: Sort by Taxonomy terms

texts:
I have a view that lists team members of a country that are referenced by an Entity reference field.

Now these team members can have different functions and job titles. I assign them through a taxonomy vocabular called "Functions" with the following terms:
- Office Head
- Partner
- Client Partner
- Consultant
- etc.

Usually team members only have one function but the Office Head always has two (Office Head and e.g. Partner).

When I now choose the above taxonomy field as a sort criteria, the office head always appears twice since it has two taxonomy terms assigned. But I only want the office head to show up only once.

Any suggestions how to do this would be greatly appreciated.


texts: Views - Conditionally rewrite title link attribute based on field empty value

texts:
I have a Resource content type that has a Title, Link or File Attachment.  The first is required, the latter two are optional.  The goal is for the administrator to create a new piece of content and link to either an internal (or external) page OR a PDF/Word file.

What I would like is have the Title be a link to either the page link or file location based on whichever is empty.

Right now, in the view, I have Title, Link and File Attachment fields exposed but hidden.  The Title field has Rewrite Output enabled, but how do I set it to link to either a web page or file path based on the empty value for the field?

Inside Rewrite Output, I can add either [file_link] or [file_attachment], but this is not conditional.


texts: video.js module Experiencing an error message after install

texts:
I am using Drupal 8 and attempting to set up the video.js module. The readme file needs work so it's hard to know where I went wrong.

Here is what I've done so far:

installed the module using composer.
went to the video.js GitHub and downloaded the js and placed it in the drupal 8 libraries folder path of libraries/video-js/video.js (not what's listed in the readme file since that said sites/all/libraries, which is a d7 location).
added the video.js to my content type field settings.

I receive this error message overlay on the video player:

  No compatible source was found for this video.

The video was shot with an iPhone 8 and uploaded using the video module field.


texts: How can I get a user by email address using a service?

texts:
I have a custom service that I created to do some stuff with users.  I want to be able to GET and DELETE users by email address because I may not know the uid.

I have the service set up now. It works through Postman, but through the actual client, it returns a 406 error because of the .com in the email.

How do I pass the email to the service if not through the URL?

This is the definition of the service.

'retrieve' => array(
    'help' => 'Retrieve a user',
    'file' => array(
        'type' => 'inc',
        'module' => 'user_service',
        'name' => 'user_service',
    ),
    'callback' => '_my_user_resource_retrieve',
    'access callback' => '_my_user_resource_access',
    'access arguments' => array('view'),
    'access arguments append' => true,
    'args' => array(
        array(
            'name' => 'email',
            'type' => 'int',
            'description' => 'The email of the user to retrieve.',
            'source' => array('param' => 'email'),
            'optional' => false,
        ),
    ),
),

The callback function is the following.

function _my_user_resource_retrieve($mail) {
  return user_load_by_mail($mail);
}


texts: In Drupal 8, how do I give access to some nodes to users with specific roles, depending on a field value or a taxonomy value?


texts:
I've got a custom content type 'professor', and a 'node--professor.html.twig' in my theme (derived from 'classy') to override the standard markup. The designer wants me to put a list (a view?) of the professor's 'courses' (which is another content type) between the professor's contacts and biography, basically, INSIDE the 'node--professor.twig.html'. Is there a Drupal-way to do it?

And, by the way, what is the main difference between a page with a custom content type and a custom content entity? Do I need to write a module and a content entity, or custom content type can do the trick?


texts: Error in validation of managed_file field with Form API

texts:
To begin I worked with this solution but a wild error appear: Image Upload in a Custom Module

Here is my code :

function module_top_content_equipe_admin_form(){
  $default = get_variable_value(variable_get('module_top_content_equipe_display', ''));
  $default_image = variable_get('module_top_content_equipe_image', '');
  $form['module_top_content_equipe_display'] = array(
    '#type' => 'text_format',
    '#name' => 'module_top_content_equipe_display',
    '#title' => t('Content of the block'),
    '#description' => t("Text to display"),
    '#format' => 'filtered_html',
    '#default_value' => $default,
  );
  $form['module_top_content_equipe_image'] = array(
    '#type' => 'managed_file',
    '#name' => 'module_top_content_equipe_image',
    '#title' => t('Top Content page l equipe Image'),
    '#description' => t("Image should be less than 400 pixels wide and in JPG format."),
    '#default_value' => $default_image,
    '#upload_location' => 'public://',
  );
  return system_settings_form($form);
}

function module_top_content_equipe_admin_form_submit($form, &$form_state){
  if (isset($form_state['values']['module_top_content_equipe_image'])) {
    $file = file_load($form_state['values']['module_top_content_equipe_image']);

    $file->status = FILE_STATUS_PERMANENT;

    file_save($file);
  }
}

and my error when I submit the form

  Fatal error: Cannot unset string offsets in /includes/form.inc on line
  2157

Thank you with advance


texts: Get the title attribute into a lightbox frame

texts:
I've been exploring and getting somewhat close to what I want (getting the value of the title attribute into my lightbox frame) by reading documentation
and this topic here at Drupal Answers.

I'm working with a custom tpl.php file with the following code (copied from elsewhere):

   if($id == 'field_afbeelding') {
            $samples = explode(';', $fields['field_werken_afbeelding_sampl']->content);
            $originals = explode(';', $field->content);
            for($i = 0; $i < count($samples); $i++) {
                print l($samples[$i], $originals[$i], array('html' => TRUE, 'attributes' => array('rel' => 'lightbox')));
            }
        }

From what I gathered in the documentation, it appears that I need to insert the lightmodal[][] array-thing into my code right at the end, where it says array('rel' => 'lightbox').

In the Drupal Answers topic, the question starts off about how to insert a CCK field (or a caption or whatever) into a lightbox, but ends about how to get the title attribute.

The very last comment says - I quote : 'Type
<?php print_r($node); ?>
 in node.tpl.php to see what's available in the node object (what fields, how formatted, etc.) and then take what you want and output it to the lightbox. I hope that's what you need..'

In my case, it's a view, so I went with devel module, going <?php global $field; dpm($fields);?>

Now as for 'take what you want and output it to the lightbox', the problem is I don't recognize out of these clickable Krumo blocks what I need. I do get these Krumo blocks that the devel module shows where you can click in the them and explore those elements/objects/whatever you want to call them.

I've been expanding all of the arrays and been seing 'title' in nested arrays. I guess the question boils down to what exactly must I put in this lightmodal[][] array if I'm right about the lightmodal thing?

And, before you ask, I made sure than in CCK, when editing the image field, I have alt and title attribute checkboxes checked and also given values to the images at hand.


texts: unlimited number of values gets really big

texts:
I have created a content type with a field inside which can take unlimited number of values. eg a city with the names of its inhabitants.

The problem is that this number can get really big (i.e. 100000).

Up to 5000 people I can edit this node with no problems (apart from the fact that it takes much time to load). But above this number I just get a white screen.

What should I do in order to be able to edit (e.g. the name of a certain inhabitant) with no problems?

My UI idea would be something like pagination (loading 100 records each time I change the page), but is this possible?


texts:
I'm using Ubercart in a Drupal 6 setup.I have created products and able to order the products as an authenticated user mode ,but when i go with anonymous buying it doesn't showing any products in cart page and it results "There are no products in your shopping cart." when click add to cart button.

For me its working good in live site , when i took live dump to my testing site , am facing above bug (There are no products in your shopping cart.) please help if anyone knows the solution for this .Thanks in advance.


texts:
I have a view in Drupal 8, and have configured a field in the view to have a custom CSS class.

The field I am adding the class to is an image. Under Style Settings I have chosen "Customize field HTML" and "Create CSS class".

When I inspect the image element on the front end, the class is nowhere to be found, and the styles are not applied.

I also have a view fields template for this view named:
views-view-fields--home-page-top-three-stories.html.twig

{{ fields.field_story_preview_image.content }}

{{ fields.title.content}}

{{ fields.field_subtitle.content }}

"fields.field_story_preview_image.content" is the image field that I would like to apply the CSS class to. Am I missing a configuration step?

Why isn't the CSS class being applied to this image field?


texts:
I'm trying to convert this:

<script type="text/javascript" data-main="/Scripts/submenu/main" src="/Scripts/require.js"></script>

into something like this:

$form['#attached']['js'] = array(
        libraries_get_path('lib').'/Scripts/require.js' => array(
            '#attributes' => array('data-main' => 'main'),
        ),
);

but I can't seem to find the way to add an attribute :(
Any Ideas?


texts: Getting group posts in og's home page view

texts:
I'm theming views-view--og.tpl.php, hoping to change the default group listing table into something a bit more attractive.

I'm looping through the $rows I have available, and for each of them I'm loading a $group_node object and creating a div with some specific content, such as the group's mission etc.
I'd also want to present the lastest 2-3 group posts for each of the groups i'm fetching in $rows, along with their autoring and date information.

If it makes it any clearer, here's what i'm doing:

<?php
<?php if ($rows): ?>
    <?php if (drupal_get_path_alias(implode('/',arg())) == 'og') { ?>

        <?php foreach($variables['view']->result as $node) { ?>
            <?php $group_node = node_load($node->nid); ?>

        <?php } ?>

    <?php } else { ?>

            <?php print $rows; ?>

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

  <?php print $empty; ?>

<?php endif; ?>
?>

How can I load all group posts related to a certain group node, and can this be done from the og home page (path /og), as I understand, it's considered outside of group context?

Help will be much appreciated,

Avner


texts:
I have a file field in a content type. The files uploaded by this field should be handled by a custom php script. I think the best way to get this done is to write a custom stream wrapper. However, I am not experienced about the stream wrappers and I don't know how to implement my file upload and downloads to work with this custom script.

If I go into detail, I need to POST the uploaded file to this php script like:

path/to/script/?action="upload"

It returns a File Id. Drupal will know only about this ID. If I want to download the file, the link should look like this:

path/to/script/?action="download"&file_id="FILE_ID"

Path to the script is at the moment in the same directory as Drupal, but may not necessarily stay always there. So that I need to take this into account as well.

It may be a very simple question but I couldn't get it done.

What I've done so far is:

Implemented hook_stream_wrappers()
Extended DrupalLocalStreamWrapper class.

The stream wrapper I created appears already as an option in the field settings, so that I can select it.

What I don't know is exactly which methods to implement in DrupalLocalStreamWrapper class. As the documentation states I must at least implement the getDirectoryPath() and getExternalUrl() methods.

Would someone direct me how to implement those methods to get it work like I described above? Is it enough to implement only those methods, or are there more methods that I should implement?


texts: Best Practice to make edit-able programmatically custom made content

texts:
SHORT VERSION
Is there a Best Practice to make edit-able a programmatically custom made content in the same way the My Account node can be editated?

LONG VERSION
When i create new content through the admin tool Add Content, this content is automatically editable(given the right permissions)

An even better example of that (what i would like to actually replicate) is the My Account node.
The fields of this node are editable through Drupal generated form fields.

what i would like to know if there exist an hook or module that could allow me to "present" my content to Drupal so to have it add the same functionality to my custom content.

EDIT 1

For learning purpose i have created a test entity i called generic_entity and i would like to have its "display page" , a node that display the entity properties in its content , to be editable in the same way the My Account is.

implementation of the hook_menu()

function test_entity_menu(){
//other menu links...
$items['test_entity/%test_entity'] = array(
    'title' => 'Display test_entity',
    'page callback' => 'test_entity_view_page',
    'page arguments' => array(1),
    'access arguments' => array('display test_entity'),
);
}

end here is the test_entity_view_page()

function test_entity_view_page($test_entity, $view_mode = 'full'){
    $test_entity->content = array();
    //to display fields attached to the entity through drupal
    field_attach_prepare_view('test_entity', array($test_entity->ap_id => $test_entity), $view_mode);
    entity_prepare_view('test_entity', array($test_entity->ap_id => $test_entity));
    $test_entity->content += field_attach_view('test_entity', $test_entity, $view_mode);
    // to display a generic properties present in generic_entity.install
    $test_entity->content['test_entity_generic_property'] = array(
        '#type' => 'item',
        '#title' => t('Generic property'),
        '#markup' => $test_entity->test_entity_generic_property,
    );
    return $test_entity->content
}

In between of the two there are obviously the test_entity_load() and test_entity_load_multiple() methods.

Is there a way to have drupal generate edit tabs for this content the same way it does with the rest of the content created trhough the Add content feature?


texts: How can I attach an existing server image to an image field rather than uploading a new image file?

texts:
Is there a module or some other way of attaching an image to an image field by selecting the image from existing files on the server rather than upload a new image?

I'm working on a project where many nodes have an image field. That image is displayed in various places at different sizes using image styles.

The users are migrating from another system and they're very used to the "image library" concept. They like to upload images that they will later use in various places around the site. The standard image field on a node only lets you upload from the local file system.

Ideally we'd like to have a "browse server" button instead of the upload button but end up with the same resulting image field.

The Media module comes tantalizingly close and I'm sure we'll use it for videos etc but it creates a media asset field, not an image field which I don't think can be resized with image styles and used so easily in views etc.

I tried the image picker module late last night. Maybe I need to try it again but I don't think I quite understood it. We don't really want resizing and create thumbnails etc on the node edit screen. We really just want a way to create an image field where the path points to an existing file somewhere below /sites/default/files. The files will be uploaded with something like IMCE.

Thanks for any ideas.


texts:
I create a search section with view and I want hide label of search inputs and set placeholder for them.

Is there any section to set this?

Drupal 8


texts: Add a default_value to name field in yml file for Drupal 8 migration

texts:
process:
   uid: EIN
   field_contractor_name: CONTACT
   name: CONTACT
    -
      plugin: default_value
      default_value: 'Full Name'

I am using the migrate source CSV module. I have a few records that DO NOT have the 'CONTACT' field set or is null. My drupal migration fails for this reason. I tried using the default_value plugin that ships with core but i keep getting the following error:

 A colon cannot be used in an unquoted mapping value at line 42 (near " default_value: full
name").

How do I get a default value added to the name field when a value is not present on the record?


texts: User permission to edit only nodes with taxonomy term

texts:
I want to let my customers only edit nodes that have a specific taxonomy term.

For example i have user TimCook from company Apple. He got the role "customer" and i want to give him the right to edit nodes only with the taxonomy term "apple" of the vocabulary "company".

I didn't find any module for this. Maybe there is one, or someone has a hint where i should start to make an own module.


texts:
I want to add functionality into my site that users may be able to sign agreement, pay, and then submit. Also I would like to use this data in the future...
Any advice??
EDIT: I want something like web form with payment option on it, I just want a user to be able to pay via Credit card, if the form is filled correctly and all required fields are good... Don't need HIGH-END commerce or online store ??? Please help :(


texts: How do I upgrade drush from 3 to the latest release?

texts: On my debian 6 server, I used apt-get to install drush.  However, it looks like it downloaded drush version 3.  I want to upgrade to the latest stable release of drush (which I believe is drush 5).  How can I do this?


texts: What is the reason behind the current menu structuring

texts:
I'm not much of a Drupal Ninja; from what I saw at http://drupal.org/node/788972,
Drupal seems to have a menu structure like Joomla, in the sense that it allows menu items to be created under menu categories.
Why are we using this unlike a central menu items section, from which we can link an item to multiple menus, if needed?

This is what I can see in Wordpress. In the latter method, I can see reduced redundancy and a single point to change multiple occurrences of the same link.

I would like to understand the logic/reasoning behind the Drupal menu structuring, not understanding how Drupal compares to Joomla or WordPress.


texts: Get Order Object on Checkout Complete Page

texts:
I'm trying to develop a new module but just can't get the correct solution, I hope you can help me.

On the checkout complete page i need the order object with all information of the just created order to print out an javascript code which will be created with the order data and execute when the user completes the checkout process. With the hook "myModule_footer" I am getting into the footer to print my code and with "arg(2)" I can check if the URL is "complete". But now I need to get the order object but I just can't find the right way to do it.

I also tried other hooks like "myModule_checkout_complete" but they won't work:

function myModule_checkout_complete($order, $account) {
drupal_set_message('It works');
}

Is there an better solution to hook into the checkout complete page, get the order object and return some code to the frontend?

Thanks


texts: Creating a column in mysql to store uuid

texts:
In Microsoft SQL we have UNIQUEIDENTIFIER type while creating table and when inserted it fills auto-generated string into that row. Is there any equivalent type in Drupal 8 or should I use some function in php to generate the string and while saving the row send the string as parameter(something like this $uuid = UUID::v4();). Currently I am creating the schema for that column as below. Is there a better way to implement this.

 'reference_unique_identifier' => array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ),

Note: I am writing custom code to develop. I think I am not using entities. The above mentioned code is in a .install file which returns the schema.


texts: How can only content be translated, not admin pages

texts:
The last developer on our site installed the entire Spanish translation from Drupal and now even the admin pages come out in Spanish.

We don't want this, we just want the content to be translated as well as some error messages, but none of the administration pages should be in Spanish.

How would I fix this?


texts: Creating individual fields from a multi-column Field API widget

texts:
This references the Addressfield and Views modules.

I would like to have extended Views support for the Addressfield module like the Location module does. Some of the extra fields that the Location module makes available are Country, Longitude, and Latitude by themselves and Proximity or Distance filters and sorts.

I've added longitude and latitude columns to the Addressfield module.

The database for the Location module is fairly straight forward in Drupal 7 but not built using the D7 Field API.

The Addressfield module is built using the Field API and with Views it has a Content: field available and also arguments, sorts and filters based on each of the columns in the Addressfield database table. Views only offers a choice of formatters on a single field.

This is fine because it's just as easy to add a formatter to a Fields API module as it is to theme a view . So I can make a formatter that only shows latitude or longitude. Perhaps, better yet, I can make a formatter that displays the latitude and longitude as a WKT point to be used for an OpenLayers map.

However, what I need is a proximity filter so I'm setting out how to extend the Field API's functionality in Views which isn't very straight forward.

Is there documentation available for the particular case or modules that extend the Fields API which can be used as examples?

I thought the logical thing to do was use hook_field_views_data_alter(). Here is the attempted code and I'm not sure why it doesn't work.

function addressfield_field_views_data_alter (&$result, $field) {
  if (array_key_exists('field_data_field_address', $result)) {
    if ($result['field_data_field_address']) {

      $columns = array();
      $columns = array(
        'field_address_administrative_area',
        'field_address_country',
        'field_address_lat',
        'field_address_lng',
        'field_address_locality',
        'field_address_postal_code',
        'field_address_premise',
        'field_address_thoroughfare',
      );

      $add_fields = array('entity_type', 'delta', 'language', 'bundle');
      foreach ($result['field_data_field_address'] as $column => $data) {
        if (in_array($column, $columns)){
          $result['field_data_field_address'][$column]['field'] = array(
            'field' => $column,
            'table' => 'field_data_field_address',
            'handler' => 'views_handler_field_field',
            'click sortable' => TRUE,
            'field_name' => $column,
            'additional fields' => $add_fields,

            'entity_tables' => array(
              'node' => 'node',
              'node_revision' => 'node',
            ),
            'element type' => 'div',
            'is revision' => FALSE,
            'entity id' => 'nid',
            'base table' => 'node',
          );

          $result['field_data_field_address'][$column]['group'] = 'Content';
        }
      }
    }
  }
}


texts: Is there a way to determine what is powering the content behind a URL?

texts:
I have a relative URL in a large site that I inherited: /my-url.

For the life of me I can't find the View, Module, or other content that shows how to edit this URL. I've grepped the code base, and searched the database, but can't find it.

How can I tell how this URL gets edited? Is there some kind of search modules/views/blocks by URL?


texts: DrupalGap index.html No connection found on ios simulator

texts:
The app is working on web-app, but when I test iPhone" simulator, then have problems with connection:

index.html - No connection found

Failed connection
http://app.newwweb.info
Check your device's network settings and try again.

I reviewed the changes in settings.js and index.html and are correct.

What can I do?


texts:
I'm learning to develop for Drupal 7 and figured I'd start with something simple, like a custom formatter.  I have a content type that contains several boolean fields indicating if the content type belongs to certain class of objects. When I create a view of the content types, all the boolean fields show a 1 or a 0, when I would like it to display an image instead.  I created the following CheckBoxFormatter.module file

    <?PHP
        /**
         * @file
         * Creates a custom format for boolean fields, a checked checkbox for true
         * and unchecked for false
         */

        /**
         * Implements hook_field_formtatter_info()
         */
        function CheckBoxFormatter_field_formatter_info() {
            return array(
                'CheckBoxFormatter' => array(
                    'label' => t('Checkboxes'),
                    'field types' => array('boolean')
                ),
            );
        }

        /**
         * Implements hook_field_formatter_view()
         */
        function CheckBoxFormatter_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
            $elements = array();
            foreach($items as $delta => $item) {

                //Build variables array for formatter
                $element = array(
                    '#obj_type' => $obj_type,
                    '#object' => $object,
                    '#field' => $field,
                    '#instance' => $instance,
                    '#langcode' => $langcode,
                    '#items' => $items,
                    '#display' => $display
                );

                if (function_exists($function = "{$display['module']}_field_formatter_{$display['type']}")) {
                    $elements[$delta] = array(
                        '#markup' => $function($element)
                    );
                }
            }
            return $elements;
        }

        /**
         *  creates the actual checkboxes
         */
         function CheckBoxFormatter_field_formatter_CheckBoxFormatter($variables) {
             $img = array("<URL TO UNCECKED>","<URL TO CHECKED>");
             $disp = array("Unchecked","Checked");

             $element = array();
             foreach($variables['#items'] as $delta => $item) {
                 $element[$delta] = array(
                     '#markup' => '<img src="' . $img[$item['value']] . '" alt="' . $disp[$item['value']] . '" />'
                 );
             }

             return $element;
         }

I uploaded this to all/sites/modules/CheckBoxFormatter.  I was able to activate the module in the modules section of my drupal site.   Now, when I go back to the view I created, this new formatter doesn't show up.  I also do not see it as an option under Manage Display for the content type.  What am I doing wrong?


texts: Is it possible to have a custom filter for exposed criteria?

texts:
When I've created a view where the filter criteria is:

"Content: Has taxonomy terms (with depth) (exposed)"

It works well, but I'd like to filter the terms. I have some "main term" and a lot of "sub-terms" for each "main term". What I'd like for this view, is to search only through "main term", i.e. propose in the list only "main term", not "sub-terms".

How can I achieve this?

If that may help: the parents of main "main term"s == 0 (in other words, "main term"s have no parents)


texts:
How do I create a second version a node add page?

For example if have node/add and I want node/add-quick?

Some fields of the required fields form node/add  would be missing or not required on node/add-quick.

I know node add fields can be hidden based on user role or other variables but how do I create an entirely new page with a select set of fields.


texts: How to make "show settings" of a reference entity view affect the real field selection

texts:
In Drupal 8, I can manage to create an "Entity Reference" view. In the preview area, it shows multiple fields separated by a string separate, just as I configured. For example:

However, in the real form, a selector does not show the expected fields as by configuration, but rather shows only content title:

I tried clearing cache, but it did not help.
What setting in the view editor should I use to let the live entity selector show fields the same as in the preview?


texts: How to change this "Anonymous's Blog" link to another name?

texts: I am trying out the Education distribution. However, I cannot find where/how to change the "ANONYMOUS'S BLOG" link (shown in red box below) to another name, for example: "BLOGS". Where is the link's name stored?


texts: How to inform future developers about hack in the core?

texts:
Let's say I had to patch a core of some module, for some reason that doesn't matter here. Is there any custom, or convention of informing future developers about it? So they will be aware of it and this may stop them from updating this module without thinking? Like creating a text file in root directory named "core-hacks" or "important-info-for-maintainers"? I have many ideas but is there any common one? Or if there is not, what would you consider the best? (the last one is open question, so you can discuss in comments).

Added:
I'm considering just creating a directory in root when I will describe what I did and put applied patch, but I'm not sure if this is best what I can do, or if someone may overlook it.


texts: Prefill content type form field with alter hook

texts:
I've created a content type with a link type field.
When an user add this content type I want to prefill the link field with the user email.
I've a create a new module named prefilllink with an alter hook :

function prefilllink_alter(&$form, &$form_state, $form_id) {
  dsm($form);
  switch($form_id) {
    case "job_node_form":
      $form["field_apply"]["und"][0]["value"]["#default_value"] = $user->mail;
      break;
  }
}

But it doesn't work... Any idea?


texts:
I am using Profile 2.

When the user clicks the 'Edit My Profile' tab, I would like its destination to be:

/user/175/edit/about-you

Where about-you is a Profile2 type.

How do I change the path of the tabs?
I am also using TabTamer, but this module does not let you change the path, only the label and enable/disable the link.

EDIT
I have tried the below code in template.php with no results.(after changing the theme name)

function THEMENAME_menu_alter(&$items) {
  $items['user/%/edit'] = $items['user/%/edit/about-you'];
  unset($items['user/%/edit']);
}


texts: Is it still possible to use a custom attribute for a form (e.g. $form['#foo'])?

texts:
In the documentation for #value, the Drupal 7 documentation contains the following note:

  Note that as of Drupal 6, you can also simply store arbitrary variables in $form['#foo'] instead, as long as '#foo' does not conflict with any other internal property of the Form API.

Is that still possible, in Drupal 8?

I looked at the documentation for the Value class, but the note given for Drupal 7 is not present.

I know Drupal adds $form['#token'] to forms, but I take it is a special case Drupal handles in a particular way.


texts: Profile2_path form_alter - Anonymous user form - access denied problem

texts:
I have created a custom profile type and given it a unique registration path using profile2 registration path. I am attempting to form alter the custom fields but I cant seem to find a way to view the from as admin in order to view the form array.

Whenever I go to the custom path of offers/register as admin I get an 'access denied'. How can I view this form that is for anonymous users whilst logged in as admin so that I can kpr($form);?

Thanks in advanced.


texts: How do I update a node's file field from within a module?

texts:
I have a file: /tmp/new.zip and I have a node, $node, that has a file field, field_ios_file. Currently, old.zip is the file saved in to the field_ios_file field. I'd like to put /tmp/new.zip there.

What I have now:

$file = file_uri_to_object('/tmp/new.zip');
print_r($node->field_ios_file);
$node->field_ios_file['und'][0] = $file ;
print_r($node->field_ios_file);
node_save($node);

the node_save() fails here because $node->field_ios_file['und'][0] should be an array, not an object. I would imagine there is a function that looks something like field_update($node, $my_field, $data), but I can't find anything like that.


texts: Create multiple pages/sub site from one node type

texts:
I am fairly new to drupal and finishing up my first large site. I am using the panopoly profile.

For this site I need to create this massive content type. It would be used to generate about 5 pages from the nodes content and they each need their own template/layout. Essentially its a child site.

How can I create multiple pages from a single node type?


texts:
I have created drupal website for ecommerce store.

Issue:
After node save i will redirect to thankyou (destination) page for tracking but it takes long time to complete.
Customer may skip if it takes long time to complete the process.

How do i run node save in background process and display thankyou page immediately after placed order.

I want to track order conversions and node save.

Please help me to resolve this issue.

Thanks,
Yadavan


texts: Creating a view block inside a fieldset using templates

texts:
I am trying to create a new .tpl.php for some of my views.
I know how to create the file and display the elements the way I want, but only by changing the default views-view.tpl.php which would change the way all my views are displayed.

Supposedly I should be creating a new file by looking at Theme: Information and giving it one of the names available that would be something like: views-view--VIEW-NAME.tpl.php, but when I do this and leave the file in the theme folder in the views module and press "Rescan template files" it doesn't detect it.

Should I put the file in a different location?

FYI: What I am trying to do is place my views content inside a fieldset, something like this:

<fieldset class="fieldset collapsible form-wrapper"
 <legend>

       <?php print $header;?>

 </legend>

    <?php if ($rows): ?>

          <?php print $rows; ?>

    <?php elseif ($empty): ?>

            <?php print $empty; ?>

    <?php endif; ?>

    <?php if ($pager): ?>
        <?php print $pager; ?>
    <?php endif; ?>

As I said this is working, I am just trying to put it in a different .tpl.php file and apply it only to certain views. Also if there is an easy way of making the fieldset collapsible that would be useful, although not essential.


texts: Printing field item attributes with Twig / Drupal 8

texts:
In Drupal 7, I can do this in a custom field template to print the alt tag of an image:

<?php print $item['#item']['alt']; ?>

And though "item" seems to be a variable in Twig / drupal 8 fields, I can't seem to do the same thing. I've tried these:

{{ item.alt }}
{{ item.item.alt }}

These don't work but I don't get any errors either. Looking at the API does not give me much insight. I saw this gist but again, no alt tag rendered separately. My image is rendering the alt tag as i can see it in the code though.


texts:
I'm trying to get File Permissions working in Drupal 8.9 with Drush 9. The old code calls _drush_file_private_path(), which doesn't exist anymore, and _drush_file_public_path() is probably a no-go as well.
What is the proper way to do the following in Drush 9?
define('DS', DIRECTORY_SEPARATOR);

// Define default paths and variables.
$default = 'sites' . DS . 'default';
$private = $default . DS . 'private';
$files = $default . DS . 'files';
$directories = array();

// Check for Private Files subdirectory.
$private_directory = _drush_file_private_path();
if (empty($private_directory)) {
  $private_directory = $private;
}
$directories[] = $private_directory;

// Check for Public Files subdirectory.
$public_directory = _drush_file_public_path();
if (empty($public_directory)) {
  $public_directory = $files;
}
$directories[] = $public_directory;

As an additional note, it would be amazing if a resource existed to see all deprecated/removed functions and their equivalent replacements. I can't even get decent results when using a search engine and the function name.


texts: How to prevent recursion when setting a data value for a user in rules?

texts:
I have a rule that is triggered on the event After updating an existing user account.  The rule performs an action, Set a data value, that changes one of the values of the user account fields.

However, doing this causes the user account to be saved again, which triggers After updating an existing user account a second time.  This causes some of my other rules that are triggered after updating a user account (such as those for sending notification e-mails) to be triggered twice.

I know this Set a data value rule is the issue because when I disable it, the account is only sent once, and the other rules that send notifications only send a single notification.

Is there a way to avoid this (single) recursion when setting a data value with a rule?


texts: Why doesn't adding results in hook_views_pre_render work?

texts:
In the docs for hook_view_pre_render http://api.drupal.org/api/views/views.api.php/function/hook_views_pre_render/7 it states "Altering the content can be achieved by editing the items of $view->result."

Removing elements from this array is reflected in the final output, but appending to it, rewriting parts of it, or reordering it results in no change to the final output.

Does anyone know what's going on? How do I use this hook to alter or add to the results of the view post-query but before rendering?


texts: How to prevent result from being displayed when user selects search/apply

texts:
I created a "view" on my site with 3 exposed filters (One for "name", the other for "occupation" and the last for "location") to allow users search/filter for other users on my site.

On page load, no results are displayed. However, if I simply select search/apply (without inputting any search string), it displays results.

Please, how can i resolve this?

Thanks.


texts:
I've installed gmap module and configured it so that I'm using custom markers. It worked well till today (I've re-deploy website).

I'm able to choose my custom marker 'Accountant' in a settings (see screen below).

However when I load map I get an error message: "Request for invalid marker set"

I've googled it and did not find a clear explanation what is wrong.

Please advise what could be an issue.


texts: How to output just the Name and Status in drush listing modules

texts:
Running drush pm-list gives the modules and theme list through some fields. By default, it gives me the Package, Name, Status and Version.
I am trying to make a shell script that outputs only module and status to be consumed by other scrips, and things will be much easier if the drush pm-list shows only Name and Status.

Is there a way to prints only the information about the Name and Status from the drush pm-list and omits the Package and Version information?


texts: How can I include a simple php in a Drupal 8 twig file?

texts:
I'm making a custom theme, and I just want to include this in my twig file.

<?php echo date("l H:i"); ?>

Do I need make a twig extension? How can I do it?


texts: Make a news item "sticky at the top of lists"

texts:
I want to sort my news items by sticky to the top and then date so I can highlight certain news items. The same question was asked here, the answer was to:

  "Just sort by sticky and after that sort by date."

I did this and it showed correctly in my preview on the news edit page. However when I went to my live news page it did not register the "sticky to the top" setting and still only sorted by date created. Why is my news edit page not making those changes on the live page?

here's a screenshot, maybe I have a setting wrong:


texts: The PHP version is not correctly detected

texts:
I'm running Drush on a host that has multiple versions of PHP installed. By default, php --version would give you 5.2.x, but php53 and php54 are also available. So in my .bash_profile I have alias php='php53' (php --version = 5.3.13), which makes Drush work for some commands.

However, I still get "Your command line PHP installation is too old. Drush requires at least PHP 5.3.2" messages for some very useful commands.

A couple of really annoying instances:

drush pm-update will report that it has backed up and then updated all modules and core successfully, then return the PHP version error and restore all backups. In verbose mode, the command that comes before the error is:
php /home/[username]/drush/drush.php  --backend=2 --verbose --root=/home/[username]/webapps/drup --uri=http://[domain name]  pm-updatecode-postupdate 2>&1
drush archive-dump will immediately return the PHP version error

The other commands I have tried so far work fine. I'm not sure why this would be, if Drush is sometimes using the php53 binary, and other times not, or if it just has trouble detecting the version correctly, but some very important features are broken for me.


texts: How do I hook the stock status message to the product page?

texts:
I have a Commerce Demo site that uses the off canvas flyout cart and I am using the Commerce Simple Stock module to stop items being sold if they are out of stock.
The module changes the stock number and prevents the item being loaded to the cart if already purchased. It sends user/status messages and removes the add to cart button using commerce_simple_stock_form_commerce_order_item_add_to_cart_form_alter().
This hook doesn't work for the Commerce Demo form.
The theme hook for the Add to cart button in Commerce Demo is commerce_cart_flyout_add_to_cart_button().
The stock status messages show on the admin pages but not on the product page itself.
How do I hook the stock status message from the module to the product page?


texts: Any one can explain shortly ? How to add [google ads] in between the views slideshow after completing four slides .presently am having gallerific slideshow and slides are from specific content type. Thanks by advance.


texts: Display distance Coordinate vs Zip Code?

texts:
I am trying display Coordinate vs Zip distance. User inputs zip they get a list of things close. Trying to work with Openlayers and expand on this post.
Need a simple Google Maps solution; lost in the labyrinth of modules


texts: How do I add a custom sorting variable to a view?

texts:
I have a view that displays a list of items. Each item has a date field called "Featured Until". This can be set to a future date. If the data is in the future, I want this item to be seen as "featured" and appear at the top of the view.

I can't just sort by "featured until date", because that would still be an issue when the featured date is passed.

Is there any easy way to do this on a view?
Should I perhaps consider just adding a new boolean field called "Featured" and then use cron to update this value when the featured date is passed?

(I don't prefer the second option because I would need to add a cron task for  updating.)


texts: Webform does not submit, instead redirects to self

texts:
My soon-to-be production Drupal site's Webforms have stopped saving submissions; instead it comes back to the same page, complete with the inputted values. I do not have a timeline when it stopped working. In a sandbox environment, Webform 7.x-3.17 works fine.

I'm looking for some suggestions to further debug.

I've tried the following, but to no success:

Disabling any modules that refer to Webform (notably Webform Template and Webform Validation, and my own custom module that had been using hook_form_alter).
Upgrading to the latest Webform (yes I remembered to use update.php).
Based on documentation, combining hook_form_alter($form, &$form_state) with array_unshift($form['#submit'],'my_custom_submit') to insert a custom callback, where I called drupal_build_form($form['form_id']['#value'],$form_state) to emulate a submission.
Obviously flushing caches consistently.
Ensuring that the Webform is published.
Writing a bare-bones module to simply monitor $form_state['executed'] (it always returns false).
Checking my server's error_log both on SSH and FTP.
Checking Reports > Recent log messages.
New: Tried disabling & uninstalling Webform, deleting old Webform files, and installing a fresh new version of Webform; no good.

I'm pretty sure the issue is not isolated to Webform, so it wouldn't make sense to post to their issue queue.

What other debugging methods can I pull out to help crush this bug? If I disable every module without uninstalling, is an entire FTP backup necessary or just SQL?

EDIT: Some more things I've tried as per suggestions (unsuccessfully)

Explicitly defining $cookie_domain and $base_url in settings.php
Looking through Trigger and Action modules for any potential misfiring redirects


texts:
In my project I want to provide path of some files from root directory. Path has repeated 4 to 5 time in one module so I am thinking that put one global variable and access that variable in same module?

I have try (dirname(__FILE__).'\sound\new'); realpath; drupal_realpath ; pathinfo; .


texts: Views List tag filtering, add a tag to a view for filtering purposes

texts:
On the Views list admin/structure/views, I can filter my list of views by the tags on the View.

I can search for the tags, but how do I add my own tags to the views so that I can easily filter them?


texts: Why can 'Others' read settings.php by default?

texts: By default, settings.php has its permissions set to 404, which means 'Others' can read the file. Why not set it to 400, so that only the user can read the file? Thanks.


texts: how to Display author and date information according to my requirement?

texts:
I am created a content type with field Title, Project code, Advertise and Body.

I want to display Author name and date information after Project code but by default it showing after title field so please let me know how to display according to my requirement.


texts:
I am trying to to show how many times a user edited a node, as follows, so I have enabled revisions support for my content type.

user1 (300)
user2 (288)
user3 (200)

The problem is that when someone creates a new node, it gets saved as revision in the node_revision table, but I don't want to count that as edit.

How can I achieve this?

This is the code I am using, so far.

$query = "SELECT users.name AS users_name, users.uid AS uid_1, COUNT(users.uid) AS uid, COUNT(users.uid) AS users_uid FROM users users
  INNER JOIN node_revision node_revision_users ON users.uid = node_revision_users.uid
  INNER JOIN users_roles users_roles ON users.uid = users_roles.uid
  WHERE (users.status <> '0') AND (users_roles.rid = '4') AND node_revision_users.nid IN ($sub_query)
  GROUP BY users_name, uid_1
  ORDER BY users_uid DESC ";

$result = db_select('node_revision', 'n')
  ->fields("n", array("nid"))
  ->groupBy('nid')
  ->having('count(nid) > 1')
  ->execute()
  ->fetchAllKeyed(0, 0);

$sub_query = implode(",", $result); // this will show give nids which are edited ie having count more than one in node_revision

$results = db_query($query);
foreach ($results as $res) {
  var_dump($res);
}


texts: How to print number of blocks in a region in Drupal 6

texts: I use Drupal 6 and I'm trying to get number of blocks in a region. How is that possible?


texts: How to disable a block on a certain view?

texts:
I want to disable two blocks for a certain view. I have tried
"Show block on specific pages >> All pages except those listed" using the machine name and the view URL with no luck; I tried Drupal Context still no luck. May you please assist?

I have looked at Exclude a block from specific parts of the website with the Context module, but the answers there didn't help.

These are the details for the view I am using.

View name: All albums Front
View machine name: all_albums
View path: /all-albums
Website view URL: http://www.example.com/all-albums
View display name: All Albums


texts:
I tried to add IP address to for example : 172.20.0.3
I get this error : The provided host name is not valid for this server.

Here my settings

$settings['trusted_host_patterns'] = array(
  '^172\.20.\0.\3$',
  '^localhost$',
);


texts: Radio button & Option list values migrate successfully with Feeds Importer but disappear in node edit

texts:
I'm doing a couple data migration projects. I'm using Feeds Importer and for the most part, things are going well.

But when I migrate option list fields, I get this weird thing where the data is migrated OK (I see it when I view the node and I see it in the appropriate table in the database), but when I edit the node, the option list field is empty/not-selected.

On one of the projects, I was using the radio button widget and the work-around ended up being changing the field's widget from that to Select list.

But on my second project, I was already using the Select List widget, and I can't seem to work around the problem. Tried changing it to radio buttons (hey - I'm not picky), but it didn't help.

It's a really sinister problem because it means I migrate the client's data OK, but when they edit one of these nodes, they will essentially delete data because the radio button or select list widget is not displaying the data. Help?


texts: What causes the 'DB Error: unknown error' after adding custom fields to a report in CiviCRM?

texts:
I have one particular set of custom fields made up of plain text fields and rich text fields. But if I try to add any of them to a report for display, the following error is returned:

  DB Error: unknown error

I don't have this problem with other similar custom field sets, just this one. Is this something anyone has experience before? What's the cause of it?


texts: As it stands now I have MediaMover move images uploaded from Image FUpload CCK to S3 while deleting the source images. However, all I see are lists of the image files that I've uploaded. How can I display a thumbnail instead? I believe that I need to use Views, but I'm a Views noob.


texts: Can't access %node context keywords in Panels & Panelizer

texts:
Context keyword sunstitutions for the node being displayed are showing up blank!

Latest drupal installation with Dev versions of Panels, Panelizer, ctools, etc...

I have a node type that has 2 entityreferences to 2 other node types.  One of the fields in the main nodetype is "field-location-detail", which is -not- present in any other nodes.  I set up Panelizer to handle the Full Content Display & also set up relationships to the other entities.  When I try to use the context keyword "" in a Custom Content Panel, nothing shows up.

First indication of the problem is that on the Context screen, the same keyword/field shows up multiple times:

Summary of contexts
Built in context    This node
  ...
  %node:field_location_detail --> Where in this location?
  %node:field-location-detail --> Where in this location?
From "This node"    Node from Node (on Node: Select a Location [field_event_location])
  ...
  %node:field_location_detail --> Where in this location?
  %node:field-location-detail --> Where in this location?

Then, when I captured the data going through function ctools_context_keyword_substitute($string, $keywords, $contexts, $converter_options = array()), the problem becomes clear.  The 3 objects passed in the $contexts argument have keywords of "none", "node", & "node_2".  So the local context variables are always overwritten.

I guess that the root problem is that the keyword being assigned isn't incremented initially, so it starts from "node" in stead of "node_1".

Anyone knows where that should happen?


texts: How to insert social share buttons in drupal 7 using Bootstrap Social Sharing Buttons?

texts:
I am using module Bootstrap Social Sharing Buttons in my D7 site.

I can show e-mail, twitter, facebook and google+ but I don´t know how to insert others social buttons like linkedIn.


texts: Manage displays of Product:image field directly in Product Display?

texts:
I have a "Product Display" node showing a "Product" (powered by the Drupal Commerce module).

I have installed the Display Suite module, and created a new view mode for the "Product Display" content type.

The problem is that this new mode is associated with the default view mode of "Product," and I see no way to change this.

What I need is to create a new mode for "Product" and get the view mode of "Product Display" associated with this new one.

Is there anyway to do it?


texts: An AJAX autocomplete textfield in Drupal 7 doesn't work in Chrome

texts:
An AJAX autocomplete textfield in Drupal 7 works in Firefox, but doesn't work in IE and Chrome. The following error appears:

An AJAX HTTP error occured. HTTP Result Code: 200 Debugging information follows.
Path: http://localhost/drupal/en/example/autocomplete
StatusText: OK
ResponseText: {"admin":"admin","alex":"alex","apple":"apple"}

function clubform_menu() {
  $items['example/autocomplete'] = array(
    'page callback' => '_module_name_autocomplete',
    'access arguments' => array('access example autocomplete'),
    'type' => MENU_CALLBACK
  );
  return $items;
}

function _module_name_autocomplete($string) {
$matches = array();
$return = db_query("SELECT name FROM users where lower(name) like '".$string."%' LIMIT 10");
  // add matches to $matches
  foreach ($return as $row) {
    $matches[$row->name] = check_plain($row->name);
  }
  // return for JS
  drupal_json_output($matches);
}

...
        $form['editclub']['club_name'] = array(
          '#title' => t(''),
          '#type' => 'textfield',
          '#description' => t(''),
          '#autocomplete_path' => 'example/autocomplete',
          '#weight' =>15,
          '#size' => 30,
         );
...

The output in Firefox is the following:


texts: How to render a block provided by a contrib module in a node template

texts:
I installed Better Social Sharing Buttons and I can not understand how to programmatically display the block of this module in node.html.twig. I display the blocks created by me like this:

function MYTHEME_preprocess_node(&$variables) {
  $block_entity = Drupal\block_content\Entity\BlockContent::load(6);
  $block_view = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity, 'foo bar');
  $variables['MyCustomBlock'] = $block_view;
}

and then {{ MyCustomBlock }} in node.html.twig.

How to display the block created by the Better Social Sharing Buttons module?


texts: Grant/refuse access permission on the fly

texts:
Is there some kind of hook or callback that will allow me to do some fancy checks before granting or refusing permission?

I have an Application content type which references another content type that contains a list of users that are allowed to view it. I need to load up the list of users and check to see if the current user is in the list.


texts: Different permissions after node publishing

texts:
I have a role (Creators) where users can create/edit/delete nodes of some content types but they can't publish it, publication is done by other role (Publishers), I'm using Workbench and Workbench Moderation modules.

Now I need to disable Creators role to edit/delete content (even their own) after someone from Publishers role published node, so if user from Creators role create node and user from Publishers role publish that node, than node creator from Creators node can't edit or delete it.

How can I achieve something like this?


texts: Remove the "upload" button from the image field form element in drupal 7

texts:
As the title suggests I need to remove the upload button from an imagefield form element within D7.

I can't seem to find the element itself within the form array (via hook_form_alter) and I'm just wondering if it needs to be done a different way perhaps.

(I do realise the button can be hidden with CSS but I'd rather not take that option if I can help it.)


texts: Render a field contained inside of another field

texts:
I am using Drupal Paragraphs module that lets you create "bundles" of fields inside other fields. (It does this using entities). Each bundle has it's own tpl.php file.

In addition, you can nest "sub-bundles" inside the "main-bundles" for complex layouts.

I have created a "main-bundle" called field_panels_content.

Inside this is another "subbundle" which holds a field_body_text. The "main-bundle" can hold an unlimited number of "sub-bundles".

In my theme, I need to access the all field_body_text fields from the multiple  "subbundle" from the tpl.php file that is for the "main-bundle".

I have used devel_themer and found I can get to the field_body_text fields like this:

<?php print render($content['field_panels_content'][0]['entity']['paragraphs_item'][9]['field_body_text']); ?>
<?php print render($content['field_panels_content'][2]['entity']['paragraphs_item'][10]['field_body_text']); ?>
<?php print render($content['field_panels_content'][2]['entity']['paragraphs_item'][12]['field_body_text']); ?>

As you can see this does not make for efficient theming as I would need to know the second array value in order to print it out (e.g. [9][10][12]).

Is there away I can use a loop or some other PHP function to get to the second array value automatically without knowing it?

This second array value changes with each new piece of content (e.g. If I add a new subbundle it will have a value of [13]. The reason the numbers jump from [10] to [12] is because I deleted the subbundle that was [11].

Update

Here are some more steps I have tried (from this page):

Here is an example loop:

<?php
foreach ( $content['field_panels_content'] as $wrapper) {
  foreach ( $wrapper['entity']['paragraphs_item'] as $item ) {
    if ( !empty($item['field_body_text']) ) {
      print render($item['field_body_text']);
    }
  }
}
?>

It produces the following results:
    Cannot use object of type ParagraphsItemEntity as array in foreach ( $wrapper['entity']['paragraphs_item'] as $item ) {

Here is a reworked version:

<?php
foreach ( $content['field_panels_content'] as $wrapper) {
  foreach ( $wrapper['entity'].paragraphs_item as $item ) {
    if ( !empty($item.field_body_text) ) {
      print render($item.field_body_text);
    }
  }
}
?>

Error message: Fatal error: Cannot use object of type ParagraphsItemEntity as array in line "foreach ( $wrapper['entity'].paragraphs_item as $item ) {"

Editing the code so only field_body_text is in square brackets (e.g. $item['field_body_text']), produces this error message:
Fatal error: Cannot use object of type ParagraphsItemEntity as array

Editing the code so only paragraphs_item is in square brackets (e.g. $wrapper['entity']['paragraphs_item']), produces this error message:
Fatal error: Only variables can be passed by reference in line  print render($item.field_body_text);

If I use print instead of render, I get this error message:
Fatal error: Cannot use object of type ParagraphsItemEntity as array

Other Notes

The following code works perfectly:

<?php print render($content['field_panels_content'][0]['entity']['paragraphs_item'][9]['field_body_text']); ?>
<?php print render($content['field_panels_content'][1]['entity']['paragraphs_item'][10]['field_body_text']); ?>

So surely it should be a simple case to refactor the code into a loop to get the desired result.

Please note

I don't want to use other modules.

I will be printing out all the field_body_text separately at the top of the tpl file.
I'll then display the whole paragraph (with the field_body_text still in it) in the normal way.


texts: How to disable Google fonts and other things like that?

texts: How do I configure my theme or Drupal itself from fetching data such as Google fonts or anything like that? Also some JS files that get transferred as well.


texts: Drupal 6 - How to programatically create a content type

texts:
I am creating a module to display a dashboard that shows various stats. One section will be for adding announcements. My thought is that the best way to do this would be to create a custom content type and then pull in the latest announcements from the announcement content type submissions.

My question is how can I create that content type programatically with the proper fields? Where can I go to add those announcements once the type is created? And how can I pull the latest announcements to display on the page?

I'm new to Drupal, so I'm struggling at the moment to learn the proper way to do things.


texts: How to use file_save to store pictures into a folder on server?

texts:
what i want to perform (globally) is to import a csv file that contains data such as book_title, author, and the cover image of the books. The csv file is loaded, book_title and author are stored in their respective tables but for pictures, what i want is to put them manually (ftp for example) on a folder (doesn't matter if it's my default public folder or a new one) and store data in tables like : file_managed and field_data_field_cover_picture etc
In my csv file, and for pictures column i just write filenames of every picture.

At the moment, i'm confused and this is my actual code :

$filename_cover = $get_filename.'.jpg'; <===from csv

        $add_cover_file = db_insert('file_managed')
        // ->key(array('fid' => rand()))
        ->fields(array(
            'uid' => $user->uid,
            'filename' => $filename_cover ,
            'uri' => 'public://couvertures/'.$filename_couv,<==my file
            'filemime' => 'application/octet-stream',
            'status' => 1,
            'timestamp' => time()
        ))
        ->execute();

Now adding on the pictures covers table : (how to put the fid ?)

  $add_couverture = db_merge('field_data_field_photo_de_couverture')
        ->key(array('entity_id' => $newNode->nid, 'field_photo_de_couverture_fid'=>$add_couv_file->fid ))
        ->fields(array(
            'field_photo_de_couverture_fid'=>$get_fid ,
            'entity_id' => $newNode->nid,
            'delta' => 0,
            'bundle' => 'livre',
            'entity_type' => 'node'
        ))
        ->execute();


texts: How to prevent Profile2 fields from loading on user registration?

texts:
I have a profile2 Profile that's named Driver.
This profile has a Term reference to a vocabulary named Cities that contains over 30.000 terms.

I made a custom user-register.tpl.php by declaring it in my template.php, and in here I display only the form keys that interests me for the account creation.
When I go to driver/register which is the custom page for registering to my profile type, the loading is taking too much time, and I suspect it to be caused by the loading of all the fields of my profile (even those non-rendered) and more especially that vast vocabulary.

I looked into profile2 folders and files trying to comment parts related to the registration but nothing would prevent the loading from happening.
I also tried to unset($form[profile_driver]) in my theme_form_user_register_alter, but it doesn't affect the fact that the profile fields are still loaded before being removed from $form, so I figured it has to be directly in profile2.

Been struggling for quite some days now so if anyone has clues on how to prevent the loading of the whole profile form or ideally specific fields I would be glad to read how to do the trick !
Thanks

7.x-1.4

FINAL EDIT :

I didn't manage to do it programmatically so I ended up setting up a Rule that assigns the Profile & the role to the newly saved user.


texts: How to implement a multi-node edit workflow?

texts:
I'm not sure if this exists. I'm looking for a multi-node edit workflow. I want to select multiple nodes then for each node selected show an edit form. This would be something like showing the first node edit form, then on save, show the next edit form, etc.

I came across the Multi Node Edit module, but it looks to be dead.

There's also this answer but it's not exactly what I want. VBO seems to work only for multiple edits on the same field, not one after another node edit forms.


texts: Can not update drupal/core with composer

texts:
Can not update drupal/core to 8.6.11

composer prohibits drupal/core:8.6.11

shows

webflo/drupal-core-require-dev  8.6.10  requires  drupal/core (8.6.10)

How can I solve it ??


texts: How do I repack an existing site into Open Source repo with bundled content and configuration?

texts:
I have been tasked to repack an existing live Drupal 7 site, that will go out of commission, to make it available as Open Source on Github so anyone interested may find some use of it.

This will require that the repository comes with a database dump containing an example configuration and content.

What I need to do is to first anonymize the database from usernames/passwords, and also remove any not needed old revisions of existing content to compact the dump.

Is there any best practice strategies for how this can be done as simple as possible, and in the documentation provide a simple step-by-step guide on how to install it using the database dump?

Please note: While a Drupal Distribution would be optimal, in this case the wast amount of extra work, and testing, required is not possible.


texts: How do I unfollow an issue on drupal.org?

texts: How can I unfollow (i.e. unsubscribe from email notifications) an issue on Drupal.org that I automatically followed when I commented on the issue?