texts: Can I define template variables for a block?

texts:
I thought that I could define my own variables in the build method of my custom block, but it does not work. Here's an example block definition:

/** ... Provides a 'Blubb' block ... @Block ...*/
class Blubb extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    return array(
      '#output' => 'Blubb',
      'output' => 'Blubb'
    );
  }

}

I render the block in with this twig template:

Output: "{{ output }}"

And find that the output varialbe is empty. The template displays just:

Output: ""

Does Drupal not want me to use varialbes in block templates?

Edit: I'm using Drupal 8.


texts: Add element to form during (element) validation checks

texts:
I'm trying to make a module that offers an #element_validate function which will check the element for dodgy looking data and if this is detected, tell the user this looks invalid and add a 2nd element to the form which can then be used to validate the dodgy-looking data.

The problem I'm having is that:

To add an element you need the form to rebuild. (see code referenced in the comment below)
To trigger a rebuild the form must have passed validation

This means that:

the #element_validate function cannot use form_error - else it would not be able to add the 2nd field. So I've had it instead set $form_state['rebuild'] = TRUE and issue a warning with drupal_set_message().
adding the 2nd element will only happen when there are not any other validation errors on the form (since these would also prevent the form rebuilding) leading to a confusing situation for the user: they will see the warning asking them to complete the 2nd element that doesn't exist. They'll correct the other errors on the form re-submit and then get that back again, this time with the 2nd element, which they'll have to complete before their submission is accepted.

Is there a way around this? e.g. a way to force a rebuild of the form from validation?


texts: ubercart - 100% discount on subtotal with shipping fee not passing proper values to paypal

texts:
We are running an Ubercart site.

We are generating bulk coupons for 100% value of an sku. On redemption the user is charged for only the shipping fee.

So we need the following passed to paypal

line 1 = subtotal - discount = £0

Line 2 = shipping fee = £3.99

Line 3 = total = £3.99

The problem we have is because the line 1 = subtotal - discount = £0 this is not passing to paypal properly - we can only make it work by combining the subtotal - discount + shipping fee as 1 line however this is causing confusion for the customer as it reads in paypal

Total = £3.99

Shipping = £0

hope you can help


texts: Advanced sorting question about drupal views

texts:
I have a content type with latitude and longitude coordinate fields. i have a view that is displayed on each page with this content type, and a google map plotting the location. Is there any way to sort a view using the distance between points?

distance=( ( current_page_lat - view_item_lat) + ( current_page_lng - view_item_lng ) )


texts:
I would like each kind of content to have its own base url, for example, example.com/international-news/friendly-url-of-node-id

How can I manage to get both a friendly url and a base url (friendly-url... and ../international-news/ respectively in the example) with the minimum possible modules (or only those from the core)?


texts: Make it so that ALL pages are served over SSL using .htaccess

texts:
I'm trying to make it so that ALL pages are served over SSL and have a https:// prefix.

I'm using the latest Drupal (as of 16.2.15) and running Apache (Fast CGI)

I'd really like it so that if a visitor were to type in:

http://example.com/test1
http://example.com/test2

they's end up at:

https://example.com/test1
https://example.com/test2

With the https added in automatically.

As per this question:
How to simply make the whole site HTTPS?

I've added this at the very end of the D7 .htaccess in the root of the domain:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This is not surrounded by any exceptions.

This seems to enforce SSL, but all pages with http:// get redirected to /index.php

So if I got to:

http://example.com/test1

I end up at:

https://example.com/index.php

NOT

https://example.com/test1

as I'd hoped!

Thanks for any help!


texts: Add and edit content form in a pop up in drupal

texts: Hi is there any modules available inorder to display the add content and edit content form in Drupal of all content type as a pop up. That is when i edit or add a content link it should display as a pop up.Plz suggest some solution without programmming.


texts: Search and Replace Scanner not publishing nodes after search?

texts:
I'm using the handy Search and Replace Scanner module to do a basic sitewide search. It's working well... except that it's not publishing the nodes after the it does the replace. It's making new unpublished revisions. This is quite annoying because then I have to go to all 50+ nodes that were changed and publish them all.

Is there any way around this? Ideally, I'd like the nodes to just be published after the replace.


texts: How to have new activity count above any view?

texts:
I have seen on your website, when there is a new question posted, the list shows a new activity button with a count above the list. How can I do that in Drupal with any view?

I am interested in showing such a thing with Statuses. There is an option in statuses settings to show a refresh button below the status stream when there is a new activity, but I want to show it above like on stackexchange and with a count.


texts:
How do I display multiple entity type fields into a single form?

I have retrieved multiple entity type fields using the following code.

$entity =\Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties([
    'type' => ['page', 'article'],
  ]);

I want to convert this into a form with edit options. I tried the following code, but it doesn't work.

\Drupal::service('entity.form_builder')->getForm($entity, 'form');

How can I achieve it?


texts: Update theme table using callback function in Ajax

texts:
I have two elements in my form: a select and a table element. Everytime onchange event is triggered on select element, I want to update the values in my table. I want to do query and change the values of '#rows' in the table.

function myid_print_user_page_form($form, &$form_state)
{
    $form = array();
    $form['myid_print']['option'] = array(
        '#type' => 'select',
        '#options' => array(
            0 => t('All'),
            1 => t("Printed ID's"),
            2 => t("Unprinted ID's"),
        ),
        '#default_value' => 0,
        '#ajax' => array(
            'callback' => 'myid_print_all_submitted_id_callback',
            'wrapper' => 'myid_table_wrapper',
        ),
    );

    // Build the sortable table header.
    $header = array(
        'id_number' => array('data' => t('ID Number'), 'field' => 'id_number','sort' => 'asc'),
        'student' => array('data' => t('Student'), 'field' => 'student', 'sort' => 'asc')
    );

    //Get the node data.

    $query = db_select('student', 't1',array('target' => 'import'));
    $result = $query
        ->fields('t1', array('studid','lastname', 'firstname', 'middlename', 'extname'))
        ->condition('t1.id_status',1,'=')
        ->distinct()
        ->execute();

    //Build the rows.
    $rows = array();
    foreach($result as $record){
        $rows[$record->studid] = array(
            'id_number' => $record->studid,
            'student' => $record->firstname . ' ' . $record->middlename . ' ' . $record->lastname . ' ' . $record->extname,
        );
    }

    //Build the table
    $form['table'] = array(
        '#theme' => 'table',
        '#header' => $header,
        '#rows' => $rows,
        '#prefix' => '
',
        '#suffix' => '
',
    );
    return $form;
}

I'm stuck here, I don't know what to put in my callback function.

function myid_print_all_submitted_id_callback($form, $form_state)
{
    //Do query here and put the query results in the table.
}

Any help would be very much appreciated.


texts: How to retain markup value added dynamically by jquery during validation?

texts:
I have added a markup which changes dynamically via jquery but on submission it validates and if there is a field level error like the title is missing it does not show the HTML which was dynamically added.
How can I retain the HTML which is added in markup via js

The code in form is

$form[$field_name.'-fieldset'][$field_name.'-popup-data'] = array(
      '#type' => 'markup',
      '#markup' => t('

'),
      '#attributes' => array('field'=> $field_name),
      '#weight' => 10,
      '#language' => $language->language,
    );

In the JS I added dynamically the HTML value inside the popup-data class but it disappears during validation


texts:
Currently example.com/comment/# shows the contents of the node that the comment is posted to. I want the page to only show the comment.

I'm assuming the page does not theme via .tpl.php. And if it isn't, do I put something like this in the template.php, and how do I override the current content of that page:

$comment = _comment_load($cid);
return theme('comment',$comment);


texts: Drush command to run cron won't work in Crontab

texts:
I am attempting to run two Drush commands from my crontab:

# m h  dom mon dow   command
*/2 * * * * drush -r /path -l https://www.domain.com/ cron
*/2 * * * * drush -r /path -l https://www.domain.com/ -u civicron civicrm-api job.execute

Both of these commands work when I run them manually on the server, however they do not appear to work through crontab, even though the log shows them running:

Apr 17 20:16:01 ip-000000000000 CRON[3736]: (ubuntu) CMD (drush -r /path -l https://www.domain.com/ -u civicron civicrm-api job.execute)
Apr 17 20:16:01 ip-000000000000 CRON[3737]: (ubuntu) CMD (drush -r /path -l https://www.domain.com/ cron)

Any suggestion as I cannot see why these would not be running?


texts: I have a route that takes data from APIs, so I would like to set the title in the controller and not in the getTitle function because it would mean calling 2 or more times the same API


texts: How can I add color to my taxonomy terms. Example I have terms "Working" and "Under maintenance". I want to color them green and red respectively. How can I achieve this?


texts:
I've placed a view block via Twig Tweak in page-front.html.twig before and it worked fine. That was on Drupal 8, but now I'm on Drupal 9. This's what I would have done in Drupal 8.

{{ drupal_view('library_carousel ', 'block_carousel') }}

This is what I gather I'm supposed to do in Drupal 9.

{{ drupal_view('library_carousel ', 'block_carousel') }}

It's not rendering anything. In Views, it shows the view machine name as 'library_carousel'. Inside the view, it shows the block machine name as 'block_carousel'.
I've confirmed that if I place the block via the Drupal interface, it does render correctly. I just can't get it to render via Twig Tweak. And yes, I've flush all the caches multiple times. Also, I have other things in the page-front twig that render correctly so I know the template is rendering in general.
Why isn't working?


texts:
I keep getting spammed/attacked looking at reports/db. Anonymous users keep trying to go to /user/register (but I disabled registering). So being annoyed by anons still trying to going to that url, I decided to write a rule:

{ "rules_anon" : {
"LABEL" : "Anon",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_view" : [] },
"IF" : [
  { "user_has_role" : {
      "account" : [ "site:current-user" ],
      "roles" : { "value" : { "1" : "1" } }
    }
  },
  { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "user\/register" } }
],
"DO" : [ { "redirect" : { "url" : "node\/39" } } ]}}

Context: Node 39 is Page Not Found

I tried it and it did not work, gives me do not have access message. So I tried the rule for a different url (/about) and it worked. I am guessing that url /user/register has a special case where Rules can not override it.

My question is: is there a way to redirect anonymous users from /user/register ?


texts:
I have 2 roles on my site. I created 2 pages and corresponding links through which each of the roles will register.

I want to prevent users from using the default user registration menu ("create new account") by either deleting it or hiding it. Also i want to prevent users from being able to visit user/register.

Please how can i achieve this?


texts: Views: How to create a list of OG groups that the current user has edit privileges for?

texts:
How to create a view that lists only organic groups that the current user has edit privileges for?

Each group could be created by different user so filtering by sth like user: created by will not work in my case.

I use set up Access: OG permission | update group or Access: Role

I didn't use any contextual filters nor could find any og/user permissions specific filters so the view shows the list of all groups in the system.

I log in as a non-administrator user/role.
I would prefer a solution that doesn't require custom module coding.


texts: In which contrib file/function should a class_alias() statement be placed so that it is always processed, regardless of the url being served?

texts:
To main backwards-compatibility I need to define two class aliases in my contrib module. Both of the source and target classes are within the same namespace within my module's namespace.
I placed the class_alias( ) statements at the top of my_module.module in open code, not a function, and this works for everything in the module, and also mostly for everything everywhere. I have created a second module which uses the original classes to check this. The second module has the first as a dependency. This works most of the time, however, there are a few places where I get a 'class not found' error, meaning that the alias statements have not been processed. For example, when viewing a few admin urls e.g admin/config/regional/language
So is there a better place than my_module.module where I can put the class_alias( ) statements, such that they are always processed?
My fall-back solution would be to re-create the two original class files, in the original locations, and each of them have the class alias statement, so that autoloading finds them. But that's a bit untidy and they will cause confusion as they are named incorrectly. It would be nicer to be able to have the two alias statements somewhere, and not have two nearly empty files left around.


texts:
My requirement is to migrate  content nodes in xml format to drupal 7 content type fields.The xml contains a node which has to be field collection in drupal.I know how to migrate field which are enity references and term references.But i am new to field collection migration.I am using drupal migrate contrib module for migration.
The field collection node in my xml file.

<myphotos_grid grid="true"><![CDATA[<rows>
  <row rowID="1">
    <rowAttribute>
      <theName>photo-name</theName>
      <value>photname1</value>
    </rowAttribute>
    <rowAttribute>
      <theName>photo-credit</theName>
      <value>my credit</value>
    </rowAttribute>
    <rowAttribute>
      <theName>photo</theName>
      <value>
      <attachment id="1009343343"/>
      </value>
    </rowAttribute>
  </row>
  <row rowID="2">
    <rowAttribute>
      <theName>photo-name</theName>
      <value/>
    </rowAttribute>
    <rowAttribute>
      <theName>photo-credit</theName>
      <value/>
    </rowAttribute>
    <rowAttribute>
      <theName>photo</theName>
      <value>
      <attachment id="4432434344"/>
      </value>
    </rowAttribute>
  </row>
</rows>]]></myphotos_grid>

I am writing a base class for my content types migration by extending XMLMigration class and it defines the migration source files and destination.Also i am writing corresponding classes for each content type which defines the field mapping by extending base class.

Above xml grid node in xml which has to be migrated to to field collection in my content type X in drupal 7 site.

My queries

Whether i need to write a seperate class for field collection extending my custom content type X migration class or adding the field mappings for field collection in the custom content type X migration class?
Whcih is the best standard to migrate field collection in drupal?

I am new to this field collection migration,please help,Also very sorry for my english.


texts:
I'm trying to create a custom block programmatically in a Drupal 7 project.
I've implemented the two hooks hook_block_info() and hook_block_view($delta=''), I can't find the created block on my_site/admin/structure/block admin page.
Here is my code:

<?php

/**
 * @file
 * File for Header module block
 */

/**
 * Implements hook_block_info().
 */
function my_header_block_info() {
  return array(
    "headers" => array(
      "info" => "Header Block",
      "cache" => DRUPAL_NO_CACHE,
    ),
  );
}

/**
 * Implements hook_block_view().
 */
function my_header_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case "headers" :
      $block['subject'] = 'HEADER';
      $block['content'] = 'Hello world';
      break;
  }

  return $block;
}

What did I do wrong?

UPDATE
It's a basic project should I install a necessary contrib module for make it working?


texts:
Recently I lost comments and everything related. In the module list I see "Comment (missing)". All I did before:

CK editor update
Installed the Better Formats module.

Manual updating the core from 7.27 to 7.28 didn't help. All comment module files are in the folder they suppose to be (modules/comment/). But Drupal doesn't see the module.

Any help would be appreciated.


texts: How do I stop View/Edit tabs appearing on Taxonomy driven Pages when I am not logged in?

texts:
I have a View and Edit button appearing on pages that are Taxonomy driven, even when I am not logged in (and in Incognito Mode).

These pages use the URL /taxonomy/term/%taxonomy_term and Views, using info from the URL, are used to display certain data on these pages. For example, with /cars/honda/civic 'cars', 'honda' and 'civic' would be used in the Views to show relevant information about Honda Civics.

The issue is that whilst there is no View and Edit buttons appearing on the base /cars page, they are appearing on every sub page (/cars/honda, /cars/toyota/camry, etc).

I can't find anything out of the ordinary in Permissions.

Would any one know what I could do to stop this?

(PS clicking the Edit button whilst not logged in does nothing - just takes you to 403 page).


texts: How to update Drupal securely using GUI/web interface

texts:
The admin/reports/updates/update page lists updates, and there's what looks like a handy button Download these updates at the bottom.

And then you're asked for your SSH user and password.

Now unless you're running over SSL, this is a massively daft thing to do. Provide your server credentials over plain http?

If Drupal really needs to do an SSH loopback (as the help text explains, it's highly likely that the webserver is the SSH server it will connect to) in order to run updates, then surely there ought to be a way to provide the webserver's user with a DSA key so that users don't need to pass credentials in plain text.

Is there a way? Or is this really as insecure as it looks!

(I generally use SSH and drush to do updates, but as there's a GUI there, which looks nice, I feel it ought to work)


texts: How do I hide text format options in node view with in place editing?

texts:
I am using drupal 7 version with in place editing module editablefields
I was able to hide the text format options in edit mode with simplify module  but in node view mode are still there.

Please, do you have any module or custom module with hooks that I could use or do?
!


texts: Error when adding BCC to email handler with webforms and smtp

texts:
I use SMTP to handle emailing and Webform to generate my forms on a drupal just upgraded to 8.7.10

I have recently discovered an issue where webforms that have an emal handler set to include a BCC email address throw the follwing error:

error: Call to undefined method Drupal\smtp\Plugin\Mail\SMTPMailSystem::_get_components()

The form submission does get saved but the confirmation process breaks so the user is not notified the submission saved and no emails of any kind are sent out.

Not including BCC fixes the problem. I use BCC in email handles to debug on a number of my sites and have never had this issue before. Any ideas? Is this a problem with webforms or smtp modules?


texts: How to hide share content option under profile type?

texts: There is an option "Share Content" under every profile type. It is being displayed to all users apart from admin. I just want to hide it. I searched for it enabling Devel module but did not get anything belongs to the option. Please share your answer if anybody knows how to do it?


texts: Entity Registration module: Enable registration by default or programmatically

texts:
By default, the Entity Registration module disables the registration. We need to enable it everytime a node is created from 'Manage Registrations - Settings' tab. How to automate the process?

I tried changing the 'status' value to '1' in registration_field_info() of registration.field.inc but it didn't work.

Is there a way to do it programmatically, otherwise?


texts: i'm trying to use an exposed filter with my views but i'm not getting my ajax to enable under the advanced link so my content can be dynamic. I try jquery update module to fix it but didn't work tried another browser didn't work too i really need help here...


texts:
I'm fairly new to drupal and this is my first time posting on stackexchange. Constructive critisism and feedback are more than welcome.

All regions in my custom theme are placed inside the body tag from html.html.twig file. Is there any way to create a region that is located underneath the body?

The markup should look something like this:

header region block(s)
...
footer region block(s)

Right now the way it's rendered it looks like this:

 header region block(s)
  ...
 footer region block(s)

I'm on drupal 8.6.
Thanks in advance,
Geordi


texts:
How do I get the rate vote number, e.g. the number after "funny," "angry," or "mad"?
I looked for the values in the database, but I didn't find a column that stores it.thank you.


texts: Attaching more than one feeds url to a single content type

texts: I have a feeds setup in which i have a content type discount travels.I have created a feeds import using xpath xml parser.Now i want to attach one more link to the same content type.I know currently there is no provision for this in the feeds module.Instead we can create one more new feed importer with new link and attach it to the same content type.I doubt is it possible to have 2 unique fileds in the same content type.I have mapped one field from first URL to guid and marked it as unique.Then i mapped another field from second URL to guid and marked it as unique.Then i attached the new import to the same discount travels content type.Has anybody achieved this before using feeds and feeds import.Any help will be appreciated.Thanks in advance.


texts: Clean URLs with multi-site only with suffixes / sub-folders

texts:
In D7 Multisite, I'd like to use clean URLs. However, these sites share the same domain but have different folder names.

For example, the login pages would are currently

https://domain.ext/red/?q=user
https://domain.ext/pink/?q=user
https://domain.ext/green/?q=user
https://domain.ext/purple/?q=user

How might I set this up to allow clean urls and have login pages as such:

https://domain.ext/red/user
https://domain.ext/pink/user
https://domain.ext/green/user
https://domain.ext/purple/user

The .htaccess file is untouched. The apache config file /etc/httpd/conf.d/aliases.conf contains:

Alias /blue /var/www/html
Alias /pink /var/www/html

And inside of /var/www/html/sites/ I have folders

/var/www/html/sites/blue
/var/www/html/sites/pink

Can I accomplish this by editing the $baseurl in each settings.php file and adding a redirect per site in .htaccess?


texts: Leaflet maps multiple icon types in views

texts:
I have a leaflet map for various attraction types which works fine with using the standard blue icon.

What I'd like is to be able to specify a different icon based on the attraction type field.

I thought this feature existed based on https://drupal.org/node/1882806 but I can't seem to get anything to work.

I've been trying to set it up through the Leaflet settings in views using the POINT ICON Field (html DivIcon) setup. However, whatever I try seems to end up with a page full of errors and no icons.

I can't find any documentation on using this feature so would really appreciated some help.

Thanks,
Chris


texts: How do I get a field value in a template?

texts:
I want to change the default HTML for a custom field called field_product_image and I created the field--field_product_image.html.twig template. Now I need to fill in the following information in the HTML, but for some reason I cannot get the content of the fields.

<img src="{{ TWIG }}" alt="{{ TWIG }}" />

I tried different suggestions like {{ content }}, {{ field.field_product_image }}, {{ field.field_product_image.value }}, {{ content.field_product_image }}, {{ content.uri.value  }} but they don't output the image link.


texts: How to validate node field for minimum length for a custom content type?

texts:
I notice body has some preselectable minimum lengths.

How do I do this for text fields?

Also, how do I set a custom minimum length for node body of a content type?


texts: Filter criteria affecting different displays in same view

texts:
I have a view that displays content in a table form so admins can quickly look through the content. There are two displays (pages).

Page1: Lists all content and exposes the filters for type and published to the user so they can narrow down there view. But initially all content should be displayed.

Page2: Has criteria set to show only type=photo and published=no.(not exposed)

Everything else is the same between the two.

The filters on page2 are affecting page1. When you first land on page1, the filter controls say -any- and -any- but the view is filtered to type=photo and published=no (page2 filters). If you hit apply the filters are removed, but you can see how this could be confusing to users.

How can I prevent the filters on page2 of the view from affecting page1.


texts: Drupal 8: SQL Insert with 10.000 datasets exceeds 300 MB PHP memory via batch_set()

texts:
I have tried to use Drupal's batch_set() function to execute a SQL insert with 10.000 items. It exceeds 300 MB of PHP memory. 512 MB of PHP memory are getting the job done. This is the case, if I use the batch_set() function and if I do not. There is currently no benefit in my use-case, either I use batch_set() or I am not using it. I expect from batch_set() to keep the PHP memory consumption low.

Here is what I am doing. After an user updates the user account, I am updating all nodes for internal purpose. This service method's code is being triggered:

$batch = array(
  'title' => 'Rebuilding user permissions',
  'init_message' => 'Start rebuilding user permissions.',
  'progress_message' => 'Completed @current step of @total.',
  'error_message' => 'Rebuilding user permissions has encountered an error.',
  'operations' => array(
    array(
      [get_class($this), 'updateGrants'],
      [$grantsByNid]
    ),
  ),
);
batch_set($batch);

The $grantsByNid contains around 10.000 items. The method which is triggered via the batch, is this:

  /**
   * @param array $grantsByNid
   */
  public static function updateGrants($grantsByNid) {
    $query = \Drupal::service('database')->insert('node_access');
    $query->fields(
      ['nid', 'langcode', 'fallback', 'gid', 'realm', 'grant_view', 'grant_update', 'grant_delete']
    );
    foreach ($grantsByNid as $nid => $grants) {
      foreach ($grants as $grant) {
        $query->values([$nid, $grant->langcode, 1, $grant->gid, $grant->realm, $grant->grant_view, $grant->grant_update, $grant->grant_delete]);
      }
    }
    $query->execute();
  }

How can I prevent $query->execute(); from causing this error:

  ( ! ) Fatal error: Allowed memory size of 201326592 bytes exhausted (tried to allocate 20480 bytes) in /home/jepster/PhpstormProjects/permissions-by-term-behat/drupal/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php on line 108

I have googled a lot and I cannot find out, why Drupal 8's database functionality is using all the memory and why the batch functionality is not preventing this.


texts: How to programmatically fetch the results of a view with facet filtering

texts:
Setup

Drupal 8.2 + Views + Facets
View articles …

… with first sub-view page_1
… has facets

View filter: field_title
View facet: field_facet allows multiple values, e.g. A and B

Concept

I would like to fetch the view results programmatically by reusing the $_GET query values. (The $_GET values are serialized and stored for later usage.)

Problem

The results are correct when working with only non-facet filters. Facet filter values are ignored and won't be filtering the results by the provided snippet.

Is the View working as expected?

Yes, the view is working as expected: Filtering works when visiting the website with a HTTP client and the query ?field_title=Hello&field_facet[0]=A&field_facet[1]=B.

Snippet

<?php

use Drupal\views\Views;

$view = Views::getView('articles');

$query = [
    // Filters results with title `Hello` as expected.
    'field_title' => 'Hello',

    // The programatically executed View ignores
    // the following facet based values for filtering.
    'field_facet' => ['A', 'B'],
];

$view->setExposedInput($query);

// bool(true)
var_dump($view->execute('page_1'));

$result = [];

/** @var Drupal\views\ResultRow $row */
foreach ($view->result as $row) {
    /** @var Drupal\search_api\Item\Item $item */
    $item = $row->_item;

    /** @var Drupal\node\Entity\Node $node */
    $node = $item->getOriginalObject()->getValue();

    $result[] = [
        'nid' => $node->id(),
        'title ($item)' => $item->getField('title')->getValues()[0],
        'title ($node)' => $node->get('title')->getValue(),
    ];
}

Experiments with the REST module

The REST module allows to create views with JSON results.
Sadly, this module is also ignoring facet based filters.

Question

How do I inject/attach the facets to use their filters?


texts: How do I insert multi image with restFul service?

texts:
I have a little issue I try to add to my node with RESTful service on Drupal 7 multiple fids for a image gallery and I can't finish the process, I try

'field_gallery[und][0][]' => array(
  'fid:2381',
  'fid:2375',
),

and I don't know where I do it wrong. This is a request with php curl.

<div class="image-widget-data"><input type="file" class="form-file" size="22" name="files[field_gallery_und_0][]" id="edit-field-gallery-und-0-upload" multiple="multiple">
  <input type="submit" class="form-submit ajax-processed" value="Upload" name="field_gallery_und_0_upload_button" id="edit-field-gallery-und-0-upload-button">
  <input type="hidden" value="0" name="field_gallery[und][0][_weight]">
  <input type="hidden" value="0" name="field_gallery[und][0][fid]">
  <input type="hidden" value="1" name="field_gallery[und][0][display]">
</div>


texts: In Views, display additional fields from an entity reference

texts:
I have a content type with a field that is an entity reference to another content type called "URLs", and the "Allowed number of values" is set to "Unlimited", meaning that one record can have multiple URLs associated to it.

When I come to the View for this node, I have added a Field for "URLs", and under "MULTIPLE FIELD SETTINGS" I have ticked "Display all values in the same row", and Display type: Unordered list.

This works well, and I get the the list of associated URLs in an unordered list, like so:

www.domain1.com
www.domain2.com
www.domain3.com

Where it gets complicated, my "URLs" content type has another field called "field_url_type", which is a field type "List (text)". This contains the type of URL, (eg. Production, Development, Staging, Decommissioned, etc).

In the main content type display View, I would like to display this additional field from the URL content type next to the URL values, like so:

www.domain1.com (Production)
www.domain2.com (Development)
www.domain3.com (Decommissioned)

I tried using the Views > Configure Field > REWRITE RESULTS panel to include the REPLACEMENT PATTERNS for both fields, like so:

{{ field_url }} ({{ field_url_type }})

... but this didn't work. I'm guessing it is more complicated than that!

Does anyone know how I can display this additional field from a content type referenced by an entity reference field in a node view?


texts: How to set page title for forum's Active and Unanswered tabs in Drupal 7?

texts:
I have to set up forums in Drupal 7. I want to set page title, meta keywords and meta description for forum tabs like

  Active Forums and Unanswered Topics for forum.

How to do this?


texts:
I have a select input that's pulling it's options from one of our site's vocabularies.  I'd like, however, to alter the options to include a data attribute based upon a custom field within the term.
The input looks like:
$form['my_sample'] = [
  '#type' => 'webform_term_select',
  '#title' => t('Sample Reason'),
  '#vocabulary' => 'sample_reasons',
  '#tree_delimiter' => '- ',
  '#empty_option' => t('Make A Selection'),
  '#select1' => TRUE,
];

I tried hook_webform_options_alter(), but that wasn't the right approach.
How do I alter/add to the select options in this scenario?


texts: Adding CSS class to flagged node teasers

texts:
I have tried the following code corolla theme's template.php

/**
 * Implements template_preprocess_node().
 */
function corolla_preprocess_node(&$variables) {
  $flag = flag_get_flag('sold'); // Machine name of your flag.
  if ($flag && $flag->is_flagged($variables['node']->nid)) {
    $variables['classes_array'][] = 'node-flag-sold';
  }
}

This is supposed to add CSS class="node-flag-sold" next to "node". But looking through my firebug, there arenosuch classes added.

Please note, that my node--content-type.tpl.php is custom rewritten.  Do I need to add anything there?


texts: How to include task links in twig node template

texts:
I have created a custom twig node template. It displays the content in the manner that I want but it is not displaying the task buttons. How do I include the display of the task buttons if the user who is viewing the page has the permission to see them?

I have tried Googling for a solution, but haven't found anything. I figure this should be pretty straight forward to do (at least I would hope it is).

Thanks.


texts: How can I set a certain cck value to selected nodes using View Bulk Operation (VBO)?

texts:
I have a text type cck filed (checkbox widget) allowing multiple values.
I need to add one of the values of this field to selected nodes using VBO.
I suppose Modify node fields (views_bulk_operations_fields_action) is the way to go but how can I exactly do it?
I need to add just one value but keeping the existing values the nodes currently have.


texts: How can I rebuild an image field with values in an Ajax callback?

texts:
in Drupal 8 I have media form with select box having ajax property and an image field.
on select box value change I want to assign specific file to the image field.
On form_alter this code work, the image field received the file and correctly rendered.
$form['field_media_image']['widget'][0]['#default_value'] = array('target_id' => "165", 'alt' => 'ttt', 'fids' => ["165"]);

but on ajax callback it's not working even if I set value.
function myAjaxCallback(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form['field_media_image']['widget'][0]['target_id']['value'] = array('target_id' => 165, 'alt' => 'ttt', 'fids' => [165]);
  return $form['field_media_image'];
}

Thanks for helping


texts:
I want to create a list of users with their orders. I know I can create it with the Views module, but when I select user as view type, there is no relation I can use to get their orders.

Some users may not have any order. I want the list to include also those users without any order.


texts: How can I build an accordion without Javascript using the Field Group module?

texts: I'm using the Field Group module to make accordions on my site, but it loads JQuery and slows the page down. Is there a way to do this without JS?


texts:
I am using the bluemarine theme Drupal 7, and I spent a lot of time trying uselessly to move down the site name. When I use the Firebug, it moves, but when I make changes on the style sheet it won't. I am using the following CSS lines:

#site-name {
  margin: 0.6em 0 0 0;
  font-size: 2em;
  white-space: nowrap;
}

I tried with the above margin property and I even used margin-top property.
Even when I change the above font-size it won't change. Can you please save me from this vicious circle.
Thanks


texts: Feeds Module Does not import float numbers

texts:
I have used the Drupal feeds module a couple of times so far and without any problem. The last couple of days I have been trying to import a csv with float numbers and it will not work. I have tried to use decimal numbers and it still did not import them. When i change the fields to text it works. With the tamper module i have tried and set it to "format to number" but no luck. Here is what the csv looks like:

  guid;Delivery;Price;INDEX
  1;02.01.2010;5.040;5;13,243
  2;03.01.2010;5.040;5;13,243

The seperator is ;
The integers and the Price Decimal import fine but the index is empty. No Error message.

If anyone could help me I would appreciate it ;)

regards

wolfmarter


texts: Add parameter to the URL based on a field value

texts:
Is it possible to append a campaign tracking code to the requested URL basing on a specific field value on the linked node? I'm trying to use a path_processor_outbound service, but it doesn't work quite as expected and it works rather randomly.

This is the code I am using.

function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {if(isset($options['entity']) && $options['entity'] instanceof \Drupal\node\NodeInterface ) {
      $node = $options['entity'];

      if($node->bundle() == 'article') {
        $channel = $node->get('field_channel')->getValue();
        $promotions = array(10);
        $channel_value = reset($channel);
        $channel_id = $channel_value['target_id'];

        if(in_array($channel_id, $promotions)) {
          $options['query']['foo'] = 'bar';
        }
      }
    }
    return $path;
  }

I have a feeling this is correct approach for links to nodes generated on site (teasers on front page), but it doesn't append parameters on page request.

I also considered adding parameters to the path alias, but that doesn't seem to be right and JavaScript code would be added too late.


texts: Display of hierarchical Taxonomy in views along with the related content

texts:
I have a Hierarchical Taxonomy like:

  Bachelor of Degree
  -Year1(child term of Bachelor of Degree)
  --Term1(child term of Year1)
  -Year2
  --Term2

  etc etc...

The contents content1, content2... of a Content type will go under Terms Term1, Term2...

Can you kindly help me in getting the view as:

  Bachelor of Degree
  -Year1(child term of Bachelor of Degree)
  --Term1(child term of Year1)
       content1
       content3
  -Year2
  --Term2
       content2
       content4


texts:
I have two profile types teacher and students. They both have a taxonomy field “State”.

Below each teacher’s profile I want to show students from his State.

I have added two relationships:

1) User: Profile
2) Field: State (which is a taxonomy term field).

Then added a contextual filter Taxonomy term: Term ID. Under "When the filter value is NOT available" have selected default value "Taxonomy term id from url".

But it doesn't displays any matching profiles. I have done similar functionality for content entity type and it works. I guess the problem is due to profile entity type or am I missing something?

Can you please tell where I am going wrong? Thanks!


texts: How to Auto Publish nodes based on set interval?

texts:
I have nodes being generated from a Feeds import on a periodic basis, however when they are imported I would like them to be queued to be published on an hourly basis (or x minutes)

I have looked at Scheduler and also Publish Queue. But those modules require input. I want this done automatically, so that as soon as nodes are created via feeds they are put into a queue to be published over a set interval of time.

How can I make this happen? Maybe I can just code this myself if there is no option out there. Something along those lines might work:

Get oldest node unpublished node
Publish node
Run this code once every cron run

Any suggestions?


texts: Display a taxonomy term every number of rows

texts:
I have a view with Infinite Scroll Pager giving me the latest products of the website.

Every taxonomy term has an image attatched on it.

I want to display taxonomy terms every 3 rows of products.


texts: How can I translate the  option for a grouped exposed filter in Views?

texts:
I have an exposed filter in Views that uses the Grouped filters option to present choices to users.  By default, an <Any> option is provided.  My site is multilingual, so I want to translate this:

I am using the i18n suite of modules as well as i18nviews.  I first searched using the Translate interface screen at admin/config/regional/translate/translate and I translated <Any>; however, when viewing the page, <Any> is still displayed, not the translated value.

There appears to be no option to customize the <Any> text within the Views UI.

I am able to translate the (user-defined) grouped filter options using i18n and i18nviews through the Translate Interface screen.

What do I need to do to translate <Any>?


texts: How to link a view to a user profile created using views

texts:
I created a view which displays users on my site.  In the view, the "name" of users links to their individual profile.

Now i want to have more control over information displayed to users when they view other peoples profile.

To achieve this, I am of the opinion that i need to create another view to display the user profile. Where i see a challenge ahead is how to make my first view link to the individual user profile based on my new view.

Please, how do i achieve these or is there a better way?

Thanks in anticipation.


texts: Programmatically load and submit the user form

texts:
I want to programmatically load the user profile form for a particular user and re-submit it without changing any of the existing values. The reasons are complex but I am dependent on gathering data during the form submit phase.

I can see functions to build an empty form ( drupal_get_form ) and to submit a new form ( drupal_form_submit ), but I can't see how to load the form prepopulated with the correct $form_state.


texts: How to change text format of summary/trimmed field?

texts:
Is there a straightforward way to change the summary/trimmed text to "full html" in Drupal 8?

There are workarounds such as creating separate body fields and using them as the summary but I am specifically asking about changing the text format of default summary/trimmed field of "Text (formatted, long, with summary)".

To put it another way, how to I add the CKEditor bar to the summary/trimmed text.


texts: How to add image field in a custom module form?

texts:
In our custom module, mymodule we have a form MyModuleForm where we want to allow for an image to be uploaded or chosen from already uploaded images. Below is the MyModuleForm.php file, but cannot figure out why we are not able to upload the Image and save it. There is a menu link where the module's form is and when we navigate to the page we see a blank page with no field or widget to set the image.

Goal

To be able to make the Image Browser widget display so that we can use an existing image or upload one.
Store the image using MyModuleForm from the custom module.
We should be able to change the image as needed and save the configuration.
Set file status to permanent.
Add to file usage calculation.

How do we add an Image field on our MyModuleForm so that we can either use an existing image or upload a new one?

Here is what we tried but didn't work

MyModuleForm.php

class MyModuleForm extends ConfigFormBase {
  protected function getEditableConfigNames() {
    return [
      'mymodule.settings'
    ];
  }

  public function getFormId() {
    return 'mymodule_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('mymodule.settings');
    $form['my_file'] = [
      '#type' => 'managed_file',
      '#title' => 'my file',
      '#name' => 'my_custom_file',
      '#description' => $this->t('my file description'),
      '#default_value' => $config->get('my_file'),
      '#upload_location' => 'public://'
    ];

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

  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Check if image is uploaded.
    if(isset($form_state['default_press_release_image'])) {
      // Set file status to permanent.
      $image = $form_state->getValue('my_file');
      $file = File::load($image[0]);
      $file->setPermanent();
      $file->save();
      // Add to file usage calculation.
      \Drupal::service('file.usage')->add;
    }

    $this->config('ns_default_images.settings')
      ->set('default_press_release_image', $form_state->getValue('default_press_release_image'))
      ->save();

    parent::submitForm($form, $form_state);
  }
}


texts: How to only define hook_menu path to certain URL

texts:
Consider this simple implementation of hook_menu()

/**
 * Implements hook_menu().
 */
function helloworld_menu() {
  $items['hello'] = array(
    'title' => 'Hello world!',
    'page callback' => 'helloworld_page',
    'access callback' => TRUE,
  );

  return $items;
}

/**
 * Page callback for /hello.
 */
function helloworld_page() {
  return "Hello World!";
}

This code work when I visit example.com/hello, but so does when I append extra argument to the url like example.com/hello/world. How do I only define the example.com/hello only without getting all these 'derivative' URL defined as well?


texts: how to install commerce_kickstart on an environment with PHP memory_limit less than 128M?

texts:
I tried the full core install aproach and got a warning that I only had 96M on php memory_limitand kickstart needs 128M. tried anyway and sure enough got a memory error at the very end of the installation. I looked around my host and I'm sure I can't change that.

How can I make this installation work?


texts: Is there a clear suggested path for migrating user fields from core 6 to 7 to 8?

texts:
For those still migrating user data (e.g., interests, languages spoken, etc.) from Drupal 6, given the current status and plans for Drupal 8, is there a preferred way to manage those fields in Drupal 7?

With the discussions of seen about what should be in core or contributed and how profile fields should be treated in D8 I'm wondering if it would make sense to think ahead to the next major migration when considering whether to use Profile2.


texts: best location for features related theming customizations

texts:
The following is a simplified scenario of an organizational problem I'm facing.

I have a site with a single features module which handles all my content types. My features module is called foo and my zen subtheme is called bar.

One of my content types (e.g event) needs a special class on it so I have 2 options.

Add the class via the foo.module:

function foo_preprocess_node(&$vars) {

  if ('event'==$vars['type']) {
    $vars['classes_array'][] = "extra-class";
  }

}

or add the class via the template.php of bar theme:

function bar_preprocess_node(&$vars) {

  if ('event'==$vars['type']) {
    $vars['classes_array'][] = "extra-class";
  }

}

Which one of the two is the best location for this theme related customization? Without the feature there will be no event content type. So it feels like placing the code in the feature module file together with the content types is the best place.

On the other hand this css class is theme related so it also feels correct to place it in the template.php.


texts: How to fetch form state value of a form on clicking custom button?

texts:
How to fetch form state value of a form on clicking custom mobile verification(required field in register form) button ajax based suppose I want to show mobile number(Form_state value) of form on clicking ajax based button named mobile verification. Here's the code:

 if($form_id == 'user_register_form')
 {

        $form['mybutton'] = array(
        '#type' => 'button',
        '#name' => 'mybutton',
        '#value' => 'Mobile Verification',
        '#title' => t('Mobile Verification'),
        //'#submit' => array('my_ajax_callback'),
        '#prefix' => '
X
<form action="#">
                        Enter OTP

                        <input type="text" class="otp" name="otp" value="">

                        <input type="submit" class="otp_submit" value="Submit">
                        </form>

',
        '#weight' => 19,
        '#ajax' => array(
                'event' => 'click',
                'callback' => 'my_ajax_callback',
                'method' => 'replace',
                'wrapper' => 'form-wrapper',
          ),
        );

}

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

     echo '
';
     print_r($form_state);
     die;
   // return $form;
 }

In short i just want without saving form data can we show form_state value on clicking ajax based button in popup form.

The above code not working for me not able to get form_state value


texts:
I'm looking to write the following module, any help, guidance, and advice would be greatly appreciated.

User is logged into site.
Site has two content types: page & note.
Logged in user can create content type note only.
User is viewing a node: /node/5.
User selects some text in the body.
Link/icon is shown above selected text.
User clicks clicks and is taken to /node/add/note
Some fields are pre-populated on Node edit page, including:

title, field_source_quote, field_entity_reference_nid

User adds his "note" to field_user_note and saves note

From my basic understanding of JSON, I should be able to create a JSON of the user selected text with something like:

var selectedText = "";
selectedText = window.getSelection().toString();

var noteData={
    "sourcePath": "/node/being/viewed",
    "selectedText": selectedText
};

How do I get noteData to a module? Better yet, how do I get nodeData to the node/add/note page and pre-populate the correct fields?

Any help would be greatly appreciated.

======= Updates Below =============

Passing data through local storage (Andrew's Approach)

I can confirm this approach is viable. There are a number of issues, however that this presents:

I'm sure this is not the most "drupal-ized" way to perform this.
If the node admin pages use a different theme, the js to retrieve and apply the data must be within the other them.
Need to have a persistent marker placed for the user ui (i.e. highlighting the text they have added a "note" to).

I've come across a library that might be helpful for #3: Rangy (https://github.com/timdown/rangy).


texts:
I want to add a view mode for particular entity type programmatically in Drupal 8.I think the documentation on view modes for Drupal 8 has not been provided like it was provided for Drupal 7 hence I am facing problem in implementing this.Any reference from module in core would help.Thanks

What needs to be done if I want to add view modes to many entities?


texts: Disqus include causing Bad Gateway errors

texts:
I've set up Disqus on my drupal site and it was previously working, but it's suddenly not working and I have no idea what changed.

This is one of my nodes with Disqus in the block at the bottom:
http://liberalgeek.com/content/republican-todd-akin-and-legitimate-rape-doesnt-cause-pregnancy

I'm getting a 502 Bad Gateway message in my javascript console on Chrome:

GET http://mediacdn.disqus.com/1345491156/uploads/themes/dsq028ee724157b05d04e7bdcf237d12e60.css?1557 502 (Bad Gateway) client.js:6
DISQUS.requireStylesheet client.js:6
Backbone.View.extend.bootstrap client.js:84
Backbone.View.extend.initialize.b client.js:81
b.Events.trigger lib.js:108
(anonymous function) client.js:16


texts:
I want to display the pool result output by the Poll module by the number of votes, instead of the default order which is the same for all the polls.
I made two attempts:

Creating a poll view displaying the choice field, with the choice target sort criteria
Unfortunately, it doesn't sort them accordingly.

Altering the template file used by the Poll module (poll-results.html.twig) where <dl> {{ results }} </dl> is used to show the poll result
I'm not sure where the variable is created and how I can change its value.

How can I alter the order used to show the pool result?


texts:
I have a View of nested taxonomy terms. As I filter using a somehow convolute logic (GET parameters, URL-frienly parameters and user permissions), I use

 $list = views_get_view_result("NAME_OF_MY_VIEW");

 foreach($list as $item){
     ... -> handle the fields.

And in my custom module I use MYMODULE_views_pre_view to set the different filters:

$filters = $view->display_handler->get_option('filters');
$handler_name = 'field_rf_product_value_1';
$terms = mega_convolute_function( $handler_name ); // extract data from several sources.
$handler = $view->display_handler->get_handler('filter', $handler_name);
$handler->value = $terms;

Is that a correct procedure? Using only the views function I start to see problems to appear, for example I can only get access to0 the raw image field path, "[uri] => public://category/cables.png" (for example), so if I want to show the thumbnail I would need to use the Drupal function image_style_url, i.e., I get some freedom to feed the filter data but I start to loose the properties set in the Views UI. What would be the spirit of the views_get_view_result function ?


texts: Drupal Commerce: How to prevent (or suspend) checkout where no shipping rate is defined?

texts:
I am using the physical products module to calculate weight based shipping rates.

My client sells heavy items for which they sometimes need to arrange negotiated shipping rates for offshore delivery areas, such as UK Highlands and Islands.

Because a shipping rate cannot always be provided, this can result in a situation where the system returns a shipping service option of  'No shipping rates found for your order. Please continue the checkout process'.

From this situation it is then possible for a buyer to complete checkout without incurring a shipping cost at all!

What is the best method for preventing (or suspending) checkout in such situations? In such a way that the shop owner can provide a quotation based shipping rate before the buyer resumes checkout?

I understand that the shop owner can manually edit a cart order to include a manual shipping rate and I am also aware the Rules can be used to direct the order flow.

But how to prevent (or suspend) checkout before a shipping rate has been quoted?


texts: Webform Address Element and Canada provinces

texts:
In the webform (drupal 8) module I am using the address element and notice that the state/province field does not contain any Canadian provinces - only US States and Territories.

Where can I add the Canadian Provinces?


texts:
After having solved How to calculate the average Fivestar rating correctly?, I have a computed field Average score that displays the average score of a node. I sometimes want to display this field in a View as a rating (e.g. 4.2/5) and add some more markup to it. For the moment, I have different templates of the form views-view-field--MY-VIEW--field-average-score.tpl.php with the same code:

<?php $rating = round(($output/100) * 5, 1); ?>

  <?php print $rating . '/5'; ?>

Having all these duplicate templates seems silly to me. Is there a way to only have one and somehow point out which Average score fields should be styled accordingly? Simply using views-view-field--field-average-score.tpl.php is not what I want, since I don't always want to style Average score like this.


texts: When to use the Flag module versus a boolean field?

texts:
In terms of performance, maintenance, and future expansion/migration, what are the advantages and disadvantages of using the Flag module versus a boolean field?

In my case I would use the module to mark articles in a newspaper website that will be featured on the front page.


texts: Is there any module that can show whoever edits a node?

texts: Is there any module that can show whoever edits a node, just like how happens on Stack Exchange sites, where the user who edited a post is shown together the author of that post?


texts: 7 - drupal_goto() ignores $path if $_GET["destination"] is set?

texts:
I have a Drupal 7 site that implements an OAuth Consumer using the OAuth module. I have a page callback defined for /oauth/login that performs the first step of the dance, then redirects the user-agent to the authorization endpoint on the Provider via drupal_goto(). The site is configured to restrict access to all pages for "Anonymous User", and the "Access Denied" page is set to my custom callback.

When visiting a page as an unauthenticated user, however, Drupal goes into an infinite redirect loop. I traced the problem down to the logic in drupal_goto() itself, which inspects the value of $_GET['destination'] and overwrites the $path argument before ever inspecting the value provided, thereby redirecting to the original path. This seems like a bug to me, but I recognize that I might just be "Doin It Rong", too.

Looks like there are a couple of other questions out here that are similar:

Drupal login not redirecting to SSO (external) server login page (Drupal 7)
drupal_goto ignored in custom form submit handler (Drupal 7)
Making drupal_goto Ignore ?destination=foo (Drupal 6)

Does anyone have any insight as to why this behavior exists? I understand why the "destination" path exists and what it's used for, but it seems to me that drupal_goto() should only ignore the value of the $path argument if no value has been passed or the value passed matches the currently executed path. If it's a real bug, I'll submit a patch and some tests to cover the use cases.


texts: Need help theming elements - $classes not being output

texts:
I'm having hard time theming text substitutions performed by my custom input filter.
I'm using this theme hook:

function ppf_theme($existing, $type, $theme, $path) {
  return array(
    'ppf_link' => array(
      'template' => 'brand_product_link',
      'variables' => array(
        'title' => NULL,
        'nid' => NULL,
        'classes' => NULL,
      ),
    )
  );
}

accompanied by this code in my filter process callback:

return theme('ppf_link', array('nid' => $node_id, 'title' => $node_title, 'classes' =>  implode(' ', $classes)));

This basically works - i.e. I'm successfully printing out the nid and title variables in the brand_product_link.tpl.php file. I'm however unable to sneak in my custom classes in the classes variable. No matter what the classes array contains, Drupal will always render a single class ppf-link (which I assume is a default safe css class taken from my theme hook name). If I rename the variable to my_classes though - everything works ok.

Now, I'm not writing to get a fix for something that works, but to learn what I'm doing wrong when it does not. Is classes a protected variable? Should I use a template_preprocess_ppf_link function, if so - how should it look like?


texts: Updating content after major upgrade from 5 to 6 (changes to production site need to be reflected in dev environment)

texts: I have been tasked with a major upgrade from D5 to D6.  The upgrade is now complete and fully themed on my development server.  The current production site is very busy, with dozens of nodes being added on a daily basis.  I need to somehow sync the content from the D5 site to the D6 site, and am wondering if there is any modules to assist or recommended way of doing this?  I just need to retrieve the content and Ubercart orders from the last month and port them to the D6 site.  Thanks for any help!!


texts: entity translation access permission alter

texts:
I'm using Entity Translation for node translations.

I would like to modify access to edit form for this translation language based on roles and node properties. I've a field in the node entity with a select list of languages, translator should only access translate nodes in languages that are checked in that list.

Which is the best option to modify the access to the node/{NID}/edit/{LANGUAGE} ?

hook_menu_alter ?
hook_node_access(): this hook is called but how can I get the language? ($_GET could be problematic I think).
Extending the EntityTranslation class?
Other?


texts: Why Cant add a class to an element by jquery

texts:
In the page.tpl.php I have some elements like

I have linked js file to the page and it is correctly works since all functions operate based on click attributes. but I would like to mudify some elements in page.tpl.php page. for example in my JS file I have a code like this:

$(".play").attr("id", "myID");

I could not make it working. basically it does not add myID to .play.

Any idea?


texts:
My page--front.html.twig is working ok. I want to print the block_1 display of the recent_comments view. I tried this but it does not seem to work.

{{ view.comments_recent(block_1) }}


texts: Can't visit site after switching on Language Detection 'Session' in combination with Ip to locale

texts:
My site is in a kind of a loop? I can't login anymore and visit the site? http://landberg.at/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/en/user

What do i have to do. Its a combination with IP to local and Language Detection 'Session'

How do i disable Language Detection 'Session' from mySql database manually?
i already disabled IP to local module from database...

I really need my site back as soon as possible.

Thanks!

Update:

I solved it by entering ?language=en behind my URL. After this i was able to login again.


texts:
I have created a content type called "Video" and I was wondering if I should create another content type called "Video Playlist" that act as a container for storing a collection of the nodes that are of content type "Video"?

Each user will have a list of favorites that will be public to everyone and all the other playlists would be optionally public or private only to that user. How would you go about creating this structure/layout? Is this the best approach?


texts:
I know I can render my custom block programmatically with

$block = \Drupal\block_content\Entity\BlockContent::load(2);
$vars['contact_us_info_block']= \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);
$vars['contact_us_info_block'] = drupal_render($vars['contact_us_info_block']);

Now I want to render SimpleNewsletter  Block programmatically,I tried

$block_manager = \Drupal::service('plugin.manager.block');
$config = [];
$plugin_block =  $block_manager->createInstance('simplenewssubscription', $config);
$vars['newsletterblock'] = $plugin_block->build();

but faced with following message in output

This block is broken or missing. You may be missing content or you might need to enable the original module.

SimpleNewsletter module is enabled,how can I render contributes modules block programmatically?


texts: Have followed instructions to disable cache for development but it's still caching

texts:
I have followed all the instructions here https://www.drupal.org/node/2598914

I'm developing a module with a block, and when I went to the Block Layout page and clicked "Place Block", the list of blocks did not come up due to an error in my code. I edited the code and was sure it was correct, yet it still didn't work. So I tried doing "drush cr" just in case the cache wasn't really disabled ... and that made it work.

So it seems to me that the cache has not been disabled by following those instructions. Is there something missing?

Edit: This has happened again when I have made new changes, even after the plugin has successfully loaded. It happens when when I make any changes to src/Plugin/Derivative/Foo.php (inside my module). Those changes aren't picked up until I manually cache rebuild


texts: These lines of code gets me out this error and i cannot understand it

texts:
$number_to_keep = db_select('variable', 'va')
    ->fields('va.value')
    ->condition('va.name', 'dblog_row_limit', '=')
    ->execute();

And it gets me out that errors:

Notice: Undefined index: table in SelectQuery->preExecute() (line 1245 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->compile() (line 1079 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->compiled() (line 1097 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: arguments in SelectQuery->arguments() (line 1024 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->arguments() (line 1028 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->compiled() (line 1097 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->__toString() (line 1531 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: table in SelectQuery->__toString() (line 1538 of /var/www/html/drupal/includes/database/select.inc).
Notice: Undefined index: alias in SelectQuery->__toString() (line 1543 of /var/www/html/drupal/includes/database/select.inc).


texts:
I created a panel page using the Panels module, Contact list at the path messages/contact-list.

The Privatemsg module causes several tabs (Inbox, Sent messages, All messages) to be displayed across the top of pages with path messages.  I am attempting to add an additional tab that links to my Panels page, Contact list.

Based on the code in privatemsg.module for the "Sent messages" tab:

  $items['messages/sent'] = array(
    'title'            => 'Sent messages',
    'page callback'    => 'privatemsg_list_page',
    'page arguments'   => array('sent'),
    'file'             => 'privatemsg.pages.inc',
    'file path'        => drupal_get_path('module', 'privatemsg'),
    'access callback'  => 'privatemsg_user_access',
    'type'             => MENU_LOCAL_TASK,
    'weight'           => -12,
    'menu_name'        => 'user-menu',
  );

I added this code to hook_menu() in a custom module:

  $items['messages/contact-list'] = array(
    'title'            => 'Contact List',
    'page callback'    => 'drupal_goto',
    'page arguments'    => array('messages/contact-list'),
    'access callback'  => 'privatemsg_user_access',
    'access arguments' => array('read privatemsg'),
    'type'             => MENU_LOCAL_TASK,
    'weight'           => 10,
    'menu_name'        => 'user-menu',
  );

However, although this produces no errors, even after clearing the cache multiple times no tab appears anywhere.  I tried moving the code from my custom module into the privatemsg module to no effect.  I've looked at the documentation for hook_menu() but it still isn't clear to me what I'm doing wrong.


texts: “Realname” module is not creating “pretty URLs” for new users?

texts:
I’m working on a site which I’ve taken over the development from a former employee. He has installed the module realname which, as I understand, should enable the function that a user URL is not the cryptic ID but the users first+last name, so the URL might look something like this:   www.mydomain.com/user/firstname-lastname

It work for most of the users but I’ve discovered that some of the users (especially new users) still uses the ID in the URL, so it become something like www.mydomain.com/user/eyyrdctxeec and that mess a lot of things up.

I’m suspecting that it might has something to do with the module and it only “recalculate” the names in some time interval, maybe by the CRON jobs. But I want it to create that member URL when a new user has signed up to the page.

Has anyone experienced that before and might have a solution? As I said, it isn’t me that has initially created this site so I don’t have a clear overview if the original developer have done some customization or other configuration – I’ve search to solve the problem but with no luck.

Any help or suggestions would be appreciated.

Sincere
- Mestika


texts: How to change taxonomy url in node view page?

texts:
How to change  taxonomy url in node view page in Drupal 8?

In node view page I am getting taxonomy term url pattern as term/{%term_id}. I want to change taxonomy term url to custom url in Drupal 8.

Any help?


texts:
I need to add some AJAX functionality to a node form. Using hook_form_alter I'm overriding form elements. In this particular case I need to add a callback on the 'language' element provided by the translation module (Core, Content Translation).

However, when selecting a different option in the 'language' listbox, the page refreshes. What could trigger this behaviour?

This is the code I'm using:

function foo_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'bar_node_form') {
    $form['#prefix'] = '
';
    $form['#suffix'] = '
';

    $form['language']['#ajax'] = array(
      'callback' => 'bar_form_callback',
      'wrapper' => 'bar-form-wrapper',
    );

    if (isset($form_state['values'])) {
      drupal_set_message('ajax callback');
    }
  }
}

function bar_form_callback($form, $form_state) {
  return $form;
}


texts: How can I have Behat create content with an address field properly filled?

texts:
I'm writting a Behat test, where I'm triying to create a content that uses a field address, generated by Address Module. I'm using Drupal 9.0.7, Address Module 1.9.0 and behat 3.8.1. My goal is to create this type of content in my scenario; I'm using a behat table for this, and a Given statement like the following.
Given place content:

  | title   | field_address:country_code |field_address:address_line1 | status |
  |<<title>>| es                         | Behat test street          | 1      |

field_address:country_code and field address:address_line1 are sub-fields of the address field.
This way of naming the sub-fields doesn't seeem to work.
How should I have to name the table headers, in order to make Behat create content with a field address properly filled?


texts: Concatenation with %keyword in mini-panels

texts:
Someone posted another question How does one concatenate fields in title field in Panels (Pages)? but its not working for me.

I need to concatenate a custom text as prefix with %node:field_city_title keyword while adding a node field in min-panels.

I tried with Event in %node:field_city_title , Event in%node:field_city_title and searched a lot but nothing works for me.

If you any idea, let me know


texts: What is the programmatic equivalent of block save?

texts:
From hook_save(), I've updated the "pages" attribute of a block, adding a path to the list.

db_update('block')
    ->fields(array('pages' => $pages))
    ->condition('delta', $delta)
    ->execute();

I've used the database API, (maybe that's the problem?) instead of the block API, because I'm under the impression there is no support in Drupal 7 for this. (hook_block_configure() I think is just for changes to default block configuration.)

The problem I'm having is that the update to the block pages attribute is not reflected, even after clearing caches, until I go to block edit form and click on Save.

There's actually one thing in core's block module function block_admin_configure_submit, and that is to pass the event along:
   module_invoke($form_state['values']['module'], 'block_save', $form_state['values']['delta'], $form_state['values']);

I'm not sure how go about structure $form_state['values'].
Is there a way to do this with the block API?

With regard to Context, we're already using it; we could accomplish the same thing by writing to path to exclude to the context['condition']['path'] attribute, (prefixing the path ~ to indicated "exclude").   This might be a better approach for us, but still would like to see the block code working.


texts:
Currently, I have a site set up like so:

Content Types:

Program
Course

Paragraph Type:

Semester

I have a lot of courses which are being taught in specific programs so I want to reference them and list them by semester on the program pages. One of my fields in Program is Courses of which I made it reference a paragraph type of Semester and this allows me to enter an unlimited amount of semesters.

The semester paragraph type is made up of a title field (of which I'd put in which semester it's in [ex. Semester 1]) and an unlimited content reference field that references the course content type.

I'm not sure if this is the best way to go about doing this but it seemed to work like I needed it to until I realized I needed the option to somehow add the ability to make it list two courses as optional. (Ex. It would need to say something like: 'Choose one of:  Course 1 or Course 2'. And I would need the option of possibly doing this more than once per semester.)

What would be the best site building method to allow me to do this?

This is basically what I'd like the final output to look like:


texts: Calculate shipping based on square meters (m2)

texts: I have lengths of material as products in Ubercart, 3 and I need to be able to calculate shipping of them based on their length x width. Plenty of options for shipping based on weight but that's not what is needed here. I've got width and lengths fields in my product type already plus I have created one called "m2" to enter the square meters manually in case that is easier. Just a bit stuck as to what I should do next. Could rules help me? Maybe modifying the flat rate module or would a custom module be needed?


texts: Do not show picture when video available

texts:
Got a content type with some text, and a video field and an image field (and some other stuff, like entity references between nodes, but not relevant for this question).

When displaying nodes for this content type, I don't want to display the image, if there is a video available.
So the image displays if the video field is empty.
If a video was added to the node, the image should not display.

Can only be done by modifying the node template I assume?
So I would need to copy the node.tpl.php  and rename it to node--contenttype.tpl.php   (with contenttype being the name of the content type)

But the PHP code in there just prints then entire $content  so I cannot interfere with the displaying of the image separately.

Is there another customisation (the one producing the html for the node probably?) where I can wrap some "if" statement around the image field that check for presence of content in the video field?


texts: I have created a menu like france menu. I just want to print it using print_r statement. Is it possible? I know menu block is there. But i don't wanna use it.


texts: Creating date field with only month and year

texts:
We are using the Form API in a custom module (and not an entity field), how can we easily set the date widget for just year and month data entry?
I've tried adding a #date_format attribute but no change:
$form['date_needed'] = array(
  '#type' => 'date',
  '#title' => $this->t('Date Needed'),
  '#date_date_format' => 'Y/m',
);

I have also tried  '#date_date_format' => 'd/m/Y' but the date widget still appears asking for YYYY-mm-dd.
Looking at the source code for core/Render/Element/Date.php and stepping though the code, I can see it's picking up this setting.
The drupal.org doc page has a comment that indicate this should work: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21Date.php/class/Date/8.2.x
Any ideas?


texts: Generate a fancy PDF certificate from form?

texts:
Anyone have ideas on how to generate a fancy PDF certificate in drupal based on user-supplied form input? Here's an example of what I want to do here:

http://www.infiniteskills.com/cert/01596

This form just collects a name and build a nice PDF. Not sure if the email address is used for anything (other than perhaps collecting email addresses).

I've attached a screenshot of the final PDF so you can see the result without using the form.

Thanks for any ideas or pointers.

Edit: Adding a link the Drupal certificate module: http://drupal.org/project/certificate

This module requires the print module and seems a little heavy for what I'm trying to do. Also, as far as I can tell, it will only create a PDF from existing HTML page.


texts: ServiceProviderBase override "winner" - can this be done with module weight?

texts:
It is noted that modules implementing ServiceProviderBase to alter defined services can 'lose' to other modules overriding the same service as there is no way to know which one should overtake in that situation.

Is this 'fixable' by making your modules weight higher than the others?


texts: How are values passed from the database to the templating system?

texts:
I haven't quite figured out how Drupal passes the values from the database or the back-end to the theme variables in the template.

Which function does it use to disperse the variables to the corresponding template?


texts: How to show only child terms of a taxonomy on a table

texts:
I want to display only child terms of a taxonomy on a tableselect ?
Example :

Term A has : terms {B,C,D}
term E has : term {F}

I want to display only {B,C,D,F} on a table (in order to make some stuff with checkbox etc)


texts:
I have installed a solr 5.2.1 in my windows 7 and I have created a solr core through SOLR Admin UI. It works fine. When, I trying to connect to solr by help of search_api_solr module in drupal 7.38 on my local host, The following error is coming.

"The Solr server could not be reached. Further data is therefore unavailable". What I have missed out, Anyone can Please help. Refer the below images.


texts: Featured content module won't display teasers

texts:
I am using the featured content block here: http://drupal.org/project/featured_content

I am successful in getting it to display similar items (based on it's search capability) I am electing to display them in teaser form, but the teaser descriptions are not being displayed, only titles. Any insight?

The node tpl.php file being routed through is the same as others which print out the teasers fine through views etc...


texts: Kernel Base Test: Create node content types and taxonomy vocabularies via configuration?

texts:
Does anybody know, how the mentioned entity types can be setup via configuration Yaml files? Right now I am setting up my entity types for a Kernel Base Test like the following:

Vocabulary::create([
  'name' => 'Kreise',
  'vid' => 'districts',
])->save();

$stringFields = [
  'field_district_number',
];
$this->saveFields($stringFields, 'string', 'districts', 'taxonomy_term');

$booleanFields = [
  'field_searchable'
];
$this->saveFields($booleanFields, 'boolean', 'districts', 'taxonomy_term');

Is it possible to quickly load the entity type configuration by an existing site configuration to save time? Because I already have configured entity types in my site configuration. It seems like an not necessary additional step, to code the entity configuration for my test.


texts:
I had the impression that in Drupal 8 all entity tokens are provided automatically since it uses the new field structure but I don't see anything available for my entity.

Do I need to enable something in the annotation or did I get it wrong and tokens have to be provided manually like in D7?


texts: I need to access individual elements of a node in my module

texts:
I have the following query that fetches all the nodes of a certain type.

function shop_home_page() {
  $render = array();
  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type AND n.status = :status';
  $result = db_query($sql,
    array(
      ':type' => 'music_albums',
      ':status' => 1,
    )
  );

  foreach ($result as $row) {
    $node = node_load($row->nid);
    $render['my_list'][] = node_view($node, 'teaser');
   }
  return $render;
}

How do I display in my page node elements such as $node-title, $node-body? I tried as $render['my_list'][] = node->title but it doesn't seem to work.
I also need to add a form with a buy button to each element. How do I attach it?


texts:
i've altered a form by adding my own fields. they're not part of the node.
i'm wondering which hook to use, to save these fields in the db.

i guess hook_nodeapi is the right one, but the form variable only gets transfered in the 'validate' $op, and it doesn't seem right to save data in the validate operation.

So how would i go about that?


texts: If I have wordpress right now with a bit of content (on a linux VPS with apache) and I want to switch over to drupal with the least possible downtime what do you recommend? Is it possible to install drupal separately and then put the content in it and then make it active over the wordpress somehow? Sorry if this was a silly thought as I don't have experience with any of this.


texts: How to pass variables between preprocess functions

texts:
I've some problem with themes and preprocess functions.

I see that, if I declare a variable in, for example, MYTHEME_preprocess_region(&$vars), this variable is available ONLY in region.tpl.php (I'm using Omega).
But in preprocess_region and region.tpl there is the $vars['node'] variable (if I'm displaying a node), so in these functions I can't create variable based on $node.

In my example, the $vars['node'] variable is available in preprocess_page and preprocess_node.

The question is: if I want to add on region.tpl.php (or preprocess_region) a variable based on $node how should I do?

The "general" question is: how can I declare a variable in a theme function, in template.php, and let this function available in other functions?


texts: From managed file ID to end-user link - neat and clean way?

texts:
I have a structure in database, and I want it printed. So in hook menu I have entry with

'page callback' => 'mymodule_mystructure_display',

And in inc file I have

function mymodule_mystructure_display($id_structure) {
  $mystructure= something(); // Data preparation
  return $mystructure;
}

And I have all helpers set up so in mystructure.tpl.php I can simply use:

kpr($mystructure);

and it all works, so let me omit details for now, they are covered in Examples for Developers anyway.

The real struggle is with files.

In $mystructure['files'] I have a nested array like this:

array(2) {
  [0]=>
  array(2) {
    ["name"]=>
    string(26) "Display name of first file"
    ["fid"]=>
    int(34)
  }
  [1]=>
  array(2) {
    ["name"]=>
    string(27) "Display name of second file"
    ["fid"]=>
    int(62)
  }
}

where ["fid"] corresponds to {file_managed}.fid field in Drupal's database.

What's the cleanest way to output links to files, with ["name"] used as link text?

What I'm doing now is pretty dirty:

In function mymodule_mystructure_display I foreach or array_walk over files.
For each element, I take file id, and use this helper function on it:

_uri_by_id($id) {
  $file = file_load($id);
  return $file->uri;
}

Result is fed to file_create_url function, and it's result is saved under ["url"] index, to give me this array in $mystructure['files']:

array(2) {
  [0]=>
  array(2) {
    ["name"]=>
    string(26) "Display name of first file"
    ["fid"]=>
    int(34)
    ["url"]=>
    string(50) "http://example.com/sites/default/files/example.pdf"
  }
  [1]=>
  array(2) {
    ["name"]=>
    string(27) "Display name of second file"
    ["fid"]=>
    int(62)
    ["url"]=>
    string(50) "http://example.com/sites/default/files/example.txt"
  }
}

In mystructure.tpl.php I use l() to print actual link:

echo l($item["name"], $item["url"]);

This all works. But it feels bad. I was always a backend guy, my frontend knowledge is somehow lacking. But I'm sure there should be a shorter way from managed file ID to a link. So what would it be?

Note: value under ["name"] is derived from $mystructure, it is not something taken directly from file object. This pretty much stopped me from using theme_file_link(). But even if it wouldn't be the problem, I still need to load file object manually to use theme_file_link().


texts:
I have just put a Drupal website online. I registered it in Google WebMaster's tool and it sent me back a Severe health issues are found on your site message related to a robot.txt file.

The content of this file is:

#
# robots.txt
#
# This file is to prevent the crawling and indexing of certain parts
# of your site by web crawlers and spiders run by sites like Yahoo!
# and Google. By telling these "robots" where not to go on your site,
# you save bandwidth and server resources.
#
# This file will be ignored unless it is at the root of your host:
# Used:    http://example.com/robots.txt
# Ignored: http://example.com/site/robots.txt
#
# For more information about the robots.txt standard, see:
# http://www.robotstxt.org/wc/robots.html
#
# For syntax checking, see:
# http://www.sxw.org.uk/computing/robots/check.html

User-agent: *
Crawl-delay: 10
# Directories
Disallow: /includes/
Disallow: /misc/
Disallow: /modules/
Disallow: /profiles/
Disallow: /scripts/
Disallow: /themes/
# Files
Disallow: /CHANGELOG.txt
Disallow: /cron.php
Disallow: /INSTALL.mysql.txt
Disallow: /INSTALL.pgsql.txt
Disallow: /INSTALL.sqlite.txt
Disallow: /install.php
Disallow: /INSTALL.txt
Disallow: /LICENSE.txt
Disallow: /MAINTAINERS.txt
Disallow: /update.php
Disallow: /UPGRADE.txt
Disallow: /xmlrpc.php
# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips/
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
Disallow: /?q=admin/
Disallow: /?q=comment/reply/
Disallow: /?q=filter/tips/
Disallow: /?q=node/add/
Disallow: /?q=search/
Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/

I believe Drupal generated this itself.

I have another Drupal site live, but it does not have a robot.txt file, and Google WebMaster Tool does not throw me such messages.

How to solve this issue? Is it safe to remove my robot.txt file?

UPDATE

I am still struggling with these strange warning messages from Google Webmaster Tools on my Drupal website:

Is robots.txt blocking important pages?
Some important page is blocked by robots.txt.

When I click on 'important page', it points to:

http://www.mydrupalsite.com/misc/jquery.js?v=1.4.4

Why would Google want to access /misc?


texts: Printing taxonomy terms as an un-ordered list

texts:
How to print taxonomy terms as an un-ordered list in page.tpl.php. Where i want to print a taxonomy term called "Article Category" and all its vocabularies one by one as a un-ordered list, so it can be used as a menu. Can't understand, please give me ideas?

EDIT: I know about a module "Taxonomy Menu" but looking for a programmatic direction, idea or any kind of reference that will help me to get started.

Thanks


texts: Chatbox with the capability of natural language processing

texts:
We need a feature of chatbot in the site with natural language processing (NLP) capability.
The chatbot will be having multiple persona.  The users can to come to the site and they can select a persona to talk with.

Say for example: If I come to the site and select a persona and ask in the chat, what are treatment methods available for dengue?
The chatbot should able to give the answer accordingly from content repository in the site.

Any solution for this available in drupal + any third party tools?


texts: Creating a form where users can edit their own submissions

texts:
I'm beginning with Drupal. I've got to set up a multistep form which allows users to add content. I want them to be able to edit their own submissions too.

I began to code a custom module in drupal/php but I'm not sure it's the easiest way. I've heard a lot about Drupal native forms or content types that could do it as well as a custom module.

My question is : what kind of modules do I need to build a multistep form with own submissions edition ?


texts: Access user points in different drupal site

texts:
We have 2 drupal sites, one as CMS and another one is SHOP.
In CMS site we are using userpoints module to award points to user on certain actions.
Now my question is, How to use these points in SHOP site. Shop site is totally different form CMS site but hosted on sub-doamin.

In shop site we are using ubercart and Commerce-userpoints modules.


texts:
How do I add view header content in code?

I have seen questions related to this but only where the view is being embedded. I am not embedding any view, but would like to provide content for the view headers in code as I have quite a few views, and I do not want to add the content through the views UI as it is difficult to make changes quickly and as some views have many pages and share the same header.

Currently I have this code.

function MYMODULE_preprocess_views_view(&$vars){
  $function = __FUNCTION__ . '_' . $vars['name'];
  if (function_exists($function)) {
    $function($vars);
  }
}

function MYMODULE_preprocess_views_view_VIEW_NAME(&$vars){
  // do something here.
  $vars['attachment_before'] .= $SOME_CONTENT;
}


texts: When using features to manage deployment, should I break my functionality into many little features or one big feature?

texts:
I'm relatively new to the features module and I've read contradictory recommendations online regarding whether it's easiest to maintain A) one big feature or B) several smaller features and then a "feature-controller" type module that lists all the smaller features as dependencies.

A bit about my specific situation: I'm using a local development -> dev server -> staging server -> live server workflow.  This particular site will almost certainly be the only one of its kind that I ever develop; I do not intend to use the features I create for this site on any other sites.

This makes me lean toward doing everything in one big feature because I've had problems in the past where I accidentally defined the same rules in multiple features and gotten into trouble.  However, in terms of structure this seems wrong to me-- there are different features/functions so they ought to be divided into separate features.  On the other hand, I feel like by doing this I may just create additional work and overhead for myself that won't benefit anyone.

Which approach is easier to maintain in actual practice-- one big feature or many smaller ones?


texts: Cannot get form_state storage or protected form values to work

texts:
I am building a form using formBuilder. I have tried two methods to store values across form submit/validate for usage in ajax callbacks, but have been unsuccessful in either.
The first method, was to store a value in $form_state->set('name','value'); and retreiving it in the form submit/validate handler. That returned an empty result.
The second method was to store a variable on the class itself protected $image_deltas = 0; and then when the ajax form submit/validation is triggered, $this->image_deltas++; However, when I do this, it still does not work.
The following is the code I am using.
$form['images'] = [
  '#type' => 'container',
  '#id' => 'images',
];

dpm($this->image_deltas);

for ($i=0;$i<=$this->image_deltas;$i++) {
  $form['images'][$i]['image'] = [
    '#type' => 'textfield',
    '#title' => t('Image Path:'),
  ];
}

$form['add_another'] = [
  '#type' => 'button',
  '#value' => t('Add Another Image'),
  '#ajax' => [
    'callback' => [$this, 'addAnotherImage'],
    'wrapper' => 'images',
  ],
  '#submit' => [$this, 'addAnotherImageSubmit'],
  '#limit_validation_errors' => [],
];

The form submission handler is the following.
public function addAnotherImageSubmit(&$form, FormStateInterface $form_state) {
  $this->image_deltas++;
  $form_state->setRebuild();
}

The AJAX callback is the following one.
public function addAnotherImage(&$form, FormStateInterface $form_state) {
  return $form['images'];
}

When I submit the form, dpm() prints 0 every time. The same thing happens if I use $form_state->set('image_deltas') and $form_state->get('image_deltas').


texts: `drush cc all` command takes too long time, what can I do?

texts: On a site of mine drush cc all takes more than 4 mins to run. The site db is a few GBs. However, I cannot see a clear reason as to why it takes too long. What can I do to locate the bottle neck?


texts: Commerce: How to skip checkout cart and redirect to PayPal

texts: How i have to set a rule to go direct to Paypal site? I use PayPal Express and i am not able to solve this. The only one rule i can set is to go to cart/checkout. But i´d like to go one step forward without to see the order and to have to click on the PayPal button. Thanks for helping


texts:
I am trying to write a batch. And I have a problem that none of the batch operations callback functions are getting called.

I wrote drupal_set_message at the start of each callback and none of the messages are displayed.

I can get the batch page, but the callback ops aren't called at all.

Here's the code I used:

function mymdoule_node_batch()
{
    $batch = array(
        'title'         => t("Migrating"),
        'operations'    => array(
            array('mycallback_001'),
            array('mycallback_002'),
        ),
        'finished'      => 'mycallback_finished',
        'init_message'  => t('Initializing...'),
        'error_message' => t('An error occurred.'),
    );

    batch_set($batch);
    drupal_set_message("step: 0"); // this is the only message the system returns
}

function mycallback_001(&$context)
{
    drupal_set_message("step: 1");
    $nids = db_select("node", "n")
            ->fields("n", array("nid"))
            ->orderBy("nid", "ASC")
            ->execute()
            ->fetchCol();
}

function mycallback_002(&$context)
{
    drupal_set_message("step: 2");
    $nids = db_select("node", "n")
            ->fields("n", array("nid"))
            ->orderBy("nid", "ASC")
            ->execute()
            ->fetchCol();
}

P.s. The batch is getting called in form submission.

What's wrong in that?


texts: Inline Template with Render Array in #context

texts:
I'm using the https://api.drupal.org/InlineTemplate to render a string with a variable, and that variable is itself another theme function.

My reading of the documentation is that this is supported; based on the fact that the #context variable can be a string or render array.

  #context: (array) The variables to substitute into the Twig template. Each variable may be a string or a render array.

However, my implementation is not working:

    $my_subtemplate = [
      '#type' => 'inline_template',
      '#template' => '{% trans %}my {{ foo }} here{% endtrans %}',
      '#context' => ['foo' => 'bar'],
    ];

    $my_string_with_embedded_themable = [
      '#type' => 'inline_template',
      '#template' => '{% trans %}Print this string and this subtemplate: {{ my_subtemplate }}.{% endtrans %}',
      '#context' => [
        'my_subtemplate' => $my_subtemplate,
      ],
    ];

The generated output is:

  Print this string and this subtemplate: .

I've confirmed that my_subtemplate generates the correct output on its own:

  my bar here

But when its placed into a variable of another inline template, it does not render.


texts: Display edit and delete button using content view

texts: i am using blog entry content type  and i am displaying blog entry using content view .But their is no any edit and delete button how to add it while using content.Edit and delete button is working only when we use field view.Any idea how to make edit and delete button working when using content view