texts: drush cex re-creates files in config/sync while they already exist in module config folder

texts:
Having a config split which says that the location/configuration of the split/module is located under /sites/all/modules/custom/module/config/optional

After it got imported with drush csim our_split one gets an drush cex preview which shows that the recently imported files will be now created again.
But they are re-created in the config/sync folder.

Any ideas how this could be fixed?


texts: How do I display category items in a view content pane?

texts:
I created an Events content type.
I created a vocabulary that has two category terms, Events and Plays.

I have a view that contains a list of all content of type Events.

Each Events listing displays with the category term as the title/link.

The link should go to a page that has a content pane (not a view page) containing a list of all of the Events with that tag.

I already have a page set up with two columns. When I click on any term in the list of Events, I want to navigate to this page (or an iteration of it, based on term selection), and one of the columns should contain the view pane with the view of events of just that category that was clicked on.

In other words, I want the destination of the term links to be a page containing the content pane of items of that category (i.e. not just a page view.)

So, the view looks something like,

Movie (term)

movieName

movieTime

Play (term)

movieName

movieTime

Movie (term)

movieName

movieTime

Play (term)

movieName

movieTime

Movie (term)

movieName

movieTime

The term field is configured to be a link.

If I click on Movie or Play I want to go to a page that has a content pane containing a list of all of the Events tagged with Play or Movie, depending on which I clicked.

On the view, I set up a Contextual filter:

Content: Has taxonomy term ID

I set up a Relationship:

Content: Taxonomy terms on node

How can I set this up so that clicking on the category will take me to another page with a column containing a view content pane that displays a list of Events based on that clicked tag?


texts: Why the function hook_form_alter doesn't work on admin forms?

texts:
In my custom module .module file I implemented hook_form_alter thus:

function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
        \Drupal::messenger()->addMessage('hook_form_alter found a form. It has the following name: ');
        \Drupal::messenger()->addMessage($form_id);
      }
    }

When I go to the homepage of my drupal installation it correctly finds the search_block_form, but when I go to, for example, mysite/admin/config/system/site-information the function finds no forms. Funnily enough, I know that there is a form on this page going by the name of 'system_site_information_settings'. Other admin forms don't get discovered either. Why is it? How to find the name of the site-information form other than by searching the internet?


texts:
I have a view that is shown in the footer of a theme (Lucid & Nodestream Features?). Since my task and scope is small, I do not what to change up everything - just use what is there. I want to show panelized node or a panel page in the header and footer of the footer view. I have tried "Entity: Rendered entity", but I just get the node's fields and not the panel layout & content.

How do I include a panel (3.3) in a view (3.7)? (not view in a panel)


texts: ubercart: finding order id when admin is editing order

texts:
I have a custom shipping quote module which adds freight costs to the orders admin comments:

$order_id = intval($_SESSION['cart_order']);
uc_order_comment_save($order_id, 0, t($shippingquote_text), 'admin');

This works correctly when the user goes through the checkout process.

Problem:
How do i find the order id when the admin is manually editing a users order?

For example: admin is on admin/store/orders/3845/edit and clicks get shipping quote button - which fires freight quote module

Want:
comment is saved to order 3845 w shipping quote details.

My answer below is valid for Ubercart 7.36 as the page doesn't use Ajax.
UberCart 7.38 Uses Ajax, and the same variable isn't available. Still looking for an answer


texts:
In Admin we have

http://domain.com/devel/php

I added query

$result = db_query("SELECT name FROM `users_field_data`");

print ($result);

It's not showing result. How to show that?


texts: Users cannot log in to new site in multisite

texts:
I am working with the Drupal multisite functionality. I have been asked to implement the following architecture:

mysite is a Drupal site with several angular pages.
mysite/backend is a separate site with a separate user store that mostly acts as a headless Drupal system. For political reasons, it is very important that the users in mysite/backend not be stored in the same database as the users in mysite .

Anyway, from what I have read about Drupal multi-sites, I have taken the following steps.

I started with a working site and performed the following steps to add a second one
Create a symlink, making the /backend a symlink to the web root:

ln -s backend .

Add entries to my sites.php (because with our deployment workflow, the site name cannot always match with the domain name. Also allows us to test with xip.io).

$sites['mysite.dev'] = 'mysite';

$sites['mysite.dev.backend'] = 'mysite.backend';

I created a directory named mysite.backend .
In mysite.backend, I created a directory corresponding to all directories in mysite.
In mysite.backend, I created the following settings.php file:

$databases = array (
   'default' =>
   array (
     'default' =>
     array (
       'database' => 'XXXXXX',
       'username' => 'XXXXXX',
       'password' => 'XXXXXX',
       'host' => 'localhost',
       'port' => '',
       'driver' => 'mysql',
       'prefix' => '',
     ),
   ),
 );

 $update_free_access = FALSE;
 $drupal_hash_salt = 'k_vtgGjzCyq0mp0dsxDk1gILuEs6G5ODP5aJuQsAUuc';
 $base_url = 'http://mysite.dev/backend';  // NO trailing slash!
 ini_set('session.gc_probability', 1);
 ini_set('session.gc_divisor', 100);
 ini_set('session.gc_maxlifetime', 200000);
 ini_set('session.cookie_lifetime', 2000000);

I go to /backend/install.php and go through the install process. Everything goes smoothly
I click the link to view the new site, and enter the admin login credentials (for the new site. I made it a point to have separate logins for each site)

My problem is that when I go to the /backend directory of my test site and log in with my credentials, I get the standard authentication error behavior if I login with an invalid username or password, but when I supply the correct credentials, I get redirected to /backend/node, but I see no indication of being logged in. If I try to go to the admin pages, I get an access denied error. I still see the login block. If I click the reset password link, I get a one-time login link in my email, but when I click it, I get a message that says that the link has expired.

Forgive me if this is too verbose or missing details. This seems to be a messy problem. Has anyone run into similar issues with Drupal?


texts: How to create an rss.xml feed on my Drupal 7 site?

texts:
I would like to set up an RSS feed on a new site, but having never done this before I am unsure of where to start.

I've got an rss icon on my page and I would like to create a http://demo.drupalizing.com/corporateclean/rss.xml equivalent which is available on this demo site:

http://demo.drupalizing.com/?theme=corporateclean

How do I do this?


texts: Exposed Views Combine filter not working

texts:
Exposed Views Combine filter is working fine for administrator role, But its showing "Page not found" when I am trying to access with authenticated user role. I rebuild the cache so many times and rechecked the permissions.

For authenticated user its showing result on :
    http://localhost/example/testfilter?combine=&title=abc

But showing "Page not found" on
    http://localhost/example/testfilter?combine=textdata&title=abc

Again for administrator , Both URLs are displaying correct result.


texts:
I have different REST End points in my Drupal 8 instance, some of them are exposed from REST Views and some are custom controllers. I have a situation where I want to maintain versioning with my end points.
I have replaced some fields in the new version and the users relying on the older API version must not be impacted by the change.
In the case of a controller, how can I manage different output for different API versions?
Also, in the case of REST Views, where the URL is directly exposed, how can new data be added to that?
For example, the /rest/taxonomy-list endpoint gives a certain set of terms as JSON output. In the new API version, I have to add/remove/replace one term which is present in same vocabulary.


texts:
I have a view that will display content (nodes) in a fields display having a multiple date field. Another filter is set to date:enddate > now.

What I want is just one row per node, but cant get it to work.

I've tried the following:
a) In the date field's "Multiple field settings" I set "All values in the same row" and "show 1 value(s)"
Did not work, no change in output

b) Under "Advanced - Query settings" -> Use distinct.
No changes in output

c) Adding a filter date:delta = 0
This will remove the duplicates, but because of my other filter (date:enddate > now) the row will also not show up

d) Use the module "Views distinct".
The problem here is that this module will filter away nodes that happen to have a date on the same day of another node, so there are others missing.

So I'm stuck here, do you have an idea how to solve this?

Drupal7

Thanks, Marc


texts: How to fix combination Dutch domain - English uri

texts:
In Google Webmaster Tools I have 60 non-existing combinations of my Dutch domain and the English original blog. Example:

http://website.nl/enlish-blog

The from English to Dutch translated blog exists.

This problem leads to a degraded customer satisfaction, as Drupal reports the web-page not to be found.

I have checked the Global Redirect property to correct this, and automatically replace the English link with the Dutch link. To no avail.

I tried to correct it in Path redirect, but also to no avail. It is not allowed, because the module interprets it as the redirection of an alias, and advises the alias to be corrected. This does not work, because then the English web-page cannot be found.

My questions:

How do I fix this?
Why did I get it in the 1st place?

Thanks for any comment or suggestion.


texts:
How can I fix this error?  I get an unexpected error has occurred when I try to create a new group in Open Atrium. I am pretty new to Open Atrium
, but experienced in Drupal. Here is the syslog error message I am getting when trying to create a new group.  Any help would be appreciated.

  OgException: OG membership can not be created in entity message and bundle oa_member using the field field_oa_message_space as the field does not reference oa_group bundle in node entity type. in OgMembership->save() (line 62 of..... /og.membership.inc).


texts: How do I get the content type of a node entity from the $entity object?

texts:
I'm using hook_ENTITY_TYPE_presave() to alter the values of nodes upon saving, but I only want to do this for a specific content type.

How do I check the content type of the $entity object?  I looked at the documentation for class node and working with Entity API, but all I found was how to get the entity type, not the content type.

Given a node $entity object, how can I check the content type?


texts:
I'm creating a custom module block that will sit in the sidebar on certain levels of my site template.

The site structure is: Home > Level 1 > Level 2 > Article.

I want Level 2 to echo out all of the child links (basically a menu tree).

I want to achieve this with hook_block_view(). How can I get the page's child links in the main menu, and put them in an array?


texts: What happens when multiple context conditions match?

texts:
I have a multi-site setup using multiple contexts:

Context A
  Conditions:
    - Path:  <front>
  Reactions:
    - Block: sidebar-left

Context B
  Conditions:
    - Domain:  Domain1.com
    - Path:  <front>
  Reactions:
    - Block: sidebar-left

Context C
  Conditions:
    - Domain:  Domain2.com
    - Path:  <front>
  Reactions:
    - Block: sidebar-right

My goal is for the more specific contexts to match first (B,C), and for the general context (A) to match all other domains.

My problem is that Context A is always being matched first for Domain2.  Is there a way to define the "weight" of each context, and force Context C to evaluate before Context A?


texts:
I am using Drupal 7 and trying to upload a file

function upload_service_menu() {
  $items = array();

  $items['api/v1/upload'] = array(
    'title' => 'File Upload Service',
    'description' => 'Upload files to public directory on this server',
    'page callback' => 'upload_service_job',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Function to get the path, download and store the file on our server.
 */
function upload_service_job() {

    $file = $_FILES;

    $validators = array();
    $file = file_save_upload($file, $validators, 'public://');
    if($file){
        echo "Sucess";
    }else {
        echo "fail";
    }
}

and my local form is

<form action="http://example.com/api/v1/upload/" method="post"
enctype="multipart/form-data">
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

But i am not able to upload file. Seems file_save_upload($file, $validators, 'public://'); function is not working .I checked permissions also..
Can anybody tell me what to do.

Thanks


texts: hook_custom_theme() works except if a user submits a user form with mismatched passwords. Then they get served the admin theme

texts:
Title basically. My hook_custom_theme() has been working for ages and I only just realised the admin theme is being served for an error when saving a user form ie. mismatched passwords.

A snippet from the top of my function:

function custom_theme_change_custom_theme() {
    global $top_bar_color;
    $top_bar_color = '#2b3643';
    if (strpos($_SERVER['HTTP_HOST'], 'example.com') !== false) {
        switch (returnRoleForTheme()) {
            case 'old': $th = 'theme_1'; $top_bar_color = '#2b3643'; break;
            case 'young': $th = 'theme_2'; $top_bar_color = '#6dad19'; break;
            case 'kid': $th = 'theme_3'; $top_bar_color = '#6dad19'; break;
        }
    }
    return $th;
}

Any ideas on how to force the theme like for every other part of the website? Why would this page in particular revert to Adminimal?


texts: How to get Panels to override node with "no extras"

texts:
I'm having a problem with the node/%node use of Panels. I would like to display the body content of a node in one pane and all the extra fields which I have added into the content type in another.

The problem I'm hitting is the "no extras" option in the Pane settings makes no difference - all the fields (body and extra fields) are always displayed.

Searching around the web, nobody else seems to have this issue. Since it is what panels is supposed to be good at, I think I'm missing something. I've tried using the panels wizard and doing this manually. I had it working in Panels 1 in D5 :(

I'm using D7 and Panels 3.

Any suggestions gratefully received!

Edward


texts:
What way should I use to load a file from a module?

I am writing a module which is divided into 3 parts

Custom core will be in the module which contains basic functions required for project
Custom notification section will handle the notifications to show on site (It has a section on site where user can see all notifications.)
Custom mail will handle mail (Users will get email on each activity.)

So I have now a module file and 2 include files, but I am confused on how to include them in .module file.

There are 3 different methods available, but I am not sure which one is best and what the major differences between them are.

require_once drupal_get_path('module', 'custom_module')
files[] = mail.inc
module_load_include('inc', 'custom_module', 'mail.inc')

I tried them, and they all are working fine for now; I don't have much experience to guess future issues.


texts: Creating a tag list in a view of multlingual nodes

texts:
I am creating a multilingual site in English and Swedish on Drupal 7.

I have a content type called ‘News’ which has a taxonomy term field that categorises the news posts. I have the content type set up with ‘Multilingual support’ set to ‘Enabled, with field translation’.

The views at /en/news and /sv/nyheter are working to the extent that they only show news in the users language. However, I can’t work out how to create a tag list in a block that shows the taxonomy terms for the users language.  i.e. when I am at /en/news I get a block which shows only English tags, (e.g. Fundraising (4), Events (2), Membership (2)) and and when I am at /sv/nyheter I only see Swedish tags (e.g. Insamling(4), Evenemanger(2), Medlemskap(2)).

What Translation mode should I use for the taxonomy?

What settings (fields, filters, relationships, etc.) should I use in the view?

Is it possible to create a view with two paths, one of the Swedish /sv/nyheter and one for the English /en/news?

I can provide more details on how I currently have it set up if necessary, and am also up for changing how it is set up to get it working. If you can point me to examples of this working with a views export and details of how you have the taxonomy set up that would also be really handy.

Thanks!


texts: Views Page Not Appearing in Search Results

texts:
Using the views module, I've created a page (view) that contains a certain content type. This page doesn't show up when searching the site.

Is this expected behavior? Is there any way to make the page show up in a search?

Instead of creating a page view, I've created a block view and added it to an actual page (content). This works in my particular case and allows the site to index the page to show up in a search. It may not be fancy but I don't have to add a module to make it happen.

Thanks to user cilefen who answered my questions and got me here.


texts: Limit number of upload in Imagefield depending on a specific field

texts:
On my website, members can pay for 3 different offers (Gold, Silver, Bronze). I would like to limit the number of pictures a member can upload, depending on the offer he picked.

I'm using Drupal's user_form and add an "Imagefield" field, with illimited upload.
Offers are 3 taxonomy terms, and all contain a field with the max number of images allowed.

I'm able to get the amount of images allowed, from the taxonomy term, but how would i go about applying that limit to the imagefield?

Thanks a lot!


texts:
I'd like to know, how could I render links to video sites like youtube and vimeo as a video, the way Facebook does when a user simply pastes a link.

The other modules or solutions I've found involved embedding videos as a field requiring users to go through a process like the one from Embeded Media Field module does. The closest one is the Video Filter module, but it still more complicated that Facebook.

I'd like this feature over because I'm implementing this for a forum and I'd like to make it as simple and familiar (since everyone uses Facebook) as possible.


texts: I have been developing a site and I feel that it would work really well as a Drupal distribution. I have no idea about how to create one, but I am familiar with drush make, install profiles etc. What is a Drupal distribution and how do I release one? What are the main benefits?


texts: how to display a link on a node view page?

texts:
I want to display a link on a node view page just like the "Add new comment" link.
How should I do this?

I think it can be done through hook_node_view(),  but how can I use this hook?


texts: How to send auto email for new unapproved comments?

texts:
How do I config to send auto email for new unapproved comments.

I enabled the comments module and anonymous user can create comments in some content types.

But, I want to receive in an specific email acount a notification for each new comment.

Any suggestion ?


texts: Override page.html.twig with custom module template

texts:
I want to override the page.html.twig template from a custom module. I know how to create a suggestion, but I would like it to find the template file in my custom module.
function promo_accc_theme_suggestions_page_alter(array &$suggestions, array $variables) {
    $suggestions[] = 'page__promo__accc';
}

I'm not sure what I would need to do from here to get Drupal to look in /custom/modules/promo_accc/templates.


texts: What do I put in the drupal 7 commerce Checkout Completed Rules: Send Email field to display all of the order data?

texts:
Currently I have the following below in my completed checkout send email settings. But when i receive the emails on a completed order, I'm still missing some data even though I have it set there. Would someone please paste their completed order send email setup?

See below as it only shows the SKU reference #'s.

One main issue I'm having is for these tokens:

[commerce-order:commerce-line-items] -- Only gives the Product ID number and nothing else

[commerce-order:commerce_line_items] -- Displays "No line items found".


texts: How to modify the image output for just one content type using Responsive Images?

texts:
There is a field_image (image) field on the basic content type. Using the Responsive Image, we enabled it on the Default view mode for the field_image field using a Responsive Image style.

The reason why we are setting the Image url as the data-src attribute is because we are using Lazysizes javascript library to lazyload the images. The Responsive Image module outputs using source srcset as separate tags from the img tag.

In my testing, I have found that although the browser fetches whatever size it needs to based on the Responsive Image style configuration, it does not change the image url.

How would we control the output of the image so that we can get the image to display similar to below?

Goal:

Lazy load images even while using Responsive Image Module
Output the image field so that the data-src is set, src is not set, and the "lazyload" class is added

Current situation:

<picture>
<source srcset="/image.jpg 1x" media="all and (min-width: 768px)" type="image/jpeg">
<source srcset="/image2.jpg 1x" media="all and (min-width: 320px)" type="image/jpeg">

</picture>

Desired Output:

<picture>
<source srcset="/image.jpg 1x" media="all and (min-width: 768px)" type="image/jpeg">
<source srcset="/image2.jpg 1x" media="all and (min-width: 320px)" type="image/jpeg">

</picture>


texts: How to add an Ajax call to an element that already has callback set?

texts:
I want to add an ajax callback to a form element inside a form_alter, but it already has 2 callbacks assigned to it.
When I review:
$form['payment_information']['payment_method']['#ajax']['callback']

it has 2 callbacks already assigned to it.
If I do this:
$form['payment_information']['payment_method']['#ajax'] = [
  'callback' => '_sia_general_get_fee',
  'event' => 'click',
];

My callback is hit on click; but of course, the other 2 callbacks are wiped out and do not work.
If I add something like this:
$form['payment_information']['payment_method']['#ajax']['callback'][] = '_sia_general_get_fee';

then the other callbacks are called; but mine is not - I suspect since I no longer of an event defined.
I am also not sure how the other ajax calls work when they have no events defined for them.
Is there any way to do this?


texts:
Recently, To improve our site security we implemented and enabled OWASP security in our server using mod_security.

After we enabled the OWASP security, whenever I try to create or edit contents in my site after logging in as admin, It is showing it as SQL INJECTION and it does not allow to crate or edit new node.

When I edit content it redirects me to "/node/1078/edit"  and then it shows error

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

I also tried to find solution here but so far nothing helps. We have used drupal database API for all our database operations. I am not sure why OWASP is showing "SQL INJECTION".

How can I fix this?


texts: How to suppress "new" indicator for imported content?

texts:
Drupal works off a "history" table to keep track of the content you have looked at (in the last 30 days).
When you import old content that users have seen already it's shown as "new" because there is no entry in the history table yet.

I could insert records into the history table for all users and all content. I remember someone posted on d.o. about a "trick" that doesn't require inserting records into history, but I can't find the reference now.

Any suggestions?


texts: How to create a simple form to redirect the user to entered URL?

texts:
I want to create a simple form to redirect the visitors to a relative path they enter.

I created a search page with views and it has lots of exposed filters. I don't want to use this exposed filter as block.

On the main page I want to show only a simple search form and if the user enter a word then submit search button, it should redirect the user to example.com/advanced-search?full_text=word.

How can I do that?


texts:
I have a database with x users. I would like to add those accounts on my drupal database without having to recreate them one by one.

I would like to do a script mike that but i'm not really sure it would work out :

username = select name from mybase;
pw = select password from mybase;
mail = select mail from mybase;

drush ucrt username --mail=mail --password=pw

Obviously it would be a loop for every user, but i just wanted to share the idea.
First of all, is it possible to do this in shell ? The database is in another server, i'm not sure i can connect and take bake information (maybe using ssh ?)
Also the password is hashed in the other database, won't it generate a bad password (by hashing a hashed password). Even so, this point is not a problem, i can reinitialize their password to their login.


texts:
We have 90,000 nodes and it and we run cron every 10 minutes and do 200 documents per cron run. At this rate it will take just over 3 days to index all the content. It is also indexing older content first.

Is there a way to index newer content first
Is there a way to index more than 200 per cron run?


texts: Why is jQuery UI toggle not working in my theme?

texts:
I've tried setting up a jQuery toggle menu without much success. I followed the exact instructions and code from this tutorial, but even this simple script is not working.

Regular JS (like an alert) seems to work fine. I have Views installed and it seems the views admin uses extensive jQuery and works fine. Is there something I have to do to enable jQuery on my theme?


texts:
Have 3 content types. Apartment, hotel, motel.

Each has integer field "number of beds".

Lets say user wants to see apartments that have between 10 and 15 beds.
In views for apartment i made exposed search filter adding number of beds 2 times, 1st is "greater or equal to" and 2nd is "less or equal to".

This all works fine.

Now i want to apply this filter to all content types in one view so that user after entering from 10 to 15 beds applies this search request to all content types at same time.

Solution that should work is to create 1 bed field on apartment and use that existing field on hotel and motel, but i want to have it separated so that i have control of each field in each content type separately.

I have tried Global: Combine fields filter, but it does not support "greater or equal to", "less or equal to" etc.


texts:
I have seen project pages in drupal under http://drupal.org/project/xyz. I don't know how that works really.

Is this a specific 'Content Type' it is, but each node (aka project) has extremely consistent layout where as the whole thing look more like an basic article or a book page. Also, the elements within also has sections and further content; so it doesn't look like a pure single node. Or is this a different entity using a module like Project? But it is not available for D7.

Specifically, I want something exactly like this, but i don't quite know how to make specialized and consistent.


texts: "Source database does not contain a recognizable Drupal version."

texts:
I have installed two Drupal sites in my local Ubuntu desktop 15.10 Apache2 (2.4.12) environment: One is a fresh install of Drupal 8 and The second is a copy of an existing working site built with Drupal 7 (which is mostly core-modules based, very humble by means of pages). Both sites are working fine without any problem, anywhere.

My aim is first and foremost upgrading the Drupal 7 site to Drupal 8. I did all the preliminary stages like configuring the same languages, Keep minimal by means of modules (uninstalling any modules in the D7 site that I could easily bring back after the Upgrade), making sure the same modules are installed in both sites, etc, and now I just want to "Transcend" (hope its a good phrasing) my Drupal 7 site into the fresh Drupal 8 one.

To achieve my aim I've installed the Drupal Upgrade module in my Drupal 8 site, went to localhost/sitename/upgrade, and filled in all the details of the Drupal 7 site.

When I clicked the "Review upgrade" button I got the error:

  Source database does not contain a recognizable Drupal version.

I've googled this error as an exact phrase ("Error") and found very few results; Most of them seem to me to require a PHP programming knowledge that I've yet acquired, so I can't determine if the error is due to a bug (especially since this module is still under heavy development) or due to my mistake in understanding the concept\functionality of this module.

What reasons are there that the D8 Drupal upgrade module wont "like" the D7 database I provided? Especially while the Drupal 7 site is working fine both online and locally.
Would migrating be a decent alternative for upgrading, if upgrading isn't possible for whatever reason? If so, what is the best most simple solution You could think of for migration?

I went to /var/www/html/benia/modules/migrate_upgrade/src/MigrationCreationTrait.php and did:

-- return $version_string ? substr($version_string, 0, 1) : FALSE;

++ return 7;
++ return $version_string ? substr($version_string, 0, 1) : FALSE;

Than got this error in top of the screen.


texts: Problem displaying second level navigation in menu block

texts:
I have something strange happening with a drupal 7 site i'm working on. I have a main navigation menu which also provides navigation via a menu block for all second level pages. this works fine - i have an additional main navigation menu which can be toggled with the main navigation at the user's discretion -this is also working fine. however, displaying the second menu in a menu block is proving difficult. i have matched the settings for both menu blocks so they are associated with the correct menus respectively, and yet on the second menu block, it will only display if the top-level links are included. so, if i want to display the second-level only, regardless of setting the maximum depth, nothing shows up. if i include the top-level and set the depth to include children, that works fine; the top level and second level are there. however i need to exclude the top level and this doesn't seem a simple task.

is this a common problem, or has anyone experienced anything similar??

Neil


texts: Remove Filter When Exposed Filter is Selected

texts:
Currently, I'm working on an events view in Drupal 8 which needs to only show events that are on or after the current date (now() filter). This view also has an exposed date range filter that allows user's to select a start date and end date. The start date can be from before the current date.

The problem is that the now() filter isn't letting user's see anything before the current date. How can I remove the now() filter when a user enters a start date so they see the list of all the events in the date range they've selected?


texts: Why are there many session entries for anonymous users in my sessions table?

texts:
I checked the session table and it was getting huge. Most entries are the anonymous users.

Does Drupal make sessions for anonymous users, or only on error pages?


texts: ubercart - Add sku to a product catalog title via tokenizing it or adding it to a view?

texts:
I'm looking to add the sku in the product catalog view.

Thus producing this:

[title][sku]

Is there a way to tokenize it? I've looked around each field. It seems as the sku is not exposed in views as a field.


texts: How can I display parent and child terms from a CCK Taxonomy field in Pathauto?

texts:
How can I have two (or more) different taxonomy vocabularies appear in my Pathauto settings at the same time? For example, if I want to use the 'location' vocabulary and the 'accommodation type' vocabulary to create a URL that would look like this:

/Holiday-Cottages/Anyregion/Anytown/Some-Holiday-Cottage

The example is made up of i) the accommodation type, ii) the locations (regional name down to the town name) and the node title.

How would I do this? Taxonomy only seems to allow me to use one vocabulary in my Pathauto settings.

I've spent the past few hours experimenting with Content Taxonomy Fields to do this, but that doesn't appear to allow me to display the entire termpath of parent and child terms in the location vocabulary (where you can see the region name and town name) in the same way that Taxonomy provides a [termpath-raw] token to use in the Pathauto alias.

This question is an off-shoot of my question here: How can I create this sort of path structure?


texts: Lost Sessions on Drupal Commerce Checkout

texts:
Recently we have been experiencing Page Not Found errors during the checkout
process of our Drupal Commerce site. The problem seems to occur when a customer
travels from the checkout page to the shipping page. We use the secure pages
module in mixed mode operation, but the checkout and shipping pages are served
over https as shown below:

cart - http
checkout/% - switch to https
checkout/%/shipping - remain on https

I have been trying to debug this issue, but there are no errors in the logs.
Somehow the session is being lost between these two pages. Does anyone have any idea how to debug this issue?

We are using the Memcache API, Commerce UPS and Commerce USPS modules as well. So far this issue has occurred with IE 11, Chrome and Firefox browsers.

Thank you,

Paul


texts: Webform: POST data and send user to external URL

texts:
I was reading this interesting post: Webform - Submit values from Drupal 7 from to external url

I'd like to know: instead of just sending the data via POST and keeping the user on the Drupal site, how would you send the user to the URL the form values are posted to, so that they would arrive at the new URL and see a new form with the values they submitted?

Thanks.


texts: Wrong text being shown in a template file

texts:
When I add text in Hebrew inside html.tpl.php, it shows me strange characters instead of the ones I am expecting.

How can I fix this?


texts: How do I create a directory in webform for uploaded files

texts:
I wanted to use the 'file' field type in webform for file submission on my website, but I was getting this error message:

  The save directory could not be created. Check that the webform files
  directory is writable.

Any suggestions?


texts: n00b question, form callback and form_alter

texts:
My highly-n00b question is: suppose I have a form callback which could be used as argument to drupal_get_form().

How can I specify an ID for the form so I can compare it inside hook_form_alter against the given-as-argument $form_id?

This means: I want to give a form id to the form, e.g. "my-system-form", and distinguish it to apply some alter-logic (don't want to apply that logic to the rest of the forms).


texts:
I have created a view by the name of news and there is an option under page setting by the name of access.

I have selected view any news content for the access option, then I have faced a problem. The problem is when I give any kind of view permission for news view, I cant access except give the permission of view any news content.

What do I have to do to give a permission of 'view own news content' so every person can see his/her news content?


texts: Drupal 7 built tokens into core. Is there a way to display tokens on a page without modifying a template?


texts:
I would like to set the URL patterns in such a way that the page name of the parent page gets inserted into the URL. For example, in the Main Menu I've got an "About Us" link (about-us) and I would like to create a child page Contact Us (contact-us) underneath it.

How do I set up the URL alias patterns so that the child page URL is automatically set to about-us/contact-us?


texts: How to input search terms via a separate form on a content page to a Views Exposed Filter on a different page?

texts:
When visiting a content page (node), I want users to be able to input search terms into a form from there which will be fed into a View via its Views Exposed Filter.

The View I have is contained within Panels in a Panels-based page and it's Views Exposed Filter is made available as an external block. This approach allows me to layout this View and Views Exposed Filter with other separate items in other Panels.

Given that the Views Exposed Filter is made available as an external block, I can display it on other pages such as content. However, entering search into this form on these content pages results in the just the View being displayed - I need it to display the Panels-based page as mentioned above with the View results.

So I would somehow need to feed the input supplied by the user into the form on the content page, as a parameter into the Panels-based page.

My initial thoughts and questions on implementaton

Is it a case of using something like dpm() (which I have found useful in the past) to understand the form data being input so that input from the form can be fed to the Panels-based page and 'routed' to the Views Exposed Filter? I think the form data needed by the Views Exposed Filter is understood but how would I know where to submit the data i.e. can I give the URL for the Panels-based page as the form action URL and is there anything else I need to do so that the Panels-based page will convey the form input data to the Views Exposed Filter in the panel?


texts:
I want to link availaible block bids with active url. Then i want to clear page cache by block. How to do that best way? I wanted to use

block_list($region)

But it's overhead.


texts: How to use views filter on an entity property

texts:
I used hook_entity_property_info_alter to add two properties to an existing entity [crm_core_contact].  I find that I can see these two new properties in the "Fields" section of views, and that my views will display the values of those properties, but I cannot see these new properties in either the Sort or the Filter section of Views?  Any ideas on documentation that might tell me what is going on?

Here is the code for one of the properties:

$properties = &$info['crm_core_contact']['properties'];
$properties['notes'] = array(
                'setter callback' => 'entity_property_verbatim_set',
                'setter_permission' => 'Administer wcgopindividualinfo content',
                'label' => 'NotesText',
                'type' => 'text',
                'schema field' => 'notes',
                'getter callback' => 'entity_property_verbatim_get',
                'entity views field' => TRUE,
                'getter_permission' => 'Administer wcgopindividualinfo content',
                );

Although the Trellon documentation does not say this, I'm wondering if I need to add a hook_views_data_alter function to specify the filter and sort handlers for the properties that I added.


texts:
The default max length for all labels of all field types is 128. The DB can handle 255. So no schema change. How can I change the default max length to 250?

I've seen this module https://www.drupal.org/project/remove_field_label_length_limit

  Removes field label length limit (which is 128 characters). The module
  supports entity field labels, field group labels, and views field
  labels.

it was working on Drupl7 very well. but there is no version for Drupal 8.

I'm looking for a way to increase all Label length in a specified content type.


texts: How to remove dropdown items from a form?

texts:
I am trying to remove two select list items from a form using this code:

function module_r_form_alter(&$form, &$form_state, $form_id)
{
    if ($form_id == 'forum-node-form') {
        unset($form['edit-taxonomy-forums-und']['#options']['_none']);
        unset($form['edit-taxonomy-forums-und']['#options']['4']);
    }
}

The above code is not working. I would greatly appreciate any help you can give me in working this problem.


texts: Show teasers from both content type and Users together in a view

texts:
I would like to be able to create a page to show teasers from content created with a certain content type, say "Company" together with teasers from Users content.

Until now, I just managed to create either a view to show the teasers of the Company content type, OR the teasers of the Users. But not both.
When I add a relation, I can use fields of both in the same block, but I would like to show a page with separate blocks of both companies and users together.

How should I do such a thing, if even possible?


texts: What are the alternatives for searching users using custom fields in Drupal 7?

texts:
Drupal 7

I would like to be able to search through users by two fields, in this case name and surname through a single input field and not having to use complete fields. The goal, for a user with name field 'John Jo' and surname 'Doe', would be to be able to find him searching 'john j', 'jo doe', or 'john doe' (note the mixture of incomplete fields).

I'm willing to create extra fields if necessary, that's no issue, a colleague told me about the possibility of using Apache SOLR to index those fields (don't even know if it's possible) but would like to be certain that it's a correct path before embarking on the trip.


texts: How to get 'base theme' information about a theme?

texts: In an admin settings form in a custom module, I need to determine what base themes a specific theme uses (the default theme, not the current theme). If I know the child theme's name, how do I obtain the names of the 'base themes' that child theme uses (if any)?


texts: I have a module for drupal 7 that generate reports. I want to print one of the reports with out drupal menus and footer. I want the report to be displayed on second page alone with view descriptive data? Please Help.


texts: How to render the main menu in alphabetical order regardless of menu link weight?

texts:
We are using the main menu of Drupal to build out the main navigation of the site. The content creators have access to add a menu link for a node in any level of the main menu and they are also able to use the weight field to set the location of where the menu link will fall under.

We are using a superfish menu block to render our main menu. We are having trouble figuring out how to always alphabetize regardless of what the current user's language is. How would we accomplish this?

Example scenarios:

For English content, the main menu will display all links only when the user's locale is English. Additionally all menu links for English should always be alphabetized regardless of the menu link weight.
For Japanese content, the main menu will only display Japanese menu links, but also in alphabetical order
For German content, the main menu will only display German menu links but also in alphabetical order.


texts:
I am trying to post article content type to my tumblr account (want to post all articles created by different user roles) . I have tried tumblr_connect but its not working i have also installed tumblr api module and registered a application and added the keys.

But i am stuck there i dont how to configure to post only the article content type and link it to my tumblr blog.


texts: Best way to add a search function to user profiles

texts:
So my client would like to have a search function added to user profiles, because the number is growing rapidly and filtering based on role, etc, isn't working for them.

How do I add a search to the user profile page? This is under User Management > Users > List


texts: Adding print friendly link on specific nodes

texts:
(I have already posted this question on StackOverflow, but I then discovered this forum, which seems to be a more appropriate place for this question.)

I have also read all the similar questions on StackOverflow, without luck.

In my Drupal 7 site I use the Printer, email and PDF versions module. I want to show the printer link on some specific pages of a specific content type. So I have enabled the link in that content type, which include a boolean field (field_printable) where the admin should be able to choose to include the link or not. In my template.php file I try to figure out how to work this out. This is what I have got so far in my template.php file:

function mytheme_preprocess_node(&$variables) {
    if($variables['type'] == "mycontenttype"){
        // boolean field that returns 1 if checked
        if($node->field_printable['und'][0]['value'] == 1){
                 what to put here ...?
        }
    }
}

I should probably use print_insert_link(); to insert the link, but I cannot figure out how. Can anyone point me in the right direction? I have spent hours googling on similar questions, but I am stuck right now.

Any help would be very appreciated, thanks in advance.


texts: Create drupal content programmatically with custom entity ( assets )

texts:
I am using asset module : https://www.drupal.org/project/asset

I creates a new entity type = asset. I get a form where I can add ( document, image, video..).

How can I, from a custom module add a content of asset ? I think that I cannot do it the way we creat nodes ... like :

$node = new stdClass();
$node->type = "asset";
node_object_prepare($node);
....

Please help

thank you


texts:
I'm building a site with Panels (and Panels Everywhere, with a custom theme based on Precision) and trying to customize the breadcrumbs for particular nodes based on their content type.

The Crumbs module looks like it does what I need, and I've been able to make it work perfectly on a test site in Garland, but as soon as I switch to using Panels, the Crumbs breadcrumbs aren't being used.

Specifically, it looks like the "Breadcrumb" Page Element Content provided by ctools doesn't use the Crumbs breadcrumb trail. Somehow crumbs_preprocess_page is being completely suppressed.

Can these two modules be made to work together? I don't see any open issues for Crumbs, or any comments on the troubleshooting page at http://drupal.org/node/1008658, so I have to think that someone has made this work.

(Drupal 7.18, Panels 1.2, CTools 3.3, and Crumbs 1.8)


texts: Programmatically delete pathauto alias pattern?

texts:
I know how to remove a pattern via the UI. Is it possible to do this programmatically to be used in hook_update()?

EDIT: I think asking this answered my question. Will post a followup answer. Probably just entity_load/entity::delete


texts:
[ Similar question: How to add custom entities to group types? (Drupal Answers). But I ask specifically about ECK entities, not other simpler custom entities ]
I want to implement collections of certain custom (ECK) entities in a Drupal 8 project.
I like the Group module and how it treats groups as entities, but custom entities are not directly available and a little module similar to gnode is needed, as explained in this answer (Drupal.org):

If you look at the group module, it also contains a gnode module that, when enabled, allows entities of type node to be added to groups. To be able to add entities of another type (like you make in ECK) you’ll need to make a gnode module equivalent.

More info in this piece of Group documentation.
I attempted something like that, from the code proposed in the above mentioned Drupal answer, just changing id, entity and module names, but it gets messy as it involves ECK bundles. Despite I am able to install the module and configure the corresponding available content:

If I "Add an existing entity", it saves and afterwards appears as an empty content. Clicking on Devel for more info crashes and tells me that "group" mandatory parameter is missing.
If I "Add a new entity", it crashes on the first step and tells about a missing bundle for this entity type.

Well, I understand that this is a more complex case and the module needs more functionality.
So... Before digging on what the module has to contain I wonder:

Is this a good approach?
Is there such a module already published (or at least any hint about it)?
Should I take an easier road (with or without Group module)?


texts:
When I create a form (using form api) I need, sometimes, to assign a default value to form elements, or to create a list for select elements, under certains conditions. In this cases, I need to do some queries, process, etc. I do it in buildForm method, but I was wondering if It is the right way because this method is called again if I need to rebuild the form due to ajax change (for example with dependant fields).
Until now, I manage it checking $form_state variable for some field in order to see if a field is empty or not, but is it the right way to do it? is there another method to initialize the form elements?


texts:
I am trying to call a function every time a page is loaded. With Drupal 7, I used hook_init, now I'm using a subscribed event.
  public function logRegEntry(GetResponseEvent $event) {
    $request = $event->getRequest();
    $method = $request->getMethod();
    $path = $request->getPathInfo();
    $route_name = \Drupal::routeMatch()->getRouteName();
    if (($method == 'GET') && ($path == '/')) {
      // do it just for this module
      \Drupal::service('wdocsDebug')->logSiteEntry();
    }
  }

This works fine for the home page, but I want it for every page a user requests. This is getting called four times; first for the page I'm requestings, and then for:
/admin/coffee/get-data
/history/5/read
/quickedit/attachments
I did notice that on the first request, the $route_name is set to "entity.node.canonical" -- might this be a better way to check for a page? Probably not, since it would only get triggered by node pages.
I'm looking for a better way to do this, not sure why there are four request events. Thanks.


texts: How to print a field from the content of a node using Omega 4 Layouts?

texts:
I'm designing a web with Drupal and my theme is a subtheme of Omega 4. I'm using Context/Context Omega and Omega Layouts.

I have a node type("Product node", for example) that has a title field(like default node), a subtitle field called field_subtitle, and the rest of the content.

Since I need to use CSS just for the subtitle field, I need to put it in a div separately from the rest of the content. So I would like to print the title, like it does by default, print the subtitle, and print the rest of the content.

What I have made in my product-layout.tpl.php, searching for this kind of things is:

      <?php print render($title_prefix); ?>
      <?php if ($title): ?>

<?php print $title; ?>

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

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

Or maybe changing the

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

for

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

, but didn't got it to work. It doesn't give any error mistakes, but it doesn't separate field_subtitle from content, since if I remove the last line of this snippet, all content dissapear, even the subtitle. So... how can I print the subtitle in a separated way that the rest of the content? Am I doing something wrong?

Thanks


texts: Drag ad drop images to make a customised gallery

texts:
So I have a content type "Albums" which has a field "image". This allows a user to upload several pictures into this album.

What I have done next is made a view that displays all the different albums. So you see a thumbnail for each album.

Once you click on an album you are taken to the contents of that album. The content is basically a list of image fields with some other stuff like date published etc...

What I want to do now is being able to pick a picture from this album and drag it to like some sort of panel at the bottom and drop it there, then navigate around the website dragging and dropping different pictures from different albums.

Once you have finished with the selection there should be a button called "create" or something similar which will maybe call a script through some trigger which will zip the pictures and download them to your pc.

I have no idea how to do this. Help!

Thanks!

I'm using Drupal 6.


texts:
I added theme wrapper to main menu using page_preprocess but its not addde class to ul of menu.

Here is my code

function semanticUI_preprocess_page(&$variables) {
$variables['primary_nav'] = FALSE;
  if ($variables['main_menu']) {
    // Build links.
    $variables['primary_nav'] = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
    // Provide default theme wrapper function.
    $variables['primary_nav']['#theme_wrappers'] = array('menu_tree__primary');
  }
}

function semanticUI_menu_tree__primary(&$variables) {
  print'
';print_r($variables);die();
  return '
' . $variables['tree'] . '
';
}


texts: Drupal 7 Orphaned fields, how should they be deleted?

texts:
Currently I uninstalled ubercart and there are still fields that exists in my database. I have the following fields that I want to delete:

uc_catalog_image
uc_product_image

http://prntscr.com/1hj1rt

How should one go about deleting these tables from the database? What would it affect if I just dropped those tables complete? And where else would I have to update if I did that manually?


texts:
I have two content types. Blog and Author. On Blog content type I have entity reference field (blog_author) where admin can find author of the blog (Author content type).

Now I have a view that is supposed to show Author image and name (fields on Author content type) on the sidebar of blog post. The settings I have on my view:

Filters (published)
Relationships (referencing field blog_author), require this relationship.

But when I go see blog page it always show same author on each blog post (newest Author). Is my relationship somehow wrong? Should it be "referenced field blog_author" as there is two different entity reference for this field. EDIT: Though I did try this but with same result. So this is why I'm bit baffled now that how to do it. I thought relatioship would be enough but do I need to use contextual filters with this too?

Views settings:

Relationship:


texts: Changing Pagination based on screen size

texts:
Is it possible to change the amount pagination displays based on screen size? For example: I have a products page that I want to show 30 items on desktop, but on mobile I'd like it to only show 10 items.

I'm currently using the Loads More Views module, but that doesn't do what I need.

Thanks!


texts: Populating fields from the User entity during a Commerce checkout

texts:
When a user checkouts out, they need to fill in some specific information which should be saved to the User entity.

Thus I need to modify the checkout form to collect the information I want, then save it to the User.

It seems like a cheeky way to simplify the process would be attaching User fields directly to the Commerce Order entity. Is this possible, or should I just load the User entity form and copy the fields I want in a hook_form_alter?


texts: Is there a way to set the cardinality of a field on a per bundle basis?

texts:
I'm creating a bunch of paragraph types with a node entity_reference field, in some cases, I want field_article allow 3 items, in some to allow 5 items and in some to be unlimited.

I'd like to set the cardinality of field_articles on a per bundle basis, so I don't have to create field_3_articles, field_5_articles as well.

Is there an easy way to set the cardinality on a per bundle basis for a field?

It looks like there's a core issue for this:

https://www.drupal.org/project/drupal/issues/1029298


texts: Why doesn't the function taxonomy_term_search exists?

texts:
I have an autocomplete field in an API Form. The callback function uses the following code to highlight the search query in the list of suggestions.
With a taxonomy vocabulary of 3 levels of hierarchy, about 8,000 terms, it takes a whole eternity of 1 second to offer the suggestions. In a direct SQL query or a EntityFieldQuery it takes just a few tenths of a second. Why doesn't mixed $tid_array = taxonomy_tearm_search(term_name, vid) exists, it would increase the code below in which only taxonomy API is used.

mymodule_providers_autocomplete($brand, $text){
   $selected_providers = array();
   $providers = get_providers_of_type($brand);
   $counter = 0;
   foreach($providers as $nid => $provider){
      if(strpos(strtoupper("." . $provider["title"]), strtoupper($text)) > 0){
           $selected_providers[$provider["title"] . ' (' . $nid . ')'] = str_ireplace($text, "<strong>" . $text . "</strong>" , $provider["title"]);
           $counter++;
           if($counter > 10) break;
       } // if
   }
 drupal_json_output($selected_providers);
} // function

function get_providers_of_type($brand){
   $children_1 = taxonomy_get_children($brand);
   $models_arr = array();
    foreach($children_1 as $key2 => $value2){
        $children_2 = taxonomy_get_children($value2->tid);
        foreach($children_2 as $key => $value){
            $models_arr[] = array("title" => $value->name);
        } // foreach
    } // foreach
}   // if
  return $models_arr;
} // function


texts: Do some tasks after a simplenews newsletter has been sent

texts: I need to unsubscribe users from a specific simplenews newsletter category after a newsletter of that category has been sent. The best way is to do this action after updating sent status of newsletter. but there are not a hook or event to do this. What is your opinion to implement this task?


texts: How to change content url content/title to text/title?

texts:
I created some content and changed the URL content/title to text/title.
My issue is why my changes didn't apply on some content.


texts:
I have field in content type called field_new_author which is User reference field.

I need to make a Rule to change Node author field to match value in field_new_author.
I tryed this solution: Change node author on node save with rules

But I'm getting database error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4141-0-all' for key 'PRIMARY': INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 4141 [:db_insert_placeholder_1] => all [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 ) in node_access_write_grants() (line 3440 of /home2/test/modules/node/node.module).

I also tryed different setups in Rules but could not find anything that would work.


texts: Custom submit handler for theme settings form

texts:
I am creating a new D8 theme and having slideshow functionality in it. For slideshow, we have title, description and image field in the theme settings form. I am able to alter the theme setting form using THEME_NAME_form_system_theme_settings_alter, but when I add a custom submit handler the form seems to break and get internal server error.

My objective for adding custom submit is to make the uploaded files status as permanent.

Here is my code,

function THEME_NAME_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  // $form['#submit'][] = 'custom_settings_form_submit'; //tried this as well
  $form['actions']['submit']['#submit'][] = '_custom_settings_form_submit';
}

function _custom_settings_form_submit(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $account = \Drupal::currentUser();
  $values = $form_state->getValues();
  for ($i = 0; $i <= SLIDESHOW_COUNT; $i++) {
    if (isset($values['slide_image_path' . $i]) && !empty($values['slide_image_path' . $i])) {
      // Load the file via file.fid.
      $file = file_load($values['slide_image_path' . $i][0]);
      // Change status to permanent.
      $file->setPermanent();
      $file->save();
      // $file_usage = \Drupal::service('file.usage');
      // $file_usage->add($file, 'user', 'user', $account->id());
    }
  }
}

NOTE:
This is the error present in apache error log:
PHP Fatal error:  Invalid placeholder (!message) in string: %type: !message in %function (line %line of %file). in /core/lib/Drupal/Component/Render/FormattableMarkup.php on line 240

Does anyone have any idea where I'm doing it wrong? or is there any workaround for making the file status permanent?


texts:
I would like to use Services to programmatically login a user from another website.

So for example if site.example.com uses the services login endpoint on example.com in Chrome, when that user moves over to example.com they will already have a valid session and cookie for accessing the site.

I have looked into adding the cookies.txt file via my CURL request, and have tried the various different Drupal authentication method like user_login_submit() and drupal_session_regenerate() but none of them are working.

When i navigate over to example.com the user is still seen as being anonymous.


texts:
In Drupal 7 I use devel's  drupal_debug() or its alias dd() to log a variable to a drupal_debug.txt in the site's temp directory.

In the Drupal 8 version of devel this function has disappeared. It seems to be replaced by DevelDumperManagerInterface
But it is not clear to me how it used.

How can I log variables to a txt file in Drupal 8?


texts: Rules: how to programmatically set the bundle of an entity?

texts:
For some tasks, rules requires to know the bundle of a given entity, the most obvious situation being when you need to set a field of a node and rules requires the type of node.

Normally you can solve this in the "condition" side of rules, where you can check that your entity is of a given bundle or that it has a specific field.
However there are situation where this approach is not possible, as when the entities derives from the result of an action, in my case they are loaded from a VBO view.
Hence how can you tell rules that a given list of entities - or a single entity - is of a given bundle, so I can use its specific fields ?


texts: I want to create a responsive Image gallery block. I have used Views Slideshow Liquid Carousel module for this but that is not working properly, It breaks when the screen is too small. I want a carousel like display of images with responsive skin like http://tympanus.net/Development/Elastislide/, I have also tried this plugin but this plugin is not working properly can't find why. So is there any other way or plugin for this.


texts:
I don't know anything about how rules work so I'm looking for help from the hive mind.
I need to set up shipping based on these calculations but not sure where to start.

Originally I was looking for rules to do all of this:

If product category is silencer & size is large shipping is $10 per that type of line item
If product category is silencer & size is small shipping is $7 per that type of line item
If product category is silencer & at least 5 line items are strike type of center shipping is free on all silencers
If product category is sbr or sbs shipping is $15 per that type of line item
If product category is accessories and no other items are in cart shipping is $10 flat rate
If accessories are added to orders with any other types of line items no additional shipping should be added to order

I've now broken out accessories as a different product type, and added the "Commerce Shipping Field" module. So that takes care of the first 2 lines, as well as the SBR and SBS shipping.

I still need the 3rd line to work.

Also, I set up flat rate shipping for accessories and it works for orders with only accessories in them, but if you add any other product the shipping method provided is not reliable, sometimes flat rate is chosen, sometimes the commerce shipping rate is chosen. I think it has to do with the order the products are added to the cart.

I really need some help on this. And talk to me like I'm not quite ready for the 'Drupal for Dummies' series. I can create sites well enough, but I've never had to deal with Rules before and they're kicking my ass!


texts: multiple entity type in entity field query

texts:
how to add mutilple entity_type and bundles in EntityFieldQuery?

$query->entityCondition('entity_type', 'profile2')
       ->entityCondition('bundle', 'user_profile');

Is there any way to do like this

$query->entityCondition('entity_type', array('profile2','user'))
       ->entityCondition('bundle', array('user_profile','property'));


texts:
How can I easily manage landing pages in Drupal 8? Do I need to created separate content types for landing page? Is there any other way to manage this with a single content type?
The landing pages I want to create are the following ones.

Blog landing page
Fields: banner title, body, image, blogs
Publication landing page
Fields: banner title, body, image, publications
News & events landing page
Fields: banner title, body, image, news and events landing


texts: Unable to Search Table Containing Webform Submissions Using Exposed Combined Fields Filter

texts:
I'm trying to add a Combined Fields Filter that users can come to my site and use to search through a Table View that is populated by user-created Webform submissions.  Unfortunately, when I create said filter, it never returns any results.

Below are the settings I have now:

View Settings

Filter Settings

Is this something you can do with webform submissions?

Thanks!


texts:
I feel like I am missing something obvious that I just can't quite put my finger on.

As an administrator, I see "Add Content > Book page" and "My Workbench > Create Content > Book page" in the admin menu, and I see tabs to create and edit drafts when viewing a book page.

My "book author" role does not see any of this though, despite seeing controls for 3 other content types just fine. The node permissions allow book authors to "Create new content" for the book page type. The 3 other content types also have "Create new content" and no edit permissions, and they all work fine.

For the 3 working content types, if I remove the "Create new content" permission, the admin options disappear from the menu and tabs aren't shown, and the menu and tabs reappear as soon as I recheck "Create new content". So it's just this Book module content type that's giving me problems.

This is a Drupal 7 site, with a few contributed modules that affect content access, such as Workbench Moderation and Organic Groups. I have also tested out some other content access modules in the past, such as Workbench Access and Domain Access. All these modules have long been disabled, however, and I have rebuilt permissions several times since. I suppose it should be noted though that I only just recently enabled the Book module, while the 3 working content types were all in use when I was experimenting with Domain Access, Workbench Access, et al, so maybe there are some lingering settings in the database?


texts: AJAX auto on views (without clicking submit button)

texts:
I'm working on a view with exposed filters ; I want it to be reloaded when a select list (based on a taxonomy) has its value changed by an user. However, by default, AJAX in Views needs a click on the submit button : "Options such as paging, table sorting, and exposed filters will not initiate a page refresh."

How can we improve that ? Why does Views not offer an option for that, it's not just about perfs considerations ?

thanks !


texts: Trying to migrate Date values using migrate module.

texts:
I'm trying to migrate some data from a csv to a field_collection in a user profile. Everythings works fine but not for a field of Date (with range) type.

I'm on Drupal 7.22 and I'm using Migration and Migration Extra modules

I do not receive any error message, but the data is not entered, please help me

My code in the migration class:

[...]
$source_file = drupal_get_path('module', 'module_name') . '/data/user_employments_info.csv';

$columns = array(
  [...]
  array('employment_period_start', 'employment_period_start'),
  array('employment_period_end', 'employment_period_end'),
  [...]
);

$this->destination = new MigrateDestinationFieldCollection(
  'field_usr_bkg_emplo',
  array('host_entity_type' => 'user')
);

[...]

$this->addFieldMapping('host_entity_id', 'user')->sourceMigration('User');

[...]

$this->addFieldMapping('field_usr_bkg_emplo_time', 'employment_period_start');
$this->addFieldMapping('field_usr_bkg_emplo_time:to', 'employment_period_end');


texts:
MySQL Server version: 5.0.77 and Current PHP version: 5.1.6

Does Drupal 7 support them?


texts: What hook do I use to add a field to a content type after it was programmatically created?

texts:
I have a module that created a custom content type with some fields.

Now I need to update the content type with a new field and wanted to know what hook do I use? As of now my content type was created via the .install file but need a way to process the changes without uninstalling and re-intsalling the module. My .install file

function example_node_install() {
  $t = get_t();

  // Define the node type
  $example_node = array(
   'type' => 'example_node',
   'name' => $t('Node Example'),
   'base' => 'node_content',
   'description' => $t('This is an example node type.'),
   'body_label' => $t('Example Description')
  );

  //Add defualts
  $content_type = node_type_set_defaults($example_node);
  node_add_body_field($content_type);

  // Create the field
  $field = array(
    'field_name' => 'item_description',
    'cardinality' => 1,
    'type' => 'text',
  );
  field_create_field($field);

  // Create the instance map description.
  $instance = array(
    'field_name' => 'item_description',
    'label' => 'The item description.',
    'bundle' => 'example_node',
    'entity_type' => 'node',
    'widget' => array(
      'type' => 'text_textfield',
      'weight'  => 2,
    ),
  );
  field_create_instance($instance);

  //Save Content Type
  node_type_save($content_type);
}

Any guidance will be appreciated.


texts:
After migrating from dev to prod on Bluehost when I run update.php I get a 500 error and I get the below error in error in error_log.

  PHP Parse error: syntax error, unexpected T_FUNCTION in
  redhen_activity.module on line 608

This is D7 with the latest update to the Open Outreach Distribution. The odd thing is that my dev site (running as a subdomain) works just fine.


texts: How can i set the custom column class field in a view to accept colons?

texts:
We are using the uswds design system in our Drupal template.

I have created a view and set the Format type to be grid. I want to setup a  responsive grid layout. Under Format -> Grid -> Settings there is a field called "Custom column class". I need to be able to use a colon in the views custom column class field.

For example, mobile column classes are specified like "grid-col-12" and then a desktop column override would be set like "desktop:grid-col-3".  This field strips the colon so it breaks the responsiveness.

Is there a way to tell this field to accept colons?

I had tried a few things like html entities, escaping the value, etc.  All of those got removed when the layout was rendered on the web page.

Is there a pre-processor for that field in the views I could tap into?

I found a bit of hacky way to fix this for now using twig_vardumper I was able to dump the values from the views-view-grid.html.twig.  It appears that the custom classes are apart of the "column.attributes" and are in an array.  They must be processed because in the array I see the class that I use the colon doesn't have the colon when it is in the array.  In the view settings, if the default classes are set to true, then the custom classes will output in the column div.  That seems wrong to me. I think it should always output my custom classes and only output the default classes if I have the checkbox checked.

I'm changing this line:

<div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>

To this:

<div{{ attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>

When I {{ dump(options) }}, I see the options.col_class_custom has the custom classes stored as a string.

I'm setting a new variable to get my custom classes:

{% set custom_class = options.col_class_custom %}

Then in this part of the views-view-grid.html.twig template I added an else statement and this will output only my custom classes and append them to the div for the column:

{% if options.col_class_default %}
  {%
    set col_classes = [
      'views-col',
      custom_class,
      options.alignment == 'vertical' ? 'clearfix',
    ]
  %}
{% else %}
  {%
    set col_classes = [
      custom_class
    ]
  %}
{% endif %}

I would think there is a better way to do this.  I am open to suggestions.  Ideally, what I want is for Drupal to not cleanse the custom classes that I enter into the custom classes field.  Is there a way to turn that off?


texts:
I'm looking at the book-tree.html.twig template and I want to achieve two things. I've searched the web and experimented a bunch and have had no luck.
Here's the template:
{% macro book_links(items, attributes, menu_level) %}
  {% import _self as book_tree %}
  {% if items %}
    {% if menu_level == 0 %}
      <ul{{ attributes.addClass('menu') }}>
    {% else %}
      <ul class="menu">
    {% endif %}
    {% for item in items %}
      {%
        set classes = [
          'menu-item',
          item.is_expanded ? 'menu-item--expanded',
          item.is_collapsed ? 'menu-item--collapsed',
          item.in_active_trail ? 'menu-item--active-trail',
        ]
      %}
      <li{{ item.attributes.addClass(classes) }}>
          {{ link(item.title, item.url) }}

        {% if item.below %}
          {{ book_tree.book_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      </li>
    {% endfor %}
    </ul>
  {% endif %}
{% endmacro %}

I want to expand the first level by default so that when you come to the website intranet, you see something like this (YLN Intranet is the top page of the book):

I want to add a class to the tree entry that matches the current page. In effect, I want to style the link for the page you're on differently. I know how to add a class but I haven't found a way to get the internal path (everything gives me the aliased path).

Are these things possible? Thanks!


texts: Book navigation pager is moved under the comments

texts:
For some reason, if I change the display order of any field in Manage display for the Article content type, the Book navigation pager is moved to the far bottom under the comments.

If I check the template output, it is showing under the comments, which was not the case when everything was right. Even reordering the fields in Manage display to where they were before fixes this.

Is there any reason for what happens? Is it a bug?

I am using the Bootstrap theme, if this makes any difference.


texts: How do I disable a checkbox on Facets Block?

texts:
I would like to disable checkboxes of a Facets block.
The option will still be visible but the user will not be able to click it.

I am using Search API, Search API Solr, Facets.

I have created a widget extending the current checkbox widget and added the attribute readonly="readonly" to the item.

However, the checkbox is built using JS and it has got static text on it. It does not get any extra attribute.
So I am building my own JS library to do that.

All I want is to add readonly attribute to the checkbox.

Thanks in advance.


texts:
Hello im back using Panels and im hoping it will help with something that ive ran into with the new Media fields etc.

I want to create a Node Page variant that will overide node page if there is a video file linked via the Media Youtube  Multimedia asset    Media file selector file. If there is an image in the Media field then show a differant variant. I think its to do with File types.

Sorry if im a little out my termenology its just D7 hs so many new things to get my head around.

So a panels node page based on variants of what type of file is added to the Media field.

thanks


texts: hook_form_alter Save $form['account']['field_first_name'] into $form['profile']['field_first_name']

texts:
Hi I'm trying to save a field into another field in the same form when the form is submitted.

I've tried using hook_form_alter and checked for count($form_state['input']) > 0 to save $form['account']['field_first_name'] into $form['profile']['field_first_name']

I know you may say that I can use the profile2 module. I'm already using that. I just need to figure out how to save one field value into another field when a form is submitted.

Any help would be greatly appreciated.


texts: I placed breadcrumb block to my page, but Breadcrumb doesn't generate any content. The pages are link in the menu, but it is still empty. Maybe I'm wrong, but I don't know what is necessary to configure. Thank you for your advice.


texts: How to create submenu based on content type and taxonomy?

texts:
I would like to create a submenu that lists items based on content type and taxonomy.  Here's the setup.

Shop for a Car [Basic Page]
    Financing Options for cars [Basic Page]
       loan 1 [Content Type: Loan / Taxonomy: Car, Home]
       loan 2 [Content Type: Loan / Taxonomy: Car]
       loan 3 [Content Type: Loan / Taxonomy: Car, Home]
Shop for a Home [Basic Page]
    Financing Options for homes [Basic Page]
       loan 1 [Content Type: Loan / Taxonomy Car, Home]
       loan 3 [Content Type: Loan / Taxonomy Car, Home]

Notice that loan 1 and loan 3 appear under two different parents.  I know I can create this menu structure manually using NodeSymlinks. In that case the Taxonomy terms are not needed.  However, I would like to generate the menu automatically using the terms for a particular content type.  I looked into the taxonomy menu module but it only allows one parent and it lists the taxonomy tag rather than the items tagged.  Any suggestions?

Thanks!


texts: How to programtically queue a function for 48 hours (to change webform Author)

texts:
The code below changes the submission author to that of a user referenced in the webform (pulls username:uid). However now need this to change after 48 hours.

I am unsure how to effectively queue this for 48 hours before it runs or even if that is possible (I guess I will have to change the hook to "hook_webform_submission_update")..

I was thinking of rules but is there a hook which would help? Also if rules is the answer could anyone shed some light on how I can implement it into my code?

// change submission author to the submitted user lookup
function helper_custom_webform_submission_presave($node, &$submission) {

    // get uid from user_lookup
    $user_lookup_cid = 1;
    $user_string = $submission->data[$user_lookup_cid]['value'][0];
    $user_string = explode(":", $user_string);
    $uid = $user_string[1];

    //change submission to be saved by user
    $submission->uid = $uid;
}


texts: Can't populate integer value in title field using rules

texts:
I have a integer value that I'm trying to add to the title of a new node, but I can't figure out how to get it to work.

This the rule I have so far.

{ "rules_rule_create_bid" : {
"LABEL" : "Create a new Bid",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "button_field", "rules", "path" ],
"ON" : { "button_field_clicked" : [] },
"IF" : [
  { "button_field_compare_button" : {
      "clicked_field" : [ "field" ],
      "comparison_field_name" : "field_email_client"
    }
  },
  { "entity_has_field" : { "entity" : [ "entity" ], "field" : "field_client_email" } },
  { "entity_has_field" : { "entity" : [ "entity" ], "field" : "field_project_id2" } },
  { "entity_has_field" : { "entity" : [ "entity" ], "field" : "field_bid_count" } },
  { "entity_has_field" : { "entity" : [ "entity" ], "field" : "body" } }
],
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "new_bid",
        "param_title" : "Default",
        "param_author" : [ "site:current-user" ]
      },
      "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
    }
  },
  { "data_set" : {
      "data" : [ "entity-created:field-bid-contractorname" ],
      "value" : "[site:current-user]"
    }
  },
  { "data_set" : {
      "data" : [ "entity-created:field-bid-projectid" ],
      "value" : [ "entity:field-project-id2" ]
    }
  },
  { "data_set" : {
      "data" : [ "entity-created:field-project-description" ],
      "value" : [ "entity:body:value" ]
    }
  },
  { "node_path_alias" : {
      "node" : [ "entity-created" ],
      "alias" : "p_[entity-created:field-bid-projectid]_u_[site:current-user]"
    }
  },
  { "entity_save" : { "data" : [ "entity-created" ], "immediate" : "1" } },
  { "data_set" : {
      "data" : [ "entity-created:title" ],
      "value" : "New Project #[entity-created:field-project-id2]"
    }
  },
  { "redirect" : { "url" : "p_[entity-created:field-bid-projectid]_u_[site:current-user]#overlay=node\/[entity-created:nid]\/edit" } },
  { "drupal_message" : { "message" : [ "entity:field-client-email" ] } }
]
}
}

I want the entity:field_project_id to show in the title, but all I get is the project number.


texts: Remove HTML element when pasting from Word

texts:
I am pasting a GDoc content using "paste from word" button on the ckeditor (4.5.4) and I want to remove the extra span with style associated with links in the text (so that it uses my theme css).
Here is how a link is styled after pasting to ckeditor:

         Neil Armstrong

I want it to be just

Neil Armstrong

I tried in ckeditor profile under Advanced options:

config.allowedContent = true;
config.disallowedContent = 'span {color, font*, text-decoration}';

This is not working!


texts:
I want to render an array and print the output as Block[content]. There is either my Foreach or the way I use $item array or $row that is wrong. I will appreciate your help.

The result i get is the HTML I define in Block[content] without the values of $row->uri, $row->title, $row->body_value. They are empty. And it means I have done something wrong.

function produkt_block_view($delta = '')
{

  $block = array();

  $list = produkt_produkliste(1);
  $items = array();
  foreach ($list as $row) {
    $items[1] = $row->uri;
    $items[2] = $row->title;
    $items[3] = $row->body_value;
  }

 switch($delta) {
  case 'produkt' :
    $block['content'] = '';
    $block['content'] .= 'uri.'" alt="Se alle vores filter elementer her">';
    $block['content'] .= '
"'.$row->title.'"
';
    $block['content'] .= '
"'.$row->body_value.'"
';
    $block['content'] .= theme ('item_list',array('items' => $items, 'type' => 'ol',   'attribute' => 'produkt'));
    break;
  }

  return $block;
}

And I ended with this solution that get some results.

function produkt_block_view($delta = '')
{

   $query  = db_query("SELECT node.title,    field_data_field_kortbeskrivelse.field_kortbeskrivelse_value, file_managed.uri
    FROM node
    JOIN field_data_field_tilh_rsforhold ON
    node.nid = field_data_field_tilh_rsforhold.entity_id

    JOIN field_data_field_kortbeskrivelse ON
    node.nid = field_data_field_kortbeskrivelse.entity_id

    JOIN field_data_field_billede ON
    node.nid = field_data_field_billede.entity_id

    JOIN file_managed
    ON field_data_field_billede.field_billede_fid = file_managed.fid

    WHERE field_data_field_tilh_rsforhold.field_tilh_rsforhold_target_id = 30
    AND  field_data_field_billede.bundle = 'produkt_kategori'
    "

      );

    $rows   = array();
    foreach ($query as $row)
    {
        $rows[] = array(
        $row->title,
        $row->field_kortbeskrivelse_value,
        $row->uri
      );
            print_r($row->uri);

            $block['content'] = 'uri . '" alt="Se alle vores filter elementer her" />'; // assuming that anchor tag will wrap img
            $block['content'] .= '
' . $row->title . '
';
            $block['content'] .= '
' . $row->field_kortbeskrivelse_value . '
';
            $block['content'] .= theme ('item_list',array('type' => 'ol',     'attribute' => 'produkt'));

    }

  return $block;
 }


texts: How do I programmatically place a block?

texts:
From UI you can add a block in a region in that way:

Go to Admin -> Structure -> Block layout (/admin/structure/block).
Click on "Place block" button besides the region name.

I want to do the same thing but programmatically. How do I add an existing block to a region and save it? This block should then be displayed in that region and be  available in the Block layout page.


texts:
I want to override the twig template for specific fields on a form which I created via the Contact module in Drupal 8.

However, I can't find any documentation, and the suggestions in the HTML comments also doesn't show me anything useful.

Basically I want to override, a custom field (field_phone) and a standard field (Sender name) on a specific contact form the following values:

form-element.html.twig
form-element-label.html.twig
input.html.twig

Is that possible? And what are the file name suggestions?


texts: Custom user login in Facebook Auth modules

texts:
I try to run Facebook Login on my Drupal 8 site. I run it by Social API module and with Simple FB Connect, but both module generate user name from first and last name on Facebook. My user will not be happy with using real name, but I don't want to give them options to change username whenever they want.

For code examples I use Simple FB Connect, but the same logic is in Social API modules.

User go to path user/simple-fb-connect and is redirected by Drupal\simple_fb_connect\Controller\SimpleFbConnectController->redirectToFb(), and when he is back, go to user/simple-fb-connect/return which is handle by Drupal\simple_fb_connect\Controller\SimpleFbConnectController->returnFromFb().

It checks permissions, get data from FB and then if email not exist in DB, registers user:

[...]
    // If there was no existing user, try to create a new user.
    $fbid = $fb_profile->getField('id');
    $fb_profile_pic = $this->fbManager->getFbProfilePic();
    if ($drupal_user = $this->userManager->createUser($fb_profile->getField('name'), $email, $fbid, $fb_profile_pic)) {
[...]

The main question is: How I can replace $fb_profile->getField('name') with custom, provided by user string ? I think about:

Replace simple link on login with form contains textfield and submit button, which send POST/GET data to user/simple-fb-connect. There store it Session, and use on returnFromFb() function to create user.

But I can't always show an additional field (eg. on homepage), and I don't know if user want to register or just login. It kills idea, just click, and get account.

After back from FB, show users one-time form, which they can't skip, and access page, before they fill it, like post-login registration in normal FB integrations, on which they can fill additional data, but only once per account.

But there I have no idea how to even start. Maybe I can replace function returnFromFb() code creating new user with register form, and after submit create user. Or leave module code in peace and base it on events from the module. But how I can lock page for user who don't fill this and secure it to be fill just one time (maybe boolean field on user entity?).

The simplest way, just leave it as it is, use display name and hide login, but I don't want to store user names and last names in database.

Thanks for help!

PS. I tried to ask the creators, but it looks like the modules work like they should work.


texts:
I have overlay turned off in Drupal. When I am editing a node, I want to prevent the redirect to the node after I hit save and just stay in the back-end. (It is really a pain to have to hit "edit" and have the page re-refresh each time when one is making a little tweak. As this can be easily achieved by having to tabs open; one for the node view and one for the backend edit form)

Is there an easy way to solve this in the configuration UI?


texts:
How do i make a custom drupal theme i already have responsive. I mean the easiest way to do this?

What about integrating my current custom theme on top of a drupal base theme like omega?


texts: Drupal module upgrade via Composer not being recognized

texts:
A Drupal 8 site started pestering me to upgrade Twig Tweak from 8.x-2.8 to 8.x-2.9. I went to the directory and ran composer require 'drupal/twig_tweak:^2.9' which seemed to work. I also did drush cr. When I go back into the Drupal web interface it still thinks I'm on the older version of Twig Tweak and wants me to upgrade. If I run the composer command again, it thinks I'm already upgraded. How do I get these two things to play nice with each other?
(You might be wondering why I didn't just use the web interface to upgrade. If I do that I have even bigger problems so I'm sticking to composer for now.)
Update: output of composer show
descrip. : A Twig extension with some useful functions and filters for Drupal development.
keywords : Drupal, Twig
versions : * 2.9.0
type     : drupal-module
license  : GNU General Public License v2.0 or later (GPL-2.0+) (OSI approved) https://spdx.org/licenses/GPL-2.0+.html#licenseText
homepage : https://www.drupal.org/project/twig_tweak
source   : [git] https://git.drupalcode.org/project/twig_tweak.git 8.x-2.9
dist     : [zip] https://ftp.drupal.org/files/projects/twig_tweak-8.x-2.9.zip 8.x-2.9
path     : /var/www/html/ycfld/modules/contrib/twig_tweak
names    : drupal/twig_tweak

support
source : https://git.drupalcode.org/project/twig_tweak
issues : https://www.drupal.org/project/issues/twig_tweak

requires
drupal/core ^8.7 || ^9.0
twig/twig ^1.41 || ^2.12

suggests
symfony/var-dumper Better dump() function for debugging Twig variables```


texts: Drupal behavior not working with Views ajax

texts:
I have a problem with applying my js to Views after its filter is changed using ajax. I'm really tearing my hairs out for a while...
As obvious in this question - my js is applied only on first load, after changing some filters and hitting send button the js is not working anymore. What is strange - if I uncomment last line with submit() the JS works! But - first time it reloads page with ajax, than after second change it reloads the page...

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

            var container = $(".category-select", context);
            var selector = $("#edit-field-category-tid", context);
            var submit = $("#edit-submit-frontpage", context);

            $(container.find("span"), context).click(function() {
            var tid = $(this).attr("data-taxonomy");
            var select = $(selector.find('option[value="'+tid+'"]'), context);
            if ( select.prop('selected') ) {
                $(this).removeClass("enabled");
                select.prop('selected',false);
            } else {
                $(this).addClass("enabled");
                select.prop('selected',true);
            }
            //submit.click();
            });

        }
    };
})(jQuery);

I tried some other configurations and... It seems like that setting prop is not working correctly after ajax refresh. Seems strange to me, because ids are the same, it finds select (option) properly but it do not change its property.
Is it possible that it do the changes on old, i dont know - cached(?), site created before ajax refresh?


texts: Contact form redirects to homepage without showing submission information

texts:
I am using default contact form available in D7 under module section. The problem is that contact form redirects to the homepage. It doesn't show any information about submission, such as "Your message has been sent" etc etc. Instead it redirects to home page immediately.

I don't want the contact form to redirect. It should stay here and should show the submission information/message.


texts: Is it possible to create a panel with 4 or more columns? The sample templates in the Panel module only go as far as 3.


texts: How can I put a checklist button in a views table to run some code on selected rows?

texts:
I want to select some rows in views table and run some code for selected rows(nodes) by submit button.
How can i do that?


texts: Search API: Custom processor not hitting addFieldValues

texts:
I'm creating a custom module for adding a processor that adds relative entities. Here's my code for getPropertyDefinition.

public function getPropertyDefinitions(DatasourceInterface $datasource = NULL) {
$properties = [];
if ($datasource) {
  $entity_type = \Drupal::service('entity_type.manager')->getStorage('group_type')->load(key($datasource->getBundles()));
  $entity_type_ids = [];
  $plugin_manager = \Drupal::service('plugin.manager.group_content_enabler')->getInstalled();
  foreach($plugin_manager->getInstanceIds() as $instance_id) {
    array_push($entity_type_ids, $plugin_manager->get($instance_id)->getPluginDefinition()['entity_type_id']);
  }
  foreach($entity_type_ids as $entity_type_id) {
    $definition = [
      'label' => $this->t(ucwords($entity_type_id)),
      'description' => $this->t('Entity reference of ' . $entity_type_id),
      'type' => 'entity:' . $entity_type_id,
      'processor_id' => $this->getPluginId(),
    ];
    $properties[$entity_type_id] = new EntityProcessorProperty($definition);
    $properties[$entity_type_id]->setEntityTypeId($entity_type_id);
  }
}
return $properties;
}

And, after adding relative fields to index, I think it should hit addFieldValues method but it doesn't. For test purpose, I only put die in the method.

public function addFieldValues(ItemInterface $item) {die;}

But, when I copied code from addURI's getPropertyDefinition into my getPropertyDefinition, it hits addFieldValues when indexing. Is there anything wrong in my getPropertyDefinition?


texts:
I have a simple Drupal 8 form where users can upload a picture.

The issue is that the upload_max_filesize is set to 2M on the server. So if I upload a bigger file, the form submission fails:

  Fatal error: Call to a member function save() on a non-object

Here is what I have tried in the submitForm:

$validators = array(
  'file_validate_is_image' => array(),
  'file_validate_size' => array(1024 * 1024),
);

/** @var File[] $pictures */
$pictures = file_save_upload('picture_upload', $validators, 'public://');
if(null !== $pictures) {
    /** @var File $picture */
    $picture = reset($pictures);
    $picture->save();
}

This actually leads to 2 issues when trying to upload a large .jpg image:

The file could not be saved because it exceeds 2 MB, the maximum allowed size for uploads.
Image type not supported. Allowed types: png jpeg gif

So my questions are: why does the validator not accept a .jpg image? How would I go about avoiding the fatal error and return to the form if the file size is too big?

Edit:

I have changed my validator to this now:

$validators = array(
  'file_validate_extensions' => array('gif png jpg jpeg'),
  'file_validate_size' => array(2 * 1024 * 1024), // 2MB file size limit
);

It works now in the way that it accepts my .jpg image and doesn't accept files larger than 2MB. But how would I go about returning to the form with an error message instead of going straight to the PHP fatal error?


texts: Get Relationship for the Author of the Latest Comment

texts:
In a Node view, I am trying to group the latest comments by the author's field_last_name, but I am having difficulty adding this field.

I tried using the the "Last comment" and "Last comment author" relationship, but they both don't appear to work. (Neither exposes the user fields or the "Comment: Author" relationship.)

Am I missing something here? Or must I switch my Node view into a Comment view?


texts: Can I use custom name for theme directory?

texts: I'm developing site using Drupal 7. I want to give a custom name for the themes directory. Is it possible with Drupal?


texts: Generate h1 et h2 inside link with theme function

texts:
I am trying to modify a module.

I have two variables: let say $date = "mydate" and $title = "mytitle"

I have for the moment a theming function that creates a link by doing something like this:

$vars['row_dates'][$i] = l( $date, '', array('fragment' => $vars['timelinr_dates_id'] . '_' . $i, 'external' => TRUE));

which output a result like:
    mydate

I would like now to output something like:

mydate

mytitle

the problem is that if I do:

$date = "
mydate
";
$title = "
mytitle
"

then the markups are outputed like text
Is there a way to acheive it ?


texts: Features - keeping Git up to date when changing features on production

texts:
I have a Drupal 7 site with a UAT version and Production version. Most of the features on production have been overridden. I want to keep my repository up to date in case anything happens to my database I can redeploy with the most current (overridden) changes.

My question is: what is the best way to go about updating my Git repo without a lot of unnecessary work?

My thinking is that I could just download the features off of production, overwrite the features on my local and commit / deploy to remove the overrides. Is this a viable strategy? Is there any risk involved with this strategy?

I appreciate any help / nudge in the right direction.


texts: Update multisite modules and core in one click

texts: I have a Drupal multisite install with 7 different sites, all sharing the same modules, themes and users but everything else is unique to the individual site.  At the moment, I only have to upload one version of Drupal core or any contributed modules when I want to update them but I have to run update.php on each website separately.  Is there an easy, quick way of making all of these updates run simultaneously?