texts: Rules Custom Condition for registration capacity

texts:
I am trying to learn Rules and adding a custom condition. I need help to figure out what I am doing wrong.

My Condiiton set up:

function rules_example_capacity_condition_info() {
   $conditions = array(
     'rules_example_action_count_capacity' => array(
       'label' => t('Print capacity count on page'),
       'group' => t('Rules examples'),
       'parameters' => array(
         'count' => array('type' => 'value', 'label' => t('registration event count')),
         'capacity' => array('type' => 'value', 'label' => t('registration event capacity')),
         ),
       ),
     );
     return $conditions;
 }

and the function that calls it...

function rules_example_action_count_capacity($count, $capacity) {
    $reg_count = reg_count_load($count);
    return($reg_count->capacity == $capacity) ? true : false;
}

I am trying to determine the count (how many people have registered so far) and the capacity. When the count and capacity are the same send an email.

I am not a developer so this is a little bit of a struggle. I found this series (http://nodeone.se/node/28) which is helpful, however there are so many smaller things I might be missing. Please help if you can. I am hoping that this will help more then just myself.

Thanks
Tim


texts: Set the reply address for the contact form to user's mail address

texts:
I have a Drupal 7 site with only few modifications and I have the /contact form enabled for anonymous and registered users, so that they can contact the admin (i.e. me) easily.

What irritates me is that their messages always have my own mail address as the reply address. And so in order to reply to them, I have to search my "Sent items" folder for the user name (I relay the mails through gmail at my CentOS server).

Isn't there a way to set the reply addresses to the ones of registered users and why isn't it done by default?

I've added apache to /etc/mail/trusted-users to get rid of the following mail header:

  X-Authentication-Warning: mysite.com: apache set sender to my@email.com using -f

But still, I see the "From" header is always set to the admin mail address.


texts: How can I make a mobile app that is basically a mobile browser to access my live Drupal site?

texts:
There is a question about exporting Drupal pages for use in a mobile app, but I would like to know if there is an easy way to make a mobile app (iOS, Android, etc.) that simply loads the existing site in a browser for online-only access.

I looked into Phonegap, but (as far as I can tell) you have to export the pages as HTML for that.  However, the primary purpose of my site is to send messages back and forth using the Private Message module, so making the site accessible offline makes no sense.

I already have a responsive theme, so the site also looks decent in mobile browsers.  I just want a mobile app because I want the site to appear in App Store and Google Play searches.

Is there a straightforward way to address this use case?


texts: How to show social network providers in OpenInviter?

texts:
Below is the image of all providers.
I have checked postinstall, everything is fine for facebook and others but they are not listed on the providers tab.
How to make facebook available to be able to import contacts from there?


texts: I downloaded a patch file from mailhandler module and need to apply the changes in order to fix the problem of pop3 accounts not deleting emails after download (import).  How do I install it?


texts: Limit reference field to nodes with referenced user

texts:
I have two content types, Restaurant and Lunch.

Restaurant content is created by content admins, and can be viewed by anyone.

Lunch has an entity reference field that references nodes of type Restaurant.

Logged in users need to be able to create their own Lunch content, but only see their own Restaurant in the referenced node select list.

Content admins can also create Lunch content, but they need to see all available Restaurants in the select list.

I'm thinking I need to put a user reference field to the Restaurant content type, and then I could filter a reference view by the referenced user? But here is where I get stuck, how then will content admins be able to see all Restaurants in the select list?


texts:
I've got this website I'm maintaining and one thing about it is driving me mad. Anonymous users have the permission to create nodes of this content type, and when they do, they are redirected to the front page so fast that they can't see the messages after (there is supposed to be messages). This happens only with anonymous users and only with that content type. Below are the steps I've taken to debug this.

Put a dpm(debug_backtrace()) as the first line of drupal_goto() (no usable output)
*I changed theme, but I didn't try with the Bartik theme
I've changed the machine name of the content type

Some more facts

There are only 2 custom modules, and they are both disabled
I disabled all the rules I was using
I do NOT have the Redirect module installed, nor Global Redirect
I have disabled all the rules and no PHP in blocks/fields (as far as I know)

How do I further debug this?


texts: Joomla to Drupal module - migrating issues

texts:
Notes: Drupal 7.x. Joomla to Drupal module version 1.0 ALPHA3

I was playing with the Joomla to Drupal module, which is currently in alpha. I had imported some 100 content items from a Joomla install using this tool. However, making changes to some of the content was producing errors, so I decided to start fresh; I deleted all of the imported content.

I then attempted to redo the import, however, it threw additional database entry related errors stating that it was unable to overwrite tables.

I decided to start anew by disabling and then removing the module and its related tables all together; logged into mysql and removed tables joomla_categories joomla_content joomla_sections and joomla_users as well as the joomla directory under ../sites/all/modules.

I proceeded to reinstall the module, and went to configure it; all of the settings were intact i.e. database name, password, etc. from the previous install (caching?).

I go to perform the import, and a database error shows up stating that the joomla_users table does not exist. I log back into mysql and notice that the module did not recreate the joomla_ database tables.

Isn't the module responsible for creating these tables? Can anyone see what I may have done wrong in my process? If the module doesn't create the tables, what does?


texts:
Sometimes, when a user post a comment, it not published immediately; this can be for several reasons (e.g. spam suspect, anonymous user). I want to use the Rules module to send an email to users that flagged the node for new comments, but only when the comment is published. I cannot find any condition in the Rules module that allows me to check if the comment is published or not.

Perhaps someone has a way to accomplish this.


texts: How do I a use a template file to theme a mulit-step form?

texts:
I am creating a multi step form, and displaying that through a template file. The first step of the form displays fine, but when I go to the second step, the first step titles are also displaying.

How can I check which form fields are displayed? The form fields for the first step should not appear when the second-step form fields are shown.


texts:
I have created a overriden taxonomy term page using views, page displays and attachment displays. A term landing page looks kind of like this:

3 articles showing image as a list (page display)
3 articles without showing image as a list (first attachment display)
6 articles in 2 column table (second attachment display)

I would like to somehow enable paging on this thing. Ideally the pager would sit on the bottom of the last attachment. When a user goes to page 2 (assuming a page size of 12), the first (page display) view would show articles 13 to 16, the first attachment from 17 to 19 and so on.

Is this possible?


texts: How to change a view overriding the query using views_pre_execute?

texts:
I want to change a view overriding his query using views_pre_execute.

function mymodule_views_pre_execute(&$view) {

global $user;

$userid = $user->uid;

if($view->name=="order_selection") {
$custom_query = db_select('commerce_order','fco');
$custom_query->join('field_data_field_restid','ffdfr', 'fco.order_id = ffdfr.entity_id');
$custom_query->join('field_data_field_username','ffdfu', 'ffdfr.field_restid_value = ffdfu.entity_id');
$custom_query->join('users','fu', 'ffdfu.field_username_target_id = fu.uid');
    $custom_query->fields('fco' , array('order_id', 'order_number', 'mail', 'created', 'status'));
$custom_query->fields('fu' , array('name'));
$custom_query->condition('fu.uid', $userid , '=');

$view->build_info['query'] = $custom_query;;

$result = $custom_query->execute()->fetchAllAssoc('order_id');

$header = array();
$header[] = array(
    array('data'=>'Nr. comanda', 'field'=>'order_number'),
    array('data'=>'E-mail','field'=>'mail'),
    array('data'=>'Data comenzii','field'=>'created'),
    array('data'=>'Status', 'field'=>'status'));

$data = array();
foreach($result as $record){
    $data[] = array(
        array('data'=>$record->order_number),
        array('data'=>$record->mail),
        array('data'=>$record->created),
            array('data'=>$record->status));
//$data[] = array($record->mail);
}

$html = theme('table',
    array('header'=>$header,
    'rows'=>$data,
    'attributes'=>array(),
    'caption'=>'',
    'sticky' => TRUE,
    'empty' => 'No rows',
    'colgroups'=>array()));
$html .= theme('pager',
    array(
        'tags'=>array()
    )
);
print render($html);
} }

I can see the correct results but these are displayed without a header and in a wrong place at the top of the page.
The major problem is that the table of the original (unwanted) view is still displayed in the main content area of the page. How can I completely remove the original view and replace it in the main content with the one generated by views_pre_execute?
Also can someone give me a hint why the header is not displayed?


texts:
I'm here

I need to create a link to three languages. for example

     Link 1

     Link 2

     Link 3

other in Spanish

     Link 1

     Link 2

     Link 3

In Portuguez

         Link 1

         Link 2

         Link 3

When I go to the block to see its links, by default it always appears / link / 1 no matter what language I am in.

It does not take in language: it ES or EN o PT-BR

Link 1 --> hover url = http://url_site/link/1
in any language.

should be

Link 1 --> hover url = http://url_site/en/link/1
OR
Link 1 --> hover url = http://url_site/es/link/1
Link 1 --> hover url = http://url_site/pt-br/link/1

configuration of my block.


texts: Remove default installation profiles with drupal core

texts:
Is there a way to remove the core installation profiles that come with drupal without the need of hacking core? i.e. is there a hook that can run to alter this list?

The reason why this is required is that we are making a custom install profile for use with aegir, and do not want the default core drupal 'minimal' and 'standard' install profiles as options for the users to create new sites.

Perhaps this could be a hook in aegir?

Has anyone found an elegant solution to this?


texts: fetchAllAssoc() is returning only first row

texts:
I have a query like this:

  $product_classes = db_select('node_type', 't')->fields('t', array('name', 'type'))->condition('module','uc_product')
  ->execute()->fetchAllAssoc('orig_type', PDO::FETCH_ASSOC);

It will return an array with only first valid table row, however there are more valid rows.

If I use this query, without specified fields:

  $product_classes = db_select('node_type', 't')->fields('t')-:condition('module','uc_product')
  ->execute()->fetchAllAssoc('orig_type', PDO::FETCH_ASSOC);

It will return array with all the valid rows. It is a drupal bug?


texts: Saving a data to two different nodes with same node id?

texts:
I am having this problem , i want to save the same data into two tables with the same node id. I want to use both the tables on two different places because data is changing in the first table and i want to keep a track to the older data in my second table.

$node->field_call_response['und'][0]['tid'] = $call_response;
$node_new->field_log_response['und'][0]['tid'] = $call_response;


texts: How to get rid of empty blocks on the dashboard?

texts:
I created a View called Recent comments and added a block to my dashboard. Afterwards, I deleted the View, which results in an empty block on my dashboard

and the following error message:

  Notice: Undefined index: recent-comments-block in
  dashboard_page_build() (line 192 of
  C:\wamp\www\mysite\modules\dashboard\dashboard.module).

I tried to drag the empty block away after clicking Customize dashboard, but every time I hit Done, it is displayed again. Clearing caches did not help either.

What should I do to get rid of the empty block?


texts: How to track location of a sign-up form in a block?

texts:
I have a newsletter sign-up form in a block that appears on many pages. When the form is submitted, I want to capture the current page.

The block and form are created in code. In the submit function, I am using drupal_get_path_alias() to get the current location. The block has no explicit caching set, so I believe DRUPAL_CACHE_PER_ROLE is assumed.

I had been thinking that although the block is cached for anonymous users, the submit function would still retrieve the correct location.

However, it doesn't seem to be working correctly. I always get a value for the path, but I believe it's incorrect in many cases.

What should I do to make sure I get a correct path on submit?

Update Mar 17 2014: I switched caching from the assumed DRUPAL_CACHE_PER_ROLE to DRUPAL_CACHE_PER_PAGE and that seems to have resolved the problem. Also, for the record, the problem looked like this: most sign-ups come from one page. But every once in a while a sign up will come from a different more obscure location on the site. What I was seeing was that "other location" repeated for the next x of signups (the number varied). So, in that respect, it did look like a caching problem.


texts: Display submitted data using a select field option - webform module

texts: I'm new to Drupal. I have a form that I created using Webform Module, is there a way to pull data submitted by Webform and group it by a column. To display result in a view


texts: Where do I set the HTML that wraps a module's config $form inputs?

texts:
I am transferring a module from one site to another. All is well except the modules form (where I set settings, upload images, etc). On the original site this is nicely wrapped in a table with each section being a row, but on my new site the form elements are just placed in one after the other, appearing vertically. This is despite me copying the modules .inc, .tpl and .module files almost verbatim.

I'm new to Drupal in general so am struggling with this a bit. Would anyone know where this is set (what file, what function)?

function gallery_grid_theme($existing, $type, $theme, $path) {
  $items = array();

  $items['gallery_grid'] = array(
    'render element' => 'element',
    'path' => drupal_get_path('module', 'gallery_grid') . '/plugins/content_types/gallery_grid/templates',
    'template' => 'gallery-grid',
    'variables' => [],
  );

  // Draggable table for gallery-grid admin form.
  $items['gallery_grid_draggable_form'] = array(
    'render element' => 'fieldset',
    'file' => drupal_get_path('module', 'gallery_grid') . '/plugins/content_types/gallery_grid/gallery_grid.theme.inc',
  );

  return $items;
}

Contents of gallery_grid.theme.inc:

function theme_gallery_grid_draggable_form($variables) {
  $fieldset = $variables['fieldset'];
  $rows = array();

  // Table for the items.
  foreach (element_children($fieldset) as $key) {
    $fieldset[$key]['weight']['#attributes']['class'] = array('item-weight');
    $rows[] = array(
      'data' => array(
        render($fieldset[$key]['image_file']),
        render($fieldset[$key]['image_url']) . render($fieldset[$key]['image_title']),
        render($fieldset[$key]['delete_row']),
        render($fieldset[$key]['weight']),
      ),
      'class' => array('draggable'),
    );
  }

  // Header and render.
  $header = array(t('Image *'), t('Image Settings'), t('Actions'), t('Weight'));
  $table_id = 'items-table';
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array('id' => $table_id),
    'sticky' => FALSE,
  ));

  // Add tabledrag.
  drupal_add_tabledrag($table_id, 'order', 'sibling', 'item-weight');
  return $output;
}


texts:
I am trying to add custom attribute with elements like "data-url" and "data-text" in views fields, it shows something like "data-text="test text"> as output on front end.
How can i add them so that they work as attribute and not print as text ?


texts:
How to change autocomplete_route_parameters value on change of select option?

I have a form element and inside autocomplete_route_parameters, I want to change $langcode value when I select any language from select list.

$form['node_items'] = array(
            '#type' => 'textfield',
            '#autocomplete_route_name' => 'autocomplete_node_search.autocomplete',
            '#autocomplete_route_parameters' => array('skip_node_id_string' => $skip_node_id_string, 'langcode' => $langcode),

          );

So if I choose language french from select list, $langcode should become = 'fr' via ajax.


texts:
Objective:
Extract image (ideally into a new field) from an existing text field in a custom entity with views handler (civicrm view or civicrm_entity).

Scenario:
HTML fields often has an image or multiple images embedded. In this case, the content is sourced from a civicrm external entity using civicrm views (could also be done using civicrm_entity module).  Views provides text field filters and can strip html tags, but I only want to extract one or more images from the html.  This can then be displayed as a seperate field in views (either as a new / generated field) or reusing the description field and stripping out everything else.

Notes:
This seems easy, but the field formatter needs to work with remote urls.  I tried the Image Resize Filter which works on remote urls, but i need to also strip the rest of the text.  This does not actually create a new field, and is pretty ugly, but can work.

Modules considered / reviews:
https://www.drupal.org/project/image_link_formatter - not a node, only avail as view
https://www.drupal.org/project/image_importer - like idea of importing as "Drupal" image but no easy way to link embeded image to file system

Discusssions:
https://www.drupal.org/node/1045712
https://drupal.stackexchange.com/questions/138961/get-images-from-textfield-and-save-them-in-filefield
Images within content of page but not separate fields


texts: How to use Google and Ubuntu fonts on Zen theme

texts: How can I use Ubuntu font and Google fonts on Zen theme?


texts: How to show a View field depending on roles?

texts:
I have a view, and I added 2 fields: "title" and "edit link".
Now I just want to show the "edit link" link if the visitor is a registered user, and has the "administrators" role.

How can I accomplish it?


texts:
Hi I have enabled the drupal 8 conditional fields module , but I do not see anywhere to configure it, the "Malnage Dependencies" tab that is supposed to appear does not show.  Am I missing a step?
thanks,


texts: How to pass multiple target_id/values field using entity reference prepopulate?

texts:
I read the documentation and saw that this is possible: node/add/page?field_bar=1,2,3

But how do you code this? I wanted to pass multiple target id, not just one.

I tried this code but this only passes 1 value which is the first field value.

<?php
$l = l( t('Create Package'), 'node/add/package',   array('query' => array('field_product_food' =>$node->field_product_food['und'][0]['target_id'])  ));
echo $l;
?>

I also tried using an array loop like this:

<?php
$nids = array();
foreach ($node->field_product_food[$node->language] as $index => $item) {
$nids[] = $item['target_id'];
}
$l = l( t('Create Package'), 'node/add/package',   array('query' => array('field_product_food' =>$nids)  ));
echo $l;
?>

but the result is not like the example from the documentation.

Can somebody help me?

Thank you very much!


texts: Delegate user administration to a limited set of users

texts:
We are currently using the excellent domain module (allows segmenting users by domain) in and the user_import module (allows uploading users via CSV) in Drupal 7.
We've got a new requirement where we want certain authorised users to be able to perform CSV uploads and edit user details for other users within their domain, but limited to no other admin function within the site (or other user details).
Without re-implementing each function (edit users, upload CSV, etc) in a new module (my fallback plan), is this possible within the Drupal permission / authorisation framework?
My gut feeling and exploration so far is no, it isn't. But I am no Drupal expert...


texts: How to add a view of product fields to a product display so that it changes when add-to-cart form is updated via ajax?

texts:
In Drupal 7/Commerce, I would like to display a view of product fields attached to a product so that when the add-to-cart selection is updated and product fields are updated via ajax, the view is also updated (as with typical product fields).

In my case, I want to create an entity reference field ("included hardware") referencing other products attached to a product and use a view to display the result. This must happen at the product level, and not with the product's display node.

I have tried EVA. These fields don't appear on Product Display View Mode configuration.

I have attempted Display Suite (block field). When I select a display template for the product I see the fields on the product type display, but they don't show up on the Product Display node.

Can anyone point me to a solution for displaying a view within a product display that changes when a new product is selected?


texts:
I would like to know how to fake a node in Drupal. I have a table with drawings. The drawings have non unique names. For each drawing I want to be able to create a page using the unique id of the drawing:

like so: http://mysite.com/drawing/100

I don't want to create nodes for each drawing but still be able to have a theme template to show the contents of the drawing record.

How do I do that. And if this is possible how do I access the drawing number in my template page?

Thanks a lot!


texts:
Why cannot I use underscores in menu machine names?
For example menu_xpto is an illegal machine name for a menu.

What is the problem with using _ in a machine name?


texts: hook_node_load for currently viewed node?

texts: I am trying to modify $node via hook_node_load but I do not have the current node in the list of $nodes handled by hook_node_load when I check it with devel's dpm. I only have some nodes from a node_load_multiple call I make in the module. Should I use hook_node_view instead? But hook_node_view says it can only modify node content.


texts: How to make custom login URL accessible in maintenance mode

texts:
I created a custom login page with custom path (www.example.com/customlogin) and blocked access to default login page via hook_menu_alter(). The requirement for default login page to return 403 is achieved.

Login page accessed via new path works great, but this page is inaccessible when the website is in maintenance mode.

Question: How to make a path accessible in maintenance mode?

I'd like to find a method that does not require the use of additional modules like Rename Admin Path


texts: Drupal EFQ propertyOrderBy with integer as title

texts:
I have an EFQ where I'm getting a list of store nodes according to the logged-in rep's (user) territory. It's working well, except the propertyOrderBy is returning the node titles ordered only by the first number in the title string. The titles are store numbers. i.e. 954, 980, 8475, etc.

  // Get the stores for the logged-in user's territory code.
  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'store')
    ->fieldCondition('field_territory', 'target_id', $terr, '=')
    ->propertyCondition('status', 1)
    ->propertyOrderBy('title', 'DESC');
  $result = $query->execute();

The list is being returned DESC as requested, but only by the first number. In this case, 9 -> 8 -> 6, whereas it should be ordered by the whole number string, 8475 -> 6905 -> 6903 -> 980 -> 954. Below is what it looks like now. Any ideas how to order properly?

    STORE #
    980
    954
    8475
    6905
    6903


texts: How to link a a custom workflow with a content type or an entity?

texts:
I have a custom entity booking.
I created a custom workflow type booking_moderation dedicated to this in Drupal\my_module\Plugin\WorkflowType\BookingModeration. I could then add my desirated states and transitions via the UI:

Then I don't understand and I can'f find any documentation about how to properly link this workflow with my custom entity type. I looked at content_moderation module to set the configuration form, in order to set my booking content but then i get confused...

Do I have to create a custom field type (+ formatter and widget) via the field Plugin and handle tables and data by this field?

Or is there a simpler trick that I can't see?!


texts: How to add a extra products fields on ubercart check out pane table?

texts:
Hi im looking to add some extra fields on the check out pane, i mean fields from the product like some attributes, theres any possibility?

Please if someone how to do this let me know!

Thank's to everyone who can help me!


texts: I set up a search criteria using taxonomy terms to filter content. The taxonomy and filter work great. The problem is the links return like www.example.com/work?tid=1 but instead I would like the filter links to use the taxonomy term name like www.example.com/work/logo. I have tired to set a alias on the terms but it keeps referring to the tid. The has taxonomy option only allows you to change the name of the identifier before the ? But the link still shows the =1 id after the identifier.


texts: Using drupal_http_post() to submit to external site: What am I doing wrong?

texts:
I intended to make a module that utilized drupal_http_request with a webform so that the form gets validated before it gets sent to an external url.

I actually was recommended this method over $form['#action'] from a previous inquiry earlier. I did as recommended, thought it worked, but found out that I was mistaken.

I did some troubleshooting and concluded my module is the culprit since:

The module utilizing $form['#action'] had no problems posting to our external url/web app and another external site/service for testing HTTP POST submissions (http://requestb.in)
The module utilizing drupal_http_post could neither post to our external url/web app nor requestb.in

My setup uses the following:

Drupal 6.x
Webform 6.x-3.17

My custom module contains the following code.

function webform_to_data_repo_form_submit(&$form, &$form_state, $form_id) {
    if ($form_id == 'webform_client_form_765') {
        $url = 'external.url.goes.here';
    $headers = array(
                 'Content-Type' => 'application/x-www-form-urlencoded',
               );

$response = drupal_http_request($url, $headers, 'POST', http_build_query($form_state['values'], '', '&'));
   }
}

Is there something wrong with my module? Just wanted to make it post to some external URL.


texts: clone of drupal project failing: operation timed out

texts:
I am trying to clone the drupal project locally  but getting this error

k10593:htdocs welcha$ git clone git://drupalcode.org/project/drupal.git fooproject
Cloning into 'fooproject'...
fatal: unable to connect to drupalcode.org:
drupalcode.org[0: 140.211.10.6]: errno=Operation timed out

I am following this tutorial: http://drupal.org/node/803746

Any idea what the problem might be?


texts: Attach a handler to the "event" of autocomplete select with jQuery

texts:
I'm using Views Autocomplete Filters on an exposed node title field. I would like to attach a handler to the "event" when the user selects one element from the autocomplete list without applying this patch which would actually trigger a "real" event.

For the simplest example: if the user has selected one element from the autocomplete list, show an alert() message. (I wouldn't do that because it's ugly, but it's the easiest demonstration of the solution.)


texts: Display message on initial login only once without a module

texts: What method is there to show a message on a user that just logged into the site without using a module? I know rules can do it, but I dont want to install a module just to do that. Is there some type of indicator variable that gets set upon initial login?


texts:
I am a bit confused now - is it normal behavior that posting an anonymous comment on cached page invalidates ALL cached pages for whole site for current anonymous user? Beacouse that is exactly what I am experiencing now. Moreover, current anonymous user is not able to cache pages by visiting them in browser. Is it a bug or is it some sort of a cookie? Thank you for answers.

UPDATE1: I created fresh install, set up a few testing nodes with anonymous commenting enabled and it seems that after submitting comment, drupal adds a cookie. In response headers there shows no-cache on all pages.

UPDATE2: I tried @mikeytown's suggestion and tested out alternative database cache http://drupal.org/project/adbc and it turned out to work ok with anonymous comments. After posting a comment on a cached page - all other precached pages are served from database for current anonymous visitor. This is what I expected as default behavior from core drupal cache. As a sidenote - in addition to that I tested content refresh module http://drupal.org/project/content_refresh which flushes cache of the page immediately where comment is posted, which turned out to be working pretty good.

Next I tested submitting comments using ajax http://www.test.eotazky.sk/admin/config/content/ajax_comments . This solution created a session which disabled access to cached pages to current anonymous user. Clearing browser's cache helped.

I tested also other forms on cached pages like poll or closedquestion which use ajax to submit forms and it seems to me that all ajax submitted forms set a session that disable access to cached pages for current anonymous user.


texts: How repeating field values in "EntityReference select list widget" as I would with "autocomplete widget"

texts:
my question is how to display "select list widget" like "autocomplete widget" when
I create or edit an entity, I mean with "add another field". I need this
because I need repeating field values in "EntityReference select list
widget" as I would with "autocomplete widget" or as shown in the module "Double Field".
thanks and sorry for my english


texts: Run "git" on remote server with drush alias

texts:
I would like to launch git commands, on my production server, from my pc.
The document root of the production application is a clone of the git repository.

On prod, on sites/all/drush/drushrc.php I've add this line:

<?php

// Drush aliases
$options['shell-aliases']['git-status'] = '!git status';

If I login on production and I execute "git status", everything works.

If I try to execute, from my pc "drush @mysite.prod git-status" I obtain:

fatal: Not a git repository (or any of the parent directories): .git
Command git status failed.

Note that if I try to run "drush @mysite.local git-status", works (and my local copy is like the production copy, the document root is the clone of git repository).

What's wrong?
Document root directory declared on my alias is right (other commons drush commands work) and is a checkout of git repository.

Thanks.


texts: How to clear cache for config entity after making changes?

texts:
We have a custom form mymoduleForm that has mymodule.settings which stores some values that we need to run some logic when calling mymodule_preprocess_node() hook. The form just has a text area where we insert URIs and use that in the mymodule_preprocess_node hook to perform some action.

We can store the values in a Config entity as expected (see below). When we make changes to the Config entity, we want to clear cache for the config entity as well. How can we clear the Config Entity's Cache after making changes?

Goal:

When there are updates to the Config entity, clear the cache for the entity so that the latest entity is used in mymodule_preprocess_node hook.

Issue:

When we make changes to the Config entity using the custom form, the logic that we need to run is not running with the latest settings.

What we have tried:

Tried adding addCacheableDependency($form, $config);  to the buildForm(), but it is not working.

mymoduleForm.php

class mymoduleForm extends ConfigFormBase {
  public function buildForm(array $form, FormStateInterface $form_state) {
    if (!$this->entity->isNew()) {
        \Drupal::service('renderer')->addCacheableDependency($form, $this->entity);
      }

    $config = $this->config('mymodule.settings');

    $form['some_field'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Some field title'),
      '#description' => $this->t('some description'),
      '#default_value' => $config->get('some_field'),
    ];

    return parent::buildForm($form, $form_state);
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('mymodule.settings'),
      ->set('some_field', $form_state->getValue('some_fields'))
      ->save();
  }
}

mymodule_preprocess_node

function mymodule_preprocess_node(&$variables) {
  $config = \Drupal::config('mymodule.settings');
  $config_value = $config->get('some_field');

  $library = 'mymodule/some-library';

  if($config_value == 'some_value') {
    $variables['#attached']['library'][] = $library;
  }
}


texts: How to utilize custom form modes to edit a user entity?

texts:
My project requires two different pages to edit a user. The first one being at /settings/{user}/my-profile, where the user updates their name, address, etc. The other page is at /settings/{user}/login-credentials, where the user updates their username, password, etc.

After navigating to /admin/structure/display-modes/form, I have created a custom form mode called "My Profile" which has the id user.my_profile, and activated it at the bottom of admin/config/people/accounts/form-display.

Now I need to create a page that utilizes this new custom form mode, and I'm a bit lost.

I looked into how the standard user edit route is created at /user/{user}/edit, and I found the code in the route provider at namespace Drupal\user\Entity;. This is what is in that method (other routes have been removed)...

public function getRoutes(EntityTypeInterface $entity_type) {
  $route_collection = new RouteCollection();

  $route = (new Route('/user/{user}/edit'))
    ->setDefaults([
      '_entity_form' => 'user.default',
      '_title_callback' => 'Drupal\user\Controller\UserController::userTitle',
    ])
    ->setOption('_admin_route', TRUE)
    ->setRequirement('user', '\d+')
    ->setRequirement('_entity_access', 'user.update');
  $route_collection->add('entity.user.edit_form', $route);

  return $route_collection;
}

Then I did some research on the routing system, and I've created a routing.yml file. The name of my module is sc, and the file is at modules/custom/sc/sc.routing.yml.

sc.routing.yml

sc.my_profile.edit:
  path: '/settings/{user}/my-profile'
  defaults:
    _entity_form: 'user.my_profile'
    _title_callback: 'Drupal\user\Controller\UserController::userTitle'
  requirements:
    user: '\d+'
    _entity_access: 'user.update'
    _permission: 'access content'

I'm logged in as user1, cleared the cache, and when I navigate to /settings/1/my-profile, I get "Page Not Found". Am I on the right track? How do I create these pages with different form modes?


texts: Email not sent with csv file as attachment

texts:
I have implemented custom function to send email with csv file as attachment.
CSV file content is created on the fly.
When I setup email header but text "Content-Type: text/html; charset="utf-8", this getting append in .csv file.

Here is code from custom module function

$message = array(
      'headers' => array(
      'From' => $from,
      'Sender' => $from,
      'Return-Path' => $from,
      'MIME-Version'=>'1.0',
      'X-Mailer' => 'Drupal',
      'Content-Type' => 'text/html; charset=UTF-8;'
      ),
   'id' => 'pathchange_notice',
   'to' => $to,
   'subject' => $subject,
   'body' => array($message),

);

$uid = md5(uniqid(time()));
$boundary = "--$uid";
$content = //csv content

$headertext .= "Content-type: text/csv;boundary=".$boundary." name=".$name."\n";
$headertext .= "Content-Transfer-Encoding: 7bit\n";
$headertext .= "Content-Disposition: attachment; filename=".$name."\n\n";
$headertext .= $content;

//$message['headers']['Content-type'] = "";
$message['headers']['Content-Transfer-Encoding'] = '7bit'.$headertext;
$message['headers']['Content-Disposition'] = 'attachment;filename='.$name."--".$boundary ."--\n";

$system = drupal_mail_system('mime', 'notice');
$message = $system->format($message);
$system->mail($message);

I can receive email with attachment but when I open csv file, I can see Content-Type: text/html; charset="utf-8".

"Voucher Id","First Name","Last Name"
"876-56325-827","Hollis","Rutledge"

Content-Type: text/html; charset="utf-8"


texts: Autosubmit for exposed filters and .appendTo

texts:
I want the combobox to my self send exposed filter, I have no problem there it succeeds to do with .change, the problem is that these combobox need them in another div outside the container exposed filter.

This is the code I'm working on:

$(document).ready(function(){

  $('.form-item-sort-bef-combine,.views-widget-per-page').appendTo('.view-header');

  $('#edit-items-per-page, #edit-sort-bef-combine').change(function() {

    // Submit the form
    //$('.block-views').find('form').submit();
    //$('form#views-exposed-form-vacation-rentals-kiawah-rentals-home').submit();

   $(this).parents('form').submit();

  });
});

Everything works until active .AppendTo


texts:
I'm in a project where the main login form must not have a password field. The user will login with a username and selecting a Country. This country field is configured within the user profile.
So far, I can manage to log in users checking their username and the selected countries, but I can't find anything not to require a password for login.

This is my code.

function hdp_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login_block') {
    // Add country field to login form
    $form['pais'] = array(
      '#type' => 'select',
      '#title' => t('Pais'),
      '#options' => array(
        'Argentina' => t('Argentina'),
        'Chile' => t('Chile'),
        'Peru' => t('Peru'),
      ),
      '#required' => TRUE,
    );
    // Add validation to check country-username
    $form['#validate'][] = 'validacion';
  }
}

function validacion(&$form, &$form_state) {
  // Variables.
  $usuario_nombre = $form_state['values']['name'];
  $usuario_pais_seleccionado = $form_state['values']['pais'];

  // Search user countries by username. Username must not be duplicated.
  $uid = db_query("SELECT uid FROM {users} WHERE name IN ('$usuario_nombre')")->fetchField();
  if (!empty($uid)) {
    $paises = db_query("SELECT field_paises_value FROM {field_data_field_paises} WHERE entity_id IN ($uid)")->fetchAll();
    $paises_habilitados = NULL;
    foreach ($paises as $pais) {
    $paises_habilitados .= $pais->field_paises_value;
  }

  // Check if selected country is one of the user profile selected countries.
  $habilitado = strpos($paises_habilitados, $usuario_pais_seleccionado);
  if ($habilitado === false) {
    form_set_error('pais', 'Acceso denegado. Por favor revise su nombre de usuario y el país seleccionado.');
  }
}


texts: How to redirect a page to the custom location after form validation?

texts: I have a form with comment section. when the comment is given as empty it redirects to the page called /comment/reply. I have to change it to my custom path. how can i do this


texts: How to login into Drupal 8 using the REST API?

texts:
Ok i've spent my whole afternoon trying to get this running:

Setup a freshly installed Drupal 8
Activate the WebServices (HAL, HTTP Basic Auth, Restful Webservices, Serialization)
Install REST UI Module
Activate the REST Module for e.g. /user/{user} under Configuration -> Web-Services -> REST (i'm activating GET/POST with json and basic_auth)
Fix the permissions so all "authenticated user" can access the Restful Webservices for User content

I basically followed this tutorial to get there: https://drupalize.me/blog/201401/introduction-restful-web-services-drupal-8

Then i go forward and create a POST call looking like this:

GET http://{my-host}/user/testing

// with following headers obj
{
  'Authorization': 'Basic dGVzdGluZzptYXN0ZXI=',
  'Content-Type': 'application/json'
}

Well, the user "testing" really exists, i've checked this like 100 times. The Basic Authorization user i'm giving him (i obfuscated the data here since it is still plain text base64) - believe me, it is a correct credential too, even from the admin user.

The path is correct too with /user/{user} - but he is always returning a 404 Not Found ...? Why?

Well what i try to achieve is a login trough a REST API call - so i can login with an existing drupal user from an external system (auth0). As far is i understood from the docs this should all be possible with the /user/{user} endpoint - but i'm totally unsure because i couldn't find any working examples for it.


texts: How to render a @FormElement in Views area plugin

texts:
I am doing a custom plugin area for displaying some data in a views footer (Drupal 8).

I do something about just like this : Create a custom area plugin

The only point is, instead of #markup in the return array of render() method, I would like to return some more complex stuff.
If I try to return a textfield if works:

return  [
  '#type' => 'textfield',
];

If I try another form API element (defined via a @FormElement): it does not render.

return  [
  '#type' => 'datetime',
];

Two questions:

Should it render ?
If not, I can render a block there using this (ViewsBlockArea) how to do the equivalent but with a FormElement instead ? (actually rendering a form API render array.)

EDIT: Here a the finality of what I want to render:

$element['form'] = [
  '#type' => 'commerce_coupon_redemption_form',
  '#order_id' => $order->id(),
  '#cardinality' => 1,
  '#element_ajax' => [
    [get_class($this), 'ajaxRefreshSummary'],
  ],
];

But you may see that more trivial render array like the datetime one given above does not work either.

Also notice that any element defined by a @FormElement annotation from within the namespace Drupal\Core\Render\Element is okay.
But @FormElement "from elsewhere" like datetime does not render.


texts: Use mobile phone number as account ID so users dont have to register?

texts:
Im making a mobile first site. Is there a way of using a user's mobile phone number so they dont have to register for an account?

Or, if a user creates an account the normal way on a desktop and enters their phone number, is it possible to detect when the visit the site with a phone from that number and log them in?

Thanks


texts: How to remove Submission information from webfrom module

texts:
I am using webform module and when I get an email from a user it is displayed with this information:

Submitted on

Submitted by user:

Submitted values are:

I don't want to this information I just want to display form information only  .


texts: user_register_form not give pre filled form

texts:
I have created a module for user listing. when I edit any user then call drupal_get_form('user_register_form', $existing_account);, its not give me form with user data.

I used Profile2 module to add some custom filed in user registration page. Now in admin , I need those custom fields with user data in it.
for that I used drupal_get_form('user_register_form', $existing_account); function where $existing_account = user_load($uid, $reset = TRUE);

  function mymodule_create_subscriber() {
  ....

  $existing_account = user_load($uid, $reset = TRUE);

  .......
  $extra =drupal_get_form('user_register_form', $existing_account);

   $form = array_merge($form,$extra);

     $form[actions]['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update Subscriber'),
      '#weight' => 30
$form['#validate'][] = 'mymodule_create_subscriber_validate';
  $form['#submit'][] = 'mymodule_create_subscriber_submit';
....
}

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

 ....some code

  return;
}

function mymodule_create_subscriber_submit(&$form, &$form_state) {
$account = array();
  $account = $form_state['values'];

......
 $account = user_save($existing_account, $account, $category);
   .....
}

Please help me where I am doing wrong or what should I do?


texts: How to add and remove tabs from/to My Account page

texts:
I have created a role Customers. I added UserA to the role. When I logged in as UserA, I see My Account link in the Header region. After I click My Account, I see three tabs : Views, Edit, Checklists. How to remove Edit and Checklists tabs from the My Account page?

I created a page view. The path for the page view is xxx.com/payments. How can I add a new tab (Payment) next to Views tab on the My Account page? When UserA clicks the Payment tab, the page view xxx.com/payments displays right under all the tabs.


texts:
I am seeing a problem on my Drupal 7 site relating to image styles.

A bit of background - This site was built by migrating the content and config from a previous site, using the Migrate and Features modules, after the previous site fell victim to Drupalgeddon. The new site seems now to be 99% working. (After fixing a lot of stuff that wasn't properly copied across by Migrate and Features - whether that was due to my inexperience in using these modules, or shortcomings of the modules, I don't know.)

One thing that isn't working is uploading image files into fields of type Image.

The Image gets uploaded successfully and is accessible from /sites/default/files/.
But no files are being created in any of the subfolders below /sites/default/files/styles. So the thumbnails don't display.

I've tried a lot of the advice I've found while Googling - the UNIX file permissions seem to be OK, the Drupal permissions seem to be correct, I can't seen anything wrong in the .htaccess files, but perhaps someone out there can give me better guidance on what to look for here.


texts:
How can I do to add more conditions on WHERE, like this
WHERE view conditions ... AND ( (sentence 1 AND sentence 2) or (sentence 3 AND sentence 4) or ... )
This view is in a user profile and this conditions depens on profile data.

Thanks


texts: Entity references or Relation for AB , BC and A =>(B)=> C?

texts:
Another which module question ... I know. Sorry for that. But time changes answers.

I need transitive bi-directional references, where both ends know from each other (to handle them with rules, actions and tokens) and also their wanted imaginated "position" in their relation (higher, lower, left,right), you name it. While I was very impressed by the kick start of relation module, which seems to be able to do that, and which had immense support from long term Drupal supporters like CHX, I am scared now of if this project would scale in the next years continuously. I can't force it. The API looks good and naught101 and others are around and very smart, but the project feels a little bit isolated in Drupal land and I can imagine that it isn't the maintainers most wanted life plan to fight for relation module. I know the question is old but in the moment the wind changes and the question is new. I am a contributor (patches, modules), but I am not in the position to change the wind in the woods, if you know would I mean. And I have to care about the route for this, because it is strongly connected to my self-employed project. I always share but this time I have to care about the outcome of the right decision.

So, my question is: do I need to put my power in the relation module and help their (no problem with that) to get deeper into it to come closer to my approach or would it be more smart to try to get it done with the so entitled more "limited" entity references module, which seems to be well supported ATM and is part of the D8 campaign? I would like to hear your opinions.

Naught was so kind to mention on the project page of relation, that this kind of relations are maybe also possible to made with entity references, but only under certain circumstances and a third connector entity. But does the referred entity "know" that it was chosen from another? I don't think so.

Let's paint an example near to mine: A task can only be set to fixed, when a "lower" related task in the hierarchy is set to "fixed". Before that, rules would hide the fixed button for this task. That means many tasks are related to each other and really "know" each other and are in a flexible hierarchy and it can change its weight, if one task gets the milestone of the other task. On both ends you can see the relation to the other. I am not sure if entity references is able to do this. Even if I have views and 3,4,6 own patches at hand showing the references on each ends, there is still this slidely "feeling" of only one  "real" direction which refers to only one end. Isn't it? Sorry for the old question but we need a refresh on this...

Related questions:

How can I implement 3-way relationship (reference) between entities?
Relation vs. References vs. Entity Reference for managing node-reference-type relationships

Another question is: do I come into trouble having them both on the same project?


texts: How to pass data between operations of a single Batch?

texts:
Is there any way to pass data between operations of a single Batch, when using Batch API ?

for an example, say I have $batch['operations'] as an array like this:

// Basic batch stuff to $batch here.
$batch['operations'] = array(
  array('my_initialize', $xyz),
  array('my_worker', $data),
);

// batch_set, process, etc.

function my_initialize($xyz, &$context) {
  // Can I process something here and pass it to
  // the operation 2 (my_worker) ?
  // May be some key in $context ?
}

function my_worker($data, &$context) {
  // How I can access some result from the my_initialize() function ?
}

I know I can set $context['sandbox'] but that's related to a second call if I set $context['finished'] = FALSE;

I'm currently storing data (it's some kind of chemistry formula which is expensive to store in the operation itself or calculate before batch_set) in $_SESSION in my_initialize and unset it in finished function but I'm curious is there any better way to do this.


texts: Create menu link for authenticated user programatically

texts:
So here is what I've tried in custom module dir I've created module.links.menu.yml file here is code. I want to just for authenticated user beside Content link have my custom link to access Webform. Also, do I need routing file to?

description: "Link descr"
menu_name: main
parent: system.admin
url: 'internal:/admin/structure/webform'
  route_name: entity.webform.collection
title: "Webforms"
weight: -48
requirements:
      _role: 'authenticated'


texts: Distinct classes for each row in views-table

texts: Is there a code that I add to my views style tables file that will give me distinct classes for each row in a views-table? or is there a module? I am working in Drupal 6


texts: Showing child taxonomy terms if the parent is selected

texts:
I want to show one drop-down with a list of parent vocabulary terms and then when one of those select corresponding child terms displays in page.

I am using Drupal 7 with views 7.x-3.0-rc1.Any one guide me do this.


texts: How to pass values to content creation page to set default values in form elements?

texts:
Introduction (not necessarily needed to be able to answer the question)
I use Domain Access module to be able to manage different sites from one Drupal installation and a single shared database. I enabled Domain Content submodule that provides a content administration page for each subdomain.
Instead of having all contents of all domains displayed at /admin/content, this allows to display all contents of a given domain at /admin/content/domain-content/mydomain.
What I'd like to do
I'd like to prefill a form element in Create Article page according to a given domain.
So I plan to add a Add content button at /admin/content/domain-content/mydomain, and pass the parameter mydomain from here until, for example, Create Article page.
Then I'll be able to prefill (tick) the right domain checkbox in the Create Article page according the passed argument.
My question
How to pass parameters between the given admin pages to be able to prefill a form in Create Article page?


texts:
I'm having a problem when executing a drush command on a group of aliases that are all remote.

When I do this:

drush -y @group.host1 status -v

all works fine.

When I do that:

drush -y @group status -v

it fails with the following message for each host in that group:

ssh -o PasswordAuthentication=no host1 'DRUSH_PHP=/usr/bin/php drush  --backend=2 --verbose --yes --uri=www.example.com --root=/var/www --reserve-margin=28  status 2>&1' 2>&1
fish: Unknown command 'DRUSH_PHP=/usr/bin/php'. Did you mean to ru
n drush with a modified environment? Tr
y 'env DRUSH_PHP=/usr/bin/php drush…'. See the help section on the set command by typing 'help set'.
Standard input: DRUSH_PHP=/usr/bin/php drush  --backend=2 --verbose --yes --uri=www.example.com --root=/var/www --reserve-margin=28  status 2>&1

So, how I read the error it looks like fish (which is the shell used instead of bash) is having an issue with the command

ssh -o PasswordAuthentication=no host1 'DRUSH_PHP=/usr/bin/php drush  --backend=2 --verbose --yes --uri=www.example.com --root=/var/www --reserve-margin=28  status 2>&1' 2>&1

Now what's the difference when I call the same thing for @group.host1 instead of @group? Then the command looks like this:

ssh -o PasswordAuthentication=no host1 'drush  --backend=2 --verbose --yes --uri=www.example.com --root=/var/www --reserve-margin=28  status 2>&1' 2>&1

The difference is that the leading "DRUSH_PHP=/usr/bin/php" is missing and then it works fine.

I have played around with /usr/bin/drush and removed the option --php="$php" from the last line in that file, and then everything works fine again too.

Important: This only happens since I've upgraded to Drush version 6.2 - before I had 6.0 on my local laptop and 5.9 on the host1.


texts: How to Inherit field values of a taxonomy terms

texts:
I have quite a large taxonomy term hierarchy with several data fields. Most of time childs and parents have the save values. I'm trying to avoid duplicating the information and thinking about organizing some kind of inheritance. So that value of a field of a term is looked in the term, then if it's empty, in it's parent, and so on.

I'll do some calculations on that values, it's easy using the taxonomy_get_parents_all api function. But what puzzles me is how to make Drupal take these inherited values into account when it renders term pages.

It probably has to do with hook_taxonomy_term_load, but how to do it properly, so that user can edit actual term values, but in all other places the inherited values are taken into account?


texts:
I try to import a csv (or excel with feeds_xls) with a title-, date- and body field in Drupal 7. The date has a calendar widget

When imported the date is empty. I think because of the difference in notation:

English: Y/m/d H:i
Belgian: d/m/Y H:i

My client has to be able to use the Belgian (EU) notation. He or she puts it in the .csv like this:

d/m/Y

for example: 19th of August 2016 becomes a string:

'16/8/2016'

I have tried the following steps:
- dev-version of the feeds_tamper module
- tried the feeds_tamper-str_to_time_with_custom_format_plugin-2631092-1.patch
- tried the strtotime plugin of the feeds_tamper module
- wrote a custom plugin that tries to convert the string
- tried a text-widget

The closest I get is what I think is the original item:

array(
  'TITEL' => 'Test',
  'DATUM' => '41671',
  'BESCHRIJVING' => 'test',
)

that is the right date (DATUM). Can anyone shine a light on this for me?


texts: Can original text be edited in translate interface or elsewhere?

texts:
When translating strings in the translate interface, I would also like to be able to edit the "original text" (for the default language), and not only fill in the translation strings for other languages.

Indeed, it's no secret you regularly have to modify or improve the text of a website pages. If the website is multilingual, each time you make such a change, you have to do all this foe each piece of text :

recreate the translation set by reloading the involved page/template
in the desired language
find and delete the initial translation set in the translate
interface
refill the new translation set with the same translation as the
original one in the translate interface

It would bee so much easier to be able to edit the original source text of the initial translation set...

Maybe I'm missing this feature somewhere... can anyone help me on this ?
Thanks you so much for your answers.


texts: Add a local task tab for a content type only

texts:
Someone can help me ? I want to display a tab only when the content type is 'test'.

Here's my files.

mymodule.routing.yml :

mymodule.check_test:
  path: '/checktest/{node}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\CheckTestController::content'
  requirements:
    _access: 'TRUE'

mymodule.links.task.yml :

mymodule.check_test:
    title: Display tests
    route_name: mymodule.check_test
    base_route: entity.node.canonical

My tab is displayed for every content, i don't know how to filter with my content type...

Thanks :).

Edit :
From mradcliffe's answer,

I've add a mymodule.services.yml :

services:
  access_check.test:
    class: Drupal\mymodule\Access\MyModuleTestAccess
    tags:
      - { name: access_check, applies_to: _access_test }

and a MyModuleTestAccess class with :

public function access(NodeInterface $node)
{
    return AccessResult::allowedIf($node->bundle() === 'test');
}

My edited mymodule.routing.yml :

mymodule.check_test:
  path: '/checktest/{node}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\CheckTestController::content'
  requirements:
    _access_test: ''


texts: How do I get a paginated view to display rel="next/previous" tags?

texts:
Using Drupal 7.

I've got several views (most of which listing articles which have been posted) that paginate and I'd like to add;

<link rel="prev" href="http://example.com/recent-articles?page=0" />
<link rel="next" href="http://example.com/recent-articles?page=2" />

links to them.

How do I do this? A module is preferred, changing the php files would preferably be avoided.

Things I've tried:

Lightbox2 (module)
Metatag (module)
Meta tags quick (module)
Views controls themselves
REL Links (module)


texts: Please  advise me on the correct value to choose for “Page cache maximum age” as a cachin strategy (I’m running a medium Drupal 8.5.3 website).


texts:
The default search results in D7 seem to include details of the node author, date, number of comments as seen here but I don't want these in my search results.

I have copied search-result.tpl.php and search-results.tpl.php to my theme file. I have added

print '<pre>'. check_plain(print_r($info_split, 1)) .'</pre';

to search-result.tpl.php. The result is here ie showing the array with [user] [date] [comment] etc

What do I need to do to exclude author / date / number of comments from the search results? If it involves my theme's search-result.tpl.php what should be the contents of search-result.tpl.php ?


texts: Show items not linked by a view relationship

texts:
I have two content types: Item and Order.

There is a link from Order -> Item through field_items.

I have a view showing content of type Item and any related order data in a table. I have set up a non-required relationship to Content using field_items to reference the Items.

I have a filter on the view to ensure that the content type on this relationship = Order. This is because I have another content type which is not shown on this view that uses field_items.

The view functions largely as required. However, it only shows Items that are linked to an order via field_items whereas I would also like it to show items for which this link doesn't yet exist.

I have tried adding a second condition for content type on the relationship is EMPTY and putting the two filters into a filter group with the OR operator. However, when I do this, nothing shows up in the view.

How do I get the view to show all Items (linked or not) with linked Order data where this exists?


texts: How to get user all order_items from different orders by entityQuery

texts:
I want to know if the user has purchased the specified product. I know the SQL. But I am learning to use entityQuery.
Example: user_id = 1, product_variant_id = 5
SELECT *
FROM commerce_order
    INNER JOIN commerce_order_item ON commerce_order.order_id = commerce_order_item.order_id
WHERE (commerce_order.state = 'completed')
    AND (commerce_order.uid = 1)
    AND (commerce_order_item.purchased_entity = 5)
ORDER BY commerce_order.completed DESC

Could anyone help me tansfer to entityQuery?


texts: How to implement redirect in kernel.request event properly?

texts:
I can reach site by multiple aliases. Business logic requires to do some redirects in case of accessing be an alias. E.g: alias1.dev -> site.dev/landing-page.

I've implemented EventSubscriber for this job. When I'm testing in browser it seems to work fine, but under the hood redirection workflow is:

alias1.dev -> alias1.dev/front-page -> site.dev/landing-page

So I've redirect to page.front in the middle. How to avoid it?

I was debugging a lot but found nothing useful.


texts: Using Panels for Layout versus custom .tpl files

texts:
I'm working through some layouts that aren't entirely complex but are definitely outside of the core Drupal provides.

It really does seem like there a 20 ways to do one thing in Drupal.

Should you edit .tpl files with different regions for specific content types and nodes, or should I just stitch everything together with Panels?

I have this fear that Panels would make everything more complex and start to bog things down from a performance perspective.


texts: Dynamically loading terms in a term reference tree from a huge taxonomy so users may select nodes as options

texts:
I'm trying to create a form that uses a bushy taxonomy of about 30,000 (max depth is ~9) terms to allow users to select multiple nodes from the tree.  The Taxonomy Term Reference Tree Widget fits the functionality I need perfectly, but with the size tree that I'm using each expand/collapse or select event takes a couple of seconds to complete, which isn't acceptable in terms of performance.

I'm new to drupal, but haven't been able to find a widget that can perform this task quickly. Are there any D7 widgets or modules that can accomplish this task? It seems that if I were able to have the widget not load all of the children all at once that performance might increase, but I can't say I'm sure.


texts:
I'm trying to overwrite the FULL LOGIN PAGE, not only the login form!

I've tried this

function your_themename_theme() {
  $items = array();
  // create custom user-login.tpl.php
  $items['user_login'] = array(
  'render element' => 'form',
  'path' => drupal_get_path('theme', 'your_themename') . '/templates',
  'template' => 'user-login',
  'preprocess functions' => array(
  'your_themename_preprocess_user_login'
  ),
 );
return $items;
}

and this:

function YOURTHEME_theme() {
  return array(
    'user_login' => array(
      'template' => 'user-login',
      'variables' => array('form' => NULL), ## you may remove this line in this case
    )
  );
}
function YOURTHEME_preprocess_user_login(&$variables) {
    $variables['form'] = drupal_build_form('user_login', user_login(array(),$form_state)); ## I have to build the user login myself.
}

but that's only working for my login form. I have a website with all same layout pages but only the login is different. How can I disable regions and edit css from my login page?

UPDATE:

Now I changed the name of the template to page--user--login.tpl and when I put
test
 in my the template I see test in my browser. But when I type nothing I see the login form but also my sidebar/footer. How can I remove them?


texts: Escaping CSS digits, 0 is removed from CSS aggregated files

texts:
The following HTML markup won't work on a production site.

TEXT

This is the code in the custom.css file.
.iconleft.\31 09,
.iconleft.\31 12,
.iconleft.\31 10,
.iconleft.\31 11,
.iconleft.\31 20 {
  background: #B0CD00;
}

.iconleft.\31 09 works on localhost with xampp and no aggregation. On the production site, where Advanced CSS/JS Aggregation is activated, it wont work for 109.
In the aggregated CSS file, I see .iconleft.\31 9 as CSS class. It seems that 0 has been removed.
Do you have any hint?


texts: How to parse PHP variables in drupal_add_js in template.php

texts:
I'm using drupal_add_js for some inline jQuery - I need to parse some php variables in the inline jQuery, what is the correct way to do it?

drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);

I've tried this, and it DOES print the variable, but breaks the JS code in the process (splits the jquery code up and doesnt function) :

drupal_add_js('jQuery(document).ready(function () { alert(" '. print $site_name .' "); });',
  array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);


texts:
I would like to add a body class in D6 if you are on a specific page(s) currently in my template.php I have:

if url('the/path') {
 add the body class...
}

but that function doesn't seem to be working for me.


texts: All File Descriptions from Multiple Value Field Showing Up for Each File in Views

texts:
I hit a little snag setting up this View for uploaded documents. I use a multi-uploader field to upload two files to an Entity. I've added descriptions for each file. When I try and display this in views, this is what I get:

Name
filename1
filename2

Description
filedesc1, filedesc2
filedesc1, filedesc2

It should be:

Description
filedesc1
filedesc2

The Description is a multiple value field, I'm assuming this is just spitting out array values for each record. Is there a way to step through this field so that the correct descriptions line up to the correct File Name?


texts: Validate a field date value in a node, only if there isn't a Google Calendar Event in my public calendar for that day

texts:
I need to validate a date value only if there is not created an event for that specific date in my public google calendar.

I have found a field validation project (https://www.drupal.org/project/field_validation) where I can type php to validate a field. What php do I type please to do this?
Thanks


texts: Remove Block Directly From Database - Drupal 7

texts:
I created a block and put in some invalid PHP code resulted in entire site not accessible at all.

I'm fairly new to Drupal and I'm not a back-end programmer either. Much appreciated if you can provide a clear step-by-step guide on how to delete that particular block directly from the Database (PhpMyAdmin).


texts: How do I add a region to the Color module?

texts:
I have a menu I would like to be able to style with the Color module.  I have found many examples for the Drupal 7 Color module and they have led me to believe that if I just add a line to the 'fields' array in the color.inc file in my theme I will be able to add more regions.

Below is my 'fields' array.  I copied an existing file as a guide and simply added my primary menu

'fields' => array(
  'top' => t('Header background top'),
  'bottom' => t('Header background bottom'),
  'primarymenu' => t('Primary navigation menu'),
  'bg' => t('Main background'),
  'sidebar' => t('Sidebar background'),
  'sidebarborders' => t('Sidebar borders'),
  'footer' => t('Footer background'),
  'titleslogan' => t('Title and slogan'),
  'text' => t('Text color'),
  'link' => t('Link color'),
),

I just added the 'primarymenu' field to the standard bartik array

I realize there is more to do to connect this field to something so it will actually change colors but everything I can find is for D7 and requires altering php templates.

Why is my field not showing up in the appearance settings menu and how do I connect it to change the color of my menu?

Edited To add the schemes array

'schemes' => array(
'default' => array(
  'title' => t('Blue Lagoon (default)'),
  'colors' => array(
    'top' => '#055a8e',
    'bottom' => '#1d84c3',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#f6f6f2',
    'sidebarborders' => '#f9f9f9',
    'footer' => '#292929',
    'titleslogan' => '#fffeff',
    'text' => '#3b3b3b',
    'link' => '#0071B3',
  ),
),
'firehouse' => array(
  'title' => t('Firehouse'),
  'colors' => array(
    'top' => '#cd2d2d',
    'bottom' => '#d64e4e',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#f1f4f0',
    'sidebarborders' => '#ededed',
    'footer' => '#1f1d1c',
    'titleslogan' => '#fffeff',
    'text' => '#888888',
    'link' => '#d6121f',
  ),
),
'ice' => array(
  'title' => t('Ice'),
  'colors' => array(
    'top' => '#d0d0d0',
    'bottom' => '#c2c4c5',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#ffffff',
    'sidebarborders' => '#cccccc',
    'footer' => '#016b83',
    'titleslogan' => '#000000',
    'text' => '#4a4a4a',
    'link' => '#019dbf',
  ),
),
'plum' => array(
  'title' => t('Plum'),
  'colors' => array(
    'top' => '#4c1c58',
    'bottom' => '#593662',
            'primarymenu' => '#ffffff',
    'bg' => '#fffdf7',
    'sidebar' => '#edede7',
    'sidebarborders' => '#e7e7e7',
    'footer' => '#2c2c28',
    'titleslogan' => '#ffffff',
    'text' => '#301313',
    'link' => '#9d408d',
  ),
),
'slate' => array(
  'title' => t('Slate'),
  'colors' => array(
    'top' => '#4a4a4a',
    'bottom' => '#4e4e4e',
            'primarymenu' => '#ffffff',
    'bg' => '#ffffff',
    'sidebar' => '#ffffff',
    'sidebarborders' => '#d0d0d0',
    'footer' => '#161617',
    'titleslogan' => '#ffffff',
    'text' => '#3b3b3b',
    'link' => '#0073b6',
  ),
),

),


texts: Dealing with nodes that do not have the field when sorting views using date field

texts: I have an 'Expired' date field that holds the date when a node expires. However, not every node has this field so nodes missing this field come after nodes containing the field. I want nodes that do not have this field to be sorted above nodes that have the field. How can I do this?


texts: how to display an image in theme using img tag?

texts:
I need to display an image in the page footer using  tag. In my page.tpl.php I have following block:

<?php print t('Copyright'); ?> &copy; <?php echo date("Y"); ?>

I can`t use print $logo since I can use another image for the logo.


texts: Translation mess up with fields which are not translatable used in views

texts:
Example set up:

Content type news with fields

Body (translatable)
date (another date field beside node published date - translatable)
type of news (list field - not translatable, the news should be of the same type in every language)

View with filters:

Published: yes
Content type: news
Content language: currently activated interface language
field "type of news" -> exposed to the user

Default language in the project is German.

When I go to the view in German and choose a type of news in the exposed filter there is no problem - the expected news are listed. The problem appears when I enter the page in English and I choose a type of news -> no results are found although the same nodes are translated into English.

I found out that this is due to the fact that the "type of news" values in the fields table are saved with the language id of the original node which is 'de' but the full view query expects the field value to have a language code 'en' (like the currently activated language has).

See this query and especially the INNER JOIN:

SELECT node__field_date.field_date_value AS node__field_date_field_date_value, node_field_data.nid AS nid, node_field_data.langcode AS node_field_data_langcode
FROM
{node_field_data} node_field_data
INNER JOIN {node__field_news_typ} node__field_news_typ ON node_field_data.nid = node__field_news_typ.entity_id AND (node__field_news_typ.deleted = '0' AND node__field_news_typ.langcode = node_field_data.langcode)
LEFT JOIN {node__field_date} node__field_date ON node_field_data.nid = node__field_date.entity_id AND (node__field_date.deleted = '0' AND node__field_date.langcode = node_field_data.langcode)
WHERE (( (node__field_news_typ.field_news_typ_value = 'press') )AND(( (node_field_data.langcode IN  ('en')) AND (node_field_data.status = '1') AND (node_field_data.type IN  ('news')) )))
ORDER BY node__field_date_field_date_value DESC
LIMIT 10 OFFSET 0

You may see that the inner join expects the langcode field in node__field_news_typ to be the same value as node_field_data.langcode which is 'en' when I enter the view in English. But looking into the table of node__field_news_typ I do not find one entry with 'en' as the field is not set to be translatable and all the nodes are originally written in German.

Maybe I did not get some basics of the multilanguage architecture in Drupal 8 but I find it a little bit strange that fields which are not translatable filter out nodes in views where a filter is set to "current active language". Is there not UNDEFINED_LANGUAGE ('und') anymore? Why do fields get a fix languagecode when they are not translatable? How can I avoid this behavior?

It seems to me that there is no other way as setting the field to translatable although I want to assure that translated nodes have the same value?!


texts: How can I display a reset password form on its own?

texts:
Thanks a lot for your posting about building a form on its own to change user password.
I used your suggested approach and I coud implement easily many isolated forms to let people change password, avatar, and so on.

What I cannot solve is how to use the same logic to reset forgotten password on a form on its own called from the one-time login link.

I tried this:
- I installed module Login Destinations and added the following destination rule triggered on one-time login link:

    global $user;
    // Let the user's password be changed without the current password check.
    $token = drupal_hash_base64(drupal_random_bytes(55));
    $_SESSION['pass_reset_' . $user->uid] = $token;
    return array('change-password', array('query' => array('pass-reset-token' => $token)));

It is triggered from user/reset/*.

change-password is my custom form implemented like this.

function _tb_user_render_user_pass_set_new_form() {
  global $user;
  if (!user_is_logged_in()) {
    drupal_access_denied();
  }

  module_load_include('inc', 'user', 'user.pages');
  $form = drupal_get_form('user_profile_form', $user);
  $children = element_children($form);

  foreach ($children as $child) {
    if (!($child == 'account' || $child == 'actions' || $child == 'form_build_id' || $child == 'form_token' || $child == 'form_id' || $child == 'current_id' || $child == 'revision_id' || $child == 'current_date')) {
      unset($form[$child]);
    }
  }

  $children = element_children($form['account']);
  foreach ($children as $child) {
    if (!($child == 'current_pass_required_values' || $child == 'pass')) {
      unset($form['account'][$child]);
    }
  }

  return $form;
}

It does't work since it still requires current password.

Do you have any idea on how to do that properly?


texts: Is there a distribution optimized for heavy data traffic?

texts:
I am testing an Android app which sends minute-by-minute updates to my Drupal site which acts as a server.

I create a single node each day and all my app data is saved in CCK fields within that node.

I got the updates working yesterday and tested for half a day. When I try to edit the node, to see the CCK data uploaded, my site crashed and complained of lack of PHP memory.

In my .htaccess file, I had set PHP memory to 100M. I then increased it to 300M and then 500M with no improvements. Then I tried 1000M. It worked but it seems slow.

That's just for one user's half a day's worth of data. Eventually, I will have hundreds of users with 24hours data each.

Can anyone tell me if there is a Drupal distribution which handles heavy data traffic by design?


texts: Ubercart payment option without gateway?

texts:
I'm new to this forum, and I'm maintaining a Drupal 6.x webshop using Ubercart 2.4 for a client. The client wants to add a new payment option for business to business customers. These customers wouldn't need to pay at all, but would be invoiced manually from the client.

The client would have to check weather the customer is actually a valid customer for this "payment method", and decide if they can take the order or not, but this would be a separate issue.

How can I add a new payment method that just stores the order with shipping and billing address to my database, no more?

Could I refactor the "Other" option from Payment Pack?


texts: Panels Everywhere and missing Page Title

texts: I am new to using Panels Everywhere and noticed that once I applied PE to my site the page titles went missing. I have site name and slogan and such set up. I can't figure out where the problem is. Has anyone run across this before?


texts: Is it possible to apply Authcache caching to elements in page.tpl.php?

texts:
In applying Authcache settings to an existing site I have encountered a problem where certain items hard-coded into the theme's page.tpl.php need to be personalised for each user. I could do it by moving those components into blocks and/or panels, but they are quite complex and I was wondering if a better approach would be to do it via the Authcache API using the authcache_usercookie.module example as a starting point.

Here is an example of the code I would like to personalise:

<?php if($page['topics_tab']): ?>

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

<?php endif; ?>

Is it possible (easy? difficult?) to modify page.tpl.php to make Authcache cache this snippet for each user, or should I redo the page using blocks/panels?


texts:
Can I add new variable in Computed field?
The added variable will be used only in the computed field


texts: How to choose language for date field in views rss feed?

texts:
I am maintaining a bilingual Drupal 6 site with German being default language and English as secondary. The site offers an RSS feed of German articles. This RSS feed is generated with Views and Views RSS. One of the displayed fields in the feed is the creation date which is in custom format "D, d M Y H:i:s O" for rss clients. The date is always shown in German, i.e. "Mi, 08 Mär 2012 13:44:27 +0200" but I'd like to have this field using English standard, i.e. "Wed, 08 Mar 2012 13:44:27 +0200".

Any idea how I could achieve that?

The feed url is sth. like domain.com/feed (German). If I use the English url domain.com/en/feed, all the date fields are in English format but then the content urls also link to the English version (e.g. domain.com/en/node/123 instead of domain.com/clean-german-url).

Thanks in advance,
Paul


texts: What is the ':input[name=???]' of a subform field?

texts:
and thank you for your contribution.

I have created a custom content type with a field (field_table_2) that is a (list of) paragraph element reference entity.

The paragraph entity, contains 'select' fields (e.g. field_rsn, field_added, field_deleted,...), that we need to hide or show according to selection.

We are reading about Conditional-form-fields, but we cannot find a way to refer to the subform field, eg.:

$form['field_table_2']['widget'][0]['subform']['field_added']['$states'] = [
        'visible' => [
          ':input[name="???"]' => ['value' => 'Added'], // name of 'field_rsn'
        ]
];

What should be the name of field_rsn in the ':input' ?

Are there any ideas/ examples? Are conditional-form-fields possible with 'paragraphs', 'entity references', or in general existing fields in the hook_form_alter?

Thank you in advance.


texts: Redirect to a custom page after a node has been added or edited

texts:
Using hook_form_alter, how can I redirect a user to a a custom page after creating or editing a node instead of the  node that was created or edited?

The current code for hook_form_alter() is the following one:

function custom_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'custom-node-form') {
    $form['actions']['submit']['#value'] = t('Add Entry');
    $form['field_custom_email']['und'][0]['value']['#element_validate'] = array('_custom_form_validate_email');
  }
}


texts:
I'm just curious how other Drupal developers handle nested path aliases when they are based on another page's url pattern.

I have a product landing page (it's a "basic page" node). When it's created, right now, the url is:

/product

For my product nodes, I set up a path alias to be

/product/[node:title]

This makes my product detail pages nicely nested under "product." This works fine for a while. But later, if someone changes the product landing page url, the alias for the product nodes will not match.

Say someone edits the product landing url to be:

/widgets

Then I have a /widgets landing page and a bunch of product nodes with urls like /product/product-name.

Is there a nice way to handle this? Or is it up to content creators to just know they need to update it?


texts:
I need some feature upon Entity Reference module, To clearing I need rendered version of entity in form instead of just entity label.

So before writing new module or hacking Entity reference, I should search for exist modules.

It will be good if I can see all modules dependent to Entity reference. Where can I find sucj list of modules?


texts: How to attach external js to Drupal.behaviours

texts:
If we write js code in Drupal.behaviours like below

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

}
};
})(jQuery);

that code will be execute multiple times on a page if needed even after an ajax callback.

But in the preprocess_node I have added an external js file. The problem is on node page there is a view with an ajax pager.
When I move to next page through views ajax pager(views infinite pager) then that external js did not work.

So my question is, Is there a way to add the external js to Drupal.behaviours?


texts: How do I write this PHP query the Drupal way (database abstraction)?

texts:
I am using the code below to evaluate if a panel pane should display. I've read the docs on database abstraction, but I just don't really understand how to apply it. Of course, the dpm values are for debugging.

(Just to be clear, this code is currently functioning exactly how I need it to, and I am not having any problems with panels itself. I just don't understand how to sanitize this the Drupal way to avoid injection.)

Any help would be appreciated. Here's the code:

// Gets NID of viewed node as well as the parent (passed by entity reference field)
$nid = $contexts['argument_entity_id:node_1']->data->nid;
$parent = $contexts['argument_entity_id:node_1']->data->field_webisode_series_reference['und'][0]['target_id'];

// Returns the 3 newest nodes with same parent as the view node
$recentNIDs = db_query("
    SELECT entity_id
    FROM field_data_field_webisode_series_reference
    WHERE field_webisode_series_reference_target_id = $parent
    ORDER BY entity_id
    DESC LIMIT 3
    ");
$result = $recentNIDs->fetchAll();

// Checks NID of the viewed node against NIDs of the 3 nodes above.
// If true, and NIDs match, then the block is displayed.
foreach ($result as $k => $v) {
    $nid2 = $v->entity_id;

    if ($nid2 == $nid) {
        $top3 = 1;
    }
}

// If $top3 is set, display. Else, do not.
if (isset($top3)) {
    dpm('TRUE', 'top 3?')
}

elseif (!isset($top3) {
    dpm('FALSE', 'top 3?')
}


texts:
I am currently using Drupal Views and its "Load More" Pager. I wish to change the words on the button to say something else instead.

It looks like the UI does not provide me with an easy way to do that, so I am wondering if there is any easy programming way to achieve that.


texts: How to display node title using computed field?

texts:
I have a computed field (text) where I would like to display the node title.

I tried the following thing but nothing worked.

$value = $entity->title;
$entity->title;

I referred

1.
https://blogs.sulross.edu/lwetterauer/computed-fields/

2.
https://stackoverflow.com/questions/14087479/how-do-you-access-the-title-node-module-element-field-in-drupal-7


texts: Form validation not triggered at first submit, but on second submit

texts:
I'm in the need for a extra validation on an existing drupal commerce form (commerce_cart_add_to_cart_form_##), strangely the validation function is not called on the first form submit, but on the 2nd submit and all the submits after the 2nd. There are multiple commerce_cart_add_to_cart_forms on a single page.

Here's my module code:

function val_form_alter(&$form, &$form_state, $form_id) {
    if (strpos($form_id, 'commerce_cart_add_to_cart_form_') !== false) {
        $form['#validate'][] = 'val_commerce_cart_add_to_cart_form_validate';
    }
}

function val_commerce_cart_add_to_cart_form_validate($form, &$form_state) {
    dpm('validating function called');
    form_set_error('quantity', t("ERROR"));
}

Any Ideas?
And, as a second question: there are different $from_ids (commerce_cart_add_to_cart_form_##) that will all need the same validation. Is there a way to call them all other than I did?

Thanks!


texts: How to validate webform with JavaScript?

texts:
I've got a Webform for which I need additional calculations to hidden fields.

I've added a JavaScript file to the page by using drupal_add_js. And let that be the only part that works...

My calculate.js file looks like this:

document.getElementById("webform-client-form-80").onsubmit = function() {
  window.alert("Test!");
  document.getElementsByName("submitted[aantal18plus]")[0].value = 5;
};

Why don't I get an alert? And why doesn't the value of "submitted[aantal18plus]" get altered?
If I change "document.getElementById("webform-client-form-80").onsubmit" to "document.onload", everything works. But unfortunately, there isn't any data yet (tried with windows.alert("");)

A bit more context:
The form is a subcription form for a BBQ. I Have 16 fieldsets (for 16 persons at once) with 4 dropdown menus (for choice of meat). A LOT of fields, and a lot of different prices. I want to calculate things like 'total' and 'number of steaks'. I want to send those in the submission e-mail, so I created 12 hidden fields, and I do need to calculate those values on submit.
I don't (necessary) need JQuery. At submit will do fine, 'cause the fields I'm altering are hidden.

Simply put: onsubmit, how on earth do I get it to work with javascript in drupal??


texts: Can I create two sites with a single user login?

texts: I have two sites with loosely related content. I'd like a user to be able to create an account on one site but have that account be valid on the other site. Also have the ability so that if any changes are made on site 1 to the account, they are reflected in site 2's database. Is this possible?


texts: Uploading videos with the Media uploader

texts: I am trying to create a video gallery. I was originally trying to use the Media module with shadowbox to display them, but I have not been able to figure out how to get a thumbnail for the media. What I came up with was the Video module. The video module allows me to create a thumbnail, however I wanted an uploader similar to the media module one, which allows me to upload it, get it from the web, or use a video that is already in my library. Is there an ad-on module for Video that will allow me to upload videos like this?


texts: Compare a single value entity reference field to a multi-value entity reference field

texts:
The article entity has an unlimited multi-value Taxonomy reference field field_article_countries referencing the Taxonomy vocabulary Countriesand the User entity has a single value Taxonomy reference field field_user_countries which referencing the same taxonomy vocabulary Countries.

Programmatically, and comparing to one specific Article, I want to load all users that has have their field_user_countries value = to one of the values available inside the multi-value Taxonomy reference field field_article_countries.

Example:
Say Article "ABC" has the field_article_countries with values:

Paris
Spain
London
Italy

User "A" has field_user_countries set to:

Spain

User "B" has field_user_countries set to:

Italy

and User "C" has field_user_countries set to:

Turkey

I want programmatically, and based on Article "ABC", to load only User A & User B.

Below is my code:

// Get in array, a list of all "Article Countries" available for the loaded article.
$Article_Countries = $article->field_article_countries->getString();

    // Get Entity Manager to build your query
    $storage = \Drupal::entityTypeManager()
      ->getStorage('user');

    // Get all Users satisfing your conditions
    // For Condition Parameters @See: https://www.drupal.org/docs/8/api/database-api/dynamic-queries/conditions
    $uids = $storage->getQuery()
      ->accessCheck(FALSE)
      //->condition1
      //->condition2
      ->condition('field_user_countries', $Article_Countries, 'IN')
      ->execute();

    // Load all User entities according to their IDs
    $users = \Drupal\user\Entity\User::loadMultiple($uids);

    // Loop through loaded users.
    foreach ($users as $user) {

    // Do something here.

}

The problem is that only one user is being loaded and not all users !

Any idea what is wrong with my code ?


texts: Taxonomy terms view sorting results numerically

texts:
I have a taxonomy that's comprised entirely of numeric term names, 1 through 1200 (with a few numbers missing in between). I created a new "Taxonomy terms" view to show all terms in this vocabulary. When I look at the view results, I'd like to see the terms sorted numerically, however the view is displaying the terms alphabetically. I understand the reason for this is because term names are strings, but I'm hoping someone has an answer of how to make the query treat the term names as integers.

Here's an example of the view results as they are displayed now:

1
10
100
1000
1001
1005
101
1014
1015
1016
1019
102
1020
1024
103
1034
104

Normally in MySQL, you could write SELECT name FROM {taxonomy_term_data} ORDER BY CAST(name AS UNSIGNED). Is there a way to get this same type of CAST() happening in views?


texts: "Undefined index" error for field which is defined

texts:
I'm getting a strange error on a Views page, even though the page works. I get ten instances of this error:

Notice: Undefined index: field_video in include() (line 28 of
/path/to/drupal/sites/all/themes/mytheme/templates/
views-view-fields--screenings--panel-pane.tpl.php).

Notice: Trying to get property of non-object in include() (line 28 of
/path/to/drupal/sites/all/themes/mytheme/templates/
views-view-fields--screenings--panel-pane.tpl.php).

Here's the content of line 28:

if (preg_match('/media/', $fields['field_video']->content)) {
    unset($fields['field_featured_image']);
}

The idea is that if a node of the relevant content type has both a Video and a Featured Image, the view will drop the image and replace it with the video.

What's crazy is that the page renders just fine; the image disappears when the node has content in both fields. What's even crazier is that the error appeared after a minor tweak to the above code, so I reverted my change and it still throws this error, no matter how many times I flush my caches.

What is happening here? This very same code worked fine for a long time, but now I can't seem to get rid of this error!


texts:
I would like to create a view that shows the title of all newly revised or updated content with the username of who modified it. The first part is easy, but for the life of me, I can't figure out how to show a the username of who updated it as everything shows the original author, not the user who updated the content.

Any ideas on how to accomplish this?


texts: new comment notification in teaser mode in links

texts: Yesterday I saw "2 new comment" in teaser view in one of news in my Drupal-based website. when I click on news and read it and return to news list, the notification was gone. Now I want know where Drupal create this?


texts: Display full webform submission on submission page

texts:
I'm using Drupal 7 and I'm learning PHP at the same time.

I'm using the webform module and when users submit a webform on my site, they can see their submission answers on the submission page but they can't see the whole webform with all the components.

I've read the THEMING.txt file in the webform module and I've copied webform-submission.tpl.php to my theme folder and have been trying to edit it but I can't figure out the code I need to use. I think it's probably quite a simple snippet but I'm not advanced enough yet to work it out.

Could someone help me out please?


texts: Remove blog-like recent content from  page

texts:
Is there a straightforward way to remove the default content, ie recent posts list, from the front page?

I've read about creating my own page and assigning certain blocks to that page and then setting it as the default starting page.. but I've already got my homepage mostly set up and wondered if it would be easy to do it the other way so I don't have to change all my other settings.


texts: Multiple modules extending form in OOP way, with no hook_form_alter()

texts:
I know very well how hook_form_alter() is working in Drupal 7 and in Drupal 8, but the main topic here is how to do things OOP way.

How would you solve the following problem the OOP way?

Suppose you have a random form, for example the user login form.

custom_module_A adds a checkbox to  the form and a custom
validation handler
custom_module_B adds a textfield to the same form and another custom
validation handler

The OOP way of altering the form is:

intercepts the original UserLoginForm and directs to a CustomModuleNewForm- an extended class from user_login_form class
Write a class that extends the user login form

I am unable to "grokh" how this can be solved the OOP way, by extending the form in custom_module_A and not having custom_module_A as a dependency for custom_module_B.

Basically, I am looking for OOP hook_form_alter() replacement.


texts: Disable form altering for admin pages on Bootstrap 3

texts:
My default theme is Bootstrap but I use Shiny theme as admin theme. Bootstrap theme alters the forms and fields.

And I use Hierarchical Select module, there is a dropbox for multiselection and the code of submit button for adding terms as below;

<input class="add-to-dropbox form-submit" id="edit-field-ana-dizin-und-hierarchical-select-dropbox-add" name="op" value="Add" type="submit">

If I use bootstrap despite I use another admin/node edit theme the submit button code showing as below and it does not work like this;

<button class="add-to-dropbox btn btn-success form-submit" id="edit-field-ana-dizin-und-hierarchical-select-dropbox-add" name="op" value="Add" type="submit">Add</button>

I think This problem is about Ajax query, when ajax script run, the field code altering based on default theme. How can I disable form altering for admin pages?

Thank you.


texts: Field widget item form alter for file field

texts: I want to alter field widget item form of a file field with cardinality > 1 so that a new form element is added to each row of the file tables. For example, in the attached image, I want to add another text field below the "Description" for each uploaded file, even the one done via Ajax, not just the existing ones. I used hook_field_widget_form_alter() but it doesn't seem to work with the newly uploaded file. Any ideas?


texts: How do I add multiple images in JSON to meet Google's schema.org requirements?

texts:
The Google guidelines for article on schema.org state:

  For best results, provide multiple high-resolution images (minimum of
  300,000 pixels when multiplying width and height) with the following
  aspect ratios: 16x9, 4x3, and 1x1.

How do I do this in Drupal?


texts: Aggregator custom template file is not overriding the default one on Drupal 7

texts:
I have the Aggregator module enabled in Drupal 7. I have one feed and I'm showing it on the front page in a block. The block has under the feed a 'more-link'.

I want to change the text depending on the language and feed that I'm showing.

I added a copy of aggregator-summary-items.tpl.php to my theme folder and customized the file.

My problem is that is still showing the default one. Is there something I'm missing?