texts: How to get an image url given term_image_tid using the customfield-PHP views module

texts:
I have created a view of type Term that lists all the taxonomy terms plus each term's image. This works. But now I want to wrap the images in a link that links to another view. I am trying to use the customfield: PHP Code field to build up an html string containing the image and the link. The only bit that I cant figure out is how to get the url of the image.

If i do print_r( $data); I get...

stdClass Object ( [tid] => 7
[term_data_name] => Old Edinburgh
[term_data_vid] => 2
[term_image_tid] => 7 )

And the sql query is...

SELECT DISTINCT(term_data.tid) AS tid,
   term_data.name AS term_data_name,
   term_data.vid AS term_data_vid,
   term_image.tid AS term_image_tid
 FROM term_data term_data
 LEFT JOIN term_node term_node ON term_data.tid = term_node.tid
 INNER JOIN node node_term_node ON term_node.vid = node_term_node.vid
 LEFT JOIN term_image term_image ON term_data.tid = term_image.tid
  GROUP BY tid


texts: What is the actions table for and can I delete orphaned actions?

texts:
I just ran

$ drush cc all -v

and it tells me I have orphaned actions. I'm curious to what the actions table is for in Drupal 7 and if it's safe to just drop all the data in the actions table?


texts: How to add_js per content type in my module?

texts:
I'm looking for a way for my module to evaluate the content type in a preprocess hook and conditionally add some javascript.

Theme_preprocess_page() makes the content type accessible plus some other useful things (I could differentiate between nodes & views & such), but I can't use it because it is likely to have already been declared by the theme.

*My_module*_preprocess_page() doesn't appear to provide the content type anywhere.

What is a good option here?


texts: How to add a hierarchical taxonomy to a content type

texts:
I have a hierarchical taxonomy like below

In Drupal 7 there was a module name hierarchical select to achieve this. But it is no longer support for Drupal 8. Is there another way to add this to a content type, so a user can select an element from this taxonomy. I need that to be hierarchical.


texts: I've created a WebForm that allows a user to upload a document file.  The file stores to Media which I'm using for images.  I can delete the image files but I'll be dog-gone if I can figure out how to delete the document files.  I've deleted the WebForm submission but when deleting the file in Media, I get the 'in use and cannot be deleted' message. Does anyone know how to delete this type of file?  I'm in the Administrator account so privileges shouldn't be the issue.  Thanks!


texts: Making a block's content's all show in one row

texts:
I have a block that is made up of 3 subblocks: an image block, a menu block and a views block.  I combine the three blocks programmatically like this:

function inflatable_icons_menu_combo_block_content() {
    $block = block_load('views', 'icon_views-block_5');
    $block2 = block_load('menu', 'menu-facebook-menu');
    $block3 = block_load('imageblock', '1');
    $output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block3, $block, $block2))));
    return ($output);
}

Now this block shows up with all three blocks and looks like this:

But I need the image to show up on the same row as the other two blocks.  What would be a good way to make it all show up on one line?


texts:
I'm trying to show articles by trimming. So, first I tried it by managing the display of body field to trimmed from content type. After fail to get desired results I tried it with views module by adding a contextual filter Content: Body setting character limit to 200 but did nothing.

I would like to hear the answer from this module as I also have the contextual filter: Content: Has taxonomy term ID already in this view.

  Update:

I want to add a view of taxonomy terms where I have created a view with contextual filter previously to which taxonomy term name is linked in this view:

In which taxonomy term is there:

And I tried with  Trim this field to a maximum length too but couldn't success.


texts: How to interpret the components exposed by Facet API in Features?

texts:
I'm developing a website in Drupal 7 when there is a content type representing research papers that has, among other things, fields representing the author (different from the Drupal user), keywords, topics and geographic zones (the last two are taxonomies, others are text).

To search among them, I'm testing with the Search API (with database index) and the Facet API. My goal is to search using the title and the fields mentioned above. In the Facets tab, I'm only enabling blocks for Topics and Geographic Zones.

I'm using too the Features module to export all the site configuration in source code. When I go to the Create Feature page, I can understand the components under the "Server" and "Index" category, as they have the same name I set to them (there is only one server and one index).

However, when I check the "Facet API" category, I find the following components:

search_api@paper_index::field_geo_zone
search_api@paper_index::field_topics
search_api@paper_index:block:field_keywords
search_api@paper_index:block:field_author
search_api@paper_index:block:field_geo_zone
search_api@paper_index:block:field_topics
search_api@paper_index:block:search_api_language
search_api@paper_index:block:title

I can't fully understand the meaning of each component. Why two of them doesn't have the 'block' part? If I only want to have facet blocks for topics and zones, it is necessary to export all of these components or only some of them?


texts: How do I render the main navigation menu?

texts:
In Drupal 7, we were able to render the main navigation menu onto a page outside the main Drupal folders by including bootstrap.inc and displaying it with this code.

 $menuData = menu_tree_output(menu_tree_all_data('main-menu'));
 print drupal_render($menuData);

Can something similar be done in Drupal 8?


texts: Setting a field on an entity form to be required

texts:
I have a multi-value entity reference field on a content entity that I am displaying using a custom form class that extends ContentEntityForm, which extends EntityForm, which extends FormBase.

I'd like to set the field to be required: when using this form, you must select at least one entity to reference. I don't want to make this an entity level constraint however, as it's not absolutely required in all circumstances.

In a form alter hook (as well as in my custom form class) I've tried setting things like

  $form['field_myfield']['widget']['#required'] = TRUE;
  $form['field_myfield']['widget']['#required'] = TRUE;
  $form['field_myfield']['widget']['0']['#required'] = TRUE;

Some of these show up when I kint the form after saving it, some are set back to FALSE, but none of these prevent the form from saving when there is no value in my field. But regardless of that, I don't see anything in FormBase, EntityForm or ContentEntityForm that will validate a required element anyway.

Do I really need to create my own validation handler? Or is it something else that I'm missing?


texts: I want to do something after users voted. I know I can do it by using hook_nodeapi('view') , but I just want to add my action while a vote is being inserted in the database table. How can I do that?


texts: Token replace for commerce products in rules

texts:
I'm trying to create a rule for automatically generating a commerce products titles from all the values of products fields.
After each values I need to add suffix like cm, W, kg, mm e.g.
In order to make the title beautiful, for example "Product Name 10cm 150W 35kg" instead of "Product Name cm W kg", I need to check for empty tokens, but this check for empty tokens is my problem.

$power = "[current-product:field_power]";
if (!empty($power)) {echo "$power". "W ";}
echo strlen($power); //test for what happens

Second line all time print "W" with or without value. (Empty check not work) The third line all time print "29" (same as token name length). As a result I can't check $power var for emptiness.
For node fields I success with token replace:

$brand = token_replace('[node:field-brand]', array('node' => $node));
if ($brand != "") {echo $brand . " ";}

But token replace not work for products variants.
How correctly use token replace for products field of how to check products field for emptiness without token replace?

Export of rule:

{ "rules_change_product_variants_titles_after_node_save" : {
    "LABEL" : "Change product variants titles after node save",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "php", "rules" ],
    "ON" : {
      "node_insert--product" : { "bundle" : "product" },
      "node_update--product" : { "bundle" : "product" }
    },
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-product-variants" ] },
          "ITEM" : { "current_product" : "Current product variant" },
          "DO" : [
            { "data_set" : {
                "data" : [ "current-product:title" ],
                "value" : "[node:title] \r\n\u003C?php\r\n    $brand = token_replace(\u0027[node:field-brand]\u0027, array(\u0027node\u0027 =\u003E $node));\r\n    $type = token_replace(\u0027[node:field-type]\u0027, array(\u0027node\u0027 =\u003E $node));\r\n\r\n\/\/add space after brand and type of product display\r\n    if ($brand != \u0022\u0022) {echo $brand . \u0022 \u0022;}\r\n    if ($type != \u0022\u0022) {echo $type . \u0022 \u0022;}\r\n\r\n    $x = \u0022[current-product:field-width]\u0022;\r\n    $y = \u0022[current-product:field-height]\u0022;\r\n    $z = \u0022[current-product:field-length]\u0022;\r\n    $diameter = \u0022[current-product:field_diameter]\u0022;\r\n    $power = \u0022[current-product:field_power]\u0022;\r\n    $weight = \u0022[current-product:field-weight]\u0022;\r\n\r\n\/\/ make product size like 10x20x15cm, not like 10cmxcm15cm\r\nif (empty($x)) {\r\n  if (empty($y)) {\r\n    if (empty($z)) {}\r\n    else {echo $z . \u0022cm \u0022;}\r\n  }\r\n  else {\r\n    if (empty($z)) {echo $y . \u0022cm \u0022;}\r\n    else {echo $y . \u0022x\u0022 . $z . \u0022cm \u0022;}\r\n  }\r\n}\r\nelse {\r\n  if (empty($y)) {\r\n    if (empty($z)) {echo $x . \u0022cm \u0022;}\r\n    else {echo $x . \u0022x\u0022 . $z . \u0022cm \u0022;}\r\n  }\r\n  else {\r\n    if (empty($z)) {echo $x . \u0022x\u0022 . $y . \u0022cm \u0022;}\r\n    else {echo $x . \u0022x\u0022 . $y . \u0022x\u0022 . $z . \u0022cm \u0022;}\r\n  }\r\n}\r\n\r\n\/\/ I can\u0027t check this data for empty value\r\necho $power . \u0022W \u0022;\r\necho $weight . \u0022kg \u0022;\r\necho $diameter . \u0022cm \u0022;\r\n?\u003E"
              }
            }
          ]
        }
      }
    ]
  }
}


texts: Offload cached pages to different Apache process

texts:
On our Drupal 6 and Drupal 7 sites each idle Apache process averages 60-100MB each.  When the page gets loaded from cache only about 10MB is really needed, but sometimes a page is not cached yet so the process jumps up to 60-100+MB.

We use prefork, so each apache process stays about 60-100MB in size, when in reality 99.99% of the page loads are cached and the processes could easily be down to 10MB.

Our MaxClients settings could be about 5x greater if there were a way to keep the apache sizes down to 10MB.

Is there a way to have two apache processes available, one with a low maxclients for non-cached pages and one with a high maxclients for cached pages?  And also, is there a way to route cached & non-cached requests to different processes?


texts: Trouble with maximum registrants for RNG

texts:
I've tried to create an event with a maximum of 5 registrants and a maximum of 5 registrations to limit my tests on these modules. I was unable to limit the number of registrants to 5 when users can create multiple people registrations for an event.

Could you explain how to set an event with authenticated users able to register several other users without going out of the maximum registrant? I've already tried to set the Conflicts on Maximum registrants without success.


texts:
I have created a website on local with bitnami. Now I want to upload it to a web server (probably on hostgator).

I don't care about content. The site is empty and I will add content only when I upload it.

I just want to keep the settings, permissions, content types and modules. So, I can start add content on air.

If I copy paste the htdocs folder with ftp in the server, this will work?


texts: How to add a functionality to views bulk operations?

texts:
I want to use Views bulk operations to be able to change all my products' taxonomy terms at once.

I have my product managing view with views bulk operations set up and working but there is no operation for editing taxonomy terms under "Modify entity values".

I assume it is possible to add this functionality, but I'm not sure how, any suggestions?


texts: I can't access a provided variable in rule action

texts:
In a rule I have 2 actions, the first one provides a variable (my_var_name). But in the second action this var is not shown as available.

I can't figure out what the problem is.


texts: How to use the Theme Page reactions in context

texts:
In the context module, how does the reaction Theme Page work? I am confused how to use it in my theme

I am using an Omega subtheme and want to display the Section title used in the context to show up in a region. How can I get this value to show?


texts: Translation not working for custom added roles

texts:
I am facing a problem that String translation is only working for Admin and Anonymous users. When I logged in with other users with some custom created roles, then translation is not working.

I provided all the required permissions regarding Locale, String Translation etc. Still not working.

Can someone please help me to resolve this problem?


texts: joining profile types using views module

texts:
According to this thread, click here, I need to use relationships to inner join different content types.

I used the same method with profile types but I ended up with the following result.

Instead of using the views UI, do I need to custom code it?

Thanks


texts: How to make menu items of restricted pages visible to all user roles?

texts:
On a website I'm working on, logged in users can post their feedback about some functionalities which the website provides. While only logged in users should have access to fill the form, invisibility of the menu item "Share your experience" caused to not many users navigate to this page and fill the form.

So what I need is to have the menu item being visible and when anonymous user navigated to this link Drupal will show them the login form automatically (which would be a different issue).

There was an Always Visible module for Drupal 7. Now I want to know what technique should I use to make the menu item always visible in Drupal 8?


texts: Override Drupal views fields module with custom module

texts:
In Drupal 7.22, I want to override 'views-view-fields.tpl.php' views module with custom 'coutforum' module.

The steps I've followed include:

1- renaming the 'views-view-fields.tpl.php' to 'views-view-fields--coutforum.tpl.php' in my custom 'coutforum' module, as per the Drupal convention of adding the double dash & suffix of my custom module.

2- Updated the code in 'coutforum.module' file:

function coutforum_preprocess_views_view_fields(&$vars) {
  if (isset($vars['view']->name)) {
    $vars['theme_hook_suggestions'] []= 'views_view_fields__coutforum';
    }
  }
function coutforum_theme_registry_alter(&$theme_registry) {
    $theme_registry['views_view_fields__coutforum'] = array(
        'theme paths' => $theme_path,
        'template' =>'views-view-fields--coutforum',
        'path' => $theme_path,
    );
}

Code written so far is working correctly, however have the following error:

Notice: Undefined index: type in theme() (line 1158 of /var/www/drupal-7.22/includes/theme.inc).
Notice: Undefined index: #title in template_preprocess_field() (line 1037 of /var/www/drupal-7.22/modules/field/field.module).

Question: How can I define the theme 'type' in template_preprocess_field() / theme registry?


texts: How to remove suggestions for a input field?

texts:
Many browsers use a sort of autocomplete function. So the moment you already entered data in a field it will be added to there remembering list.

I would like to have no suggestion for fields.

A solution for this is using autocomplete on/off for the input fields
http://www.w3schools.com/tags/att_input_autocomplete.asp
I do not understand the compliance for the different browser...

I use many fields in my system. I do not want this for all fields.

There are some solution with modules but not for all fields:
https://www.drupal.org/project/no_autocomplete = only working for login screens

What ways are there to implement this in a easy way in Drupal 7?
I guess to have a hook_form_alter but then?

I guess something like this:

  ' Setuplist with fields automcomplete should be off
    afields_setautomcompleteoff ("fieldname1", "fieldname2","fieldname3")

    ' Look if the current form contains a fields with should be edited
    if(count(array_intersect(?????, $afields_setautomcompleteoff)) == 1){
        'add att to input field but how?
    };

Any suggestions?


texts: How to filter a view relating node and user data?

texts:
I created a content type called Vouchers. This content type has a field called: Points.

In the other hand I enabled the http://drupal.org/project/Userpoints module which allows users to get points.

I created 2 Vouchers nodes. One of them has the value 10 for the Points field and the other one 15

After, I created a view to show the content type: Vouchers. Now I need to add a filter to show the vouchers node only if its Points field value is lower than the User points value (the current logged user)

Please, look my capture to make this understandable:


texts:
What is the purpose of $node->data? the Node object reference has $node->date, which used for

  Long date, including timezone data, of when the node was created.

May I use $node->data to store my own temporary variables?


texts: Commerce / Rules Adding an additional product (or extra fee) for every 10 products of a certain SKU

texts:
My company is trying to implement a complex pricing scheme for drupal commerce that is as follows:

For every 10 products of type A you automatically purchase product B (or the total price is increased by $10)

So for 1-10 products of type A in the cart, the total cost should be the cost of product A * the quantity, plus the price of 1 product B ($10)

And for 11-20 products of type A in the cart it should be the the cost of product A * the quantity, plus the price of 2 product B ($20)

Is there any way to implement this with rules or is there any plugin that would accommodate this kind of price scheme? I've tried looking for a significant amount of time already.

The rationale behind this is that a case is required for the product, and the case fits 10 of the products, so you need exactly one for every 10 products.


texts: How to alter the default user permisions based on a returned value after login?

texts: I am having some users who have access to a limited modules. Now after a user logs in, i want to alter the permissions of that user based on the uid. I mean i should be able to add or delete some permissions of that user immediately after a user logs in. Immediately after login i wrote a custom code which executes and returns a value whether the user is active or inactive. Then based on the result i should be able to delete some permissions to access some modules of my site if inactive or add if he is active.


texts: How to convert a complex select query to Drupal dynamic query?

texts:
I read online that db_query is faster than db_select for complex queries.
I wanted to check this for one of the queries I have written.

Following is the code with db_query:

$query = "SELECT og_users_roles.uid
        FROM {og_users_roles} AS og_users_roles
          LEFT JOIN {og_role} AS og_role
            ON og_users_roles.rid = og_role.rid
          LEFT JOIN {users} AS users
            ON og_users_roles.uid = users.uid
        WHERE og_users_roles.gid = :gid
          AND og_role.name =  :role_name
          AND users.uid <> 0
          AND users.status = 1";

$placeholders = array(
  ':gid' => $group_entity->nid,
  ':role_name' => OG_ADMINISTRATOR_ROLE,
);

$results = db_query($query, $placeholders)->fetchAll();

Now, before testing the performance I need to change above to user db_select.

This is what I have done:

$query = db_select('og_users_roles', 'o_u_r')
  ->leftJoin('og_role', 'o_r', 'o_u_r.rid = o_r.rid')
  ->leftJoin('user', 'u', 'o_u_r.uid = u.uid')
  ->fields('o_u_r', array('uid'))
  ->condition('o_u_r.gid', $group_entity->nid)
  ->condition('o_r.name', OG_ADMINISTRATOR_ROLE)
  ->condition('u.uid', 0, '<>')
  ->condition('u.status', 1);

$results = $query->execute()->fetchAll();

However, this seems to fail with a WSOD.
Can someone point the error?


texts: How can I add a sub-array structure in my results? $_POST

texts:
I'm building a form. In that form I have a lot of checkboxes. Normally, It's possible to make an array of some checkboxes (with name attribute).

<input type="text" name="reservatie[0][1]" />
<input type="text" name="reservatie[0][2]" />
<input type="text" name="reservatie[1][1]" />

Normally I would have this result with print_r($_POST);

Array(
    [reservatie] => Array(
        [0] => Array (
            [1] => value
            [2] => value
            )
        )
        [1] => Array
        (
            [1] => value
        )
    )
)

I tried to add the name attribute, but the $_POST takes the structure of $form. But how can I add a sub-array structure in my results?

foreach($result as $time) {
                    $form['reservatie'][$item->id][$time->id] = array(
                          '#type' => 'checkbox',
                          '#return_value' => 1,
                          '#default_value' => 0,
                          '#prefix' => '<td>',
                          '#suffix' => '</td>',
                          '#attributes' => array('name' => 'reservatie[0]['.$time->id.']')
                    );
                }

This is what I get:

array(42) {
  ["date"]=>
  string(10) "01/07/2016"
  ["reservatie[1][1]"]=>
  int(0)
  ["reservatie[1][2]"]=>
  int(0)
  ["reservatie[1][3]"]=>
  int(0)
  ["reservatie[1][4]"]=>
  int(0)
  ["reservatie[1][5]"]=>
  int(0)
  ["reservatie[1][6]"]=>
  int(0)
  ["reservatie[1][7]"]=>
  int(0)
  ["reservatie[1][8]"]=>
  int(0)
  ["reservatie[1][9]"]=>
  int(0)
  ["reservatie[2][1]"]=>
  int(0)
...
)


texts: How to load a variable through different nodeapi's $op?

texts:
I have a registration form on which I ask if user want to participate to a certain program ; if he clicks "yes", then i have a conditional field which requires to upload a picture. There are some problems for validating a picture with drupal, so I decided to create my own validation system.

If the user clicks on "yes" but doesn't upload a picture, then there must be an error message. If the user clicks on "no", the user can't upload a picture (thanks to conditional field).

For that, I've written this under a hook_nodeapi() function :

        if ($op=='validate'){
        if($node->type == 'profile'){
            // check if the user accepted or not
            if ($node->field_prof_firstflash[0]['value']=="Yes"){
                //check if there's an image loaded
                    if ($node->field_prof_img[0]['filesize'] == 0)
                        form_set_error('field_prof_img', t('Please upload a profile picture.'));
                }
            }
        }
    }

The problem comes when a user wants to edit his settings, later. If the user said "Yes" before but eventually wants to turn it off, my preceding code won't work anymore since $node->field_prof_firstflash[0]['value'] is still set to "Yes". Then, I thought about loading a variable when $op=='prepare' like :

        if ($op =='prepare'){
        $firstflash = $node->field_prof_firstflash[0]['value'];
        $img=$node->field_prof_img[0]['filesize'];

    }
    if ($op=='validate'){
        if($node->type == 'profile'){
            // check if the user accepted or not
            if ($firstflash=="Yes"){
                //check if there's an image loaded
                    if ($img == 0)
                        form_set_error('field_prof_img', t('Please upload a profile picture.'));
                }
            }
        }
    }

But of course (this would have been too simple :-) ), $firstflash is not loaded when $op=='validate', even with that piece of code...

Does anyone has any idea on how to do that?


texts:
Getting the below error after I tried to install new modules to D8.

  [error] 32411#32411: *31 FastCGI sent in stderr: "PHP message: PHP
  Fatal error:  Cannot redeclare twig_without() (previously declared in
  /var/www/html/drupal/modules/drupal-8.7.7/core/themes/engines/twig/twig.engine:140)
  in /var/www/html/drupal/core/themes/engines/twig/twig.engine on line
  140" while reading response header from upstream, client:

Could someone help me? Thank you very much!


texts:
I'm testing ajax callback functionality in drupal 8
I have a custom module which is a simple form
Added an ajax callback to submit button

Code:

namespace Drupal\ajax_form_submit\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;

/**
 * Implementing a ajax form.
 */
class AjaxSubmitDemo extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'ajax_submit_demo';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

$form['message'] = [
  '#type' => 'markup',
  '#markup' => '

',
];

$form['number_1'] = [
  '#type' => 'textfield',
  '#title' => $this->t('Number 1'),
];

$form['number_2'] = [
  '#type' => 'textfield',
  '#title' => $this->t('Number 2'),
];

$form['actions'] = [
  '#type' => 'button',
  '#value' => $this->t('Submit'),
    '#ajax' => [
    'callback' => '::setMessage',
  ],
];

return $form;
  }

  /**
   * Setting the message in our form.
   */
  public function setMessage(array $form, FormStateInterface $form_state) {

$response = new AjaxResponse();
$response->addCommand(
  new HtmlCommand(
    '.result_message',
    '
' . t('The results is @result', ['@result' => ($form_state->getValue('number_1') + $form_state->getValue('number_2'))]) . '
'
  )
);
return $response;
  }

  /**
   * Submitting the form.
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
  }

}

Clicking on submit reloads the whole page rather than giving an ajax response
Provided complete path of function in callback but still the same
Attached the screenshot showing the error messages from the console pointing
to the syntax error in jquery.min.js under /core/assets/vendor
Using sales zymphonies theme.
When I change the theme to Bartik, everything works fine.
Trying to understand what might be the problem from the theme that might be messing with the ajax callback.
Raised the issue on the project page as well, but trying to understand how an ajax callback here is dependent on the theme's javascript/jquery to call the callback function
Any suggestion or guidance towards possible reasons is appreciated


texts: How to update node fields via twilio sms reply from node author?

texts:
I have been working on this for a while now, but I am still struggling to wrap my head around it. I am using Drupal 7.x with Views, Rules, Views Rules, Twilio and Services to try and achieve this.

Here is what I have so far:

User submits a node with only a few of the many fields filled. On submit, Rules schedules the following action set.
Views Rules, contextually filtered by uid and content-type, produces the user's mobile number and the first field of the node that has a null value.
An SMS is sent via Twilio to that user's mobile number containing the value of the field's label (which is a question).

Here is where I am stuck. I would like the SMS reply from the user to update the value of that field, thus saving the answer to that question in the original node authored by that user.

How would I match the response to the user, node and field and update that field's data with the SMS reply?


texts: Call REST GET request inside Rules Action

texts:
I created a custom Rules Action that calls a REST API.
I can be able to display $entityId = $entity->id(); but when I try to use it concatenated in my $uri I am getting no result in $data.

$uri = 'http://localhost:8080/api/' . $entityId;

\Drupal::logger('test')->notice('Path: ' . $uri); // Displays correct path

try {
  $response = $client->get($uri, array('headers' => array('Accept' => 'application/json')));
  $data = (string) $response->getBody();
  if (empty($data)) {
    return FALSE;
  }
}
catch (RequestException $e) {
  return FALSE;
}
\Drupal::logger('test')->notice('Data: ' . $data); // Displays "Data: []"

Its so strange that when I assign hardcoded value for $entityId = 123; it does work. I can get the whole api content for specific node in the log.


texts: Error when I edit a block: Notice: Undefined index: und in eval()

texts:
I don't understand why I put $node->field_test['und'][0]['value'] appears the next error:

  Notice: Undefined index: und in eval()

The field "field_test" is a boolean field. The code is the following one:

$node = node_load(153);
if ($node->field_test['und'][0]['value'] == 1) {
  echo "test";
}

What is my error?


texts: How to add html to the "My user points" page (user points module)

texts:
I am building a Drupal 7 site using the User Points module.

I have some issues that I am not able to solve, you can see the issue here.
I can go around these issues if I will be able to edit the HTML of the "my user points" page (the page that every user can see the points he got and the reason he got them).

Mainly, I want to add a link in this page, that will link to another page on my site.
In addition, I want to add some text beneath the title of the page (original title).
Third thing I want to do is make sure the output on the "Reason column" will be longer, and won't cut off and be too short with "..." in the end.

How can I achieve that?

Where and how I can find the HTML of this page, and edit & add some HTML code?


texts: What is the most efficient way to create and manage 500 sales/landing pages

texts:
For a domain sales business, what is the best way to create and manage about 500 landing pages, each connected to a top level domain name?

I have worked with the Domain Access module in the past, but that becomes very unpractical with more than 10 domains, it lacks the features to handle large numbers of domains.

I have worked with and Aegir server but don't have experience with using a shared Drupal commerce instance for all the domains.

The domain landing pages can either be one page or multiple pages (sites) as long as it will be easy to apply different themes to them easily, if possible through a centralized management tool.


texts:
Used sqlquery to get the error log messages from watchdog table.
Getting message like,

'Sending mail to: @to'.
'%type: !message in %function (line    %line of %file)'
(which seems not relevant).

How can I get error log message similar as shown at SiteReports-->Recent Log Messages  view?


texts:
I'm new with Drupal and I want to save a user after submitting the form, so I create a new module with 3 files: openerp_client.info, openerp_client.module and the openerp_client.install

I want to know how to save this user in my table. This is my openerp_client.install:

function openerp_client_schema() {
$schema = array();
$schema['openerp_client'] = array(
'description' => 'The base table for nodes.',
'fields' => array(
  'oc_id' => array(
    'description' => 'The primary identifier for a node.',
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ),

  'first_name' => array(
    'description' => "User's first name.",
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
    'default' => '',
  ),
  'last_name' => array(
    'description' => "User's last name.",
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
    'default' => '',
  ),
   'company' => array(
    'description' => "User's company name.",
    'type' => 'varchar',
    'length' => 32,
    'not null' => TRUE,
    'default' => '',
  ),
   'email_address' => array(
    'type' => 'varchar',
    'length' => 254,
    'not null' => FALSE,
    'default' => '',
    'description' => "User's e-mail address.",
  ),
),
'indexes' => array(
  'openerp_client_oc_id' => array('oc_id'),
),

'primary key' => array('oc_id'),
);
return $schema;
}

This is what's in my implementation of hook_webform_submission_insert():

function openerp_client_webform_submission_insert($node, $submission) {
$nid = db_insert('openerp_client')
 ->fields(array(
'first_name' => $submission->first_name,
'last_name' =>$submission->last_name,
'company' =>$submission->company,
'email_address' =>$submission->email_address,
))
->execute();
}

But I get this exception:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'first_name' cannot be null: INSERT INTO {openerp_client} (first_name, last_name, company, email_address) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => ...

Why?


texts:
I have a really strange problem on my Drupal site: The site reports double access to every page.

When I'm visiting an admin/something URL as administrator user, I can see in the log a warning alerting me that an anonymous user is trying to access that page.
I discovered this error when clearing the log page and a warning instantly was added telling me that a user is trying to access the page.

How can I check why this double access occurs?
This is causing me a lot of problems. (No Drupal message is shown.)


texts: Order Status is Pending after Paypal Payment

texts:
I created an order with weekly or monthly subscription. User can purchase the subscription only through paypal.

If a user purchase the subscription he redirected to paypal site. After successfully payment the order is created. But the order status showing pending. It should be completed.

Recurring Module : UC Recurring Payments and Subscriptions

Payment Method - Paypal

(Edit) Problem was in Sandbox paypal Account. Api Credential (Password and Signature) was not there. I changed the merchant account Api Credential.

After changed the api credential same problem occured with changed account. What to do?


texts: How can I use native dates using mongodb field storage?

texts: I currently have a setup with mongodb as a backend and couldn't find a way to use native dates with date module. Is there a way to specify a different field schema for mongodb / map the types to the native equivalent?


texts: Rules - Send mail to all addresses in email field of specific content type

texts:
I have a content type (school) with an unlimited email field (field_email).
Now on creation of another node (page), I would like to send to all emails stored in the "field_email" of all school nodes an email.

I started by created a rule with the "rules" module but i cannot figure out how to pull the data from a separated node (school).

Could someone point me in the right direction?


texts: Rate Module: Display the rating in the comment user added to the node

texts:
Is there a way to display the rating in comment given by a user in the node? For example, in this page http://www.yelp.com/biz/ikes-place-san-francisco at the top we can see the total rating, but in comments we can see the rating given by the user.

Is there some way to do this? Thanks!


texts:
I have a problem with the module "Taxonomy Menu" in Drupal 7.
I have a menu where the parent element is "Categories" and children are all Taxonomies (is located on "Main Menu")

When I create content, choose your taxonomy and save. This taxonomy was selected, it appears as menu in the "main menu" of my drupal site. That is, it escapes the parent element that contains it.

Is this configurable module itself? (I do not see a configuration related to that) or is it a problem in the module?


texts: Where is $config_directories value set in Acquia BLT?

texts:
Generally to setup path for Config Directories,it is defined under
settings.php as

$config_directories['sync'] = 'path/to/config';

but in a blt setup when I checked

settings.php
sites/default/settings/local.settings.php
/../vendor/acquia/blt/settings/blt.settings.php

I see there is no definition of

$config_directories['sync']

whereas in the documentation it says its defined here under vcs

  Although, by default, Drupal 8 uses the sync configuration directory
  type for configuration, Acquia Cloud uses the vcs configuration
  directory type for that purpose.
  https://docs.acquia.com/acquia-cloud/develop/config-d8/#cloud-manage-local-config

But I still can't find the place where it is defined?


texts:
I have a query that works fine with one where clause however when I add AND it doesn't work, can someone please tell me what I'm doing wrong?

$args2 = array(':name' => $existingproductIDfield);
$args3 = array(':vid' => '6');
    $result2 = db_query('SELECT * FROM taxonomy_term_data WHERE name = :name', $args2 .'AND vid = :vid', $args3);

    if ($result2->rowCount() > 0) {
        foreach($result2 as $row) print_r($row);

    }


texts: How to wrap node output with a link using Display Suite?

texts:
how would I best wrap my entire node in an  tag linking to the full node? My nodes are display using Display Suite and a custom view mode.

I'm guessing creating a php template and manually writing the link somehow would work?


texts: How to parse out links and img src references from body copy?

texts:
I need to modify links and img references in the body of nodes and comments. MPD already gave me good advice regarding using a script.

Is there an easy way in Drupal or PHP to parse out all the links in the body copy?


texts: The custom node template file is not working

texts:
I've created template file named node--product-display.tpl.php as suggested by the Theme developer module, but the changes I made to this file don't show up.
I've also copied the node.tpl.php file in my templates directory. The changes in the latter one show up but that in the former one doesn't.

Do you have any suggestion?

I have cleared the cache. The template file is for a "Product Display" content type, whose machine name is "product_display."


texts: How can I force changes to go to settings.local.php?

texts:
I have a settings.php file in git which has the logic to include settings.local.php already uncommented, with settings.local.php in .gitignore for security purposes.

I would like to be able to install Drupal (8.3.3) so that any changes which are made by the installer (by default: hash salt, databases array, install profile, sync directory location) are made to settings.local.php rather than settings.php as the installation currently does. Is this possible?


texts: Index Data from External Database for Search - Views

texts: I have a Drupal 7 view which obtains data from an external database and displays it on the page. I would like to index this external data (read through Views) so that the resulting items can be searched for using Drupal Search. How do I go about doing this?


texts: How can I automatically assign users to a node based on a taxonomy?

texts:
I've Googled this but might just not be using the right search phrases. I'm building an RFP repository for my company. Each RFP question will have a Category assigned to it. Within Drupal, I'd like to:

Automatically assign one or more users as the SME (subject matter expert) based on the Category that was assigned to the question, e.g. if Category = Analytics, then automatically assign user 'John Smith' as the SME upon node creation. The users assigned to the question should be viewable on the node.
To do this, I'd need to have a mapping of Category => SME(s) table I'd assume.
The end goal, would be to use something like the Flag module to be able to notify those users via email if an RFP question that they are the SME for needs updating.
Ideally, there would be a way to automatically update existing nodes with the most current mapping of Category => SME (people leave, new people come onboard, etc.)


texts: What could be causing drupal to want to reinstall itself after I clear cache?

texts:
I am trying to update Drupal from 7.17 to 7.18. I uploaded a copy of my site from a test server to my production server. Everything installs fine, I actually see the site working, and I can navigate it. Then, as soon as I perform updates on modules and core, I run database updates, and then the site automatically navigates me back to install.php to reinstall the site from scratch. I have tried to reinstall the site several times from scratch, manually and using Drush.

What is the mechanism that determines to redirect to install.php? How can I determine how and why this is happening?

Even though the install.php page is showing up in the browser, drush status shows that the site is up, running, successfully connected to the database with correct theme. According to Drush, everything is working properly.


texts:
I have enabled QuickEdit but not seeing its functionality appear anywhere.

Here is my node--type.html.twig:

{%
  set classes = [
    'node',
    'node--type-' ~ node.bundle|clean_class,
    node.isPromoted() ? 'node--promoted',
    node.isSticky() ? 'node--sticky',
    not node.isPublished() ? 'node--unpublished',
    view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
  ]
%}

  {{ title_prefix }}{{ title_suffix }}

      {% if node.field_image_position.value == 'below' %}

          {{ content.field_summary_image }}

      {% endif %}

      {{ content|without('field_story_subject', 'field_summary_image') }}

      {% if node.field_story_subject.value is not empty %}

Tags:

            {{ content.field_story_subject }}

      {% endif %}

Here is my body field twig, for example:

{%
  set classes = [
    'hl__rich-text'
  ]
%}

{% for item in items %}

{{ item.content }}

{% endfor %}

{{ attributes }} in neither case seem to carry the things that attach quickedit to tags. I am using Stable as the base theme - what is missing here?


texts: Why is a template being looked in a theme and not in my module?

texts:
I have created a custom module. in that module I have create a custom twig template using hook_theme function

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'mymodule_settings' => array(
      'variables' => array(
        'role' => NULL,
      )
    )
  );
}

Then I created a custom block using my module here is the code of the block

public function build() {
    $config = \Drupal::config('mymodule.config');
    $role = $config->get('role');
    return array(
      '#theme' => 'mymodule_settings',
      '#role' => $role,
    );
  }

I created a templates directory in my module and inside that directory I have created mymodule-settings.html.twig file.

Cleared the cache but Drupal gives me the following error.

Twig_Error_Loader: Template "themes/subtheme/templates/mymodule-settings.html.twig" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "themes/subtheme/templates/mymodule-settings.html.twig" in the Drupal theme registry.). in Twig_Loader_Chain->getCacheKey() (line 45 of themes/basetheme/templates/block.html.twig).

My theme is a subtheme. Why Drupal is looking for the template in the theme and not in my module?


texts: drush status not showing correct setting from alias file

texts:
I'm trying to get drush to work with my test environment, which is actually using a separate database.

so here's my alias in aliases.drushrc.php:

 $aliases['local'] = array(
   'root' => '/my/drupal/root',
   'uri'  => 'http://localhost',
 );

 $aliases['test'] = array(
   'parent' => '@local',
   'databases' => array (
     'default' =>
     array (
       'default' =>
       array (
         'database' => 'test_db',
         'username' => 'test_user',
         'password' => 'test_pwd',
         'host' => 'localhost',
         'port' => '',
         'driver' => 'mysql',
         'prefix' => '',
       ),
     ),
   ),
 );

When I look at the drush site-alias @local and drush site-alias @test the config is read correctly.

When I run drush @test status it gives me the default status.  Notice that the username and db are the default, not my test details.

 $ drush @test status
  Drupal version                  :  7.14
  Site URI                        :  http://localhost
  Database driver                 :  mysql
  Database hostname               :  localhost
  Database username               :  default_user
  Database name                   :  default_db
  Database                        :  Connected
  Drupal bootstrap                :  Successful
  Drupal user                     :  Anonymous
  Default theme                   :  sporttracks
  Administration theme            :  seven
  PHP configuration               :  /private/etc/php.ini
  Drush version                   :  5.8
  Drush configuration             :
  Drush alias files               :  /my/home/dir/.drush/aliases.drushrc.php
  Drupal root                     :  /my/drupal/root
  Site path                       :  sites/default
  File directory path             :  sites/default/files
  Temporary file directory path   :  /tmp

So the question is: why is the alias not being read?


texts: How can i get rid of ' 403 Access Denied' error for SoundManager2 mp3 files, that are in the Downloads folder?

texts:
i have installed SoundManager2 to playback audio files but realized that anonymous users get a 403 Forbidden error when trying to play. These files are actually products. i attached to product type using 'File Attach' method. After that it moves the file to the downloads folder but cleverly when looking at the markup it says the file is in 'system/files'. unless i'm wrong there is no such dir.  For now,  i have the downloads permissions set to 'rwxrwxr-x'. I've also checked the Permissions page and set anything related to products and mp3's accessible to anonymous users.

any ideas?!, thanks!


texts: how to use parent field in child view in views field View

texts:
I am using Views Field View module.
I need to filter the child view using the parent field. Can anyone experienced in it please share.


texts: How to show related taxonomy terms vith views on term page?

texts:
I have a content type book and it has a taxonomy term reference field: author. This field can have multiple taxonomy terms.
What I want to do is to create a views to show related taxonomy terms on taxonomy term page.
For example, if a node has two authors: term 1 and term 2 then these terms are "related".


texts:
There is a method of installing Drush via Composer.
composer global require drush/drush:dev-master

How do I uninstall it using Composer?


texts: How can one automatically rename files uploaded in a webform?

texts:
I would like to rename the files uploaded to a webform according to some tokens or the value in some other field.

I did some research on this and was surprised to find no definite solution.

For example:

https://www.drupal.org/node/326738 => A patch supplied for token support but the discussion ends without a final working patch
https://www.drupal.org/node/364752 => Discussion on "Renaming file upload fields using other form fields". Discussion ends in "Won't Fix"
Webform, creating customized directories for uploaded files => Approaches have been suggested here but no final solution given.


texts: How do I programmatically delete a reference field value?

texts:
I have a multi-valued taxonomy reference field named field_classrooms in a node type. I use below code to delete the value in the field.

$node = Drupal\node\Entity\Node::load('1512');
unset($node->field_classrooms[0]);
$node->save();

I can't figure out what I am doing wrong here.


texts: Backup table from custom module using backup and migrate

texts:
I have a module that allows a user to add to a custom table in bulk via a custom form. But before they do so I'd like to backup that table to the private folder. Does anyone know if it is possible to create a new profile in the Backup and Migrate module and save a table using code in a custom module?

So what I'd like to do is programmatically create a Backup and Migrate profile in my modules .install file. Then in my custom form submit function, trigger the backup using that profile.


texts: How to get content type data on basis of assigned taxonomy?

texts:
I want to get the data of particular content type on the basis of taxonomy assigned to it. How can I get this using query.

$bloglist = db_select('node', 'n')
                    ->fields('n', array('nid'))
                    ->condition('type', 'product_list', '=')
                    ->condition('status', 1, '=')
                    ->orderBy('created', 'DESC')
                    ->execute()
                    ->fetchCol();

        // Get all of the article nodes.
        $bloglists2 = node_load_multiple($bloglist);

I have this query to get the data for product_list content type. Now I want to add one more condition of taxonomy to get data on basis of taxonomy and content type. How can I do that?


texts: List all bundle types for entity field query?

texts:
Trying to use entity field query to simplify some times; e.g. a slide show of images.

How does one get the field values for entity field query. Specifically, get a list of all the possible bundle types there are?

E.g.

<?php

function foo_load() {
   $query = new EntityFieldQuery;
   $query
     // What conditions or properties are there?
     ->entityCondition('entity_type', 'node')
     ->entityCondition('bundle', 'banner')
     ->propertyOrderBy('created', 'DESC');
     ->propertyCondition('status', 1);

}


texts: Regarding menus for authenticated users only

texts:
Using Structures/Menus/User Menu in DRUPAL 7 i am adding a custom menu link under it and providing a path to it as node/whatever_my_nid. It is working fine. I have cleared all cache. However this menu link is being displayed for all users. I want it to be displayed only for authenticated users and admin. This should be a simple thing to figure out but apparently i cannot. I thought it would have been a permission issues but i don't think so. Would appreciate any help.
Thanks

Edit: I found that this code may help:

<?php
global $user;
if ($user->uid) {
if ($menu = theme_menu_tree()) {
   $menu = "
". $menu . "
";
   return $menu;
}
}
else {return;}
?>

But where do i place this code...In my page.tpl.php or somewhere else like in template.php in my themes?

I tried placing the above function in my theme's preprocess function as:

function ypwb_preprocess_block(&$variables, $hook) {
     if ($user->uid) {
        if ($menu = theme_menu_tree()) {
           $menu = "
". $menu . "
";
           return $menu;
        }
      }
        else {return;}
    }

However, the menu is still showing for anonymous user as well.


texts: How to remove "Show row weights" option on File Upload field?

texts: I have created a file field with multiple uploads allowed. Is there any way(except CSS) I can remove "Show row weights" link from file upload field? Or is there any way to remove weight drop down entirely from file field?


texts: Submit form load results instead of messages

texts:
I am testing out the new Drupal 8 custom modules and currently stuck with the submit form handler to load form submitted results in the same page and my current functions of last submit is this (inside the controller form) :

    <?php
/**
 * @file
 * Contains \Drupal\resume\Form\ResumeForm.
 */
namespace Drupal\resume\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class ResumeForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'resume_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['candidate_name'] = array(
      '#type' => 'textfield',
      '#title' => t('Candidate Name:'),
      '#required' => TRUE,
    );

    $form['candidate_mail'] = array(
      '#type' => 'email',
      '#title' => t('Email ID:'),
      '#required' => TRUE,
    );

    $form['candidate_number'] = array (
      '#type' => 'tel',
      '#title' => t('Mobile no'),
    );

    $form['candidate_dob'] = array (
      '#type' => 'date',
      '#title' => t('DOB'),
      '#required' => TRUE,
    );

    $form['candidate_gender'] = array (
      '#type' => 'select',
      '#title' => ('Gender'),
      '#options' => array(
        'Female' => t('Female'),
        'male' => t('Male'),
      ),
    );

    $form['candidate_confirmation'] = array (
      '#type' => 'radios',
      '#title' => ('Are you above 18 years old?'),
      '#options' => array(
        'Yes' =>t('Yes'),
        'No' =>t('No')
      ),
    );

    $form['candidate_copy'] = array(
      '#type' => 'checkbox',
      '#title' => t('Send me a copy of the application.'),
    );

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Save'),
      '#button_type' => 'primary',
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
    public function validateForm(array &$form, FormStateInterface $form_state) {

      if (strlen($form_state->getValue('candidate_number')) < 10) {
        $form_state->setErrorByName('candidate_number', $this->t('Mobile number is too short.'));
      }

    }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

   // drupal_set_message($this->t('@can_name ,Your application is being submitted!', array('@can_name' => $form_state->getValue('candidate_name'))));

    foreach ($form_state->getValues() as $key => $value) {
      drupal_set_message($key . ': ' . $value);
    }

   }
}

I wanted to show results in a table in the same page form where user submit the form, rather than just throwing in messages

thank you


texts: Change the pager and the number of elements per page of a specific view

texts:
I create a view (FO) that lists certain content type. By default, I put a pager (mini) and a number of items per page (content 10 per page).

This view, I integrated into a content type (CFTO) in addition to other parameters.
If I agree, I want to use my other variables to redefine this view without saving it in a database (eg disable the pager / display 3 content page / ...)

I try different hooks as hook_views_pre_view, hook_views_pre_render, views_pre_build, but nothing works.
I can not change the number of a content page. This is my different test :

I wish i could change my view different information as enable / disable pager and more then change the number of elements of the page.

I find a way of hook_views_pre_render(&$views) to change the pager and more. It works well.

function my_views_pre_render(&$view){
//For more
$view->display['page']->handler->options['use_more'] = TRUE;

//For pager
if(!$this_node_pager_value) {
    $view->query->pager->set_items_per_page($view->total_rows);
    $view->query->pager->update_page_info();
}}

Now i wish i could change the number of elements in my page to display, I tested this code in different hook sities previously.

function my_views_pre_render(&$view){
if($this_node_pager_value) {
//TEST 1
$view->query->pager->set_items_per_page(3);
$view->query->pager->update_page_info();

//TEST 2
$view->exposed_raw_input['items_per_page'] = 3;
}}

function my_views_pre_view(&$view, &$display_id, &$args){
//TEST 1
$view->display_handler->display->display_options['pager']['options']['items_per_page'] = 3;

//TEST 2
$view->query->pager->set_items_per_page(3);
$view->query->pager->update_page_info();

//TEST 3
$view->exposed_raw_input['items_per_page'] = 3;
}

function my_views_pre_execute(&$view){
//TEST 1
$view->display_handler->display->display_options['pager']['options']['items_per_page'] = 3;
//TEST 2
$view->query->pager->set_items_per_page(3);
$view->query->pager->update_page_info();
//TEST 3
$view->exposed_raw_input['items_per_page'] = 3;
//TEST 4
$view->display_handler->set_option('items_per_page', 3);
}

function cci_generic_views_pre_build(&$view){
//TEST 1
$view->pager["items_per_page"] = 3;
//TEST 2
$view->display_handler->options['pager']['options']['items_per_page'] = 2;
//TEST 3
$view->display_handler->options['pager']['options']['expose']['items_per_page'] = 2;
}

None works. Would you know what should be done to make it work?

You would know what is the right hook to use? And how to change this value?
thank you for your help

Djik


texts:
I have a content entity type, and I would like to have an 'Upload file' field. I have declared the field in my Entity class

$fields['file'] = BaseFieldDefinition::create('file')
    ->setLabel(t('Upload a file'))
    ->setDescription(t('Choose file from your computer'));

And in EntityForm I am trying to set some settings, because I need to make this dependable later with the '#states'

$form['file'] = [
    '#title' => $this->t('File'),
    '#description' => $this->t('Upload a file from your computer'),
    '#type' => 'file',
    '#default_value' => $entity->file->value,
];

But at the moment the field is displayed, but I have problems on saving the form. The file is attached, but not getting uploaded and the error says:

  Fatal error: Call to a member function getValue() on a non-object in
  C:\A
  plus\drupalsite\core\modules\file\src\Plugin\Validation\Constraint\FileValidationConstraintValidator.php
  on line 18


texts:
I have a view that shows all the contents of my site, with an exposed filter, that allows to filter these contents according to different taxonomy terms.

I would like the taxonomy term chosen via the exposed filter to appear as a page title.

Example:

I type in my search form: drupal,
I arrive on a page with the title "drupal" and presenting all the contents having for term "drupal".

I tried different options, especially with the contextual filter, but without success.

For example, i tried this solution (1) or this solution (2), but either I do not get any title (1), or I get many errors that make the site crash (2), of type

  Warning : Illegal string offset 'value' dans Drupal\views\Plugin\views\area\Text->preQuery() ((...)/core/modules/views/src/Plugin/views/area/Text.php ligne 50)

Help would be much appreciated

Edit:

My views configuration (maybe views can't find the id in the url? The url of my page: : mysite/myviews?tid=term+taxonomy+(ID) )


texts:
I'm new to Drupal development and this question may have been asked and answered but I haven't found an answer that works for me yet.

I am developing a module that creates 4 paths using a menu_hook. Three of the pages appear inside an iframe defined on a page. I'd like to prevent the header/sidebars/footer (and other regions other than content) from appearing on the iframed page. This must be done independent of the theme - I don't know or care what the theme is.

I'd like the iframed page to only contain the  content  tags. I want to do this programmatically without the help of any additional modules. The iframed page executes a js script (on load) that redirects (the parent) to a results page. It is during the redirect that I can see the loaded iframed page and then the redirection occurs. The transition is ugly.

I have tried using templates in the module directory; however, I don't think I've done them correctly and haven't yet encountered a good example of a template loaded and used from a module directory.

I have tried a hook_page_alter function to unset the regions (but the header and footer still appear on the page).

I've tried a theme_hook function but I'm only interested in suppressing some of the regions the theme may be using and not interested in variables.

Because I don't know what the theme is and I don't know what the selector names or classes might be for the page divs I don't want to try and solve this with a few "display:none;" entries in a css file. Any help or ideas would be appreciated.


texts: AJAX event and disable select form element

texts:
I have a little problem:

/**
 * Form callback
 */
function ajax_disable_test_form($form, &$form_state) {
  $form['select'] = array(
    '#type' => 'select',
    '#required' => FALSE,
    '#title' => t('Change me!'),
    '#empty_option' => t('- Select -'),
    '#options' => drupal_map_assoc(range(1, 3)),
    '#prefix' => '
',
    '#suffix' => '
',
  );
  $form['change'] = array(
    '#type' => 'submit',
    '#value' => t('Change!'),
    '#ajax' => array(
      'callback' => 'ajax_disable_test_form_submit_ajax',
      'wrapper' => 'select_box_wrapper',
    ),
  );
  return $form;
}

/**
 * Ajax callback
 */
function ajax_disable_test_form_submit_ajax($form, $form_state) {
  $form['select']['#title'] = t('Changed!'); // It's work!
  $form['select']['#disabled'] = TRUE; // It's not work!
  return $form['select'];
}

Link: https://gist.github.com/nevergone/23f0a50bee01acc34ed2

If clicked the button, select box title changed, but select box not disabled. Why?
Version: Drupal 7.41


texts: Cannot use feeds to import into data tables where the primary key is multiple

texts:
I am using Data Module to create tables in Drupal.
Now, I need to import some data through CSVs, for this I want to use Feeds Module.
My table consists of more than one primary key i.e. a group of fields together forms a primary key.

Is there any way to import the data for such a case using feeds? Coz my understanding is that feeds cannot import data if the primary keys are not restricted into a single column.


texts: Loading fully themed node with Ajax - Drupal 7

texts:
I am loading node content to a specific div with Ajax. Is it possible to load a fully themed and rendered node (themed via page--node--1.tpl.php) with Ajax?

I have a custom module controlling my Ajax functions. From what I understand, the code below should be returning a fully themed node - but it is not doing so:

function ajax_reader_init() {
    drupal_add_js('misc/jquery.form.js');
    drupal_add_library('system','drupal.ajax');
}

/**
 * Implements hook_menu()
 */
function ajax_reader_menu() {
    $items['ajax-reader'] = array (
        'page callback' => 'ajax_link_response',
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK
    );
    return $items;
}

function ajax_link_response($type = 'ajax', $nid = 0) {
    $output = _ajax_reader_load_noder($nid);
    if ($type == 'ajax'){
        $commands = array();
        $commands[] = ajax_command_replace('.main', '
'.$output.'
');
        $page = array(
            '#type' => 'ajax',
            '#commands' => $commands
        );
        ajax_deliver($page);
    } else {
        $output = '
'.$output.'
';
        return $output;
    }
}

function _ajax_reader_load_noder($nid = 0) {
    $node = node_load($nid);
    if($node) {
        $vnode = node_view($nid);
        return theme("node", $vnode);
    }
}


texts:
I'm having a content type with referenced fields of paragraph type. How to get referenced fields in hook_form_alter?

Here are my fields:

[field_media_audio] => Drupal\field\Entity\FieldConfig Object
        (
            [deleted:protected] =>
            [fieldStorage:protected] => Drupal\field\Entity\FieldStorageConfig Object
                (
                    [id:protected] => node.field_media_audio
                    [field_name:protected] => field_media_audio
                    [entity_type:protected] => node
                    [type:protected] => entity_reference_revisions
                    [module:protected] => entity_reference_revisions
                    [settings:protected] => Array
                        (
                            [target_type] => paragraph
                        )

                    [cardinality:protected] => -1
                    [translatable:protected] => 1
                    [locked:protected] =>
                    [persist_with_no_fields:protected] =>
                    [custom_storage] =>
                    [indexes:protected] => Array
                        (
                        )

                    [deleted:protected] =>
                    [schema:protected] =>
                    [propertyDefinitions:protected] => Array
                        (
                            [target_id] => Drupal\Core\TypedData\DataReferenceTargetDefinition Object
                                (
                                    [definition:protected] => Array
                                        (
                                            [type] => integer
                                            [label] => Drupal\Core\StringTranslation\TranslatableMarkup Object


texts: Host two ready websites with different URL using same code base

texts:
I’m pretty newbie to drupal and deploying stuffs. I’ve two separate drupal websites ready.

www.example.com
www.example.org

My directory structures on local machine for both websites are

wamp/www/example.com/sites/’all & default ‘ folder
wamp/www/example.org/sites/’all & default ‘ folder

These websites have complete different theme and database from each other. Now I want to go live for these two websites. But the problem is on hosting server they will provide me only 1 drupal installation. I need both URL’s working. (There is a setting for URL redirection on hosting).  But on hosting server, redirection via .htaccess is not running. (They said !!!). So my question is how to host two complete different websites on server with two complete different URLs using same drupal code base? I’m using drupal 7. Any help or suggestion will be appreciated.

Thanks in advance…


texts: Changing which content appears at which parts of site

texts:
I would like to make different divs in the template, that show up at different parts of a site: eg. div#1 shows at pages from Menu-01 + it's sub-menus; div#2 shows up at pages from Menu-02 + its' sub-menus, div#3 at Blog pages, and so on.

How can this be achieved? Coming from the Wordpress world it is something like

<?php
if ( is_category ('1') ) {
//something for category 1
}
if (is_page ('6') ){
 // something for page 6
}
// other functions for descendant checks possible with custom made checkers in functions.php
?>

In Drupal I only found the front page check

drupal_is_front_page()

But I've found no other types of checkings with this method.

Any help please?
Thanks.


texts: How to loop over a list of Organic Group users using Rules

texts: When a user requests to join an Organic Group, I want to send an email to the group's admins. I've found this answer (https://stackoverflow.com/questions/16742925/how-to-send-an-email-to-drupal-7-organic-groups-role-members/23301910) which helps with selecting users with the appropriate role, but I can't for the life of me get a list of just the users from the current group.


texts: Caching - techniques? suggestions? best practices?

texts:
I have a website that will be using three (3) views slideshows on the landing page/front page. What are the best ways to set this up site to be able to load efficiently?  Should I start with a Pressflow site? Install and enable specific modules to improve performance? Use Boost? Are most of the caching modules and techniques related only to logged in users? Do I have to own my own server to do this well?
I am assuming that because there are so many slideshow instances loading at the same time that this will be a severe performance hit at loading.


texts: Filter by taxonomy parent using Json api

texts:
In drupal 8.5 I have a taxonomy term list like this:

Term A (12 items)
  Term 1 (3 items)
  Term 2 (8 items)
  Term 3 (1 items)
Term B (3 items)
  Term 4 (1 items)
  Term 5 (2 items)

I want to use the json api to fetch all data within term B. So I expect a result set of 3 items.
But when I do:

https://www.some-api.com/jsonapi/node/test?
  _format=api_json&
  filter[taxFilter][condition][path]=field_regio&
  filter[taxFilter][condition][operator]=IN&
  filter[taxFilter][condition][value][]=2 (=> id of term B)

I get a response with "data": [],
This is probably because the term id of these nodes are set to the children (term 4 and 5).

But isn't drupal supposed to return all nodes in the children of term B?

Otherwise how can I get all nodes in Term A or B?


texts: Views sort criteria setup by number of fields

texts:
I am using views with exposed so visitors can search on items that are published by other users.

Content type that views is showing has 50 fields (+ 3 taxonomy fields with around 200 terms).
Only 7 fields are mandatory. Rest are there to better describe the item. Rarely someone uses all fields but most are using half.

Reward for using as many fields+terms as possible per content would result in higher position in view sort criteria.

Example: Users A and B have 2 nodes each.

A1 = 7 fields used

A2 = 12 fields used

B1 = 8 fields used

B2 = 10 fields used

Views results: A1, B1, B10, A12

Is there a way to do this with views ?


texts: Cannot install Search API pages module, due to database errors?

texts:
Trying to install search_api_page created repeated database errors about the search_api_page table not being available.

Is it a known problem known to happen?


texts: Hook form alter not working for node edit form

texts:
I have a content type called landing_page. If I edit an existing node in the admin /node/31/edit and I inspect the form I see id="node-landing-page-edit-form".

I can't get it to work to use hook_form_FORM_ID_alter()?

I tried:

function MYTHEME_form_node_landing_page_edit_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
  $form['field_message'] = array(
    '#type' => 'item',
    '#title' => t('New article'),
    '#markup' => t('Test message'),
  );
}

I also tried:

function MYTHEME_form_node_form_alter(&$form, FormStateInterface $form_state) {
  $form['field_message'] = array(
    '#type' => 'item',
    '#title' => t('New article'),
    '#markup' => t('Test message'),
  );
}

And I tried:

function MYTHEME_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'node_landing_page_edit_form') {
// My code here
}
}


texts:
I am using Drupal 7, I have Pathauto enabled, and my user has permissions to create new aliases.

When I manually create a node, uncheck the checkbox for automatic alias generation, and enter a custom alias (e.g. 'qwerty'), I can use drupal_lookup_path() to return the alias. So

$path = drupal_lookup_path('node/' . $node->nid);

gives $path a value of 'qwerty'.

However, when I create a node in simpletest with the code

$edit = array(
  'title' => 'asdf',
  'path[alias]' => 'qwerty',
);
$this->drupalPost("node/add/{$this->content_type}", $edit, t('Save'));

and then

$path = drupal_lookup_path('node/' . $node->nid);

$path has a value of 'NULL', even when the alias is functioning, e.g. when

$this->drupalGet('qwerty');

returns a 200 status.

Why is drupal_lookup_path() failing to find my alias only when called from a test?


texts: How to handle validation (email along with custom user field) user registration via REST API?

texts:
I am using Drupal 8 default REST API end points for user registration and login services as per link below provided

https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services#users

How to validate user with email along with custom filed values which I created in the user profile ? I mean if both email and custom field value already exists, then throw an error to stop registration; if not, then allow registration.

Note: I have tried with entity queries via form alter to validate but it is working fine when registrations happens via website but it's not working registrations happens via REST API POST Method.


texts: On hook_form_alter setting select list options for a field

texts:
By default select options i have left empty in admin of that content type.

I am trying to alter select list option of a content type using hook_form_alter.

I am setting the values to select values and is getting assigned.

Only issue is that its getting logged out with single refresh to create form of that content type form or try to submit that form. What am i doing wrong in the code.

Thanks in advance.

function hook_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id == 'product_node_form')
    {

            $users = db_select('users', 'u');
            $users->join('users_roles','ur','u.uid = ur.uid');
            $users->fields('u',array('name'));
            $users->fields('ur',array('uid'));
            $users->condition('ur.rid',6,'=');
            $users->orderBy('u.uid');
            $users = $users->execute()->fetchAll();

            $vendor_list = array("Tan" => "Tan");

            foreach($users as $key => $user)
            {
                $vendor_list[$user->name] = $user->name;
            }
            $form['field_publish_to']['und']['#options'] = $vendor_list;
    }
}


texts: How do I override the HTML output of a theme function?

texts:
Let say we have theme function in module A theme_super_a(), this function returning some HTML. I want to write function in my own module (let's call it B) where I can get output of theme_super_a() manipulate it and return back to Drupal theme system. How can I do it?

Notice that I'm not interested in overriding whole theme with hook_theme_registry_alter(&$theme_registry).


texts: How to make contents public or private based on flags

texts:
I have two flags in my privacy profile settings to make contents public or private, I have two content types called 'videos' and 'albums' and two flags called 'keep my videos private' and 'keep my albums private'. I have provided user menu links as 'my videos' and 'my album' on user profile page. When other users see my profile they get these links (above mentioned) visible and they can view all my video & albums. Now what I want is when I flag my contents (using flags mentioned above) to be private, the menu links should be hidden on my profile page so that other users would not be able to see my profile. I have written below code in the menu custom block but not getting how to make contents(videos ,albums) private or public based on flagging.How can i do that?

global $user; $user_uid=arg(1); $flag=flag_get_flag(flag_name);

if($flag_is_flagged($user_uid)) { do stuff here......... }


texts: Cannot see user_stats module logs in drupal site

texts:
I have used  User Stats Module for the purpose to find the users login count till date.
I am able to see the data in database but can't find the logs in my drupal site.

I have checked in "Reports" but can't see. Please help.


texts: Push data to dataLayer on Webform Ajax submit

texts:
I'm using the Webform Ajax module to ajaxify my Webform and I need to push some data to the dataLayer to use with Google Tag Manager after a successful submit.

Like:

dataLayer.push({
  'event': 'Submitted',
  'page': 'Contact'
});

Is there a simple way of doing that?


texts: How to make payments on recurring product automatically(RESOLVED)

texts:
I have drupal 7 and commerce modules. I'm using Stripe payment system with module commerce_stripe. Customer's card details are stored in file (commerce card in file).
Site sells recurring products.

My question is:
can I make payments on recurring products automatically without user agreement?
And if I can how should I do it?

Thanks in advance.

UPDATE

Found how recurring entities and card on file work. After user bought subscription first time his card data saves into file to use it in later payments. When user should pay for subscription again cron commerce_recurring_cron should run. This cron checks recurring entities and if it's time to pay creates an order with status pending.

When this cron runs once again it charges payments and necessary amount of money debited from users account.

So everything I need is processed and my customer is happy.


texts:
I've created an API using the Services Module (by way of the Services Views Module) that I am accessing via a Single Page Application. In this application, users need to be able to download a selection of files.

This selection of files has been setup in a view that make available to the app using the Services Views Module. When I access the api in my app, I can get all off my data fine but I run into an issue when I try and download movies and pdf's.

Is there a special formatter I need in order to make files downloadable via my api?


texts: Views filter that alternates content types?

texts: Does anyone know if it's possible to have a view that alternates between content types? Aka show 1 of content type news and then 1 of content type article repeating?


texts:
I want to generate meta tags on panels node pages. I am adding Meta tags using nodewords module, it works fine on other node pages except panels generated layout.

Any workaround for this?


texts: Creation of a Grid/Matrix using views in Drupal 7

texts:
Does anyone know of a good way to automate the creation of matrix/grids/tables like this?

Basically what I'm trying to accomplish is to create a grid that can show links to other nodes  based on an entity (or node) reference.

There could be many of these grids on the site so I'm trying to figure out an automated way to create them (i.e. go to a page like /grid/1/3 and the 1/3 tells the page what columns and rows to pull in - and then based on references how to fill the grid)

It's a little confusing to get across what I mean but hopefully it's understandable.


texts: Auto Post to Google + from RSS Feed Content

texts:
I am using Drupal 7. I used Feeds module for content from the RSS. So i can get the content from RSS Feeds. Now Feed Content types automatically saved with RSS Feeds content. So now I want to auto Post the Feeds content to the twitter,linkedin and facebook.I am using Twitter module.

So i can Auto post the content using rules module to Facebook.
Same Time I Can Auto Post the content using rules module to twitter..

Now I want to auto post the content to Google + also.I am using Google plus for Google+ connect to my drupal site. After saving my new node display the google+ icon and sharing option also. Same time I want to Auto post the the new node to Google+ Page.


texts:
I have a list of Authors listed as taxonomy terms .
 I also have a view list of Contents named Topics

I need to display the taxonomy terms of Authors in a View block (lets say in the home page).
and then link each term to its related content view page (displayed as List).

Thanks in advance.


texts: Using jQuery $.ajax() on my site won't work

texts:
This is the first time for me to use the jQuery $.ajax() in Drupal. The code is a simple test code but it keeps going to the error: section instead of success:. Could my url path be wrong? The .js file and the test-ajax.php file are in the same folder named "code".

    //This is Javascript
    $.ajax({
        url: 'code/test-ajax.php',
        data: 'a=hello&b=world',
        type: 'POST',
        success: function(data){
            alert(data); //Should return "hello, world"
        },
        error: function(){
            alert('FAIL'); //Keep getting "FAIL". It's like it can't find the php file.
        }
    });

Nothing fancy inside the file test-ajax.php:

<?php
$a = $_POST['a'];
$b = $_POST['b'];

echo "$a, $b";
?>

EDIT: To avoid confusion on the paths (I keep it organized):

Main theme files: <templatename>/<.info, template.php, style.css, etc.>
Template files: <templatename>/templates/*.tpl.php
AJAX files: <templatename>/code/<PHP and .JS files>


texts: How capture video thumbnail , when video is uploaded under media video type file?

texts:
I'm using Core media module to upload video[Media Type is video,which has field video of 'file field type'].
This module will refer video.png as thumnail for all video uploaded from the local system.

I want to capture first frame of video as thumbnail when video is uploaded from the local system in media section.
I have seen 'PHP ffmpeg' , module , But i don't know the approach to follow to capture first frame of video.
 If i need to write a custom module to capture thumnail while saving media type of video, which hook function I need to use or please suggest me what apprach I can follow?


texts:
Drupal 8, Paragraphs Version: 8.x-1.12, ERR Version: 8.x-1.8
I created a custom paragraph type. I then added a field on a node type that referenced that custom paragraph. Adding the paragraph and saving it in that nodes edit form works great. When I click 'remove' or, after, 'confirm removal' not only is it not removed from the database, no delete or pre-delete hooks are run. If the node edit form is reloaded, the paragraph is back with  the values it had before 'remove' or 'confirm removal'. If i remove and confirm removal and save the node, again, no delete or predelete hooks are run, but if the node edit form is reloaded, the paragraph appears removed. However, it still exists in the paragraphs_items_field_data table. If i just delete the entire node, the paragraph still exists in paragraphs_items_field_data.
What is the reason for this behavior? Is it because you could still restore an old revision of the node after deletion?
How do I canonically delete a Paragraph? Can it only be done programmatically?


texts: Use Views to delete a record from the database

texts: I have created a view that displays userpoints info. What I need is to create a link that will delete or reset individual records.


texts: Computed field : Count number of elements in multiple entity reference list

texts:
I have multiple entity reference field in the user form. I just want to do the sum of each element checked by the user in its profile.

I made this code but it doesn't work (I don't really know php actually) :

$entity_field[0]['value'] = $Balance;

$modeling_softwares = count(field_get_items($entity_type, $entity, 'field_3d_modeling_softwares'));
$database_sofwares = count(field_get_items($entity_type, $entity, 'field_database_management_softwa'));
$sig_softwares = count(field_get_items($entity_type, $entity, 'field_geographic_information_sof'));
$operating_system = count(field_get_items($entity_type, $entity, 'field_operating_system'));
$vector_graphic_softwares = count(field_get_items($entity_type, $entity, 'field_vector_graphics_softwares'));

$Balance = $modeling_softwares + $database_sofwares + $sig_softwares + $operating_system + $vector_graphic_softwares


texts: Login form - hook_form_alter destinations broken

texts:
I have a custom log in template along with some alterations. It seems to work just fine everywhere except where I have ...?destination=foo/bar.

The template code is:

    <?php print render(drupal_get_form('user_login', $form)); ?>

Don't have an account? Register now

    <?php print render(drupal_get_form('user_register_form')); ?>

The module code is:

function fdanconia_menu(){
  $items['login'] = array(
    'title' => 'Login',
    'page callback' => '_fdanconia_login',
    'access callback' => true,
  );
  return $items;
}

function fdanconia_theme(){
  $themes = array(
    'fdanconia_login' => array(
      'template' => 'fdanconia_login',
      'arguments' => array(),
    ),
  );
  return $themes;
}

function fdanconia_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  switch ($form_id) {
    case 'user_login':
      // Redirect users to the new login page
      if (isset($_GET['destination']) && $destination = $_GET['destination']) {
        $options = array('query' => array('destination' => $destination));
        unset($_GET['destination']);
      } else {
        $options = array();
      }
      if (arg(0) == 'user' && !$user->uid) drupal_goto('login', $options);
      $form['name']['#description'] = 'Email';
      $form['pass']['#description'] = 'Password';
    break;
    case 'user_register_form':
      if (arg(0) == 'user' && !$user->uid) drupal_goto('login', array('query' => array('destination' => $destination)));
      $form['account']['name']['#type'] = 'hidden';
      array_unshift($form['#validate'], '_fdanconia_login_validate');
    break;
  }
}

function _fdanconia_login() {
  drupal_add_css(drupal_get_path('module', 'fdanconia') . '/fdanconia.css');
  drupal_add_js(drupal_get_path('module', 'fdanconia') . '/fda.js', 'file');
  return theme('fdanconia_login');
}

function _fdanconia_login_validate($form, &$form_state) {
  $email = $form_state['values']['mail'];
  $form_state['input']['name'] = $email;
  $form_state['values']['name'] = $email;
  $form_state['complete form']['account']['name']['value'] = $email;
}

So, when I log in with a destination no matter what it redirects to the default log in page as if there were no destination parameter. However, the destination shows up in the URL. I can even manually put a destination in the URL and when I submit the form, I am not redirected to the proper destination. There is nothing in watchdog about the log in other than a session has been created.

What is going wrong here?


texts: How to subtract the node getChangedTime from 1 year

texts:
I created a field that display a nodes last changed date using hook_form alter like this.

function demo3_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'node_page_edit_form') {
   $node = $form_state->getFormObject()->getEntity();
   $form['field_message'] = array(
     '#type' => 'item',
     '#title' => t('Changed date'),
     '#markup' => format_date($node->getChangedTime(), 'medium'),
   );
}

I need to create a new field underneath it for the Review date. This field needs to subtract the getChangedTime from a period of 1 year or 365 days. So if the changed date was 30 days ago. The Review date will be 335 days and display in a medium format.


texts:
Possible Duplicate:
  How do I print a view table?

I'm using drupal 7.
I have already asked for printing views tables but no one answered me.
I used print module but does not support printing views.
What can i do to print the table?
There is any why?


texts: Listing Active Members of Current Group in View pane (OG 7.x-2.3)

texts:
I am relatively new to Drupal and somewhat boggled by the new version of Organic Groups. We recently migrated our site from OG 7.x-1.4 to OG 7.x-2.3. Everything went fine except certain view panes no longer work. We had one view content pane that listed the members of the group in a page based on the context. We created a panel page for the group home page layout when the content pane was embedded in that page it would show the members for that group. However, the contextual filter for that view was broken after the import.

I tried to copy the view settings from a clean install of the latest OG code but that didn't work. The view is one of users but I cannot figure out how I should set the contextual filters or the relationships of that view to show only the members of the group. I just can't seem to wrap my head around how the OG_Membership object works.

Any help would be greatly appreciated.


texts: how to pass a parameter to a route of type _entity_form

texts:
With some help I could create a route to an extended register form: as this form is an "entity form", my route have this type and the definition of this new form has been made in hook_entity_type_alter

The last part of the path of the route is a role name; and the user submitting this form (registering itself) should get this role.

Here is the code:

1-Extending the register form

class RegisterByRole extends RegisterForm
{
    public function form(array $form, FormStateInterface $form_state, $role = null)
    {
        $form = parent::form($form, $form_state);
        if ($role) {
            $form['test'] = [
                '#markup' => '<p>Test:' . $role
            ];
        }
        return $form;
    }
}

2-Adding a new entity form to the entity_type definition/annotation

function my_module_entity_type_alter(array &$entity_types) {
    $entity_types['user']->setFormClass('role_registration', 'Drupal\my_module\Form\RegisterByRole');
}

3-Creating the route

my_module.register:
  path: '/register/{role}'
  defaults:
    _entity_form: 'user.role_registration'
    _title: 'Register by role'
  requirements:
    _permission: 'access content'

Unfortunatly, the $role parameter is not transmitted...


texts:
I make a custom Entity content module, and for a field i want ckEditor.

Here my code for this field :

$fields['description'] = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Description'))
    ->setRequired(true)
    ->setDisplayOptions('view', array(
        'label' => 'above',
        'type' => 'string_textarea',
        'weight' => -4,

    ))
    ->setDisplayOptions('form', array(
        'type' => 'string_textarea',
        'weight' => -4,
        'settings' => array(
            'placeholder' => 'Description de votre annonce',
        ),
    ))
    ->setDisplayConfigurable('view', TRUE)
    ->setDisplayConfigurable('form', TRUE);

  Type : string_textarea

How can i tell Drupal 8 to get the widget for textarea basic html mode ?


texts: After Drupal 7.32 should sql injection attempts create PDOExceptions?

texts:
I have the Logging and Alerts module installed on a few of my sites. Yesterday I noticed a series of notification emails with the following data. These produced PDOException exceptions and so far as I can tell were unsuccessful at doing anything malicious.

This site was patched hours after SA-CORE-2014-005 was announced on 2014-Oct-15.

I simply want verification that these types of SQL injection attacks create PDOExceptions in Drupal, vs stripping the offending key/values from the injection attempt. Prior to the patch I wasn't receiving any such errors.

Email Title from LoggingAlerts module:
[] Error: PDOException: SQLSTATE[42000]: Syntax error or access...

Email Message Body:
admin@site.com  Mon, Nov 17, 2014 at 11:04 AM
To: admin@site.com
Site: https://site.com
Severity: Error (3)
Timestamp: 20141117 11:04:35
Type: php
IP Address: 128.xxx.xxx.xxx
Request URI: https://site.com/?q=user/login
Referrer URI:
User: Anonymous (0)
Link:
Message:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You
have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ' 'test' AND status =
1' at line 1: SELECT * FROM {users} WHERE name = :name_0, :name_1 AND status
= 1; Array
(
[:name_0] => test3
[:name_1] => test
)
in user_login_authenticate_validate() (line 2149 of
/var/www/mysite/htdocs/modules/user/user.module).
$_SERVER => Array
(
[HTTP_HOST] => site.com
[HTTP_X_REAL_IP] => 198.101.235.xxx
[HTTP_X_FORWARDED_FOR] =>

... lots of more lines of email output ...


texts: Add comment with Inline Entity Form while adding content

texts:
I'm creating a content type. and want to add comment for the same content on same form of add content.

I've installed Entity Reference, and selected Entity reference as Field type & selected Inline entity form - multiple values as the widget. I've chosen Selected Target type Comment under FIELD SETTINGS and I'm still not getting the comment section on content addition form.

Why is it not showing? Is there another way to show comment on content addition form?


texts: Display Vocabulary (VID) From Selected Field

texts:
I'm trying to print out the selected vocabulary from a content type on a page.  As the previous user did not use views for this layout, I need to find a way to add it.

Here is my code so far.

foreach ( (array)$node->taxonomy as $term ) {
        echo $term->name;
    }?>

Right now, it shows all of the terms that are listed in my taxonomy. Is there a way to narrow this down? to only show selected vid?

Regards,


texts: How do I strip HTML markup or use plain text in the body field?

texts:
I am using a view to create a block that display a set of data. The data appears as expected, but it shows HTML markup between body fields, which I want to strip or render as they are like in nodes. I am using hook_views_pre_render(), but I am not able to strip HTML markup with that.

How can I achieve this? Is there any view settings for removing HTML markup?


texts: How to fetch the content author name with views in twig?

texts:
I am unable to fetch the content author name inside the twig template thorough views.

Below is what i did so far :
- Created a relationship under the advanced tab in views and added the Authored by field.

I can see the author in the preview section of the view but since i have overridden the template with views-view-filed i cant fetch it in twig with {{ fields.author.user.name}}

Kint is not of much help as its freezing the browser.


texts: What should I use in Drupal 8 instead of votingapi_set_vote()?

texts:
VotingAPI docs are out of date. votingapi_set_vote() has been removed in Drupal 8.

What should I use in its place to programmatically set votes (for instance in a migration)?


texts:
I'm trying to skip delete confirmation page only for a content type in my site.
I found this question but I can't figure out how to modify this code to affect only a nodes in a content type.
This is the code i found:

function mymodule_menu_alter(&$items) {
  $items['node/%node/delete']['page callback'] = 'my_node_delete_function';
  $items['node/%node/delete']['page arguments'] = array(1);
  $items['node/%node/delete']['module'] = 'mymodule';
}

function my_node_delete_function($node) {
  // Taken from node modules node_delete_confirm submit handler
  node_delete($node->nid);
  watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
  drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));

  // Do a drupal goto here to preserver the 'destination' parameter
  drupal_goto();
}


texts:
After a user shops in my Ubercart store, I would like to automatically send an email to the user and offers a discount on next buy, and also say that this discount is only valid for a time.

Do anyone know how to do this?


texts:
I am confused by this one.

I want the translator service injected in my service. The closes thing I've found is this one: Drupal\Core\StringTranslation\TranslationManager; ( https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StringTranslation!TranslationManager.php/class/TranslationManager/8.2.x) but it has no method "t" and it really makes emphasises to not use it's translate function, to use \Drupal\Core\StringTranslation\StringTranslationTrait; instead. But I can't inject this in my service, can I? (how?)

Ultimately, I just want to call t function in my own service.


texts: Displaying one node for each unique field reference in View (e.g. one videogame for each developer)

texts:
I have an view that display my custom content type (e.g. covers of video game titles).

Lets assume that I have this structure for my content types:

developer
|--title
|--country
...

video game
|--title
|--body
|--developer_ref (term reference, as choice list)
...

It works ok except for one thing. I want to display only one video game per developer here (the newest one).

So for example, if we have 3 different developers I want to display 3 items and each of it its the latest node referenced to each developer.

I know how to display 3 latest nodes, but that way they can e.g. all come from one developer.

I have already tried with agreegation on video game.developer_ref field:

But I don't know why it doesn't change a thing (I still see multiple games for some developers).


texts: Is there any way to connect Acquia Cloud intance with issue tracker?

texts:
As in question, I'm looking for a way to connect any issue tracker with a development site hosted by Acquia Cloud.

I want to have a connection between git commits and issues.

Is this possible in Acquia?


texts:
How to define column css in views?

I testing a theme. I tried edit the css from CSS class one-half to one-fourth. The layout changes successfully from half column to fourth column.

I wondered how the CSS define.

I looked into the views but can't find the css added (one-half)


texts: Drupal 7 - repication breaks with "Error 'Can't create database "

texts:
we are having replication issues (we are on Drupal 7, have 2 masters and 1 slave). Several times a week and sometimes a day replicaton breaks. This happens when we drop a database and then create it (creating new sites basically). We see the following errors in the logs:

  [ERROR] Slave SQL: Error 'Can't create database 'cmssite3gwuedu';
  database exists' on query. Default database: 'cmssite3gwuedu'. Query:
  'CREATE DATABASE `cmssite3gwuedu`', Error_code: 1007

And then replicaton breaks. At this point we have 99 databases and will have more. Moreover, these databases are created by Aegir tool. I understand that these types of issues are cased by replicating everything - temp data, cache, etc and that those should be omitted from replicaton. The solution that I found is to basically specify the database that you wand and do not want to replicate and ignore cache, watchdog and temp tables. Like this:

binlog-do-db=<strong>DrupalDB
</strong>   # A database you do NOT want to replicate
binlog-ignore-db=DontReplicateThisDB
   # Don't replicate the "mysql" database itself (i.e., local MySQL config)
binlog-ignore-db=mysql
server-id=1
sync_binlog=1
#Minimizes the number of changes you lose if a problem occurs down to 1, reference
#max_allowed_packet = 16M
max_allowed_packet = 32M
#
   # Don't replicate Drupal cache, watchdog, temporary search data
replicate-wild-ignore-table=DrupalDB%.cache%
replicate-wild-ignore-table=DrupalDB%.watchdog%
replicate-ignore-table=DrupalDB.temp_search_sids
replicate-ignore-table=DrupalDB.temp_search_results

The problem with this solution is that we have 99 databases and more will be created later. Do we have to specify all 99 in replicate-wild-ignore? Will this work? Has anyone faced the same issue (having multiple databases). I understand that mysql database should not be replicated. Thank you for any input!


texts:
I have a Drupal 7 site and all seems to be working well except for one problem I have just discovered.

Users can login via the login block on the home page with no problems.  However, if they go to the /user page and attempt to login they are returned to the same /user page without being logged in.  No error message is displayed.

I have tried emptying the sessions table but that didn't work.

I have also noticed that, occasionally, when I go to the /user page I get a message saying that the one time login link is invalid.  On those occasions I was not trying to access a one time link.