texts: My data content type does not appear as an option on my 'Add content' page

texts:
I have just created a new content type for my site, and wrote a few rules which act when an instance of that type is created.  I went to create a few test instances of my new content type and noticed that it did not appear on that 'Add content' screen (mysite/node/add.)  'No problem' I thought, 'I'll just go to mysite/node/add/new_type.' However, this failed to work too.  The page loaded as as the url I submitted, but it appeared to be a duplicate of mysite/node/add.  This is a problem because I can not add new content of this type.

I have a few other content type that do not appear on the mysite/node/add, but this was never problematic because I could still create new content of that type by visiting mysite/node/add/some_other_type.

I found that I can create new instances of this content type using Development: Generate Content (and the rules work just fine.)  Still, I have yet to figure out why I cant get to the creation page manually.
What could be causing this?

Edit ===================================

A newly added content type (just called test with no other changes or fields added) does not appear either (even with all permissions set to 'registered user').


texts: Project issue tracking: How to assign issues to users?

texts:
In my Drupal 7 installation I am using the module Project issue tracking together with Organic Groups (every project is a group).

How is it possible that every member of each group is able to assign an issue to any other member of that group? At this moment every user can assign an issue only to him/her self or may set it to ›unassigned‹.


texts: How to write a view of a user signed up nodes?

texts: There is a content-type (event) with signup enabled. I want to show, on a user profile, the events this user has already signed up. I am having several frustrations with the signup relations and arguments. Is this possible with the current 2.x release?


texts: How to cancel added product to cart if previous order has same commerce-product creator id

texts:
I need this rule on before add product to cart react event, not after save commerce order.

I need when user (buyer) klick second button add to cart (for multi order), system check the product creator id first, if the product creator id for the second order clicked is same with previous (where is actually on cart) system cancel the previous clicked order.

With this scenario I want to limit order only from same product creator for one times order. So if buyer want to continue order from different product creator they have to do after first order completed.

Any suggest how to solve this using rule??


texts: How to load and display a view with Ajax in Drupal 7?

texts:
This is the first time I've ever tried to load a view using Ajax in Drupal7 and I would be appreciated if you help me from scratch. I've spent hours to learn how to do this but I still failed!

I created a view called image_gallery, it has three blocks called hd,tablet and phone and it displays set of images.I created a tab and I want to display and load these blocks (generally views) with Ajax. this my HTML:

HD

Tablet

Cellphone

                <?php print views_embed_view("image_gallery","hd") ?>

I set the Use Ajax to "yes" in the views UI. this is my jQuery code:

$("#image_gallery_tab ul li").click(function(){
        var id = $(this).attr("id").slice(-1);
        $(".igc").css("display","none");
        if(id==2)
            {
            $.ajax({
                url: Drupal.settings.basePath + 'views/ajax',
                type: 'POST',
                dataType: 'json',
                data: 'view_name=image_gallery&view_display_id=tablet', // Pass a key/value pair.
                success: function(response) {
                  $("#igc2").innerHTML=response.display;
                },
                error: function(data) {
                 alert('An error occured!');
                }
              });
            }
    });

but it displays nothing. what is wrong here and what shall I do?
thanks


texts:
When I insert an image into content area it's usually larger than the content area and the pasted image overlaps with neighbouring blocks. I have to edit HTML and set width and height CSS properties.

Is it possible to configure Drupal for automatic image resizing (shrinking), so the creator of the article will only upload the image of arbitrary size?

thank you


texts: SQL error after using Feeds Import with Taxonomies

texts:
I have been using intensively the Feeds module. After many imports of data doing test, I sometimes get the following error message: ´SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry taxonomy_term-32591-0-0-und' for key 'PRIMARY'

Can I clean the database in such a way that I will no longer have this error message? Of course, when it happens, the taxonomy terms are not imported. After deleting the Feeds and importing again, it goes perfect, but the problem happens from time to time.

I don't think I have many extra modules which will store taxonomy tid's on them, so maybe the problem is with the core database tables, but I cannot find where there are still rows to be deleted manually to solve the problem.

Because the data are already corrupted, I pretend to manually repair the integrity of database (or with the help of a module) without having to look for a previous backup, which would imply losing hours of work done on other sections (and thus tables of the database).


texts: Cannot add content to panels pages (stuck in overlay)

texts:
When I try to edit the content of panels pages, I click the add content link in the drop down menu an  drag and drop down menu. The progress indicator appears and turns for a while and then nothing happens. The screen remains with the semi transparent overlay (screenshot below).

Also, drag and drop for reordering the content does not work.

Assuming it is related with an ajax call I checked the chrome console but there seems to be no error.

I am using:
panels 7.x-3.3
ctools 7.x-1.3
jQuery v1.8.3
jQuery UI 1.8.7
jQuery UI Draggable 1.8.7
jQuery UI Droppable 1.8.7

I have been searching for hours now but could not find a related post anywhere.

Any ideas?

(a note: I do not have firebug or facebook modules installed. they are reported to cause a similar problem)


texts: How can I, in Drupal, install a project that have 2 different websites(frontend) but share the same backend? Is it possible?


texts: Exported configuration with drush cex only visible in docker shell, not in local repo

texts:
I have a Drupal 8 local development environment running with Docker. I can use drush (use drush cr, drush cex -y etc) after I login with ssh in docker.

I make some configuration changes in my Drupal admin. After that I want to export them to my config sync directory configuration/base (which is tracked by Git)
I use drush cex -y to export my configuration. I get the message: Configuration successfully exported to configuration/base

But after a git status I don't see any changed files? Also when I look at my yml-files in my local git repo (in configuration/base), I don't my changed configuration? But when I look in the shell (from where I also use drush), I see my changed yml-files. But there my local git repo isn't tracking those files.

So what do I have to do, after I do a drush cex -y, to get my changed exported configuration visible in my local git repo?


texts: sites/drupal folder not pushed to git repository

texts:
My .gitignore in the drupal root is as follows:

# Ignore configuration files that may contain sensitive information.
sites/*/*settings*.php

# Ignore paths that contain generated content.
files/
sites/*/files
sites/*/private

When I pushed it to a repository on github, the sites/default folder did not get pushed.

How to solve the issue?


texts: How to set node default language (or avoid language neutral) without Content translation module

texts:
I both have nodes that need to be translated (using Entity Translation), and nodes that need to have a single language (which we are discussing here).

Because of some incompatibility between Entity and Content translation, I cannot enable "Content translation" and "Multilingual content".

Also, even if it was possible, all I really want is not linking translations of different nodes and the other features that come with Content translation.

I just want to let users select the node language when creating/editing a node without having the "Language neutral" option, or select language by default (based on current page language).


texts: Is incremental auth supported on OAuth2 Server module?

texts: I'm working on a project where I would need to use OAuth2 server module and I've searched through the source-code of the module to check if incremental auth is supported i.e. adding scopes to old and valid tokens but couldn't find support for that. So, is there support for this feature in the module? And if someone has previously worked on adding that feature to the module; what was the work-around?


texts:
Please any one help me to how I can do customizing User/Registration page in Drupal 7. For example I have a select option for user group, suppose if I choose 'others' option ’ then user is allowed to create new group in separate text box.

I'm new to Drupal. Please anyone help me


texts: Get node ID that field belongs, in field.tpl.php being displayed in a block on any page

texts:
I have a 'Gallery' content type that has an entity reference field, which I use to reference other nodes of the 'Gallery Item' content type. When creating a 'Gallery' I use the nodeblock module to automatically create a block with this content.

So when I place this block in any page, let's say the homepage, I have it displaying the 'Gallery' title and a body on top, and below that, each 'gallery item' using the 'rendered entity' field formatter.

What I also need, is to somehow display the node id of each 'gallery item'.

I've tried editing the entity reference field template by creating a custom field.tpl.php template for it, but I can't find a way of accessing the node ID of each corresponding item.

Please help!


texts: How do I remove a module JavaScript file through a theme?

texts: I need to remove a JavaScript file added from a module through a theme. How can I achieve this?


texts: How to add css classes to modal forms module

texts:
My Problem

I'm trying add CSS classes to help me style the modal forms created using the Modal Forms module.

I have a User Login and a User Register form at the moment, but they have no form specific CSS classes.

Example 1

To style the height of the input boxes:

I either have to use "form-text" in <input> which will edit all form inputs across all forms or "edit-name" which will become "edit-name--1" if the user fails to login and the break the css.

    <input id="edit-name" class="form-text required"
    type="text" maxlength="60" size="25" value="" name="name">

Example 2

To alter the labels "username & password" the only tag I can work with is edit-pass

    ...

Which will change edit-pass--x every time they fail to complete the form correctly, resetting the css.

How would I insert CSS classes using hook form alter?

What I've tried

I printed out the array for the user login form (using print_r, can't use dpm because have to be logged in and user login won't work if you're logged in), here's the first chunk of it.

Array ( [name] => Array ( [#type] => textfield
                          [#title] => Username
                          [#size] => 25
                          [#maxlength] => 60
                          [#required] => 1
                          [#description] => Enter your drupaltest2 username. )

        [pass] => Array ( [#type] => password
                          [#title] => Password
                          [#description] => Enter the password that accompanies your username.
                          [#required] => 1 [#size] => 25 )

        [#validate] => Array ( [0] => user_login_name_validate
                               [1] => user_login_authenticate_validate
                               [2] => user_login_final_validate )

        [actions] => Array ( [#type] => actions
                             [submit] => Array ( [#type] => submit
                                                 [#value] => Log in ) )

I tried inserting

[#class] => 'TEST';

into [name] and other slight variations but none of them work.  I can give more examples if I've explained this badly.

EDIT -- RajeevK Solution -- Not enough granularity

I added the following lines into my alter form:

Name array:

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

Pass array:

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

And the end results looks like this:

This is what the page looks like (I'm using firebug to show what the div contains).

Or if I select CAPTAINTEST it looks like:

Hopefully this will help some though and cheers to RajeevK for the suggestion. I was hoping to control individual elements of the forms, does anyone know whether it would be possible to get more granularity without having to hack the module?

(Here's my form alter:

function mytheme_form_user_login_alter(&$form, &$form_state, $form_id) {
  //override to change text in user sign in box
  drupal_set_title('');
  $form['name']['#title'] = 'Username/Email';
  $form['name']['#description'] = '';
  $form['name']['#prefix'] = '
';
  $form['name']['#sufix'] = '
';
  $form['pass']['#description'] = '';
  $form['pass']['#prefix'] = '
';
  $form['pass']['#sufix'] = '
';
  $form['actions']['submit']['#value'] = 'Sign In.';


texts: How can I create a new page template for the user registration page?

texts:
I am a beginner in Drupal. I need to create a new page template for the registration page. Because in my website almost all pages have different layout.

Currently all pages are rendering through page.tpl.php.

Any suggestions?


texts: How to Add a quertystring to a link using jquery

texts:
I have a set of links on my page and some of them start with /mypath, like this

I need to add a querystring to the links that start this way, so the result is something like  with the '1234' being the node id of the node we're currently viewing.

I've sucessfully passed the nid into my js file using drupal settings.  The only part of this I can't get to work is putting the original link in where you see the second attr('href').

My code is as follows:

    $('a[href^="/mypath/"]').attr('href', attr('href') + '?parent=' + Drupal.settings.nodeinfo.nid);

Instead of that second attr('href') I've tried a number of things and can't figure out what it should be.


texts: Using Views in Drupal 7, I have listed certain fields of profiles (eg. Name, Job) and then link each field to the relevant profile. Now I am wondering how to link the fields to the relevant profile. I appreciate your hints.


texts: How to clear Text in search box once the user selects other option

texts: I have created a view for to search my channels. But when user searches for a specific channel, and when he clicks any other option or on any other event,he redirects to other page but text in search box is not cleared,what i want is, the text in search box should get cleared once he clicks on other option.How can i do this??


texts: How to expose edit link on editable areas for all authorized users?

texts:
The ideas is that in Drupal 7, on mouse hover on a node (or block) a edit link  appear at top corner of the node (or block), just like  the cog that appears for admin when s/he hovers on editable areas.

By exposing the the edit link on hover, we can create a much better user experience, for users that are not necessarily familiar with Drupal backend. I appreciate your hints.


texts:
I got hook in my *.modules file php_invoke_preprocess_node that should print data from JSON according to node type. I need to print it to node content everytime i run it but now it runs only once and print it at the top of the site and then it won't run until I clear cache.

function php_invoke_preprocess_node(&$variables) {
$node = $variables['elements']['#node'];
//check content type
switch($node->getType()) {
  case 'nodeType':
    $session = getSession('','');
    $data = ['additonal JSON headers'];
    echo (CallAPI($data, $session)); //return JSON array that i want to print to node but i dont know how
  break;


texts:
I have a view of nodes.  I'd like to be able to select rows (thinking VBO is the best) and pass those selected nodes to a form (specifically /node/add/payments) to pre-populate entity references.

Any thoughts on how to do this?  I've been playing around with several options and can't figure it out.


texts: Display Google Map after entering address?

texts:
Trying to find an easy way to do the following:

1) Visitor enters their address in a form field
2) Google map display's their address on the page

Does not seem to be an easy way to accomplish this in Drupal 7?


texts: How to put the Bootswatch theme locally?

texts:
I  am using this sub-theme
and I can't find any help.

bootstrap-barrio-installation

barrio-starter-kit

I am currently using Bootswatch Flatly in CDN mode. I want to put everything locally.
Here is what I did:

I ran the following 2 commands on my server :

mkdir -p web/libraries/bootstrap
cp -R vendor/twbs/bootstrap/dist web/libraries/bootstrap

I modified the bootstrap_subtheme_front_office.info.yml file :

name: Bootstrap Subtheme Front Office
type: theme
description: 'SASS starter kit for a Bootstrap Barrio SubTheme.'
# version: VERSION
core: 8.x
core_version_requirement: ^8 || ^9
base theme: bootstrap_barrio

libraries:
  - bootstrap_subtheme_front_office/bootstrap
  - bootstrap_subtheme_front_office/global-styling
libraries-override:
  bootstrap_barrio/global-styling: true
  bootstrap_barrio/file: true
regions:
  navigation_collapsible_first: 'Navigation (Collapsible first)'
  navigation_collapsible_left: 'Navigation (Collapsible left)'
  navigation: 'Navigation'
  navigation_collapsible_right: 'Navigation (Collapsible right)'
  navigation_collapsible_second: 'Navigation (Collapsible second)'
  breadcrumb: 'Breadcrumb'
  header: 'Top Bar'
  sidebar_first: 'Primary'
  highlighted: 'Highlighted'
  help: 'Help'
  content: 'Content'
  sidebar_second: 'Secondary'
  footer: 'Footer'

# Information added by Drupal.org packaging script on 2020-10-11
version: '5.0.2'
project: 'bootstrap_subtheme_front_office'
datestamp: 1602444143

And I modified the bootstrap_subtheme_front_office.libraries.yml file :
global-styling:
  version: VERSION
  js:
    js/popper.min.js: {}
    js/bootstrap.min.js: {}
    js/barrio.js: {}
    js/custom.js: {}
    js/back-to-top.js: {}
    js/copy-to-clipboard.js: {}
  css:
    component:
      css/style.min.css: {}
  dependencies:
    - core/jquery
    - core/drupal
bootstrap:
  js:
    /libraries/bootstrap/dist/js/bootstrap.bundle.min.js: {}
  css:
    component:
      /libraries/bootstrap/dist/css/bootstrap.min.css: {}

I downloaded the 4 Bootswatch Flatly files to my computer:

I copied the 4 files in the folder
/libraries/bootswatch/dist/flatly

I executed the gulp and drush cr command.

MY PROBLEM
How to declare Bootswatch? Where to put the files?


texts:
I have removed default css files using a code below, but still it is showing some unwanted css files

<?php
function _phptemplate_variables($hook, $vars)
{
 $css = drupal_add_css();
 unset($css['all']['module']['modules/system/system.css']);
 unset($css['all']['module']['modules/system/defaults.css']);
 $vars['styles'] = drupal_get_css($css);
 return $vars;
}
?>

In firebug GOw.css is appearing I dont know from where, can anybody please tell me how can I resolve this?


texts: translate custom fields in the registration form

texts:
I've installed i18n and added some new fields to the registration form, but I can't translate these new fields.

If I create a view to list the registered users, the string I want to translate shows up in the Translate Interface, but it only works on that page with the users list. The registration form remains untranslated.

I am using Drupal 7.


texts: Passing NID argument from views to panelizer

texts:
I am working on a complex site using Views and Panelizer.

I am trying to use Panelizer to display Views generated data, filtered by NID, for each advertisement.

To do that, I created a view called Advertisements with a content pane called Display which takes an NID as a contextual filter.

The NID filter is set to Provide default value -> Content ID from URL.

With that I am able to preview the field data of an existing article node when I provide it's NID as an argument.

However I have problems beyond this point :-(

I find my View content-pane in the Views panes section of the content area of Article's panelizer area - but there is no preview.
This immediately suggest there is something wrong with the output.

This is confirmed when I save the configuration and visit an Advertisement node - my output does not display.

After some research, I return to Views and go into the pane settings -> argument input section. I set it to From context -> Content ID.

With the View saved, I return to my advertisement node to find the page still blank.

I am very stomped and a lot of time has been wasted on this.

Can anyone please advice what I'm doing wrong or missing.


texts: Subtract UserPoints from all taxonomy terms upon purchase?

texts: OK So i was wondering if someone could point me in the right direction. Currently I'm running User Points Module with UberCart in order to purchase items with currency or use points for purchases. Now i've managed to get the transaction to work as needed except for one small thing. The Ubercart API only allows me to subtract the purchase points from a single category like "General". Id like to subtract the points used to buy the product from ALL the categories the use has points in. Does anybody know a way this can be done?


texts: Javascript running twice when not logged in

texts:
I have this issue that any custom js (added into theme.info file) script file is runned twice. However, I noticed that it will be runned only once if I am logged in. This happens in Drupal 7.

What is the cause?

The js script is a clear only having alert("Entered js file");

Also it is not added twice in the info and also looking into source code not there twice either.

The function is triggered while nothing rendered on page and second time when all DOM elements are loaded.


texts:
Recently I created a new Content type and Added a bunch of CCK fiekds in it. After that I migrated some contents to the system using node_save() function.

Everything was fine until I cleared the cache then 3 of my existing views broke and started to say "Views Broken/missing handler" in some of the fields and in filters. Though the fields do exist as the CCK fields in the proper content type.

See the attached image
When I try to remove or modify the field then it says "An illegal choice has been detected. Please contact the site administrator." Also the field formats is not show. Refer to the below image.
These fields though exist in the CCK as per the below image.
To make the site working again I have to go to the Content type's Manage Fields page and click on save. Then it starts to show in proper way (Followed: https://drupal.org/node/624826). The problem is if I clear cache then again this happens.
I had backed up the database before the migration and once I saw this then I DROPPED the total database and again imported the sqldump in the blank database but then again once I cleared the cache it again showed Broken/missing handler.

I am totally confused here. Searched Google but didn't got a proper solution. After dumping the old database still its happening. Is it that Views and CCK is storing something while I created the CCK? We are using Memcache in the system, but I suppose that has nothing to do with it.

Please help me on this.


texts:
I'm running Drupal 7, and I've cleared the cache through drush many times (drush cc all). I'm trying to access any subsequent pages beyond the front page and it results in a "Object not found error" error.

Does anyone have any idea? I feel like it's most likely an Apache or site configuration issue but I can't figure out what it is.


texts:
I was wondering how I am able to find the position of an item in a views pager?

I have nodes listed using views (with pager, 20 every page), and I'd like to find out for example where in the pager one node is?


texts: vbo action to reset back to default value

texts:
Text field's default value is set using field_default_token and it is working fine. There are several nodes present prior adding default value and needs to be set in bulk(no input is required again as value is already available in field settings).For this how I can use VBO.
default value for field in field instance is set to

[node:field-year][node:nid]

Referred this link for code

$form['bundle_item']['field_name'][LANGUAGE_NONE][0]['value'] = <how to get default token here>

Update:
another example

Let say there is a content type Professors with basic fields like name,expertise_in etc and some contents are created with these fields.
Later another field is added called Prefix whose default value is set to Dr. From now onwards all new content created will have the prefix field value set to Dr and thats fine. Now I want to set value of Prefix(which are empty) for the contents created in step 1 but without giving user option to set value of prefix instead it should retrieve default value which is set in the Prefix field settings ie Dr.


texts: How to programmally add nodes with next nid?

texts:
i want to create multiple nodes (from csv file) the csv is loaded well, and my table node contains many old records (with nid from 1 to 170) what i want is to record the csv's new nodes with nid strating from the last one on table node (the new nodes would start from 171 on nid)
I've tried db_last_insert_id() with no success.

This is my db_merge part :

 $nodes = db_merge('node')
        ->key(array('nid' => last_insert_id()))
        ->fields(array(
            'type' => 'livre',
            'uid' => 1,
            'status' => 1,
            'comment' => 1,
            'promote' => 0,
            'title' => $new_array['titre_csv']<===from csv
        ))
        ->execute();


texts: How to debug views_handler_field_node_revision handler?

texts:
I believe I have updated some of my modules, then the following debug message pop on the calendar page. Does anyone know what is this message and how to solve it?

  Debug:

    'Handler views_handler_field_node_revision tried to add
    additional_field nid but node could not be added!'

  in views_handler_field->add_additional_fields() (line 142 of
  /public_html/sites/all/modules/views/handlers/views_handler_field.inc).


texts: Is safe to EMPTY all cache tables directly from database?

texts:
Possible Duplicate:
  Can any of the cache_* be emptied safely?

I have following cache table, is safe to EMPTY them form phpMyAdmin?

cache
cache_block
cache_bootstrap
cache_field
cache_filter
cache_form
cache_gravatar
cache_image
cache_mailchimp_user
cache_menu
cache_metatag
cache_page
cache_path
cache_token
cache_update
cache_views
cache_views_data


texts:
For clever auth users who know you have a drupal site, they can type in "node/add/whatever" into your site and the page, "Create Content" pops up with all the links to the content that user is allowed to create.

I wish to hide this specific page. I found one way, not too practical, though. You would theme the "page-node-add.tpl.php" to redirect to 404, but then you need to manually add page-add themes for each content type for those links to work. Ugh.

I think the best way is to create some theme function to read if the page title is "Create Content" then redirect to 404.

Does anyone have any insight? Code? Cheers!


texts: How to use AJAX form on custom maintenance page

texts:
I have been working to customize our maintenance page via custom template and hook_preprocess_maintenance_page(), the intent is to provide the maintenance message, some static text, as well as a basic AJAX form that allows the user to select a state, and then a specific location in that state, once they submit they will then be passed to the appropriate location outside of our site.

This is how I am handling the form:

in hook_preprocess_maintenance_page()

$vars['maintenance_header'] = $vars['content'] ? "
" . $vars['content'] . "
" : "
System Maintenance
";
$vars['maintenance_content'] = "
Don't go anywhere!
";
$maintenance_form = drupal_get_form('ajax_example_simplest');
$vars['maintenance_join_form'] = drupal_render($maintenance_form);

in maintenance-page.tpl.php

<?php print $maintenance_header; ?>
<?php print $maintenance_content; ?>
<?php print $maintenance_join_form; ?>

In building the form I noticed that when the Ajax callback fires, the contents of $vars[maintenance_header] is printed to an alert window on the screen, instead of the page being updated as I expect. To validate if this was an issue with my form specifically, I grabbed the simple ajax example which is linked below, and the behavior is exactly the same.
https://api.drupal.org/api/examples/ajax_example%21ajax_example.module/function/ajax_example_simplest/7

In searching for questions around this I continue to find general ajax questions, and questions about theming the maintenance page, but nothing that covers using an ajax form within the maintenance page, so I have started this new topic to see if others have encountered this specific issue. I am wondering whether an ajax form simply won't work on a custom maintenance page or if this is related to how I am handling the form in the preprocess hook?

Thank You,
Rose


texts:
I have a View and it's based on a query and I'd like to modify the query that it is based on. What is the best way to do this?

More specifically, the query generated by Views is like this:

SELECT blah, blah, field-repeating-date, field-startdate, blah blah
FROM etc. etc.
WHERE this, that and the other
ORDER BY field-repeating-date ASC, field-startdate ASC

and I'd like the query to be:

SELECT blah, blah, IFNULL(field-repeating-date, field-startdate) AS thedate, blah blah
FROM etc. etc.
WHERE this, that and the other
ORDER BY thedate

in order to be able to mix the two date fields and have them sort properly. The modified query does what I want when entered through phpMyAdmin.

I'm using Drupal 7 with Views 3.

Edit:
I did find a solution, but I can't post an answer for another 3 hours because I do not have a reputation here.


texts: How can we create configurable product in ubercart?

texts:
I am creating an e-commerce website using ubercart and Drupal 7. I have created attribute size and color for the product from the  "Administration » Store » Products" and assigned to product.

I have also used search api and facet api module to generate facet search. I have created a views page to display product listing of search index product and showing facet block in that page.

Now, the problem is that I want to display product attribute as filter in the above product listing page. I have searched on google but did not find any solution for that.

Can any one suggest me?

Thanks in advance for your help.


texts: How to create a menu option with HTML in its title from a module?

texts: HTML in a menu option would be very useful from a module too, i.e. inserting an image as a menu option. Is there a way to do use something like function MODULE_preprocess_menu_link(&$variables) inside a module, and not in template.php?


texts: Which drupal hook to implement to react on module installation?

texts:
I have module A installed that defines some custom hooks. Module A wants to be notified when another module B is installed, so that it can inspect and see if module B implements its hooks (for building a cache of some info for example).

Is there a hook like "hook_module_enabled($module_name)" ?


texts: How can I render the output in a certain language in a Twig template?

texts:
I am trying to override the titles of the nodes on my view page for Drupal 8. As my whole website is in English, but only on one view page I need to fetch the french translation of the titles, without translating the whole interface.

For this I am overriding the views-view-field.html.twig template with custom views-view-field--my-view--title.html.twig.

In the preprocess function in MYTHEME.theme I am sending the language = 'fr':

function MYTHEME_preprocess_views_view_field__MYVIEW__title(&$variables) {
  $variables['language'] = 'fr';
  $variables['#cache']['contexts'][] = 'route';
}

The Twig template receives the language, but still displays titles in English. This is how my Twig template currently looks like. How can I say to fetch output in French?

{{ output }}

UPDATE:

thanks to Kint sub-module I could get all possible . Now I need to fetch the right translation.

How can I reach french translation? I have tried already few options:

{{ row._entity.title.value.translation('fr') }}
{{ row._entity.title.value.fr }}
{{ row._entity.values.title.translation('fr') }}
{{ row._entity.values.title.fr }}

None of them is working.
As I can see the values is an array, then it should be some special may accesing the elements inside


texts:
-Term 1
   --Term 1 Sub 1
   --Term 1 Sub 2
     -- Term 1 Sub 2 Sub 1
     -- Term 1 Sub 2 Sub 2
 -Term 2
 --------------------
 -------------

This is my Taxonomy structure. I need to build a taxonomy list in views.

http://mydom.com/gallery/term-1  // this will list the next level of taxonomy.
http://mydom.com/gallery/term-1/term-1-sub-1 // this will list the next sub level

etc like that. Can you please suggest one good way for doing this


texts:
I need to provide a backend user with a fieldset to enter technical data, such as value (in an editfield) and unit (selected from a dropbox). Instead of the default row-based layout such as in:

Value: [editfield]
Unit: {dropbox|values}

I would like to provide:

Parameter name: [value editfield] {unit|list}

While I know I could set up a suggestion template for that, does anyone know of the easiest way to re-position the fields? Display Suite?

Artur


texts: Displaying Token Field Labels From Fetched Entity In Rules HTML Email

texts:
I am sending a MIME HTML email using rules.  Much of the information contained in the email comes from a fetched custom entity (custom ECK entity).  Using the available replacement patterns, I can get the fields from the entity I need to print. However, I'm wanting both the label and the value from the field to display in the email.

I have the Token view mode active for this particular bundle, and the field name visible inline, but in the email, nothing but the value appears.

Hard-coding the label isn't really an option, as I'm dealing with about 15 fields, which will not always be completed in every entity, and I don't want an empty label to show.

How can I get the label to display as well?

Specs/Versions: D7.43, Rules 2.9, Token 1.6, DS 2.13


texts: Display the amount of the order on the block cart

texts:
do you know how to display the amount of the basket next to the number of elements?
As this page http://demo.commerceguys.com/cart

thank you

/**
* Returns the title of the shopping cart menu item with an item count.
*/
function commerce_cart_menu_item_title() {
global $user;

// Default to a static title.
$title = t('Shopping cart');

// If the user actually has a cart order...
if ($order = commerce_cart_order_load($user->uid)) {
// Count the number of product line items on the order.
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$quantity = commerce_line_items_quantity($wrapper->commerce_line_items,             commerce_product_line_item_types());

// If there are more than 0 product line items on the order...
if ($quantity > 0) {
  // Use the dynamic menu item title.
  $title = format_plural($quantity, 'Shopping cart (1 item)', 'Shopping   cart (@count items)');
 }
 }

return $title;
 }


texts: Correct way to import an RSS feed and display it in a view?

texts:
I have an rss feed (facebook) (can also be output as a json). I want to import the RSS feed and have it display using a view.

I already have the Feeds module installed and the Feeds: Facebook Parser installed. I think I have everything I need but I can't figure out how put it together. Seems like this is a common need just not sure how to put the pieces together to make it happen.


texts: Why the label of "subject' field in comment-form not be translated and how can I do the translation in a better way?

texts:
In the baseFieldDefinitions of Comment Entity, the subject field is set to be translatable, but I can not find such a translation in User interface translation(admin/config/regional/translate) that can make it take effect when comment on a content.

$fields['subject'] = BaseFieldDefinition::create('string')
  ->setLabel(t('Subject'))
  ->setTranslatable(TRUE)
  ->setSetting('max_length', 64)
  ->setDisplayOptions('form', [
    'type' => 'string_textfield',
    // Default comment body field has weight 20.
    'weight' => 10,
  ])
  ->setDisplayConfigurable('form', TRUE);

I now use the code to translate it in my module:

function mymodule_preprocess_form_element(&$variables) {

  if (\Drupal::routeMatch()->getRouteName() == 'entity.node.canonical') {
    if($variables['label']['#title'] == 'Subject') $variables['label']['#title'] = t('Subject');
  }
}

I don't think it's a good way since the translation is already defined.(And I've defined Hook_Comment_presave, this two function seems will effect each other,which I don’t want it happen either.)

Is there a better way to do that?


texts:
I tried to use a Drupal project which was previously developed by another person.
I have imported the database as well.

When I try to run the website, I get this error:

  Fatal error: Call to undefined function webform_menu_load()

I tried to remove progressively all the modules I have, but it's not working.

Does anyone know how to resolve this?


texts: How to integrate a private Google Calendar?

texts:
My client is a counseling center that would like to use Google Calendar to record and manage confidential information when clients schedule appointments online.  The catch is that they want it to be a private Google Calendar.

Is this possible?

Can a private Google Calendar be embedded with a drupal site?


texts: How do you deploy a change to a main menu?

texts:
We have a small D7 site. We want to deactivate a main menu item.
On dev server I was able to deactivate it in /admin/structure/menu/manage/main-menu

I believe The menu is stored in the DB, right. Also in a config file? So you only need to deploy those two things and it is done.

Is that correct? If not, what are the steps to deploy a main menu change?


texts: Is there a way to partially rebuild the router or invalidate a route cache?

texts:
I'm using the Groups module (http://dgo.to/group) to set up groups on a SaaS project I'm working on. I've set up a domain field on the groups, allowing groups to have vanity domain. As such, groups can have custom front pages, which are shown at site route. The front page is set as a field on the Group entity. For example, group 1 may set their front page path as /page/1 and group 2 may set it as /page/2.

To show this front page, I'm using inbound URL processing, showing the different paths on the different domains. To get the different paths to cache independently, I've overridden Drupal\Core\Routing\RouteProviderRouteProvider::getRouteCollectionCacheId():

  /**
   * {@inheritdoc}
   */
  protected function getRouteCollectionCacheId(Request $request) {
    $cache_id = parent::getRouteCollectionCacheId($request);

    // Get the current domain.
    $domain = $this->currentPath->getRequestStack()->getCurrentRequest()->getHost();

    $cache_id .= ':' . $domain;

    return $cache_id;
  }

I've got this all working, however I ran into an issue in that when the path to the front page of a group is updated, the page content doesn't update until the router is rebuild.

I did find a solution, rebuilding the router in hook_entity_update() using \Drupal::service('router.builder')->rebuild(). This works, but it seems very heavy handed.

I tried finding a way to invalidate the cache tags for the route using the cache tags invalidator, but I could not figure out which cache tags to pass.

So my questions are:

Is there a way to partially rebuild the router, rather than rebuilding the whole thing? Or...
Is there a way to invalidate the cache for a route?


texts: How to change all hyperlinks in the content

texts:
Hi i am new to the drupal and i got problem in my site in the hyperlinks.
I have book copy module by which i have created one copy of the book.
After creating the book i set aliases to content/newbook but the links in the content pointing to the old links they have not updated so i need some module which can change all hyperlinks in the content.
I have tried with views/pathauto/pathlogic/path filter but not able to solve  the problem any of these.
Please let me know if there any such module.


texts: Let the user change language with a select

texts: I need to let the user change language with a select. I need to do everything by hand because i'm putting that in a custom block. Do you have any idea on how I can accomplish that?


texts: How do I change the delta values using a hook?

texts:
I have a view getting all fields from nodes that have a relationship with the viewed node (using delta = all); it then only shows one node using CSS styles.

How do I change the delta value for every request and take its value as an argument from the URL?

I reloaded the page from JavaScript when the user needs to see the next field (using pager controls).

Which hooks does the Views module provide to edit that value?


texts: Why would an error persist after after uninstalling the module?

texts:
I created a module for Drupal 8 and when I try to add it to the menu it throws this error

 Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Route "hello_world.content" does not exist.") in "core/modules/toolbar/templates/menu--toolbar.html.twig" at line 36."

everything fell apart after this.  All of my site was unreachable because of an error page.

I tried removing the module and clearing the cache and the error is still there.  What do I have to do to fix this error?


texts: Why file extension validator does not work?

texts:
Created this based on doc comments: http://api.drupal.org/api/drupal/includes%21file.inc/function/file_validate_extensions/7
My upload field definition:

   $form['xml'] = array(
        #'#title' => t('Upload Document XML'),
        '#type' => 'file',
        '#description' => t('We process only XML files'),
        '#upload_location'    => "public://documents/",
        "#upload_validators"  => array("file_validate_extensions" => array("xml")),

    );

But every file type passed in...

Any suggestions, please?

Am I doing it wrong or I should call file_validate_extensions directly inside validation function


texts:
I am trying to use the Drupal 8 Modal API to output a link in a modal window - using the "Simple Link" approach here.

When clicking my link, I get a little animated spinner and I can see the response being returned via ajax using my browser inspector. However, no modal appears? There are no errors output to the console.

I am using a custom theme - is there some mark up I must place in the theme, to act as a container for the modal?


texts: how to add multiple tables in hook_schema() in .install file while creating custom module?

texts: Is it possible to add multiple tables in hook_schema() while creating a custom module? I have created a custom module with the help of Drupal entities. Will it be possible to store two different table in the modulename.install file?


texts:
I am trying to set the status of an uploaded file to 1 but looking in the file_managed table it stays 0. The file does get uploaded properly but gets removed after a while.

My form field:

$form['nor'] = array(
  '#type' => 'file',
  '#title' => 'Upload pdf',
);

And my function:

function mymodule_addForm_submit($form, &$form_state) {
  $nor = file_save_upload('nor', null, 'public://docs');

  if ($nor){
    $nor->status = FILE_STATUS_PERMANENT;
    file_save($nor);
  }
}

Debug of $nor:

stdClass::__set_state(array(
 'uid' => '1',
 'status' => 0,
 'filename' => 'my_file.pdf',
 'uri' => 'public://docs/my_file.pdf',
 'filemime' => 'application/pdf',
 'filesize' => 57930,
 'source' => 'nor',
 'destination' => 'public://docs/my_file.pdf',
 'timestamp' => 1363198206,
 'type' => 'default',
 'fid' => '148',
 'field_license' =>
   array (
     'und' =>
       array (
         0 =>
           array (
            'value' => 'nothing',
           ),
       ),
   ),
  )
 )

What am I doing wrong here?


texts: Full name field on node using Display Suite

texts:
I am using Display Suite for layout and arrangement of nodes. I would like to display the full name of a node author (a field I have added to the user entity). Display Suite will only show the author username.

How do I display the full name field on a node, instead of the author username?


texts:
I have a media entity target id and I want to render the image contained in it. I've loaded the media entity using Media::load, I was hoping to use something like render() on some rendererable array that I can extract/generate from that media entity object.
I found a somehow related question here: How to get Media entity image (Entity Reference Field) URL in TWIG theme, using ImageStyle::load, but I want to render the whole image with its defined attributes (alt, title or fields). Any suggestions please?


texts: How to add validation on 'next' button using fieldgroup module

texts:
I am creating a multiple page registration form using the field group module and
I want to add validation on 'next' and 'previous' buttons.

If the first page's field is empty, the user can not go to next page they show some alert or message.
I am using jquery but not successful with it.


texts:
Currently I have a boolean field field_private_content, if that field is set, the content should only be shown to authenticated users, anonymous users may only see the teaser and a login form. So far it's working well, also with views where I added the filter on that field. The filter get's removed automatically by the implementation of hook_views_pre_view() in a custom module:

function custom_module_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  // Remove filter on field_private_content != TRUE for authenticated users.
  if ($view->getHandler($view->current_display, 'filter', 'field_private_content') && \Drupal::currentUser()->isAuthenticated()) {
    $view->removeHandler($view->current_display, 'filter', 'field_private_content');
  }
}

Although that works very well, the behavior is not obvious from views ui. I would prefer to have a duplicate of the field_private_content filter which should have the mentioned behavior by default and could be labeled properly - the original filter should keep it's original behavior.

How can that be achieved?

How to add a custom views filter handler for a specific field?


texts: How can I access a node's menu link and weight through EntityFieldQuery

texts:
In D7, I'm trying to set up a custom menu that is ordered by the weight of the node->path ("weight" field in table menu_links). How can I access the node's path's weight value in my query so it can be ordered correctly? This is what I had but was shot down very quickly:

    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')
    ->propertyCondition('status', 1)
    ->fieldCondition('field_meeting', 'value', $meetid, '=')
    -> propertyOrderBy('weight','ASC')
    ->addMetaData('account', user_load(1)); // Run the query as user 1.
    $result = $query->execute();


texts: Drupal 7 : Tons of HTTP requests from Media Vimeo module

texts:
I am using the Media module

And two of its sub-modules - YouTube and Vimeo

As a result - front end page for some reason sends 4 HTTP requests for each Vimeo video on the page and they totally slow down page loading - http://snag.gy/dKEjv.jpg

Question :

If there is somebody familiar with these modules or with Vimeo API - could you explain what are these requests for?


texts: How to replace links and embedded image references after migrating of content

texts:
I want to import content from a legacy system into Drupal using the migrate module. The URL structure is going to change.

Some of the content has links pointing to the old content and there are also embedded images with soon to be outdated links.

After migrate is done I'll have a mapping from old urls to new urls and should be able to run a custom script. This script would check for all nodes with old urls and replace it with the new urls and then just node_save() it.

Is this a good approach or is there a better solution?

Btw, I'm also planning on setting up a simple php site under the domain to 302 redirect old urls to the new url.


texts:
I would like to show a table of products. I grouped them by nid. In the table header views shows me the nid. Instead of this, I would like to add fields of the node to be displayed once like: node title, image, price.

I attached two illustrations:
Screenshot 1: This is what Views shows me.

Screenshot 2: This is what I would like to have


texts: User login block doesn't appear for authenticated user

texts:
Well, I go to structure/blocks/User Login/configuration and I tried select all checkboxes in "Show block for specific roles" but login form doesn't appear when user has status "authenticated".

How I can solve this issue?


texts: Unchecking a boolean field on form render

texts:
I have a content type that has a boolean field (checkbox) that editors need to always re-check on saving a new revision, if they want the value to still be true. Otherwise, it would be saved as false.

I'm using a hook_form_node_form_alter to modify the $form before the page is shown to the Editor.

public function my_module_form_node_form_alter(&$form, &$form_state, &$form_id)
{
   $form['field_my_boolean_field']['#value'] = 0;
}

I've tried something similar to the above and have also tried #checked and #default_value in place of #value but nothing seems to work. The checkbox always renders checked (as it is saved in the database). How can I uncheck this boolean field when the form is rendered? Note that I do not want to change the actual value of the field for this node, just make it unchecked in the UI when the form for this content is shown.


texts:
I currently have a content type that is keyed by its organic group's gid, but I am trying to make a contextual filter based on nid. Is there is relationship to get the gid from the nid directly?

I could write a relationship to do that, but would that be a difficult task to do?

edit: gid is the group id of the organic group.


texts: Can I enforce required fields when creating a node programmatically?

texts:
I'm experimenting with creating content. I made a method to create a piece of example content and redirect to its edit page. I didn't set some fields that I had defined as required on the content type. I thought it would probably cause an exception, or at least generally not work, but it created the node without the required fields.

Is there a way to prevent a node from saving if any of its required fields are empty? I've read some about entity validation and started working with that a bit, but I don't want to reinvent the wheel if there's already some built-in setting or something that does that. If there isn't, is a validator the way to go?

class ExampleController extends ControllerBase
{

    public function create_example_content()
    {
        $node = Node::create(['type' => 'example_type']);
        $node->set('title', 'Example Content');
        $node->save();
        return $this->redirect('entity.node.edit_form', ['node' => $node->id()]);
    }
}

I did notice that not setting the title causes an SQL error, but it looks like that's different because the title is a column in the node record rather than a related field.

The redirect to the edit form is done just to debug the code and check the result of creating the node.


texts: Multi-site vs Large Single site for Intranet

texts:
Whenever I look at "Should I use Multi-site?", it always seems to depend on the use case. (I am using Drupal 7)

I have been developing a company's Intranet on a single Drupal install and it is getting larger and larger.

I have about 75 Content Types and over 500 fields.

The reason for the Drupal site having so many Content Types is to give each department access to manage nodes within specific content types. (Using Content Access).

There are also additional Content Types for workflows that are using with Rules.

I feel the greatest performance hit when managing fields on a Content Type.
Other than that, the site still runs smoothly.

In a situation like this where there are going to be so many more fields and content types added, does it make sense to use Multi-site instead? Or is it perhaps the specs of my Server that are causing the slowness?

It is convenient having everything on one site since I can have a unified Dashboard, not have to re-make the User groups/roles on multiple sites, etc.

In this use case, is it worth converting my structure to a Multi-site setup?


texts: Programmatic user registration not forcing user to activate account

texts:
I'm manually creating a user and then sending a notification email as follows:

$new_user = array(
  'name' => $username,
  'pass' => $password,
  'mail' => $email,
  'status' => 1,
  'init' => $email,
);

$account = user_save(drupal_anonymous_user(), $new_user);
 _user_mail_notify('register_no_approval_required', $account);

However, the user is able to login right away. How can I enforce account activation? I have it enabled in the admin panel


texts:
I have a question.
My site sells tours.
For each tour(product) a user can choose a flight  and some hotel rooms.
Example tour1:
user can choose: flight1 and flight2.
user can choose: double rooms and/or single rooms.
If the user choose flight1 then ->  double rooms costs 50, single rooms costs 100(a).
If the user choose flight2 then -> double rooms costs 150, single rooms costs 200 (b).
I have 3 dependent variation types(flight, doubleRoom, singleRoom). What I want is:
if the user choose flight1 I only show double rooms = 50, single rooms  =100 (rooms(a));
if the user choose flight2 I only show double rooms = 150, single rooms=200 (rooms(b)).
Flights and rooms have  a taxonomy terms called 'solution':solution1, solution2 ecc..
I think that a way should be use rules, with event 'After adding a product to the cart' but I can't write the condition('if flight  choose solution1') and the action(set visible=true where rooms solution= solution1).
Can someone help me please??
Thanks in advice


texts: How to change page title for admin users to easly find which admin page they are

texts: During development I need to work with modules, views, site configurations, nodes etc.. I open all of them in new tabs (browser). It would be much convenient to switch between tabs to choose desired page if page title (html title that displays in the browser) has name of the admin navigation link/name. I have set 'Seven' as admin theme. Is there any configuration available to enable this or I need to tweek code?


texts: Title in page does not change with different page of the same View

texts:
I have a View which displays a list of content. The content is paged, like this

http://www.exampple.com/en/products?product=all&brand=0&page=4

I keep the parameter page as exactly provided by default View pager. However, when clicking on different pages, the TITLE of the page does not change, it is "Products | WEBSITE_NAME" all the time. I would have expected the page number to be added automatically, as the site domain name is. For instance:

 "Products Page 1 of 3 | WEBSITE NAME"

Is there a module or a config to achieve this, or must I do it through a hook and drupal_set_title function in my custom module ?

The above different title for each page is necessary to avoid SEO penalization by Google and other seo bots.


texts:
I'm coming across what seems to be contradictory information, and I'm hoping someone here can clarify.  The basic question is "what is the correct folder structure for PSR-4 style auto-discovery of classes in Drupal 8, particularly test classes, and how much flexibility is there in that structure?"  (I apologize in advance about this, but I'm going to have to partially break up my question into comments, since I don't have enough reputation yet to post all the necessary links.)

I have run across the following conventions I'm about to list in subsequent comments.  I'm hoping someone can clarify what the proper layout is.  Or will all work?  I could spin up a D8 instance and test this, but I'm afraid such a cursory examination would conceal pitfalls of one approach versus the other, in terms of community support.


texts: Problem with submitting ajax form with autocomplete

texts:
I've been a newbie to drupal and trying to add feature to our corporate website (this module
called 'userpasswords2' searches database of local mailsystem passwords).
I'm using AJAX autocomplete and modification of the form.

AJAX autocomplete works fine, I can choose the user but I have a problem - I cannot submit the form by enter key. If I submit it by hittin 'submit' button by mouse, everything works fine. But I cannot submit it from keyboard.

I would like it to work like here https://api.drupal.org/api/drupal - user enters for example 'hook', chooses what he/she needs, hits enter, then hits enter again and get the result!

So again - clicking submit button works fine, hitting 'enter' key doesn't work.

Googled a lot, the workarounds I've found doesn't work for me. Please help.

function userpasswords2_menu() {
  $items = array();
  $items['userpasswords2'] = array(
      'title' => 'User passwords',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('userpasswords2_form'),
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
  );
  $items['userpasswords2/ajax_username_autocomplete_callback2'] = array(
      'page callback' => 'ajax_username_autocomplete_callback2',
      'type' => MENU_CALLBACK,
      'access callback' => TRUE,
  );
  return $items;
}

function userpasswords2_form($form, &$form_state) {
  $form = array();
  $form['user'] = array(
      '#type' => 'textfield',
      '#title' => t('Введите имя пользователя'),
      '#autocomplete_path' => 'userpasswords2/ajax_username_autocomplete_callback2',
      '#executes_submit_callback' => 'TRUE',
  );
  $form['box'] = array(
    '#type' => 'markup',
    '#prefix' => '
',
    '#suffix' => '
',
    '#markup' => '
',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#ajax' => array(
      'callback' => 'userpasswords2_callback',
      'wrapper' => 'box',
    ),
    '#value' => t('Submit'),
  );
  return $form;

}

function ajax_username_autocomplete_callback2($string = "") {
  $matches = array();
  if ($string) {
    $result = db_select('my_domain_passwords')
      ->fields('my_domain_passwords',array('fullname','password'))
      ->condition('fullname', db_like($string) . '%', 'LIKE')
      ->range(0,10)
      ->execute();
    foreach ($result as $user) {
      $form['custom']['username'] = $matches[$user->fullname] = check_plain($user->fullname);
      $form['custom']['password'] = check_plain($user->password);
    }
  }
  drupal_json_output($matches);
}

function userpasswords2_form($form, &$form_state) {
$form = array();
$form['user'] = array(
    '#type' => 'textfield',
    '#title' => t('Введите имя пользователя'),
    '#autocomplete_path' => 'userpasswords2/ajax_username_autocomplete_callback2',
    '#executes_submit_callback' => 'TRUE',
);

$form['box'] = array(
  '#type' => 'markup',
  '#prefix' => '
',
  '#suffix' => '
',
  '#markup' => '
',
);
$form['actions']['submit'] = array(
  '#type' => 'submit',
  '#ajax' => array(
    'callback' => 'userpasswords2_callback',
    'wrapper' => 'box',
  ),
  '#value' => t('Submit'),
);
return $form;
}

function userpasswords2_callback($form, &$form_state) {
  if ( (!empty($form_state['custom']['username'])) && (!empty($form_state['custom']['password'])) ) {
    $output_string = $form_state['custom']['username'] . " : " . $form_state['custom']['password'];
  } else {
    $output_string = "No such user: " . $form_state['values']['user'];
  }
  $username = $form_state['custom']['username'];
  $password = $form_state['custom']['password'];
  $element = $form['box'];
  $element['#markup'] = $output_string;
  return $element;
}


texts: Export and import configuration settings and content

texts:
I have created two sites. They have the same modules and themes available, however I want them to be complete clones of each other without doing a manual database export and import.

I attempted using Drupal 8's configuration synchronization but I receive the following message

The staged configuration cannot be imported,
because it originates from a different site than this site.
You can only synchronize configuration
between cloned instances of this site.

I've attempted using the Features module. But I don't see an option for exporting and importing to separate sites.

I've also looked at a similar question here Sync content between two Drupal sites
However that applies to Drupal 7.

Is there a way to import and export nodes, site settings, and configurations such as menu items and what modules are turned on or off from one site to another?

UPDATE: I've discovered that I might be able to use configuration synchronization if I get the UUIDs to match, but I'm having trouble running drush on my multisite. Is there a way to manually change the UUID in the database?


texts: How do I put a taxonomy term on a panel page?

texts:
I'd like to put several hand-picked taxonomy terms on a panels page, each term as a panels pane, showing their descriptions, with a more link to the term's view page, and maybe some of the fields that I have added.  Is there any module to do this?

Right now for each term I have to create a page, panelize it, add a view pane of the term to it, and then add the page to the panels I want them to show up. Seems to be working nicely enough but still too troublesome for ordinary editors to do it themselves.


texts:
i'm working on a project and all batch callbacks in http not https so instead of redirecting to https://example.com/batch?id=844&op=start redirect to http://example.com/batch?id=844&op=start, and as result query params get lost and redirect me after to https://example.com/batch which gives me a 403 forbidden page:

i have checked htaccess file and also the server i don't have any redirection.
anyone has experienced this, any help ?
EDIT:
I have checked the result of \Drupal\Core\Url::fromRoute('<front>')->setAbsolute()->toString() i get the url correct with the right protocol and also i have added:
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);

to my settings.php and again no luck.
Note: all redirections in the site works perfectly with https only this one!


texts: How to create more than 1 block with different .tpl (theme) file in a single module?

texts:
How to create more than one block with different .tpl (theme) file in single module in Drupal 7?

Suppose I have a module name mymodule, I want to create two blocks in this module name as myblock1 and myblock2 and these two block should be associated with different tpl file like block1.tpl.php and block2.tpl.php. and both blocks have same content.

Any help?


texts: Display Count of associated nodes as "more" in Calendar View?

texts:
I'm using the Drupal Calendar module to create a monthly calendar view. As is default behavior the monthly calendar shows a list of the days events on each day. I have the Format Settings set to only display one event and then a "more" link. I would like to have the total number of events for that day next to the "more" link.

I attempted to add a "nid:count" aggregated field but it only counted for each node (so it was always "1") not per day.

How can I show the total number of events per day?


texts: Drupal Services 3.x - Custom error output

texts:
Is there a way to control the output in the drupal services? Example, if a argument that is required, it not provided in the call, I get the following output as a JSON array.

Missing required argument title

I'd like to either override this output, or instead of returning a json object, just return plain text.

Is this possible to do?


texts: How to specify a patch for dependencies inside a module's composer file?

texts:
I would like to know how to specify a patch inside a module's composer file.

The scenario is like this:

On my Drupal 9 site, I want to run the command composer require module.
The module composer file, has dependencies and 2 modules specified there, are not yet ported to Drupal 9 but there have been patches created (not sure if the modules will be ported soon since they kind of seem a bit abandoned).

What I did, I modified the composer file of the module I want to install to look like this:

But, the patches do not apply so when I run the command composer require module I get told that google_analytics_reports is not D9 compatible. I am 100% sure that the patch I am trying to apply makes it compatible.
Not sure what I've been missing. If I apply the patch in the Drupal's composer, it works, but I want a standalone module.

If it helps, the error is just the generic one: module requires drupal/google_analytics_reports 3.0.0-beta3 -> satisfiable by drupal/google_analytics_reports[3.0.0-beta3]. (which requires D8 and so on)


texts: Drush command to uninstall from enabled...?

texts: Is there a command for Drush so I can uninstall a module from the enabled state?  I hate having to drush dis mymod -y (and) drush pm-uninstall mymod -y


texts: When using Rules, does a page refresh happen immediately if the event is set to 'Drupal is initializing'

texts:
I have several views pages set up on my site that filter the content that is shown to normal visitors.  In general, these views will show users content that they have created.  However, when an admin user visits one of these pages, I want them to see all of the content (created by everyone.)  Currently, I have a rule set up which will redirect all admin users to a different url which has a different view (with access restricted to admin users and no filters)  Functionally, this does want I want (all users click on the same menu link, but eventually reach different pages.)

I am wondering, does the rules redirect event happen before the first view is loaded?  I want for the redirect to happen as soon as possible to save server resources and load time.  So, If the redirect happens after the page is created, it would be better for me to change my navigation strategy.


texts: How to show a RSS feed button for aggregator node page

texts: I use the Aggregator module to display RSS contents. I want to have a RSS button along with the aggregator node, how can I enable or add the button to page?


texts:
I've been trying to create a post method in Drupal 8, I used the following code:

custom_rest/src/Plugin/rest/resource/CustomRestResourceUserCheck.php:

<?php

namespace Drupal\custom_rest\Plugin\rest\resource;

use Drupal\Core\Session\AccountProxyInterface;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Psr\Log\LoggerInterface;

/**
 * Provides a resource to get view modes by entity and bundle.
 *
 * @RestResource(
 *   id = "custom_rest_resource_user_check",
 *   label = @Translation("Custom User Check"),
 *   uri_paths = {
 *     "canonical" = "/api/v1/custom/user_check"
 *   }
 * )
 */
class CustomRestResourceUserCheck extends ResourceBase {

  /**
   * A current user instance.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

  /**
   * Constructs a Drupal\rest\Plugin\ResourceBase object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param array $serializer_formats
   *   The available serialization formats.
   * @param \Psr\Log\LoggerInterface $logger
   *   A logger instance.
   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
   *   A current user instance.
   */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    array $serializer_formats,
    LoggerInterface $logger,
    AccountProxyInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger);

    $this->currentUser = $current_user;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->getParameter('serializer.formats'),
      $container->get('logger.factory')->get('custom_rest'),
      $container->get('current_user')
    );
  }

  /**
   * Responds to POST requests.
   *
   * Returns a list of bundles for specified entity.
   *
   * @throws \Symfony\Component\HttpKernel\Exception\HttpException
   *   Throws exception expected.
   */
  public function post() {

    // You must to implement the logic of your REST Resource here.
    // Use current user after pass authentication to validate access.
    if (!$this->currentUser->hasPermission('access content')) {
      throw new AccessDeniedHttpException();
    }

    return new ResourceResponse("Implement REST State POST!");
  }

}

I have activated:

I tested this functionality in Postman but I get the following error:

Someone may know that something is wrong?

Edit 1

Drupal version: 8.1.9


texts:
My research
I have browsed some of the other similar questions asked regarding this but the fixes do not work for me so I figured I'd ask a new question in the hopes that I can help myself and hopefully others that have the same issue. I have also checked the drupal help forums which again does not fix my issue.

What I want to happen
This is using Drupal 7. I want to make it so that when creating a news article, I can upload files that can be downloaded when people view the page.

What happens when I try to do this
I have added the field successfully and when creating the page, I can upload the file and it shows in the preview. However, when I save the page, although the file shows as uploaded in the 'edit' side, it does not show on the public page.

What I've tried
Additionally, when checking in the files through FTP, the files gets uploaded to the sites/default/files/ directory. I have checked, double checked and tripled checked the permissions which I even set to 777 briefly so permissions doesn't seem to be the issue here.

I have tried commenting out some lines in the sites/default/files/.htaccess file which is one fix I found but unfortunately didn't work for me.

I have checked user permissions which, again, isn't the issue as I'm an admin with every permission checked.

I have also copied the exact settings from another website where this feature is working in case I missed something very simple but this didn't work either unfortunately. The file upload field is set to display and I believe that it's set up appropriately although it is possible I'm missing something extremely simple.

I'm more than happy to update my question with further information if anyone needs any more to help me out. I'm completely baffled on this one so any help would be greatly appreciated.


texts: why system/connect web services return nothing in drupal 7?

texts:
I have Drupal 7 with web services activated, but the system/connect resource returns a 404 Controller Not Found response. I was trying the user resource, and it works correctly. I tried using the following URL in my browser window, which does a HTTP GET:

https://localhost/drupal/x_login/system/connect

where x_login is the endpoint.


texts: Change attributes order in Drupal Commerce

texts:
So I have a shop on Drupal commerce with a few products. I have a size option with a price variation (XL, L, M, S), this is a taxonomy vocabulary. Everything was okay with the bulk add products.

But then we've decided that we want to show the smallest product first instead of the biggest. So I've changed the taxonomy order but I guess as the product SKU was created from the largest to the smallest, by default the XL is still selected.

Is there a way to change this order or do I need to manually overide the SKU (1 would be the smallest then) ?

Thanks


texts: How do I find the default value or change state of a form element?

texts:
I'm putting together a fairly complex form with Drupal 8 (currently building on beta 7). In my validation function, I need to be able to detect whether a field, which was populated with default values, has changed.

In Drupal 7, this would have been pretty straightforward. I could dig into the form_state array and find the appropriate default_value entry and compare it to the submitted value.

But now that form_state is an encapsulated object, I don't see an obvious way to get the default value.

I know I can kluge this if I need to, by including hidden fields in the form itself with the default values. But I know that the information is in the form_state object: if I print_r form_state I can see both the old and new values--but not in any way I can figure out how to access using the methods listed in FormStateInterface.

Bottom line: in Drupal 8, how do I test whether the submitted value of a form element is the same as its default value?


texts: How do I make custom entity create new revision by default?

texts:
I made a custom entity that extends RevisionableContentEntityBase. I can use the web interface to create entities. If I edit an entity and check the box Create new revision then a new revision will be created. There is no configuration form available to set the default for Create new revision.

The custom entity is quite simple. It has a few base fields and was built using drush generate module-content-entity.

How do I make my custom entity create a new revision by default?


texts: Change content color based on Date Range

texts:
I am building a website using Drupal 7, Views, Rules, Ctools, Panels, etc.

I need to change the content color based on the date. The idea is that each quarter's reports have a different color to make them easier to sort over the life of the student.

Any ideas on how to achieve this?


texts: Change table to divs on imagefield values unlimited

texts: Is it possible to output the Image Field values so that it doesn't use tables but divs?


texts:
Drupal cron is running every 10 minutes in my site but i have set-ed 1 day time for cron,
i have cleared cache and fix all the major php error logs, please help me how to fix this issue.


texts: Show a term description when the search filter in a view is that term?

texts:
I have a content type that has several vocabularies. Nodes can have 0, 1, 2 or all 3 terms selected.

Ive added a field to the terms so they all have a description as well as their name.

Color (vocabulary)

-Red (term)
  --This has red items (term description)

-Blue (term)
  --This has blue items (term description)

-Green (term)
  --This has green items (term description)

Pattern (vocabulary)

-Stripy (term)
--This has stripy items (term description)

-Spotted (term)
--This has spotty items (term description)

-Pinstripe (term)
--This has pinstriped items (term description)

I have a View of nodes of the content type. I'm using Better Exposed Filters so you can filter by the different terms. I need it so when you have selected a single term its description is shown at the top of the view.

So if you checked 'Red' and 'Stripy', or 'Blue' 'Spotted' and 'Pinstripe', then no description would be shown. But if you just checked 'Blue' then 'This has blue items' would be printed at the top of the view before the nodes tagged with 'Blue' were listed.


texts:
Is there a developer tool, module, or code snippet that will show all the menu items currently configured in a Drupal system?

If not, would it be "safe" to invoke the menu hook myself to collect this information?  In other words — do individual menu hook listeners (implemented by module developers) alter system state in such a way that invoking the menu hook twice during a page request would be a "bad thing".

Newish to Drupal, not new to programming. I'm specifically interested in a programmer's view of the menu.


texts: How to disable page redirect on node edit?

texts:
Thank you for reading my question.

I have a node type and all I want is it not to redirect to the node on edit submission.

Currently, when on the node edit page submissions are sent through ajax, however when the node is submitted it also redirects to the node page, making the ajax pointless :( ...

How do I stop the edit page redirecting on submission.

Thanks for any help


texts: How do I print a link only if it doesn't lead to access denied

texts:
My nodes have fairly complex permissions set on them.  I want to display a small edit link on the teaser for a specific content type, only if the user has the permissions required to edit that specific node.  I already customise the display with the file node--newsletter.tpl.php

I tried:

<?php
$quick_links['quick-edit'] = array(
    'title' => 'Edit',
    'href' => 'node/' . $nid . '/edit');
?>
<div class="links quick-edit-links">
    <?php print theme('links', array('links' => $quick_links, 'class' => 'links inline')); ?>
</div>

But that prints out the edit link no matter what.  What's the correct way to do this.  Ideally I'd like to have a solution that is reasonably generic and works for practically any link (e.g. node/id/delete, or admin/)  So I can use it elsewhere, but a solution which only works for this specific case would be OK.


texts:
I am working with the module Better Exposed Filters (BEF) within my view. I have about 12 exposed filters, some of theme are select lists and some are range sliders. Some filters thematically belong together which is why I try to visually group them under a headline. Unfortunately, this can't be done using BEF.

I also tried Views Exposed Groups but this module can only be used instead of BEF, not together (I need BEF because of the slider funcionality). Besides I tried MEFIBS (More Exposed Filters in Blocks) which isn't suitable for me too.

Does somebody know of another module that helps me to accomplish this problem?

PS: I am no coder so editing the exposed-form.tpl.php is the last option for me.

Thanks,
Thomas


texts: Problem with SchemaIncompleteException when running BrowserTestBase

texts:
I am trying to run a test, which extends BrowserTestBase, on my module. I got the following error:

Drupal\Tests\my_module\Functional\BasicTestCase::testMyModule
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for
field.storage.node.field_tsc_language with the following errors:
field.storage.node.field_tsc_language:settings.language_range missing schema, field.storage.node.field_tsc_language:settings.included_languages missing schema, field.storage.node.field_tsc_language:settings.excluded_languages missing schema, field.storage.node.field_tsc_language:settings.groups missing schema, field.storage.node.field_tsc_language:settings.maxlength missing schema, field.storage.node.field_tsc_language:settings.allowed_values_function missing schema

field.storage.node.field_tsc_language is a language field I have added to a content type. I don't understand why it is asking me to create a schema, but anyway I have done it, creating the my_module.schema.yml file inside my_module/config/schema/.
field.storage.node.field_tsc_language
  type: config_object
  label: 'Langue de la société'
  mapping:
    settings:
      type: mapping
      label: 'Settings'
      mapping:
        language_range:
          type: integer
          label: 'Language range'
        included_languages:
          type: sequence
          label: 'Included language'
          sequence:
            type: string
            label: 'Language code'
        excluded_languages:
          type: sequence
          label: 'Excluded language'
          sequence:
            type: string
            label: 'Language code'
        groups:
          type: string
          label: 'Groups'
        maxlength:
          type: integer
          label: 'Max length'
        allowed_values_function:
          type: string
          label: 'Function name'

I have tried other schemas, but in all the cases I get the same error.
I have created this schema based on the following field.storage.node.field_tsc_language.yml file.
uuid: 59d14613-4a21-4d99-88b9-8adad83ca7f7
langcode: en
status: true
dependencies:
  module:
    - languagefield
    - node
id: node.field_tsc_language
field_name: field_tsc_language
entity_type: node
type: language_field
settings:
  language_range:
    1: '1'
    11: 0
    12: 0
    2: 0
    site_default: 0
    und: 0
    current_interface: 0
    authors_default: 0
  included_languages: {  }
  excluded_languages: {  }
  groups: ''
  maxlength: 12
  allowed_values_function: languagefield_allowed_values
module: languagefield
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false


texts: How do I change the salt used for the user password when creating an account?

texts:
I am working on Drupal 8 site where the client has asked us to use their own custom salt when storing the user password in the database.

Is it possible to set a custom salt for a Drupal site?

The client is thinking of the feature from a security perspective. What can be done?


texts: Is there a way to create a "Digg" like site in Drupal. Basically I want to create a site based in "social voting". The users should be able to vote on specific items and based on this "democratic" behaviour the popularity of that particular item would be determined. I did come across a module "drigg" but was not too impressed with it. Any other alternatives ?


texts: How do I access datetime field formatter node values?

texts:
The DateTimeFormatterBase class is performing a ->setTimeZone incorrectly for my use case. How do I access the node values from where the $date passed to setTimeZone originated? Strange question I know, but I need to get to an entity reference field value to find the right time zone for the date.
Simple use case that I can't make work:
3 Fire Station nodes in Content Type FireHouses.
1 Content type Alarms with entity reference to FireHouses.
Station#, Address, City, Timezone
Station 1, 123 Main St, New York City, America/New_York
Station 1, 321 Any St, Chicago, America/Chicago
Station 1, 567 Hollywood, Los Angeles, America/Los_Angeles

Alarms come into all 3 stations at the same time (let's say just after midnight in New York) and Drupal sets Authored On field to same UTC time on all 3 Alarm nodes.

Views Report with Grouping by City:
New York:
  Fire at 987 street, 2019/01/25 12:01 am
   .
   .
Chicago:
  Medical Emergency, 2019/01/24 11:01 pm
   .
   .
Los Angeles:
   Fire at 567 Hollywood, 2019/01/24 09:01 pm
   .

This really simple use case/report fails because Drupal provides System Timezone, User Timezone, Field Display widget TZ (whole entity, not node level), Views TZ override and none apply here. 3 alarms, each in a different time zone but at the same time and I've found no way to override core functionality at the FormatterBase level because I can't traverse up (from $date) to the FireHouse entity level to get the correct TZ to provide to $date->setTimeZone function. Inside PHPStorm I can see the memory cache with node ids that I could use to get back to the FireHouse but I can't access them in code. My module must override core at this level so all displays of a date anywhere in the application are for the local time where the incident occurred.


texts: I am using custom module to insert and rendering data from Drupal Database.Is it possible rendering data using  theme table in my custom div block


texts: Show multiple term references as ID in one row

texts:
I've got a view of nodes, displayed as fields. As each node may have references to multiple terms/tags, I would like to show all these tags.

When I use field "term_node_tid", then I get the multiple values properly displayed in one row separated by commas. But instead of the readable term, I need the term-IDs.

So I set up another field using "tid", but now only the ID of the first term is shown. There's no multiple value field setting, where I could tweak things. Any help much appreciated.


texts: Am I able to call functions in my custom module from other modules?

texts:
I would like to integrate the Barcode (http://drupal.org/project/barcode) module functionality into a custom shipping module that I am creating.

I would like to make calls the genBarCode method or something similar so I may generate barcodes within my module.

Is this ok within the context or custom/contrib modules and if so how can it be done?


texts: How to hide page title based on node type using template_preprocess_page()

texts:
I am trying to hide the title of the current page (as printed by page.tpl.php) if the current page is 1) a node in full display (as opposed to teaser mode), AND 2) the node type is either concert or bio. I print the node title for these content types directly in the node content, so I want to hide the duplicate being printed by page.tpl.php. I am not able to get this to work directly in page.tpl.php, and my reading suggests the best practice is to handle template logic in template.php using preprocess and process functions. So, I am trying to hide the current page title (with the above 2 conditions) using template_preprocess_page(). This is my code.

<?php
    function MYTHEME_preprocess_page(&$variables) {
        if (!empty($variables['node']) && $variables['node']->type == 'concert') {
            hide($variables['title']);
        }
    }
?>

I read How do I test for node type to print a variable from template.php? and the documentation page for template_preprocess_page(), and various other sites, but I just can't seem to get this to work. I saw suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that didn't work either. I didn't see a clear solution posted anywhere, and I'm at my wit's end.


texts: Commerce - delete products that do not reference a node

texts: I want to delete commerce products that are not referencing nodes. Either a delete process or report that shows which commerce products are not referencing nodes.


texts: Htaccess 301 redirects after switching language detection method

texts:
We have a multilingual Drupal installation with a domain for each language. Like this:

domainexample.com
domainexample.no
domainexample.de
etc...

We want to switch to a single domain and use domain prefix instead:

domainexample.com/en
domainexample.com/no
domainexample.com/de
etc

Settings this up through Drupal administration is no hassle - the problem is that the old domains should redirect to the new one.
My guess is that this should be possible with some sneaky htaccess. I'm no expert here however.
I currently have:

RewriteCond %{HTTP_HOST} ^domainexample.de$ [OR]
RewriteCond %{HTTP_HOST} ^www.domainexample.de$
RewriteRule (.*)$ http://domainexample.com/de/$1 [R=301,L]

...which works for the frontpage - but not for the subpages. They get redirected to this 404 page: domainexample.com/de/index.php.

How can this be solved?

/Morten


texts:
I have Drupal 7 site. I am using Memcache for caching.

This is how I am storing the JSON into it

    //creating an object of Memcache
    $cache = new Memcache();
    $cache ->addServer('localhost', 11211);
    //adding a key
    $cacheKey = 'mobile';
    //delete old cache
    $cache ->delete($cacheKey);
    //refresh cache
    $cache ->set($cacheKey, serialize($jsonData));

No issue till here. But when fetching the JSON from this cache.

returned JSON fails to validate

I am using http://jsonlint.com/ to validate my JSON.

Please note the however the JSON has correct data but issue is validation.

$Records = $cache->get($cacheKey);

echo '<pre>';
print_r(Records);
exit();

JSON

{
"defaults": [{
    "nid": "213",
    "public_url": "http:\/\/www.mywebsite.com",
    "HTMLStr": "layout and user interface.\
    r\ n\ t
    http: \ /\/mywebsite.com<\/a><\/p>\r\n"
}]

}

Any help highly appreciated.


texts:
We are migrating from Drupal 7 to Drupal 8 and are currently at the last hurdle - relying on Drupal's session to authenticate for custom scripts.
Previously we used to rely on drupal_bootstrap but now I have implemented a similar Drupal 8 aware version for bootstrapping and checking the user is authenticated (and which roles they have etc) - this is broadly based on core/authorize.php.
However - this only works in the drupal root directory or the core/ directory - in every other directory this fails to authenticate the user.
I believe this is down to the routing, and authentication only working for pre-defined routes.
Specifically I want to be able to authenticate users in any script in a folder (recursively). EG

external_scripts/script1.php
external_scripts/script1.php
external_scripts/other_scripts/script3.php

How do I add a route to allow this? Or can I just bypass this route checking when using the cookie? Can I spoof the route?
<?php

/**
 * @file
 * Locates the Drupal root directory and bootstraps the kernel.
 */

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\Routing\Route;

function _find_autoloader($dir) {
  $autoloadFile = $dir . '/vendor/autoload.php';
  if (file_exists($autoloadFile)) {
    return include_once($autoloadFile);
  }
  elseif (empty($dir) || $dir === DIRECTORY_SEPARATOR) {
    return FALSE;
  }
  return _find_autoloader(dirname($dir));
}

// Immediately return if classes are discoverable (already booted).
if (class_exists('\Drupal\Core\DrupalKernel') && class_exists('\Drupal')) {
  return \Drupal::service('kernel');
}

$autoloader = _find_autoloader(empty($_SERVER['PWD']) ? getcwd() : $_SERVER['PWD']); // defined in start.inc
if (!$autoloader || !class_exists('\Drupal\Core\DrupalKernel')) {
  print "This script must be invoked inside a Drupal 8 environment. Unable to continue.\n";
  exit();
}

const MAINTENANCE_MODE = 'update';

try {
  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $kernel->boot();
  $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
  $request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
  $kernel->preHandle($request);
  if (PHP_SAPI !== 'cli') {
    $request->setSession($kernel->getContainer()->get('session'));
  }
}
catch (HttpExceptionInterface $e) {
  $response = new Response('', $e->getStatusCode());
  $response->prepare($request)->send();
  exit;
}

\Drupal::moduleHandler()->addModule('system', 'core/modules/system');
\Drupal::moduleHandler()->addModule('user', 'core/modules/user');
\Drupal::moduleHandler()->load('system');
\Drupal::moduleHandler()->load('user');

$content = [];
$show_messages = TRUE;

$account = \Drupal::service('authentication')->authenticate($request);

if ($account) {
  \Drupal::currentUser()->setAccount($account);
}

var_dump(\Drupal::currentUser());


texts: How to redirect a user to previous page after successful login?

texts:
I have added flag links to content pages for anonymous user. When user clicks on that link, the user should be redirected to user login page but after successful login the user should be redirect to last visited page.

I have used this code of a previously posted thread:

<?php
  global $user;
  if(!$user->uid) {
  // $flag: bookmark or make_feature, $action: flag, $content_id: $nid.....
  $flag_link = flag_flag_link($flag, $action, $content_id);

  $flag_link = flag_flag_link($flag, $action, $content_id);
  $flag_url = $flag_link['href'];

  //echo implode("/",arg());
    if(isset($flag_link['query']['token'])) {

      $flag_url .= '?'.$flag_link['query']['token'];

    }
  print l(t('SAVE '), 'user/login' , array('query'=> array('destination' => $flag_url)));
  print l(t('LIST'), 'user/login' , array('query'=> array('destination' => $flag_url)));
  } else {
    print render($content['links']['flag']);
  }

By using this code, anonymous user can redirect to login page but not to last visited page.


texts: Redirect to a specific tab in a page after node submit

texts:
I'm working on Drupal 8.9.6.
I'm trying to redirect users to a particular page after they add a node. I can do that without any problem, by adding the following information in the form's URL:
/node/add/author/edit?destination=/author-list

However, when I try to have a specific tab of the destination page opened, as follows:
/node/add/author/edit?destination=/author-list#tab2

It directly redirects me to /author-list, ignoring the #tab2 part. While if I enter in the browser /author-list#tab2 I get the /author-list page with the #tab2 active without problem.
Does anyone know what could be happening?
Thank you!


texts: CSS Mime Type transferred as Zip in Chrome - 15 second delay

texts:
Resource interpreted as Stylesheet but transferred with MIME type application/x-gzip: "http://www.energyjustice.net/modules/system/system.base.css?m7sb47".

I turned off the CSS aggregate and compress option, and emptied the Chrome browser cache.  So I'm not sure why I'm still getting this?

If there is nothing in the cache, this error causes Chrome to have a 15 second delay in transferring the system.base.css file.  Firefox works fine.

Drupal 7.14
Apache/1.3.41 (Unix) with mod_gzip/1.3.26.1a
Chrome 20.0.1132.57

It looks like mod_headers is installed.


texts: How to set up drush aliases for a local server for rsync?

texts:
I'd like to use drush to sync files from local server to production server. I have edited the aliases.drushrc.php file and placed inside /drush/aliases in both local and remote machines. Everything seems to work fine except that drush understands that both sites are in the same server since I do not know how to tell drush that local is in another machine in my local server.
I guess it's something to do with uri but I do not know what should I write there.

I've tried with this:

$aliases['local'] = array(
  'uri'  => 'mysite.localhost',
  'root' => '/home/user/www/mysite',
);

and this:

$aliases['local'] = array(
  'uri'  => 'localhost/mysite',
  'root' => '/home/user/www/mysite',
);

being mysite the name of the folder placed in /home/user/www in my local server, but none of them seem to work.

Anyone can tell me what am I doing wrong?

EDIT:

I have placed mysite.aliases.drushrc.php in my local sites folder.
However I didn't succeed with the following code in my local site:

drush rsync @mysite.live:%files @mysite.local:%files

This is what I get:

  You will destroy data from @mysite.local:/home/user/www/mysite/%files and replace with data from @carloscamara.live:/home/user/www/mysite/%files
  Do you really want to continue? (y/n): y
  The source and destination cannot both be remote.
  rsync error: syntax or usage error (code 1) at main.c(1166) [Receiver=3.0.8]

This is mysite.aliases.drushrc.php content:

$aliases['local'] = array(
    'uri'  => 'localhost/mysite',
    'root' => '/home/user/www/mysite',
    'path-aliases' => array(
      '%files' => 'sites/default/files',
     ),
     'command-specific' => array (
       'sql-sync' => array (
         'no-cache' => TRUE,
       ),

$aliases['live'] = array(
    'uri' => 'mysite.com',
    'root' => '/home/user/mysite';
    'remote-machine' => 'mysite.com';
    'remote-user' => 'myusername',
    'remote-host' => 'mysite.com',
    'path-aliases' => array(
      '%files' => '/home/myusername/mysite.com/sites/default/files',
     ),
  );


texts: What are my options to visualise a views table with many fields grouped in columns?

texts:
I have a view with 30 fields. Displaying its results would look best using a table, but with fields grouped in columns.

Default table in Views can't do this because there are to many fields.

So instead of what it looks now:

  field-1 header, field-2 header, field-3 header, field-4 header, field-5 header, etc. (with default field under each header)

I need:

  header1 I header2

  field-1 I field4

  field-2 I field5

  field-3 I field6

Any suggestions?

Notes:

It's something I would like to do on several views with a module or "simple" theming.
I tried the groupfield views module (broken when using table format, works great on html, unformated, etc.).
I tried DS views layout, but can't use CSS on each field on that one.
I'm thinking of Panels, but that seems like overdoing it just to get simple view display for my case.


texts: How does one keep a session alive across two different URLs?

texts:
I have the same drupal 7 installation running on www.mysite1.com and www.mysite2.com.

Most people redirect mysite.com to www.mysite.com, but doing so users logged in on a site aren't kept logged-in in the other site.

Since mysite1.com is running the same code as mysite2.com, I want the users to remain logged-in when switching from a site to the other one.

I assume Drupal stores the user's session ID, and when switching to the other site, the users get a new session ID, but surely there must be a way to make the two sites aware of each other, so that users are kept logged-in across two sites.


texts: How do I check radio buttons in Twig template?

texts:
In a form, I have this field:

$form['payment'] = [
  '#type' => 'radios',
  '#title' => $this->t('Payment Mode'),
  '#options' => [
    'chk' => $this->t('by check'),
    'tfr' => $this->t('by bank transfer'),
    'crd' => $this->t('by card'),
  ],
  '#required' => TRUE,
];

In the Twig template associated to the form, I'd like to show the field and some html stuff depending on the selected option. I tried this:

<form{{ attributes }}> {{ form.form_build_id }} {{ form.form_token }} {{ form.form_id }}
  <div>
    {{ form.payment }}
    {% if form.payment ==  'chk' %}
      You chose 'Check'
    {% elseif form.payment ==  'tfr' %}
      You chose 'Bank Transfer'
    {% elseif form.payment ==  'crd' %}
      You chose 'Card'
    {% endif %}
  </div>

But it is nor working!
Any idea?