texts: How can I have admin language English and frontend language another?

texts:
I would like to create a site to display the frontend of the site in one language and still keep the backend in English (or another language).

Is there a module like "Administration Language" or any configuration for Drupal 8?


texts: add a repeatable autopopulate node title select list to custom block

texts:
I'm going to develop a new block that user can select 4(or more) node with 4(or more) autopopulate node selection list but i couldn't find any documentation or tutorial on how to build those select list.

Any suggestion?


texts: Adding map with user location into the profile

texts:
I am trying to add a 'IPGV&M: Map (Google) centered on visitor's location' block to all user profiles and I kinda succeeded. The map appears in the user profile, in the footer where i intended to have it, when I visit the user profile it asks if it can use my location. After clicking yes, I face couple problems:

It just shows a world's map from far far away without any marker on the location of a user
I have to make it so when visiting a user's profile I would be able to see where he/she is from in the map. If I use this method I talked about, doesn't it mean that when I visit someone else's profile I will be still seeing my own location? How to solve this problem?


texts: How to alter the parameters in the core.services.yml file programatically?

texts:
I need to modify the filter_protocols parameter inside the core.services.yml file programmatically to add a new protocol. I know how to alter a service but I don't find any information about how to alter a parameter.
parameters:
  session.storage.options:
    gc_probability: 1
    gc_divisor: 100
    gc_maxlifetime: 200000
    cookie_lifetime: 2000000
  twig.config:
    debug: false
    auto_reload: null
    cache: true
  renderer.config:
    required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions']
    auto_placeholder_conditions:
      max-age: 0
      contexts: ['session', 'user']
      tags: []
  factory.keyvalue:
    default: keyvalue.database
  http.response.debug_cacheability_headers: false
  factory.keyvalue.expirable:
    default: keyvalue.expirable.database
  filter_protocols:
    - http
    - https
    - ftp
    - news
    - nntp
    - tel
    - telnet
    - mailto
    - irc
    - ssh
    - sftp
    - webcal
    - rtsp

I know how to do this by copying the services.yml file inside the sites/default folder but at this time I need to do this programmatically.
Any idea about how to do it?


texts: How can I apply node template file only to node view page but not revision page?

texts:
I have a node template named node-"content-type-name".tpl.php which overrides the default node.tpl.php for this content type.

But this template file is applied to also node revision pages. Is there anyway I can apply the node template file to just node view/edit page without revision page?


texts: Drupal 8 : Serving private files using nginx and X-Accel-Redirect

texts:
We're using private files on a site which is working quite fine.

The problem is that if an author uploads private videos which have like 10 minutes length the php worker does not shut down until the viewer has stopped looking at the video.

I would like to handover the serving process to nginx after authentication to Drupal so that the worker is free again.

So long all my attempts failed.

Here the setup:

PHP7.1-FPM
Drupal 8.4.2
Web Folder /var/www/web
Private Files /var/www/private

Nginx Config for the private files which works:

location ~ ^(/[a-z\-]+)?/system/files{
    try_files $uri @rewrite;
}

Private File path:

$settings['file_private_path'] = '../private';

I tried multiple ways of telling nginx to serve the files.

Changed the Request and Response so that BinaryFileResponse adds this header
Added X-Accel-Redirect directly to the Response
Multiple different nginx alias / root / internal settings

Nothing works. Is there any good example for Drupal 8 and nginx?

I can only find old things for Drupal 7.
I implemented this in a seperate project in Symfony and got it working, it's just the combination of Drupal, Private files, Private image styles and so on which does not work.

Any help would be appreciated.


texts: Assign Multiple roles to Ubercart Product

texts:
I am using ubercart and Roles module to sell some roles on my drupal 7 site.
I wonder whether I can sell multiple roles with a single product, I tried to add multiple roles to a single product under features, but after purchasing a product I found only one role is assigned to the purchaser, Is there any way I can assign multiple roles.


texts: Is the views module a viable options for creating reports with calculated totals?

texts:
I have an application built in Drupal 7 that records properties as nodes and relates property nodes to charge nodes and payment nodes.

I would like to add the ability to view a report by selecting a property and specifying two dates, a start date and an end date for the report, that shows a total of payments, a total of charges and then a balance total for a particular property.

However, the charges content type is only used to record additional charges to a property. There is a monthly service charge which is stored as an amount in a field of the property node. So when generating the report, I simply add one service charge payment for each month the report spans.

A summary of the report:

Select a property and give a date range.
Produce a list of charges by :

Adding one service charge for each month between the two dates.
(Note: The service charge amount is given in a field of the property node)
Adding amount from all charge nodes related to this property.
Give a total field for all the charges.
Show all payments from payment nodes related to this property.
Total the payments.
Give a balance total(charge total - payment total)

What I can't figure out is if views can build the report I need.

Can this be done by adding calculated fields to views, in particular the service charge payments, or do I have to do this in a template file (views-view--foobar--page.tpl.php for example)?

I know how to get all payments and charges related to a property into a view, but I am not sure where to go from there. Maybe this comes down to personal preference, but this is my first venture into views and I would appreciate some advice on where I should be concentrating my efforts!


texts:
Okay, so I looked inside of the Managed File element and the FileWidget code and I am pretty overwhelmed.  I don't think I need anything quite so complex, but it seems like there is so much that can be done with a file widget that I don't want to do things in a way that could cause problems in the future.

I have some javascript that will upload a file to a remote server and return a url, so I want to send that url to a custom controller and save it in Drupal.  Is writing a file widget the right way to go here?

Any guidelines on where to go to find a good example of a file widget, or an explanation of how it works?


texts: How can I Eliminate render-blocking JavaScript and CSS in above-the-fold content?

texts:
I am using drupal 7 and Page speed in 82 for desktop on Google Page Insights.
I am having some issues regarding eliminating render blocking js and css.
How can I do this for aggregated js/css ?
I know we cannot enable Leverage browser caching for external js.
I have used following modules:
1. Minify
2. Advanced CSS / JS Aggregation.

Please see the attached screenshot of Google Page Insights.


texts:
I have a webform with file upload element.  This works fine as long as the file upload element does not have a condition tied to it.  Without the condition, one can see that the selected file was uploaded.  With the condition, the file does upload, but the page does not update showing the uploaded file.  It took me a while to realize that

The file was indeed uploading
the condition was causing this behavior

I saw that there was a ticket about this exact issue for drupal 7 and it was marked as won't fix.  I wasn't sure if this meant that it wouldn't be fixed just for Drupal 7 or does this apply to Drupal 8 as well?


texts: I am looking for a Drupal 7 module to manage a content publication workflow for different roles. When a user with a certain role creates a content node, it needs to be validated by another user within another role, before it is marked as published. In Drupal 6, I have used the Workflow module, but it is not available for Drupal 7.


texts: How to get list of sites with module enabled using drush?

texts: How can I find out, using drush, which sites from my Drupal multisite installation have a particular module/theme enabled?


texts: Calendar with multiple content types on multiple field types

texts:
I'm hoping to set up a calendar using date + calendar. I have 2 content types, one of which specifically has a date field, the other of which I want to display on the calendar using the published date. How could I go about doing this? I can get the first content to display under two different dates, one for published date and the other for its date field, but obviously this is not the desired behavior.

The following issue kind-of comes close, but not quite: How to use multiple content types in a "Calendar" View sorting by the field type of "Date"?


texts: hook_node_presave() fires twice when adding a new node

texts:
In a custom module I use hook_node_presave($node) on node objects with referenced fields.

When creating a new node, ddebug_backtrace() shows that entity_save is called first and then node_save. Which leads to two new nodes. At the end of hook_node_presave() I have one correctly created node and one with only partially filled fields.

How can I prevent node_save to fire in hook_node_presave() when entity_save was already executed? Or maybe the solution is to prevent entity_save to fire?

Could anybody please explain how to correctly use hook_node_presave() on node objects with attached referenced fields?


texts:
My Drush alias file is:

$aliases['mysite'] = array (
  'uri' => 'mysite.com',
  'root' => '/var/www/mysite',
  'path-aliases' => array(
    '%dump-dir' => '/tmp',
  ),
);

when I do drush @mysite status I get

 Drupal version         :  7.36
 Site URI               :  mysite.com
 Database driver        :  mysql
 Database hostname      :  localhost
 Database port          :  3306
 Database username      :  dbuser
 Database name          :  dbname
 PHP executable         :  /bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush version          :  7.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /home/deploy/.drush/mysite.aliases.drushrc.php
 Drupal root            :  /var/www/mysite
 Site path              :  sites/default

But I'm unable to run other Drush commands.

eg:

drush @mysite dd
You need to specify an alias or run this command within a drupal site.           [error]
Target 'root' not found.        [error]

OR

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

But drush dd commands works this way:

drush dd @mysite
/var/www/mysite

I tried like that, but this one doesn't work though
drush cc all @mysite

Any ideas why is that so, the site is running perfectly.


texts: Calorie Calculator with Drupal: There are modules or solutions?

texts: I want to create a calorie calculator with Drupal 7. You should be able to choose different foods and at the end the total calories should be calculated. Are there solutions (modules) - does anyone know the best solution? Is it possible with Webform Calculator?


texts: Superfish Menu OnHover instead of OnClick

texts:
I'm in the process of redesigning my site and have decided on using Superfish menus.

Well after installing it (and I've made sure every library is included) I have run into the issue that the dropdowns only appear after clicking the parent, rather than hovering.

Is this something that needs to be selected in the settings or am I missing something somewhere else?

I've also tries using jQuery verions 1.7, 1.8, 1.9, 1.10 as tests from other posts who have suggested it, but nothing has worked.

If anyone can provide any help, I'd greatly appreciate it! Thanks!


texts:
Which is an efficient way to fetch entity label and id?
Database query or entity query with entity load?

I need to get the list of all taxonomy terms in an associative array of ID and Label. I can do it loading the tree but the vocabulary has ~650 terms in it. So, loading the all the 650 terms and then building an array out of it seems like overkill.

I went with the static \Drupal::database->query() route to get the result and cache the resulting array. Just wondering if it's the right or the Drupal way of doing it.


texts: How can I grey out/disable certain fields?

texts:
I am using a Webform module for my multi page form. I would like certain form elements to be greyed out/disabled if an answer to one of the questions is "Yes" (dropdown list).

How would I go about doing this?


texts: Share users database from one Drupal database with other Drupal Installs (separate databases, not just prefixed tables in the same db)

texts: I have several Drupal databases and core sites currently. What I want to have is several Drupal databases that share a common users database under one core site source. The reason I want this is so that I can restore a sites database from any date I choose without rolling back the other sites content as well. I have looked into prefixing but it sounds like all sites have to be under the same database, the same seems to be true of domain access.


texts:
I have a search box using custom_search module. I am trying to add multiple classes to the input field using a hook.

Here is the code I have tried:

<?php
function mytheme_form_search_block_form_alter(&$form, &$form_state) {
      $form['keys']['#attributes']['class'][] = 'custom_search-keys','form-search','form-control';
    }

But it does not add the classes to the search box input field?


texts:
How can i list my vocabularies and their terms in this way . Is there a module that can help me to do this . or i should go with custom VIEW and jQuery.

thanks :)


texts: Is it possible to rewrite sort fields in a view without using additional modules?

texts: I need to sort by title but some of titles start with a space and sort is putting titles with a space first (before a,b,c, etc).  So I would like to use trim when I sort by title. The view is part of feature so I can add theme files.


texts: Allow users to >only< upload images to existing nodes?

texts:
I want to allow users to upload images for exsits content, for example for article, but i will not allow they to delete already exist images.

How modules i can use? How to create this submit form for they?

I use drupal 7.

Thank you!

EDIT:
Hi Vincent,
thanks for reply.

On example:
I have article about Rome with title "Rome". I create description for that beautiful city and i want to allow users to upload images to this exist article about Rome and create gallery of users pictures under descripton.

User can submit photo, but can't remove own or anyone images.
Admin must accept every image before it's publish.

Greetings.


texts: Add configuration options for Views block under Structure > Blocks > configure

texts:
I'm building a module that defines several blocks and provides custom options for those blocks via hook_block_configure(). Two of these blocks were built from scratch using hook_block_info() and their configuration options defined in hook_block_configure() display as intended. In other words, if you navigate to Structure > Blocks and click configure for either of these two blocks, the custom configuration options are displayed as intended.

The third block is a Views block, defined by hook_views_api() and hook_views_default_views(), and the hook_block_configure() hook doesn't trigger at all for this block. Navigating to Structure > Blocks and clicking on configure for this block just shows the default block configuration options.

What I would like to know is how to add custom configuration options for this Views block or a similar solution. Is there any way to register this block so that it will also listen in on the hook_block_configure() hook? Or is there maybe a different hook that would allow me to accomplish my goal? My Google-fu has yielded nothing.


texts: Moving PayPal Payment iFrame to Checkout page

texts:
The Problem

Hi, I'm trying to move the payment iframe from its own page to the main checkout page so that I just have a one page form for checkout. I followed the directions here but wasn't able to get it to work (ie. I moved the 'review' section to 'disabled' and move the 'payment' section to 'checkout' in configuration).

The Current Status of My Situation

I'm using the Drupal Payflow Link module, and I have all my items in my checkout pane in store configuration. However, when a user goes to the checkout page they fill out all their information and also choose what payment method they want to use, but the actual entering of the payment information (credit card for example) still happens on the 'next' page. I want everything on ONE page.

Question

Anyone know how to make this happen with PayPal Advanced Payments/PayFlow Link so that entering the credit card details also appears on the main checkout page?


texts:
I am trying to access the admin of my Drupal site but .../admin and .../user are not working.
When I try to access those pages I get the 404 page.
I believe this may have been redirected similar to https://www.drupal.org/project/rename_admin_paths.

I have access to the database and files where would this configuration change be stored?


texts: Where and how should I use Composer and the drupal-composer/drupal-project scaffold to install the required libraries?

texts:
I installed Drupal 8 using the drupal-composer/drupal-project scaffold. I also installed the Devel module, and enabled its Webprofiler submodule.

Drupal status reports that Webprofiler needs:

D3.js library
highlight.js library

There's no libraries path in my Drupal installation.

As I'm using composer, both D3 and highlight have packages.

https://packagist.org/packages/mbostock/d3
https://packagist.org/packages/components/highlightjs

That's a preferred option.

Where do the libraries need to actually go when using this scaffold?  What path?

How do I correctly use Composer on this install to put them there?

Although Where should I download libraries for modules through composer? talks about it, it's only for the case of Composer Manager, which I am NOT using.


texts: Javascript file attached via Drupal behaviours does not work occasionally

texts:
I'm facing a weird issue where a JS file attached via the Javascript API does not work properly. I couldn't really pin down why it isn't working by the JS file consists of a few event listeners which get attached to DOM elements and it looks like this:
(function ($, Drupal) {
  Drupal.behaviors.basics = {
    attach: function (context, settings) {
      if (context !== document) {
        return;
      }

     initPublicationsAccordion($)
     initBackground($)
     initNavbarFix($)
     initMobileNav($)
     initAuthorsDropdown($)
     setTimeout(() => initCarousel($), 500) // this fixes it
    }
  };
})(jQuery, Drupal);

and the corresponding *.libraries.yml file:
global:
  css:
    theme:
      css/main.css: {}
  dependencies:
    - core/drupal
    - core/jquery
    - drulma/bulma
    - drulma/mainjs

...
mainjs:
  js:
    js/main.js: {}
  dependencies:
    - core/drupal

There are no errors in the console, but I noticed I can make it work by wrapping the functions in a setTimeout. I would appreciate if anyone has an idea?


texts: How to reorganise files location without updating each node manually?

texts:
In my file system, I have different folders where are stored the files linked to the nodes (either pictures in the body of the node or pictures in a 'Gallery' field I added to custom content type).

I'd like to reorganize all these folders in a more structured way.
How can I do that without editing each of these nodes?

Is there a way to update the database, e.g. change mydomainname/sites/default/files/mypicture.png (or whatever) to mydomainname/sites/default/files/pictures/yyyymmdd/mypicture.png where yyyymmdd is related to an event, for example?

My version of Drupal is 8.5.6.


texts:
I am trying to override the core login method in Drupal\user\Controller\UserAuthenticationController by extending the UserAuthenticationController class so that I can inject custom data into the response object. I could achieve override by creating an Event subscriber service and using the alterRoutes method.

 public function login(Request $request) {
     $response_data = parent::login($request);

      return $response_data;

  }

However the response data is an object of type Symfony\Component\HttpFoundation\Response and there is absolutely no way to access the data. I would like to do the following but not able to modify the response object.

 public function login(Request $request) {
     $response_data = parent::login($request);
     $response_date = $this->fetchCustomdata($response_data);
     return $response_data;

  }

  private function fetchCustomdata($response_data) {
   // Do some work and return modified $response_dat
   return $reponse_data
 }

Is there any better way to inject custom data into the response parameters?

Note: The additional data I am trying to inject is additional fields i have added to the user profile like First Name, Email and other reference fields. It is required to deliver these along with the other default responses along with the default response on login.

Note: I tried copying the original method and modifying the data and it works but it goes against the good practice as we are trying to reduce duplication.


texts:
I have successfully installed composer, but when i try to install drush and modify the .~/.bashrc file it returns Content-Type: text/html when i run any kinda of drush command.

Anyone seen anything like this? Sorry can't be more specific but can get you  any info you need to be helpful..


texts:
I have a view with multiple fields:

Nid
Title
Content
Image

On my page, I use the nid as a selector ( I have a button elsewhere on the page tied to it) to open my content without going to another page. The images are also loaded. Only problem I have is that I need to find a way to ensure that only the images for the view row's [nid] are being output, rather than all of them. The [nid]  filter requires a hard value and I'm looking more for a "current page" ish kind of thing.

Basicaly, I want to load only the images that have the same nid as the content being displayed in each row.

How would I set up a filter for this?


texts: How to hide a block entirely if it's empty

texts:
I've added a series of blocks to my template file for a specific content type. These blocks are built in Views and they show Downloads filtered by the specific content you are viewing. For example, on the Product A page, the Product Literature block shows all downloads categorised as Product Literature specifically associated with Product A.

There is a block for Product Literature, a block for Videos (set up in a similar way) and a block for Publications (again, set up in a similar way).

At the moment, if there aren't any videos for Product X, the heading Product X still displays for Video Gallery, is there a way I can detect if there is any content under the Video Gallery heading and if there isn't, choose not to display it?

Each block is printed as below:

$block = module_invoke('views', 'block_view', '712046d635e195e59dd93bd378e45423');
print "
Product Literature
";
print render($block);


texts: HTML tags in views field label. Is it possible?

texts:
By default in views field label it possible to put only plain text, so the markup looks like:

  Price: -10%
  9.99

But I need to add some text wrapped with tags, like

  Price: -10%
  9.99

How it is possible?


texts: Previous week is calculated wrongly in Views

texts:
I have a view with 1 contextual filter. This filter using a field of type: Date.
Configuration of this contextual filter:

When the filter value is NOT available: Provide default value -> Current Date
Granularity: Week

In same view, I also use Pager by date, so I've links in the view to the previous and next week.
As of Today (2021-01-09), the link to "Previous week" in the view is pointing to "2020-W04" (❌), not sure why!!
The link to "Next week" is showing correct value, i.e. 2021-W04 (✅)
I've struggling since fist day with the year with Year/Week numbers. Any idea why this is happening?
P.S.

Site is using Drupal v7.69, Views module v7.x-3.24, Date module v7.x-2.10
Site Regional settings -> First day of week: Saturday


texts: Make a public object property visible in other places

texts:
I am using a class inside a Drupal module. I inserted the class inside the html.tpl.php like this:

require_once(drupal_get_path('module','shop')."/jcart/jcart.php");

Now I can use its properties in the pages but I need it to use one of them ($jcart->subtotal) inside a block module I created like this:

function MYMODULE_block_info(){
    $blocks = array();
    $blocks['total'] = array(
        'info' => t('Total amount of the cart'),
                //'cache' => DRUPAL_NO_CACHE,
    );
    return $blocks;
}

/**
 * Implements MYMODULE_block_view().
 */
function total_block_view($block_name = '') {
    $block['title'] = t('Total');

        $total = $jcart->subtotal;

    $block['content'] = $total;
    return $block;
}

notes:

I cannot add the class twice with require (because the $jcart) is being initialized inside the class and cannot be done twice
I need a block with so I think the variable is not visible in a Drupal block.


texts: Drush Enable a module and all its submodules

texts: For example when I enable coder  module, I also want to enable coder_review, coder_sniffer and coder_upgrade modules.


texts: Rebuild permissions needed after installation from profile

texts:
Once solved this issue:
How to define settings from an install profile

I would like to skip the Error Message I get on first load of the application:

Message d'erreur
Les permissions d'accès au contenu doivent être reconstruites. Reconstruire les permissions.

To do so, I've created a task to perform the function
    node_access_rebuild(FALSE);

function genius_install_tasks(&$install_state) {
  $tasks['genius_settings'] = array(
      'display' => FALSE,
      'type' => 'batch',
      'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
  );

  $tasks['link_taxonomy_menu'] = array(
      'display' => FALSE,
      'type' => 'batch',
      'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
  );

  $tasks['rebuild_permissions'] = array(
      'display' => FALSE,
      'type' => 'batch',
      'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
  );

  return $tasks;

}

But it seems to don't be enough.In fact, I set a message that I can't see, so I think this task maybe is not being perform.

function rebuild_permissions() {
    // Rebuild permissions
    node_access_rebuild(FALSE);
    // This message is set at the end of the node_access_rebuild
    // Keep here to ensure this task has been made
    drupal_set_message(t('Content permissions have been rebuilt.'));

}

I am going to try to change the type of the task to normal.
EDIT: This change doesn't solve the problem

Mindwhile, appreciate reader, do you have any advice to do the rebuild permissions at the end of the installation correctly?

Thanks for the reading.


texts: How do i override a View attachment glossary fields link or url

texts:
Is there a way of overriding an attachment views field's url link that is in glossary mode?

I've tried altering the url and link property of the field in the pre-render and post render theme functions, and I can alter their values but it never sticks. I've tried the .tpl.php file but then the html tags.

I need to make them links to anchor links show.


texts: Create a block view which shows a single item based on offset

texts:
I would like to create a block view which shows a single item based on offset. Let me explain ...

I can easily create a block view that shows the title's of the three most recently created nodes. But I want to break this ONE block into THREE blocks, that each show a single item:

Block A shows the most recently created node's title.
Block B shows the second most recently created node's title.
Block C shows the third most recently created node's title.
All three blocks 'look' have the same layout, etc.

I thought I could do this with a default display, and then have 2 or 3 different displays. But I cannot seem to alter the offset of a display.

Is there a way for me to achieve this, without having to create three seperate views?

Edit: By offset, I am referring to the PAGER settings of the view.


texts: CTools Modal AJAX Webform onchange submit problem

texts:
I want to submit form on radio button change, it works, but form is submitted twice and i got JSON error on confirmation page.

I'm using this function:

function surveySubmit() {
  $("form").one("click", "input:radio", function(){
    $("form input[type=submit]").click();
  });
}


texts: Fast way to make all menu-links "Show as expanded"?

texts:
Is there a way to automatically make all menu-links in all menus whatsoever "Show as expanded"?

I have about 4 menus that contain many links and it's not serious to pass one by one and click "show as expanded".

Is there a module or a script that will do that automatically? Thanks,


texts: How do I support text formats for an entity property?

texts:
I have a custom entity I've created following this basic SitePoint tutorial. My custom entity has just two properties, a name and description. My entity is not fieldable (maybe it needs to be?.

I want to make the description support text formats so it's not just interpreted as plain text. Ideally the user could choose text formats like they could for something like a text field added thru the field UI, but since my entity is not fieldable and has no UI for adding fields, I'm not sure where to go with this?


texts: How to use component variable in direct input mode

texts:
I'm trying to use a component variable in direct input mode, but as far as I know there's no token for variables. Is this a yet-to-implement feature of Rules, or is there any workarounds?

For example if you want to use Rules programmatically, you could call rules_invoke_component($component_name, $variable1, ...) to pass the variables to the component and execute it. It would be pretty nice to use the value of those variables in the body of an e-mail for example, but it's not possible, because AFAIK you can't use variables in direct input mode.


texts: Db_Query Fatal error: Unsupported operand types

texts:
I am simply trying to return the rows from a table in my db but i keep getting this error thrown back at me no matter what I do "Fatal error: Unsupported operand types in C:\xampp\htdocs\d7\includes\form.inc on line 1009". Am I missing a argument or something?

This is my function

Hook menu

function auto_form_menu() {
$items = array();
$items['admin/config/auto_form'] = array(
    'title' => 'My Module',
    'description' => 'description',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('auto_form_records'),
    'access arguments' => array('administer site configuration'),
    'file' => 'auto_form.admin.inc'
);

$items['admin/config/auto_form/manage'] = array(
    'title' => 'My Module',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'description' => 'description',
    'weight' => -10,
);
return $items;
}

'auto_form.admin.inc'

function auto_form_records() {
  $header = array('First Name', 'Last Name');

  $dbresult = db_query("SELECT first, last FROM {auto}");

    $rows = array();
    foreach ($dbresult as $dbrow) {
        $rows[] = array(
        $dbrow->first,
        $dbrow->last
      );
    }
    return $output = theme('table', array('header' => $header, 'rows' => $rows));
}

Updated Code:

Any help is appreciated seeing how I am completely lost on figuring this out.


texts: hook_form_alter() does not work for the contact form?

texts:
I have contact form module enabled from core drupal 8 modules.

When I use the below code it has

   $form['field_consumer_name']['widget'][0]['#title'] = 'Individual Name';

I want that this code which I have written should override default title but it does not .
I would be interested in knowing how I can override title?

 function referral_q_form_contact_message_referral_form_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state ) {
   // print_r($form['field_consumer_name']['widget'][0]['#title']);
$form['field_consumer_name']['widget'][0]['#title'] = 'Consumer Name Works';

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

   $form['field_consumer_name']['widget'][0]['#title'] = 'Individual Name';
   $form['field_referral_date']['widget'][0]['#title'] = 'Date';

   $form['field_diagnostic_code_1']['widget'][0]['#title'] = 'Diagnostic Code';

   _referral_q_remove_radio_na($form['field_veteran']);

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


texts: How do I run unit tests against datasets? (DrupalWebTestCase and DrupalTestCase)

texts:
I am testing a module that I am writing against the Unit Testing framework that comes with Drupal 7. All makes sense, and everything asserts as it should.

My question though, is it possible to run test cases against test data?

I can think of a few options/answers:

Trick the unit test into not setting up a test database, and just run against the live data (I don't want to do this, its hackish)
It's also very possible that testing against test data is not the place of a unit test, because technically a unit test should pass if there is data or not - from my understand of unit testing.

Should functionality testing be done in a different place than the SimpleTest framework? Or is there a way to test against data sets?


texts: Additional textbox for adding unique css classes to images uploaded

texts:
My project has a custom module that uses the paragraphs module. I have a background image upload field that now requires an additional textbox field to set unique css classes for the individual images uploaded.
Everything currently works as expected although I am now seeing that some images, which are used in many different types of layouts, are not very responsive to mobile views. I have set some breakpoints but it also effects the background images that respond very well to mobile. So having an option to set an image class on the individual image uploaded would be ideal.

Any suggestions or solutions would be highly appreciated.
Thanks


texts: What is the best way to collect and report statistics from within views 3's exposed filter?

texts:
I have a content type "song" and created a view on it. Using Views 3 exposed filter, people can search with different criteria.

With Google Analytics, I can collect some rough statistics. But I do not want anonymous statistics. I would like to collect and report the criteria by the login user/roles.

I can put a PHP code into my view so that every time someone interacts with this view, the PHP code will collect the criteria from the URL and save to a table.

Is there a better way?

EDIT

I've got an interim solution:

Write a custom module that uses hook_form_alter to update the exposed filter form. See link.
Install Views Watchdog
Create a view that reports on these watchdog entries. I can use PHP to parse the watchdog's location field to get my reports better.

If you have a better alternatives, please let me know.


texts: How to hide node title for specific content type using template file

texts:
I am trying to remove a node title on a specific content type (Core Article) using its template file.

I don't want to use preprocess_node() hook that it's pretty straight forward but not of my liking due to I want to organize all my edited templates in my custom template folder.

What I did is this:
I copied the node.tpl.php to my template folder under the folder "templates". I renamed that file to node--article.tpl.php. I edited the template file removing all the header section (which includes the title render function). Cleared the caches but the title is still there.

What am I doing wrong?

EDIT: Here is the code in my node--article.tpl.php

<article id="node-<?php print $node->nid; ?>" class="<?php  print $classes; ?> clearfix"<?php  print $attributes; ?>>
   <?php
      // Hide comments, tags, and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_tags']);
      print render($content);
      ?>
      <?php
     if (!empty($content['field_tags']) || !empty($content['links'])):
      ?>
   <footer>
      <?php
         print render($content['field_tags']);
         ?>
      <?php
         print render($content['links']);
         ?>
   </footer>
   <?php
      endif;
    ?>
    <?php
      print render($content['comments']);
    ?>

PS: Sorry for the code styling but I guess html5 tags are breaking the lines in stack exchange editor.


texts:
I created a new role, and this role should only have the permissions to insert/edit/remove to content types.

The problem is that the admin menu ( Navigation Menu ) doesn't show up in the admin area, and I can't seem to figure out why.

The other problem is that if I login with this user, and access the create node by putting admin/node/add ( since the Navigation menu doesn't show up ), I can create every content type available.

What am I doing wrong?


texts:
I have a content type, have a integer value field suppose field name is "field_xyz" and I have also variable from variable tables (variable_set('xyz')) which have some dynamic value

Now I want to create a view in which I need to add a filter and showing all node having field_xyz's value greater than equal to variable_get('xyz') value. I can do this using views_php module but I want to do it with manual configuration (No PHP code). Is there anyway ?


texts: We have a country based site that needs to have an unfiltered view of various content types and a filtered view per country. We have implemented the countries with Organic groups but can't seem to get the contextual filters to limit the view based on the OG name in the URL. Is there anyone that has done something like this with OG?


texts: D7 sites/default/files/.htaccess caused unloaded css&pictures&etc...

texts:
After an error [SA-CORE-2013-003 - Drupal core - Multiple vulnerabilities]
notice showed up in my site's status report page,
I rewrote the content according to this
https://www.drupal.org/SA-CORE-2013-003, and the error itself was solved and gone.

but it turned out that all css and pictures of my site were entirely lost!!
it may mean that all the thing from sites/default/files are not loaded now.

What I did was that just changing the content of .htaccess at sites/default/files.
now, I tried to change the content of .htaccess back to former one,
but the gone css and pictures still can't be applied again...

Im using Drupal 7.34, I don't know how to fix it.
please someone could help me?


texts: Card on File Recurring - Apply a filter to fetched recurring orders

texts:
With the cardonfile module comes a submodule 'cardonfile_recurring' that provides a rule to charging pending recurring orders.

What I'm trying to achieve:
I want to filter the list of recurring orders loaded in this rule,
i want to charge only recurring orders referenced to a recurring entity that has been created from an order that has a payment method that supports cardonfile.

For example let's say i have 2 recurring products, Product A & B, and 2 payments method X (Supports CardOnFile)  & Y (no cardonfile integration for example cash on delivery)
I've ordered Product A and paid using payment method X, and Product B using payment method Y.

After confirming the payments, i get 2 recurring entities C (for A) & D( for B) each Product. I want to charge only recurring orders that are referenced in Recurring entity C.

What i tried to do is to check the first order referenced to this recurring entity and check if it's has been paid using a payment method that supports card on file.

I made this filter as an action:

function MODULE_NAME_recurring_rules_action_info() {
  module_load_include('inc', 'rules', 'entity.rules');
  $action = array();
  $action['filter_reccurring'] = array(
    'label' => t('Filter Card On File Recurring Orders'),
      'parameter' => array(
        'value' => array(
        'label' => t('Entity type'),
        'type' => 'list,
        ),
      ),
    'provides' => array(
      'entity_fetched' => array('type' => 'list', 'label' => t('Fetched entity')),
    ),
    'group' => t('MODULE_NAME Recurring'),
  );
 return $action;
}

And this is the action callback:

     function filter_reccurring($args, $element) {

$return = array();
foreach ($args as $key => $arg) {
    $recurring_entity = commerce_recurring_load_by_order($arg);
    $ent = reset($recurring_entity);
    if (isset($ent->commerce_recurring_order['und'][0])) {
        $rec = entity_load('commerce_order', array($ent->commerce_recurring_order['und'][0]['target_id']));
        $first_order = reset($rec);

        $payment_method = explode('|', $first_order->data['payment_method']);

        $payment_methods = _commerce_cardonfile_capable_payment_methods();

        if (!isset($payment_methods[$payment_method[0]])) {
            unset($args[$key]);
        }
    }

//
    }

foreach ($args as $arg) {
    $return[] = (int) $arg->order_id;
}

return array('entity_fetched' => $return);
}

What am i doing wrong ?


texts: Views with exposed filters WITHOUT `Use Ajax`?

texts: Is there a way to use exposed filters, but not require Use Ajax ? I want exposed filters but I want it to submit the form and refresh the page.


texts:
I have 7 roles in my project.
I arranged them by weight in admin/people/permissions/roles page
Add the sort criteria Global:PHP with code

return $row1->rid;

But users display with no sort on role weight on page.


texts: Getting xdebug to work with BrowserTestBase functional tests?

texts:
I'm having a really difficult time trying to get XDebug working with my functional tests that extend from BrowserTestBase.

Does anyone have a working configuration in place for this?

I'm using PHPStorm (version 2016.2) for debugging and already have a working XDebug setup for standard unit tests. I've been initiating the tests from PHPStorm directly, but would certainly be happy running them from a terminal outside of PHPStorm if it works!

Here's what I've tried for running out outside of PHPStorm in a normal terminal:

export SIMPLETEST_BASE_URL=http://drupal8.dd:8083
export XDEBUG_CONFIG="idekey=PHPSTORM"
vendor/bin/phpunit --configuration core/phpunit.xml.dist /Users/bosborne/Projects/drupal8/modules/cas/tests/src/Functional/CasAdminSettingsTest.php

The tests run but my breakpoints are ignored.


texts:
How can I delete my own node comments without installing modules?

Googling, I found the Comment Access module. I don't want to install it.


texts: What are the really use of the ancient Project Application issue queue now that you can promote your own sandbox projects?

texts:
The Gates are open for Drupal.org Code Contributions, so now you can promote sandbox projects to full projects with releases if you have accepted the git terms of service.

But what is the actual use of the legacy Project Application issue queue (which is now named Drupal.org security advisory coverage applications?

I post this question because I have a module in revision there a some users that says that the code is OK, they made some suggestions and I made the changes until the last comment that says:

  When a node Add is disabled, you should at minimum highlight which
  content type won't accept new content (in fact providing node edition
  instead).

This is a UX change that don't affect the security and don't affect the module functionalities. The module works fine without this. And now the module is promoted to full project this is an impediment to approve the module in the new Drupal.org security advisory coverage applications queue?

What are now the procedures to go ahead wit the revisions?

Disclosure: I'm the maintainer of the module Only One. I'm not looking for promotion, I just want to know how to finish the review process.


texts: How would I paginate to 5 results in each page this query?

texts:
I am trying to paginate the results from the table, I saw some examples but those make use of db_select, I chose db_query. Is there a way to get the paging with db_query? I have been trying to translate the code into db_select but no luck, support please! Thanks!
Here is my code!

function rss_list_form($form, $form_state) {
  $header = array(
    'article' => t('Article'),
  );

  $sql = "SELECT * FROM {rss_table}";
  $result = db_query($sql);

  $rows = array();
  foreach ($result as $dbrow) {
    $rows[$dbrow->GUID] = array(
      'article' => '
'.$dbrow->title . '
' . '

' . strip_tags($dbrow->description, '

') . '

' . '' . $dbrow->date . '
' . $dbrow->link . '
',
    );
  }

  $form['rss_select'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#empty' => t('No articles found.'),
  );

  $form['import'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
    '#weight' => 0,
    '#submit'=> array('rss_list_form_import'),
  );

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

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

  $form['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#submit'=> array('rss_list_form_delete'),
  );

  return $form;

}


texts: strcmp() expects parameter 2 to be string error on configuration and system status page

texts:
I am getting the following error on the configuration and the system status page:

Warning: strcmp() expects parameter 2 to be string, array given in
_system_sort_requirements() (line 2805 of   /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: strcmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2805 of /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: strcmp() expects parameter 1 to be string, array given in _system_sort_requirements() (line 2805 of /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: strcmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2805 of /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: strcmp() expects parameter 1 to be string, array given in _system_sort_requirements() (line 2805 of /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: strcmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2805 of /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: strcmp() expects parameter 2 to be string, array given in _system_sort_requirements() (line 2805 of /srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.module).
Warning: usort(): Array was modified by the user comparison function in system_status() (line 2351 of
/srv/bindings/00fd0ded5def4c8289075262cb552d75/code/modules/system/system.admin.inc).

Has anyone seen this before?  It's something to do with core but I have no idea what's caused it.


texts: How to get average rating of Fivestar fields for multiple nodes?

texts:
I am creating a Property listing application where each property has fivestar voting enabled through user comments and each property belongs to certain location.
I am trying to create a aggregated view of Locations (I am providing field relation to connect it to Properties) and show average rating of all properties belonging to that location. I am not able to get right result. Please help.


texts: How to use drupal tokens using token_replace

texts:
Recently i developed a module which will prompt a message to user when he logs in
Hi xyz .thanks for vising the site.
using drupal_set_message.Now in order for this to work i had to use
token_replace($message,array(user=>$user)).
Now the object variable for user:name was $user . So just like this there are various other tokens available in drupal so how will i identify the object names of those variables and use them in token_replace to make sure that the message gets displayed with the proper values


texts: How to translate a database query with a subquery to a db_select statement?

texts:
Assume any variable that doesn't have a definition in the sample code is defined elsewhere. I need to get the results of the following query:

select type, eid, vid, language, keyword, custom_value from (select * from custom_keywords_entity_values where language = 'en' order by eid asc, vid desc) as ckev group by keyword;

However, I'm not entirely sure how to translate this into a query that leverages the Database API.

Fatal error: Unsupported operand types in /Users/lpeabody/Sites/jandj/docroot/includes/database/query.inc on line 1809

This is my working structure right now:

$subquery = db_select('custom_keywords_entity_values', 'a');
$subquery->fields('a')
  ->where('language', $language)
  ->orderBy('eid')
  ->orderBy('vid', 'DESC');

$query = db_select($subquery, 'ev');
$query->fields('ev')
  ->groupBy('keyword')
  ->execute();

$keywords = $query->fetchAllAssoc('keyword', PDO::FETCH_ASSOC);

I feel like that's the most literal translation, but I'm probably missing something since I'm getting this sweet error:

Fatal error: Unsupported operand types in /Users/lpeabody/Sites/jandj/docroot/includes/database/query.inc on line 1809

Let me know if there's any other information you need me to provide you.


texts: How to set maximum height in image style in Drupal 7?

texts:
I want to define an image style in Drupal 7 which changes the width of images to 200px and the max of the height to 150px. That means if a picture is 400x300 the image style should change it to 200x150 but if an image is 250x120 the image style should change only the width of it to 200px and the height shouldn't be changed.

How can I do it ? It seems it is not possible by 'admin/config/media/image-styles'.


texts: TableField and ARIA roles (role="presentation")

texts:
I'm using the TableField module to include a table in one of my content types. How would I go about adding the following ARIA role for accessibility (for screen readers) in all the tables?

<table role="presentation">


texts:
I have a view which I want to give a different look and feel from the rest of my page. Now the view is displayed as a page at a specific URL. I have tried naming my custom page template like views-view--mobile-special-events--page.tpl.php, (mobile-special-events being the name of my View) but this didn't work, it seems to apply this template only to the actual view area on my page but I want to re-theme the complete page, what do I need?

edit 1

I found this page: https://www.drupal.org/node/701920 where they say that you can preparte a page template from the link but I called my template page-mobile-special-events.tpl.php while my page is reachable under www.mysite.com/mobile-special-events but it doesn't seem to work, I've cleared the cache... what's going on, I'm wondering... :o


texts: how to insert a block within a cck input form in Drupal 7?

texts:
I wanted to insert a block within the CCK input field in drupal 7. I have created a block which would display all the custom content types and the nodes created with those content type in tree structure and categories,sub categories from Magento. The tree value is dynamically populated every time.

I want to display this tree in the cck input form to enable the user to make the selection. I was trying to do this using hook_theme in hook_form_FORM_ID_alter. I used module_invoke to insert the block module within the module template file. but its look like I cant insert the block within the template.
Could anyone tell me why I module_invoke is not working and suggest me a way to insert this tree in the CCK input field. I want to get the value selected in this field and store for use in some other module.


texts: What's the best practice way to test block Views with SImpleTest?

texts:
I've created a block view, which I've positioned on the  page using the admin UI. I've exported my view using Features and fe_block for its block.

I'd like to write a SimpleTest to verify that content from the view is displaying on the front page.

I've written a test that creates some nodes (of the type being displayed by the view), then does a drupalGet('/') and some assertText() statements to verify the content is displayed.

However, these are currently failing. When I view the HTML of the frontpage as seen by SimpleTest, the view isn't there.

Have I missed something? Is there a better way to be testing this?


texts: Rule to Send email to Admin when user points category reaches a certain value

texts:
I want to create a rule that sends an email when a user has points for a particular category that reaches a certain value, e.g., 100. Having problems with the condition.
I have a User Points category = Contest.

Rule Event: User was awarded points

1st Condition: Data Comparison Data to compare: [userpoints-transaction:tid], Data value: Contest

2nd Condition:
i)  Tried, Data Comparison, userpoints-transaction:points, equals, 100

ii) Tried, Data Comparison, userpoints-transaction, but not correct option as the value to compare doesn't allow an integer

Action: Send mail, I have email, subject and message.

With just the 1st condition, the Rule works, I get an email when someone gets a point for the Contest category, not for other categories.

Can't figure out a condition so  that will send an email when someone reaches 100 Contest User Points.

Anyone done this?
Thanks


texts: how to programmatically alter the rendering of a field in Views

texts:
I have a content type called 'Ping'. It has several fields and one of them is a url by the name 'filename'. I want the View of all such pings, names 'user-pings' to display not the url itself, but a link to it. How do I do that?

I've tried the following, but it doesn't work:

function feedback_views_pre_render(&$view)
{

    if( $view->name === 'user_pings' )
    {

        foreach( $view->result as $key => $val )
        {
           $lang = $view->result[$key]->_field_data['nid']['entity']->language;
           $field = $view->result[$key]->_field_data['nid']['entity']->field_filename[$lang][0];
           $filename = $field['value'];
           $link = "(download)";
           $view->result[$key]->_field_data['nid']['entity']->field_filename[$lang][0]['value'] = $link;
           $view->result[$key]->_field_data['nid']['entity']->field_filename[$lang][0]['safe_value'] = $link;

        }

    }

}

Additionally, if this code is a try in the right direction, I would very much like to learn how to do the same thing in less code.

Cheers and thanks in advance,
Alan


texts: Zen theme - recommended way to display 2 blocks next to each other in a region

texts:
I'm using a zen subtheme and I want to display 2 blocks next to each other.

I don't want to create 2 more regions in the info file because it will only be displayed on the home page. (Maybe even 3 blocks on another page)

Trying to move away from panels due to added markup and extra loading times during dev.

Would the correct way be to.

Add blocks to content region
Add css aka (width:50%) on the blocks to get the desired layout

or
Is there another theme layer of some-kind I can use for layouts inside of zen?


texts:
I'm baffled by this issue on my new site. I have double checked permissions to verify that authenticated users can post so I'm just getting that out of the way first off.

However, what is odd is that each node (where I rely off of the default Drupal node template, and those in which I have created a custom template) has a "Login or Register to Post Comments" div and appropriate links, however, when I login as a test user, there is no comment form.

I'm not sure where to go from here, as even my Admin account cannot see the comments form.

EDIT-----------

Also, all comment settings are set to "Open" for all content types and individual content postings.

EDIT-----------

I have rebuilt the permissions as well, just in case. Nothing has changed.

EDIT-----------

I happened to remember that I had previously posted a test comment on one of the pages, and now I can't see that comment, even if I go through the admin panels. I can see that there is a comment, but I cannot see the comment itself.


texts: jquery in select (views module) -- change submit click to link

texts:
This is regular Views selector exposed to user:

This is a part of block, attached to Panel on main page. I want to create links "show expiring" and "show latest" but I need to learn what function is fired while clicking Apply. Anyone knows where can I find it? Debugging it with Chrome is tricky, a lot of JS files…

Is there a way of previewing all javascript acitvity?


texts: Lots of permissions errors, should the entire site be set to www-data?

texts:
This is my first time configuring a lamp stack and I'm running into lots of problems with permissions. Here's an example of one of the errors

The specified file temporary://fileChLMzd could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

When I go to reports / recent log messages, this is all I can find:

REFERRER   http://localhost/boilerplate/public/admin/reports/dblog
MESSAGE File temporary://fileChLMzd could not be copied, because the destination directory public://js is not configured correctly.

I use to get a lot more of these errors when I had my temp directory inside of the apache installation, but I've since moved it to /tmp, which got rid of a lot of errors.

I've currently got my entire sites/default/files folder set to 777 with www-data access, which doesn't feel safe.. is this right?

Should everything else be set to have root access, like it currently is, instead www-data?

Stuff that I'm using:

Ubuntu 14.04
Apache2
MySQL
PHP 5.5
Drush status:
 Drupal version                  :  7.41
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database username               :  admin
 Database name                   :  boilerplate
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anonymous
 Default theme                   :  boilerplate
 Administration theme            :  seven
 PHP configuration               :  /etc/php5/cli/php.ini
 Drush version                   :  5.10.0
 Drush configuration             :
 Drupal root                     :  /var/www/html/boilerplate/public
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Private file directory path     :  /var/www/html/boilerplate/private
 Temporary file directory path   :  /tmp


texts:
I'm new to Drupal in general and am having some trouble with creating a view to display and link the information I want.

I have a content type called Project. This content type has a boolean called "Project Status" where "true" is labelled as "In Progress" and "false" is "Completed".

I want to create a block view to use as a sidebar on my page that lists all projects where the project status is true, and links to those projects by their title. I can make the view display the list of the projects that are in progress, but I can't figure out how to make it link back to those projects.

How do I do this?


texts: How to escape markup with check_markup in a twig template?

texts:
I am getting following error in drupal 8 :

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

Twig_Error_Syntax: Unknown "check_markup" function.

Twig template line :

{% set featured_portfolio_text = check_markup(featured_portfolio_array['field_portfolio_link_text']['#items'][0]['value'],'full_html') %}

Is there any alternative to check_markup function for twig?


texts: Remove tabledrag statuses on Ajax submit and display status message after Ajax submit

texts:
I've added drupal_add_tabledrag() on one of my custom forms, it enables the users to drag to reorder the elements' weights, which then gets submitted via ajax to a callback function that saves the weights.

It's all working and the weights get saved, but after the save, the asterisks that indicate the weights have been changed, and also the message "Changes made in this table will not be saved until the form is submitted" won't go away.

What's the best way to let the dragtable know that the weights have been saved?
What's the best way to display status messages from an ajax callback function? I'd like to say "Weights saved successfully" after the callback function gets called. Currently I'm using drupal_set_message and return true from the callback function. This works as theme_system_messages() get prepended to the responses (see #ajax['callback']), but I'd like to know if there's a better way to achieve this.


texts: Adding a dropdown list to the Registration Form. Drupal 7

texts: How would I go about adding a dropdown list to the user registration form? Also, is there a limit as to how many dropdown items you can have?


texts: How to set time limit only for one php file?

texts:
I have a script which walks through database table, makes some checks and based on them it makes notifications for website users. It works for a pretty long time. Currently in dev it takes a minute for every user.  So I think I need to set max execution time(.htaccess, php etc) to 0 for this one.

Currently it's launched from "drupal page with form", later I'll be launching it with cron. Drupal is not letting me set set_time_limit(0) because it's not the beginning of file where I can put it. But I don't want to set_time_limit(0) for whole website.

Is there a way bypass this limitaion? Maybe some external script execution? I'd like to remain Drupal functionality in it.


texts:
I want to give editors the ability to take advantage of a grid system we have on our site.  I can easily jump into a node and add this to the Body

one column

content on the left

content on the right

one column

...

Editors aren't savvy enough with HTML and CSS to do this themselves, and that's fine, that's what wysiwyg editors are for, and why we use Drupal in the first place (mainly).

But, this is a system of layout that can be applied consistently on any node. I'd think it would be easy enough to allow editors to take advantage of it. I'd love to let them create as many rows with as many columns as they want on any node without having to code it up themselves.

I know I can create template files that will apply structured HTML to all nodes of a given type, or one node, or some subset of nodes.  However, I don't want to make that choice for editors.  And besides, you can't split up the body content of a node into rows and columns like that from a tpl.php file.

I've looked into Panels too, but from what I can tell that's just a GUI means of creating tpl.php files.  Same problem.

This is very similar to the unanswered question Select Panel Node Layout on Node edit form.  I'm using 7.


texts: Render first element of a multivalued field

texts:
On my site I've an image field, multi value.
I would like, on a custom view mode, to display only the first image. On the field formatter I don't have this option.

How should I do this? Directly from twig or I've to use a preprocess function?

[EDIT] I would to do this without using a custom node template :)


texts:
I have a rules data selection token that looks like this
[order:products:0:node:author:uid]
In data selection mode that works perfectly, and adds the exact data right where I need it.
But when I am trying to add that kind of token into the mysql with this, using "execute custom php code" inside that rule using this code

$nid = db_insert('mytable') ->fields(array(
  'uid' => $uid,
  'username' => $username,
  'addr' => $address,
  'destination' => "[order:products:0:node:author:uid]"
))
->execute();

I am getting no error as a response, but only a blank field 'destination' with no value in mysql. All the other fields are filling correctly. What could possibly be a problem here?


texts:
I have Drupal 8.5.1 and I am trying to force a redirect for anonymous users to the CAS login page. First I thought that the issue was related with the firing of the checkAuthStatus function below, however, the issue seems related to an endless redirect:

namespace Drupal\my_custom_module\EventSubscriber;

use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Event subscriber subscribing to KernelEvents::REQUEST.
 */
class RedirectAnonymousSubscriber implements EventSubscriberInterface {

  public function __construct() {
    $this->account = \Drupal::currentUser();
  }

  public function checkAuthStatus(GetResponseEvent $event) {
    \Drupal::logger('my_custom_module')->error('THIS IS A TEST');
    if ($this->account->isAnonymous()
        && \Drupal::routeMatch()->getRouteName() != 'cas.legacy_login'
        && \Drupal::routeMatch()->getRouteName() != 'cas.service') {
      $response = new RedirectResponse('/cas', 301);
      $response->send();
    }
  }

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

}

What could be the issue?


texts: Combine two fields to be displayed together

texts:
I have a content type that represents an object and amongst other fields this has two fields for dimensions - width and height. Currently the display has each field displayed one above the other:

                      10cm
                      20cm

because these are in independent divs I do not see a way to use CSS to position these in line with each other to give output like (should be centred on page as well):

                      Size 10cm x 20cm

The 'manage display' for a content type does not have any option to rewrite the output. How do I go about getting the output I require?


texts:
I have a content type with a Location text field and a Geofield. The Geofield is geocoding the Location field into a coordinate and displaying it to a Google Map embed on the page.

This is working quite well and the map is always marked at the correct location. The problem I have is that the Google Map is quite useless because it doesn't allow the user to do anything with it.

The map shows the location but doesn't allow the user to get directions to it or get the address or anything. When the user clicks on the marker on the map they get a shout out box with the name of the event not the location.

Is there any way I can have the Google Map be more useful? ie add a Directions To button or something like that?


texts: drupal Theme class is missing, I guess! How to fix it?

texts: I am using civicrm on drupal 7.26. When I use default theme i can see the link "View all Contribution...." but as you can see from top part of screenshot it does not appear on bootstrap theme. can anyone help me to fix this please? thanks


texts: How can build a website for multiple organization?

texts:
I am going to build a Drupal 7 website with this structure.

Drupal admin create organizations, the organization is separated.
In each organization, it will be have an organization admin who is
assigned by Drupal admin.
Each organization will have their own taxonomy. The taxonomy are
created on one vocabulary.
Organization admin is able to create Project.
Organization can create users (called organization user) in their
organization and assign what project users can working on.
Organization users can create some nodes and those nodes are
separated in each project they are working on.

My questions are: 1) How I can do like that? and 2) What modules can be used to do it?


texts: How can I create a table view of entities showing their related entities in the same row?

texts:
I have multiple content types, which are in some ways related to each other. Lets say, the first one is "Author". Other ones are "Novel", "Drama" and "Short Story", which each reference "Author" (using the same field for each content type, so I can create relationships easier later in the view).
Now I want to create a view table like this:

Author
Novels
Dramas
Short Stories

King, S.
It, Insomnia, ...
...
Rush Call, ...

Martin, G. R. R.
ASOIF, ...
...
...

...
...
...
...

For each author there should be one(!) row in the table and for each text type they wrote there should be a column in the table showing the titles of that text type comma separated.
How can I achieve this output using views? I tried different ways of grouping and aggregation, but none of them quite worked. For example, when I try to group by "Novel", the tables split and it looks awful. I would have no problem styling the final results in a custom template, but what can I do using core views to get to my desired outcome a little bit easier?


texts: Replacement pattern in view field template

texts:
I have a body field view template:

<?php

/**
 * @file
 * This template is used to print a single field in a view.
 *
 * It is not actually used in default Views, as this is registered as a theme
 * function which has better performance. For single overrides, the template is
 * perfectly okay.
 *
 * Variables available:
 * - $view: The view object
 * - $field: The field handler object that can process the input
 * - $row: The raw SQL result that can be used
 * - $output: The processed output that will normally be used.
 *
 * When fetching output from the $row, this construct should be used:
 * $data = $row->{$field->field_alias}
 *
 * The above will guarantee that you'll always get the correct data,
 * regardless of any changes in the aliasing that might happen if
 * the view is modified.
 */
?>
<?php print $output; ?>

What I want is:

if nid == 1
print $output =  view_embed_view('my custom view')
else
print $output;

How can we do this?

Note: I'm already using the Views Field View module, but can't figure out as how to apply this condition of nid.


texts:
I love Drupal views and tags but I'm having a bit of trouble figuring out how to do this.

We have several online seminars with multiple sessions in each.

For example:  Refocusing on Family part 1, Refocusing on Family part 2, True Womanhood part 1, etc.

For each of these articles I have a view created that will return all the articles in that category.

For example, when you click on Refocusing on Family you get a page with teasers and links for:

Refocusing on Family part 1
Refocusing on Family part 2
etc.

What I would like to do is create a new view (something like "Life Academy" for example) that had a description and link to each of the top level views (which, in turn, link to the articles).

So the user would go to the Life Academy page and see links and descriptions for Refocusing on Family, True Womanhood, and any future seminar groups.  Clicking on these links will then take you to the view page (with links to the articles) for the appropriate group.

What I want to avoid is having to manually update the page every time a new seminar category is added.

Any help is greatly appreciated!


texts: How to creat different user type in drupal?

texts: I want to create two different type of users for example internal and external users. For internal users need to be authenticate against different database. Any suggestions?


texts: A contributed module without an issue tracker on Drupal.org?

texts:
The project page for the RNG - Events and Registrations module doesn't seem to have the typical block (column right) with title "Issues for moduleX" (similar to the block for pretty much any other moduleY on Drupal.org). Not sure if there are other modules for which this block is missing also.

Instead its project page does include some links to other sites (though not for "documentation requests" ...), i.e.:

Bug reports and feature requests.
Support requests.

What happened to this module's issue queue on Drupal.org?


texts: Get the value of a checkbox field (Boolean field type) from an entity object

texts:
Am trying to get the value of a Boolean field from a node entity, but it returns null whether the field is checked or not checked
$field_id = 'field_test_boolean';
/** @var Node $entity */
$entity = \Drupal::entityTypeManager()
  ->getStorage('node')
  ->load(220);

dump($entity->get($field_id)->get(0));

Not sure what am doing wrong here!!


texts: How to pass on the user id(block user) after registration

texts:
I am working on a project where users need to pay to use site.Site have a registration form where user can register and redirected to the payment page.All the resisted users are blocked until they make payment.
The registration process working fine but, when user redirects to payment page there is no method to get resisted user id. How to get registered user id on payment page?


texts: Paragraph field titles showing even when set to visually hidden

texts:
I am using the following code to render a paragraph entity in a twig template: {{ content.entity_name}}

A second template renders the paragraph's fields correctly using:

{{ content.nav_title }}

The problem is it showing the label even when set to "visually hidden" and when set to label "hidden" it doesn't display the content at all.

For example, it should render:

Example Option Two

Example Option Two

But when set to label "visually hidden" instead it renders (with extra spaces):

Entity Name Label

Example Option Two

Example Option Two

Finally, when set to label: "hidden" it renders (correct number of items but no content or markup from template):

{ item.content }}
{ item.content }}


texts: Is it acceptable to modify Drupal's composer.json file?

texts:
Drupal adheres to the best-practice of never modifying core.

Drupal 8 has a composer.json file built into core, if you need to add a third-party library, should you modify composer.json, or is there a better way to do this?


texts: Which modules help with loading of large images in a nice transition?

texts: Currently I am using the single_page module that does the anchor page sliding thing on the page, but currently I'm loading big images onto this single page. Which modules or recommendations on how to streamline the loading of these large image files? I tried the image_lazyloader module but none of the images show up when activating this on the single_page module. I'm guessing these two modules have a conflict. What other possible options do i have? it seems that spotify.com has the same setup, how are they doing it there?


texts: I already have a complete HTML/CSS mockup should I use a base theme or start from scratch?

texts: Will it be less painful to just build my theme from scratch using the HTML/CSS mockup that I have or should I still go through the process of using a base theme like Zen?


texts:
I am trying to install the appointments module, but running composer require drupal/appointments fails because some 3rd party libraries are not installed. I am using the drupal-project composer template.

The module page refers to some composer commands for installing these libraries but I am unsure whether these should be run from the command line or whether they should be included within the composer.json file (and if so where?).

How to install the appointments module with composer?


texts: How to programmatically search content with a specific taxonomy term with Search API?

texts:
I'm working on programmatically searching content with the Search API module. Ideally I would like the ability to select which taxonomy term of a content type is being searched. For example, if I have a content type of 'restaurants' and three taxonomy terms representing the style of restaurants, lets say 'Italian', 'Chinese' and 'Fast Food'. I would then like the ability to search and get results of all the restaurants content entities associated with, lets say, just the Chinese taxonomy term.

Here is the code that I have so far:

$search_entry = $form_state->getValue('search');

$query = \Drupal\search_api\Entity\Index::load('forum_ct_search')->query();
$query->keys($search_entry);
$query->range(0, 5);

$result = $query->execute();
$items = $result->getResultItems();

This is working as far as I'm able to search the specific content type I'm interested. However I'm assuming there is a way to ask the Search API to just search by taxonomy terms. If it's possible, my best guess is that it is with the addCondition method, such as this:

$query->addCondition('type', ['article', 'snippet'], 'IN');

If this is the correct method for filtering by taxonomy term what are the correct parameters? If not how may I?

The other alternative would be to weed out the taxonomy terms from the results. This would work but it strikes me as cleaner to do it the other way.

Any ideas? Thanks!

(I'm running Drupal 8.6 with Search API 1.12)


texts:
I have a views which filters films by genre and year, however the client would like urls in the following format:

/films/comedy/2009

however views is outputing the url like:

/films?genre=3&year=22

Any way to get round this?


texts: Can't use drush site-install to drop tables and reinstall in MAMP

texts:
I have a local multisite instance running MAMP 3.0.7.3, and I can't use the drush site-install command to do a re-install of one of my sites without actually dropping the database first.

If I try the command without dropping the database, I get the following output:

$ drush --uri="www.example.local" si -y my_great_install_profile --account-pass=admin --sites-subdir="www.example.com"
You are about to DROP all tables in your 'example_site' database. Do you want to continue? (y/n): y

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &amp;#039;example_site.registry&amp;#039; doesn&amp;#039;t exist: SELECT filename FROM {registry} WHERE name = :name AND type = :type; Array
(
    [:name] =&amp;gt; drush_drupal_site_install
    [:type] =&amp;gt; interface
)
 in _registry_check_code() (line 3188 of /Users/gravelpot/sites/www.example.local/includes/bootstrap.inc).

Additional

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &amp;#039;example_site.registry&amp;#039; doesn&amp;#039;t exist: SELECT filename FROM {registry} WHERE name = :name AND type = :type; Array
(
    [:name] =&amp;gt; drush_drupal_environment
    [:type] =&amp;gt; interface
)
 in _registry_check_code() (line 3188 of /Users/gravelpot/sites/www.example.local/includes/bootstrap.inc).

Drush command terminated abnormally due to an unrecoverable error.                                                                            [error]

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &amp;#039;example_site.semaphore&amp;#039; doesn&amp;#039;t exist: DELETE FROM {semaphore}
WHERE  (value = :db_condition_placeholder_0) ; Array
(
    [:db_condition_placeholder_0] =&amp;gt; 1731533568552880e6a71ed3.80394544
)
 in lock_release_all() (line 269 of /Users/gravelpot/sites/www.example.local/includes/lock.inc).

I also have the same problem when trying to import a SQL dump file by doing something like drush sql-drop followed by drush sqlc < path/to/file.sql, which is a pattern I see suggested in a lot of blog posts.

I am using Drush 6.5 installed via composer. My co-workers have a similar configuration, and do not have this problem.


texts: Problem with using a taxonomy and taxonomy term referece field to organize my site content

texts:
I have created a taxonomy called category in order to organize my website with Drupal 7.

I have tier 2s like cómo-aprender-inglés (how to learn English). If I create a basic page and select cómo aprender inglés as the term reference I create the following node http://www.brays.es/es/cómo-aprender-inglés/cómo-aprender-inglés. However, I would like the node to appear as http://www.brays.es/es/cómo-aprender-inglés. Is this possible?

At the moment:

I am hiding the node title so that a user navigating the site cannot access the full node view (cómo-aprender-inglés/cómo-aprender-inglés).
I have prevented that URL from being picked up by search engines by selecting this option in the Metatag module.
I think my solution is a bit messy and I don't think it is the best option. What can I do?

Thanks in advance.


texts: I deleted my .htaccess. easy way to fix this?

texts:
I'm clueless enough that I managed to delete my .htaccess file from my drupal site (after some mistaked advice from my webhost tech support).
Now, I can go to the home page, but links to all internal pages result in 404 not found.
I'm using drupal 5 and my web host is dreamhost.
I don't have a recent backup of my site. I did find a very old htaccess file, and uploaded it, but then it threw a login pass popup.

Is there an easy way to fix this? Must I have the htaccess file?
How can I generate a new one that will work with my site?

any help much appreciated.


texts: Is there a way to set only the "Full HTML" input format for the administrator role?

texts:
A plain Drupal 8 installation set the following input formats for the administrator role it creates:

Basic HTML
Restricted HTML
Full HTML

The first one is assigned to authenticated users; so, I guess it would be automatically allowed to the administrator role. The second one is assigned to anonymous users too.

Is there a way to assign the Restricted HTML input format only to anonymous users? I tried editing it to remove the administrator role from it, but when I edit that input format again, I see it is still assigned to the administrator role.

To make the question more understandable, I am referring to the settings in admin/config/content/formats/manage/basic_html.

I can unselect Administrator from the Roles list, but that change will not be keep after saving. Differently, I can take off the permission to use the Basic HTML format from the Authenticated user role, select it in admin/config/content/formats/manage/basic_html, and the selection will be kept.


texts: My javascript is making the drupal admin menu disappear. Not sure how though

texts:
Ok, so any time I try to view a page on my Drupal 7 site while I am using either
drupal_add_js(drupal_get_path('module', 'floormap') . '/includes/javaScript.js');
or
drupal_add_js('http://code.jquery.com/jquery-1.10.2.js', 'external');

The admin menu is hidden,  As soon as I comment them out, it is back.

First, do I need to include code.jquery.com in Drupal, or is it already there?

Next, I went to my jS file, and made it so that on DOMContentLoaded, it checks the page url, if it isnt the url of my module, nothing is executed...I put in an alert(); and it is only alerting on my pages, but somehow the menu is being hidden still.  Why is it still happening on other pages if my jS is only being executed on my module's URL? It seems like just having this file included breaks everything.

function checkPage() {

    if (window.location.pathname == '/floormap_page'){
        alert(window.location.pathname);
        hideAgentInfo();
    }else if (window.location.pathname == '/floormap_page/setup_floormap') {
        alert(window.location.pathname);
        coordGrabber();
    }
}

function displayAgentInfo(top,left,floormap,uid) {

    var bubble_info = '';
    bubble_info += floormap+','+uid;

    $.ajax({
        type: "POST",
        url: Drupal.settings.basePath + 'floormap_callback',
        data: {'bubble_info':bubble_info},
        success: function(data){
        document.getElementById('agent_info_bubble').innerHTML = data;
        document.getElementById('agent_info_bubble').style.display = "block";
        document.getElementById('agent_info_bubble').style.top = top+'px';
        document.getElementById('agent_info_bubble').style.left = left+'px';
    }
    });

}
function hideAgentInfo() {
    document.getElementById('img').style.height = '550px';
    document.getElementById('img').style.width = 'auto';
    document.getElementById('agent_info_bubble').style.display = "none";
    document.getElementById('agent_info_bubble').innerHTML = '#';

}

document.addEventListener("DOMContentLoaded", checkPage, false);

I've noticed that the admin menu is retieved using $.ajax get, I'm using $.ajax post in my jS, could that be causing issues?  Again though, the post is only happening on the pages with my module's URL....

Another note, when I look at the page's source code, the div for the admin menu isn't there at all, it isn't just not visible.  That is why I'm getting the impression that it's an issue with the GET function.  When I'm watching the log with firebug, it show's the GET when everything is commented out.  When my files are included, firebug doesn't show the GET.

Here is a link to my javaScript file if there is anything else you need from it.
https://gist.github.com/anonymous/9916901

This is what the firebug console gives me if I have ANY drupal_add_js() in my module's inc file:

  ReferenceError: jQuery is not defined

  jQuery.noConflict();

  drupal.js?n3ddny (line 5) ReferenceError: jQuery is not defined

  })(jQuery);

  contex...s?v=1.0 (line 52) ReferenceError: jQuery is not defined

  jQuery(document).ready(function($) {

  scripts.js?n3ddny (line 1) ReferenceError: jQuery is not defined

  jQuery(document).ready(function() {

  scripts.js?n3ddny (line 1) ReferenceError: jQuery is not defined

  })(jQuery);

  admin_...?n3ddny (line 397) ReferenceError: jQuery is not defined

  })(jQuery);

  scripts.js?n3ddny (line 32) ReferenceError: jQuery is not defined

  jQuery(document).ready(function() {

  main.js?n3ddny (line 1) ReferenceError: jQuery is not defined

  ...odules/custom/TLSConnectPackage/TLSApplicationFilter/TLSApplicationFilter.cs...

  app.lo...bal.com (line 58)

If I remove drupal_add_js() the only thing that shows in the console is the GET for the admin menu.


texts: How to display content for a Taxonomy Vocabulary?

texts:
I am using Drupal 8.

I have a Vocabulary called Fruit which contains terms:

Apple
Banana
Orange

I can go to page for term Apple and I can find all the content which was tagged with apple there. I want to create a page with all content tagged under Fruit as well. Is there a way to achieve this?


texts: How can I disable the node page for a specific content type? (But still use colorbox-node)

texts:
I use colorbox en colorbox-node to show the content of a node but I don't want people to access the node page for that content type.

How can I disable the node's detailpage and still access all the content in colorbox-node?


texts: How can I update the length of a base field definition in an update hook?

texts:
I'm struggling with writing an update hook that will simply update the length of a text base field attached to an entity of mine.

Here's my update hook:

function my_module_update_8001() {
  // Collect all existing story run data.
  $database = \Drupal::database();

  // Gather all the existing story run data.
  $tables = [
    'content_tile_field_data',
    'content_tile_field_revision',
  ];
  $existing_data = [];
  foreach ($tables as $table) {
    $existing_data[$table] = $database->select($table)
      ->fields($table)
      ->execute()
      ->fetchAll(PDO::FETCH_ASSOC);
    $database->truncate($table)->execute();
  }

  // Update the "name" base field definition to a new max length
  $update_manager = \Drupal::entityDefinitionUpdateManager();
  $name_field = $update_manager->getFieldStorageDefinition('name', 'content_tile');
  $name_field->setSetting('max_length', 100);
  $update_manager->updateFieldStorageDefinition($name_field);

  // Restore the data.
  foreach ($tables as $table) {
    $insert_query = $database
      ->insert($table)
      ->fields(array_keys(end($existing_data[$table])));
    foreach ($existing_data[$table] as $row) {
      $insert_query->values(array_values($row));
    }
    $insert_query->execute();
  }
}

After running this, the name field is clearly dropped and re-added (I know because it now appears at the end of the list of columns in the table), but the length is still set to 50, the old value.

I've narrowed this down to BaseFieldDefinition::getSchema():

  public function getSchema() {
    if (!isset($this->schema)) {
      // Get the schema from the field item class.
      $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getType());
      $class = $definition['class'];
      $schema = $class::schema($this);
      // Fill in default values.
      $schema += array(
        'columns' => array(),
        'unique keys' => array(),
        'indexes' => array(),
        'foreign keys' => array(),
      );

      // Merge custom indexes with those specified by the field type. Custom
      // indexes prevail.
      $schema['indexes'] = $this->indexes + $schema['indexes'];

      $this->schema = $schema;
    }

    return $this->schema;
  }

The schema definition is cached, so the update process gets the old schema data instead of regenerating it. There appears to be no way to clear this internal cache.

If I comment out the code related to the caching, it works as expected.

Is there another approach to this that I'm missing?

EDIT: The approach I took instead is to just load the current definition and pass that through to the update manager, like this:

  $update_manager = \Drupal::entityDefinitionUpdateManager();
  $definitions = \Drupal::entityManager()->getFieldStorageDefinitions('content_tile');
  $name_field_definition = $definitions['name'];
  $update_manager->updateFieldStorageDefinition($name_field_definition);

I guess this is not recommended normally, but it worked just fine.


texts: Drupal console "settings:set" not working or I am doing it wrong

texts:
I wanted to use Drupal console to change some settings on a site:

To set the default 403 page to "/user/login"
To set user registration permission to "admin only"

Following the instructions here, which gives this example:

drupal settings:set  application.language es

I tried the following:

drupal settings:set user.settings.register admin_only
drupal settings:set user.settings register:admin_only
drupal settings:set user.settings.register "admin_only"

In all cases, I got a green bar saying that the setting had been successfully set. But looking at the site showed that it had not. Also doing drupal config:edit user.settings showed that it had not (but when I changed it in the editor, it did update successfully in real life).

The exact same thing happened with:

drupal settings:set system.site.page.403 /user/login

Am I doing something wrong, or is this an unimplemented part of drupal console?


texts:
I am trying to install omega through the UI. But I get this error:

Error installing / updatingFile Transfer failed, reason: Cannot create directory /var/www/drupal/sites/all/themes

How can I bypass this error? I am using vsftpd.

Update: I can connect to my server via a SFTP Client, but I still get the error above.


texts: Checking for first and last panel arguments in a variant selection rule

texts:
I am creating a panel page in Drupal 7. My original idea is ending having urls following the next structure:

problem/!nid/!topicname/!level.

The "topicname" and "level" arguments are both taxonomy term names and "nid" is the nid :-).

As you can see, all the arguments are optional. My question comes with selection rules. Is there a way for having a variant displayed when first ("nid") and last argument ("level") are presents?

This means "problem/32/advance" would be a panel variant. I've been making some test and when I add a "context exist" selection rule it doesn't select the corresponding variant, it just shows the "default variant" (the last in the variant list order).

Hope everything makes sense. If you need further information, just let me know please.

Thank you very much in advance for your help.


texts: Mapping existing file against a new content type

texts:
I am facing a situation here.

I have a content type A with an image field(field_upload_snaps) in it. There is another content type B which also contains an image field(field_valid_snaps).

Now user will upload the pics from A content type. So if user upload 3 pics via A then 3 FID and their corresponding URIs will be created in file_managed table in Drupal 7.

Now I have a requirement where I have to insert 2 images out of 3 programatically using Drupal code. Now there is no need to generate any new image copy in public URI as images already exist via A.

I tried two approaches:-

1) I have created a new node of Type B. I tried to fetch file URI,filesize,filemime and all relevant parameter from existing fid and associate with the node using this.

 global $user;
 $node = new stdClass();
 $node->type = "user_slideshow_snaps";
 $node->language = LANGUAGE_NONE;
 node_object_prepare($node);
 $node->uid = $user->uid;
 $file = (object) array(
  'uid' => $user->uid,
  'uri' => 'public://1.jpeg" ,
  'filemime' => 'image/jpeg',
  'status' => 1,
 );

 $node->field_upload_snaps['und'][] = (array)$file;
 $node = node_submit($node); // Prepare node for a submit
 node_save($node);

But it gives me an error that "Cant insert duplicate value in file_managed". It will give because such value already exist in file_managed via A. So I am not able to save value.

2) I saved node first and then manually insert in the image field like this.

 global $user;
 $node = new stdClass();
 $node->type = "user_slideshow_snaps";
 $node->language = LANGUAGE_NONE;
 node_object_prepare($node);
 $node->uid = $user->uid;
 $node = node_submit($node); // Prepare node for a submit
 node_save($node);

 db_insert('field_data_field_valid_snaps')
    ->fields(array(
    'entity_type' => 'node',
    'bundle' => 'user_actualD_snaps',
    'deleted'=> 0,
    'entity_id'=>$node->nid,
    'delta'=>0,
    'field_valid_snaps_fid'=>517,
    'field_valid_snaps_alt'=>'',
    'field_valid_snaps_title'=>'',
    'field_valid_snaps_width'=>200,
    'field_valid_snaps_height'=>300,
    ))
    ->execute();

But the line after node_save() doesnt execute in this case. So I am not able to save it.

Are there any functions available which will map existing images into another table?


texts: How to get fields values in an override file?

texts:
I am writing a field override tpl file, in which I want to sum up two INT fields to one INT field.
In the file I tried the code:

$sum = $field_one + $field_two;

The problem is that I get an a notice that Drupal doesn't know what are these variable ($field_one, $field_two). I tried using "field_get_item", but I didn't succeed. I guess I use it wrong..
Can someone help me get these two fields to my override .tpl file.

How can I get these fields and calculate?

Thanks.


texts: Custom Drupal breadcrumbs - how to disable the last item

texts:
I have a D8 custom module providing its own breadcrumbs.
The breadcrumbs are shown perfectly, but the current page (last item) is shown as a link. I want to change Change this but as I see it, the ::build method requires the $links to be returned as an array of Link.

use ...

class BreadcrumbsBuilder implements BreadcrumbBuilderInterface {

  public function __construct() {
    ...
  }

  public function applies(RouteMatchInterface $route_match) {

    $result = // calculate logic
    return $result;
  }

  public function build(RouteMatchInterface $route_match) {
    $crumbs = new Breadcrumb();
    // prepare the data
    $links = $this->buildLinks($prepared_data);

    $crumbs->buildLinks($links);
      return $crumbs;
  }

  private function buildLinks($prepared_data) {
    $links = [
      Link::createFromRoute(t('Home'), '<front>'),
      Link::createFromRoute($title, 'entity.node.canonical', ['node' => $this->node->id()]),
    ];

    foreach($prepared_data as $data) {
      $links[] = Link::fromTextAndUrl($page_title, Url::fromUserInput($dummy_data));
    }
    return $links;
  }

}

The crumbs are shown properly as:

home >> My Title >> page_1 >> page_2

But page_2 is the current page, so it should not show as a link


texts: How to create multiple option field for product display?

texts: I am trying out the Commerce feature (bulk product creation), but the result is that the product has only one option list with all internal options. I want have more multiple options list with relative options, in the picture below you can see what I want to have in the product display: