texts: Views: upcoming events list with first upcoming event at the top

texts:
I have content type which have date field(multiple). It also collect the end date.

Now I am creating a view which will list the nodes of that content type.

It will sort the nodes with the start date in ascending order.
And only those nodes will display whose start date is greater than the current date.

I have added the filter of start date. If start date is greater than the current date. The option Add multiple value identifier is set to Yes in the filter settings.

In the query settings I Distinct and pure distinct is checked. I have also tried the aggregation but still the view returns duplicate results.

Any Idea how will remove the dupliation?

EDIT

This is the sql query that view generates

SELECT DISTINCT node.title AS node_title, node.nid AS nid, field_data_field_event_date_time.field_event_date_time_value AS field_data_field_event_date_time_field_event_date_time_value, node.created AS node_created, 'node' AS field_data_field_event_date_time_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_event_date_time} field_data_field_event_date_time ON node.nid = field_data_field_event_date_time.entity_id AND (field_data_field_event_date_time.entity_type = 'node' AND field_data_field_event_date_time.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('event')) AND (DATE_FORMAT(ADDTIME(field_data_field_event_date_time.field_event_date_time_value, SEC_TO_TIME(-25200)), '%Y-%m-%d\T%H:%i') >= '2014-05-15T22:19') ))
ORDER BY field_data_field_event_date_time_field_event_date_time_value ASC, node_created DESC
LIMIT 10 OFFSET 0

The problem is if an event has 2 dates then it is displaying two times and if it has 3 dates then it is displaying 3 times in the results.


texts:
On my Drupal 7 site, I noticed that the IMCE popup loses its action buttons and all functionality when I'm using Adminimal as the admin theme:

In the Known Issues section of the IMCE project page, it mentions using the ThemeKey module if there is a conflict with your custom theme. Here are the ThemeKey rules it says to write:

drupal:path = %token
drupal:path:wildcard token * imce

When I do this, the IMCE buttons are, in fact, back in place (yay!)... BUT the entire site, both public pages and administration pages, are also displayed in Garland (boo!).

How can I force just the IMCE popup window to render in Garland?


texts:
I created a feed for one of my views. I was under the impression that Drupal would automatically display an RSS icon on a view that has a feed?
I see that page.tpl.php prints an icon:

However, I'm not seeing the icon. What am I missing?


texts: Is there a way to assign an html ID automatically to a field in a content type?

texts: I am using JavaScript in my custom module and the field is inside an div, but that div only has a class tag.  Is there a way to automatically give an ID to the field so that whenever it shows up, it's easier to manipulate it with an ID tag?  The field belongs to a content type.


texts: Add 'Last modified by ...' footer to each page

texts: How do I add a footer to each page generated by Drupal (7) so to show the identity of the last user that modified that page? (together with the modification date)


texts:
I have a content type (named "Category") and another content type ("Article"). I want to "Category" nodes have similar functionality as taxonomy term in a way of option to assign "article" nodes to them and display list of "article" nodes teasers on the "Category" page too.

For example: Lets say I have "Category" node named "People". And several "Article" nodes ("Joe", "Frank", "Peter") somehow (part of my question) assigned to "People". When I go to "People" page, I want to see this node content and below also teasers of all assigned "Article" nodes. And I want this not only for a specific node, but for all nodes of content type "Category". How to attain this? Maybe something like taxonomy terms view, but adapted to nodes instead of taxonomy terms?

I know it's easy with taxonomy, but I want to avoid that way - because of buggy taxonomy menu and other things. Thanks


texts: Why is my theme table row array not being displayed?

texts:
I have the below code and I know both the $headers and the $html have values stored in them as i can echo them out.
I can also set the 'header' => in the theme function to be either $header or $html and it will display the data.

However when I add in 'rows' =>, no data is displayed.

Can anyone see why?

function emnies_ad_hoc_query_exporter_get_html_formatted_ad_hoc_query_responses($obj_response) {
  $str_current_country = '';

  foreach ($obj_response as $response) {
    if ($str_current_country != $response->country) {
      $str_current_country = $response->country;
      $html = emnies_ad_hoc_query_exporter_get_country_row($str_current_country, $obj_response);
    }
  }
  $header = array('Country', 'Wider Dissemination', 'Responses');
  $output = theme('table', array(
    'header' => $header,
    'rows' => $html
  ));
  return $output;
}

function emnies_ad_hoc_query_exporter_get_country_row($str_current_country, $obj_response) {
  $rows = array();
  $i = 0;
  foreach ($obj_response as $response) {
    if ($str_current_country == $response->country) {
      if ($i == 0) {
        $rows[] = $str_current_country;
        $rows[] = $response->wider_dissemination;
      }
      $i = $i + 1;
      $rows[] = $response->response;
    }
  }
  return $rows;
}


texts: User images slideshow: first slide from reference entity

texts:
I wish to do a slideshow with a first slide of my node picture and then others slides with pictures submitted by users (affiliated to a node via entity reference).

What I want to do is (Node Entity Reference Image) (userA pic1) (userA pic2) (userA pic3) (userB pic3).

I edited a view template

content(image) goes here

    <?php foreach ($rows as $key => $row): ?>

        <?php print $row ?>

    <?php endforeach ?>

How can I output my "field_passager_image" defined by relationship to Content entity referenced from "field_passager_id" passed through an url argument (node id from url) ?


texts:
Is it possible to create a image file upload and then have that image appear as a background image within the "content" area of a particular page?  I then want to put content (text) over the image.  It would only be for a particular content type, but there is about 80 pages within this content type and each page/node would have its own background image.

To simplify, I have about 80 recipes.  I have high-res images of each.  I want the image to be the background and I would then have the specifics of the recipe on top of the background image.

Example:


texts: Is it safe to manually delete the "field_deleted_*" tables and state API data?

texts:
I'm in an odd situation where the state data that tracks which fields are deleted has a field in it that does not have its associated field_deleted_data_* table. As result, when cron tries to purge the deleted field data, an exception is thrown because it runs a query on a non-existent table.

Is OK to just delete all the remaining field_deleted_data_* and field_deleted_revision_* tables and then delete the two state API rows from the key_value table, field.field.deleted and field.storage.deleted?


texts: Is it possible to customize site status messages?

texts:
There are various types, like "Error, status" and they show up after creating content, or when triggered by a rule.

I'm wondering if it is possible to create a new type, such as "Dev" and have it's visibility limited to certain roles, like administrator.


texts: Add headers to each grouped section in a view

texts:
I've got some content (Employees) and I've got a View that is showing the content in a grid grouped by Department (i.e. it shows the title "Customer Support" and then a grid of Employees and then the title "Sales" and a grid of Employees, etc.)

I would like to include a paragraph of text before each section, preferably from a content node so that my users can modify the description before each section.

I've seen something online (although I'm having trouble finding it again) about being able to attach a view above another view. Is it possible to somehow display a DepartmentDescription node before each section of my grouped view?


texts: Clean urls working everywhere except my custom module

texts:
I'm attempting to create a custom drupal module, but I can't get clean urls to work. Clean urls have been enabled and are working everywhere else on the site.

I can access my module page using "?q=" but if I remove that and try to access it with the clean url I get a "page not found" error.

I've tried clearing the cache and rebuilding the menus using devel. I've also tried disabling and re-enabling my module.

Here's the code I have in my .module file.

/**
 * @file
 * This example demonstrates how a module can display a page at a given URL.
 */

/**
 * Implements hook_menu().
 */
function page_example_menu() {
  $items['examples/page_example/simple'] = array(
    'title' => 'Simple - no arguments',
    'page callback' => 'page_example_simple',
    'access arguments' => array('access simple page'),
  );

  return $items;
}

/**
 * Constructs a simple example page.
 *
 * @return array
 *    The render array for the simple example page.
 */
function page_example_simple() {
  return array('#markup' => '<p>' . t('Simple page: The quick brown fox jumps over the lazy dog.') . '</p>');
}


texts:
I have created a views list of users who are flagged offensive by other users.

I want a button in front of each user to clear that flag from him from every user. So if admin after checking the user decided that he was wrongly flagged he can simply remove that flag.

I have different view pages for each flag report like following

annoying
offensive
fake

So if I am on view page for list of annoying users, I need a link in front of each user to clear that flag from that user from all/any users.


texts: Media module file browser/selector widget

texts: Is the interface shown in the image below specific to Media 7.x-2.x? I installed Media 7.x-1.x and I don't have the "View Library" tab shown here, I just have "Upload" and "Library".


texts:
I'm making a footer menu. The base-theme I use is Omega. Now I'm looking for the best way to add a CSS value to each menu-item, so Omega places them next to eachother.

Basicaly, what I would like to do is adding "grid-3" to the parent menu items...
In the example you can see class="nolink" (from the module special_menu_items), I also want to add the class "grid-3".

Web Design

Drupal Design

Graphic Design

Logo Design

SEO Services

Google Adwords

Great Keywords

Link Submission

SEO Link Building


texts: How to place multiple blocks in one column in bootstrap theme

texts: I am using bootstrap theme. I have 4 blocks: block1, block2, block3, block4. Bootstrap has 12 columns grid. I would like to place block 1 in first 7 columns(using bootstrap class "col-md-7"). I would like to place block 2,3,and 4 to the right of the block 1. Can you please advise how to achieve it?


texts: How to increase weight range avaliable when using Tabledrag?

texts:
I have a tabledrag with more than 20 entries. Much more. Default weight range is from -10 to +10, so it can only order first 20 entries. Every additional one have weight of 10 and is ordered by secondary means like ID, name or whatever, and not the way user set it to. How can I expand that range? I can't see anything like that in drupal_add_tabledrag documentation.

My form definition is pretty much copy-paste from Examples for Developers.


texts: Migrating users: how to customise the import of custom fields

texts:
I'm starting a D7 -> D9 migration of our site, but am having trouble migrating a custom field that was added to the D7 user entity. As far as I can tell the migration ignores the .yml for those custom fields.
The custom field, 'profile' is a text field with a value and a text format.
The standard upgrade_d7_user.yml that migrate builds doesn't migrate the custom field's text format properly - it's a numeric value in d7 that needs to be mapped to something like 'basic_html' in d9.
I edited the yml to add in a static map. I added in debug lines to the yml that show the value being changed, but didn't see any change to to values written to the d9 database.
To make sure the yml was having an effect, I deleted most of the process section to just have:
process:
  uid:
    -
      plugin: get
      source: uid
  name:
    -
      plugin: get
      source: name

So I'd only expect to see uid and name getting written to the D9 database. But when I run the migration the raw values of the custom fields still get written to the D9 database, and still show up in the debug output:
"---------------------------------------------------------------------"
"|                           $Destination                            |"
"---------------------------------------------------------------------"
array:4 [
  "uid" => "2"
  "name" => "batgung"
  "field_profile" => array:1 [
    0 => array:2 [
      "value" => "PHP Code"
      "format" => "2"
    ]
  ]
  "field_newsletter_subscriptions" => []
]

So it looks as though any custom fields that were added to the user entity are just copied directly across, regardless of what the yml says.
Is this a bug in the way Migrate handles the migration of users or am I going about this the wrong way?


texts:
I'm developing a simple site and want to keep everything as simple as possible, without any unnecessary performance lost or redundat code. Design is pretty static, therefore no need lot of regions for a lot of blocks. Currentlty I have have only one region and 2 templates - one for front page and second for other pages - that's all I need so far.

But there is a new block generated by Language switcher module that shows a select input for switching languages. What's more efficient way of displaying a block - by creating new region and placing this block into, or by inserting it directly into page.tpl.php template with module_invoke() function?


texts: Adding file description field to already existing records

texts: I have a site with various hundreds of a particular content type. This content type contains a field of type file. We have decided we want to display a description rather than the filename. I have enabled the description on the file data type for the content type. It works when new files are added, but if we try to update existing files with a description it doesn't work (you can fill in the field but on Save it is not added to the record). I'm guessing that the description field wasn't created in the database when these files were added prior to the description field being added. Is there anything we can do about this, other than re-uploading all the files again, which would be rather laborious?


texts: How do I merge composer manager composer.json with core 8.3 composer.json?

texts:
I was using Drupal 8.0.5 site with composer manager. Now I want to upgrade core to 8.3.2 which comes with composer.

Composer Manager asked me to uninstall this module, as it is no longer supported in core 8.3.

How can I merge old composer.json with new composer.json supplied by core 8.3.


texts: How can I filter submissions for download?

texts:
I have a query about the webform download options. /admin/structure/webform/manage/{{webform_name}}/results/download

In my webform there is a field dropdown with some data like 'a', 'b', 'c'...

Please let me know is it possible to download all submissions whose dropdown value is 'a'?


texts: We have a number of Drupal websites to login to. Is there an automated solution to login to each one? They are not on the same domain, not on the same server for that matter.


texts: Load a user object via login form name field

texts:
I'm trying to check if a user account has been disabled for LDAP before the user completes the login process using a custom form validator.

What has me stuck is how I would use user_load to load the user object of the person logging in via the login form. I'm not sure how I would structure the form array within the user_load function.

What I currently have is:

$account = user_load($form_state['values']->name);

Thank you for your time.


texts: drush not able to download and enable modules whenever executing drush en  on Windows OS

texts: I keep getting this pop-up screen that tries to locate an app to open .launcher files whenever I try to execute drush en <Module_Name> commands to download and enable a module on Drupal 8. On mac nothing like this happens, I'm not sure what needs to be done in order for the commands to work.


texts: How do I get low level data from the Flag module?

texts:
Is it possible to get the following raw, low level data from the Flag Module and/or it's services?

Flagging count as integer
URL to flag/unflag as a string
Current user's flagging status as boolean

I already know that I can do this:
$flag_link = \Drupal::service('flag.link_builder')->build('node',$nid,'bookmark');

But it will output the full blown markup with Ajax and everything.
I've done this:
$flag_service = Drupal::service('flag.count');
$counts = $flag_service->getEntityFlagCounts($node);

But I can't actually figure out what exactly $counts contains, I definitely can't output it as an integer on my template, I get an error.


texts: How do you reliably create a GraphQL/Twig theme as a subtheme?

texts:
Our theme is built with GraphQL Twig and it's working great. We need to build a subtheme for a different website based on this theme. We're not really having a problem overriding simple Atoms templates, but once you start getting more complex, the site won't recognize the existence of the new templates. Instead, the site keeps using the old templates. I can't go in and change the location of the referenced child template in the higher-level parent templates because they are all part of the base theme. Were we to have to go through and change these locations in all the code, we'd be duplicating so many templates in the subtheme that we might as well just copy/paste the entire base theme and just have divergent code (two base themes). This really isn't something we want to do. We want to be able to maintain the base theme with slight changes to the subtheme.
For example, we have a paragraph which needs three additional fields added to it in the subtheme. In a site without GraphQL, we would simply add the fields to the paragraph.twig. In this theme, however, the field variables come from the container and are passed to the paragraph. Adding the field-container doesn't work either as it is referenced in the landing page, page, and news content types, all of which reference these templates. If we don't include all of these templates in the subtheme, the subtheme cannot find them because they are not physically in the subtheme folders. Some of those folders don't even exist in the subtheme because we aren't overriding the templates inside them.
themes
  - contrib
     - our_base_graphql_theme
        - storybook
           - 01-base
           - 02-atoms
           - 03-molecules
              - our-paragraph
                 - our-paragraph.twig
           - 04-organisms
              - our-field-container
                 - our-field-container.twig
           - 05-templates
           - 06-pages
              - our-landing-page
                 - our-landing-page.twig
              - our-page
                 - our-page.twig
              - our-news
                 - our-news.twig
  - custom
     - our_subtheme
        - storybook
           - 03-molecules
              - overrides
                 - our-paragraph
                    - our-paragraph.twig

Snippet from field container template our-field-container.twig:
{% if type == 'our-paragraph' %}
  {% include '@storybook/03-molecules/our-paragraph/our-paragraph.twig' %}
{% endif %}

Snippet from content type templates such as our-landing-page.twig:
  {# The field container #}
  <div class="lower-content">
      {% include '@storybook/04-organisms/our-field-container/our-field-container.twig' %}
  </div>

I don't think we should have to copy all of the theme templates in order to override just one field. I'm certain I am missing something, but the documentation online is slim.
How can I fix this problem?


texts: Getting the value of a taxonomy term reference field

texts:
I have a content type (Movie) with a taxonomy reference (Movie rating) for which can get multiple values. I would like to use the template node--movie.html.twig and get the first value inserted in the taxonomy term.

I tried using the following code, but it doesn't give any value.

{{ content.field_rating['#items'].getValue()|first.value }}

What am I doing wrong? In which way do I reference the taxonomy term value?


texts: How to combine Views, Rules and EVA to record submission?

texts:
I have a Drupal 7 site and I'm using Views, Rules and EVA.

I have a specific requirement that I am sure can be achieved with the modules, but I am having no joy configuring a working process.

I have an 'Application' content type, which has a submission form embedded (i.e. visitor completes submission form for the role they are applying for).

As all visitors login in order to submit an application, I would like to record each application they make into a 'My Applications' view/block, within their User (/user) page.

I see the process as something along the lines of:

Visitor completes application form and clicks a Submit button.
Via Rules, an association/reference between the user and the specific role/application is recorded.
Using EVA, a custom view will list the applications the user has made (showing only his/her applications, unless admin).

The part I am failing with is how to configure a Rule, triggered by the submit button, that links the user to the specific application, in such a way that it can then form the EVA view.

Has anybody implemented a similar process? Recording applications (for jobs, events, meetings etc) and allowing users to see those they have applied for must be possible?

I would be happy to use an entirely different approach if there is a better method vs. the  Views/Rules/EVA idea.

Suggestions gratefully received. Thank you.


texts:
How do I hide an article if it doesn't have an image?

In Drupal 6, the setting is Block: Configure filter Content: (field_image), but I can't find this settings in Drupal 7.


texts: Ignore custom block field content (settings) with config_ignore

texts:
I am trying to ignore the content of some fields in a custom defined block plugin.

In my block plugin (class MyAwesomeBlock extends BlockBase implements BlockPluginInterface { ... })

I've declared some fields with the blockForm function.

$form['my_awesome_field'] = [
  '#type' => 'text_format',
  '#title' => $this->t('Title'),
  ...
];

Now, I would like the content of this field in the block configuration to be ignored, but the general block settings (placement, weight etc.) should be kept.

I've tried some things in the config_ignore settings like:

block.block.myawesomeblock:my_awesome_field
block.block.myawesomeblock:settings.my_awesome_field
block.block.myawesomeblock.my_awesome_field
block.block.myawesomeblock.settings.my_awesome_field

But they don't seem to work. Any ideas what I'm missing?


texts: Create a node programmatically on installing a module

texts:
I would like to have my module to create new nodes (page) when being installed and removing these pages on uninstall.

I tried the following with no success in my mymodule.install file:

<?php

function mymodule_install() {

  $node = new stdClass(); // We create a new node object
  $node->type = "page"; // Or any other content type you want
  $node->title = "Your title goes jere";
  $node->language = LANGUAGE_NONE; // Or any language code if Locale module is enabled. More on this below *
  $node->uid = 1; // Or any id you wish
  $node->path = array('alias' => 'your_node_path'); // Setting a node path
  node_object_prepare($node); // Set some default values.

  // Let's add standard body field
  $node->body[$node->language][0]['value'] = 'This is a body text';
  $node->body[$node->language][0]['summary'] = 'Here goes a summary';
  $node->body[$node->language][0]['format'] = 'filtered_html'; // If field has a format, you need to define it. Here we define a default filtered_html format for a body field

  $node = node_submit($node); // Prepare node for a submit
  node_save($node); // After this call we'll get a nid

}

This code is cut n' paste from this page.

When I disable/enable the module, the page is not created (at least it does not appear in Content and in the node table of the database).

How should I do it please?


texts: How to force users to register with only email address?

texts:
I need force users to register on my site with just email only. I cannot use the Email Registration module. With this module, a username is generated and assigned based on the user name part of the email address. Subsequent users who have the same name (email prefix) are numbered sequentially. For example, "johndoe@exampleA.com" would be assigned username "johndoe", "johndoe@exampleB.com" would be assigned "johndoe001" and so forth..

The use case is that I have a number of subdomains that I am using Bakery on and need to ensure that there aren't any conflicting slave site accounts. The Email registration module will just create a tokenized username with appended unique IDs, creating conflicting accounts.

I figure by forcing email addresses, I can bypass most of this as an issue. How can I completely eliminate the username field and just use email field?


texts: How to update a library through drush or git url? what about update chosen library?

texts:
I am new with Drush and git... previously I use to work with Ftp so at the moment I would like to know How I can update a common library by using drush or by using git (library url).

I know that in order to update a module I can use: drush up module_name How about for libraries?

I tried to do the same for libraries but it did not work.... I know some libraries have their own drush command for download it like is the case of chosen library:

drush chosenplugin

however I have in my local machine a Drupal profile that I am all the time updating it so the profile of course has not sites/all/libraries but has profiles/libraries/ the problem in this case is that when running drush chosenplugin the console shows up:

Unable to unzip chosen_v1.1.0.zip   error

and I think it shows that error because according to the chosen module/library drupal site information https://www.drupal.org/project/chosen what the drush chosenplugin does is:

  The command will download the plugin and unpack it in
  "sites/all/libraries". It is possible to add another path as an option
  to the command, but not recommended unless you know what you are
  doing.

So of course in this case I dont have sites/all/libraries and that´s why I think the command is not getting success with the download/update?

Is there a way how to add another path? how to add it in order my chosen library gets updated in the path profiles/libraries/.

Please keep in mind that I have already a chosen library version v0.9.1 installed and now what I want is to update it to the last version which one is v1.1.0.

So how I update it if I have profiles/libraries as path and not sites/all/libraries?

The library belongs to the drupal profile.

I run drush help chosenplugin but it only says:

  Arguments: path Optional. A path where to install the chosen plugin.
  If committed Drush will use the default location.

I know that the default location is sites/libraries BUT IN MY CASE the PATH would be: profiles/myprofile/libraries/chosen SO in this case if I do the libray update with the command drush chosenplugin then how I set up the path in this command? the help just says that i can use path as argument but does not say how to set it...

If there is no way to update it through drush then please provideme a guide how to update the chosen library by using git... knowing that the library url in git is: https://github.com/harvesthq/chosen.git

PLEASE HELP!!!!! :)

Thank you everyone!!!

Liz


texts:
I need a simple reservation module for my D7 restaurant site.

What I need in the form is:

Customer information fields (Name, email, contact number, address, etc)
Number of tables to be reserved by that customer
Upon submission of reservation will lead to another link (I will write codes to link to payment gateway)

Admin are able to configure:

Price per table (Eg: USD 100 per table)
Total number of tables available to reserve (Eg: 100 tables)
Closing date for reservation, so that customer can't reserve after the closing date

Admin able to see:

Report of reservation
Details such as customer name, number of tables reserves, etc

I had tried using Webform, but I can't do the following:

Reservation close on particular date
Limit number of tables so that overall tables reserved will not exceed 100

Is there any reservation or registration module that I can use?

Or is there any method I can modify my webform to suit the requirement?


texts:
I'm using a custom module to change subject and recipient email. Actually my fields are a single text field for the subject, and a select field for recipients.

I would like to add a more options actually. My webform is on a public page opened to all. I add a new page with a link to the contact form and I want that link to provide some options.

So my link is like this: /node/5?option=1

This bring me to the aforementioned page and set the subject field according to my custom module like this:

function ca_formdispatch_form_alter(&$form, &$form_state, $form_id)
{
    $nid = arg(1);
    drupal_set_message(t(" webform_client_form: .", $form_id));

    //determination de l'ID du formulaire afin de l'alt�rer
    if ($form_id == 'webform_client_form_5' && $nid == 5)
    {
        $origine = $_GET['origine'];

        drupal_set_message(t("contenu d'origine : @origine.", array("@origine" => $origine)));

        //liste des email destintaire possible en fonction de l'origine du destinataire

        switch ($origine)
        {
            case '1':
                $email_dest='xxx@example.com';
                $sujet_mail="Message pour 1";
                break;
            case '2':
                $email_dest='xxx@example.com';
                $sujet_mail="Message pour 2";
                break;
        }

        //affectation de la valeur de $email_dest comme email destinataire du message,
        $form['submitted']['destinataire']['#default_value']=$email_dest;
        drupal_set_message(t("contenu de email : @email.", array("@email" => $email_dest)));

        //affectation de la valeur de $sujet_mail comme sujet du message
        $form['submitted']['sujet']['#default_value']=$sujet_mail;
        drupal_set_message(t("contenu de sujet mail : @sujet_mail.", array("@sujet_mail" => $sujet_mail)));
    }
}

It works for the subject field but not for the recipient field. My recipient select field can take 4 options. I can set the select on an existing key but not add a new key not provided by the select by default.

I would to lock the key set by the module or hide the select field to don't allow is change by the user that did click on the link before.Is it possible? I know I can use hook_webform_select_options or hook_webform_select_options_alter but I don't know how with to make this code ... if someone could help me.

EDIT:
i test this to get the "key" and pass it to the webform field but  i think it doesn't work.

switch ($origine) {
  case 'charge-relation-entreprise'://valeur de $origine
  $clef="Chargé des Relations Entreprises";
  $email='web@pro.com';
  break;....

$form['submitted']['choisissez_votre_destinataire']['#options'][$clef] = $clef;
$form['submitted']['choisissez_votre_destinataire']['#value']=$clef;
$form['submitted']['choisissez_votre_destinataire']['#key']=$clef;

but if this display the right text in the select,it doesn't send mail...

EDIT2 : i get the right key label displayed if i set a default value key in the webform select list setting like here https://computing.artsci.wustl.edu/help/drupal-webforms-advanced

But my select doesn't work anymore if i go to the webform page directly,whithout instructions in the url.Like with the edit1


texts: file field on form in view is ajax-enabled ONLY if rendered as part of page, not retrieved through ajax

texts:
We are using the popup module to render views within a page.

One of the views has a file field for uploading. The popup module can render the popup as part of the page and then display the popup or pull the data in through an ajax call.

If the views is pulled in as part of the rendering of the page, the field has ajax enabled and works correctly.

However, when the view is pulled in through ajax, the field does not have ajax enabled and fails to function.

There are dozens of such popups on the page and it is simply not practical to have all the popups pre-rendered (not to mention the inefficiency of it).

I have tried pulling in just one popup to check whether its just some missing javascript files but while the solitary popup works as expected, the other ones still fail to function.

Digging into the popup module, the bit of code to retrieve the view is exactly the same regardless of whether it's being pulled in as part of the page, or separately through ajax.

from popup.api.inc

function _popup_view($attributes, $return = FALSE){

  $title = FALSE;
  $body = FALSE;

  if (module_exists('views')){

    $view = views_get_view($attributes['view']);

    $display = $attributes['display'] ? $attributes['display'] : 'default';
    $args = isset($attributes['args'])
      ? explode(',', $attributes['args'])
      : array();

    if ($view){
      $view->set_arguments($args);
      $view->set_display($display);
      $body = $view->preview();

      $computed_title = $view->get_title();
      $title = $attributes['title']
        ? $attributes['title']
        : ($computed_title
            ? $computed_title
            : @$view->display[$display]->display_options['title']
          );

    }

  } else {
    $body = false;
  }

  $title = $title ? $title : 'View';
  if ($return == 'title'){
    return $title;
  }

  if ($return == 'body'){
    return $body;
  }

  return
    popup_element(
      $title,
      $body,
      $attributes
    );

}

The relevant javascript section:

  var placeContent = function(data, destination){

    thisObject.body.unbind('showing', fetchContent);
    var close = $('.popup-close-button', destination);

    if (close.length){
      close.siblings().remove();
      destination.append(data);
    } else {
      destination.html(data);
    }

    Drupal.attachBehaviors(destination);
  }

The popup module has a mechanism for rendering drupal forms view a popup and load that via ajax as well. This too does not work.

I should state that regular forms do work without any issues. I have views being rendered via ajax popup that have other controls (submit buttons just now) which work without any issues.

However, if I add a file form field into any of those forms, it breaks even the original controls. I believe this may be related to the form changing to a multipart mime form.

This leads me to the conclusion that there is something specific about the file form field that fails when being retrieved through ajax.

Manually adding the file.js has had not impact (I was thinking that attachBehaviours may not be working correctly)

Any help to resolve this will be greatly appreciated.


texts:
I am having trouble creating and registering migrate modules. At the moment, when I go to the UI screen, it says 'Class X no longer exists' (so, at least its being picked up) and wont show in the list of migrations on  the page. At the moment, I have only implemented one class and had this issue (when I figure this out, I will create everything else). Here is my code:

function migrate_rcmd_migrate_api() {
  $api = array(
    'api' => 2,
    'groups' => array(
      'Test' => array(
        'title' => t('Test Migrations'),
      ),
    ),
    'migrations' => array(
      'EventNode' => array(
        'class_name' => 'EventNodeMigration',
        'group_name' => 'Test',
      ),
      'CareerNode' => array(
        'class_name' => 'CareerNodeMigration',
        'group_name' => 'Test',
      ),
      'NodeRegistrationEntity' => array(
        'class_name' => 'NodeRegistrationEntityMigration',
        'group_name' => 'Test',
      ),
      'JobPostingEntity' => array(
        'class_name' => 'JobPostingEntityMigration',
        'group_name' => 'Test',
      ),
      'CoverLetterFileEntity' =>array(  //may only need one file entity migration class
        'class_name' => 'CoverLetterFileEntityMigration',
        'group_name' => 'Test',
      ),
      'ResumeFileEntity' => array(
        'class_name' => 'ResumeFileEntityMigration',
        'group_name' => 'Test',
      ),
    ),
  );
  return $api;
}

and

abstract class Test_Migration extends DynamicMigration {
  public function __construct() {
    // Always call the parent constructor first for basic setup
    parent::__construct();

    // With migrate_ui enabled, migration pages will indicate people involved in
    // the particular migration, with their role and contact info. We default the
    // list in the shared class; it can be overridden for specific migrations.
    $this->team = array(
      new MigrateTeamMember('Liz Taster', 'ltaster@example.com', t('Product Owner')),
      new MigrateTeamMember('Larry Brewer', 'lbrewer@example.com', t('Implementor')),
    );

    // Individual mappings in a migration can be linked to a ticket or issue
    // in an external tracking system. Define the URL pattern here in the shared
    // class with ':id:' representing the position of the issue number, then add
    // ->issueNumber(1234) to a mapping.
    $this->issuePattern = 'http://drupal.org/node/:id:';
  }
}

class EventNodeMigration extends Test_Migration {
  public function __construct($arguments) {
    parent::__construct($arguments);
    //WE WILL NEED THIS
    //$this->dependencies = array('BeerTerm', 'BeerUser');

    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'nid' => array(
          'type' => 'int',
          'not null' => TRUE,
          'description' => 'The primary identifier for a node.',
          'alias' => 'n',
        )
      ),
      MigrateDestinationNode::getKeySchema()
    );
    //example
    $query = Database::getConnection('default', 'legacy')
             ->select('node', 'n')
             ->fields('n', array('nid','vid','type','language','title','uid','status','created', 'changed','comment','promote','sticky','tnid','translate','uuid'))
              ->condition('type', 'events','=');
              //ADD JOINS TO FIELD TABLES HERE
    $this->source = new MigrateSourceSQL($query);
    $this->destination = new MigrateDestinationNode('events');

    $this->addSimpleMappings(array('nid','vid','type','language','title','uid','status','created', 'changed','comment','promote','sticky','tnid','translate','uuid'));
    //$this->addFieldMapping('title', 'page_title');
    //$this->addFieldMapping('body', 'page_body');
  }
}


texts: How to resolve the error: Argument 2 passed to t() must be of the type array, null given, called in rules.core.inc

texts:
A Drupal Commerce site is giving from time to time the following error on /cart page:

TypeError: Argument 2 passed to t() must be of the type array, null
given, called in
/home/username/public_html/sites/all/modules/rules/includes/rules.core.inc
on line 2676 in t() (line 1720 of
/home/username/public_html/includes/bootstrap.inc).

I tried to put the dpm(ddebug_backtrace(TRUE)); just before the line 1720 in bootstrap.inc file, but the website goes blank. Devel module is of course enabled.

The website's error log show:

mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Call to undefined function ddebug_backtrace() in /home/username/public_html/includes/bootstrap.inc:1720
mod_fcgid: stderr: Stack trace:
mod_fcgid: stderr: #0 /home/username/public_html/index.php(19): require_once()
mod_fcgid: stderr: #1 {main}
mod_fcgid: stderr:   thrown in /home/username/public_html/includes/bootstrap.inc on line 1720
mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Call to undefined function ddebug_backtrace() in /home/username/public_html/includes/bootstrap.inc:1720, referer: https://website.com/admin/reports/dblog
mod_fcgid: stderr: Stack trace:, referer: https://website.com/admin/reports/dblog
mod_fcgid: stderr: #0 /home/username/public_html/index.php(19): require_once(), referer: https://website.com/admin/reports/dblog
mod_fcgid: stderr: #1 {main}, referer: https://website.com/admin/reports/dblog
mod_fcgid: stderr:   thrown in /home/username/public_html/includes/bootstrap.inc on line 1720, referer: https://website.com/admin/reports/dblog

I believe one of the Rules is faulty, but the website has so many of them that it would be nice to trace which one first. And then I can't why ddebug_backtrace does not work. Any hints appreciated.

Edit: Reported this on Rules module's issue queue: Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1836 of /bootstrap.inc). But the error is still there.


texts: Multisites login from main site to other site, drupal 7

texts:
i have multisites installed single code and database, and 1 user table.

users are classified as different types,
and user get register from site1 or site2

i need to do is if user has type of site2. and if he is trying to login to mysite.com, user type is checked and redirect to specific site and login the user to that site.


texts: hook_alter_form() to change an exposed filter

texts:
I need to add an exposed filter to my view in form of a select. I followed these steps.

I exposed the Content: Countries (field_countries) filter to visitors
I chose Grouped filters
I added  France with value equal to FR

I have many values to add in my list, but I have to select them from my database according to a specific condition. So my list must be dynamic.

In my module, I implemented hook_form_alter().

function projects_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    $all_countries = country_get_list();
    // $project_countries = Array ( [0] => FR [1] => IT )
    $new_filter = array('All' => t('All'));
    $i = 1;
    foreach ($project_countries as $key => $value) {
      $new_filter[$i] = $all_countries[$value];
      $i++;
    }
    $form['field_countries_value']['#options'] = $new_filter;
    return $form;
  }
}

This returns the list I need, but the search doesn't work anymore.

I also tried the following code.

foreach ($project_countries as $key => $value) {
  $new_filter[$key] = $all_countries[$value];
}
//$new_filter=Array('All'=>'All','FR'=>'France', 'IT'=>'ITALI')

How can I fix the code?

Thank you


texts: How to: Setting an Expires Response Header for a Views block?

texts:
On another question I received the following advice:

Create a module drupal generate:module, create the route subscriber drupal generate:route subscriber and to look up the route name of the view drupal router:debug
...
setting an Expires Response Header

How can I Do that?
Composer and Console are running with Acquia-dev-desktop.
I've created a first "mymodule" with "implement method: hello".
So I have come a lot further than I was yesterday.
Do you have a guide for me?
Best regards
Frank
PS: I discovered the module "Advanced Page Expiration".
This will probably only be for pages, not for blocks?


texts: How do I skip language selection with installation profile?

texts:
I am building an installation profile for Drupal 7 and trying to skip the language selection page.

In the .profile file I put the following code:

function efocus_install_tasks_alter(&$tasks, $install_state){
    $tasks['install_select_locale']['run'] = INSTALL_TASK_SKIP;
    $install_state['parameters']['locale'] = 'en';
}

This skips the page but apperantly the locale selection is not working for some reason. Anybody that has any experience with this? I am quite new to Drupal, just started a month ago and can't figure out why it is not working. Any tips on what I can try?


texts: Error :The referenced entity (node: 252287) is invalid.?

texts:
I have a node reference field (which is reference for node B) in a node A .When a user who does not have permissions for node B accesses the node A, the problem occurs when node A form is submitted it gives the following error:

The referenced entity (node: 252287) is invalid.

The nid shown above is the selected nid for the node reference field.
The workflow is as follows:
1. One user submits the form (node A) who has access to node B
2. Other user submits the form (node B) who  does not have access to node B.
But when the other user tries submitting he gets the error mentioned above.

Even after providing node access for (node B) to the user is not able to submit the form .
How can I solve the problem?
In the hook_node_access_records the code was as follows:

$deny_access_types = array( 'node_B', 'node C');
  if (in_array($node->type, $deny_access_types)) {
    $grants[] = array(
      'realm' => 'test_all',
      'gid' => 0,
      'grant_view' => 0,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );
  }

Now I have changed the code to

 $deny_access_types = array( 'node_B', 'node C');
      if (in_array($node->type, $deny_access_types)) {
        $grants[] = array(
          'realm' => 'test_all',
          'gid' => 0,
          'grant_view' => 1,
          'grant_update' => 1,
          'grant_delete' => 1,
          'priority' => 0,
        );
      }

But till it does not work
Also changed the permission from the UI but still not works ?


texts:
I have a 2-column panel (Regular, not stacked). I've made it responsive and it appears allright in mobile view @media screen and (max-width: 519px) {width: 100%;}.

The only problem is that my site is a Right to left one, and therefore, What you guys call "Panel-col-first" appears last in mobile view and it's seems Illogical... What is the way to change it, specifically for that particular panel?

Btw, CSS games (Float) didn't help one bit, so I'm looking for a another way, may it be customization of other files.


texts: How do I enable and use a view mode for a product type?

texts:
In default commerce2 (drupal 8) I want to add second product-type view mode, to show in views - like teaser version, including add-to-cart btn with variations. I have additional field in Product type Default (in some custom product types too) and I want to limit them in this second view mode.

Seem like Product type (Default and customs) no options to add other view mode and in views is available Default view mode for Product. Product (type) is not listed in Structure > Display modes > Views modes.

edit:

lamp stack, php-7.0, composer instalation from http://docs.drupalcommerce.org/v2/getting-started/install.html, act as uid 1

admin/commerce/config/product-types/default/edit/display

missing "Custom display settings" above "Save" btn

admin/structure/display-modes/view

Missing "Product (type?)" in list


texts: How do I ensure $page['content'] doesn't include a piece of content in a view on the page?

texts:
I have a block/view at the top of the front page that features three "featured" articles. For context, this view is achieved via a boolean checkbox field and not Nodequeue.

How do I make sure an article featured in this view is not duplicated in $page['content']? I only want an article to appear once on the front page, whether that's in the featured block or in the regular river of content.

Degree of difficulty: I would like to do this in code, without using Context or Display Suite or something similar.

Here's a mock, if that helps.


texts: Drupal JavaScript settings versus jQuery.data()

texts:
When I writing JavaScript code for my module, I could use jQuery.data() or the setting object passed to the Drupal behavior my module add.

Should a module always use the settings object, or could I use jQuery.data() in my module?
Is there any case where using jQuery.data() is problematic when used in AJAX code?


texts:
I am creating a page flip for a drupal site using pdf_to_imagefield module to export PDf to JPG and then I need to have the list of JPG files as XML to use them in Dynaimc page flip.

The PDF and all JPOG files for each PDF page are stored in the same node of a certaine content type. How do I output this node as XML where I can control XML tags??

I have tried to create node-content-type.tpl.php but it comes as HTML.


texts: How to define a non-database relationship for the Views module

texts:
Basically, I have an array of nids (node ids) stored in a $_SESSION variable, which is updated according to user actions (it holds a history of visited node pages).
Now, I would like to create a view which displays a list of nodes, filtered by nids given in a $_SESSION variable.

For example:
if $_SESSION['my_nids'] == [1,5,6]
=> I want to display nodes 1,5,6 in the view.

Storing the nids in a db table is not an option due to performance reasons.

Can someone point me how to create such a non-database relationship views handler?


texts: Allow users to view others contents with autocomplete Entity Reference field

texts:
I'm trying to build a content type where any user can select an entity reference value through an autocompleted Entity Reference field.

Using this field works as an admin. I'm able to see the referenced contents. But when I try as a logged in lambda user, I can't view the content created by other users.

The field is in the content type "Invoice" and has to allow users to select a contact name (content type "Contact").

I think it's a matter of access rights on this specific content type. So far, I've tryed creating a module with a hook_node_access function :

function contact_node_access($node, $op, $account) {
  $type = is_string($node) ? $node : $node->type;

  if (in_array($type, node_permissions_get_configured_types())) {
    if ($op == 'view' && user_access('view ' . $type . ' content', $account)) {
      return NODE_ACCESS_ALLOW;
    }
  }

}

It still doesn't allow users to see and select other's people contacts.


texts: Features workflow issue with deleting a field

texts:
Suppose I have a content type Person with fields: Name, Age, Email

This content type is controlled by a Feature called test so I can source control it and push it to the live site.

My workflow goes like this:

I add a new field on Person called Phone
locally I do: drush fu test -y
I edit the test.info to increase the version number
I commit the changes to my repository
I push the feature to the live site (copy the feature files)
on the live site I do: drush fr test -y
on the live site I do: drush cc all

Then the new field appears on the live site's Person.

If on the first step I remove a field of Person the field will not be deleted from the live site. How do I solve this? I don't want to have to manually delete it from the UI on the live site.
Is this workflow correct?


texts: How do I hide some fields to registered users?

texts:
This is my use case:

If an anonymous user completes an order, the order shows profile type A. When user completes that order, the system creates a new user, and fulfill his profile with the profile2 type A order information.
If a registered user completes an order, it does not show any profile2 information.

I want to make my checkout process shorter for already registered users, and I want for the anonymous users to have a profile filled with the order information.
I get the first part of the use case working (the anonymous user workflow) with the excellent Commerce Order Profile2 Checkout Panes module, but I have no idea on what to do to avoid it appears for registered users. The problem is that the fiels in question are profile fields, so I need to grant registered users permission to view/edit them, and I can't hide them there with field permissions or CSS styles because they wouldn't be available to anonymous users too.

What could I do?


texts:
I created a view block based search API module.

I want displayed in this block similar products to the product currently being viewed.

When I get the word "mint" in the value of fixed contexuel filter "full text search", I have products containing "mint" that appear in the right column.

I want the text title field and body field are sought instead of "mint".

I parameterize filters API search index, not to seek unnecessary words.

How to do this ? How to set the pop filter?

Thank you


texts: Is there a way to skip bootstrapping drupal to save load time via drush?

texts: I currently use drush alot to manage my sites, but I was wondering if there was a way to skip bootstrapping drupal everytime drush is run for certain commands that might not need it. This would save significant load time. I tend to do pm-list alot, but sometimes it just takes a long time to load depending on the size of the site. Same goes for enabling/disabling modules.


texts:
I found a responsive menu code here and I want to add it to my Drupal 7 site. I have no experience with JavaScript, but I thought that if i just copy the script into mytheme/js/menu.js, call it in mytheme.info, and add the HTML to a block, I will have the script up and running.

The HTML part works fine, but the JavaScript part isn't working.

Why doesn't my JavaScript code work?


texts: How can I create template for specific page in module?

texts:
I am completely new to drupal, and just started learning.

Here's my issue:

I have created a module, called 'doom'. It has only one form.

I would like to remove all the default elements ( header, footer, sidebar ) and to add custom  elements.

I tried this,

/**
 * Implements hook_theme_registry_alter().
 */
function doom_theme_registry_alter(&$theme_registry) {
    $module_path = drupal_get_path('module', 'doom');
    $template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
    foreach ($template_file_objects as $key => $template_file_object) {
        if (!isset($theme_registry[$key]['theme path']) || !preg_match('#/themes/#', $theme_registry[$key]['theme path'])) {
            $theme_registry[$key]['theme path'] = $module_path;
            $theme_registry[$key] = array_merge($theme_registry[$key], $template_file_object);
            $theme_registry[$key]['type'] = 'module';
        }
    }
}

This code changes all the pages in the site. But I just wanted to customize the template for 'doom' page.  http://example.com/drupal/doom


texts: How to add a percent field in content type

texts: Simple question. When creating a content type field, we have a float, decimal and integer number type, but how can we create a field with percentage type value, basically a range of 1-100%.


texts: How to require revision logging for certain users

texts: In Drupal 7, if a specific role modifies any content, I want to require that the user add message explaining the changes.  How can this be accomplished, either through an existing contrib module or custom code?


texts: How to access current menu level/depth when overriding THEMENAME_menu_tree__MENU($variables)?

texts:
I'm creating a custom menu for a project built in Drupal 7 and I want to add some custom HTML before every UL in the main menu.

By adding the THEMENAME_menu_tree__main_menu($variables) function to my template.php I can output my custom HTML:

return '
My custom HTML

' . $variables['tree'] . '
';

The function is called for every level in the menu and the HTML printed in front of every UL. But now I also want to customize this HTML in different ways for each level, but I cannot find any information regarding the current menu level in the $variables parameter.

Is it at all possible to access information about current menu level in the body of the function? If so, how?


texts: Create a rule to send confirmation email message after anonymous/authenticated user has created content

texts:
I have created a custom content type (CCK) called apply (machine name) and installed the Rules module. How would I go about sending the user an email (they could be anonymous or authenticated) after they have created content. I understand that I have to create a rule of some sort, could someone please walk me through it?

I want to capture the content of field_email_address somehow, as that is the field in which the user will be entering their email address.

This is my rule so far, not sure what to put in the Conditions and Elements section.


texts: How can I add a search feature to my Drupal 7 Zen child theme frontpage?

texts:
I would like to add a search form to the front page. I've added this to my template.php:

function my_theme_preprocess_page(&$variables){
   $search_box = drupal_render(drupal_get_form('search_form'));
   $variables['search_box'] = $search_box;
}

I've added this to my page.tpl.php:

<?php print $search_box; ?>

After viewing my site I do see the search form but get this error:

  Strict warning: Only variables should be passed by reference in
  denta_quest_preprocess_page() (line 142 of
  C:\xampp\htdocs\drupal\themes\my_theme\template.php).


texts:
I am in the process of creating a View for my Drupal site and I am attempting to add a contextual filter by Taxonomy so I've added the Content: Has Taxonomy term ID (with depth) filter and selected the Specify validation criteria option and selected the Taxonomy that I wanted to work with. I also used the filter value type of Term name converted to term ID yet when I attempt to preview the filtered elements, I get the no results behavior. What should I be typing to call the filtered elements correctly?

Atm, to provide a concrete example, I have tried my_view/mississippi-river to call all nodes tagged with the Mississippi River taxonomy term via hierarchical select. Again, this leads me to the no results behavior. Additionally, how would I call a child of the Mississippi River Taxonomy term? Any ideas?


texts:
All of the documentation assumes the content content load into colorbox will happen as a result of click... (e.g., the parameters calling colorbox are built into the link)

  My Example

I want to issue a redirect to a URL that then opens in colobox...

Any suggestions or experience solving this?


texts:
I am trying to write my own drush command. I have a hunch that something is not quite working right. I can't see documentation saying whether drush fires hook_exit()

Anyone know this?


texts: Rule to store user's last post date and scheduled rule based 30 day reminder

texts:
In this scenario, user's can post 1 node of a specific content type every 30 days (interval changes depending on user role). We are using node_limit to accomplish this; it's doesn't play with rules.

So, the idea is to schedule an email that will remind the user 30 days later to post a new article AND update a field in the user's account to display the last time the user posted. Once the node is saved, the rule should update the user field with the node's post date.

BUT I'm unable to correctly configure the set a data value.

The rule I have created is as follows:

Fetch entity by property
Parameter: Entity type: User, Property: press_update_last_posted, Value: [node:created]
Provides variables: Date (entity_fetched_pressupdatelastposted)

Set a data value
Parameter: Data: [entity-fetched] ..., Value: [entity-fetched] ...

And then of course it would fire up the scheduled email and display a message on the site.

Any suggestions?


texts: Print translated links in custom page--front.tpl.php

texts:
I have a custom template for my front page, where I have to manually set URLs. Some of them are Views paths (such as news), some - aliased node URLs (projects/project-1). How to get their path translation URL in raw PHP code?

If I say something like:

<a href="<?php print url('news', array('language'=> $langcode, 'alias' => TRUE)) ?>" ...>

the rendered link is invalid langauge-crossed, such as mysite.com/es/news.

I tried also with the l() function but I'm getting untranslated link pointing to the root mysite.com/news.


texts:
I build a view page and have exposed filter, when I change any filters I use ajax to fetch data and re-build the content area. The ajax URL looks like

  views/ajax

I want to change the above URL to some external middleware something like below

  http://www.example.com/getData

with the existing post data. Is it possible?


texts: Simple row saving through link with Drupal 7

texts:
I have a simple requirement but I am not sure how to fulfill it. On my Drupal site, I need a link which when I click creates a row in a table in DB through AJAX.

That's about it.

The main goal of mine is to create a "My List" for any user. The user can go to any node and press "Save it" and it can then save it to the "List". User can later go to "My List" and see all the "saved" nodes which he saved.

Hence Basically, it's a Save for later for the nodes.

I hope there is some module for it. I couldn't find hence I thought I can create it myself, hence the question.

Many Thanks


texts:
I'm using Drupal Privatemsg module and there's a requirement when a link is clicked, it should open up write new message form with recipient, subject and part of message body are already filled for the sender.

I'm getting the recipient and subject as messages/new/$recipient/$subject through URL but don't know how to set message body.

I can't change it in admin/config/messaging/privatemsg as there are several message types being passed but only one needs this preset message body text.

Can someone help me please?


texts: How to check if a scheduled Rules action set has already been scheduled?

texts:
I'm using the Rules Scheduler (sub-module of the Rules module) to schedule an email reminder based on a date field set in the content type. So a user can request a reminder email on a specific date, to update that content.

However, if I invoke the Rules Action on node update, then I end up with lots of emails scheduled for that date.

How can I make sure that the rule is only scheduled once for the given date?


texts: How do I remove or hide seconds in the Drupal 8 time picker?


texts:
small question and I will keep it simple : I have a drupal website with an xml page. The xml is used by another website and needs a different '< TAG >'. The current tag for an image I'm using is '< enclosure url="url">< /enclosure>' and I need it to be '< image > URL HERE < /image >'.

Any tips or answers are welcome!


texts: Colorbox Slideshow not Working on Mobile Devices

texts: I have a Colorbox slideshow that doesn't want to work on mobile devices. Instead of opening up the slideshow modal on an image click, the browser opens the image in a new tab.


texts: Contextual filters not allowing multiple values

texts:
I'm using Drupal 7 and Views 7.x-3.8. I have a taxonomy term "A" which is related with another taxonomy term "B". I want to retrieve a list of "A", but filtered by those "B" that are present in the URL as query parameters. There can be more than one "B" in the URL.

So I've created a contextual filter with PHP code that finds all "B" IDs in the URL and ends up with something like: "return $B1+$B2+$B3...;". Of course, I've checked the Allow multiple values option.

If I pass only one value (e.g. return "15";), the query runs OK and it brings me all "A" related with the B with ID 15, but if I pass two or more values (e.g. return "15+20";), I get a No query was run message, and nothing in the view.

Is this bug for the Views module? I've also tried to replace the PHP code with a simple return "15+20"; in order to simplify the test case, but I get the same error.


texts: How do I set the "Save draft" button by default on all webform nodes?

texts:
I have a situation where, when I create a new webform node, its "Save draft" button must be there by default.

How can I achieve this?


texts: Changing navigation depending on authentication status

texts:
How can I change my menu items depending on whether the user is logged in or not? For example, I would like my secondary navigation to have a "sign in" link if the user isn't authenticated and "log out" if the user is authenticated.

Thanks!
Jane


texts: Installing Drush on Mac OS 10.13 (High Sierra)

texts:
I've been struggling for a few days getting drush to install properly on my Mac.

I've followed the instructions on https://www.drupal.org/node/1674222

Composer installs fine, but when I cd into drush-master and run composer install, I get:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for drush/drush No version set (parsed as 1.0.0) -> satisfiable by drush/drush[No version set (parsed as 1.0.0)].
    - drupal/core 8.0.0-beta9 requires phpunit/phpunit 4.4.* -> satisfiable by phpunit/phpunit[4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta8 requires phpunit/phpunit 4.4.* -> satisfiable by phpunit/phpunit[4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta7 requires phpunit/phpunit 4.4.* -> satisfiable by phpunit/phpunit[4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta6 requires phpunit/phpunit 4.4.* -> satisfiable by phpunit/phpunit[4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta15 requires phpunit/phpunit 4.6.* -> satisfiable by phpunit/phpunit[4.6.0, 4.6.1, 4.6.10, 4.6.2, 4.6.3, 4.6.4, 4.6.5, 4.6.6, 4.6.7, 4.6.8, 4.6.9] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta14 requires phpunit/phpunit 4.6.* -> satisfiable by phpunit/phpunit[4.6.0, 4.6.1, 4.6.10, 4.6.2, 4.6.3, 4.6.4, 4.6.5, 4.6.6, 4.6.7, 4.6.8, 4.6.9] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta13 requires phpunit/phpunit 4.6.* -> satisfiable by phpunit/phpunit[4.6.0, 4.6.1, 4.6.10, 4.6.2, 4.6.3, 4.6.4, 4.6.5, 4.6.6, 4.6.7, 4.6.8, 4.6.9] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta12 requires phpunit/phpunit 4.6.* -> satisfiable by phpunit/phpunit[4.6.0, 4.6.1, 4.6.10, 4.6.2, 4.6.3, 4.6.4, 4.6.5, 4.6.6, 4.6.7, 4.6.8, 4.6.9] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta11 requires phpunit/phpunit 4.6.* -> satisfiable by phpunit/phpunit[4.6.0, 4.6.1, 4.6.10, 4.6.2, 4.6.3, 4.6.4, 4.6.5, 4.6.6, 4.6.7, 4.6.8, 4.6.9] but these conflict with your requirements or minimum-stability.
    - drupal/core 8.0.0-beta10 requires phpunit/phpunit 4.4.* -> satisfiable by phpunit/phpunit[4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5] but these conflict with your requirements or minimum-stability.
    - Installation request for webflo/drupal-core-strict 8.6.x-dev -> satisfiable by webflo/drupal-core-strict[8.6.x-dev].
    - drupal/alinks 1.0.0 requires drupal/core * -> satisfiable by drupal/core[8.0.0, 8.0.0-beta10, 8.0.0-beta11, 8.0.0-beta12, 8.0.0-beta13, 8.0.0-beta14, 8.0.0-beta15, 8.0.0-beta16, 8.0.0-beta6, 8.0.0-beta7, 8.0.0-beta8, 8.0.0-beta9, 8.0.0-rc1, 8.0.0-rc2, 8.0.0-rc3, 8.0.0-rc4, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.6, 8.0.x-dev, 8.1.0, 8.1.0-beta1, 8.1.0-beta2, 8.1.0-rc1, 8.1.1, 8.1.10, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.1.7, 8.1.8, 8.1.9, 8.1.x-dev, 8.2.0, 8.2.0-beta1, 8.2.0-beta2, 8.2.0-beta3, 8.2.0-rc1, 8.2.0-rc2, 8.2.1, 8.2.2, 8.2.3, 8.2.4, 8.2.5, 8.2.6, 8.2.7, 8.2.8, 8.2.x-dev, 8.3.0, 8.3.0-alpha1, 8.3.0-beta1, 8.3.0-rc1, 8.3.0-rc2, 8.3.1, 8.3.2, 8.3.3, 8.3.4, 8.3.5, 8.3.6, 8.3.7, 8.3.8, 8.3.9, 8.3.x-dev, 8.4.0, 8.4.0-alpha1, 8.4.0-beta1, 8.4.0-rc1, 8.4.0-rc2, 8.4.1, 8.4.2, 8.4.3, 8.4.4, 8.4.5, 8.4.6, 8.4.7, 8.4.8, 8.4.x-dev, 8.5.0, 8.5.0-alpha1, 8.5.0-beta1, 8.5.0-rc1, 8.5.1, 8.5.2, 8.5.3, 8.5.4, 8.5.5, 8.5.6, 8.5.7, 8.5.8, 8.5.x-dev, 8.6.0, 8.6.0-alpha1, 8.6.0-beta1, 8.6.0-beta2, 8.6.0-rc1, 8.6.1, 8.6.2, 8.6.3, 8.6.x-dev, 8.7.x-dev].

etc...

Can someone tell me how to do this right?


texts: Custom permissions for unpublished content

texts:
I'm running in to a problem with my drupal 8 site. I want to give access to unpublished content. I found a solution using a hook.

I want to create a custom module these don't seem to work.

I found this for the unpublished problem:
"View unpublished content" permission for non-author

It looks like a solid solutions for my problems but I can't get them to work. I can enable the modules created, and it doesn't give any errors.

My view_unpub.info.yml file:

name: View Unpublished
type: module
description: 'View Unpublished Content'
package: SVDS
core: 8.x

My view_unpub.module file:

<?php
function view_unpub_permission()
{
    return array(
        'unconditionally view unpublished content' => array(
            'title' => t('Unconditionally View Unpublished Content'),
            'restrict access' => TRUE
        )
    );
}

function view_unpub_node_access($node, $op, $account)
{
// We're only bothered about the 'view' operation at the moment
    if ($op == 'view') {
// If the user has access to our new permission, let 'em at it
        if (user_access('unconditionally view unpublished content', $account)) {
            return NODE_ACCESS_ALLOW;
        }
    }

// For everything else let the system decide.
    return NODE_ACCESS_IGNORE;
}


texts: Fatal error: Class 'SelectQuery' not found in includes/database/database.inc on line 813

texts:
Fatal error: Class 'SelectQuery' not found in /home/content/71/11241671/html/drupal/includes/database/database.inc on line 813

We built a site in a subfolder called /drupal while building the site, and then moved the files to the root directory when we were finished but it gave the above error on a WSOD.

I have tried:

flushing the cache before moving
tried the registry rebuild
truncating and replacing the registry and registry_file tables with a fresh install copy, and rebuilding the registry again
rewrite base in htaccess
setting a new base url in settings.php

But nothing has worked.

The second we put the files back into the /drupal folder, it works again. It also looks like the error mentions the file in the /drupal directory, which isnt there anymore.

This is on 7.37

Anyone have any ideas?


texts: Views + Search API not properly sorting by Commerce Price (seems random)

texts:
I have a search index View of product variations. The commerce_price field is indexed and exposed as sort option. However, when sorting by the price it appears mostly in order (Asc or Desc) but some items are not in the proper order (see screenshot)
I've tried indexing the price field as an integer, decimal, and string but it always has the same effect.
There are no additional sort items.
There are not any price adjustments or custom calculations.
There is no custom code affecting the Views or pricing.
I've tried wiping and rebuilding the index multiple times.
The View is using Better Exposed Filters.
Any ideas how I can get the products to sort by price correctly?


texts:
I am using someone else's theme on a very small site.

Specifically, I want to display blocks on specific pages. I am able to display blocks on  only and on all pages except .

My understanding is that I should be able to display a block only on page "what-we-do" putting what-we-do where I put .

Alternatively I code put node/7 (this page being node/7).

The result is that the block is displayed persistently on the front page and on no others.

This is clearly nonsensical and either I am doing something very silly or I need to start reading through the code.

My question, precisely: has anyone encountered this problem before and can they suggest a way forward?


texts: Drupal 7 I need to style the title attribute

texts:
Here is link to what I am trying to accomplish in drupal.

 http://70.169.1.219/hijo/css3_test.html

In order to get the mouse over to work the title tags where changed to data tags and styled by the css.

In drupal, it deletes the data tags that I put in block to render the affect.

 http://70.184.177.183/Uptown/home

If I style the title block, I get the double affect. I don't think there is a way to suppress the browser rendering of the title tag.

Looking for any suggestion.

UPDATE:

What I ended up getting to work was that in the CKEditor, I remember you use to be able to make an editor and call it PHP which would allow anyone to introduce PHP code into the block. So I created a new CKEditor profile and to my suprise it did not really offer any config. So I gave it the minimum config that it requiried and named it PHP. I went back in and switched to that profile an opened the block and was able to type in any HTML code I so choose and now my project is back on schedule. !
screenshot of the image overlay


texts:
I like to implement this codepen into drupal but the images in the background should come from a ctype within Drupal.

The codepen example:
http://codepen.io/AmeliaBR/pen/myPBNg

So basically how to get this line dynamic in a page?

article {
  background: url(https://foo.com/fooimage.jpg) no-repeat center;
}

Can you point me to the good direction? Is there a module which support this? What tags should I look?


texts: Organic Groups - How to disable "Groups" Tab

texts: I enabled OG and now I have a tab that lists all "public" groups if you're not registered, and it'll show the groups you belong to if registered. What's the best way to get rid of the groups tab for Anonymous users? It can be visible to authenticated users.


texts: How add tab menu item with external link to article node content

texts:
I want to add an extra tab menu item to article node type.

I mean a new menu item beside view, edit and other tabs only in article node.

but this tab menu item has external link to another site and it's target is _blank (to open destination in new window)

what is your solution for my issue?


texts: How to disallow a view to display user's label (and some other fields?) when the user access is not allowed

texts:
I have created a very simple UserAccessControlHandler which return AccessResult::forbidden() is all cases:
 class MyUserAccessControlHandler extends UserAccessControlHandler {

  protected $viewLabelOperation = FALSE;

  protected function checkAccess(EntityInterface $user, $operation, AccountInterface $account) {
    return AccessResult::forbidden();
  }
}

function my_module_entity_type_alter(array &$entity_types) {
  $user = $entity_types['user'];
  $user->setAccessClass('Drupal\my_module\Access\MyUserAccessControlHandler');
}

it is working fine: Nobody can access a user profile.
But, If I create a view listing all users in a table with 3 columns:

column 1 : name of the user (+link to the profile)
column 2 : a custom field value of the user
column 3 : the langcode field of the user (not sure what is this field, it looks like it is the original language code when the user has been encoded)

I was expecting that the view was empty for all regular users... but not!
The view display all users with the following information:

column 1 : The name (without the link)
column 2 : empty (has expected)
column 3 : the langcode of the user

My question is: is it a bug or did I miss something?
Edit to add: I solve this problem by implementing a checkFieldAccess function which allow the access of the name field (and some others) only if the account have access to the user: $access = $user->access($operation) [There is also the case of the user creation, but it is not my topic]
It is working, but I feel this is not the way to go (if there is no access to the user then there should be no FieldAccess at all)... My question remains.


texts: How can I add a span tag inside my menu link?

texts:
My twig file contains the following:

   {{ link(item.title, item.url) }}

Which outputs:

    Search

But I really want to add a  tag around the text Search (for styling purposes and replacing the text with an icon image.

I tried replacing {{ link(item.title, item.url) }} with {{item.title}} but that loses valuable attributes provided by the link function (as well as the menu_link_attributes module). I'm not sure if I can do this in twig or I need to write some sort of function in my .theme file. Any help appreciated. Thank you.


texts: How to add content filter into a content page(not in a view)?

texts:
So I'm totally new with the drupal and try to wrap things around my head, which is quite overhelming at first, so my question might be a simple one for pro's.

I'm building Property Listings site where users could submit their own listings, add comments and search and view Property Listings sorted by location, type, price and etc.

So when you search the site on the Search Bar it gives you a page with all the relevant content. For example: If i search for 2bed flats at around 50k they open a page with url defined in taxonomy term"around50k". And now, i have no idea what to do to add a filter for "Location" on that page.

I could make the whole new page with a view for that exact type of listings and add whatever filters i want, however as there a hundreds of categories it would be a nightmare.

I know i could add more filters to a search bar, however i will have all Property Type menu on the site and i need *location and price* filters for each page on that menu.

Is there any functions that would create filters for content on pages or any other solution to this problem?


texts: Delay ajax call on textfield to allow for typing

texts:
I would like to delay ajax from firing in the same way that the autocomplete seems to work. For example, if a user it typing, the ajax will not run until 500ms has elapsed since the last keyup.

I am currently looking at drupal.behaviors but not able to make it work.

Drupal.behaviors.mymodule = {
  attach: function(context, settings) {
    $('input.andtimer', context).delay(500).ajaxStart();
  }
};

This is the form element to which the behavior is attached.

$form['my_input'] = array(
  '#type' => 'textfield',
  '#default_value' => $value,
  '#ajax' => array(
    'callback' => 'my_callback',
    'event' => 'keyup',
    'wrapper' => 'my_wrapper',
    'trigger_as' => array(
      'name' =>  'my_button',
  ),
  'progress' => array('type' => 'none'),
  ),
  '#attributes' => array(
    'class' => array('andtimer'),
  ),
);

This jsfiddle shows what I am trying to achieve.

Would How to override Drupal.ajax.prototype.beforeSend? be a route to take this down?

The following works for the first 'set' of inputs with the class .andtimer. It is not working for any other set, the ajax always continues with the first set. Any ideas how to fix this?

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

            var events = $('.andtimer').clone(true).data('events');
            $('.andtimer').unbind('keyup');
            var typingTimer;
            var doneTypingInterval = 300;
            $('.andtimer').keyup(function() {
                clearTimeout(typingTimer);
                typingTimer = setTimeout(doneTyping, doneTypingInterval);
                function doneTyping() {
                    $.each(events.keyup, function() {
                        this.handler();
                    });
                }

                return false;
            });
        }
    };
})(jQuery, Drupal);

Using $form['my_input']['#ajax']['event'] = 'finishedinput' as suggested and

var typingTimer;
var doneTypingInterval = 600;

$('.andtimer').on('keyup', function (e) {
  clearTimeout(typingTimer);
  if ($(this).val) {
    var trigid = $(this);
    typingTimer = setTimeout(function(){
      trigid.triggerHandler('finishedinput');
    }, doneTypingInterval);
  }
});

Works for each 'group' of inputs where the count of filled inputs needs to be obtained.


texts: How to use the same URL alias for all translations of a node?

texts:
I want to use the same URL alias for all nodes regardless of language.

On my site, the primary language is English.  Translation is enabled for nodes of type basic page.

At /admin/config/regional/content-language, content translation is enabled for the Title and Body fields.

With this configuration, on the node edit page, it shows "URL alias (all languages").  I set a URL alias manually for each English node.

However, when I add a translation in another language, even though I see my alias on the translation edit page, this alias is not applied for that language.  In other words, if the alias is myfolder/mypage in English, if I go to the Japanese translation at /ja/myfolder/mypage, I get a "page not found" error. Instead, the page is available at /node/5 or whatever the NID is.  But, on the "edit node" page for the Japanese translation, it does show the English alias with the text "all languages."

Workaround

I can go to /admin/config/regional/content-language and enable translation of URL alias and then manually set each additional language alias to the English alias, but this seems like a lot of extra work to keep the same alias.


texts: Salesforce API module encryption warning

texts:
I started working on a legacy Drupal 7 site that uses the salesforce_api at version 7.x-2.0-alpha3 (yes, it's ancient). I noticed in the status report page the following warning:

There is a link on the warning that goes to the Salesforce module configuration page, but no real direction what to change to encrypt this properly.

Does anyone know what could be missing from the Salesforce configuration to throw this warning? Is it because the module is so old? That's my suspicion, but after googling around, nothing came up on that warning at all.


texts: Simplest way to have dynamic content (year) in field's default value?

texts:
I'm looking for the simplest way in Drupal 7 to set simple dynamic content in the default value of a text field.

Specifically, I have a "Copyright notice" field, and I want the default value to be like this: "© Copyright Our Organisation [YEAR]", where [YEAR] is the current year. When the user creates a node in 2012, the form field is pre-populated "© Copyright Our Organisation 2012", and will be saved as this and stay as 2012 unless editted. When the user creates a node in 2013, the form field is pre-populated "© Copyright Our Organisation 2013" but all the old nodes made in 2012 don't change. EDIT: The field should still be editable, so users can replace it where it's not appropriate (e.g. if one piece of content they're uploading is actually "© Copyright Some Other Organisation 1981"): but the default should reflect the current year.

There seem to be a few options, but none of them seem particularly clean:

Using tokens. It seems that this requires either the token_filter module or the token_insert module. Then, the default value could include [current-date:custom:Y]. However, it's not so clean. For token_filter, the token from the default won't be translated until the user manually changes the input filter to "token filter" and hits save - bad for the user. For Token Insert, I believe the input field type would need to change to long text, and I'm not even sure it would work in the context of setting the default value.
Custom module. Something like, setting the default value to include some gibberish string like "_!YEAR!_", and then use something like hook_form_alter(); to find and replace. Or, defining some custom field that does this. Both involve fixing this specific combination of field and content firmly into code, which seems undesirable.
D7 CCK module. It exists (as a dev module) and apparently it has some feature to do with setting lists using PHP that didn't go into D7 core. Sounds not very applicable to this case however.
PHP filter. While you can set the Default Value field to use the PHP filter, in testing I found it doesn't actually apply the filter to the content you enter into the default value field. For example, putting © copyright Our Organisation <?php echo date('Y'); ?> into a default value field with PHP Filter applied just dumps that exact string, © copyright Our Organisation <?php echo date('Y'); ?>, into the field on the edit/create form, giving a user without access to the PHP filter nothing but some escaped text resembling PHP code, and giving a user with PHP filter access PHP code in the content of the field which continually processes, rather than becoming static text.

Am I missing something? Is there another way, or a variant on the above that is simpler?


texts: How to filter with taxonomy term (with depth) for a user based view

texts:
There is no filter by taxonomy term with depth option when I filter my view of users. I can only filter by a single exact term, so filtering by "Europe" doesn't find users with "France". All the content views allow this filter, so how do i get it for users?

All my content an users are associated with a taxonomy term for their Location:

Europe

France
Germany

North America

USA
Canada

etc etc


texts: Users that exist only on slave cannot login

texts:
Once I've installed bakery, users that exist only on the slave site can no longer log in. Everything else is working perfectly.

Is this by design?


texts:
I have facing this issue like I have given menu link say http://localhost/mcs/admin/config/b_creation  but that menu only admin can able to access not any other users, all most all the menu which comes under http://localhost/mcs/admin/config/ will not show to authenticated user I have tried many times by setting the permission in people->permission but no use of it it shows

  Access denied You are not authorized to access this page

. can any one tell me why is it happening?


texts: Overriding theme_item_list() not working

texts:
I have the following code in the theme template.php file:

function MYTHEME_item_list(&$variables) {
  // my custom stuff done to theme_item_list
  return $output;
}

And also this:

function MYTHEME_theme($existing, $type, $theme, $path) {
  return array(
    'item_list' => array(
      'variables' => array(),
    ),
  );
}

I have cleared cache many times.

Looking at the theme registry I can see that my override is getting picked up:

[item_list] => Array
  (
    [function] => MYTHEME_item_list
    [type] => theme_engine
    [theme path] => profiles/eurostar/themes/eurostar
    [variables] => Array
      (
        [items] => Array
          (
          )
        [title] =>
        [type] => ul
        [attributes] => Array
          (
          )
      )
    [preprocess functions] => Array
      (
      )
    [process functions] => Array
      (
      )
  )

Unfortunately none of this works. Does anyone have an idea of what I'm doing wrong?

UPDATE:
So, this works: theme('item_list', $variables);

This does not: theme_item_list($variables);


texts: Custom validation for a custom field in comment form

texts:
I'm currently trying to set up a custom validation script to prevent spam on a comment form with hidden elements.  The problem involves setting up the conditional for the submitted form values.  I'm currently using the hook_form_FORM_ID_alter.  Here is my existing code.

function STARTERKIT_form_comment_node_contact_page_form_alter(&$form, &$form_state) {
    $form['#validate'][] = 'comment_validation_function';
}

function comment_validation_function($form, &$form_state)
{
    if ($form_state['values']['field_website'] != 'http://') {
        form_set_error('field_website', t('Please do not change the value of this field.'));
    }
}

The problem is that $form_state['values']['field_website'] isn't returning the value inside the text field.  I've looked at so many pages showing a script very similar to this, yet I haven't been able to get this even close to working.

The field id is "field_website".


texts: Delete permissions not working with Domain Access instaled

texts: I have a site with Domain Access module installed. I have created an Admin View, which lists types of content (exposed filter). My surprise is that a role, which is Editor (a kind of Authenticated user), and which in permissions has only Edit permissions for that kind of content, is able to Delete the node, when he/she would not be allowed according to the permissions. I have rebuilt permissions, and there appears the Delete link, and it also performs the deletion. How can I check it, maybe at low level database?


texts: Send email to all users with specific role (updated privacy policy)

texts:
We want to send an email to all users of a given role, to let them know about an updated privacy policy.

The filter by role allows to send different versions of the email to different roles.. not sure this is needed, but it will be useful to know.

Since this is a legal notice, it does not make sense to provide an unsubscribe link.

The email should be a somewhat decent looking HTML.
Perhaps we want to add some user-specific tokens, e.t. to link to the user profile.

So there needs to be some kind of authoring UI, e.g. by creating a node or something.

What I looked at so far

I installed mass_contact, but it seemed to add unnecessary complication with its categories.

In some other questions, people suggest to use rules. But in my understanding those are mostly meant for repeated email-sending, not for a one-off. Also I don't really know where I would find the authoring UI.

Simplenews might be another option. In my understanding, this is designed for consent-based newsletters.

Perhaps all these solutions can be used for the purpose I intend, but perhaps there is something more specialized for this specific task?


texts: How do I hide an empty field if my custom field formatter removes all items?

texts:
I have a custom field formatter (in Drupal 8) that displays a list of taxonomy terms on a node. Some terms are not meant to be displayed, so the field formatter removes them from the items list.

Occasionally, all items are removed -- yet the HTML elements that wrap the field are still rendered. How do I hide the field completely when all items are removed?

EDIT FOR CLARITY:

I have a field with machine name field_tags that is an entity reference to multiple taxonomy terms.

To render this field, I wrote a custom formatter as a field formatter plugin in a custom module. The code is stored in the standard location in mymodule/src/Plugin/Field/FieldFormatter/TermListFormatter.php

My class extends EntityReferenceFormatterBase.

In my class, my viewElements() method strips out some items as needed and sometimes returns an empty array if no items should be rendered.

  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];

    // Loop through each of the terms in this field.
    foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
      $label = $entity->label();

      // ONLY show taxonomy terms that begin with "Test".
      if (mb_substr($label, 0, 5) === 'Test') {
        $options = [
          'query' => [
            'tags' => [$entity->id()],
          ],
        ];

        // Output terms as links to /test?tags[]={tid}
        $elements[$delta] = [
          '#type' => 'link',
          '#title' => $label,
          '#url' => Url::fromRoute('view.test.page_1'),
          '#options' => $options,
        ];

        if (!empty($items[$delta]->_attributes)) {
          $elements[$delta]['#options'] += ['attributes' => []];
          $elements[$delta]['#options']['attributes'] += $items[$delta]->_attributes;
          // Unset field item attributes since they have been included in the
          // formatter output and shouldn't be rendered in the field template.
          unset($items[$delta]->_attributes);
        }

        $elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
      }
    }

    // This will be an empty array if there were no terms beginning with "Test"
    return $elements;
  }

When all the terms are stripped out, the field wrapper elements are still output as follows:

How do I stop these elements from appearing when there are no terms to show?


texts:
I'm using Rules Link, via a Views block set in a user Panel page. At the moment it sits ready for a users click response to trigger an event and works fine in its approach.

Prior to major Theming/CSS, I would like to have the generic 'Blue' URL text link show as a graphic button (ie generic 'bootstrap' style), can anyone advise the quickest way to change this so I can get a feel of the layout and look. I presume it's a CSS template addition, can someone give me some tips (I'm using Bootstrap)
Thanks in advance for any help.


texts: Is there a hook when a relation is created, updated or deleted?

texts:
I know how to use hooks like hook_node_presave. Is there also a hook to catch the deletion of a relation or the update of a relation? In the API I cannot find anything.
Maybe there is a workaround?

Thanks.


texts: What are some reasons unpublished content is visible to anonymous users?

texts: The anonymous user role has no permissions to view/edit unpublished content. I'm wondering what kind of tests I can use to locate the bug, there is one module calling hook_node_access, but it returns AccessResult::allowed(); on update operations $op == 'update' so it should not be affecting view operations. I'm stumped.


texts: How to dynamically Prepopulate / Prefill addressfields

texts:
I have an single entityform of type 'letter generator' this contains two addressfields:

'To' addressfield
'From' addressfield

I would like to prepopulate / prefill these addresses with content from elsewhere on my site.

'From' addressfield populated from the 'User addressfield' attached to my 'user' entity type.
'To' addressfield populated from the 'School addressfield' attached to my 'School  info' 'node' entity type (also the parent node for the letter generator)

I am new to php and programming so this is my first attempt at a custom module. So far I have the following php that attempts to address point (1.)

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

// Check to see if the form alter function is actually running
dsm($form);

    // Only do this for a new, not-yet updated entityform -NB might need a 'return' here
    if (!isset($form['#entity']->is_new)) {

        //Ensure, we're updating field info on the correct entity type
        if ($form_id == 'letter_generator_entityform_edit_form') {

            // load user information
            global $user;
            $current_user = user_load($user->uid);

            //Populate the entityform addressfield with values from the user addressfield
            $form['field_user_address'][LANGUAGE_NONE][0]['#address']['thoroughfare'] =
                $current_user->field_user_address[LANGUAGE_NONE][0]['#address']['thoroughfare']['value'];
            $form['field_user_address'][LANGUAGE_NONE][0]['#address']['premise'] =
                $current_user->field_user_address[LANGUAGE_NONE][0]['#address']['premise']['value'];
            $form['field_user_address'][LANGUAGE_NONE][0]['#address']['locality'] =
                $current_user->field_user_address[LANGUAGE_NONE][0]['#address']['locality']['value'];
            $form['field_user_address'][LANGUAGE_NONE][0]['#address']['administrative_area'] =
                $current_user->field_user_address[LANGUAGE_NONE][0]['#address']['administrative_area']['value'];
            $form['field_user_address'][LANGUAGE_NONE][0]['#address']['postal_code'] =
                $current_user->field_user_address[LANGUAGE_NONE][0]['#address']['postal_code']['value'];

        }
    }

}

...
Ok I got this working:

global $user;
$user_fields = user_load($user->uid);
//useful ...
dsm($user_fields);
$userthoroughfare = $user_fields->field_user_address['und']['0']['thoroughfare'];
$userpremise = $user_fields->field_user_address['und']['0']['premise'];
$form['field_user_address'][LANGUAGE_NONE][0]['#address']['thoroughfare'] = $userthoroughfare;
$form['field_user_address'][LANGUAGE_NONE][0]['#address']['premise'] = $userpremise;

  NB adding ['value'] to the line:

$form['field_user_address'][LANGUAGE_NONE][0]['#address']['administrative_area']['value'] = $useradministrativearea;

  will select the state for you...


texts:
I am on Omega 4. How do I disable responsive web design for my sub-theme? i.e. fixed grid yet I can still use singularity or other goodies in Omega.

I was from Omega 3.

I would like to quickly get the website up without spending too much time tweaking for RWD.


texts: Would redirecting users in hook_menu's access callback have any undesirable effects?

texts:
This answer led to a discussion about the best way to redirect a user to a specific page if they shouldn't have access to the page they are trying to access.

One option is to set the access callback to true and then redirect users in the page callback. Whilst this seems valid I think it is mixing access functionality with page building functionality in the page callback.

E.g.

function hook_menu() {
    $items['player/my_page'] = array(
        'title' => t('My Page'), // note this is a required parameter
        'access callback' => TRUE,
        'page callback' => 'some_function',
    );
    return $items;
}

function some_function() {
    global $user;
    if(!$user->uid) { // here checking if the user is logged in but could be checking for a specific permission or field value
        $dest = drupal_get_destination();
        drupal_goto('user/login', $dest); // this remembers where the user is coming from
    }
    // carry on building rest of page
}

Another option is to set the access callback function to call a function that checks if the user has access, but then instead of returning false it would redirect the user to another page. This is good as it is separating access logic and page building logic. However the purpose of an access callback is to return a boolean value, so this is breaking that logic by redirecting the user.

E.g.

function hook_menu() {
    $items['player/my_page'] = array(
        'title' => t('My Page'), // note this is a required parameter
        'access callback' => 'check_access',
        'page callback' => 'some_function',
    );
    return $items;
}

function check_access() {
    global $user;
    // here checking if the user is logged in but could be checking for a specific permission or field value
    if(!$user->uid) {
        $dest = drupal_get_destination();
        drupal_goto('user/login', $dest);
    }
    return TRUE;
}

Are there any undesirable effects from redirecting users in the access callback that I'm not aware of?

What do you think is best practice here?