texts: Sending out bulk HTML formatted emails with one time login links

texts:
I'm making a new webshop for a client, and the idea is, once it goes online to send existing users an email saying:

'hey, we have a new site, and while we're at it, check out these new offers we have'

However, I wouldn't want it to be only plain text, as thats not very efficient in luring customers and the email has to contain a one-time login link, cause I wasn't able to get the passwords from the old D6 website due to changes in the encryption algorithm. Currently, I'm using the one-time login module, which does the job, but doesn't let me to HTML format the mail template.

My question is:
Is there a solution readily available for this, i.e. to embed wysiwyg editor to the mail template (under admin/config/people/accounts), or can someone suggest another module, that can both handle one time login links and supports HTML mails? Or maybe a solution outside drupal, that somehow integrates with it, and is possibly free of charge?

https://www.drupal.org/project/mimemail - or may this module be eligible for the task? And if yes, can someone give me some hints on how to get it working the way I need to?

Thanks in advance!
Huba


texts:
When we want some specification for a content, how should we decide whether to make that specification a separate content type or a taxonomy term?

For example, I had to build a music store site. The main content was music tracks, albums, label, music director, and producer. I made a content type (Music Tracks) and albums, label, music director, and producer were taxonomy terms which were given as entity references in the Music Tracks. Then, I was suggested to make the site scalable and thus making album, producer, and label a separate content type.

So how do content types help in making the website scalable?


texts: How to send a push notification with Rules to specified user by grabbing UID from content field?

texts:
I want to send a push notification to a single Drupal, which, seems simple given the below screen shot.

This works great when the user is always the same (I simply type in the UID). However, in my case, the UID is always different. Is it possible for me to grab the UID from a content field (e.g. from Content Type 'Friends', I have a field named field_target_user) using a token, and have it populate in my Rules' User Identifier field?


texts: else condition does not work in my code in twig template

texts:
In the code given below

content.field_image_link[0]['#url']
is empty but it still enters the if condition and adds html
what is incorrect in the below code due to which it enters the if condition whereas it should enter the second if condition given below

{% if content.field_image_link[0]['#url'] %}

{% block paragraph %}

    {% block content %}

{% if content.field_image_link[0]['#url'] %}

{{ content.field_image_2 }}

{{ content.field_image_link[0]['#title'] }}

{% endif %}
{% if content.field_image_link[0]['#url'] == '' %}
{{ content.field_image_2 }}

{{ content.field_image_link[0]['#title'] }}

{% endif %}
    {% endblock %}

{% endblock paragraph %}


texts: What is the simplest, most drupalish, way to restrict access to some content to authenticated users or a certain role?

texts:
I am creating a publications database that is used by staff to input their publications.  Some of these publications are available to the public, and some are not.  Additionally, the publications have files associated with them, some being public and some not.  I have a number of content types for different types of publications with a boolean public field, and two seperate file fields, one for public and one for internal files.  I currently have one user role (Staff member) though the number of roles is likely to increase slightly to allow for administrators and a content approval workflow.

Content Type a

Public?
Public Files
Internal Files

Content Type b

Public?
Public Files
Internal Files

The idea is that all the publications lists should show a list of public documents to non-authenticated users, and a list of all documents to authenticated users of the right role.

My initial thought is to create two different views for each page with different access settings on each.  The first being a page that doesn't check the public field and includes the non-public files field, and a second, available to anyone, that filters to publications where the public field is set to true, and does not include the internal files field, and a few other fields only of interest to staff.

node list view

view a

access: staff only
filter: Published nodes

node list view

view b

access: no restriction
filter: Published nodes AND public is true

node view

view a

access: staff only
filter: Published Nodes
fields: All Fields, including internal files

view b

access: no restriction
filter: Published Node AND marked public
fields: don't display internal files, some other fields

Is this the simplest, most drupalish approach?  Would it make more sense to control the fields used through the view or via view mode (Full Content, Teaser, etc.)  I'm still somewhat new to working with Drupal, and find that I'm fighting it at every turn, that makes me think, I must be thinking the wrong way for working with a drupal site.

Further Information: I'm actually reimplementing this from an existing system, and am using the Migrate module to bring in thousands of entries, so I have to be able to specify as part of the migration in some way, what the permissions should be.


texts: Must new tables be created in hook_update_N()?

texts:
When you create a new table in hook_schema(), should that table be added in a hook_update_N() as well? Or is there some trick, or something I missed, to have databae-updates automatically add tables?

The documentation of hook_update_N() does not explain anything about introducing new tables, whereas the documentation of hook_schema() says:

  The tables declared by this hook will be automatically created when the module is first enabled, and removed when the module is uninstalled.

(Highlight is mine)

And if so, how to best avoid duplicating the schema definitions for the new table in both hook_update_N() and hook_schema(). Simply referring to the schema as follows:

 function hook_update_N(&$sandbox) {
   $schema = hook_schema();
   $name = "foo";
   $table = $schema["foo"];
   db_create_table($name, $table);
 }

Seems to work, but on changing the table again, will fail if a user runs the updates and gets to run two or more hook_update_N()s. After all: the first hook_update_N will then already install the correct database and the second hook_update_M() will try to add/change/alter columns that were already up-to-date.

How do you deal with this?


texts: Workflow for Entity relationship / relations

texts:
I have a content type called Blog. I want the end users to be able to add new relations between the blogs, so that we can build a network of related blogs. But the challenges I am facing are

Users should be able to add the relations without having the access to edit blogs.
The relations(references) added by the users should be monitored. I need to have a workflow around it. Eg : If more than 2 users with the role moderator upvote this relations/reference then it should become public.

I have searched quite a bit for workflow and entity relationship but nothing worthwhile seems to come up. Currently the only option seems to be a combination of relations and workflow module. I haven't used in relations in any projects earlier and would try to avoid it if possible.

Any suggestions or inputs are greatly appreciated. TIA


texts: Cannot modify header information following page not found error

texts:
I see a lot of these in my dblog;

  Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/includes/bootstrap.inc:1368) in drupal_send_headers() (line 1220 of /var/www/html/includes/bootstrap.inc).

or

  Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/includes/common.inc:2700) in drupal_send_headers() (line 1220 of /var/www/html/includes/bootstrap.inc).

and

  Warning: ini_set(): Cannot change zlib.output_compression - headers already sent in drupal_serve_page_from_cache() (line 1357 of /var/www/html/includes/bootstrap.inc).

This happens after a page not found error of a comment that had been deleted.
Even though this does not generate any problem, having them filling up my dblog annoys me. Any help will be appreciated.

Thank you

Edit: Fixed it temporarily by adding a redirect.


texts: Changing a plain text field to enable rich editing

texts:
In Drupal 8, I set up a plain text field and now I have no way to change it back to rich text editing.
I could take the approach of just setting up a new field and copy the field data from the old one to the new one manually, but I have hundreds of records. What are some other solutions?


texts: Delayed error messages for webform blocks in template

texts:
I am printing a webform block in my node.tpl.php:

  <?php
      $block = module_invoke('webform', 'block_view', 'client-block-72');
      print render($block['content']);
  ?>

And when I submit the webform with nothing, no error messages are shown. They are shown on the next reload.

If insert the block in admin -> structure -> block, it works fine.

Is there any way to make it work with inserted block in template file?


texts:
I get a problem with my dropdown that shows "--select--","0","foods","meals" when I developing custom form with Drupal 7. The purpose of my dropdown is used to show "foods" and "meals" from category table. How does this "0" come from? I am hoping anyone suggestion to fix it.

function subcategory_form($form, &$form_state= NULL, $my_object= '', $subcategoryId, $name, $categoryId) {

     $category = db_select('category', 'cat')
    ->fields('cat')
    ->execute();

    $rows[] = array();
    while($data = $category->fetchAssoc())
    {
        $rows[$data['id']] = t($data['name']);
        dpm($rows);
    }

    $form['category_name'] = array(
    '#type' => 'select',
    '#title' => t('Category'),
    '#options' => $rows,
    '#default_value' =>t($categoryId),
    '#description' => t("Please select category."),
    '#required' => 'true'
  );

  return $form;
}


texts: How to send message using Organic Groups Invite?

texts:
I am trying to use the Organic Groups Invite module along with the Rules and Message modules to send a message to users containing an option to accept or decline an invitation to a group.

I have set up rules to send a message to the user when they are invited. This all works perfectly, however the message does not contain the accept / decline options that I assume come with the Organic Groups Invite Module.

I am new to Drupal, and since this module has no documentation, I wonder if anyone could help me out with adding the accept / decline option to the message.


texts:
I would like to display a block only on the [root]/dashboard page, and I would like to do this from my custom module defining the block, not from the Drupal admin interface. How can I do this? Thanks you!

Also, where would this condition be better to be written? In hook_block_view() within the module or in the block template file?


texts:
I am using a view page with some attachments.
For each attachment, I need to display the title : it's right in the preview, I can see the attachment's title, but not in the rendered page.
How can I fix this please?

zorglub


texts:
I would like to pass data from Javascript to PHP using Drupal 7.14.  To this end, I'm trying to follow this SO post: https://stackoverflow.com/questions/4834132/how-to-pass-jquery-variable-to-drupal-ajax.

However, |hook_menu()` is not working as expected.

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

  $items['example_callback/%'] = array(
    'title' => 'My Custom Callback',
    'description' => 'Description',
    'page callback' => 'my_custom_php_function',
    'page arguments' => array(1), // fill this
    // 'access arguments' => array('access content'),
    'access callback' => true,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

/**
 * Function that gets called from JQuery asynchronously.
 */
function my_custom_php_function($argument) {
  // Do something with $argument...
  echo $argument;
}

In my understanding, going to http://mywebsite.com/example_callback should call my_custom_php_function.  Instead, I get:

  The requested URL /example_callback was not found on this server.

Are there other steps necessary to write a simple menu callback?


texts:
How can I achieve the discount by time on not by date functionality.
I have to provide discount on 8 March from 8AM to 8PM.


texts: How to override template for view mode of a entity within a module?

texts:
I see in theme suggestion array that I can override template for my custom entity type based on view mode like this:

  custom_entity__custom_entity__view_mode_name

Now I want to put

  custom-entity--custom-entity--view-mode-name.tpl.php

inside custom module.

I'm trying something like:

function custom_module_theme_registry_alter(&$theme_registry) {

  if (isset($theme_registry['entity'])) {

    $entity = &$theme_registry['entity'];

    if (!isset($entity['theme paths'])) {
      $entity['theme paths'] = array();
    }

    $entity['theme paths'][] = drupal_get_path('module', 'custom_module') . '/templates';

    if (isset($entity['theme path'])) {
      $entity['theme paths'][] = $entity['theme path'];
      unset($entity['theme path']);
   }
  }
}

So my template file is in custom_module/templates directory.

But after clearing cache always entity.tpl.php is used for all view modes.


texts: How can I get the file field uploaded file path of a node?

texts: I am using the tpl file to creat a node page to contain the video player, JW player. I have created 2 content types,in one of it , I build a file field to upload the video, another file field to upload the srt file. How can I get the path of these file fields and use it as  dynamic url in the JW player?


texts: "Load a list of entity objects from a VBO View" rules action not working

texts:
I am trying to use the Rules action called "Load a list of entity objects from a VBO View." I had it working before, but I've since refreshed my DB from prod and I can't remember what my views looked like. I stripped the setup down to its most basic, vanilla configuration and I still can't get it to work.

Here's what I've done:

I created a view of Users. No page; no blocks; just a master display of users with no filter. Two fields: the user's name and the Bulk Operations checkbox (no actions; everything default).

I then created a rule. The event is just "view content" so I can iterate quickly. For the action, I selected "Load a list of entity objects from a VBO View." When I view a node (which triggers the rule), an error message pops up in the log that says, "Unable to get a data value. Error: Invalid data value given. Be sure it matches the required data type and format."

The reason is that the function views_bulk_operations_action_load_list() is trying to make an entity_metadata_wrapper out of FALSE. The exact line is views_bulk_operations.rules.inc:176:

$entities[] = entity_metadata_wrapper($entity_type, $vbo->get_value($result)); // $entity_type == 'user'

$vbo->get_value($result) ends up FALSE because $vbo->entities is NULL. Where are the entities? Did I miss something obvious when I set up my view?


texts:
I have a purchased theme that I've cloned, to which Bootstrap is set as the base theme.
I've done the standard rebranding procedure of renaming all of the files and functions to match the new theme name [theme2].
It's mostly working, except that /themes/bootstrap/css/overrides.css is loading in theme2, and its causing a few issues.
It doesn't load in the original theme1, and everything is fine.

It doesn't seem to matter if CDN is on or off.

What invokes Bootstrap overrides.css?

Any thoughts?


texts:
I want to use the computed field in my drupal 8 website to calculate the charges for a parking system where I calculate the charge for a vehicle by taking the date of collection minus the date of parking, multiplying by the charge per day. total-charges=(collection-paking)*charge-per-day. However, even before I do the calculation, I tested to see if the computed field is working by assigning the $value='hello' and the assign the $disply_output=$value but its not being displayed in the content of the node together with other fields. Other things done to try to resolve this issue

Change the data type from varchar to text to int and others
Change the settings in the 'manage display' option of the content type. From toggling sanitize on an off, change display of the computed field from above to inline, etc
Resave the node by clicking edit and then saving the node, and even creating a new node of that content type after adding the content field.

Still not working.

After googling, most common solution, which works for drupal 7 guys is to uncheck the option to save the field in the database. But I dont see that option in drupal 8 so that I can uncheck it. Because I do not want to store the value in the database since It changes everyday a vehicle is not collected, so all I want is to calculate the value on the fly and charge the vehicle owner when collecting the vehicle.
How do I make the computed field even display a simple 'Hello World'?


texts: Views: Display only first value from content field in a staff directory

texts:
I'm creating a staff directory for my library in Views. In one of the display field, Departments, staff often are assigned more than one departmental affiliation when I create their Content Profile. In this tabular view I'm creating, how can I make it so only the first value of the field representing departmental affiliation is displayed? It really clutters things up to display two or more departments in this table. I'd be happy to export the view & post it if that will help solve my problem.

Thanks,

Jason


texts: How to display number of posts in author pane?

texts:
I have installed Advanced Forum and Author Pane modules.

Now I want to show user's post count instead of 'Last seen':

  Last seen: 2 weeks 6 hours ago

I could not see any guide in the docs so appreciate your help.


texts: How can I install modules using the FTP method?

texts: I got a error when trying to install modules. What should I set up for the FTP? I just learned Drupal. Who knows what happen? I am using Drupal 7.7.


texts:
I've read many discussions about image preview in fapi with 'managed_file', but I can't find a conclusive answer on how to do this properly in D8.

An obvious solution would be to reuse Drupal\image\Plugin\Field\FieldWidget\ImageWidget, but I don't know how to accomplish this.

So my question is: how can I have an image upload field with image preview in my form in D8 and what would the associative array in my buildForm function look like?


texts: Using ENTER key to submit default Drupal 7 Search doesn't not return results: Why?

texts:
I have a design provided by the customer, where the search block form has no SUBMIT button. It is expected the user just hits the "enter" key.

Users can type keywords into the search box, and when they press "enter," the form is submitted. The problem is that the form is submitted always with "#default_value" and never with the keywords typed into the input box.

On the advanced search page/results the search does work.

Does anyone know why this might be?

We have hidden the submit button via a CSS call of display: none.


texts:
Using Drupal 7.

I'm trying to toggle required field based on the click of a radio button.

I already tried the proposed solution in this post but it did not work.

Here is my code:

        $(context).find('.field-name-field-stop-displaying-after').hide();
        $(context).find('.field-name-field-stop-displaying-after').removeClass('required');
        $(context).find("input[name='field_status[und]']").click(function() {
          var radioSelect = $(this).val();
          if (radioSelect == 0) {
            $(context).find('.field-name-field-stop-displaying-after').hide();
            $(context).find('.field-name-field-stop-displaying-after').removeClass('required');
          } else {
            $(context).find('.field-name-field-stop-displaying-after').show();
            $(context).find('.field-name-field-stop-displaying-after').addClass('required');
          }
        });

Note that the hide/show toggle works properly.

For the required class, I am targeting the element that the system targets when I set it as required in configuration. The required class is toggled on the element, but does not actually toggle the requirement. In other words, if the field is hidden, it should not be required, but it remains required. The only difference I can see with the system setting is that it adds a legend element that describes the field as required.

What am I missing here? How can I toggle the requirement of the field?


texts:
I am planning a Drupal 7 site for video sharing, where registered users can share videos.

Main Site: example.com
Subdomain for blog for registered users would be: blog.example.com.

The database would be different for main site and subdomain. Since the target of main site would be very high traffic, what would be the efficient choice ? either Multisite or Multiple Drupal installation (one installation for Main and another installation for blog) ?

what would you advice and why ? (I mean from personal experience, difficulty to handle and maintain, performance issues, etc)


texts: Proper way to redeclare function in own module

texts: Using module isotope for drupal 7, I would like to redeclare/overwrite the function theme_isotope_filter(array $vars) which is in file isotope.module. But what is the proper name to overwrite it? My custom modules name is my_module, so I tried to overwrite it ineptly by naming it my_module_theme_isotope_filter(array $vars) or theme_my_module_filter(array $vars). I also tried to implement it as mythemename_isotope_filter(array $vars) in template.php. But nothing worked. Do I have to overwrite the function in my custom module or in template.php? And what is the proper name to do so?


texts: Show product commerce by taxonomy parent with childs

texts:
I want to show several products filtered by apples. Apple is a hierarchy taxonomy and not always the values from the parents are in the childs.

Example:
apple (apple can have other results that are not in big_apple nor small_aplle)
-big_apple
-small_apple

Question: How can I create a view that when it's 'fruit/apple' shows apple + big_apple + small_apple and whent  it's 'fruit/big_apple' it will only be 'big_apple' ?

I think with this in contextual filters can help but it's far from working:

$id= taxonomy_get_term_by_name($argument);
$children = array_keys(taxonomy_get_children($id));
if(!empty($children))
{
    $handler->argument .= '+' . implode('+', $children);
    return TRUE;
}else
    return FALSE;


texts: Best way to redirect a page after javascript tracking code has executed

texts:
I'm looking for the best way (and also simplest if different) to accomplish this in Drupal 7.

Users arriving at example.com/special-redirect should be redirected quickly to example.com/newpage
Nothing needs to be rendered, but before they are redirected to the new URL on our site, I need to make sure our JS tracking script is executed.
the tracking script is currently loaded into the header from the theme.info file, and needs to run on every page of the site.

I assume that the URL redirect module won't accomplish this (ie. never loads the page).

I'm thinking I have to rely on the javascript method of putting this somewhere:

   <script type="text/javascript">
        window.location = "http://www.yoururl.com";
   </script>

But I'm not sure where I should put this (or a modified one) on the site.
It's just for the one page, but would putting it in the html.tpl.php file with and if statement for the NodeID work?  I'm also open to moving the tracking script if it makes sense to.

thanks for any advice


texts:
I have been trying to install the search_api_solr module.  I installed tomcat and Solr according to the instructions on the module's project site and the INSTALL instruction in the module.  However, I am stuck.

According to the INSTALL.txt instructions:

  NOTE: The Solr 4.3+ example application is currently not completely
  supported with the configuration files included in this module, due to
  a slight change in the directory structure. To fix this, simply copy, move
  or symlink the contrib/ directory from the top level of the extracted
  Solr package one level down to example/.

  (For other directory structures: the contrib/ directory has to be in the directory two levels up from the one which includes the conf/
  directory. For help, just start the Solr server and check the log
  files for WARN messages – they should state in which place Solr
  expects the directory to be.)

I checked an sure enough Solr is reporting the following warnings:

  00:15:45  WARN    SolrResourceLoader  Can't find (or read) directory to
  add to classloader: ../../../contrib/extraction/lib (resolved as:
  /usr/local/tomcat/solr/drupal/../../../contrib/extraction/lib).

  00:15:45  WARN    SolrResourceLoader  Can't find (or read) directory to
  add to classloader: ../../../contrib/clustering/lib/ (resolved as:
  /usr/local/tomcat/solr/drupal/../../../contrib/clustering/lib).

The question is how to resolve this? I am using SolrL ver 4.6.1


texts: Why does aggregator report "There is new syndicated content" but still 0 items for this feed?

texts:
We've had a working feed aggregator running for quite some time now (over 12 months) from a YouTube feed link (http://gdata.youtube.com/feeds/base/users/[username]/uploads). We just recently noticed that there are no items displaying in this feed's block. Upon visiting the feed configuration page (admin/config/services/aggregator/edit/feed/[feed-id]), I can see that there are 0 items in the feed. Running the feed manually reports "There is new syndicated content from YouTube.", but there are no items created. The dblog shows an entry from the feed aggregator with the same message, but no error messages.

Has anyone experienced this or have any ideas on where to troubleshoot? Without any actual errors I'm unsure if this is a bug, works-as-designed, or potentially something wrong with YouTube's feed. I've validated the feed on a couple of websites and there are no (apparent) issues with it.


texts:
I have a section in my theme where I'd like to manually include a search input.  I do not want to use the search block as I have some additional customizations I'm integrating outside of the scope of this question.

It looks like the default search form posts to the existing page and redirects to the results page (/search/node/query).  How can I manually trigger this to happen?

I've tried to mimic the form_id but it doesn't seem to pick it up:

<form method="post" action="">
    Search:
    <input type="text" name="search_block_form" ng-model="query" />
    <input type="submit" value="Search" />

    <input type="hidden" name="form_token" value="">
    <input type="hidden" name="form_id" value="search_block_form">
</form>

There is an additional field in the default block called form_build_id but it
changes each time the form is rendered.

How can I accomplish manually creating a POST to go to search results?


texts: How does apache solr search recognize my changes by mysql query in my database

texts:
I would like to use mysql query to modify some of my data. But I found that apache solr doesn't index all my changes.

For example, I modified some products' category in the field_data_field_category table through query yesterday. When I went to those products' content edit page, the category shows correctly. However, I found that Apache Solr doesn't count any of them into Remaining Item.

Does anyone know how does apache solr search work? Or what kind of query I should use to achieve my goal.


texts: How to restrict one exposed filter per content area?

texts:
On my Drupal 8 site a have a /search view page that contains two exposed filters. I would like to expose them in different areas, for example to use search bar in the navigation, and filter by content type in the "content" block. But if I pick in 'advanced' tab 'Exposed form in block' "Yes", then both my filters appear in the navigation bar.

How can I split my exposed filters into different areas?


texts: How to create a view which would list related content for current article?

texts:
I try to create a view which would list related content (some articles) to a content type article.

Here is what i’ve done. I’ve created a field "Entity reference"  in the content types "Article". It works. I can see in database the related article ID .

Then, I create a view with a block. It works, i can see all articles listed in that view (which is visible on each article).

Here is my issue. I need to display only articles related to the current article. So, in contextual filter, i have tried with
Content: ID and also tried with advanced/Relationships but without success. I don’t see my related articles.

How can I do ?

I’ve also tried a different way (create a twig) and even if it works, it is not the best solution i think


texts: Can a content entity type have a bundle which is a configuration entity type as with the contact form?

texts:
What is bundle_entity_type for @ContentEntityType when id = contact_message and where contact_message is @ConfigEntityType?
Can a configuration entity Type be a bundle of a content entity type?

core/modules/contact/src/Entity/Message.php

/**
 * Defines the contact message entity.
 *
 * @ContentEntityType(
 *   id = "contact_message",
 *   label = @Translation("Contact message"),
 *   label_collection = @Translation("Contact messages"),
 *   label_singular = @Translation("contact message"),
 *   label_plural = @Translation("contact messages"),
 *   label_count = @PluralTranslation(
 *     singular = "@count contact message",
 *     plural = "@count contact messages",
 *   ),
 *   bundle_label = @Translation("Contact form"),
 *   handlers = {
 *     "access" = "Drupal\contact\ContactMessageAccessControlHandler",
 *     "storage" = "Drupal\Core\Entity\ContentEntityNullStorage",
 *     "view_builder" = "Drupal\contact\MessageViewBuilder",
 *     "form" = {
 *       "default" = "Drupal\contact\MessageForm"
 *     }
 *   },
 *   admin_permission = "administer contact forms",
 *   entity_keys = {
 *     "bundle" = "contact_form",
 *     "uuid" = "uuid",
 *     "langcode" = "langcode"
 *   },
 *   bundle_entity_type = "contact_form",
 *   field_ui_base_route = "entity.contact_form.edit_form",
 * )
 */
class Message extends ContentEntityBase implements MessageInterface {

core/modules/contact/src/Entity/ContactForm.php
which says bundle_of ==> contact_message

/**
 * Defines the contact form entity.
 *
 * @ConfigEntityType(
 *   id = "contact_form",
 *   label = @Translation("Contact form"),
 *   label_collection = @Translation("Contact forms"),
 *   label_singular = @Translation("contact form"),
 *   label_plural = @Translation("contact forms"),
 *   label_count = @PluralTranslation(
 *     singular = "@count contact form",
 *     plural = "@count contact forms",
 *   ),
 *   handlers = {
 *     "access" = "Drupal\contact\ContactFormAccessControlHandler",
 *     "list_builder" = "Drupal\contact\ContactFormListBuilder",
 *     "form" = {
 *       "add" = "Drupal\contact\ContactFormEditForm",
 *       "edit" = "Drupal\contact\ContactFormEditForm",
 *       "delete" = "Drupal\Core\Entity\EntityDeleteForm"
 *     }
 *   },
 *   config_prefix = "form",
 *   admin_permission = "administer contact forms",
 *   bundle_of = "contact_message",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label"
 *   },
 *   links = {
 *     "delete-form" = "/admin/structure/contact/manage/{contact_form}/delete",
 *     "edit-form" = "/admin/structure/contact/manage/{contact_form}",
 *     "collection" = "/admin/structure/contact",
 *     "canonical" = "/contact/{contact_form}",
 *   },
 *   config_export = {
 *     "id",
 *     "label",
 *     "recipients",
 *     "reply",
 *     "weight",
 *     "message",
 *     "redirect",
 *   }
 * )
 */
class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface {


texts: Complex where condition with entity field query (D8)

texts:
Is there a method similar to the D7 dynamic query where method to allow us to use arbitrary snippets of SQL to restrict the result set?

Take the following MYSQL query as an example:

SELECT id, publish_date
FROM teaching_period
WHERE publish_date IS NULL OR UNIX_TIMESTAMP(STR_TO_DATE(CONCAT(publish_date, ' 23:59:59'), '%Y-%m-%d %H:%i:%s')) > UNIX_TIMESTAMP(CURRENT_TIMESTAMP)
ORDER BY created DESC
LIMIT 0, 1

How can I create the where statement in this query using the D8 entity query API? Is it even possible?


texts: How to stop by Webform from sending duplicate emails?

texts:
So I have a webform in Drupal 7 that is set up like this:

And I made it so that each of those checkboxes can share the same email key.  But when I submit my form, it will send duplicate emails to that address depending on how many boxes I checked.  How can I make it so that when I check multiple boxes, it will send only one email to that address they share?


texts: Getting access denied when altering user view route

texts:
I want to display custom content for the user profile page instead of the entity view so I am altering the entity.user.canonical route and I am setting a custom controller and title compared to the entity view and page callback that is set by the UserRouteProvider. I am leaving the requirements athey are since I don't need to change anything regarding the permissions.

Strangely though I am still getting Access denied after I flush the cache. The code that I am using in my event subscriber that is run on the RoutingEvents::ALTER event is:

  $collection = $event->getRouteCollection();
    $route = $collection->get('entity.user.canonical');
    $route->setDefaults(array(
      '_controller' => '\Drupal\mymodule\Controller\UserController::profilePage',
      '_title' => 'Profile'
    ));

If I will use setDefault('_controller'...) instead of setDefaults() method it will work since I think the _controller has more priority over _entity_view but the _title does not have priority over _title_callback. So this is not a viable solution.

Any idea what the issue with that access might be? Does the _entity_access requirement require the _entity_view to be used instead of the controller? Should the presence of the entity in the url be sufficient?


texts: How do I fix the errors I get after removing the comment field from a content type?

texts:
After I removed the comment field from the user interface, and uninstalled the Comments module, I can't open any Article node.

In the Drupal log, I find this message.

  InvalidArgumentException: Field comment is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
  Drupal\Core\Entity\ContentEntityBase->get("comment") (Line: 17)
  gavias_sanbro_preprocess_node(Array, "node", Array) (Line: 287)
  Drupal\Core\Theme\ThemeManager->render("node", Array) (Line: 437)
  Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
  Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
  Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent{closure}() (Line: 582)
  Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
  Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object,
  Object) (Line: 117)
  Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
  Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, "kernel.view", Object)
  call_user_func(Array, Object, "kernel.view", Object) (Line: 111)
  Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch("kernel.view", Object) (Line: 156)
  Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
  Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
  Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
  Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
  Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
  Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
  Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
  Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
  Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
  Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

How can I fix this issue?


texts: Create a rule based on specific URL being visited

texts:
I have set up a rule on my website so that when a content writer creates an article, it sends me an email notification and also the body content of the node so I can review it. Only after I have reviewed it and changed a field on the node to mark it as reviewed will it be published.
I often get the email on my smartphone and want a quick way to email back the site so automatically publish the article. Does anyone know what rule would do this for me?


texts: Conditional Field on Multiple Selects Module

texts:
I have 1 Multiple Select field and 2 Select List fields:

I need to show those 2 Select field only when Multiple Select has a value of 1 (the first value of the list is selected). I made the dependency and the 2 Select lists are hidden, but when I select the first value of the Multiple Select field, the 2 fields are not appearing, nothing happens.

Is there something that I'm doing wrong? Any opinions why is this not working?


texts: Alternative to Simplenews, or a way to send formatted mailing lists to subscribers?

texts:
I have installed simplenews on Drupal 7 but it seems all the related modules: Simplenews Content Selection (to build up the newsletter using nodes or views) and Simplenews Template are outdated (Drupal6).

Is there another way to use the nodes in the sites or at least creating a template to reuse with this module?

Or is there a way using other mailing list modules or custom code to build up newsletters from nodes?

br. onirio


texts: Change drupal theme based on panels layout

texts:
I'm using panels and ctools page manager on Drupal 7 in order to create landing pages. I want to force the use of a specific theme for pages defined with a certain panels layout.

I can use hook_ctools_render_alter to get layout name - $context['handler']->conf['temp_layout']. But I can't figure out how to change the theme in this hook. You can use hook_custom_theme to change theme but there you haven't $context object.


texts:
What is $form_state typically used for in the context of the Form API if it is used as an argument?

Specifically, I'm looking for an example of when it is used.


texts: Allow user to enter unpublished content from the site in Drupal 7

texts:
I have a content type "User Bio" in my Drupal 7 site. On my site I created a form with all the fields in User Bio for the anonymous user to fill.

Now when the user enters and submits this information I want the node of "User Bio" type to be created but it should be unpublished. When the admin reviews, only then it can be published.

Is there a way to do it?

Thanks


texts: How to change taxonomy term path for table and grid view

texts:
I am using taxonomy term module. I have categories vocabulary and in term so many categories and I have created the view using taxonomy term.

With two page first is in table format and another is grid format and in both view page header I place the two icon one is list icon and another is matrix icon.

My issue are that when I click on list icon the page redirect to table view and path are show taxonomy/term/% but I want show the path in this format [vocabulary name]/[term name]/[tid]/list


texts: Is there a module that allow to access a page using a specific URL?

texts:
I remember seeing this module a while ago, but can't for the life of me finding it. What it did was to only allow a page to be accessible by a specific link you set for it. So, if you just entered the URL into your browser, you would be redirected to, say, your home page.

Does anyone recall this module?


texts: Unknown option `--tail` when running `drush ws --tail`

texts:
I am using Drush version 9.0-dev-dev.

When I run drush ws --tail, I get the following error:

[error]  Unknown option: --tail.  See `drush help watchdog-show` for available options. To suppress this error, add the option --strict=0.

I've used this with all other versions of drush with no issues.


texts:
I need to create dynamic page using Views.
I created many of static page using views, for this simply define page link in view, but when I create Dynamic page like 'practice-areas/%' then it is not working. Here % is using for node id.


texts: Displaying article image on full display conditionally

texts:
I would like to enable/disable visibility of article image on full display for some articles while keeping article image always visible on teaser display. Is there a way to achieve that apart from dealing with views?

Thanks.


texts: How do I show the "Your Cart" link in my Rules message

texts:
I have a created a rule in drupal commerce.  I want to include a link to the users cart in that message, just like the link that appears when you add a product to the cart.  When I use the url token, the message displays like this: This item has been removed from http://dcomm/user/3/orders/6.

I want it to be --This item has been removed from your cart. and you click on the "your cart" and be taken to your cart view.

How do I do this?


texts: Drupal's aggregator module doesnt fetch all items in feed

texts: I implemented the module to fetch data as XML from an API but the module fetches only 7 elements from the page while it contains 12. Any idea on why it does that ?


texts: Feeds module import csv: problem with mapping

texts:
I've been trying to import data from a .csv file into my content type but
have found some trouble mapping the headers of the csv file to fields.

How do you map a field to a header (since I'm not seeing that
as an option in Feed)? I've tried using the new Source option and putting the name of the header but had some errors importing.

I'm planning to use the Feeds module and stay away from code since a
site admin will be importing subsequent files and is not very familiar with drush.

I used to use the Feeds Import Preview module on D7 but have not been
able to find something similar for D8.


texts: What privileges should a MySQL user have?

texts:
When I am creating a user for my Drupal in cPanel, it asks me to check all privileges. What privileges should be enabled, to make Drupal work correctly?

Currently, my user has all privileges except Drop permission.


texts: How to disable shipping for ONLY virtual products and not if combined with physical

texts:
In Drupal Commerce, I'm trying to come up with a rule the bypasses shipping if
virtual product types are put into the cart, but ONLY if all products are virtual; if physical products are put in, then the rule wouldn't fire because these products need to be shipped.

Below, for reference, is a solution for virtual products; it's close but it won't suffice if combined with both physical and virtual products.

Install Commerce Rules Extra

Create a rule for Event: Process checkout pane
Add Action: Change pane properties
Value: Shipping information
Page to move to: <do not change>
Enabled: uncheck
Add Condition: e.g. by Order contains products of particular product types, or based on Commerce order contains shippable products supplied by Commerce Physical Product.
You may have to clear caches before this takes effect.


texts: How to create an Entity reference with taxonomy term selection?

texts:
I'd like to make an entity reference autocomplete field where I can only select the options which have a certain taxonomy term attached to it.

Example:
I have a sports player who belongs to a certain team. The player is part of content type 'person' with taxonomy term 'player'. Other taxonomy terms which can be applied to this content type are 'referee' and 'trainer'.

I also have content type 'team' where I want to be able to select players for this team. I have used an entity reference field for this which refers to content type 'Person'. But now I can select all persons, so also referees and trainers.

What I did now was create a View with content type=person, term=player and saved this as an entity reference display. I can now select 'Views: filter by an entity reference view' in the reference field in Teams. This all works fine.

The problem however is, I'd like to quickly add a new player if the player isn't in the database yet. I installed the References Dialog module, which adds buttons to an entity reference field to add or edit nodes you're referring to. This module only works when you select the Simple entity reference and not the Views entity reference.

Any solution for my problem?


texts:
I have described the form, but every element there is located under the previous one. I need to describe the form where all elements will be placed horizontally but not vertically.
This is my form:

function contact_register_form($form, &$form_state) {
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('Sign up to be notified when your community launches:'),
  );

  $form['email'] = array(
    '#type' => 'textfield',
    '#title' => t('Email'),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Add me',
  );

  return $form;
}


texts: Using Views "Rewrite the output of this field" tokens

texts:
I have a field which allows a user to upload 3 photos called field_prodshots. To any Views experts out there, is it possible to display just the first value of that field instead of all 3 while using "Rewrite the output of this field" tokens? After all, I only need the one image to use as a thumbnail.

Typing in [field_prodshots] in the textarea for rewriting the output results in the display of all 3 images. I only need the first one.


texts: Elegant way to retrieve nodes by content type?

texts:
Of course I can do something like:

$results = db_query("SELECT * FROM {node} WHERE type = '%s'", $content_type);

while ($node = db_fetch_object($results)) {
    // ...
}

But is there a more elegant way maybe?


texts: How to post correctly fields in views-view-fields.tpl.php?

texts:
I'm using Drupal 7, and Views 3.

I would like to reproduce my comment template in views-view-fields.tpl.php.

Thus I need to print my fields to be able to arrange them as I wish it.

For each field, I proceed like that : <?php print $view->render_field('field_name', $id);?>, is it the correct/secure way ?

I don't think so, because all the row does not display.


texts:
how can i avoid fatal error due to ?

 |GuzzleHttp\Exception\ConnectException: cURL error 6: Could not resolve host|

My code here do not catch it

try {
      $client = new Client();
      $response = $client->request('GET', $url);
      $content = json_decode($response->getBody(), true);
    }
    catch (Exception $e) {
      \Drupal::logger('amu_hal')->error('this url aint good'.$url);
    }


texts: I want to show some fields of a database table with Views. There is no node type, fields, or something like that for this database table. How can I do that?


texts: Symbols for certain locales missing in multilingual sites when using the number formatter moule to format integers to ordinal numbers

texts:
I was looking for a module that converts integers entered in a field into ordinal numbers, For eg 22 to 22nd and 33 to 33rd.
I ran into the https://www.drupal.org/project/number_formatter and it works
The module works really well for English (en) converting 1 to 1st, 2 to 2nd, and so on.
However, for other languages like Arabic with locale 'ar' it is not converting accurately. The symbol seems to be missing and instead, we get a '.'. The same happens for ru as well. "
I debugged the module and I found that it was using the core PHP class NumberFormatter.
use NumberFormatter as IntlNumberFormatter;

$language = $this->languageManager->getCurrentLanguage()->getId();
$numberFormatter = new IntlNumberFormatter($language, $this->settings['style']);

Dumping the $numberFormatter led me to the following output.
^ NumberFormatter {#2773 ▼
  locale: "ar"
  pattern: """
    %digits-ordinal:

    0: =#,##0=.;

    -x: −>%digits-ordinal>;

    """
  attributes: {▶}
  text_attributes: {▶}
  symbols: {▶}
  error_code: 16
  error_message: "Error getting symbol value: U_UNSUPPORTED_ERROR"
}

I tested this code separately and found that the problem exists outside the module and is likely a core PHP bug. Is there something additional we need to do get this fixed?


texts: Is it possible to dynamically select between two different template files for the same content type?

texts:
We are rolling out changes on a content type with a new theme and field structures for existing content.
Is it possible to dynamically select one of two template files for a content type?
For example, if a field on the content type is checked then use node--product.html.twig but otherwise use node--product-old.html.twig.


texts: Using hook_menu() and hook_permission() to control access

texts:
How does one limit "what" can access a page. I understand how to use hook_permission() to set user permission based on a role to control access to hook_menu() items. However, what if I have a hook_menu() item that is to be used solely by the system itself? For example, say I have a registration page in a custom module: module/register - Anyone can access that page. Then, say I have an ajax call that is to be made when the user performs some action on the page. So, I register another item in hook_menu(), call it module/register/ajax - I do not want anyone to be able to browse to module/register/ajax but I want to be able to do an ajax call to that page. What is the best way to accomplish this?

I have used AJAX callbacks but this is not a case where a form is being submitted. This is just a pure AJAX call from JavaScript on an event after the page loads.


texts: Views Criteria Filter - Changes Affect Master Display

texts:
I have a problem with the module Views with the FILTER CRITERIA, When I clone a block inside my view and change the FILTER CRITERIA the change also occurs on the Master Display is it a normal behavior ?

Thanks !


texts: Title field input not appearing when creating content type by module

texts:
I have this problem, I'm creating a content type by creating a module, using the example 'node_example' of examples project as a code template. The thing is that I get it work, I create the content type successfully but when I create a new node of that content type, all fields appear but the title. I'm a little lost. I put by myself the propperty 'has_title' to true on hook_node_info() but it stays the same. Cleared drupal caches several times, removed previous nodes, nothing. Any idea? Thanks.

(Maybe I don't follow all the standards, I'm quite a begginer and I try to follow them as possible) Module name: ct_conversacion. Content type: conversacion.

-------------edit:

Ok, it was tough but I found the solution. The function 'ct_conversacion_form' that I wrote below should be 'conversacion_form' (the content type name preceding).

My code:

  /**
   * Implements hook_node_info().
   */

      function ct_conversacion_node_info() {

        return array(
          'conversacion' => array(
        'name' => t('Conversacion'),
        'base' => 'conversacion',
        'description' => t('Es una conversacion.'),
        'has_title' => TRUE,
        'title_label' => t('Title'),
        'locked' => TRUE,
      ),
    );
  }

  /**
   * Implement hook_form().
   */
  function ct_conversacion_form($node, $form_state) {
    return node_content_form($node, $form_state);
  }

  /**
   * Implements hook_node_type_insert().
   */

  function ct_conversacion_node_type_insert($content_type) {
    if ($content_type->type == 'conversacion') {

      $body_instance = node_add_body_field($content_type, t('Mi descripcion'));

      field_update_instance($body_instance);

      foreach (_conversacion_installed_fields() as $field) {
        field_create_field($field);
      }

      foreach (_conversacion_installed_instances() as $instance) {
        $instance['entity_type'] = 'node';
        $instance['bundle'] = 'conversacion';
        field_create_instance($instance);
      }
    }
  }

  /**
   * Define the fields for our content type.
   *
   */
  function _conversacion_installed_fields() { // Cambiar *****
    return array(
      'conversacion_field2' => array(
        'field_name' => 'conversacion_field2',
        'cardinality' => 3,
        'type'        => 'text',
        'settings'    => array(
          'max_length' => 60,
        ),
      ),
    );
  }

  /**
   * Define the field instances for our content type.
   */

  function _conversacion_installed_instances() {
    return array(
      'conversacion_field2' => array(
        'field_name' => 'conversacion_field2',
        'label'       => t('Field 2 de Conversacion.'),
        'widget'      => array(
          'type'    => 'text_textfield',
        ),
      ),
    );
  }


texts: Custom module 'managed_file' variable info keeps disappearing

texts:
I have a custom module which allows a 'managed_file' upload in the settings/config page. This works fine and displays as expected after uploading (with the filename linked, and a "Remove" submit button) but the value of the field keeps disappearing after some time. What am I missing?

Here's the code from the custom module:

  $form['custom_managed_jpg'] = array(
    '#type' => 'managed_file',
    '#name' => 'custom_managed_jpg',
    '#title' => 'Custom Image (JPG)',
    '#default_value' => variable_get('custom_managed_jpg', ''),
    '#upload_location' => 'public://custom_directory/',
    '#upload_validators' => array(
      'file_validate_extensions' => array('jpg'),
    ),
    '#description' => t('This is a custom image (jpg format).'),
  );

It appears to be a problem with the file_load function. The variable is indeed saved, as I get a file ID when I dpm() the variable_get('custom_managed_jpg') (a number -- the fid). However, when I dpm() the result of file_load($fid) it is empty.

The strangest part is that this works as expected to start with, and the file will even remain between page loads and cache clears, but then after a few hours it just disappears as described above without any warning.

UPDATE:

It seems that the reason file_load doesn't return anything is that the directory (public://custom_directory/) is empty. At some point these files are being deleted from the directory but I have no idea why.

UPDATE2:

When I watch the file_managed table, I can see a new file added after uploading. The one difference between files uploaded here and those already in the table is that the status field is set to 0 instead of 1. I am guessing that could be part of the problem? How/where do I set the status to 1 programmatically?


texts: How to grant access on some functionnalities in system dashboard to a given role

texts:
How can I grant access on system dashboard to a given role.
Let's assume the role is "Webmaster". So when a user with this role logged in, he will land to the admin page as if he belongs to the "admin" role, but with fewer options available.
For example he will not be able to see the "configuration" menu, and so fourth...

Because what I actually have is, when this kind of user logged in, he lands on a user page like other authenticated user (I mean a regular front page).

Thanks for your help


texts: Stop Varnish from caching 302 redirect from POST responses

texts:
drupal_goto() uses a 302 redirect by default, which means a lot of redirects, including form redirects, get served with a 302 response code.

Having a issue in Varnish that is caching 302 response from user submitted forms for anonymous traffic.

It caches the first 302 redirect but then if the customer selects different options on the form it should be redirected to another url.

Not being able to cache product pages on our Drupal commerce site amounts to millions of cache misses a month and excessive performance issues. Drupal based page level caching is not a option as we have over 4,500 stores deployed.

How can this be fixed?


texts: How to show Users and Nodes in a single view?

texts:
Using the Flag module I have created a bookmark flag for User and Node entities. Working so far so good, but I cannot create a view that displays both Node and User entities in one view.

How do I do this without having to dump views and hand-create the page in PHP?


texts:
I have a simple question but after and hour searching I can't find the right answer.

I'm trying to submit a custom form via ajax but I don't know which is the right way to show validation error or where to show them.

My initial code is this:

function contactar_profesor_form($form, &$form_state,$uid) {
  $form['from'] = array(
    '#type' => 'item',
    '#title' => '',
    '#markup' => '
Escríbeme un mensaje
',
  );
  $form['nombre'] = array(
    '#title' => t(''),
    '#type' => 'textfield',
    '#size' => 255,
    '#maxlength' => 255,
    '#attributes' => array('placeholder' => 'Escribe tu nombre',),
  );
  $form['mensaje'] = array(
    '#title' => t(''),
    '#type' => 'textarea',
    '#attributes' => array('placeholder' => 'Deja tu mensaje. Recuerda que puedes indicarle tu número de teléfono o email para que el profesor contacte contigo',),
  );
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Enviar'),
    '#ajax' => array(
      'callback' => 'contactar_profesor_callback',
      'wrapper' => "contacto-wrapper-$uid",
      'method' => 'replace',
    ),
  );
  $form['uid'] = array('#type' => 'value', '#value' => $uid);
  $form['#attributes']['class'][] = 'contactar-profesor-form';
  return $form;
}

function contactar_profesor_callback($form, &$form_state) {
  if (!$form_state['values']['nombre']) {
    // show errors??? how???
  }
  return '

';
}

I have tried with drupal_set_message but it doesn't appear.

Thanks!


texts: complete installation proess for drupal 7.15 and ubercart-7.x-3.0

texts: I install drupal 7.15 and working successfully. After that i add ubercart-7.x-3.0 module. enabled product and store module but cant enable cart and order. how to enable cart and order. I am the beginner of drupal and ubercart. please help me


texts:
I have a webform where users can choose between nodes on my site. I'm using a Select options component on the webform and dynamically load my node titles with the "Load a pre-built option list" and a custom module to create the list.

I need to display the result of the collected webform data as a top list of the most choosen nodes. The list should look something like:

Title of node yy (34 votes)
Title of node xx (15 votes)
...
Title of node zz (0 votes)

I tried using views to display webform submission data and the views aggregation function, but this does not include the nodes that has not gotten any "votes".

Any suggestion of how I could accomplish this would be greatly appreciated!


texts:
.module file

/**
* Implements hook_views_api().
*/
function core_sms_views_api() {
    watchdog("test","<pre>".print_r('imhere',TRUE)."</pre>");
  return array("version" => "3.0");
}

.views.inc

<?php
/**
* Implements hook_views_data().
*/
function core_sms_views_data() {
  $data['core_sms_details']['table']['group'] = t('core_sms_details table');
  $data['core_sms_details']['table']['base'] = array(
    'field' => 'date', // This is the identifier field for the view.
    'title' => t('Core SMS details date'),
    'help' => t('Core_sms_details contains sent and failed sms counts on datewise.'),
    'weight' => -10,
  );

  // sent count field.
  $data['core_sms_details']['sent_count'] = array(
    'title' => t('Sent count'),
    'help' => t('Sent count field.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // failed count field.
  $data['core_sms_details']['failed_count'] = array(
    'title' => t('failed count'),
    'help' => t('failed count field.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  return $data;
}

Thats the code i am using to expose the fields to views but i am not able to see in views add fields. what i am doing wrong.
just to check i put watchdogs in both functions and the watchdogs are geting display.. please help.


texts: Add foreign key to schema using hook_update_N

texts:
I've written a module that establishes a child/parent relation ship between magazine issues and the articles in each issue.  The idea is that by associating articles with magazine issues they can all be automatically published on a given date via cron.  That all works fine.

The problem is I'm trying to use a View to list a subset of those articles and list them according the parent issues date, but that isn't showing up as a relationship.  I assume the problem is that I haven't defined a foreign key in my schema.

Is it possible to add one in hook_update_N or whatever?

To clarify, the relationship is created using fields defined in a custom module using the Field API where the parent node has the date info and the child node has a field for the parent NID.


texts:
User warning: The following module is missing from the file system:
  node_reference. For information about how
  to fix this, see the
  documentation page. in trigger_error() (line 1138 of
  /[localdevetc/drupalrootetc]/docroot/includes/bootstrap.inc). =>

This error usually occurs when module files are removed without a module being disabled and uninstalled first. Typically it's corrected by simply re-downloading the module files and then uninstalling it. The problem is that there doesn't seem to be a module called node_reference for Drupal 7. I tried drush dl node_reference and got:

  No release history was found for the requested project
  (node_reference).
  Could not download requested project(s).

Any ideas?


texts:
I would like to add multiple existing fields to a content type using drush.  Right now I'm using the following to create the fields:

drush field-create [content-type] [field-machine-name],[field-type]

Is there any way to do something like the following instead?

drush field-create [content-type] [field-label],[field-machine-name],[field-type]


texts:
I would like to add extra fields to an existing entity WebformSubmission :

Assigned to (entity reference to a user)
Status ( taxonomy term reference)

for these two fields I will need it to be available in Views.

what is the right method ?


texts:
I would like to generate a forum for each article posted on the website.
Actually what i'm able to do is create the forum before, write the article and match a field with the forum.

Now i would like to hide this field in the creation of the article (correct me if i'm wrong but i think it can be done with a $form['#access'] = false;) and create it on the submit of the article.

I would like to create the forum on the submit and match it with the field while it is invisible to the poster.

Do you know how i could do that ? Thanks by advance.


texts: amazons3-7-x-2.0, Multiple upload to S3, #upload_location wrong URI

texts:
I installed the brand new amazons3-7.x-2.0 published last week, and the process is not straightforward.

I finally managed to have it works, and I have the CCK file field, with a typical remote #upload location URI : s3://[bucketname]/[subdirectory].

On the node form, the first file I upload works fine. It monitored the file_managed_file_save_upload($element) function, which is called with the proper argument (remote URI):  $element['#upload_location']=s3://[bucketname]/[subdirectory] .

But when I click on "add new file" and select another file, the file_managed_file_save_upload function is called with a wrong #upload_location :
$element[#upload_location']= s3://[subdirectory]

The upload then failed with the following message : "The file could not be uploaded.".

In order to get amazons3 module to work with this long awaited new release, I had to patch a lot of files with contributed patches fixing the exact same issue of bucketname in the URI.

Is somebody facing the same problem and found a solution ? I will try the plupload module see if it fixes the issue.


texts: synchronise development website with live website

texts:
I'm developing a business website with Drupal 7 that is currently running on a server at my home so that I can just upload  everything to my VPS when it is all ready. I'm only a solo developer so I don't have the resources to have a production/staging site and different stages etc., but I do anticipate that there will be a time when this might happen and there will definitely be times when I need to do a major update on the website. So is there a way I can make changes to content, themes and modules on my server at home, and then once I'm happy 'synchronize' the changes with the actual website so that I don't have to keep putting the site in maintenance mode for long periods of time.

I can't just simply re-upload the site everytime though because it is an e-commerce site so hopefully orders will be flowing and there would be new user accounts since I pulled the database so that I could work on the website etc.

Hope that makes sense


texts: How do I create RSS feeds for a particular content type?

texts:
I have created a custom content entity type form with 2 form fields:

entity name (textfields)
content type (drop-down list)

When I choose the content type from the entity form, and click on Save, an RSS feed of that selected content type should get generated.

How can I achieve this without using the Views module?

Is there any class that can be extended to generate RSS feeds?


texts: How to take care of .htaccess of all sites in multi-site setup on Linux?

texts:
I've read this article: http://drupal.org/node/290768 which explains multisite settings on Linux.

But I need separate .htaccess for each site. How do I do it?


texts:
First, the problem:
I create a new Basic Page content with simple text and a couple of carriage returns, for example:

this
is
my
content.

I save the content using "Filtered HTML".  When I then try to edit that content (still with "Filtered HTML") the content in the body of the editor has lost all the carriage returns (and formatting if applied) and looks like this:

this is my content.

If I save this content it still looks like the above.

This does not happen with the WYSIWYG module installed but no editor added.  When I add TinyMCE and configure with any buttons, then I get the above problem.  This also happens with CKEditor.

I've tried three new clean installs of test sites (two on my local server and one remote) and I get the same results when I try to configure an editor with WYSIWYG.

The only non-core modules I have installed are chaos tool and WYSIWYG.

Very perplexing.  Can anyone help?


texts: How do I create a container entity that contains variable number of fields

texts: I am interested in creating a content type that contains a variable number of fields. Each field contains an entity reference to another entity, but as I said there may be one field or 4 fields. I'm a little unclear the best way to implement this


texts:
I have programmatically created a block. In my module folder I added all suggested templates in a templates folder(mymodule/templates/suggestedtemplatename.html.twig).

However the block is not using any of them!
I have enabled the theme debugger which gives me all the suggestions and describes which part of the page is produced from which template. I can see only block.html.twig producing html.
I tried drush cr and uninstalling/installing the module


texts:
There must be something obvious I'm missing as it seems from other posts that Exposed Filters in views should generate URLS from its results out of the box.

I've got some filter with ajax enabled and they work fine, but the url doesn't change when using the filter.

How to I achieve this and become able to link to a specific setting on the filter?


texts:
I'm attempting to add a custom token so I can use it in a view block. Looking at examples I've added this code to my custom .theme file

function mytheme_token_info(){
  $types['mytheme_tokens'] = [
    'name' => t('mytheme Tokens'),
    'description' => t('mytheme token type'),
  ];
  $currentnode_token['current_node_title'] = [
    'name' => t('Current Node Title'),
    'description' => t('Title of the current node'),
  ];
  return [
    'types' => $types,
    'tokens' => [
      'mytheme_tokens' => $currentnode_token,
    ],
  ];
}
function mytheme_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata){
  $token_service = \Drupal::token();
  $replacements = array();
  if($type == 'mytheme_tokens') {
    foreach($tokens as $name => $original){
      switch($name){
        case 'current_node_title':
        $node = \Drupal::routeMatch()->getParameter('node');
        $title = (!empty($node)) ? $node->title->value : '';
        $replacements[$original] = $title;
        break;
      }
    }
  }
  return $replacements;
}

But in my view in a custom text block I have a header using that token but it spits out

  [mytheme_tokens:current_node_title] Products

And the token isn't replaced. I know for sure the tokenizer is running though because [site:title] did work.

How do you create custom globally available tokens?


texts: How do I programmatically update the order status?

texts:
After Payment is accepted, I need to update the order status to "Completed" from the page controller.

How do I do this, on Drupal 8?

I find no documentation about this; there is an example for Drupal 7.

// Updating Order status.
$orderObj = commerce_order_load($orderID);
commerce_order_status_update($orderObj, 'canceled', TRUE, 'Order Voided');
$orderObj->log = 'Order cancelled programatically';
commerce_order_save($orderObj);


texts: How to restrict access to view a block for a certain role?

texts:
I have some custom roles such as Premium Membership and I don't want to allow access to this category.

The authenticated role is included to Premium Membership or Moderator users because every registered user has this authenticated role assigned to them by default.

I want to hide a block and display only for authenticated users that do not have other roles assigned to them.

What can I do?


texts: Retain Guzzle Session During Batch Operations

texts:
On a Drupal 7 site, I am using the Batch API to perform operations on many entities, one at a time. During a typical operation, the D7 site uses Guzzle to make a POST call to a Drupal 8 site. The D7 Batch callback looks like this:
function example_operation($foo, &$context) {

  // Login to Drupal 8.
  // ...

  // Make POST call to Drupal 8.
  // ...

  // Logout from Drupal 8.
  // ...

}

The D7 client uses a Guzzle client and cookie jar to authenticate with the D8 server (REST+cookies), with no issues. Great!
Now imagine running this on 100K+ entities, that's an awful lot of logging in and out unnecessarily, wasting a whole bunch of time and resources. So I figure, let's login once on the first operation, retain that session for each operation, then logout when finished. Sounds reasonable.
I thought I'd use D7 Batch API's $context['results'] array to hang onto the cookie jar and D8 rest tokens, that way each operation would have access to them, no problem, or so I thought. Take a look at this attempt in the D7 Batch callbacks:
function example_operation($foo, &$context) {

  $jar = NULL;
  $csrfToken = NULL;

  // Login to Drupal 8 (first time only)
  if (!isset($context['results']['jar'])) {

    // Login to Drupal 8.
    // ...

    // Set aside cookie jar and tokens.
    $context['results']['jar'] = $jar;
    $context['results']['csrf_token'] = $csrfToken;
    $context['results']['logout_token'] = $logoutToken;

  }
  else {

    // We've already logged in, grab the cookie jar and token.
    $jar = $context['results']['jar'];
    $csrfToken = $context['results']['csrf_token'];

  }

  // Make POST call to Drupal 8 (using cookie jar and token).
  // ...

}

function example_finished($success, $results, $operations) {

  // Pull out cookie jar and tokens.
  $jar = $results['jar'];
  $csrfToken = $results['csrf_token'];
  $logoutToken = $results['logout_token'];

  // Logout from Drupal 8 (using cookie jar and tokens)
  // ...

}

This approach works fine on the first operation only. Then on the second operation, the tokens are available in $context['results'] as expected, but the cookie jar always comes through as a __PHP_Incomplete_Class Object, and then if I try using it with the Guzzle client a cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface is thrown.
How do you retain a Guzzle session between batch operations in Drupal 7?

Perhaps $context['results'] cannot contain "complex" class/objects like a Guzzle cookie jar
I tried using the cookies request option when instantiating the Guzzle client, but that breaks any authenticated POST calls (including the first operation)
Maybe the way D7's batch http requests work, it starts confusing the client/cookies/etc


texts:
I'm using the i18n module for translating nodes and menu items.
I have a bunch of menu-items and am now trying to put that into the header with a menublock.

But unfortunately all menu-items in all languages appear instead of just the items in the current language and language-neutral.

Does anyone know how to fix that.

The only solution I have is to create a menu for every language.


texts: Use multiple data blocks in the same chart created using forena reports

texts:
I have created a chart using Forena reports. I need to set the chart title dynamically based on the logged in user's country. At present I have hard coded the title as "Your Country". The data for this chart is coming from a data block (let's say data_block_1). And the logged in user's country can be obtained from a second data block(data_block_2).

How can I show the logged in user's country as the chart tile?

Though I have the second data block I don't know where to put the name or how to call that data block.

I am posting the screenshot of the body tag inside the frx file and also the chart I created thus and also the sql file.


texts: How to programmatically update the allowed values of a list field?

texts:
I have created a select list for a Profile2 account in Drupal 7. In the allowed values list, I have added some values. Now what I would like to do is programmatically update the values in that list (add, delete or update). I don't want to use form_alter as I want these updates committed to the database. My problem is I can't seem to find where these values are stored in the database or how to pull those values from Profile2, update them and then save them.

I have Googled high and low on this particular issue and can't find an answer on how to do this. I hope someone can help me out.

Thanks.


texts: I have a content type "event".I show all my events rejected or validated. Now in my view I want to show fontawesome icon like "cancel" to signal that the event is rejected and another fontawesome icon like "okey" to signal that the event is validate. How to use Global text to make it? I don't like to use page.tpl.php. But if there are a solution base it I can accept it.


texts: I'm trying to retrieve a custom content type onto the user profile page

texts:
I'm using D7.
I have a custom content type that I need to relate to the user. The user will set up and maintain this page themselves.
i.e. Each user has one page of content for this content type.

When a user profile is viewed though I need to show the relevant page that relates to the the user.

What's the best way of doing this in D7?
I'm guessing it's something to do with creating a block view and then using contextual filters. I've managed to get a block view that does this within the preview but I can't get any further than that in terms of linking it to a user profile.

There is the possibility of linking the user name to the content title. In fact if the two were intrinsically linked it would be better. Ideally I would have used the profile 2 module but I'm using location ( doesn't work with users in D7 ) and FiveStar ( doesn't work with users in D7 ).

Any suggestions on where to start looking to solve this would be appreciated.


texts:
I'm using Manual Crop, which is not functional on a mobile phone (you can't drag the resize tool), so I'd like to prevent the init on a mobile device.

Any advice on how to override a module for smaller screen widths?

I could set the mobile user to not have access via Mobile Tools, but I'm not confident that module will work for D7, plus it may be overkill for my needs.

Thoughts? Is this even possible?

Kate H


texts: What is wrong in my XML structure to add nodes using a RESTFul web service POST?

texts:
I'm using RESTFul Web Services module with Drupal 7. I can log in with basic authentication, get CSRF-token, get nodes, and so on.

The problem is with POST/PUT: I cannot get adding nodes to work. I get a node of type "page" and I use the same xml structure to do the post. But it doesn't work.

I'm using Delphi RAD Studio 2010 and Indy components to connect with RESTFul service. It works good with all restful request. When I do a POST, I get a 200 OK result, but the page is NOT added.

Here is the XML structure I use:

<node>
<body>
  <value>This is a simple test page</value>
  <summary/>
  <format>full_html</format>
</body>
<type>page</type>
<title>Test Page</title>
<language>es</language>
<status>1</status>
<promote>0</promote>
<sticky>0</sticky>
<views>0</views>
<day_views>0</day_views></node>

I send csrf-token with post, and server gives me 200 OK.

My question: Where could be the problem, perhaps the XML structure is incorrect?


texts: CKEditor generates  when leaving a textarea field empty

texts:
I'm using CKEditor module with satisfaction, but it behaves really frustrating in one case: when leaving textareas empty, it generates
 tags in them after rendering CKEditor's interface.

This can be a problem for example when using "Summary or trimmed" display, and on the node creation form, the Summary field would be left empty, but in fact it's not empty, because it contains a
 (so teaser will also contain a single
).

I can get round this problem with going to Source view and deleting the
 tag all the time, but it's not a solution (other users will not know how to do it).

Do you have any ideas how to stop this behavior?


texts: Redirect user back to the private page after they have logged in

texts:
On my site I have a private page that can only be accessed when the user is logged in. If they aren't logged in they are directed to the login page.

I want to redirect them back to that page after they've logged in

I've tried a lot of solutions already listed on here including: logindestination and logintoboggan.

Every time the person logs in they are always directed to their user page no matter what I change in logintoboggan/logindestination

I tried creating a rule but was getting a 404. I'm not sure what to put in the PHP Evaluation field in the redirect action.

I've added this to my template file

global $user;
    if ($user->uid == 0){
        print l("Login","user/login",array('query' =>     drupal_get_destination()));
    }
else{
print l("Logout","user/logout",array('query' => drupal_get_destination()));
}

And then in logindestination I added

$destination = drupal_get_destination();
print $destination;

What am I doing wrong??


texts: Why my site is blocked by too many connection errors?

texts:
I've created a simple website with a few pages on my local computer. I have Drupal installed in my XAMPP directory, so the directory looks like this: c:\xampp\htdocs\drupal\<all the drupal files sit here>.

I've signed up for a domain and I'm trying to upload my Drupal site to the web hosting company to go live.

I searched for many sites for step-by-step instructions how to do it. This is what I got and this is what I did:

Backup my drupal database on my computer.
Create a new blank database on the host.
Upload my local files on my computer to the host (I assume I need to upload all the files inside the Drupal directory, is that correct?)
Import my backed up database to the host.
Change the settings.php in the host. Is that the only file and place I need to change?

This is what I changed:

$databases = array (
'default' =>
  array (
    'default' =>
    array (
    'database' => 'yyyyy_xxx',   <== Can I use a different database name than the one I use on my localhost?
    'username' => 'yyyyy_xxx',   <== Can I use a different username than the one I use on my localhost?
    'password' => '12345',       <== Can I use a different password than the one I use on my localhost?
    'host' => '<www.my new site's domain name.com>',    <== Should I be using my new site's domain name here or localhost since all the files are sitting at the web hosting company's server?
    'port' => '',
    'driver' => 'mysql',
    'prefix' => '',
   ),
 ),
);

When refreshed my webpage and I've got the following error:

Error:
The website encountered an unexpected error. Please try again later.
Error message:
PDOException: SQLSTATE[HY000] [1129] Host 'box373.bluehost.com' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in lock_may_be_available() (line 167 of /home3/<my website>/public_html/includes/lock.inc).

I've logged into my account on the hosting company using Putty and went to public_html/ and entered mysqladmin flush-hosts. Now I've got the error:

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'xxx'@'localhost' (using password: NO)'

The xxx is the database name I used on my localhost. The new database name on the host is yyyy_xxx. Is it still referring to my localhost database even though I've changed the settings in settings.php file on the host?

I would appreciate if somebody can help me and give me some insights how to fix this problem.

Is this the correct procedure to upload files to the host for my website to go live?
Besides settings.php file, are there any other files I need to change?
How do I unblock mysqladmin using flush-hosts? Some websites suggest to include username and password to login to mysqladmin. I've entered mysqladmin -uyyyy_xxx -p12345 flush-hosts and I got the following error:

mysqladmin: refresh failed; error: 'Access denied; you need (at least one of) the RELOAD privilege(s) for this operation'

How do I prevent this problem to happen again? I just uploaded a few files to the host and I got this problem. In the future, I am going to upload the complete website to the host with way more files. I would like to find out the correct way to launch a Drupal website.


texts: How can I redirect users upon password reset?

texts:
The solution shown in How can I redirect users upon login sometimes but not break the "Forgot password?" function? work for Drupal 7.

In Drupal 6, with the User:user has logged in event and the following PHP conditions, nothing happens.

if (arg(0) == 'user' && arg(1) == 'reset') {
  return false;
} else {
  return true;
}

How can I redirect users upon password reset in Drupal 6?

PS. The only variable for this event is $account for the logged-in user.

This is the exported rule I am using.

array (
  'rules' =>
  array (
    'rules_passwordreset' =>
    array (
      '#type' => 'rule',
      '#set' => 'event_user_login',
      '#label' => 'passwordreset',
      '#active' => 1,
      '#weight' => '0',
      '#categories' =>
      array (
      ),
      '#status' => 'custom',
      '#conditions' =>
      array (
        0 =>
        array (
          '#weight' => 0,
          '#type' => 'condition',
          '#settings' =>
          array (
            'code' => 'if (arg(0) == \'user\' && arg(1) == \'reset\') {
  return false;
} else {
  return true;
}',
            'vars' =>
            array (
            ),
          ),
          '#name' => 'rules_condition_custom_php',
          '#info' =>
          array (
            'label' => 'Execute custom PHP code',
            'module' => 'PHP',
            'eval input' =>
            array (
              0 => 'code',
            ),
          ),
        ),
      ),
      '#actions' =>
      array (
        0 =>
        array (
          '#weight' => 0,
          '#info' =>
          array (
            'label' => 'Page redirect',
            'module' => 'System',
            'eval input' =>
            array (
              0 => 'path',
              1 => 'query',
              2 => 'fragment',
            ),
          ),
          '#name' => 'rules_action_drupal_goto',
          '#settings' =>
          array (
            'path' => 'http://www.sample.com',
            'query' => '',
            'fragment' => '',
            'force' => 0,
            'immediate' => 0,
          ),
          '#type' => 'action',
        ),
      ),
      '#version' => 6003,
    ),
  ),
)


texts:
Let's say I'm currently editing a page and there is a WYSIWYG editor in the backend to edit a specific part.

Now I add a table via the WYSIWYG. How can I apply CSS styles on that table WITHOUT altering the CKEditor plugin settings (I don't want to provide classes in the "Styles" dropdown)?


texts: Facet adding itself to search parameters in pager when not selected

texts:
I have a number of search pages that use views, each displays a large number of facets using Search & Facet APIs.

I've noticed recently that when I use the pager I get directed to a url with an extra parameter:

current pagination url - mysite.com?&&field_1=all&page=1
correct pagination url - mysite.com?&page=1

It's only caused by a single taxonomy facet, if I turn that facet off it disappears. However I have other taxonomy facets, which are aside from vocabulary, identical and they don't cause the problem. Has anyone come across this before or have any ideas where it might come from?


texts:
I read documentation first: https://drupal.org/node/1591498 and installed Media 2.x.
I don't see any other docs in module files.

Then I added two additional fields to Application file type.

Now I want to create node with file field. Sample xls file is uploaded via node form but I see only standard description field for this file after upload.

Where I can find and edit those two fields that I added in file type?


texts: Drupal 7, form api - file field default_value

texts:
I've created a formular where the user can upload an image using a file field. In another formular the user is able to change the image he previous uploaded.

So far I was able that the user can upload a new picture or let the field empty and the existing image remains. My question is, how do I show the user in a nice way which file he previously uploaded with the field? Setting a #default_value (@code below) does nothing for me.

//$smallimage = fid of image
$form['smallimage'] = array(
  '#type' => 'file',
  '#title' => t('Image'),
  '#default_value' => $smallimage,
  '#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'),
);

Has anyone a solution/workaround without switching to managed_file?

Thank you in advance

Edit:

As seen in the answers there is no direct solution for the problem. So I've changed the type back to managed_file and gave user1 and node1 the responsibility of being the reference of my files. I'm not happy with that but it works.


texts: Allowing HTML in block title - where is $block->subject created?

texts:
I want to get a
 tag into a block-title but by default the brackets are turned into html characters. My theme's block.tpl is

<h2<?php print $title_attributes; ?>><?php print $block->subject; ?>

so it looks like the rendering isn't happening there. I can't find where $block->subject is getting processed. It's not in my theme's template.php. So where in core is $block->subject assembled?


texts:
Is there a way to string replace with rules?

I'm trying to find some way to transform values without changing a value entirely.

Is there something I'm missing, or should I just make a custom rule that does string replace?


texts: Panel with a view that is filtered dynamically by taxonomy term

texts:
I'm using D7 with the panels3 and views 3.

I've got a view of medical procedures which are categorized by medical specialty. I have doctors becoming members of the site and, using profile2, I'm having them choose a specialty from that some tax vocab. I have a view of these procedures and I want it to be filtered by the specialty(ies) that the logged in user has in their profile. i.e. I want only doctors who selected the 'surgeon' specialty to see procedures also tagged with the 'surgeon' term.

I've got a view content pane set up and I have a page created with page manager which holds this in a panel but I just can't figure out how to configure Contexts to get the filtering to work.

In the view's configurations under pane settings -> argument input I have selected "From Context". As the Contextual Filters I have chosen: Has taxonomy term ID.

Please help!!

:)


texts: How to Auto-save a custom entity to database in response to a new user account using Rules?

texts:
I have defined new custom entity through hook_entity_info:

function mymodule_entity_info(){
  return array(
    'mymodule_account' => array(
      'label' => 'MyModule Account',
      'entity class' => 'MymoduleAccount',
      'controller class' => 'EntityAPIController',
      'views controller class' => 'EntityDefaultViewsController',
      'base table' => 'mymodule_accounts',
      'entity keys' => array(
        'id' => 'aid',
      ),
      'fieldable' => TRUE,
      'load hook' => 'mymodule_account_load',
      'view modes' => array(
        'full' => array('label' => 'Full', 'custom settings' => FALSE),
        'teaser' => array('label' => 'Teaser', 'custom settings' => FALSE),
      ),
    ),

  );
}

I have extended the Entity class, overriding the constructor:

class MymoduleAccount extends Entity{

  public function __construct(array $values = array(), $entityType =
  'mymodule_account'){

    global $user;
    if(empty($values)){
      $values['created'] = REQUEST_TIME;
      $values['title'] = '';
      $values['balance'] = 0.00;
      $values['uid'] = $user->uid;
    }

    $this->entityType = $entityType;
    $this->setUp();
    // Set initial values.
    foreach ($values as $key => $value) {
      $this->$key = $value;
    }
  }
}

I have defined a reaction-rule as follows:

On events segment: I selected

After saving a new user account

On actions segment: I defined two elements:

Create a new entity
Parameter: Entity type: Mymodule Account
Provides variables: Created entity (entity_created)

And:

Save entity
Parameter: Entity: [entity-created], Force saving immediately: true

I have tested these codes by creating new user account, but no mymodule_account has been created in it's database table. What am I missing?


texts: How do you validate against empty form fields in D7?

texts:
In D6, the method I used was to store the value of form fields into a variable and then setting an error message of the variable == null.

Is this still possible in D7, or is there a better way to handle this?  The fields I'm trying to apply custom validation to are select lists so I imagine there must be a different technique.


texts: Exclude specific weekdays from date field

texts:
I am using a date field in the Commerce Order to pick up the product (Collection Date)
Currently, there is a restriction to select dates in the past.
Is there an option on the date field, somehow to restrict specific days of the week?
For example, weekends (Saturdays and Sundays) should not be available.
What would be the best approach to solve this?


texts:
I have written a D8 sub-theme.  Base theme is bootstrap, but I don't think it really matters.

My base theme defines a very specific template field--node--field-image--article.html.twig that I would like to ignore, as if it did not exist.  I would like to fallback to the next best match template, whatever that is.

I have already considered the following options, but they aren't entirely satisfactory.

Delete the unwanted template from the base theme.  However I then have to remember to delete the file again every time I update the base theme.
Override the unwanted template with an identically named file in my sub-theme.  In that file %include the preferred template.  However this requires me to name a specific preferred template.  I would rather let Drupal decide what template would be the best match excluding the unwanted one.
I have discovered the function hook_theme_suggestions_alter.  However I'm not sure that it solves my problem because I don't want to lose the ability to use any given suggestion in general - just that one very specific file.

I guess I will end up going with option 1) if I can't find a better idea.


texts:
On exploring search_api.module file, there mentioned few hooks.Is there any practical demonstration how to use search_api_index_reindex hook?

Basically I'm trying to re-index nodes, after executing some operations. I tried the way, mentioned below, but didn't get any success. any help is really appreciated.

$conditions = [
    'status' => TRUE,
  ];
  $index_storage = \Drupal::entityTypeManager()->getStorage('search_api_index');
  $indexes = $index_storage->loadByProperties($conditions);
  foreach ($indexes as $index_id => $index) {
    try {
          $num = $index->indexItems('-1');
         // print_r($num);
          \Drupal::logger('Reindexing processing...')->debug(print('reindexing done'));
    }catch (Exception $e) {
\Drupal::logger('custom benefits cron reindexing')->debug(print($e));
    }
  }


texts: Active trail not producing expected results

texts:
I'm writing a very simple module to alter the active trail on specific pages.  Observe.

function alter_breadcrumbs_menu_breadcrumb_alter(&$active_trail, $item) {
  if (substr($item['href'], 0, 4) == 'user') {
    $num_crumbs = count($active_trail);
    $people = array(
      'href' => 'people',
      'title' => t('People'),
      'localized_options' => array(),
    );
    $active_trail[] = $people;
  }
}

The profile page by default has the breadcrumb 'Home'.  I have a directory page that has a list of users with links to their profile pages.  This page is located under /people.  So, on the user page, I want the breadcrumbs to look like 'Home > People > John Smith'.

I expect the code above to produce 'Home > People', but it doesn't.  Instead, it produces 'Home > jsmith > People'.  It puts in jsmith instead of John Smith because John Smith is derived from custom first and last name fields, but the crumbs currently just take the user's username by default, so ignore that fact for now.  What it comes down to is I don't understand why it's pushing on the username crumb and the People crumb, rather than just the People crumb.  Any insight would be helpful.

Cheers.


texts: How can I change an image field programatically?

texts:
I'm trying to change the image field 'Badge' when an article is situated at the top of a view 'Top 3' after it has been updated. This is my custom module:

function top_node_update($node) {
    $top = views_get_view_result('top_3');
    $first = $top[0]->nid;

    if ($first == $node->nid) {
        $node->field_badge[0]['value'] = '/default/files/images/gouden_rozet.png';
        field_attach_update('node', $node);
    }
}

Unfortunately, nothing happens when I edit and save an article.

What's going wrong and how can I solve this?

Edit: Everything seemed perfectly fine after @undersounds answer, because the image fields were correctly changed by my custom module. I used the same piece of code to also edit the images of the second and third node in the view:

<?php

function top_node_update($node) {
  $top = views_get_view_result('top_3');
  $first = $top[0]->nid;
  $second = $top[1]->nid;
  $third = $top[2]->nid;

  if ($first == $node->nid) {
    $image = file_get_contents('public://images/gouden rozet.png');
    $file  = file_save_data($image, 'public://images/gouden rozet.png',FILE_EXISTS_REPLACE);
    $node->field_badge[LANGUAGE_NONE]['0']['fid'] = $file->fid;
    field_attach_update('node', $node);
  }

  if ($second == $node->nid) {
    $image = file_get_contents('public://images/zilveren rozet.png');
    $file  = file_save_data($image, 'public://images/zilveren rozet.png',FILE_EXISTS_REPLACE);
    $node->field_badge[LANGUAGE_NONE]['0']['fid'] = $file->fid;
    field_attach_update('node', $node);
  }

  if ($third == $node->nid) {
    $image = file_get_contents('public://images/bronzen rozet.png');
    $file  = file_save_data($image, 'public://images/bronzen rozet.png', FILE_EXISTS_REPLACE);
    $node->field_badge[LANGUAGE_NONE]['0']['fid'] = $file->fid;
    field_attach_update('node', $node);
  }
}

I started playing around a bit to see whether everything worked and discovered this: when a certain node has for example the 'bronzen rozet' image and moves to the first row in the view, the image is changed to 'gouden rozet' - as it should be - but the bronzen rozet.png file is also deleted in my images file!

How can I prevent this?


texts: How on node forms do I set multiple vertical tabs to be always open?

texts: How can I make sure that the Menu Settings part when editing a node is always open just like the published section. See the image below.


texts: Someone let us know about an error on our site. I logged in (as an admin). I was able to move the site to maintenance mode and then went through the steps to clear the cache on the site. Once I did that, I am no longer able to log in or even get to the log in page.  I went to our site: safefields.org/user and I get this error: safefields.org is currently unable to handle this request. HTTP ERROR 500  How can I fix any of this if I can't even log in?