texts:
I'm not sure how much sense this makes as I've confused myself so much trying to do this.

I'm using Drupal 7.28 and the Drupal Commerce 7.x-1.9.

Basically the image and the description fields are both on the Product Type not the content type as each product has its own description and image.

In my view I now need to add the image field, but I can't add it, which I believe is because the field isn't in the content type.

When I add the 'Content: Referenced Products' relationship to the view, I am then able to add the image field to my view.

However when I then select to link this image field to the original content, the field links to the admin page where I edit the product - not the content type node that is displaying the product.

Also, after adding the image field, the view lists the image for every single product variation whereas I just need one image that links to the node.


texts: More multiple add to cart buttons drupal commerce

texts: I want to be able to have multiple add to cart buttons on 1 page for example for selling music like this. Example!


texts:
I'm using images inside of a Paragraph, and trying to use checkboxes in the Paragraph to control whether to display the credit and/or caption of the images.

The problem is that the image gets cached the first time it loads and subsequent instances ignore the checkbox values.

I'm trying to set that cache keys so that each Paragraph + image gets its own cache instance, but keep getting errors saying that I'm not allowed to set cache keys.

I've tried in hook_media_preprocess, hook_paragraph_preprocess, hook_entity_view, hook_entity_view_alter, but no luck.

Could someone point me in the right direction?

Thanks,

Luca


texts:
I want to send a unique code to the user after registration. I know how to do custom modules. Also in the mail text send to the user I can see there are variables such as [user:name]. Should I define a variable and send it to the user?

Any help will be appreciated.

Thanks


texts: show fields after adding joins in hook_views_query_alter

texts:
I managed to programmatically add tables/joins in hook_views_query_alter() like this:

$td_join = new views_join();
$td_join->table = 'taxonomy_term_data';
$td_join->field = 'tid';
$td_join->left_table = 'audience_node_og_mvh_ti';
$td_join->left_field = 'tid';
$td_join->type = 'inner';

$query->add_relationship('audience_node_og_mvh_ti_td', $td_join, 'node', 'audience_node_og_mvh_ti');

When I go to edit the view and check the "auto preview" I can see that the generated query is correct:

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, audience_node_og_mvh.title AS mvh_title, audience_node_og_mvh_ti_td.name AS field_data_field_cv_node_entity_type
FROM
{node} node
inner JOIN {field_data_group_audience} audience_node ON node.nid = audience_node.entity_id
inner JOIN {og} audience_node_og ON audience_node.group_audience_gid = audience_node_og.gid
inner JOIN {node} audience_node_og_mvh ON audience_node_og.etid = audience_node_og_mvh.nid
inner JOIN {taxonomy_index} audience_node_og_mvh_ti ON audience_node_og_mvh.nid = audience_node_og_mvh_ti.nid
LEFT JOIN {taxonomy_index} audience_node_og_mvh_ti_audience_node_og_mvh_ti ON audience_node_og_mvh_ti.nid = audience_node_og_mvh_ti_audience_node_og_mvh_ti.nid
inner JOIN {taxonomy_term_data} audience_node_og_mvh_ti_td ON audience_node_og_mvh_ti_audience_node_og_mvh_ti.tid = audience_node_og_mvh_ti_td.tid
WHERE (( (node.status = '1') )AND( (node.type IN  ('johndoe')) ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0

But somehow I can't figure out how the new fields in the query (the ones from the joins) can be shown in the view itself.

Does anyone know how to do this?


texts: Webform Submission & Commerce Order Database Relations

texts:
Where is the relation between Webform Submission ID & Commerce Order ID in the drupal database?

The problem is one of my orders crashes after editing the webform so I guess that the relation between the order and the webform crashes in the database.

I've seen commerce_ and webform_ tables but I didn't find anything.


texts: How to vote for both answers and question using the Answers module?

texts:
I am using Answers module. In that only for nodes of type Question I can add vote up/down field.

But I wonder how I can add a voting feature for the nodes of type Answer?


texts: Various shape drawing with CKEditor in drupal 7?

texts: Is there any way to draw various shapes (circle, triangle, rectangles) like MS-Office-Word/Paint shapes in the CKEditor. I tried to find the plugin, but could not. Is there anyway.


texts: http://example.com/node/111 also accessible through http://example.com/node/111.000

texts:
An acunetix scan has complained about the following:

http://example.com/node/111.000 or http://example.com/node/111.0 or http://example.com/node/111.000000 (any number of zeros) serves the node http://example.com/node/111

For the regular url, the pathalias is then used, for the url with .0 added, it is displayed as is.

Two questions: is it possible to disable this behavior, and if not, is there a standard reference to justify this to our security team?


texts:
I'm working on a design heavy site and one of the sections created via the Paragraphs module requires to display the user_register form.

I'm currently doing this in the paragraphs-item--myparagraph.tpl.php file with the following code:

<?php
  $form = drupal_get_form('user_register_form');
  print drupal_render($form);
?>

This works for showing the form but the problem is that if there are form validation errors, they don't show. I have read that the issue is rendering the form too late but I can't see how I adapt this to Paragraph entities. I have tried using mytheme_preprocess_entity to pass the form in but I can't render it?


texts: How can we register a CSV data migration dynamically?

texts:
I am trying to achieve CSV data migration like below:

Requirement:
CSV file will be pushed to our server on daily basis from other vendors. We have to fetch that particular CSV file and we need to migrate the CSV data into content to our website.

Tried: I installed migrate source csv, migrate tools and migrate plus.
I created a below YAML structure for the same and I imported through configuration synchronisation.

YAML structure:

langcode: en
status: true
id: article_csv_import
migration_group: default
label: 'Import articles'
source:
  plugin: csv
  path: 'public://customfiles/file.csv'
  delimiter: ','
  enclosure: '"'
  header_offset: 0
  ids:
    - id
  fields:
    -
      name: id
      label: 'Unique Id'
    -
      name: title
      label: Title
    -
      name: body
      label: 'Post body'
process:
  title: title
  body: body
  type:
    plugin: default_value
    default_value: article
destination:
  plugin: 'entity:node'
configuration: {  }

As you can see the path: 'public://customfiles/file.csv' in the YAML structure this is a static way to do the migration. But what I am looking out is dynamically registering our migration. Everyday filename will be changing and I have to fetch the filename and update in YAML dynamically.
I referred this particular link but i didn't get what i was in need of:
Please suggest a approach for the same. Any suggestion will be appreciated.


texts:
Recently I got in to an issue that I can't login to the system. I tried to clear the cache and reviewed all the permissions. I logged in via one time password url created by drush uli and then changed the admin password and then tried to login . Still no luck. Even when I created a new user/modified the password of existing user and tried to login, still login not working.

I tried the same scenario in an incognito window too and not working.

I have another server in the same network with the same admin and users, and with same permissions. It is working with no issues.

I had a database backup from earlier, when I restored the db first time the login is working. But then after logout it's not working.

Is it related to some caching or permission issue? If someone can give any insights it will be great.

When I checked in to the core module (user) and not getting the username in the validateName validate function , but am getting the password though. Any idea of this strange behaviour ?

in UserLoginForm.php

/**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('system.site');

    // Display login form:
    $form['name'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Username'),
      '#size' => 60,
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#description' => $this->t('Enter your @s username.', ['@s' => $config->get('name')]),
      '#required' => TRUE,
      '#attributes' => [
        'autocorrect' => 'none',
        'autocapitalize' => 'none',
        'spellcheck' => 'false',
        'autofocus' => 'autofocus',
      ],
    ];

    $form['pass'] = [
      '#type' => 'password',
      '#title' => $this->t('Password'),
      '#size' => 60,
      '#description' => $this->t('Enter the password that accompanies your username.'),
      '#required' => TRUE,
    ];

    $form['actions'] = ['#type' => 'actions'];
    $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->t('Log in')];

    $form['#validate'][] = '::validateName';
    $form['#validate'][] = '::validateAuthentication';
    $form['#validate'][] = '::validateFinal';

    $this->renderer->addCacheableDependency($form, $config);

    return $form;
  }

    /**
       * Sets an error if supplied username has been blocked.
       */
      public function validateName(array &$form, FormStateInterface $form_state) {
echo $form_state->getValue('name');exit; //not getting this though
        if (!$form_state->isValueEmpty('name') && user_is_blocked($form_state->getValue('name'))) {
          // Blocked in user administration.
          $form_state->setErrorByName('name', $this->t('The username %name has not been activated or is blocked.', ['%name' => $form_state->getValue('name')]));
        }
      }


texts: Hide Content Type Default Pages from Search Results

texts:
I have multiple content types where users enter data that I consume in views and create pages from.

I want to exclude some of these default content type rendered pages from the search results, but do not want to exclude the content and the views page where the results are.

For example, I have Basic Page Content Type and want to see any basic page content. I also have Custom Page Content Type and want to see these fields, but not the default rendered page, just my View created page that consumes the Custom Page Content Type fields.

Where do I set this up or how do I set up search to handle this type of need?


texts: hook_views_post_execute already has rendered fields

texts:
I have a view with a date field that I would like to move back a few minutes e.g. $timestamp - 60.

I run hook_views_post_execute() but, when I look at $view it already has rendered markup in it:

$view->result[0]->field_field_end_date[0]['rendered']['#markup'] ==>> '0 sec

The documentation states "This hook is called right after the execute process. The query has been executed, but the pre_render() phase has not yet happened for handlers."

What gives?

To solve this problem. I need to add/subtract from the "raw" value before it is rendered.

How can I do this?

Thanks.


texts: Ckeditor can not create new profile with input format

texts:
I've already a profile with input types but I can not create another, even when I am cloning the profile with input types.

These are my text format, and I using administrator user.

This is the list of ckeditor profiles

In Test profile, the only text format allowed is PHP code.

What could it be?


texts: How do I get the placeholder attribute into a Search API Solr Search field?

texts:
I'm using Search API Solr Search and can't seem to get a placeholder attribute in it. I've tried using hook form alter as I would on a normal search block, but doesn't seem to work with search api solr.

The id of the form = views-exposed-form-recipe-find-recipe-find-list
The name of the search input field = search_api_views_fulltext

I've placed this function in my theme's template.php...

function marigold_institute_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form_recipe_find_recipe_find_list') {
    $form['search_api_views_fulltext']['#attributes']['placeholder'] = t('Search by name or ingredient');
  }
}

I'm not quite sure what I'm doing wrong. This is the first time I've tried using hook_form_alter, so I could easily be missing something obvious. I tried the function on a normal search block using "search_block_form" for the id and name, and it worked. I just can't seem to get it working with search api solr search.


texts: How to convert a webform to a content type?

texts:
I have a long webform with about 90 textarea fields modeling a report item. Since the requirements of my Drupal site have changed, the report is now part of the content and should have workflow and other content type functionality.

So I want to convert my webform with its 90 fields to a CT. I know this will raise some problems regarding the performance, but I was thinking to overcome them by reusing some textarea fields (e.g. by putting them in different field collections in the same content type and changing their title and description only per field instance).

Is there an easy way to convert my exported webform with its fields to a content type with the same fields? Or should I do it manually?


texts: Given a taxonomy term id, how do we get the value of other fields; specifically the machine_id?

texts:
A good example of getting the children is posted How to get fields...

I need the machine_id of the parent (or target)

Code below fetches the name;

$product_name_id = $product_name_reference->getValue()[0]['target_id'];
$product_name = \Drupal\taxonomy\Entity\Term::load($product_name_id)->label();

The machine_name is visible under 'values'. How do I get it!


texts: How to create a content-type with "sub-pages" that are default and/or custom per node

texts:
I'm in the process of planning a Drupal 7 site-build that will make use of what we're calling 'sub-pages' or 'minisites.' Essentially, as you can see in the wireframe below, we'll have a page for each Doctor, and each doctor page will have a sub-nav.

Here are some requirements;

This sub-nav will link to pages with the url structure 'doctors/[doctor-name]/[sub-page-title]'.
Sub-pages like 'Biography' are populated via fields on the node.
Sub-pages like 'News' and 'Case Studies' are populated via contextual Views (based on references from these content types).
Sub-pages like 'Community' are completely custom and unique to each doctor. Another doctor may have a 'Family' sub-page instead.
The header above the sub-page should stay the same on every sub-page.
Content managers should be able to easily add additional custom sub-pages.
The site is being built utilizing the Panels suite (Panels Everywhere included).

What's the best way to accomplish this? I've fielded suggestions like 'use the Book module', but I wanted to get some feedback from the larger community before I start down a path that leads to a "90% solution."

Update (Includes my solution)

I've decided to pursue the Organic Groups route, as OG and its suite of modules have value in other areas of the site's architecture. In order to meet my requirements I've had to introduce a few additional modules (benefits included);

OG Menu

Configured to automatically create a menu for each 'Doctor' (an organic group).

OG Menu: Default Links (Submodule)

Configured to provide default menu links to views standard for any Doctor. When a Doctor is created, they'll automatically have menu links like 'News' and 'Case Studies'.

Rules

When my content managers create a new Doctor Page (organic group content to the Doctor Group), I made a custom rule that adds a menu link entry to the referred group menu (provided by OG Menu).

Sub-pathauto

We want URLS that are aliased to match the pattern 'doctors/[doctor-name]/[doctor-page-title]'. This modules lets me do that easily (doctor/[node:og_group_ref]/[node:title]).

OG Role Override

I need all content managers to edit and assign content to all Doctor groups. This module lets me do that easily.

Panels

General layout, but also overriding layout for Doctor Pages and default links that direct to views.

All-in-all, I have exactly what I need and didn't write a line of code.

Update Nov 16

This feature was sent out to pasture. Sad Panda. :`(


texts:
There are lot of tutorials on Internet about how to display menu, but no one works for me.
I have tried:

$menu_array = menu_navigation_links('menu_menu-login-menu');
print theme('links__menu_login_menu', array('links' => $menu_array));

print drupal_render(menu_tree_output(menu_tree_all_data('menu-login-menu')));

Both don't work.

My menu looks like this.


texts: Problem with inline images after migration

texts:
We recently migrated from D7 to D8 (8.7.6). The migration went OK with the exception of nodes with inline images in the body fields (see the attached screen shot). The images were created in D7 with the CKEditor/Media Browser.

I have searched for contrib modules that can help with this issue but have not found anything yet.  Any suggestions would be appreciated.


texts:
I am upgrading a site from Drupal 6 to Drupal 7, following the instructions here: https://www.drupal.org/node/570162

When running update.php it gets stuck on the first step 'Updating user module' at 0%. I'm wondering if this might be because the site has about 400,000 registered users (another issue there I need to fix), or if something else is going on to prevent it from updating. Perhaps the message

Notice: unserialize() [function.unserialize]: Error at offset 416 of 427 bytes in variable_initialize() (line 935 of /services/webpages/util/5/4/54ev547u.myutilitydomain.com/livemusicashland.com/ifollo/public/includes/bootstrap.inc).

has something to do with it? It's my first attempt at updating from one major Drupal version to another, so I'll take any advice I can get. Thanks!


texts: db_select get all results count when also using a pager

texts:
Is it possilbe to get the count of all rows, when using a pager in a db_select query?
 My pager is the following:

$query = $query->extend('PagerDefault')->limit(20);


texts: Could some one tell me how I increase the weight of an order total using rules and ubercart module?


texts: Aggregate / average 10 fields from 300 nodes and display on a page

texts:
I have about 250 nodes of data (which will probably grow to 300) which I want to aggregate so that the user can see the average value for each of the fields. Each node would contain about 40 fields but I would only need to show about averaged values of 10 of these at any one time. The final view (or page) I wish to produce would therefore show 10 fields in which the data was the average of the fields in the 250-300 nodes. There would be 4 similar pages, each drawing a new set of 10 fields from that 250 nodes to average.

I would like to know what a workable solution producing this might be. It is not going to be a high traffic site, and would probably only receive a handful of views per week. Therefore optimizing the efficiency of this operation is not as crucial as it might be. However a solution that was efficient and simple would be preferable :)

I considered drawing all 250-300 nodes into a view and using the views calc module to create the averages of each field. I would hide the original data and only show the 10 pieces of averaged data. From looking at views calc this seems like it should work, but it also seems inefficient. Can anyone give an opinion on whether this approach would work or suggest better solutions?


texts: drupal 7 parent menu item will not hide for authenticated user

texts:
Could any one give me some ideas on what i need to check please?

I wish i could just show the site, but of course it' for my company, so I can't,  but I have a menu bar at top of my page home, contact, meet the authors, books;

Under "Meet the authors", i have several authors, I created an authors content type and have one for each author. When you hover over "Meet the Authors" you see the drop-down list/sub-menus of the authors - only five of them now.

so using panels and views, when you click of "meet the authors" you see a list of the authors on the page and can click in for more detail.

Using the access control module, I only want this link to appear for anonymous users, once logged-in, this link should disappear but the link will not hide itself after login, but here is what's really odd, the sub-links which are the authors, those links/sub-menu do/does hide when the user logs in and only displays for the anonymous user

so for example, this enable menu should appear for the anonymous user

Meet the authors
 - ----Kim Fields
 - ----Tony Bruewer
 - ----Harris Carlton
 - ----John Brown

and should be completely hidden for the authenticated user, but what is happening though, upon login, the user sees the parent menu:
Meet the authors

but the sub menus have hidden themselves as they should, i just can't get the parent menu to hide itself.

I have checked the access control to make sure I have selected things properly.  I even created test content type and menus to test and everything worked, so I assume there is something different, but I just can't see what and where.

Any ideas and guidance would be greatly appreciated. Thank you.

Notes: the parent menu about [Meet the authors] is pointing to a panel page that contains a view to display the list of authors.  I do not have access setting on the panel.

More Information:
So for my own sanity, I slowly created another content type, a view for that content type and a panel page.  Saved, cleared cache, ran cron.  Change settings in control access module.  Here is what I now see-- The sub-menus of the parent menu [Meet the authors]are following the authentication rule, the top menu just displays all the time.  I create this mention from the Structure->Menus navigation.  So the top menu item is pointing to the panel whereas the sub-menu items are actually the content types.

Still more Info:
Here is what I think the issue that I still have not found a way around.  I create the view, create the panel, place the view in the panel, give the panel page a normal menu entry.  So that is my menu item that appears.  If I click on that top parent link, it takes me to the panel with my view, but the menu item won't display/hide as needed.  So i realized that the menu I am creating in the panel has nothing to do with the content type and the content type is needed to manage the access control module.  So I go into my content type, change one of it's types and change the menu to point to the panel url I created.  Well when I do that, that url is assigned to that content type node, not panel, but the menu item does, now, display/hide based on the selection from the access control module.

Can anyone give me a way around this?  What i think I need is a way to point one of my node content types to the panel.  Does this make sense.  I love Drupal, but sometimes...


texts: Why are my radio buttons not displaying?

texts:
I'm working on enhancing a search form on a site I inherited. I'm trying to add a radio button set to allow the user to narrow potential search results, but I cannot for the life of me get the radio buttons to display. The label displays, but the buttons themselves do not.

Here's the function in template.php:

function ismiv3point1_search_block_form($form) {
    $form['search_block_form']['#title'] = '';
    $form['search_block_form']['#value'] = 'Search mysite.org';

    $form['submit']['#type'] = 'markup';
    $form['submit']['#value'] = '<input type="image" name="submit" value="Search the Site" src="/icons/search.png" alt="Search the Site" />';
    $form['submit']['#weight'] = 2;

    // this is the new field I'm trying to add
    $form['image_switch'] = array(
        '#type' => 'radios',
        '#title' => t('Image Switch Radios'),
        '#prefix' => '
',
        '#suffix'   => '',
        '#weight' => '3',
        '#options' => array(
            1 => t('Images'),
            2 => t('All'),
        ),
        '#default_value' => 1
    );

    return '

'.drupal_render($form).'

Sort by newest first

Sort by newest first

Sort by relevance

';
}

Here's the rendered source:

<form action="/"  accept-charset="UTF-8" method="post" id="search-block-form">

      <input type="text" maxlength="128" name="search_block_form" id="edit-search-block-form-1" size="15" value="Search mysite.org" title="Enter the terms you wish to search for." class="form-text" />

   <input type="image" name="submit" value="Search the Site" src="/icons/search.png" alt="Search the Site" />
   <input type="hidden" name="form_build_id" id="form-17ad7cfea143f9acf10cca6602a02df0" value="form-17ad7cfea143f9acf10cca6602a02df0"  />
   <input type="hidden" name="form_token" id="edit-search-block-form-form-token" value="65a199ea9da3f7a52ed4c2693012997b"  />
   <input type="hidden" name="form_id" id="edit-search-block-form" value="search_block_form"  />

    Image Switch Radios

Sort by newest first

Sort by newest first

Sort by relevance

</form>

Any ideas? Is it because the field is being added after the submit? The reason for that is because the submit is a graphic (the magnifying glass) at the end of the search box; we want the radio buttons to be positioned below that.


texts:
We have a taxonomy vocab called Phones that goes like this.

Taxonomy: Phones

-Nokia
--3310
--Jitterbug
--7.1
-Samsung
--Galaxy S6
--Galaxy Edge
--S7
-HTC
-- one
--S7
list goes on, but you get the idea.

We also have content types:
-Questions
-Photos

in each of these content types, we add taxonomy PHONE as a field.

The view that we are looking to create needs to show the corresponding content type for each phone based on path.

Which means that if we go to
domain/phone/samsung/s7/questions/

one sees all the questions for the Galaxy S7 but if we go to:

domain/phone/samsung/s7/photos/

one will see all the photos for the Galaxy S7.

How can this view be setup? Especially the path? So that when you go to another phone /questions or /photos it still works.

* BONUS QUESTION *  There are cases where the same model name is used by two phone manufacturers, for example S7 above.  Is it possible to somehow filter by term id? Or dobule filter? Meaning you filter with parent name in url, then filter with term name that matches the parent name? This would be ideal, but if we can't filter by term ID, we will edit those duplicate models so that they don't conflict.

Any help would be greatly appreciated.


texts: How can I use conditional logic to not display a  in page.tpl.php based on node id?

texts:
I'm using a theme that has regions not supported by Panels' "Disable Drupal blocks/regions" settings. I've tried to remove the  using an if statement in PHP, but either my PHP syntax is wrong or I'm not using the correct Drupal variables. Right now the section looks like this:

<?php
    if ($node->nid != 51) {
        echo '
';
            { if ($left) { print $left;}
        echo '
';
 ?>

I have a feeling I'm not nesting the second if statement correctly in PHP though.


texts: Setting a user as an administrator via drush command line?

texts: How can I set a user to a specific role via drush? In my case I want to give the role of administrator to the user.


texts:
Any way to achieve metro style layout for Views items?

E.g.:

I was thinking maybe there are modules or something. Was searching for something like Masonry, but didn't find any.


texts:
We have a view, myview, that is added to the https://www.adomain.com/some-page/ page. It has an exposed filter, Topic that a person can use to filter the user where Ajax = Enabled so that it loads the results without refreshing the page.

The view is added to a landing page (content type = basic) and at the bottom of the page. It is meant to return nodes where topic tag value is equal to what is supplied from the url.

Taxonomy term values (topic):

IoT
Cloud
Cloud Security

How to setup view to filter based on second URL parameter?

Expected behavior:

Display all items when https://www.adomain.com/some-page/ is loaded.
Display all items where topic = Cloud Security when https://www.adomain.com/some-page/cloud-security is loaded
Display all items where topic = Cloud when https://www.adomain.com/some-page/cloud is loaded

Current Behavior:

Displays all items when loading https://www.adomain.com/some-page/
Displays no items when loading https://www.adomain.com/some-page/cloud

What we have tried using block display type:

Create view using block display type with a contextual filter Content: topic
When filter value is not available = Display all results for the specified field
When the filter value is available or a default is provided is set to Specify Validation Criteria = enabled, Validator = Taxonomy Term Name, Vocabulary = topic, and Action to take if filter value does not validate = Display all results for the specified field

What we tried using Page display type:

add path /some-path (without %)
Add relationship, field_topic: taxonomy term and require relationship = true
Add contextual filter: Name from Taxonomy term (field_topic) with the following settings below.

Contextual filter settings:

When the filter value is not in the URL

Display all results for the specified field

When the filter value is in the url or a default is provided

Specify validation criteria = Validator = Taxonomy term name
Vocabulary = Topic
Transform dashes in URL to spaces in term name filter values = true
Action to take if filter value does not validate = Display a summary
Case = Lower case
Case in path = lower case
More = Transform spaces to dashes in url = enabled


texts: Add translation files to custom module doesn't work

texts:
I've created translations files with poedit called nl_NL.mo and nl_NL.po and added them to a 'translations' folder within my custom module.

Now when I try to re-install my module; the translation isn't being imported.

Could this be because my default language is NL or is some other issue?


texts: Custom form to modify only some fields of an EntityForm

texts:
I generated an Entity following this guide. Now I would like to create a custom form to modify only some fields inside a single entity.
I was thinking to create an action inside the controller calling a new/custom form:

I created the routing file to open the form with the specified path (I know I can also create an action inside the controller to open the form with a custom template)
I created the form that extends the main EntityForm:

class DetailedForm extends CompleteEntityForm{
    public function getFormId() {
       return 'detailed_form';
    }

    public function buildForm(array $form, FormStateInterface $form_state){
        $form = parent::buildForm($form, $form_state);
        return $form:
    }
 }

I put some lines of code inside the functions getFormId(), buildForm(), validateForm() and submitForm().

But in the end the result is an error:

  Call to a member function getEntityTypeId() on null in
  \drupal\core\lib\Drupal\Core\Entity\EntityForm.php on line 79 #0
  \drupal\core\lib\Drupal\Core\Form\FormBuilder.php(196):
  Drupal\Core\Entity\EntityForm->getBaseFormId()

Any suggestions?


texts:
What is the proper way to embed a (public) facebook video with the oembed field module?

I tried including a video with a link like https://www.facebook.com/video.php?v=55555555555 but when I tested the link I got an error message (log didn't reveal details).

  https://www.facebook.com/video.php?v=55555555555 is not valid oEmbed URL. Please check the error log for messages.

It also doesn't show up in the content type field.

The default schemes didn't do the trick:

http://www.facebook.com/video/video.php*
https://www.facebook.com/photo.php*
https://www.facebook.com/video/video.php*

So I've added this https://www.facebook.com/video.php?v=* in the media - oembed settings for facebook.

still, it didnt work.

Any ideas on what URL I have to provide for this to work?

EDIT:

I've posted an answer that worked for me.

Ideally, it should work without an embed.ly API key.


texts:
I would like to use the new Cache Tagging in D8 to help keep related content of different types (entities, nodes, blocks, etc) in sync. But from reading the currently available documentation of this feature I do not understand how to add my own cache tag to the items of content when creating/updating said items.

For example when creating a new node of an type Store I would like to add the cache tag location:new_york_123 and the same for a a block. Then if I changed the display name of the New York 123 location to SoHo, I could invalidate the cache tag and have all related content update.


texts: How to add button to webform to set value to a field

texts:
Using Drupal 7 and Webform (both up to date), I'm looking for a way to add a button that when clicked, set the value of a field.

I can add a button using code like this:

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

switch ($form_id) {

case 'webform_client_form_ID':
  $form['alt_button'] = array(
  '#type' => 'submit',
  '#value' => t('Alternative Action'),
);

I now need to figure how to perform the action of changing the value of one of the the webform field when this button is clicked...

Any help will be appreciate!


texts: Why doesn't hook_preprocess_block() alter the block content?

texts:
I'm finding I can't alter block content with hook_preprocess_block() in Drupal 8.  Should I expect to be able to alter content, such as a block body, using hook_preprocess_block()?

For example, this has no effect on my block output:

function mysite_preprocess_block(&$variables) {
  $variables['elements']['content']['body'][0]['#text'] = 'alter all block bodies everywhere';
}


texts: How to add HTML to page following user/register to track Google AdWords conversions?

texts:
I want to track conversions for Google AdWords. Basically I want to track when people sign up via the user register page (i.e. when they click join).

Google provides code (which is basically a little image) which it says I have to add to the page I want to track. I figure I need to add this to the page which comes after the visitor clicks the join button at the bottom of the user/register page.

(1) Is there a module to do this (Drupal 7)? OR
(2) How can I add HTML to the page following the user/register page (perhaps using hook_page_alter)?


texts: Fullcalendar is putting my events into the "all-day" category

texts:
I'm doing some stuff with fullcalendar and views that, more or less, is working.  In particular, a month view properly shows a set of events on the day in which they're scheduled. However, when I switch to week or day view, the events show up in the "all day" part of the calendar.

The nodes' fields containing the dates definitely correspond to specific times. How can I get them properly showing up in the right time areas in those calendar views?


texts: How do I add a Hubspot tracking code into a Drupal Website

texts:
I followed the instructions for Drupal lower on this page: https://knowledge.hubspot.com/getting-started-with-hubspot-v2/install-the-tracking-code

by adding a block and doing exactly what they said to do. But the tracking code ends up showing up on the Footer of the website but should be hidden.

What am I doing wrong? Do you have other instructions that would work better?


texts: what does the 'debug mode' on Services actually do?

texts:
Each Services endpoint has an option for 'debug mode'.

What does this actually do?


texts:
How do I create a path like this www.example.com/PROFILE_NAME/FULL_NAME

FULL_NAME is a Profile2 field.

With pathauto you cannot modify profile2 entity.


texts: node_save creating 2 nodes from external script

texts:
This is my custom code for creating a node from some arbitrary data - this is executed in the browser from a different website by executing localhost/submit.php - the contents are below:

 <?php

    define('DRUPAL_ROOT', "C:\wamp\www\mydrupalsite");
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

    $bodytext = "Foo bar";

    $node = new stdClass();
    $node->type = "article";
    node_object_prepare($node);
    $node->title    = "A new node sees the light of day";
    $node->language = LANGUAGE_NONE;
    $node->uid = 1;
    node_save($node);

    ?>

This results in 2 nodes being created even though I've just hit the script once in the browser. Can anyone see what's wrong with this?

The output gives me 2 nodes (both have different nids) and they have identical data.


texts: Which other methods for building html content are out there?

texts:
I am searching for opinions about the construction of static pages in Drupal.

Imagine this page as a PSD or PNG:
https://www.paypal.com/br/webapps/mpp/quanto-custa-empresa

It's a static page, but it's not just text, it has a somewhat rich layout. I don't think a regular node with WYSIWYG is the right way to do a page like this.

So, imagine you already have the template built, the side menu, the header, footer, etc, but you want more control over the content (middle) layout.

These are the ways I know for building this kind of "rich content":

Create the HTML page in a decent editor, then paste the HTML on the node body when you're finished.

Pros:

Practical for extremely simple pages

Cons:

Lose version control
If you do node-specific CSS, which is pretty much necessary for this kind of page, you might get into trouble if you can't maintain the node id between installations
Needs php input format in order to print images relatively
Requires back and forth from IDE every time something changes

Node-[id].tpl.php template

Pros:

Version control
Allows you to keep working on the IDE

Cons:

When doing node-specific CSS, which is pretty much necessary for this kind of page, you might get into trouble if you don't have a way to maintain the node id between installations
Same thing for the whole page. It will go blank if you don't keep track of the node ID.

hook_menu + hook_theme invoking a custom template for the wanted path

Pros:

Version control
Allows you to keep working on the IDE

Cons:

Requires custom module and a little more effort
Does not provide caching by default like a node does (performance hit wouldn't be that great for this, however)
You lose some node juicy stuff (can't remember an example right now)

So, are there any methods people are using I'm not aware of?
Maybe with panels? Context? Please let me know!


texts: Node's cache isn't automatically cleared on update (intermittent problem)

texts:
Occasionally, about 1 out of 5 times, a node's cache isn't cleared when it is updated. Even going to view the revision that the update created or editing the node doesn't show the changes. Minimum cache lifetime is set to 1 minute but even after waiting for a minute and running cron it isn't automatically cleared.

It seems that this problem happens more during the site's busier times and we haven't been able to reproduce the issue in our development environment (which typically only has 1 user on it at a time). The cache tables are all InnoDB so I'm told this means we shouldn't need to worry about locking.

A similar problem with the chosen answer saying that this is just an issue of properly setting the minimum cache lifetime. But, I found this Drupal bug that implies that on node updates the cache should be cleared regardless of that setting. Though, its status is still "needs work" which maybe means a solution was never implemented and this is still the case.

Update

Building off a patch in the bug and using hook_node_update I tried the following

function MYMODULE_node_update($node)
{
   // Forcibly wipe this node's page view from the cache because, if a
   // minimum cache lifetime is in effect, cache_clear_all() will not
   // clear any page cache entries younger than that minimum.
   //
   // Page cache cids are absolute URLs.  url() in absolute-mode will
   // get the aliased path if there is one, and we also wipe the
   // absolute version of the node/nid URL just in case.
   // Copied from http://drupal.org/node/256416#comment-838118
   global $base_url;
   cache_clear_all( url('node/'.$node->nid, array('absolute' => true))
                  , 'cache_page' );
   cache_clear_all($base_url .'/node/'. $node->nid, 'cache_page');
}

This should work around the minimum cache limit and only clear the cache for that node. Unfortunately, this did not work.

Update 2

After digging further I discovered that running cache_clear_all('field:node:<nid>', 'cache_field') (where <nid> is replaced with the relevant node ID) cleared the correct cache when the problem cropped up. I tried putting this in a MYMODULE_node_update() hook but it did not resolve the issue.

In discovering this and following the path of the code I also discovered that the APC module is taking care of the caching and none of this is being stored in the database as I originally thought.

Knowing that the caching is being handled by APC and considering the intermittent nature of the issue it brings me back to a possible locking issue with APC. Would that even make sense? Preliminary searches have not revealed anything.


texts:
I have two content types, Project and Resource,

I have a view displaying fields from Projects, and I would like to display fields from resources referenced by projects in that view.

If I Twig debug, I can see the resource fields are available in the view, but I cannot output them using {{ fields.field_project_linked_resource.content }} or similar...

Any help much appreciated!


texts: Import soap webservice xml to node with Feeds?

texts:
I have a soap web service which requires authentication to access its various function. I want to call one function of this web service and import that XML to node in Drupal with feeds module.

I am not finding any example of authentication from the Feeds module.


texts: varnish + multiple webheads = files/(css/*.css|js/*.js) missing

texts:
I have this weird issue and I'm not sure if it's me who's doing something wrong or I'm just missing something but maybe some of you can guide me a little bit here...

i setup a varnish server, within varnish itself i created 2 backends and using director i'm able to do round robin to my webheads. That parts seems to be working fine as I'm able to bring one of my webheads down and the other one can serve content to varnish and vice verse.

but here is a kicker... i noticed that sometimes page doesn't load properly so i start looking into why and I noticed some of the files are 304 or 404, so turns out somehow some of files in (files/css/.css or files/js/.js are missing), so I rsync them so now they all appears to have same content in those directories, but when i go to another page it seems like drupal generates more of those and since varnish goes to a round robin for any hit it serves some of page from one webhead and another part from another, so even though css,js file has been generated on first webhead it not generated on second and hence shows 304 or 404.

please advise


texts: Can the 'update' module be made less aggressive?

texts:
Running an update check on all the installed modules on my site takes quite some time, and sometimes even exceeds PHP's runtime limits. Leaving the module enabled makes using the web based administration very difficult, as many different actions cause it to make a full run.

Is there a way to leave the module enabled, but only have full updates triggered by cron instead of every time the status or module pages are visited in admin?

I'm using Drupal 6.26.


texts:
Once I create a custom module where I'll have some kind of administrative tasks like configurations should I create a new permission or just use any available permission?

This question comes to my mind because when we create a custom module for the community we can imagine how this module will be used, but maybe in some scenarios some admins need to give specific permission to others users to configure the site and in this case if we have specific permission for this tasks made this work is very easy, if not this admins need to create a new custom module to handle this situation.

But in the other hand if we create one permission for each administrative task in our custom module maybe we are overloading the site with permission that are rarely used.

When I should create a new permission in my custom module?

Note: I'm not trying to create primarily opinion-based question here, if some user feel this, please help me to improve the question.


texts: Uploading images to CKeditor in a file field way?

texts:
Background

I'm looking for one of the two possible solutions concerning image-uploading to Drupal, and especially to CKeditor image uploading and handling:

Possible solution 1

A module that creates an independent image-folder to every node, uploads images to this specific directory, and then let me choose only between these images directly from CKeditor. If the node is deleted, than this folder is deleted along with it.

Possible solution 2:

a module that uploads images into CKeditor text areas in an efficient, fast, Drupal-file-field-like way; It is important for me that this uploader will use the same rules like the Drupal file-field, the same mechanisms and SQL tables, so that when I delete the image I uploaded - it will be totally deleted from the site's home-folder.

So basically the uploader I'm looking for should do 2 things:

Upload files easy and fast, just like the Drupal file-field does.
Send some kind of signal when a file is deleted from that very CKeditor text area.

Please help me to find of these two possible solutions:


texts: Bulk move content from one category to another - Drupal 7

texts: I have a lot of content that I've imported into Drupal 7.  Unfortunately it imported to the wrong category.  Is there a way in Drupal or drush to bulk move that content from one taxonomy term to another?  Or is it a simple matter of assigning the new taxonomy term to the content?


texts: Login Destination behaving differently on two instances of Drupal

texts:
I'm seeing some inconsistent behaviour from the Login Destination module on my "UAT" site as compared to my "Dev" site. Both sites (AFAIK) have the same module configuration:

Neither of the global settings is enabled
There is only one Rule, as follows:

Redirect to Page foo-bar
Redirect upon Triggers Login, registration, one-time link
Redirect from listed pages : Only the listed pages - <front>

The problem is with the one-time link sent out on account activation.

The one-time link references a URL of user/reset/[snipped].
At this location there is a "Log in" button.

Clicking this button on my Dev site, users are redirected to user/NNN/edit?pass-reset-token=[snipped], from where they can edit their account details.

BUT clicking this button on my UAT site, users don't redirect to the edit profile page, but are logged in and redirected to /foo-bar, which is useless, because they can never set their passwords.

The only difference I can see between the Dev and UAT sites is that the UAT site is HTTPS while my Dev site is HTTP. Is it possible that could be a cause of this issue? If not, how can I go about debugging this?

Best regards,

MB

UPDATE

Problem resolved - I'm just recording the outcome in case someone Googles this page in future.

It was of course nothing to do with HTTPS.

Someone had previously enabled the Trigger module on my UAT site, and there was a Trigger defined on user login to redirect to foo-bar. This was causing the one-time link to be redirected.

Due to the large number of modules on our UAT site, I didn't find this for a while. Disabling the Trigger module restored the desired behaviour.


texts: Need a Best Video Player For My Video Hosting Site

texts:
I am creating a video sharing and hosting site on drupal but I am having difficulties in finding a good video player which can play almost all files. I have used media element but that is playing some mp4 files and some are not being played.

Secondly I want the video player to generate thumbnails by itself.


texts: Best method of pushing content changes that contains paragraph fields from dev to production?

texts:
I manage a very big site with over 30k nodes and these nodes have many fields in them including paragaph fields with many sub fields in them too. Currently when testing and adding in content. I have to manually input them into the dev site and once the client approves, I have to manually do this again on prod. The import feeds module doesnt support paragraphs and neither do others from what I researched.

What would be the best method of deploying content changes from dev to prod that contain paragraph fields data?


texts: When creating a module, where do I set cookies?

texts:
Drupal 7 newb here.

I am creating a simple module. Basically, this has an admin config form with a message text area. On the front end, that message appears or not depending on the state of a cookie.

My question is: where (in what function) should you set the cookie?

My code is:

/**
 * Implements hook_block_info().
 */
function message_block_info() {
  return [
    'message_block' => [
      'info' => t('Message'),
      'cache' => DRUPAL_CACHE_GLOBAL,
    ],
  ];
}

/**
 * Implements hook_theme().
 */
function message_theme() {
  return [
    'message_block' => [
      'template' => 'templates/message-block',
      'variables' => [
        'config' => NULL,
      ],
    ],
  ];
}

/**
 * Implements hook_block_view().
 */
function message_block_view($delta = '') {
  if ($delta !== 'message_block') {
    return;
  }

  $config = message_default_settings();
  if (empty($config['alert_message']) || $config['alert_show'] === 0) {
    return;
  }

  $block['content'] = array(
    '#theme' => 'message_block',
    '#config' => array(
      'alert_show' => $config['alert_show'],
      'alert_message' => filter_xss($config['alert_message']),
      'alert_link' => filter_xss($config['alert_link']),
    ),
  );

  return $block;
}


texts: How to customize a contributed module's template

texts:
I have a contributed module with a theme file in the module's directory. I want to change it a bit by creating a template file in my custom theme directory. I thought I could just copy and paste the template file into the directory and it would be overridden. That doesn't work, so what am I missing?

Here is the implementation of hook_theme() that's in the .module file:

function wunderground_api_theme() {
  return array(
    'wunderground_api_block' => array(
      'template' => 'wunderground_block',
      'variables' => array(
        'weather_data' => NULL,
      ),
    ),
  );
}


texts: Image link in views exposed filter gallery

texts:
I created a content type which contains among other infos, some pictures

I'm using views with exposed filters to render them on the page (the images are thumbnails)

How can i create a link on the thumbnails that will start a gallery (big pop-up modal img slider) that include only the pictures in each content?

Here is what i can link pictures to atm (i'm looking for some other options for this drop down menu)


texts:
I want to display an image at the top of my block. My block is a dynamic Views block, and it displays the top 5 latest news items. Is there any module to do so.

Also is it possible to rotate image and content within certain time interval (Eg. 1 hour).


texts: Drupal commerce save date field product type to order

texts:
I have setup a new content type called product in Drupal 7 and I have a product reference entity multi value linking to my product type. So I can addthe sku, price I made a new field in the product type calied course dates and used the Unix date time stamp using the date module and pop up calendar.

The admin add the sku, Price and course dates which are added okay. Now the problem how can I save the course date field into the order where the sku, price smd title from the product display are stored to the order?

As the course dates expire I want to delete the dates. It says it's referenced to an order that's the reason why I want to store it into the order then delete the product variations from the product type so I don't have loads of old dates.


texts:
I want to know how to add conflicts in D8 info.yml.

I tried like this in D8 .info.yml:

name: Example
type: module
description: some example.
core: 8.x
package: Other
dependencies:
  - menu_ui
conflicts:
  - module1
  - module2

and in .install file

<?php
/**
 * Implements hook_requirements().
 */
function example_requirements($phase) {
  $requirements = [];

  switch ($phase) {
    // Called while the module is installed.
    case 'install':
    if (\Drupal::moduleHandler()->moduleExists('module1')) {
        $requirements[] = [
          'title' => t('Module 1'),
          'value' => t('Module 1'),
          'description' => t('Module 1 conflicts with example.'),
          'severity' => REQUIREMENT_ERROR,
        ];
      }
      break;
  }

  return $requirements;
}

But in D7 it is working:

name = Example
description = some example.
core = 7.x
dependencies[] = menu
package = Other
conflicts[] = module1
conflicts[] = module2

While enabling my example module it is not showing any conflict error in D8.

  Installation Order:

  1) Fresh Drupal installation.

  2) Module 1

  3) Module 2

  4) Example module(here i need to show module1 and 2 are present while
  installing)


texts:
Im using user points (module) to reward users whenever they create content on my site. Now, I`d like to start rewarding thise points within categories (Points categories).

The categories I want in my points system are to be the terms that is available in a specific vocabulary on my site.

Exampple:
User X creates a "node Y" and classifies it with "term A". In this case Id like to award user x 5 points in the "term A" category.

Anyone know how to do this?

Thanks,


texts: Unable to generate derived image located at public://

texts:
I am trying to use a slideshow on my server and I get this error

Date    Monday, January 28, 2019 - 18:28
User    Anonymous (not verified)
Location    http://mysite.dev.local/sites/default/files/styles/max_1920x1920/public/2019-01/Screenshot_2019-01-28_15-00-52_0.png?itok=xMdR5S3S
Referrer    http://mysite.dev.local/
Message     Unable to generate the derived image located at public://styles/max_1920x1920/public/2019-01/Screenshot_2019-01-28_15-00-52_0.png.
Severity    Notice
Hostname    127.0.0.1

My browser reports 500 Internal Server Error but the error.log shows nothing about the image even on LogLevel debug


texts: How do I associate multiple nodes to a user?

texts:
I have some users, and I have a "product" content type, which has the following fields: "name," "type," and "description."

I want to associate specific nodes of this content type to a user. How do you suggest I should do this?

Shall I create a new table and store the user and the product ID?


texts: Migrate source id's and map them to already existing Drupal entity id's

texts:
I've tried a bunch of different setups, but I can't get it to work. Here are the two setups I was the most confident in that it would work. I simply want to map existing id's in the source to new id's that are already created in taxonomy.

Attempt 1:

  field_season:
    # Map the seasons to our already existing taxonomy terms
    -
      plugin: static_map
      source: season
      map:
        '1': 26 # Lente
        '2': 29 # Zomer
        '3': 24 # Herfst
        '4': 28 # Winter
    -
      plugin: entity_lookup
      value_key: tid
      entity_type: taxonomy_term
      bundle_key: tid
      bundle: seasons

Attempt 2:

  field_season:
    plugin: iterator
    source: field_season
    process:
      target_id:
        # Map the seasons to our already existing taxonomy terms
        plugin: static_map
        source: season
        map:
          '1': 26 # Lente
          '2': 29 # Zomer
          '3': 24 # Herfst
          '4': 28 # Winter

Edit: FWIW, all the other processes work just fine!


texts: How to pull multiple terms from the same Taxonomy in View Page using contextual filters?

texts:
I have a multilevel taxonomy tree with products/versions.

product 1

version 3.1.0
version 3.1.1
version 3.2.1

product 2

version 5.4.0
version 5.4.1

product 3

version 1.0.0
version 1.0.1

I have pieces of content that have a term reference to the product and version.

I am trying to create a View Page at that uses contextual filters on the content. The path would look like: /products/product-2/version/540

The path to in my View Page is: /products/%/version/%

After that I add a contextual filter for the first term in the path and that works. But if I have two contextual filters, one for each term in the path it does not work. The second term has depth and I am not sure if that is the issue.

I tried to create a View Page with just content referencing the version and I couldn't get that to work. So that leads me to believe it is an issue getting sub terms from contextual filters.

Is there a way to pull sub terms in contextual filters?


texts:
I'm trying to insert a span class around some text in title callback. It passes through a t() function so all the html is escaped.

Is there a way round this?

My code is:

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

  $items['discussion'] = array(
    'title' => 'Discussion',
    'title callback' => 'custom_module_title',
    'page callback' => 'custom_module_tester1',
    'access callback' => TRUE,
    'menu_name' => 'document-menu',
    'type' => MENU_NORMAL_ITEM,
    'options' => array('attributes' => array('class' => 'discussion')),
    'weight' => 10,
  );

  return $items;
}
function custom_module_title() {
  $discussionnid = custom_module_postexist(3);
  if ($discussionnid) {
    return 'Discussion 85';
  }
  else {
    return 'Discussion';
  }

}


texts:
I've been trying to get an answer to the following question AJAX dependent select. However I think I'm compounding to many concepts. Perhaps I should first master the FAPI AJAX before building upon it. I can not get the following to work properly. After selecting an option I get the drupal clock like it's going to re-render the text field however nothing happens and the value does not change. Where am I going wrong?

function main_iosupload_form($form, &$form_state) {
//Define SQL Lookup Query
  $sqlplatform = "SELECT vid, name FROM {taxonomy_vocabulary} WHERE vid >= 4";

  $result = db_query($sqlplatform);
  $options = array();
    foreach ($result as $row) {
      $options[$row->vid] = t($row->name);
    }

$form['platform'] = array(
  '#type' => 'select',
  '#title' => t('Select a Platform'),
  '#options' => array(
    0 => t('- Select -')) + $options,
  '#default_value' =>  0,
  '#required' => TRUE,
  '#ajax' => array(
    'callback' => 'ajax_select_callback',
    'wrapper' => 'replace_model_div',
    'effect' => 'fade',
   ),
);

$form['model_wrapper'] = array(
  '#type' => 'textfield',
  '#default_value' => (!empty($form_state['values']['platform']) ? $form_state['values']['platform'] : t("Intial Value")),
  '#prefix' => '
',
  '#suffix' => '
',
);

return $form;
}
function ajax_select_callback($form, $form_state) {
  return $form['model_wraper'];
}


texts:
Trying to do a simple query from a table called 'raffles' under the drupal database.

It is not a complex query, Just trying to get all sets from drupal.raffles

$query = db_select('raffles');
$query->execute();
$result = $query->fetchAssoc();
dpm($result);

The error

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 'FROM raffles raffles' at line 1: SELECT FROM {raffles} raffles; Array ( ) in raffle_create_form() (line 8

From the error, the query has the table name twice, and is probably what is causing the error. maybe im doing something wrong? There is not much information related to this on the api page.

Any help would be gladly appreciated.

Thanks.


texts: Checking the option "Generate automatic URL alias" doesn't work on a taxonomy vocabulary

texts:
I am having 2 taxonomy vocabularies

Cars
Make

and I have Installed all needed modules to generate automatic URL, such as Path, Pathauto, tokens etc..
I have set patterns for these taxonomy vocabulary terms

car :car/[name]
make : car/make/[name]

in the "Cars" vocabulary I add a term and checked the "Generate automatic URL alias" option and save I see the path has been changed according to the pattern I have set.
but  in the "make" vocabulary terms when I check "Generate automatic URL alias" and save I don't see the URL created according to the pattern but (taxonomy/term/tid), when I click edit on the term I don't see "Generate automatic URL alias" checked it is simply unchecked.

Tried fixing it by doing some pathauto settings, google search my bad I didn't find anything similar.


texts:
This happens in my custom Zen-based theme where I made a custom node type 'events'. I put print_r($node) inside of my node-events.tpl.php which gave all the ckk fields including the ones that didn't turn into HTML i.e. not displayed.

When viewing this type of node in a stock drupal theme, this problem doesn't occur so everything gets displayed as desired.
This means my viewing permissions are in check and also under admin->content type-> 'events' -> display fields hidden is turned off (set to standard just the way it was when I didn't have the problem)


texts:
Background

I have started a tech blog which will regularly have Drupal articles.
I've followed the Planet Drupal instructions specified on Drupal.org

Created an RSS feed and validated it on W3C validator
Ensured that it has 2 original initial articles
Created a ticket to request the addition of my site to Drupal Planet

I've also contacted a Planet Drupal maintainer, i.e. people who approve Planet Drupal feeds.

The problem

It's been around a week, but there's no news :( I believe that my articles will get stale and they won't be picked up by the weekly drop.

Is there anything I can do to accelerate the process? Or is there something I'm not doing right?


texts:
I'm using the Drupal 8 #table element to populate a table on my form, and it's working great for displaying static data.

foreach ($entries = getData() as $entry) {
  $row = array_map('Drupal\Component\Utility\SafeMarkup::checkPlain', $entry);
  $rows[] = $row;
}
$form['table'] = array(
  '#type' => 'table',
  '#header' => $headers,
  '#rows' => $rows,
  '#attributes' => array('id' => 'my-module-list'),
  '#empty' => t('No entries available.'),
);

However, I would like to embed a control in each row of the table, for example:

foreach ($entries = getData() as $entry) {
  $row = array_map('Drupal\Component\Utility\SafeMarkup::checkPlain', $entry);
  $row["field_name"] = array(
    '#type' => 'textbox',
  );
  $rows[] = $row;
}
//dpm($rows);
$form['table'] = array(
  '#type' => 'table',
  '#header' => $headers,
  '#rows' => $rows,
  '#attributes' => array('id' => 'my-module-list'),
  '#empty' => t('No entries available.'),
);

However, the #textbox field is currently being ignored, and an empty cell is shown in its place.

Is there a way I can embed fields in a Drupal generated table, or do I need to build my own table from scratch?


texts: How to have Drush make automatically find libraries download path?

texts:
I don't know from what URL's I got my libraries files from. Is there a way for Drush Make to find those URL's, a command?

Additionally, what URL/Path can I use for my own custom modules?
Can I use a local path in a URL so the libraries are sourced locally?


texts: What is the intended use of drupal_static?

texts:
I understand Drupal static cache is used to store static values in the memory for the length of the request to faster access them. However throughout Drupal and contributed modules I tend to see two different versions:

Example from drupal_is_front_page:

function drupal_is_front_page() {
  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['is_front_page'] = &drupal_static(__FUNCTION__);
  }
  $is_front_page = &$drupal_static_fast['is_front_page'];

  if (!isset($is_front_page)) {
    // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
    // we can check it against the 'site_frontpage' variable.
    $is_front_page = ($_GET['q'] == variable_get('site_frontpage', 'node'));
  }

  return $is_front_page;
}

They way I read (and used) it from some tutorial I once found:

$static_cache = &drupal_static(__FUNCTION__);
if (!isset($static_cache[$key])) {
  // Obtain value
  $static_cache[$key] = $obtained_value;
}

return $static_cache[$key];

So I skipped the static declaration of the local variable, and to be honest I don't see why I should be adding it, it is in the first line of drupal_static:

function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
  static $data = array(), $default = array();
  // First check if dealing with a previously defined static variable.
  if (isset($data[$name]) || array_key_exists($name, $data)) {
    // Non-NULL $name and both $data[$name] and $default[$name] statics exist.
    if ($reset) {
      // Reset pre-existing static variable to its default value.
      $data[$name] = $default[$name];
    }
    return $data[$name];
  }
  ...
}

Is is even faster if I declare another static variable in my module to hold a function that manages a static variable? (The name drupal_static_fast implies this.) Is this some old Drupal 6 convention where there was no drupal_static and it had to be declared locally? Or am I missing something else?


texts: Where does the Entity Registration module store the signup data and how to delete it?

texts:
I am running Drupal 7.50. I'm using the Entity Registration module, and I have set up a small classroom enrollment content that I used to test this out.

My questions:

Where does Entity Registration store the signup data?
How do I see the information collected?
How do I delete it?


texts: How to display tags of content filtered by a different tag

texts:
I have a content type that has 3 taxonomy fields (Year, Project & Type, respectively).

On the top page of the view I want to display all terms of the Year-vocabulary, this is no problem. I rewrite the field so it links to

/work/Year

On the next page I want to show all the unique Project-terms for the selected year.

Example:

Project A: Year: 2014, Project: Scanning Paper, Type: Painting
Project B: Year: 2014, Project: Scanning Paper, Type: Drawing
Project C: Year: 2013, Project: Leaving , Type: Painting
Project D: Year: 2014, Project: Afterlife, Type: Painting

If the year 2014 is selected, I want the next view to display all unique projects:

Scanning Paper
Afterlife

I've been trying this to accomplish this using Views, and been working at a solution for a couple of days now, but I can't figure it out. I've tried a lot of things, searched here and elsewhere, but haven't find a solution. I'm beginning to think maybe the approach with taxonomy terms isn't right, but I need some guidance.

Thank you.


texts: Entity Metadata Wrapper - check filtered text value is set

texts:
I'm seemingly unable to check for the existence of a value of a field if the field in question is set to filtered text. The following code returns an error - and any possible combination I've tried to find online results in the same:

if ($wrapper->__isset('body')) {
  print $wrapper->body->value->value();
}

The error:

EntityMetadataWrapperException: Unable to get the data property value as the parent data structure is not set. in EntityStructureWrapper->getPropertyValue() (line 438 of /Applications/MAMP/htdocs/arch-main/httpdocs/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

To be clear, the node does have the body field, but no content has been placed in it.

Any ideas on how to check for this?

EDIT:

Ok this seems to work, but there must be a better way

try {
          print $wrap->body->value->value();
        } catch (EntityMetadataWrapperException $e) {
          // ???
        }


texts: How to execute a script that takes a long time?

texts:
I am executing a script by calling a URL using the wget command. I want to execute this script 3 times a day for 2 hours each time. To do so, I check the difference between the start time and the current time.

My problem is that sometimes the script runs for 2 hours, sometime 1 hour, and sometimes just 3 minutes. I don't know why. I have increased memory_limit and max_execution_time. Still, I haven't been able to find the reason.

What my script is doing exactly:

It fetches a data from other site using cUrl. The data are articles, journals and some other user's data.
After getting the data in XML format, it adds each content.


texts: Primary links background not visible by non-admins

texts:
I have styled my primary links with a background and it all works out just fine. Except for when I log out, the background disappears.
So it looks like the anonymous user doesn't have permissions to see the background (which I would fine strange...)

Is this a known issue and if so, what can I do about this?


texts: How to set up subscription service with credits that visitors can use to buy products?

texts:
I have a client that has a Drupal 7 site with Drupal Commerce already running to manage his store of products.

He wants to add a subscription service where users could pay a monthly subscription fee, and this fee would give them credits to buy products with.

Just wondering the best way to set this up/what recommendations people have to implement this.


texts:
I'm using Views 3 with Drupal 7. I'm trying to dynamically add a class to the "views-row" line of a view based on the node type. I have a view with a relationship which is duplicating items when a relationship exists. I thought by adding a class for the node type into the views-row line I could hide the field in the row. I'm not sure whether I should be overriding views-view-unformatted.tpl.php or views-view-fields.tpl.php, to add the class and how I can extract the node type from the data to add it into the the classes for that line.

I'd be grateful for any guidance.

Ben


texts: How I get notified every time their is an *new* update and not every day for the sames updates?

texts:
The update module can send you email when a new release is available for a module you installed. The problem is I get a email everyday. Some security update are very minor and unreachable for an attacker, I don't want to update the website and so I don't want future notification about this update.

I would like to be notified every time their is an new update, not every day for the sames updates.


texts: How to create a view that display on the same row a field and its translation

texts:
Let say I have a content type with 2 fields that can be translated in a 2 languages site (EN-FR): the title and field_tobe_translated

I would like to list (in a view) all nodes of this content type with only one row by node and each row should have this format:

Title_FR -- Title_EN -- translatable_field_FR -- translatable_field_EN

The "--" before means a column separator in a table type view.

Added question:

Is it possible to filter this view to show only the row where "Title_FR != Title_EN" [I assusme that the process would be the same for the other translatable field]


texts: Duplicate nodes after node import using the Node Export module

texts:
I ran into a major problem with the Node Export module... on my remote site I use drush to export all nodes of a certain type into a text file. Then I move that file to my local site and import the file, also using drush. The problem is that new nodes are created during the import, so that existing nodes gets duplicated. And yes I have checked the option "Create a new revision of the existing node" (if the node exists).

A very strange thing is that if I export the nodes locally and then re-import them again locally, this does not happen. But my remote site is identical with the local one, and the nodes do have the same node IDs. I have checked and double checked that.

I have also looked in the file itself before import and the node IDs are correct.

Does anyone have an idea why the export file from the remote site is treated differently during import, so that nodes get duplicated?


texts: Change the position of the block created from the Locale module

texts:
I am using Drupal 7, and I have enabled the Locale module. I have configured the block so  that it appears on the header, but I want the block to appear near the site's name.

How can I do it? Which files need to be changed?

I am using a Zen sub-theme.


texts:
I've created a website in Drupal 7 and we would like an app version of the website. I'm looking at DrupalGap. Is this the best way to do this?
If I use a function like DrupalGap do I need to reconstruct all the page for the app or will it pull through the pages from the website?


texts: How to call different fields from different content in same view?

texts: I have content type Say "A" and for that i want to create view, in this view i want to add a field which is from different content type say "B", reason is here in the B content type i have fee category and assigning the rent value for each category, and this node of content type is referring in a content type A with entity reference, something like this in screen shot. as of now i created view for content type A,and added the field of content type B, but the values add in the content B are not displaying in the view of content A


texts: Views Taxonomy get children of a specific parent term within a vocabulary

texts: I have a taxonomy vocabulary with 2 parent terms with children (fishing, and hunting) I want to get all children of the fishing parent term. I've tried to do it with core, but not sure it is possible.


texts:
In Drupal 7, there are hook_library() and drupal_add_library() that can be used to manage JS and CSS libraries. I am looking for how to include the PHPExel library in my distribution.

How can I do it?


texts: How do you update a user role to be an admin role via Drush sql-query?

texts: I know the following User ID 2524 and the Name is Tester. And the role to be an admin is 3. What command is needed to make a user an admin using only the the drush terminal?


texts:
I created a view via the administration interface. This view lists content (style teaser; title and image).
The default link of titles is /node/'nid'; I want to replace the link with /custompate/'nid'.

I suppose I must "find" the template of my custom view and overwrite it in a custom module.

How can I find the name of the template for this specific view?

Edit : the "advanced" block in my view (theme information is missing :/)


texts: Real-time preview of node/form in Drupal 7

texts:
I'm trying to achieve this in Drupal 7. This is what I need URL for working example (But its not in Drupal).
Requirement - Live Preview with alignment features

From Drupal.Stackexchange I've came across this post 29325 where the user is trying to achieve the similar thing there its mentioned about the Drupal's Live Module but as the description page of the module shows yet its not made up for Drupal 7 and I'm sure this will not fulfill my requirement.
Question:

Rather than Drupal's Live module, is there any other module available?
Can any of the JS/jQuery plugin or library or framework can fulfill my above mentioned requirement?

Note

I've created the left/side panel form using the custom content type hence now, if I can achieve this live preview using some JS plugin/library also then I'm fine with it as I can see that no Drupal module is available for this!


texts: While developing a custom module, which function creates table in database?

texts:
While developing a custom module in Drupal 7, which function actually creates tables in the database?

I have implemented hook_schema in mymodule.install, mymodule.info, mymodule.module file and defined the Controller class and creates an StdClass object, but still I can't seem to find my tables in my database.

Can anybody tell me what I could be doing wrong?


texts: How do I get a node, or a taxonomy term URL knowing the node ID or the taxonomy term ID?

texts: I need to render the full URL from a taxonomy term ID.


texts: How can I change the file system from public to private?

texts:
I have been using public file system has the upload destination for file field. I want to change public file system into private file system. I cannot change it it showing below error.

  There is data for this field in the database. The field settings can
  no longer be changed.

I cannot select the upload destination. How to change the file system for file field in drupal 8


texts: How to make drush to work correctly in Windows?

texts:
In Linux drush is comfortable with all Linux native commands. But how to make it working in Windows?

Of course there is a drush installer for Windows and it is correct, but the real question is: how to make all commands to work correctly?

For example drush sql-dump returns this error:

'mysqldump' is not recognized as an internal command


texts:
I'm running a Drupal 7 web-site with Drupal Commerce and CAPTCHA modules. I have a CAPTCHA challenge set up on the checkout page. Although an incorrect solved CAPTCHA will show an error, the CAPTCHA still gets ignored when I click "Continue to next step", thus the CAPTCHA can be left empty and the site will still take the user to the next form.

The CAPTCHA is added in the CAPTCHA config (admin/config/people/captcha) to the form "commerce_checkout_form_checkout".

Things I've tried (but didn't help):

Add a CAPTCHA field to the form programmatically;
Add "[required] => 1" to said field;
Tried with both the Math CAPTCHA and reCAPTCHA.

How can I make CAPTCHA work on Drupal Commerce's checkout form?


texts: How do I add a meta tag when creating a node via REST API?

texts:
So I have this code, using Guzzle POSTing to create node via Drupal REST API.
No error, but the field_meta_tags value is empty  on the node created (still using default [node:summary] for the meta description).

$node = array(
'title' => array(0 => array('value' => 'asd')),
'type' => array(0 => array('target_id' => 'page')),
'path' => array(0 => array('alias' => $pathalias)),
'field_meta_tags' => array(
  'title' => 'asd',
  'description' => 'asd',
  'keywords' => 'asd',
),
'body' => array(0 => array('value' => 'huehuehue')),
);

$response = $client->post($base_url . '/entity/node', array(
  'cookies' => $jar,
  'query' => array(
    '_format' => 'json',
  ),
  'headers' => array(
    'Accept' => 'application/json',
    'Content-Type' => 'application/json',
    'X-CSRF-Token' => $csrf_token,
  ),
  'json' => $node
));

I also try using array structure like this:

'field_meta_tags' => array(0 => array(
  'title' => 'asd',
  'description' => 'asd',
  'keywords' => 'asd,
)),

But still no luck.

What is the correct format to provide metatag value? Or is there another thing that I might need to check?


texts: How to edit a custom region from an Omega subtheme in Drupal 7

texts:
I created a new region in my Omega subtheme called MYTHEME-MENU. I want this region to do the same thing as the normal menu region, but with adding some markup. What is the proper way of doing this (I don't want to add the markup in Omega's region-menu.tpl.php file)?

I see I have a template, process and preprocess directories along with an empty template.php file, but I'm not sure how to use these.

Essentially my MYTHEME-MENU region needs to spit out the following:

<div<?php print $attributes; ?>>
   <div<?php print $content_attributes; ?>>

    <?php if ($main_menu || $secondary_menu): ?>

    <?php print theme('links__system_main_menu', array('links' => $main_menu,
       'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline',
       'clearfix',     'main-menu')), 'heading' => array('text' => t('Main
        menu'),'level' => 'h2','class' =>     array('element-invisible')))); ?>
    <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu,
       'attributes' => array('id' => 'secondary-menu', 'class' => array('links',
       'inline', 'clearfix', 'secondary-menu')), 'heading' => array('text' =>
        t('Secondary menu'),'level' =>     'h2','class' => array('element-
        invisible')))); ?>

    <?php endif; ?>
    <?php print $content; ?>


texts: How do I get kint() to include the variable name in output?

texts: My understanding that normally kint will display the variable name in the output, e.g. $abc. But in my code kint($abc) never outputs the $abc label so when I have multiple kints it becomes very confusing. Any idea how to force this or label kint output?


texts: Organic groups content propagation direction

texts:
where can I set content propagation direction in Organic groups (7.x-2.x). Post https://drupal.stackexchange.com/questions/40835/need-groups-within-a-group/175000 shows screen which I can not find even though I have installed modules Organic groups and Subgroups for organic groups.

Do you have any advice where can I find this screen or any other way I could set proparation of content from parent to children groups?


texts:
I have a site  displaying text in a slideshow format using  views slideshow. I was wondering if there is anyway to append  the slideshow with new  content created on the site maybe via  ajax. View out  refreshing the page

My current work around was to refresh the  view after the slideshow ends the  problem with this is that there is a visible break in the flow of the animation if the entire refreshes


texts: How to render a media entity image (that uses a focal point image style) inside a paragraph twig file?

texts:
Originally I used a typical image field in my paragraph, now with the new updates for the media module I would like to use the image library to upload and reuse media entity images. I use focal point for my image styles, in the paragraph I use, the user can choose between a couple of image styles.

preprocess code for passing image styles to twig template:

function tekst_en_afbeelding_preprocess_paragraph__tekst_en_afbeelding(&$variables) {
    if (isset($variables['elements']['field_image']['#items'])) {
      $variables['img_223_x_308'] = ImageStyle::load('223_x_308')->buildUrl($variables['elements']['field_image']['#items']->entity->uri->value);
      $variables['img_326_x_450'] = ImageStyle::load('326_x_450')->buildUrl($variables['elements']['field_image']['#items']->entity->uri->value);
      $variables['img_560_x_308'] = ImageStyle::load('560_x_308')->buildUrl($variables['elements']['field_image']['#items']->entity->uri->value);
      $variables['img_1280_x_703'] = ImageStyle::load('1280_x_703')->buildUrl($variables['elements']['field_image']['#items']->entity->uri->value);
  }
}

This code does not work anymore for the media entity image.what do I need to change for this to work?


texts: I'm using entity translation module for node localization and dpm($language_content) always gives english, which is my default language. This outcome is for all languages, I don't understand what is the problem.


texts: Why are my menu items not showing under the top level menu item?

texts:
I'd like my other 3 menu items to sit under Manage Instagram in my Admin/Config menu but they are all being created as individual top level menu items.

  function instagram_menu() {

  $items = array();

  // Top Level Menu Item
  $items['admin/config/instagram'] = array(
    'title' => 'Manage Instagram',
    'type' => MENU_NORMAL_ITEM,
  );

  // Secondary Level Menu Item
  $items['admin/config/instagram/pull-images'] = array(
    'title' => 'Pull Instagram Images',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('instagram_form'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_NORMAL_ITEM,
  );

  // Secondary Level Menu Item
  $items['admin/config/instagram/client_id'] = array(
    'title' => 'Set Instagram Client ID',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('instagram_client_id_form'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_NORMAL_ITEM,
  );

  // Secondary Level Menu Item
  $items['admin/config/instagram/delete'] = array(
    'title' => 'Delete Instagram Data',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('instagram_delete_form'),
    'access arguments' => array('administer site configuration'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}


texts: How to override output (query) for views exposed filter?

texts: I have a views with exposed filter of taxonomy terms (select). It have multiple choice, and nodes output with that terms. But I want to change output of result of views for this filter. How can I do it programmatically?


texts: allow users to continue the survey (webform) if closed by accident

texts:
I wonder if there is a way of let users continue with survey (webform) in case they close the browser or the tab. For example:

I have a very long webform survey, it has like 30 questions, if Users start answering the survey today I need to let them continue with it if they close it and reopen it tomorrow.

example the url ot my survey is "node/1"

so if user begins the survey and closes it, then tomorrow he must be able for login and go to "node/1" and continue with the survey, right now users have to start over if they close the tab.

any idea? suggestions?

Thank you


texts: Is there a way to pass an argument to a view without using the url?

texts:
UPDATE: Shawn's answer is correct but I'd like to mention for anyone else looking to implement it. The arguments must match the contextual filters you've added, in the same order.

Right now I'm embedding views using

print views_embed_view('customview', 'customblock');

in a block. Is there a way that I can still embed a view in a block and pass in a parameter to it. I'd like to create a filter like this

print views_embed_view('customview', 'customblock', 'customcategory');

Is this possible?


texts:
I want to add a query to filter my entity list table.

class CommandesLignesEntityListBuilder extends EntityListBuilder {

  use LinkGeneratorTrait;

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['id'] = $this->t('ID');
    $header['produit'] = $this->t('Produit');
    $header['quantite'] = $this->t('Quantité');
    $header['prixHT'] = $this->t('Prix HT');
    $header['TVA'] = $this->t('TVA');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {

    /* @var $entity \Drupal\boutique\Entity\CommandesLignesEntity */
    $row['id'] = $entity->id();
    $row['produit'] =$entity->getProduit();
    $row['quantite'] =$entity->getQTE();
    $row['prixHT'] =$entity->getPrixHT();
    $row['TVA'] =$entity->getTVA();

    return $row + parent::buildRow($entity);
  }

}

This show me all lines. How can I filter this with a query? For example, how can I get only lines with price greater or equal to 100?

i would like a permanent query for this EntityListBuilder sub-class.


texts: How to theme video_embed_field per node type

texts:
I have two seperate node types and d8 with media installed

in both node types there is a field called video using video_embed_field on a deeper layer in the theme because it uses media entity.

I try to find out how to alte the content of

video-embed-iframe.html per node type.

I am new to d8 and twig.

How can i td this inisde a theme without the need of a custom module

cold i theme the video field per contetn type and then display all template contetn in video field based on an if condition?


texts: Does anonymous can access current node? How to check it in my module?

texts:
I need to do something witn current node by my module only if anonymous users can view this node. How to check it?

By default I use $node->status == 1, but some other modules can change anonymous access rights also for published nodes.


texts: How to add certificate to drupal_http_request()?

texts:
I am currently setting up a payment method in my Drupal 7 site and following the API documentation for the service I could use this cURL command for testing purposes:

$ curl -s -S -i --cert
./Swish_Merchant_TestCertificate_1231181189.p12:swish --cert-type p12 --
cacert ./Swish_TLS_RootCA.pem --tlsv1.1 --header "Content-Type:
application/json"
https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests --data
'{ "payeePaymentReference" : "0123456789", "callbackUrl" :
"https://myfakehost.se/swishcallback.cfm", "payerAlias" : "4671234768",
"payeeAlias" : "1231181189", "amount" : "100", "currency" : "SEK",
"message" : "Kingston USB Flash Drive 8 GB" }'

But since I am developing this function in Drupal 7 I want to use drupal_http_request instead. But I am confused about how to include the certificates used in the cURL command. Anyone?

EDITED:
After the suggestion below I added a context parameter. I still get "connection refused by destination". Is there anything more I should do? This is how my function looks so far:

function create_payment_request(){
  // Send payment request to Swish API
  $headers =  array('Content-Type'=>'application/JSON' );
  $url = "https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests";

  $context = stream_context_create([ 'ssl' => [
  'local_cert'        => '/mypathtocertificates/TestCertificate_123456789.pem',
  'passphrase'        => 'pass' ]]);

  $json = '{
  "payeePaymentReference": "0123456789",
  "callbackUrl: "/swish_callback",
  "payerAlias": "4671234768",
  "payeeAlias: "1231181189",
  "amount": "100",
  "currency": "SEK",
  "message": "testo 925"
}
';

  $options=array(
      'headers'=>$headers,
      'context' => $context,
      'method'=>'POST',
      'data'=>$json,
    );

    $result=drupal_http_request($url, $options);
    dpm($result);
}


texts: How to add AJAX call back from another AJAX result in a form

texts:
I want to use 2 AJAX call back within a form. The scenario is like I am having a text field and a Search button which is defined in the form alter function. After entering a text and clicking on the Search button, will display some matching strings with some other information from database as an HTML in ul li a format.

I had made each string as a form element link and displaying under the search field. Now, I need to add AJAX callback to this link and after clicking on any string, the whole HTML content has to be removed and some other new text fields should be displayed in the form and the selected string should be placed on the text field.

Please see below codes.

FORM ALTER

  $form['searchbutton'] = array(
      '#type' => 'button',
      '#value'=> t('Search'),
      '#id'   => 'search_button',
      '#ajax' =>  array(
          'callback' => 'ajax_search_callback',
          'wrapper' => 'search-list-wrapper',
          'method' => 'replace',
          'effect' => 'fade',
          'progress' => array('type' => 'none'),
        )
     );

Below code is the first AJAX call on button click

/**
     * AJAX call back
     */
function ajax_search_callback($form, $form_state) {

//getting matching list from database with respect to search text
// $search_results

 $form['link-lists'] = array(
        '#type' => 'item',
        '#prefix' => "
",
        '#suffix' => "
",
    );
 foreach ($search_results as $key => $result) {
        $result_html = "
" . $result['title'] . "

" . $result['description'] . "
";

        $form['link-lists']['options'.$key] = array(
            '#type' => 'link',
            '#prefix' => "
",
            '#suffix' => "
",
            '#title' => $result_html,
            '#href' => '#',
            '#options' => array(
              'html' => true,
            ),
            '#ajax' => array(
              'wrapper' => 'search-list',
              //'method' => 'html',
              'callback' => 'select_ajax_callback',
            )
      );

 }
  $commands = array();
  $commands[] = ajax_command_replace('#descriptions-list', drupal_render($form['link-lists']));
  $page = array('#type' => 'ajax', '#commands' => $commands);
  return $page;

}

I think, the second AJAX call back select_ajax_callback given for the form item link is not correct. It would be thankful if anyone can help me on below questions?

How to set callback for a form item link? Please correct me.
How I will get $form and $form_state values in the function select_ajax_callback. And in this function I need to return another form element which is already defined in the form alter.

Thank You.


texts:
Well it might be a simple solution but I don't get it.

I have a field in my content type "field_color". I can get the value of that field in my page.html.twig with {{ node.field_color.value }}

It works really good.

With Display Suite I created several layouts, but how to I access the field value within the layout.

I already tried:

{{ node.field_color.value }}
{{ ds_content.field_color.value }}
{{ ds_content.field_ }}
{{ ds_content.0 }}
{{ ds_content.1 }}
{{ ds_content.3 }}

nothing works.

Drupal 8, DS 2.5 stables

In my layouts.yml

sw_default_text:
  label: 'Text 1col Collapse'
  category: 'my cat'
  class: '\Drupal\ds\Plugin\DsLayout'
  template: layouts/sw_default_text/sw-default-text
  regions:
    middle:
      label: Content

My sw-default-text.html.twig:

{#
/**
 * @file
 * Template for a 1 column layout.
 *
#}
<div {{ attributes.setAttribute('id', settings.css_id).addClass('row shrink', 'sw-default-text', settings.css_classes) }}>
  <div class="small-12 columns">
    {{ content.middle }}
  </div>
</div>


texts: How to Filter views result by current logged in user's role

texts: I know it can be done using PHP Code I am looking an option which will be using configurations.


texts: Prompt user to download file via AJAX form submission

texts:
I have a file that is generated when an AJAX button is clicked. I want to immediately have a file download prompt come up. The file is being generated and has the correct data in the file. I just don't know how to force the download prompt to come up.

Edit#1

I have updated the generateCSV() code to include:

$response = new BinaryFileResponse($path . $filename);
$response->setContentDisposition(
  ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  $filename
);

$form_state->setResponse($response);

This is not invoking a download.

AJAX Button

$form['comp_card_dl'] = [
  '#type' => 'button',
  '#value' => $this->t('Download'),
  '#ajax' => [
    'callback' => '::generateCSV',
    'progress' => [
      'type' => 'throbber',
    ],
  ],
  '#name' => 'comp_card_download',
];

CSV File Creation

public function generateCSV($form, FormStateInterface $form_state) {
  $trigger = $form_state->getTriggeringElement();
  if ($trigger['#name'] == 'gift_card_download') {
    $filename = $form['#gift_card_filename'];
    $data = $form['#gift_card_data'];
  }
  else if ($trigger['#name'] == 'comp_card_download') {
    $filename = $form['#comp_card_filename'];
    $data = $form['#comp_card_data'];
  }

  $path = \Drupal::service('file_system')->realpath(file_default_scheme() . "://") . '/';
  $csv = fopen($path . $filename, 'w');

  foreach ($data as $id => $value) {
    array_unshift($value, $id);
    fputcsv($csv, $value);
  }

  fclose($csv);

  $response = new BinaryFileResponse($path . $filename);
  $response->setContentDisposition(
    ResponseHeaderBag::DISPOSITION_ATTACHMENT,
    $filename
  );

  $form_state->setResponse($response);
}


texts:
I have HTML menu. With the following:

cccc

aaaaaa

bbbb

And created this items on Main Menu via Drupal admin. I know, when erase this HTML items and add ?php print render($page['main_menu']); ?> get my menu structure. But i don't want it.

I want, my Drupal menu items, write a href=** So, like this:

">cccc

Is it possible?


texts: How to create a Rule to create a new entity of type Comment and a body with tokens?

texts:
Using drupal 7 and the Rules module, I'm trying to "create a new entity" of type comment. What it's strange, is that although all the other fields accept tokens, "the main body text" doesn't.
Tokens are considered as simple text.

Anyone experienced this and know how to solve it?


texts:
I have an issue with a new role I created. I created a role called "folders" and defined it in the module and AD, since we are using LDAP, however I can not see the role on grant. I have tried refreshing the browser, flushing all caches and logging in and out, but it does not show up on the roles list when I am trying to grant it.

Also I have checked that it has "show published content" checkbox checked

Please help me out what could be the issue and what to do to resolve it.

Thank you for your help


texts:
I am getting this error after transferring my site to another host. Not sure why it broke so need some help troubleshooting.

It seems the block_html_id and the content itself is not coming through. I am using the standard block.tpl file
What could be wrong?

here is the code from simplenews-block.tpl.php

47:     <div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

50:    <php if ($block->subject): ?>

56:       <?php print $content ?>

Here is all the code from the simplenews-block.tpl.php

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><?php print $block->subject ?>

<?php endif;?>
  <?php print render($title_suffix); ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php print $content ?>

I am thinking I need to delete the module and all tables related to it in the DB and start fresh...? What else is there to do?

This is the content of the template.php file.


texts:
I have upgraded a D6 to D7 site on my localhost. After upgrade I can login using admin credentials as per usual. I have disabled Clean URLs and I see that users are in detabase. Actually all works well however when I try to log in to a user account, I get:

The website encountered an unexpected error. Please try again later

I get this error also, when I create a user from admin panel.
I tested a lot of suggestions but none helped. So appreciate your hints.