texts: Difference between adding single parameter vs adding parameter in entity?

texts:
Under custom_changes.routing.yml
For argument {first_arg},  I am adding default value under defaults

custom_changes.argument:
  path: '/arg-demo/{first_arg}'
  defaults:
    _controller: '\Drupal\custom_changes\Controller\StaticContent:content_arg'
    _title: 'Content With Arg'
    first_arg: 100

Whereas for entity parameter as seen below

custom_changes.node_view:
  path: '/list/{node_1}/{node_2}'
  defaults:
    _title: 'List Nodes'
    _controller: '\Drupal\custom_changes\Controller\StaticContent:node_list'
    parameters:
      node_1: 52
      node_2: 52
  requirements:
    _permission: 'access node listing'
  options:
    parameters:
      node_1:
        type: node
      node_2:
        type: node

OR

custom_changes.node_view:
  path: '/list/{node_1}/{node_2}'
  defaults:
    _title: 'List Nodes'
    _controller: '\Drupal\custom_changes\Controller\StaticContent:node_list'
      node_1: 52
      node_2: 52
  requirements:
    _permission: 'access node listing'
  options:
    parameters:
      node_1:
        type: node
      node_2:
        type: node

It does not add default value if I visit /list and also gives an error

  TypeError: Argument 1 passed to
  Drupal\custom_changes\Controller\StaticContent::node_list() must be an
  instance of Drupal\node\Entity\Node or null, string given in
  Drupal\custom_changes\Controller\StaticContent->node_list() (line 24
  of modules/custom/custom_changes/src/Controller/StaticContent.php).

<?php

namespace Drupal\custom_changes\Controller;

use \Drupal\Core\Controller\ControllerBase;
use \Drupal\node\Entity\Node;

Class StaticContent extends ControllerBase  {
  public function static_callback() {
    $build = [
      '#markup' => $this->t('Hello World!'),
    ];
    return $build;
  }

  public function content_arg($first_arg) {
    $build = [
      '#markup' => $this->t('Hello World' . $first_arg),
    ];

    return $build;
  }

  public function node_list(Node $node_1 = NULL, Node $node_2 = NULL) {
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
    $storage = \Drupal::entityTypeManager()->getStorage('node');
    $view = $view_builder->viewField($node_1->get('body'), [
      'type' => 'string', // string, entity_reference_label
      'label' => 'hidden',
      'settings' => ['link' => FALSE],
      ]);
    $view_title = $view_builder->viewField($node_2->getTitle(), [
      'type' => 'string',
      'label'=> 'hidden',
      'settings' => ['link' => FALSE],
    ]);
    $output_title = render($view_title);
    $output = render($view);
    $build = [
      '#markup' => $output + $output_title,
    ];
    return $build;
  }
}

Also should we use Node or NodeInterface and how is that determined in typehinting for method node_list under class StaticContent


texts: How should I deal with Views URL parameter "page" in Google web master tool?

texts:
I have node view which has pager with URL parameter "page". I want Google bot crawls all the pages ( page=1 page=2 page=3... ) but regard all of them as just one and only the first page (without parameter "page") should appear on the search result.

On the webmaster setting page I have set URL parameter for "page" as below but now I'm getting duplicated title and description.

  How does this parameter affect page content: Paginates
  Which URLs with this parameter should Googlebot crawl: Every URL

What's the best way to configure URL parameter for Views "page" on Google Webmaster Tools?


texts: How do I avoid a template get rendered from a preprocess function?

texts:
I have a multilingual site with two view blocks, and a custom template for them.

I want to render both blocks in language A, but only one in language B.
Is it possible to avoid that one of them is rendered on a language basis, from the preprocess function?


texts: Taking check box option and turn into select list

texts:
I want to take the value of multiple checkbox options while creating node and then when viewing the node, I want these values which were selected in a multiple checkbox to be in a select list.

Any idea how to implement this?


texts: How to automatically select the organic group audience when adding content?

texts:
How can I setup a link on a group page to add content that automatically selects the group audience as the referred group?

For instance:

I'm a member of the group "Puppy Kittens" and I'm logged in to that group page (node/12) and I have links on that page to "Add Post". The link "Add Post" opens up and allows me to add a post for my group without me having to select my group.


texts: How to delete a node or a list of nodes with Drush?

texts:
I discovered the Delete all module which gives you the ability to delete all the nodes of a given content type. However, with this module you can't delete a single node or a list of nodes.

In the question "Can I delete nodes of a given content type with Drush?" I found 2 answers talking about the command drush node_delete <nid> but I can't find this command.

I found in a discussion about node_delete() some code using eval to accomplish this task, but it is using eval:

drush php-eval "global \$user; \$user = user_load(1); node_delete(nid);"

In case that there doesn't exist a functionality implemented to accomplish this, what is the better way to implement this functionality: in the Drush module or create a new module?


texts: Continually adding fields to a form each time a button is pressed using AJAX

texts:
I'm attempting to add fields dynamically to a form using AJAX in a block plugin however no action occurs when clicking on the button that is meant to add a field.
The code I'm currently is below

   class Standard extends BlockBase {
    public function blockForm($form, FormStateInterface $form_state) {
        $form_state->setCached(FALSE);
        $form['actions'] = array(
            '#type' => 'actions',
        );
        $form['column']['columnNum'] = array(
            '#type'          => 'value',
            '#default_value' => $this->configuration['columns_submit'],
        );

        $form['column_wrapper'] = array(
            '#type'       => 'container',
            '#attributes' => array(
                'id'         => 'column_wrapper',
            ),
        );
        for ($i = 1; $i <= $this->configuration['columns_submit']; $i += 1) {
            $form['column'][$i] = array(
                '#type'           => 'details',
                '#title'          => t('Column '.$i),
                '#open'           => FALSE,
                'group'           => 'Content',
                'body_text'       => array(
                    '#type'          => 'text_format',
                    '#title'         => $this->t('Body'),
                    '#default_value' => $this->configuration['column'][$i]['body_text_submit']['value'],
                ),
                'class'           => array(
                    '#type'          => 'textfield',
                    '#title'         => $this->t('Class'),
                    '#default_value' => $this->configuration['column'][$i]['class_submit'],
                ),

            );
        }
        $form['addcolumn'] = array(
            '#type'     => 'button',
            '#name'     => 'Add Column',
            '#value'    => t('Add column'),
            '#submit'   => array($this, 'addColumnSubmit'),
            '#ajax'     => array(
                'callback' => [$this, 'addColumnCallback'],
                'effect'   => 'fade',
                'wrapper'  => 'column_wrapper',
            ),
        );
        return $form;
    }
    public function addColumnSubmit(array&$form, FormStateInterface $form_state) {
        $this->configuration['columns_submit'] += 1;
        $form_state->setRebuild(TRUE);
    }
    public function addColumnCallback(array&$form, FormStateInterface $form_state) {

        return $form['column'];
    }

Nothing occurs when clicking the $form['addcolumn'] button. I've based my attempts on examples such as this one https://www.drupal.org/node/2723033. (I understand that is an example of it not working, but based on the comments it seemed like an error that was easily fixed)
I'd like to be able to continually add fields each time the button is pressed. Is there something wrong with my code? Is there a proper way to continually add fields when a button is pressed to a form using AJAX?

Update: I made another attempt which failed as well.

I used

    if (empty($form_state->getValue('columnNum'))) {
        $form_state->setValue('columnNum', 1);
    }
    $columnNum = $form_state->getValue('columnNum');

in BlockForm()

and

    $numColumns = $form_state->getValue('numColumns');
    $numColumns += 1;
    $form_state->setValue('numColumns', $numColumns);
    $form_state->setRebuild(TRUE);

in addColumnSubmit()


texts: How can I convert HTML entities imported from CSV via Feeds in to readable characters?

texts:
This relates to a prior question - How can I convert character entities to display as 'normal' characters in Drupal?

It looks as if the CSV file itself is imported via Feeds, so I assume that it's Feeds that should 'parse' the HTML entities and convert them in to readable characters (Unicode?).

Is there some sort of extension or patch available for Feeds that can help me to do this?


texts: How to display custom content when viewing node?

texts:
I am using the Biblio module and I like the display mode (e.g. full, teaser).  I would like to tack on custom text and information when a user views the content below the display.  How do I append my own custom text in the current display?  When I go to "Manage Display", the custom fields are not shown.  It might be hard coded in the module.  What Drupal API call should I be looking for? Or better yet, I am perfectly willing to write my own module.  I just do not know where to start in adding my own additions to an existing display.

An example is the comment module.  When someone leaves a comment, then you can see the comment someone has written that is tied to the specific node and/or content type.  I am not talking about creating a user input form or input HTML field.


texts: Tabs: invalidating cache tags does not lead to a rebuild of the tabs

texts:
I have a custom route defined with a custom access check. Apart from some more checks one of the rules for accessing the path is that a specific custom entity exists. The access check does the following:
  public function access(AccountInterface $account) {
    if ($entity_does_not_exist) {
      return AccessResult::forbidden()->addCacheTags(['my_unique_cache_tag']);
    }
  }

In my custom entity class I defined the postSave and postDelete methods to invalidate this tag every time an entity is created or deleted:
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage, $entities);
    foreach ($entities as $entity) {
      \Drupal::cache('render')->invalidate('my_unique_cache_tag');
    }
  }

  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);

    if (!$update) {
      \Drupal::cache('render')->invalidate(ParliamentPeriodCCController::getCacheTag('my_unique_cache_tag');
    }
  }

My problem is that my custom route is used as a secondary tab in my_module.links.task.yml. What I found out so far is that the tabs are rendered in a block which really gets my unique cache tag (as I see in cache_render table - this is why I defined  \Drupal::cache('render') above - \Drupal::cache() did not work neither) but it seems it never gets invalidated. When I enter a page where the secondary tab was not created because no entity exists it is still not shown when I create the entity afterwards. But when I delete the entry for the block from cache_render it is rendered correctly.


texts:
It is very time consuming to define fields, set their types and validation while creating a content type. It's a nightmare if the fields are exceeding in numbers (say more then 10).

Is there any way to define all the fields, their types, structures, validations one time on a page and generate the whole content type at once?


texts:
In Drupal 7, by default the $messages variable is printed in page.tpl.php.

Is there a way to print $messages in a node.tpl.php file (e.g. $node-mycontenttype.tpl.php).

Just putting <?php print $messages; ?> or
<?php print render($page['messages']); ?> does not work.

There's a tutorial here for printing $messages in a block, but I would like to put it in my node.tpl.php file.


texts: How to split node fields into view blocks

texts:
I am using Omega, and I want to assign fields for a node type to regions of a template.  I created a view, with a page (to get a URL) and block views with fields. I then assigned the blocks of fields to their regions to only display for that node type.  It's not working.  I have a contextual filter for NID, and if not found, to default to the Content ID in the URL.

I feel like this should work, but I'm missing something.


texts:
I need to check if the http_referrer var is a specific page in Drupal and redirect otherwise.

I was trying the Rules module but I need something flexible enough to add PHP code.

Can I use hook_init() in my template.php function to check for the referrer and the destination node and redirect if certain conditions are in place?


texts:
Given a PHP switch statement, would it be a good (or bad) idea to use t() in case statements?

switch ($button_value) {
  case t('Clear'):
    // …
    break;
  case t('Search'):
    // …
    break;
}


texts: How to print drupal module version with drush 6.5.0

texts:
Here's an example of a module in one of my make files:

projects[views][version] = "3.8"
projects[views][type] = "module"
projects[views][subdir] = "contrib"
projects[views][download][url] = "git://testurl.org/drupal/modules/views.git"
projects[views][download][tag] = "7.x-3.8

Drush 5.7.0 adds information about the module to every module .info file:

; Information added by drush on 2015-01-20
version = "7.x-3.8"
core = "7.x"
project = "views"
datestamp = "1421783211"

I can't find a way to append this information with Drush 6.5.0 and since I am using a git repo, the version is always missing from the .info file.

Is there a way to print that information with Drush 6.5.0?


texts: Share one User Table with two Drupal Sites

texts:
I have a drupal site which has thousands registered users. (I also added fields like age,dob country etc at /admin/config/people/accounts/fields)

I have another site which is hosted at the same hosting with different database.

Is there a way that i can use first site USERS table in the second site ?
(user registration, forget password and login etc will be connected to first site)

Any clue?

thanks


texts: How do I make my homepage slideshow to fit the page width?

texts: I have my website built in Drupal 6, and I have used the Views slideshow module for the home page banner which is 960 pixel wide. I need a banner with 100% width to fit the page. Can anybody help me in making it to 100% or kindly suggest any full width banner slideshow module which is compatible with Drupal 6?


texts: Problem with IF command in comment.html.twig

texts:
I create a "select" field (field_points) in comment section that users rating my content and in "manage display" I set "key" for my field format.

5|Excellent
4|Good
3|No Idea
2|Bad
1|Very Bad

Now I use this code in comment.html.twig:

{% if content.field_points == 5 %}
   *****
{% elseif content.field_points == 4 %}
    ****
{% elseif content.field_points == 3 %}
    ***
{% elseif content.field_points == 2 %}
    **
{% elseif content.field_points == 1 %}
    *
{% endif %}

When I use this code nothing is displayed But when I use {{ content.field_points }} , print for example 5 ( 5 is field key ).

How can I fix this problem in drupal 8?


texts:
I want to have a views with this Filter criteria

Content: Nid (= 2410)
OR
Content: Type (= news) AND
Content: value (= high) AND
Content: published (Yes)
OR
Content: Type (= multimedia) AND
Content: category (<> cinema) AND
Content: piblished (Yes)

and Sort criteria :

Content: Post date (desc)

and just need to display 10 items.

actually, I need to force views to bring one or more NIDs. But when it sorts the results by post date if the specified nid is older than the 10 first results it does not appear in the results.

How can I solve the problem?


texts: Unable to loop through all nodes in a content type and load them without hitting memory limits

texts:
I'm having an issue in Drupal 8 where I am unable to loop through a large amount of nodes without hitting memory limits. The products content type in the below example has ~6000 nodes. The memory limit is currently set to 512M and is not changeable.

I've tried unsetting the $node variable and clearing the entity cache  in the loop without any success.

$query = \Drupal::entityQuery('node')
         ->condition('type', 'product')
         ->execute();
$nids = array_keys($query);

foreach ($nids as $nid) {
    $node = \Drupal\node\Entity\Node::load($nid);
    print $node->title->value;
}

The goal is to be able to iterate through all nodes of a content type without hitting memory limits.


texts: Is this possible? Dynamically changing fieldsets on node creation

texts:
(Note that I am not talking about simply hiding/displaying fields conditional upon other fields' values.)

This question about programmatically creating fields led to questions about whether it was even possible to do what I want. See, I want to create a set of webforms that I will use as quizzes. Then I want to create a node of type "answer key" for each quiz. The answer key will be connected to a quiz by a node reference field. Upon selection of a quiz from the dropdown, some AJAX will automagically go to the specified webform, find its form elements, bring them back, and add them to node submission form for the answer key.

The tricky part here is trying to save them. See, since they weren't known to the content type beforehand, they won't have been defined already with a spot in the database and all that. So, how can I store them? Can I define on the content type a text field with unlimited values and just store one form element's answer per value in the unlimited field?

The tl;dr of this is: Is it possible to save inputs on fieldsets that are different for each node of the same content type?


texts: Ajax not working inside hook_field_widget_form()

texts:
How to make ajax work inside hook_field_widget_form()

    /**
      * Implements hook_field_widget_form().
     */
        function test_field_widget_form($form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
      $form_field['autocomplete'] = array(
        '#type' => 'textfield',
        '#title' => 'Tags',
        '#autocomplete_path' => 'taxonomy/autocomplete' . '/' . $field['field_name'],
        '#size' => $instance['widget']['settings']['size'],
        '#maxlength' => 1024,
        '#element_validate' => array('taxonomy_autocomplete_validate'),
        '#prefix' => '
',
        '#suffix' => '
',
      );
      if (isset($form_state['values']['autocomplete'])) {
        $form_field['autocomplete']['#value'] = 'new value';
      }

      $form_field['search_tags'] = array(
        '#type' => 'button',
        '#value' => 'Recommend Tags',
        '#ajax' => array(
          'callback' => 'call_ajax_replace_value',
          'wrapper' => 'subscribers-name',
          'method' => 'replace',
        ),
      );
      $element += $form_field;
      return $element;
    }

    function call_ajax_replace_value($form, &$form_state) {
       return $form['field_tags'][LANGUAGE_NONE][0]['autocomplete'];
    }

How do i update autocomplete textfield value on AJAX callback?


texts: How to pass #cache information in field formatter to parent element?

texts:
I have a entity reference field formatter that provides #cache tags even for entities that are not displayed since I want to flush the render cache of the entity that has this field attached when the referenced entity changes so it will be hidden/displayed immediately(note that I am not using the checkAccess() for this).

The issue I have is that if I provide empty entry for such entity only with the cache tags set, it will result in empty field item div to be rendered. If I put the cache tags to the parent element(the element that is returned by the viewElements() method) and not "delta" item within this element, it won't work at all. I'm not sure if this is because the cache is being overwritten later on or if that is because of the way Drupal core works or whatnot but it is just not working.

So my question is: how could I provide these cache tags and avoid having empty field item divs in the resulting html output?


texts: The option "Invite my Facebook friends" in the facebook connect module is a white screen

texts: I don't understand why when I put click in "Invite friends from FB" appears a white screen. I can't see any list of friends to invite.


texts: Template file in admin theme not looked for in admin theme

texts:
As documented here, I've created a custom filefield source that gets images from Apache Solr, and I'm using this in conjunction with the Insert module. I wanted to add some additional markup for displaying a caption when the image is inserted into the body, so I did the following steps:

Created a custom version of the Seven admin them (called cns_seven),
Implemented hook_insert_widgets_alter() to modify the wrapper and add the widget for the caption field, and
Overrode the image-insert-image.tpl.php in my cns_seven theme.

If I use the default Upload option or one of the default Filefield Sources (such as Autocomplete Reference) for the image, the custom template is used just fine when inserting the image into the body. However, when I use my custom source field, it isn't used. I did some debugging, and discovered that the theme() function for some reason is looking for image-insert-image.tpl.php in my front end theme and not cns_seven, even though I'm using cns_seven when editing the node (so adding a version of that template in the front end theme achieves the functionality). I've looked through the code in both modules, I don't see anything that adds a custom template suggestion or does anything extra to force the function to look in the admin theme.

Any idea as to what would be causing this?

Thanks.


texts: How to send mails with mime module only for specific modules?

texts:
Fixed it, see answer below

On my drupal installation there are some fancy webforms which send plain text emails, turning on the mime module messes them all up. But, I need the mime module to send html mails when using simplenews newsletters.

I did the following in the settings but it has no effect (html = plain):

(http://abload.de/img/bildschirmfoto2013-11w1j7v.png)

What did I miss? How to use the mime mails only when simplenews is sending mails? I set HTML as format in newsletter settings.

Thanks!


texts: How do I enable PHPUnit testing for a sandbox project on drupal.org?

texts:
This questions is specifically about my sandbox project. I have PHPUnit running on other full projects that I maintain.

I have created a sandbox project, fully uploaded to drupal.org, for 8.x and 9.x testing. But there is no "Automated testing" tab on the project page, like there is with full projects. What has to be done to enable testing on drupal.org?

The project has a composer.json, .info.yml and drupalci.yml. My phpunit tests run locally. Everything looks fine. I have searched drupal.org docs https://www.drupal.org/node/1011196 and it does not say that phpunit testing is not available for sandbox projects.


texts: Commerce - how to set no payment for free orders when 100% coupon applied

texts:
I'm working with a one-page checkout process, where cart contents, account info, billing, payment, and coupon information are all under Checkout. Coupons are handled by commerce_coupon.

This has worked fine, but now I want to allow free orders using 100% discount coupons, and I'm having trouble getting the right payment method selected when the coupon is applied.

To handle order totals being <= 0 because of coupons applied, I've added additional conditions to two payment methods as follows:

Stripe - commerce-order:commerce-order-total > 0.00

No Payment - commerce-order:commerce-order-total <= 0.00

Here's what happens:

When the order arrives at checkout. Stripe is selected as the payment method. When the 100% coupon is applied, the order total drops to zero as expected (through an AJAX refresh), but stripe stays selected as the payment method and the no payment option is not visible. If I reload the page manually, Stripe goes away and the No payment option is selected.

What I want:

Ideally, when a user applies a 100% coupon to the order at checkout, Stripe would disappear from available payment methods and "No payment required" would be automatically selected. Even better would be to also remove the billing information if the order total is <= 0, since there is no reason to collect it.

How can I achieve this?

I'm happy to work directly in code if that's a better approach.


texts: Create a View Showing Related Tax Term Reference Terms

texts:
Hello I have a vocab named 'categories'. I also have a vocab called 'tags'. I have added a term reference field (categories) to tags vocab so as i can relate tags to categories. Previously on D6 i would have the same vocab for both but with D7's new fieldable taxonomy i have to give this a go.

I am trying to create a view (block or views pane) that will display on my Categories term page. The view will contain the tags that are 'related' (have the category field added to them) on display. I am making this sound harder than it is is.

Term (tag vocab) 'Web Design' with term Reference (category vocab) 'Tech'. when i visit 'Tech' i see a view in the sidebar displaying 'web design'.

Can anyone give me any pointers in creating this View? I think I am using the wrong relationship possibly. I have three options. The Optional field is my category field:

  Taxonomy term: Optional (field_optional) This is an alias of Field:
  Optional (field_optional).

  Taxonomy term: Content using Optional Relate each Content with a
  Optional set to the term.

  Taxonomy term: Taxonomy term using Optional Relate each Taxonomy term
  with a Optional set to the term.

I think if I at least knew the right one to use it might help me accomplish my task. thanks


texts: How does one override default icons used to dislpay uploaded files from within a module instead of a theme?

texts: I'm attempting to add a custom icon for file uploads via a module. However, all I'm finding online is advice on using a theme function (How to change File field icons (without changing core)?). I want this in a module to make it work across various themes. I found file_icon_path, but am not sure how to implement it. How would this be done in a module?


texts:
I have a site using Drupal 8.5 I installed with Composer.
When users want to visit the site, they'd normally need to add /web after the domain to access it. I have a cpanel redirect that redirects users from domain abc.com to abc.com/web, so they don't have to add /web.
This solution is still a bit silly because the visitors still see the abc.com/web while I really want it to look like a regular website domain, domain.com.

I'm not allowed to use virtual hosts, but I am allowed to use htacces or symlinks.
How do I "redirect" visitors from domain localhost/temp-project to localhost/temp-project/web/index.php without having /web in the URL?

--Update 2--
I've tried to add a .htaccess snippet (from GitHub) in my root (localhost/temp-project) to point to /web and browsed to localhost/temp-project:

#Redirect to www location with subdirectory
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} localhost/temp-project [NC]
RewriteRule ^(.*)$ /web/index.php[R=301,NC]

This just doesn't do anything, what's going wrong here?


texts: How to deal with 'internal:' in your link->uri?

texts:
I have a link field, which I can populate with both internal and external links:

  /node/123

I'm building an API that parses the node and returns the URL from the link field:

$node->my_field->uri

Which returns internal:/node/123 which makes this URL useless.

If I try using use Drupal\Core\Url; and Url::fromUri($node->my_field->uri), I get a 500 error!

So what is the correct approach for getting a formatted URL, that can parse both internal and external links?


texts: "The specified file temporary://fileXXXXXX could not be copied" warning

texts:
If i open my local website there is a indication like this.

  The specified file temporary://filel17IDM could not be copied, because
  the destination directory is not properly configured. This may be
  caused by a problem with file or directory permissions. More
  information is available in the system log.

how to get out of this?


texts: Views PHP: Comparing two Field and display Answer

texts:
I tried to build a soccer magazine website. I want to display Match Win/Loss/Draw in the Match Result Page with the score result. I want to display it like:

if [field_score1] > [field_score2] display 'Win'
if [field_score1] < [field_score2] display 'Loss'
if [field_score1] = [field_score2] display 'Draw'

Im stuck please Help.


texts:
When I try to change my ACCOUNT settings at admin/config/people/accounts

The new state (visitors) doesn't stay checked at Who can register accounts. It reverts just back to admin.

Does anyone know why?

Note:  I had a look in settings and all the files around it (D8). But I cannot see anything similar.


texts: How do you force Drupal to re-render images?

texts:
I have an image style. It's defined as requiring images which are 60x60, however all of the images it's created are 500x500.

This is a screenshot of the image style definition:
https://monosnap.com/file/GEIcrx6kRjeHg1b9VoDnRSAFNLgXmJ

I would think that this image would be a tad smaller (pixelation is intentional):
https://monosnap.com/file/E6oUIF3rxZ3qtLRTcbgJPGwZUg0j1e

I was able to disable and re-enable the responsive images in borealis on one of the environments, and that re-generated the same image, but that did not work on this environment.


texts: Can we remove template.php from active theme folder?

texts:
If we remove template.php file from active theme folder will it work ? Will it follow default theme's template.php ?

Please help with this question.


texts:
I am wondering whether it is a good idea to convert a large D6 database of a community site (with 80% read 20% write and about 1300 qps, using MyIsam engine) from Mysql to MariaDB?

MariaDB seems to be highly desirable:

  MariaDB is a database server that offers drop-in replacement
  functionality for MySQL. MariaDB is built by some of the original
  authors of MySQL, with assistance from the broader community of Free
  and open source software developers. In addition to the core
  functionality of MySQL, MariaDB offers a rich set of feature
  enhancements including alternate storage engines, server
  optimizations, and patches

However I'd like to hear first-hand experiences of fellow drupallers about the expected performance gains. I know that MariaDB uses XtraDB (InnoDB improved) storage engine by default. In fact my site slowed down significantly once I moved the Mysql database to InnoDB engine, so I am a bit unsure about the supposed performance gains.

Also I'd like to know about caveats (possible incompatible modules, etc) of converting to MariaDB.

Thanks


texts: Show only used taxonomy terms in exposed filters

texts:
I have an exposed filter for tags on my view. I want this filter to only show show used tags. I found some drupal 7 options like this one and the Views Selective Filter but can't seem to find a good drupal 8 option.

Can anyone help me out with a solution for this?


texts:
I'm trying to set an english/spanish website and I've already set in my post types which are the types I want to be translatable. I also translated the posts but I'm not really sure how to set the views to display the content based on the language... I want the spanish posts to show up in domain.com/es/whatever/route ... and the english posts to show up in domain.com/whatever/route ... right now, both paths show the same content (the posts in English and the posts in Spanish)...

I'm guessing I need to somehow set contextual filters and relationships but I'm not so sure about how. Could I get a hand with that?


texts: Why use constuctor injection in controllers or forms?

texts:
Documentation is proposed to use injection in constructor instead of using \Drupal::service(). Why?

Example with injection:

class MyController extends ControllerBase implements ContainerInjectionInterface {
  protected $database;
  public function __construct(Connection $database) {
    $this->database = $database;
  }
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('database')
    );
  }
}

Example without injection (it is easier):

class MyController extends ControllerBase {
  protected $database;
  public function __construct() {
    $this->database = \Drupal::service('database');
    // or
    $this->database = \Drupal::database();
  }
}


texts: How to animate set of titles of a View using JQuery

texts:
There is a View of latest news title linked to the node page and I need to display them like this Effect.

I've trying to do it by creating a new template file for my views named:

  views-view-list--latest-news--block.tpl.php

and this is the code I was trying to set to work:

<?php print $wrapper_prefix; ?>
  <?php if (!empty($title)) : ?>

<?php print $title; ?>

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

         //this is where it shoul be typed...

  <?php print $list_type_suffix; ?>
<?php print $wrapper_suffix; ?>
<?php
$setOfTitles = "";
foreach($rows as $id=>$row)
     $setoftitles.="'".$row."'".",";
$setoftitles = rtrim($setoftitles , ','); // to remove the last `,`
print_r ($setoftitles); // and it says I have all of you node titles
?>
<?php print_r($setOfTitles); ?>

but it is not a true answer!! because my alert in js is empty and means I couldn't pass variable form php to js. Where is the problem? and how can I solve it? or is there a better way to do it?


texts: Get the value of a field inside a paragraph field in hook_preprocess_field

texts:
I'm usign the module Paragraphs for Drupal 8. I need to print the raw value of a paragraph field in the twig template, so I'm trying to access to the value of the field in the hook_preprocess_field, but I don't know how to access the value in $variables.

Any idea?


texts: Contextual filter term names with dashes

texts:
I cannot filter for a one word taxonomy term in Views, when configuring Contextual filters to display results based on a taxonomy term, when specifying the validation criteria, using:

Validator: Taxonomy term,
Filter Value type: Term name converted to term ID,
Transform dashes in URL to spaces in term name filter values = Checked.

Where Page settings: Path = myview/%/list

For instance: http://www.example.com/myview/cool-tools/list will filter content tagged with the Taxonomy term "Cool Tools"

Whereas: http://www.example.com/myview/tools/list will not filter any content tagged with "Tools."

If I uncheck "Transform dashes in URL to spaces in term name filter values", I can filter for "/myview/tools/list" and "/myview/cool tools/list" (with the space in the URL - undesirable), but I cannot filter for /myview/cool-tools/list.

Will I need to clone the view and uncheck the "Transform dashes in URL to spaces in term name filter values" checkbox to have both one word Taxonomy terms and multi-word Taxonomy terms with dashes in place of spaces work as filters? It seems like there would be a more graceful way to achieve this result with one view.


texts:
I'm brand new to the Drupal universe, and I'm stuck on something too big for me ^^
I need to create a View or a Content Type that will list files from a distant FTP Server and provide download link to some registered users.

I found something of interest named "Feeds FTP Fetcher", but I just can't find how to display something with it or even if I'm absolutely mistaken with it...

Could you please show me the way to get this "downloadable" list ?

Edit :
I got 2 upvotes and one downvote but still no comments or answers... can you comment below what you need from me ? i can give more details on some points maybe ?


texts: Access to only few fields of a content type for specific user

texts:
I am using drupal 6. I have created one content type 'video' in which I have many fields like url,language,locations etc. I have created 1 role, Now I just want to give permissions to that particular role so that he can only add fields like url,locations. He shouldn't be able to use other fields.
Any Suggestion,


texts: Changing Drush make default subdir for install profiles

texts:
I have a drush make file which has a default subdir for projects:

defaults[projects][subdir] = contrib

This places all modules into the sites/all/modules/contrib folder, which is great.

The trouble is, it also places my install profiles into the profiles/contrib folder.  Now when I run drush site-install, it doesn't work because the install profile is in the wrong folder.

Is there any way to tell drush make to NOT put the install profiles into a subdir?


texts: Load content without refreshing page in views

texts:
i am trying to create a view with pagination. In this view i have images and fivestar rating for it. When user clicks on next i want next image and fivestar to load with out refreshing page.

Thanks.


texts: Date Popup does not translate date format

texts:
I am using date popup for a Italian site.
In edit/node when in my_data_field I select the date it shows in English format mm/dd/YY and not in dd/mm/YYYY.

Instead if I use the date popup in a exposed filter in the display view works as I expected.

The problem occour only in edit/node .

Can you help me to solve this?


texts: How do you create a custom Panels layout in an Omega sub-theme?

texts:
I'd like to create a new custom Panels layout based on one of the Omega Panels layouts and put it in my Omega sub-theme, but I can't seem to find a way to do this.

So far I've added the following to my sub-theme .info file:

; PLUGINS
plugins[panels][layouts] = panels/layouts

I have then taken the layout I want to work from (omega_12_twocol_6_6_bricks) and renamed and copied this to sites/all/themes/mycustom/panels/layouts/omega_12/mycustom_12_twocol_6_6_bricks. I then renamed all the files within the mycustom_12_twocol_6_6_bricks directory replacing 'omega' with 'mycustom'. Then, within my mycustom_12_twocol_6_6_bricks.inc file I changed:

function omega_omega_12_twocol_6_6_bricks_panels_layouts() {
  $items['omega_12_twocol_6_6_bricks'] = array(
    'title' => t('Two Column 6-6 bricks'),
    'category' => t('Omega: 12 Column Grid'),
    'icon' => 'omega_12_twocol_6_6_bricks.png',
    'theme' => 'omega_12_twocol_6_6_bricks',
    'admin css' => '../omega_panels_admin_12.css',
    'regions' => array(
      'top' => t('Top'),
      'left_above' => t('Left above'),
      'right_above' => t('Right above'),
      'middle' => t('Middle'),
      'left_below' => t('Left below'),
      'right_below' => t('Right below'),
      'bottom' => t('Bottom'),
    ),
  );

  return $items;
}

to

function mycustom_omega_12_twocol_6_6_bricks_panels_layouts() {
  $items['mycustom_12_twocol_6_6_bricks'] = array(
    'title' => t('My Custom Two Column 6-6 bricks'),
    'category' => t('Omega: 12 Column Grid'),
    'icon' => 'mycustom_12_twocol_6_6_bricks.png',
    'theme' => 'mycustom_12_twocol_6_6_bricks',
    'admin css' => '../omega_panels_admin_12.css',
    'regions' => array(
      'top' => t('Top'),
      'left_above' => t('Left above'),
      'right_above' => t('Right above'),
      'middle' => t('Middle'),
      'left_below' => t('Left below'),
      'right_below' => t('Right below'),
      'bottom' => t('Bottom'),
    ),
  );

  return $items;
}

I also copied the admin css file into the relative directory as stated in the .inc file, cleared all cache and ran update.php, but I can't see my new layout when adding a new Panel.

The module versions I'm using are:

Drupal 7.22
Panels 3.3
Omega 3.1

Any help here appreciated.

Many thanks


texts: Editing the default layout for a content type in Panopoly

texts:
I am using the panopoly distribution. What is the easiest and preferred way to edit the default layout for a content type.

I know that I can use panelizer for one page, but where should I go to edit the entire contenttype?


texts: Rendering multiple-value field in Views theme tpl using arbitrary formatter

texts:
I need to merge items of one file field with other file fields, into one  list, as in

 Field A File

 Field B File

 Field C0 File

 Field C1 File

 Field C2 File

While files A and B are easily formatted in the Views UI (using my custom formatter), the files C have to be formatted in the code of the tpl file. That's because rewriting the output as in
[field_c]
 did not work as expected.

So I created a row-style tpl file and when it came to the Field C, the trouble began. I don't seem to be able to invoke my custom formatter by code:

  $fitems = field_get_items('node', $node, 'field_c');
  $display = array('type' => 'fileformatter', 'settings' => array('link_text' => 'MY CUSTOM FORMATTER STRING'));
  foreach($fitems as $delta => $fitem){
    $output = field_view_value('node', $node, 'field_c', $fitems[$delta], $display);
    print '
' . render($output) . '
';
  }

The files from field C are formatted using the default, generic file formatter.
General question arises: CAN custom formatter be invoked by Views tpl file?
The formatter works ok for any other instances, just not here. (It is not themeable yet, if that's of any importance).

I have also checked out this line:
$output = field_view_field('node', $node, 'field_c', $display);
which - to my knowledge - invokes the formmater's hook_field_formatter_view, but it does not accept delta :(

What else could I try?


texts: Entity form in ctools modal popup, whilst passing in values from current node

texts:
I need to open an entityform in a modal popup. I have got this working using 'Modal operations' and 'Modal forms' modules following this guide: http://julian.pustkuchen.com/en/comment/reply/599. My link looks like the following:

<?php print t('Apply') ?>

The problem now is that I need to pass certain data (e.g. the nid) of the currently viewed node into the entityform.

I am happy to use hook_form_alter or similar, but obviously hooking the entityform has no knowledge of the currently viewed node. My other, pretty hacky, idea was to grab data with javascript and put it in that way, but I need some sort of popup event to work from, which I don't think exists.

Is there another approach to this I could be using, or am I going down the right track?


texts: How can show only "read more" link in node's teaser, and remove or unset other links like "add new comments" or "2 Comments" at the end of a node teaser?


texts: How to get attributes of the form elements?

texts:
I know that it should be easy, but currently it doesnt work.
In my function I want to get #title of each element in the form. My form is fieldset "add_company". For example, when I try to get #title:

$msg = '';
foreach ($form['values']['add_company'] as $item)
    $msg .= $item['#title'] . ' ';

But I receive nothing.

Second part of question is when i try smth like this:

$value = $form_state['values']['add_company']['offers']['#title'];

I receive "O", but not "Offers".


texts: JQuery Accordion closes unintended when ajax-link from inside gets response

texts:
I'm working on a page where a user can click on ajaxified links inside a JQuery-Accordion-Widget.

Currently every time a link is clicked and the response is loaded, the accordion gets closed and it is not possible to click it anymore - but no JS-error is raised.

Did i miss something i have to call i.e. to change the focus ?

Thanks for your help,
piezo.


texts: How to fix millions of Alt Text are missing on body content?

texts:
This question is very similar to my other question. I have a website missing millions of Alt Text in body content(not image field). My solution is to set the default Alt Text as the file name without extension. Is it even possible, if so, how?

-- -- added additional info on Oct 2nd 12:40pm for tenken : below is a screenshot of setting

PS: there is no replace setting on Setting section

Here is the screenshot on setting section


texts: Drush rsync permission woes (files directory)

texts:
I'm rsyncing just the files directory (rest of the site is done through git) from my local Ubuntu setup to my centOS server. It worked at least (thankfully), but produced a ton of errors.
First it said:

rsync: failed to set times on "/home/myuser/mycentossite/sites/default/files/ctools": Operation not permitted (1)

Then tmp files and js files stated play up (sometimes happens on Ubuntu setup when clearing cache also)

rsync: mkstemp "/home/mycentosuser/mysite/sites/default/files/js/.js_ouzQFXPVCjfNTxl3b4ONpKTE.js.nghTEc" failed: Permission denied (13)
rsync: send_files failed to open "/home/myubuntuuser/websites/mysite/sites/default/files/tmp/file5GjL": Permission denied (13)

I fixed the permissions errors gradually with CHOWN and things started to work on the site. Though I'm wondering what is the correct way to go about rsyncing between local/remote in regard to permissions? And what happens if I rsync again - will it overwrite the stuff I've changed the permissions for? Or just add the new files?
Somewhat related.. My CentOS setup which uses the DSO PHP handler is also nagging me whenever I visit a page which generates a new folder of some kind. Is there way to set this up without having to go around putting CHMOD 777 on everything? (I'm the only user, so 777 in itself is not a problem for me...)
Thanks for any thoughts :)


texts: How to disallow users to edit their content after it was submitted for review?

texts:
I'm looking for a solution that does not allow a user to edit content after being submitted for review.

I'm working with two roles: Content Creator and Reviewer.

If the Reviewer rejects the content, then it will be enabled for the Content Creator to apply changes again.

I've tried using the Workbench module, it is very practical, but when the Content Creator submits a new content for review, the user still has access to edit this content, even if it is with status "Under review".


texts: Drupal script cannot change folder and file permissions in my VPS

texts:
Drupal always change permissions of /sites/default and settings.php. Now I move it in my VPS and maybe I misconfigure user www-data access but i cannot remember what exactly.

Now Drupal does not change permissions.

This problem caused by my mistakes.

Please, how to return proper configuration to have a Drupal works fine?


texts:
At my current work we do often landing pages (with their own domain)
I was wandering if someone already thought to do them with Drupal:

A multi-site (only one database) with several landing pages, each of them with their own domain. Anyone did it already?

How to face the multidomain feature?
Which are the best modules for accomplish this?


texts: How to achieve a particular layout (view within a view, custom template, or ____)?

texts:
Say I had a site with travel destinations and I wanted to display a series of videos associated with each destination on a page below a description of the destination. The destinations and the videos each have their own node type.

Currently, the list of destinations is a view. Each video has a taxonomy term associated with it, that ties it to a particular destination. We use views arguments to pick up the taxonomy term from the URL and have the videos displayed in the side bar. However, we'd like to make it more clear that the videos are associated with a particular destination.

How can we best achieve the following layout?

+-----------------------------------------+
| +-------------------------------------+ |
| |                                     | |
| |               node 1                | |
| |                                     | |
| +-------------------------------------+ |
| +----------+ +----------+ +-----------+ |
| | video 1a | | video 1b | | video 1c  | |
| +----------+ +----------+ +-----------+ |
|                                         |
| +-------------------------------------+ |
| |                                     | |
| |               node 2                | |
| |                                     | |
| +-------------------------------------+ |
| +----------+ +----------+ +-----------+ |
| | video 2a | | video 2b | | video 2c  | |
| +----------+ +----------+ +-----------+ |
+-----------------------------------------+

p.s. - We're already using the Context module, if that helps at all (and consequently, we'd like to avoid installing Panels, since they serve similar purposes).


texts: How to add taxonomy to node of custom type when taxonomy field name is unknown?

texts:
If field name is known it easy:

$node->field_{taxonony_field_name}[$node->language][0] = array('tid' => $term->tid);

What if name is unknown?

I found some examples which using this construct:

$node->taxonomy = $term;

but in my case it just wasn't work.


texts:
I'am trying to install Drupal 7 using composer. Before that I tried to install drupal 8 using composer and it works perfectly.

Now when I try to install D7 using same method it is still installing D8 instead of D7. I set up package repository as mentioned here but still installing D8 only. I tried $ composer clearcache also but no difference. Please help.


texts:
I am using the following PHP code in the view's header to set the breadcrumbs of the view.

global $base_url;
$path = $base_url . "/tag/" . arg(1) . "/" . arg(2);
$title = ucfirst(str_replace("-", " ", arg(2)));
drupal_set_title($title);
$breadcrumb = array();
$breadcrumb[] = l('Home', '<front>');
$breadcrumb[] = l($title, $path);
drupal_set_breadcrumb($breadcrumb);
print views_embed_view('article_tag_name', 'default', array(arg(2)));

In my page, the breadcrumbs contain the term ID, not the term name. How do I get the term name?


texts: Execute product pricing rule for the order owner

texts:
I have a custom product pricing rule set up in Drupal Commerce which gives users of role Trade a different price by using a different commerce_price field on the product which works fine.

But I need to export the values later on in to a XML file. The original product price is being returned as the rule is set up to use the Current user role, not that of the original user who made the transaction.

Is there anyway to have the rule act on the line item owner or for me to overwrite this in my XML output when calling rules_invoke_event('commerce_product_calculate_sell_price', $line_item);


texts: Create a panel with related group content based on a view

texts:
I'm using groups (Drupal 7) and have set up panels to show related content for each group. So that if I look at a particular group node it also shows associated group news items, members, etc. The main content is the group body field.

I now want to show a view that displays a list of related content (group messages) for a group as the main content. This should also show the associated group members and news items in a related pane, as it does in the main group panel. I can't see how I can relate the group to the view. It is straightforward to relate the view to the group but not vice versa.

Is it possible to relate the group to the view based on an argument in the path? When I create a new panel the contextual options are all about the node being viewed or the group, but nothing for views or the path.

Or alternatively, is it possible to add a variant to the main group panel page that shows the view I want to display instead of the group body field? How could I create a different context for this? Would it be possible to do it using a path?

Many thanks in advance,

Ben


texts: How to attach files using mimemail (Getting 0kb file)

texts:
(This isn't the same as the other issue I raised. I thought I'd got the attachment working but I haven't)

Initial Problem

I'm trying to attach a file to an email. It's part of job application so a person goes to a node, presses apply and it sends an email to the creator of the node. I want to attach a CV & cover letter to it.

Here are my submit and hook_mail functions.

function tellafriend_form_submit($form, &$form_state) { ...

        $message = drupal_mail('tellafriend', 'notify', $email, language_default()); ...
}

function tellafriend_mail($key, &$message, $params) {

        global $base_url;

        $attachment = array(
          'filecontent' => file_get_contents('http://localhost/public/counciltax.txt'),
          'filename' => 'counciltax.txt',
          'filemime' => 'text/plain',
          'list' => TRUE,
          );
        $message['subject'] = t('Your friend thought you might like this site');
        $message['body'][] = t("Hello,\nYour friend thought you might like this site.  Please click the link below to visit.\n\n!link", array('!link' => $base_url));
        $message['params']['attachments'][] = $attachment;
}

Sometimes this will send an attachment. Othertimes it won't. It sent once, I repeated the same process and it didn't work. Mostly it doesn't work.

These two tests were run 10 seconds apart and I didn't change any code.

Here's the successful email.

And here's the unsuccessful email.

Am I doing this wrong, or is this just broken? How would I debug this?

(This was the example I used as reference http://rapiddg.com/blog-post/drupal-7-html-e-mail-pdf-attachments)

EDIT  ----- 05/08/2013

I tried using frazras's technique (cheers!), of putting the attachment in the submit function however it still doesn't work every time. (Code not shown because it's identical to the section he posted.)

My public folder looks like this:

This is the information I'm entering:

'uri' => 'public://hashtags.txt',
'filename' => 'README.txt',
'filemime' => 'text/plain',

The results of sending 12 or so in a row. It mostly works now, but still randomly fails

I'm changing nothing inbetween the tries, it just doesn't work sometimes. Any other ideas or info about how I could debug this?


texts:
I am creating (content/nodes)  directly by SQL , I am inserting following tables :
node
node_revision
body_field

everything looks ok . But when I use FLAG module it does'nt show anything on the bookmarked view . Am i missing any other table which should be updated ?

Thanks
pks


texts: How do I add a date format to custom block output

texts:
I have two custom block output fields that are date

    function my_three_upcoming_events() {
  $output = '';
  $now_events = views_get_view_result('schedule_list2');
  $upcoming_events = views_get_view_result('clone_of_now');
  $max_events = 3;

  $all_events = array_merge($now_events, $upcoming_events);
/*   print_r ('
');
print_r ($all_events);
exit();
*/  for ($i=0,$z=$max_events;$i<$z;$i++) {

    $node = node_load($all_events[$i]->nid);
    $output .='
' . l($node->title,'/node/'.$node->nid) . '
';
    $output .='
' .($node->body[und][0][value]) . '
';
    $output .='
' .($node->field_venue[und][0][value]) . '
';
    $output .='
' .($node->field_session_start_date[und][0][value]) . '
';
    $output .='
' .($node->field_session_start_date[und][0][value2]) . '
';

  }

}

and they output like this

2014-04-18 15:15:00
2014-04-19 21:15:00

How can I change to one of the php date formats

Thanks for any help on this


texts: How to change the starting order number for Commerce 2?

texts:
I want to change the initial order number for my new Commerce store to 777 instead of 1.

For Drupal 7, there is an explanation here, but I know the Commerce architecture has changed a lot.

I'm using Drupal 8.4 and Commerce 2.1.

The basic approach described is to use a sql query to adjust AUTO_INCREMENT for the order table-- is that still the recommended approach in Commerce 2?


texts:
In Drupal 8 I am using

$date_service = \Drupal::service('date');
$options = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200,
  64800, 86400, 172800, 259200, 604800, 1209600, 2419200), array($date_service, 'formatInterval'));

But this gives me error

  Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
  You have requested a non-existent service "date". Did you mean one of
  these: "theme.negotiator.system.db_update",
  "entity.definition_update_manager", "date.formatter",
  "update.post_update_registry", "update.post_update_registry_factory",
  "access_check.db_update", "access_check.update.manager_access",
  "update.manager", "update.processor", "update.fetcher", "update.root"?
  in Drupal\Component\DependencyInjection\Container->get() (line 161 of
  /Applications/MAMP/htdocs/drupal-8.0.x-dev/core/lib/Drupal/Component/DependencyInjection/Container.php).

What wrong am i doing? Am i missing use class something like this use Drupal.... or something wrong in line $date_service = \Drupal::service('date');


texts: Add image when creating content with Devel Content Generate?

texts:
I used to use Devel to generate nodes content for developing purposes. It works fine but it doesn't add images to the created nodes even though the content type has an image field.

What am I missing here?


texts: The right way to validate fields via hook_node_validate

texts:
Rather than creating a new field via the Field API, and as a quick workaround, I've added a simple text field to a content type that I'm now attempting to validate via hook_node_validate(). Unlike previous versions of Drupal, the value for this field is not simply available as $node->field_name or $form['field_name'], but instead as a nested array containing a variety of other information.

My question then is this: what is the 'correct' and therefore most future proof way to retrieve the value for this field? Am I supposed to be using the likes of field_view_value() or field_view_field(), or is it acceptable to simply reference $node->field_name['und'][0]['value'] for example.


texts: I have created full text search in webforms using Search Api and its working fine earlier but when i added some new records, the new records are not indexed and not able to displayed them on view. I don't know why new records are not indexed.


texts: How to list most viewed nodes using Statistics module?

texts:
How to list most viewed nodes using Statistics module in Drupal 6?

I'm looking for the PHP code to use in a custom theme.


texts: Difference of two Dates in Computed Field

texts:
fields: (Date to - Date from) = Total Number of Days

How can I compute the total number of days between two dates using Computed Field?


texts: Add percentage based fee/tax to specific product types on checkout

texts:
In Drupal 7 Commerce, I have two product types, a service product and a physical product. I would like a 6% fee added to all physical products only when the user gets to the cart review page. Ultimately it would be a custom line item like a sub-total or tax.

Currently I've been able to add another sales tax to produce this functionality, however the tax is being applied to all products, rather than calculating the 6% on only the physical products. I'm not sure if this can be done with Drupal Rules, or if I'd need to use hooks.


texts: As in subject: how to prevent warnings from displaying to anonymous users? They contain paths etc. Even better, how to display warnings only to priviledged users?


texts: Commerce Kickstart - Show breadcrumbs on account/profile pages

texts:
How display the breacrumbs on all account pages (user/*)?

In Kickstart distribution of Drupal Commerce, the breadcrumbs is hidden by default on this pages.

I have try to set position for the breacrumbs block (disabled by default), it's correctly displayed on all pages but it's displayed duplicate as you can see.

What's the good way for this?

Edit: Adding a screenshot.


texts: Show parent items in hierarchical facet display

texts:
Taxonomy terms are configured as such:

Parent category 1
- Child category 1
- Child category 2

Parent category 2
- Child category 3
- Child category 4

"Empty facet behaviour" is set to "Do not display facet".

"Flatten hierarchy" is turned off.

"Treat parent items as individual facet items" is turned off.

But the facet display doesn't show the parent items. How do I configure it properly to do so?


texts: how long do files hang around in temporary://?

texts: I want to offer a file download to my users, and I was thinking of using temporary:// to store the data. But how temporary is it? When do files disappear from it? Of course, I want to avoid having the file not be present when my user goes to download it jsut after a form submission, and I also want it gone after a while. So when do they go?


texts:
I am creating a site with drupal 7.15 with bootstrap and using less. But when i reload the page i found the following errors. (dope is my sub-theme name)

LESS could not create a directory in public://less/51761ea74e5068.61766466/sites/all/themes/dope/less
Warning: Invalid argument supplied for foreach() in drupal_pre_render_styles() (line 3311 of /home/seat3/public_html/DOPE/drupal/includes/common.inc).
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 of /home/seat3/public_html/DOPE/drupal/includes/common.inc).


texts: EntityFieldQuery: Filter by field language

texts:
How would I use EntityFieldQuery->fieldCondition() or similar to filter by field language? E.g. give me all nodes where field_description has items in English, or in LANGUAGE_NONE?

There is a $language_group parameter, but I think this won't do the job..

Background: I would like to improve entity_translation module for D7, see https://www.drupal.org/project/entity_translation/issues/2852983#comment-13039403


texts: Form element replaced via Ajax callback doesn't seem to be submitting or the values are not appearing in buildForm

texts:
I'm having a form with a select list and a textbox. On-change of select list will trigger an ajax callback. The callback function will replace the default value of textbox with an updated value.
But when I try to get the textbox value in buildForm() or if I try to submit the form, instead of the updated value the default value (old value which is set) is passed on submit handler. Below is the code -

<?php

namespace Drupal\my_module\Form;

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Form\FormStateInterface;

class MyAjaxForm extends ConfigFormBase {

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

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

    $form['output'] = [
        '#type' => 'textfield',
        '#size' => '60',
        '#value' => 'oldvalue',
        '#default_value' => 'oldvalue',
        '#attributes' => [
            'id' => ['edit-output'],
        ],
    ];

    $form['input'] = array(
        '#title' => t('Crust Size'),
        '#type' => 'select',
        '#description' => 'Select the desired pizza crust size.',
        '#options' => [
          'medium' => 'Medium',
          'large' => 'large',
         ],
        '#ajax' => [
            'callback' => [$this, 'seyHello'],
            'event' => 'change',
            'wrapper' => 'edit-output',
            'progress' => [
                'type' => 'throbber',
                'message' => t('Verifying entry...'),
            ],
        ],
    );

    return parent::buildForm($form, $form_state);
    dpm($form['output']['#value']);
    //even after the ajax callback return and the textbox is filled with 'newvalue', dpm returns 'oldvalue' still.
  }

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

    dpm($form['output']['#value']);
    dpm($form_state->getValue('output'));
    //both returns 'oldvalue'

  }

  public function seyHello(array &$form, FormStateInterface &$form_state) : AjaxResponse {
    $elem = [
        '#type' => 'textfield',
        '#size' => '60',
        '#default_value' => 'newvalue',
        '#value' => 'newvalue',
        '#attributes' => [
            'id' => ['edit-output'],
        ],
    ];
    $renderer = \Drupal::service('renderer');
    $response = new AjaxResponse();
    $response->addCommand(new ReplaceCommand('#edit-output',
    $renderer->render($elem)));
    $form_state->setRebuild(TRUE);
    return $response;
  }

}

I'm not sure why this is happening, it clearly seems to be the case of form values not getting updated after the ajax callback for me. Been debugging this for entire day. Any help/ suggestions would be lovely.
Thanks.


texts: Adding text before and after cart contents block in Drupal 7 commerce

texts:
I need to add some text above and below the Cart Contents block at the top of the checkout form. I tried just editing the view and adding a header and footer to that view but no dice, it doesn't work (it shows in the View preview but not in the view results when saved).

So I'm looking for the page--checkout.tpl.php form and I can't find it anywhere. Does anyone know where I can find this template?


texts: how can i get path vocabulary based taxonomy term with node title using views?

texts:
I have created vocabulary called Category and it contains below hierarchy

term1
  term 1.1
     term 1.1.1
     term 1.1.2
     term 1.1.3
  term 1.2
term2

and i have assigned to this category to content type called Product after that i have displayed those product items based on category using views with panels it's working fine.when i click product title the url goes like this

http://www.example.com/content/prodcut-title

but i want path like this

http://www.example.com/category/term1/term1.1/term1.1.1/product-title
category with term based product title using views.

Please suggest possible ways,

Thanks.


texts: How to configure the fields in the report created by the Content Audit module?

texts:
I use the Content Audit module on my site.

Does anyone know how to configure the fields that are present in the resulting report beyond modifying the content_audit_report.views_default.inc file?


texts: How to Make Managed File Field Available to Twig Template?

texts:
I am wanting to make it so that users can upload images to a block configuration form for a pre-existing (views-generated) block (views_exposed_form) and have the images available in the block's template file. Here's my block class:

<?php

namespace Drupal\exposed_filter_images\Plugin\Block;

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\Block\ViewsExposedFilterBlock;

/**
 * Provides a 'Views Exposed Filter' block.
 *
 * @Block(
 *   id = "exposed_filter_images_block",
 *   admin_label = @Translation("Exposed Filter Images Block"),
 *   deriver = "Drupal\exposed_filter_images\Plugin\Derivative\ExposedFilterImagesBlock"
 * )
 */
class ExposedFilterImagesBlock extends ViewsExposedFilterBlock {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);

    $form['image_1'] = [
      '#type' => 'managed_file',
      '#upload_location' => 'public://images/steps/',
      '#title' => t('Image 1'),
      '#description' => t("Image on the left"),
      '#default_value' => $this->configuration['image_1'],
      '#upload_validators' => [
        'file_validate_extensions' => ['gif png jpg jpeg'],
        'file_validate_size' => [25600000],
      ],
      '#states' => [
        'visible' => [
          ':input[name="image_type"]' => ['value' => t('Upload New Image(s)')],
        ]
      ]
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->configuration['image_1'] = $form_state->getValue('image_1');
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    $output = parent::build();

    $output['#theme'] = 'views_exposed_form';
    $output['#files'][0] = $this->configuration['image_1'];

    return $output;
  }
}

Here's my exposed_filter_images.module file:

<?php

/**
 * Implements hook_theme().
 */
function exposed_filter_images_theme($existing, $type, $theme, $path) {
  return [
      'views_exposed_form' => [
          'variables' => ['files' => []],
      ],
  ];
}

/**
 * Implements hook_block_alter().
 */
function exposed_filter_images_block_alter(&$plugins) {
  if (isset($plugins['views_exposed_filter_block:elder_index-page_1'])) {
    $plugins['views_exposed_filter_block:elder_index-page_1']['class'] = \Drupal\exposed_filter_images\Plugin\Block\ExposedFilterImagesBlock::class;
  }
}

And then in the views-exposed-form.html.twig file, I can have a number returned with this simple debug: {{ files.0|json_encode }} (without the |json_encode filter, nothing shows up), but I'm not really understanding what this number is is or what I can do with it.

So I'm looking for what I would need to do in the class or in the twig file in order to have an image or at least the URL to the image appear on the front-end.

Thanks in advance!


texts: how to stop a view from executing within a views hook

texts:
I am using custom code with a views pre_execute and i want the view to return an empty set if certain conditions are met , or not to return the view at all.
how can i do this ?  this is what i tried.

function mymodule_views_pre_execute(&$view) {
   // if certain conditions are met i want this view to be empty or not come out at all
  if ($myconditions){
   $view = null;
  }
}


texts: How can i use bootstrap js library in my theme?

texts:
I use bootstrap drupal theme. And i want to use collapse.

I added in theme.info the library path bootstrap.js have cleaned the cache, but after using the following code generates only the button, but the content is not deployed.

      <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">

Most likely is not initializing bootsrap.js, please tell me how to fix it?


texts: I want to remove the comment section from all my articles. Can this be done with an sql query or something so I don't have to do it manually by setting comments to disabled ?


texts: Override default drupal_set_message() on node creation

texts:
I am creating a simple basic module that alters the text of a submit button and should change the default creation message with drupal_set_message().

I've found an example about changing the message, and changed the code a little.

 function ask_admin_form_alter(&$form, $form_state, $form_id) {
   if ($form_id == "vragen_node_form") {
     $form['actions']['submit']['#value'] = 'Stel Uw Vraag';
     $form['buttons']['submit']['#submit'][0] = 'ask_admin_node_form_submit';
   }
 }

 function ask_admin_node_form_submit($form, &$form_state) {
   global $user;

   $node = node_form_submit_build_node($form, $form_state);
   $insert = empty($node->nid);
   node_save($node);
   $node_link = l(t('view'), 'node/'. $node->nid);
   $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
   $t_args = array('@type' => node_get_types('name', $node), '%title' => $node->title);

   if ($insert) {
     watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
     drupal_set_message(t('Uw vraag is met succes ontvangen en zal zo spoedig mogelijk beantwoord worden.', $t_args));
   }
   else {
     watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
     drupal_set_message(t('U heeft uw vraag met succes gewijzigd.', $t_args));
   }
   if ($node->nid) {
     unset($form_state['rebuild']);
     $form_state['nid'] = $node->nid;
     $form_state['redirect'] = 'node/'. $node->nid;
   }
   else {
     // In the unlikely case something went wrong on save, the node will be
     // rebuilt and node form redisplayed the same way as in preview.
     drupal_set_message(t('Er ging iets mis bij het verzenden van uw vraag.'), 'error');
  }
}

Although the form button is indeed changed to my own text, the message won't change when the node is created.

When I copy and paste the whole tutorial, my node messages won't change, but I also get no error messages.

Does anyone knows what is wrong, or how I can change the message using other code?


texts:
I'm trying to output a menu with all of its submenus into a template file, currently I'm using the code below. The problem is that it only displays the top level links. If I pass the second $level parameter into menu_navigation_links it'll then only display that one level, not any of the others above or below.

How can I display all the different menu levels & still have the ability to add classes to the  as below? The title isn't really that important as I can 'hard code' that tag into the template file.

print theme('links__menu_top_page_navigation', array('links' => menu_navigation_links('menu-top-page-navigation'), 'attributes' => array('id' => 'main-menu', 'class' => array('main-menu', 'list-menu')), 'heading' => array('text' => t('Main menu'),'level' => 'h2','class' => array('main-menu-title'))));

The closest thing I've found so far is to use menu_tree_all_data() & menu_tree_all_output() but I cannot see how to edit the  class using that.


texts: Entityform: email submitted form to someone who is not admin?

texts: How do I get the Entityform module to email the contents of a submitted form to user@example.com. The owner of this email address is not the admin. Thanks


texts: Is there a way to place the "Add new comment" link where I want?

texts: Is there a way to place the "Add new comment" link where I want in my content type? I'd like the link to be between two already existing fields in the content type. Is there some type of way to add this link via a field? Please help. This issue has been killing me.


texts:
I'm trying to convert a d6 location field into a a d8 geolocation field, but when I run it the field does not get updated, and I don't get any messages either.

All of the other node data has been imported already so I am running the migration with the command: drush migrate-import ttf_location_migration --update

I am including title because without it I get an mySQL error message.

Here's my migration YML file:

id: ttf_location_migration

label: Migrate old location data to geolocation field

source:
  plugin: ttf_location
  key: ttf_migrate

process:
  nid: nid
  title: title
  type: type
  'field_location/bundle': type
  'field_location/deleted':
    plugin: default_value
    default_value: 0
  'field_location/entity_id': nid
  'field_location/revision_id': nid
  'field_location/langcode':
    plugin: default_value
    default_value: 'en'
  'field_location/delta':
    plugin: default_value
    default_value: 0
  'field_location/field_location_lat': latitude
  'field_location/field_location_lng': longitude

destination:
  plugin: entity:node
  overwrite_properties:
    - 'field_location/bundle'
    - 'field_location/deleted'
    - 'field_location/entity_id'
    - 'field_location/revision_id'
    - 'field_location/langcode'
    - 'field_location/delta'
    - 'field_location/field_location_lat'
    - 'field_location/field_location_lng'

migration_dependencies: {}

dependencies:
  enforced:
    module:
      - ttf_migrate

and my source plugin:

<?php

namespace Drupal\ttf_migrate\Plugin\migrate\source;

use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;

/**
 * Source plugin for location.
 *
 * @MigrateSource(
 *   id = "ttf_location"
 * )
 */
class TtfLocation extends SqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {

    $query = $this->select('location', 'l')
      ->fields('l', ['lid', 'latitude', 'longitude']);
    $query->join('location_instance','li','l.lid = li.lid');
    $query->fields('li', ['nid']);
    $query->join('node', 'n', 'li.nid = n.nid');
    $query->fields('n', ['type', 'title']);

    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    $fields = [
      'lid' => $this->t('Location ID'),
      'latitude' => $this->t('Latitude'),
      'longitude' => $this->t('longitude'),
      'nid' => $this->t('Content ID'),
      'type' => $this->t('Type'),
      'title'=>$this->t('Title')
    ];

    return $fields;
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    return [
      'nid' => [
        'type' => 'integer',
        'alias' => 'nid',
      ],
    ];
  }

}

Any help much appreciated

Thank you


texts: Book page appears in one language (of four) only

texts:
I run a Drupal 7 site with 4 languages installed: English (for me as admin) and 3 balkan languages (I don't speak them actually): Serbian, Croatian, Slovenian.

I have added a book there (url shortcut should be: help) and have added 3 book pages: Imprint (in German, url shortcut imprint), Privacy and Terms of Services (both pages have English content and url shortcuts privacy and tos).

All 3 book pages should be visible in all languages - i.e. in English, Serbian, Croatian, Slovenian.

However for some reason they are only visible in the Croatian view of my web site and also only /hr/shortcuts work.

And when I look at http://balkan-preferans.de/en/node/1#overlay=en/admin/content they have Croatian as language:

Can I somehow change the language to be All?


texts:
I use below script to update the drupal - core and modules - using the linux cron.

#!/bin/bash
perform_backup(){
cd "$1"
echo "Current working directory : $(pwd)"
if  /usr/bin/drush -r .  status bootstrap | grep -q 'Successful' #Check if a drupal website
then
  if /usr/bin/drush -r . ard --tar-options="--exclude=.git"
  then
    # If archive-dump was successful, then
    # Perform drush update without further backups
    /usr/bin/drush -r . -y pm-update --no-backup
  fi
else
#Do a git commit of the current working directory
git add .
git commit -m"CronBackup-$(date +%s)"
fi
}
export -f perform_backup
find /var/www/html/ -mindepth 1 -maxdepth 1 -type d -exec bash -c 'perform_backup "$0"' {} \;

The linux crontab entry is as follows.

0        0          *              *                0,3,6           /usr/bin/drupal-updater >> /var/log/site-update-log

and the log details which i got for one website from /var/log/site-update-log is like below

Current working directory : /var/www/html/example.com
/root/drush-backups/archive-dump/20170304000002/example.20170304_000002.tar.gz
Update information last refreshed: Sat, 2017-03-04 04:52
 Name               Installed  Proposed  Message
                    Version    version
 Metatag (metatag)  7.x-1.20   7.x-1.21  SECURITY UPDATE available
 Panels (panels)    7.x-3.8    7.x-3.9   Update available
 Views (views)      7.x-3.14   7.x-3.15  SECURITY UPDATE available
 Views Slideshow    7.x-3.5    7.x-3.7   Update available
 (views_slideshow)

Security and code updates will be made to the following projects: Metatag [metatag-7.x-1.21], Panels [panels-7.x-3.9], Views [views-7.x-3.15], Views Slideshow [views_slideshow-7.x-3.7]

Note: You have selected to not store backups.
Do you really want to continue with the update process? (y/n): y
Project metatag was updated successfully. Installed version is now 7.x-1.21.
Project panels was updated successfully. Installed version is now 7.x-3.9.
Project views was updated successfully. Installed version is now 7.x-3.15.
Project views_slideshow was updated successfully. Installed version is now 7.x-3.7.

However, in reality none of those modules were updated though the archive dump of the website was successful. When I did a pm-update from the document root, below is the result I got

[root@instance-1 example.com]# drush pm-update
Update information last refreshed: Sat, 2017-03-04 09:55
 Name               Installed  Proposed  Message
                    Version    version
 Metatag (metatag)  7.x-1.20   7.x-1.21  SECURITY UPDATE available
 Panels (panels)    7.x-3.8    7.x-3.9   Update available
 Views (views)      7.x-3.14   7.x-3.15  SECURITY UPDATE available
 Views Slideshow    7.x-3.5    7.x-3.7   Update available
 (views_slideshow)

Security and code updates will be made to the following projects: Metatag [metatag-7.x-1.21], Panels [panels-7.x-3.9], Views [views-7.x-3.15], Views Slideshow [views_slideshow-7.x-3.7]

Note: A backup of your project will be stored to backups directory if it is not managed by a supported version control system.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue with the update process? (y/n): n
Aborting.                                                            [cancel]
No database updates required                                         [success]
drush c'all' cache was cleared.                                             [success]
Finished performing updates.                                         [ok]
[root@instance-1 example.com]#

The actual updates were made only during manual updation. What is the cause for this?

Note: The actual domain name is changed for security reasons


texts: Get variable from controller in twig using template

texts:
I have a php variable in my controller and i want to use it in twig.
So i do this :

Controller :

$firstLetter = '2017'; //dynamic variable but for the test it's a constant

$build ['list'] = array(
      '#theme' => 'liste-adh2',
      '#content'=>$result,
      '#filters'=>$ListApport,
      '#filters2' =>$Listline,
      '#test' => $firstLetter,  //sending to my template
   );

return $build;

Template :

function adh_apport_theme($existing, $type, $theme, $path)
{

    return [
        'liste-adh2' => [
            'variables' => ['content' => NULL, 'filters' => NULL,
                            'filters2' => NULL,], ['test' => NULL,],
                        ],
            ];
}

Twig :

{{ test.firstLetter }}

i got nothing in twig and i don't know why.

Thanks for helping.


texts: Paragraphs Entity Type Causing Issues After Core Update

texts:
I am getting this error whenever I try to create a node on Drupal 8.6.2.

  Drupal\Component\Plugin\Exception\PluginNotFoundException: The paragraph entity type does not exist. in Drupal\Core\Entity\EntityTypeManager line 133.

Right now, the paragraphs module is turned off. I have ran drupal updb to see if the database needed updating; nothing came back.

I tried drupal moi and drupal mou for paragraphs, but I get this error.

  [ERROR] Configuration objects (core.entity_view_mode.paragraph.preview) provided by paragraphs already exist in active configuration

How can I fix this error?


texts: Design views display and views filters separately?

texts:
Looking of the exported views code it looks like the code for the filters is usually in a separate section from the fields and their layout.

With that in mind I want to separate out the aspect of views which cover the selection of fields and their display from the design of the filters, so I can continue to improve the filters on one page, whilst designing the data selection and presentation on another. I would then merge them into a new view later.

Is something like this feasible? Of course that means when designing a view I should not remove any of the fields in the display view which are used in the filters.


texts: Display status message after submitting modal popup form

texts:
Ok so i have a custom entity and want to display a custom delete form. Have created the Route and everything works except for Drupal messenger displaying status message after submission, even after a manual refresh.
The weird thing is, if i add a ksm() output to hook_entity_delete() which is called after the entity is deleted, the status message does display.
I have added a '?destination=' parameter to the end of the link the initiates the popup, and after submit, the redirect is successful.
Here is my class, which i can get to popup in a dialog window, with the form and successful deletion and window close.
Just to clarify, trying to get the status message to display on the form from where the modal popup was initiated from, not to get the message in an additional popup.
Any ideas?
class TrEntryDeleteForm extends ConfirmFormBase {

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

    $entry_id = $na_entry->id();

    $form['title'] = [
      '#markup' => t("
Title
"),
    ];

    $form['description'] = [
      '#markup' => t("
This action can't be undone
"),
    ];

    $form['entry_id'] = [
      '#type' => 'hidden',
      '#default_value' => $entry_id,
      '#required' => TRUE,
    ];

    $form['actions'] = [
      '#type' => 'actions',
    ];

    $form['actions']['cancel'] = [
      '#type' => 'submit',
      '#value' => $this->t('Cancel'),
      '#attributes' => [
        'class' => [
          'use-ajax',
          'cancel',
        ],
      ],
      '#ajax' => [
        'callback' => [$this, 'closeModalForm'],
        'event' => 'click',
      ],
    ];

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

    return $form;
  }

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

    $entry_entity = \Drupal::entityTypeManager()->getStorage('entry')->load($entry_id);
    $entry_entity->delete();

    \Drupal::messenger()->addStatus(
      t('@msg', ['@msg' => 'Entity deleted.'])
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {

  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    // TODO: Implement getCancelUrl() method.
  }

}


texts: Printing outout of a view in to a field in user profiles

texts:
I have created a view which prints only usernames of registered users .

In user registration there is field named "father username" .  i want that field to be populated as a list from the above view .

i used view reference , but it just shows all the views in the site .

any clue ?
thanks :)


texts:
I'm trying to setup a slideshow on my site using the Slideshow setup that is currently used on D7. I click on the Slideshow option and the following screen shows up. Then, I enter the name, and then I tried to browse the image. Somehow I can't seem to browse for the image (let alone attach it).

Is there a reason why? Is there something that I need to install?


texts: The most efficient way to query the user table and custom profile info based on UID

texts:
I am trying to grab a specific users profile info + custom profile fields WHERE uid = X,
I have used the views module currently and copied that sql however that creates a massive query. I was wondering if there is a better way to query Drupal 6 other than views to grab the UID, name, email, + my custom fields?

SELECT profile_values_firstname.value AS profile_values_firstname_value,
profile_values_firstname.uid AS profile_values_firstname_uid,
profile_values_surname.value AS profile_values_surname_value,
profile_values_surname.uid AS profile_values_surname_uid,
profile_values_telnumber.value AS profile_values_telnumber_value,
profile_values_telnumber.uid AS profile_values_telnumber_uid,
users.mail AS users_mail,
users.uid AS users_uid,
users.access AS users_access,
users.name AS users_name
FROM node node
 INNER JOIN users users ON node.uid = users.uid
LEFT JOIN profile_values profile_values_firstname ON users.uid = profile_values_firstname.uid AND profile_values_firstname.fid = '1'
LEFT JOIN profile_values profile_values_surname ON users.uid = profile_values_surname.uid AND profile_values_surname.fid = '2'
LEFT JOIN profile_values profile_values_telnumber ON users.uid = profile_values_telnumber.uid AND profile_values_telnumber.fid = '3'


texts: Parent Theme overriding Subtheme on certain paths

texts:
I installed the Opgino installation for Drupal 8 and created a sub-theme for default theme that comes with Opigno. The subtheme works as it should, except on certain paths. Anything with a path of /group/* uses the parent theme. (I.e., example.com/group/40/module/37/answer/32) None of the styles, JavaScript or other template will work on these pages.
The Switch Page Theme module does nothing to help. Among the Opigino module files, I couldn't find references to ThemeNegotiatorInterface. I found a modules with multiple references to the parent theme in the *.yml install file.
status: true
dependencies:
  module:
    - group
    - opigno_learning_path
  theme:
    - platon
id: opignogroupoperationsblock
theme: platon

Does that mean it's set in the database for these pages and this module? Is it possible to create installation yml files that override these?


texts: Having trouble obtaining a query parameter on a views page

texts:
I have successfully created a custom contextual link to create a "picture" node linked to the current "artefact" node:

    function tanw_contextual_links_view_alter(&$element, $items) {
      if (isset($element['#contextual_links']['node'])
             && in_array($element['#contextual_links']['node']['metadata']['ds_bundle'], ['artefacts','events'])) {
        $entity = entity_load('node', $element['#contextual_links']['node']['route_parameters']['node']);
          {do my thing with the entity}

But now I am completely stuck trying to add the very same link to a views page that shows all pictures linked to a given "artefact". The nid is in the url:

http://MY_DOMAIN/manage_photos?node=32006

The following code seems to pick up the correct context for adding the link:

  else if (isset($element['#contextual_links']['entity.view.edit_form'])
         && $element['#contextual_links']['entity.view.edit_form']['metadata']['name']
== 'photo_slideshow' )

But for the life of me I cannot find a way of prying the node query parameter value either out of the URL or out of elsewhere.

The $element array for the views context doesn't contain the query parameters anywhere. \Drupal::request()->query returns NULL for some inexplicable reason. While exploring the request object, the only part where I even see the query parameters is buried somewhere under ->server in HTTP_REFERRER of all places. Of course I can try to extract what I need from there but it looks like a horrible last resort kind of hack I am not yet ready to resort to.
I am feeling that I am missing something obvious and/or looking in a wrong place. Will appreciate any pointers to the right place.

PS I just realized that the "current path" for the hook context is /contextual/render as it seems to be a separate ajax request from the main page request and the main request query parameters are no longer relevant here. So the question is: how do I obtain the main page request?


texts: How to grant User Points after Quiz questions are answered correctly?

texts:
I have the User Points module enabled and I want to use the Rules module to create a rule which lets a user win User Points whenever the user answers correctly my questions.

I don't know what should I put as Rules Event and as a Rules Condition.

How can I specify that the user only earns User Points when the answer is correct?


texts: How to get a node object/id from theme functions when the form is ajaxified?

texts:
I used theme_radio() hook to change the html code of my radio buttons in ubercart attributes form to get something like that:

The code I used in theme_radio function to display this is:

//We modify only radio input in ubercart attributes forms
  if(isset($variables['element']['#parents'])){

    if(($variables['element']['#parents']['0']=='attributes')&&($variables['element']['#parents']['1']=='8')&&($variables['element']['#type']=='radio')){

      $node = menu_get_object();

      $position = $variables['element']['#return_value'];

      //We load content from field collection
      $field_collection_entity = field_collection_item_load($node->field_colors['und'][$position]['value']);

      //We extract color name from field collection
      $color_code = $field_collection_entity->field_color_code['und'][0]['rgb'];

      $pellet_html = '';
    }else{
      $pellet_html = '';
    }
  }else{
    $pellet_html = '';
  };

So everything works well when I load the page.

The problem occurs when I select something in form. As the form is ajaxified, actually when I click either on colors or sizes inputs, the form reload and my function is no more able to retrieve the node object with:

$node = menu_get_object();

or with:

if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  if ($nid) {
    $node = node_load($nid);
  }
}

After I clicked in a option, the color inputs get back to initial state:

So how to retrieve node object/id from a theme function when form is ajaxified??

You can check the form there:

http://www.zanonymes.krown.ch/collections/les-accroch%C3%A9s


texts: How do i get the node id using menu_hook

texts:
Hi I try to get the node id when user edit the node by the code below:

       function test_plugin_menu(){
            $item = array();
            $item['node/%/edit'] = array(
                'page callback' => 'test_plugin',
                'page arguments' => array(1),
                'access callback' => TRUE,
                'type' =>  MENU_LOCAL_TASK,
            );
            return $item;
        }

        function test_plugin($node_id){
              dpm($node_id);
         }

I get into a blank page when i edit a node. Please help, thank you !


texts: How do I inject CSS classes to a rendered field with a view style?

texts:
I maintain a module that provides several views styles. I have been unable to figure out how to get the fields where a users custom css entered in the views UI is then output with the view when I have to use style_plugin->getField (Drupal 8) or style_plugin->get_field (Drupal 7). It returns a "rendered" field, but that rendering does not include css additions added in the view settings. Secondarily, I'd like to inject some css classes for some of those fields (img styles added as a class to the img tag) but can't seem to figure that one out. I don't know of a function from views that would return a render array instead of the rendered output. I'm not sure what I'm missing.
Here is the Views UI:

This css class "hello-world-field" is not in the output code at all.


texts:
I have enabled the "locale" and "content translation" modules. Also I have two languages in my Drupal, Spanish and English, after that I have configured the detention method by URL.

I have finished my English page and I just need to translate the website to Spanish. When I set the language switcher to the website (the header or a columns) of my Structure I don't see anything. I can click on "translate" button of the blocks of my web, I see the "spanish" option, I click in "translate", but I get this message:

  This string uses the Full HTML text format. Strings with this format
  are not allowed for translation.

Ok, I change the format to Plain Text but I lost my HTML format, styles... I can't translate and I can't see the switcher to change to Spanish or English.

Drupal version 7.4.


texts: Changing confirmation page url dynamically after webforms submission

texts:
We have a single webform (Built using https://www.drupal.org/project/webform ) with a confirmation url of /thank-you

The same webform is displayed/used also if you originated from a translated page. So http://example.com/form/enquire is the same form for http://example.com/en-US/form/enquire

I need to be able to detect the en-US and instead forward onto http://example.com/en-US/thank-you

Is this possible through any hooks? This is a short term solution, we intend to translate the form ASAP but in the next day or so we need some solution which will do the above?

Regards
John


texts:
I am currently working on an old Drupal website. I had to upgrade the version from 7.19 to 7.61. After this update, everything is still working except for one thing. Before the update when you went to website.com/en/people the body had the class page-people. After the update, the body doesn't have this class anymore. I tried to find a setting to define a class or something but couldn't find anything.

The HTML code for the body tag is:

<body class="<?php print $classes; ?>" <?php print $attributes;?>>

What could be my problem?


texts: How do you edit the link count on /poll index page?

texts:
In Drupal 7 how do you increase the number of polls listed on domain.com/poll ?

The current limit appears to be 15 polls per page and then there is pagination at the bottom. I would much rather have all my polls listed without pagination.

Is there anyway to increase the number of polls listed?


texts: Limited access to 'Edit' Commerce Order & limit line items to only 1 type

texts:
With further to my earlier question regarding Services for Products, I have implemented as per the suggestions:

Following are the components:

Orders
Service Vendors - The individual or the Person who would provide service for an order request
Rating and Review - Fivestar rating and Editable text field added as fields for Commerce Order.

I am facing the following problems:

In order for user to rate and provide a review on the order I would have to expose the Order as editable for authenticated user which would let the user to edit all other order attributes. The fivestar rating module, allows rating the star without edit privilege but the review - (editable textfield) requires edit privileges on Order entity for the user. I have tried to use Field Permissions to limit edit access only to these 2 fields but with no success!
I am providing Voting and Review operations on Order because the Line items can be configured only in "Add to cart" form. Hence, I would have to limit a single order to contain only 1 line item type (which can contain multiple products / services of the same type). How can I achieve this?
As against the accepted answer here I am planning to create an order request when user needs it and then later update the price (also quantity in line item) after the service quotation actually takes place. Is there a way to edit the order to accommodate this functionality?

PS: I would need the rating module to be applied on Order (or Line item) because unlike regular E-Commerce this does not deal with product, it is service oriented. There is a possibility that different vendors can provide service for each order of same type, hence I will have to associate the rating and review system with either Order or Line Item and then pick up the average rating of a particular vendor who has serviced different orders in the past.

Also, if there are any better ways of achieving the same kindly let me know.