texts: How to get the context node in a custom block inside a views list?

texts:
I have a view which displays all pictures of the content type photo.
I've set some fields in this view for the display.

This is how iIrender the list of pictures:

views-view-fields--photo.html

{{ fields['field_date'].content }}

{{ fields['field_lieu'].content }}

{{ drupal_block('comment_block') }}

I use the Twig tweak module to render a custom block in this template. This block should load all comments for the picture. For that, I need to pass the nid of the node to my block.

Here's the code of the block:

CommentBlock.php

/**
 * Provides a 'CommentBlock' block.
 *
 * @Block(
 *  id = "comment_block",
 *  admin_label = @Translation("Comment block"),
 *  context = {
 *    "node" = @ContextDefinition("entity:node", label = @Translation("Node"))
 *  }
 * )
 */
class CommentBlock extends BlockBase implements ContainerFactoryPluginInterface {

  /**
   * Drupal\Core\Entity\EntityTypeManagerInterface definition.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a new CommentBlock object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param string $plugin_definition
   *   The plugin implementation definition.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('entity_type.manager')
    );
  }

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

    $build = [];

    $node = $this->getContextValue('node');
    kint($node->id());

    $build['#theme'] = 'comment_ajax';

    return $build;
  }

}

What I try is to get the context of the views row into my block. But I get this error:

Drupal\Component\Plugin\Exception\ContextException : Required contexts without a value: node

What am I doing wrong?

I can load my block from template_preprocess_views_view_fields() to link with the nid but I try to understand the context annotation.

Update

Here's a picture of the view, my custom block returns just a link name "Comment".

I now load the block programmatically instead of using drupal_block in the preprocess.

$block             = \Drupal\block\Entity\Block::load('commentblock');
$variables['test'] = \Drupal::entityTypeManager()
  ->getViewBuilder('block')
  ->view($block);

Then I print this block in views-view-fields.html.twig:

{{ fields['title'].content }}
{{ test }}

If I kint the context in my block I still get an error except if I set the annotation required = FALSE.

 *   context = {
 *     "node" = @ContextDefinition(
 *       "entity:node",
 *       label = @Translation("Current Node"),
 *       required = FALSE,
 *     )
 *   }

But the context is still empty.


texts: URL alias for File field on a Content Type

texts:
I have a File field on one of my content types and I'd like a URL alias for downloading that file regardless of how many times the actual uploaded file has been updated. Any advice?

I've been looking into the Attachment Links module as it accurately describes what I want to do, but it seems it isn't actively being maintained. Is there a community best practice for this type of functionality before I run with Attachment Links?


texts: AJAX callback on form item generated by AJAX

texts:
I'm trying to add AJAX callback to form element that was previously rendered by AJAX but with no luck. Code below.

A bit of description. There are three main methods here:

buildForm - base form
extraField - AJAX callback attached to ['month']
choosePerson - AJAX callback attached to: ['week_day']['hour']

In the buildForm method I create base form with AJAX callback on 'month' select element. In the AJAX callback you can find an extraField method. This method contains form element called 'hour' ($form['week_day']['hour']) and this element renders well. But this element also contains AJAX callback, which doesn't work, it does not generate 'person_container' element and the 'person' select.

Any idea how to ajaxify elements that previously were rendered by ajax?

class ReservationForm extends FormBase {

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

  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['month'] = array(
      '#type' => 'select',
      '#title' => $this->t('Select month'),
      '#options' => array($this->t('January'), $this->t('February'), $this->t('March')),
      '#ajax' => array(
        'callback' => array($this, 'extraField'),
        'event' => 'change',
        'wrapper' => 'week-day',
      ),
    );

    // Disable caching on this form.
    $form_state->setCached(FALSE);

    $form['week_day'] = [
      '#type' => 'container',
      '#attributes' => ['id' => 'week-day'],
    ];
  }

  public function extraField(array &$form, FormStateInterface $form_state) {
    $month = $form_state->getValue('month');

    $hour_options = array();

    if ($month == '0') {
      $hour_options[0] = $this->t('08:00');
      $hour_options[1] = $this->t('09:00');
      $hour_options[2] = $this->t('10:00');
    }

    if ($month == '1') {
      $hour_options[0] = $this->t('12:00');
      $hour_options[1] = $this->t('13:00');
      $hour_options[2] = $this->t('14:00');
    }

    if ($month == '2') {
      $hour_options[0] = $this->t('18:00');
      $hour_options[1] = $this->t('19:00');
      $hour_options[2] = $this->t('20:00');
    }

    $form['week_day']['hour'] = array(
      '#type' => 'select',
      '#title' => $this->t('Choose hours @month', array('@month' => $month)),
      '#options' => $hour_options,
      '#ajax' => array(
        // tried with that callback too: [ $this, 'choosePerson']
        'callback' => array($this, 'choosePerson'),
        'event' => 'change',
        'wrapper' => 'person',
      ),
    );

    $form['week_day']['person_container'] = array(
      '#type' => 'container',
      '#attributes' => ['id' => 'person-container'],
    );

    $form['week_day']['person_container']['person'] = array(
      '#type' => 'select',
      '#title' => $this->t('Choose person'),
      '#options' => ['John', 'Sarah', 'Peter'],
    );

    return $form['week_day'];
  }

  public function choosePerson(array &$form, FormStateInterface $form_state) {
    $form['week_day']['person_container']['person'] = array(
      '#type' => 'select',
      '#title' => $this->t('Choose person'),
      '#options' => ['John', 'Sarah', 'Peter'],
    );

   return $form['week_day']['person_container'];
  }
}


texts: How to disable payment cart pane when discount brings total to $0

texts:
I am using the uc_discounts_alt module on a Drupal 6 / Ubercart 2 site to provide specific dollar amount discounts for specific products. The discounts bring the product price down to zero, and conditional actions check for that discount code and, if found, make the shipping cost $0 as well.

I enabled the Ubercart Free Payments Module to allow these free orders to check out, but the cart states that the credit card info is missing when I to proceed to the order confirmation page. Apparently the Free Payments Module is not working as expected.

Is there any way I can hide or otherwise disable the payment panel when a certain discount is being applied... or any other options that may give me the functionality I need? Unfortunately, I am in a bit of a time crunch as we have a big promotion starting tomorrow, and this issue was masked by another payment method.

Thanks!


texts: Is it a good idea to add field directly to the node table via db_add_field and schema_alter? e.g. i want to add just number of views field to it. I know the recommended approach is field api but find it kind of overkill to create a new table just for a simple field like that. Let me know your views on that approach.. has anyone done it in a project?


texts:
I'm working in the creation of a custom profile.

When the installation is already finished, on the configuration module /admin/config/development/configuration appears the following warning

  The staged configuration cannot be imported, because it originates
  from a different site than this site. You can only synchronize
  configuration between cloned instances of this site.

All my configuration based on new changes is exported to

  web/profiles/DISTRIBUTION_NAME/config/install

using the following sh file

ddev exec drush cex
find ./web/profiles/DISTRIBUTION_NAME/config/install/ -type f -exec sed -i -e '/^uuid: /d' {} \;
find ./web/profiles/DISTRIBUTION_NAME/config/install/ -type f  -exec sed -i -e '/_core:/,+1d' {} \;

rm -f ./web/profiles/DISTRIBUTION_NAME/config/install/core.extension.yml ./web/profiles/DISTRIBUTION_NAME/config/install/update.settings.yml ./web/profiles/DISTRIBUTION_NAME/config/install/file.settings.yml

so, what i'm doing wrong or what else is missing?


texts: How do I remove the "My account" and "Logout" links?

texts: I am trying to sub-theme the Bootstrap theme. How do I  remove the My account and Logout links from the navigation bar?


texts:
My site was copied from production to test server. It works on Drupal 7 + Nginx + PostgreSQL. On production, user login works fine, but on test server I receive a 403 error on users/admin (or user/1) where I'm redirected after login.

What I've already checked/done:

Database tables cache_* and sessions are empty.
User admin in the database has: uid = 1, status = 1, roles = 2 (authorized), 3 (administrator), 10 (site admin)
Try to open in IE, Chrome, Firefox. All history (cache and cookies) were deleted.
In file sites/default/settings.php there are the variables $base_url = "http://mytest.domain.com", and $cookie_domain = "mytest.domain.com"
nginx.conf contains such rules for 403 error:

location ~ \..*/.*\.php$ {
    return 403;
}

location ~ ^/sites/.*/private/ {
  return 403;
}

location ~ (^|/)\. {
  return 403;
}

Also all fastcgi_cache options are commented out.
Permissions on server: sites/default - 775 (folders), 644 (files); sites/default/files - 775 (folders), 644 (files).
Also I see that login field in the users table is updated when I login, but  the watchdog table and sessions table don't contain rows about the session being open.
php.ini: opcache.enable = 0

How can I fix the 403 error?


texts: Is there any way to install all modules a in specific folder with a custom module? I need to install my custom module and have all modules in a specific folder installed automatically.


texts: The Expanding & Folding of the information related to a checkbox isn't working in drupal 7.34

texts:
I am using Drupal-7.34, and after enabling the following modules:

Admin-Menu.
Ctools.
IMCE.
IMCE Wysiwyg Bridge.
insert.
jquery-Update.
Libraries.
Link.
Pathauto.
Token.
Views.
Wysiwyg.
Webform.

I got a problem about the "Expanding & Folding of the information related to a check box"

For Example:
After enabling all the modules listed above, when I enter into the configuration of the "View UI" Module and try to "Add a view"; And after checking/unchecking the check boxes of "Description", "Create a Page View" or "Create a Block View", the information related to these check boxes is not expanded or folded. (Just the mark of checking/unchecking will appear/disappear and nothing else happen.

Note that before enabling the following modules listed above, this problem didn't appear and everything was great...

any help will be appreciated, Thank you in advance.

IN THE IMAGE BELOW, YOU CAN NOTICE HOT THE DESCRIPTION CHECK BOX IS CHECKED BUT THE TEXT BOX TO WRITE A DESCRIPTION ISN'T APPEAR AND ALSO HOW THE CREATE A PAGE CHECK BOX IS UNCHECKED BUT ALL THE INFORMATION RELATED TO IT STILL APPEARED AND DIDN'T DISAPPEAR OR FOLD...


texts: How to get friendly URLs to work in a headless implementation?

texts:
I'm planning to implement a headless Drupal 8 with a SPA using React. I've been looking through articles on this subject but have found that most of them are just describing how I can pull data off from Drupal's API services.

In a regular Drupal site, when I create a blog post, the system will create a friendly URL like "www.mydomain.com/articles/my-post-title". When I'm creating the frontend through a view library such as React, that URL is likely not going to work because that will route the user away from my SPA site but to the Drupal page instead.

I understand that the routing part in React is usually handled by a library such as react-router. However, I don't understand how should the friendly links of pages and blog posts created by Drupal be mapped over in react-router.

If I want the friendly links Drupal create to work with my React frontend, how should I approach this in my headless implementation?


texts:
I'm trying to override the HTML output of a single menu_link only when the user is anonymous. The following code is based on this by deskulu developers.

function MYTHEME_menu_tree__secondary(&$variables) {
  $variables['tree'] = i18n_menu_translated_tree('user-menu');
  if (user_is_anonymous()) {
    $children = element_children($variables['tree']);
    foreach($children as $index => $id) {
      $classes = ['btn', 'navbar-btn'];
      if ($index == count($children) - 1) {
        $classes[] = 'btn-warning';
        $variables['tree'][$id]['#localized_options']['attributes']['class'] = $classes;
        $element = $variables['tree'][$id];
        $output = l($element['#title'], $element['#href'], $element['#localized_options']);
        return '

' . $output . "

\n";
      }
    }
  }
  return render($variables['tree']);
}

The result, however, is a correct rewrite of the single link but the disappearance of the others.

Also, I'm unable to print with dpm() the $variables['tree'] object so it's a bit difficult to debug.


texts:
I'm trying to alter custom blocks contextual menu.
In particular I need to remove "Configure block" and "Delete".
Is there any way to achieve this?


texts:
I have installed Drupal 8.6.3 minimum profile and found out that there's no Administrator role under permissions section. Is this normal or am I missing something?

We have few people that needs to be using Admin roles, so without a Administrator role, I can't assign them to such a role.


texts: Is there a way to add the comment section to the node edit page?

texts: I am developing a site which will be used for information gathering.  All views are designed to send users to node edit pages (instead of node view pages) so that they can see and update information at the same time.  I would like to use the comment system, but I have not been able to figure out (yet) how to enable the comment section on a node edit page.  This section show up on the node view. I would like to know if there is a way to make it show up on the node edit page as well.


texts: Website saves separate sessions for "www.domain.com" and "domain.com"

texts:
I open a browser, type "www(dot)mydomain(dot)com"
I login as an admin
I open a new tab, type "mydomain(dot)com". I'm logged out, and i can login as a different user..

It's weird. I can't find anything helpful on google (or i don't know the right search keywords). Does anyone here have any idea?

Thanks :)


texts: Entity Wrapper : how to delete multiple values field?

texts:
I have a multiple values field on the user entity. This field is field_data.

There are several values in this field. I want to delete all of them.

I tried the following code:

for ($i = 0; $i < count($user->field_data->value()); $i++) {
    $user->field_data[$i]->delete();
}

But I get errors about ->delete() not being a method on this object. I also tried with ->clear() to no avail.

I've been looking for examples on Google for how to do this, but my Google-fu is not so strong today.


texts: How to update fields of a new node created using Rules?

texts:
I have created a content type called Tasks that helps me track things I need to do on my site. I am trying to create a rule that when some content is published, a new task item is created reminding me to do some follow up work.

I created a rule that when the new content is published, a new task item is created.  I did this by adding Create a new entity to the Actions section.  I can give the item a title and set the author, but I can't figure out how to update the other fields in the new Tasks item.

Can this be done using rules or do I have to write PHP code to accomplish this?


texts: Renewal fails but license remains active, and a new recurring is made

texts:
I am using Drupal Commerce, Commerce License, and Commerce License Billing.

Something unexpected is happening.

When an order tries to renew but fails (due to a card issue): the
order that had been in the system with a status='recurring_open' is
updated to have a status = 'cardonfile_payment_error_hard_decline'.
The license is still active
A new order is made. It has the status 'recurring_open'. It has an active billing cycle.

My Thoughts

Concerning #1 - This seems expected, though I expected the declined status to be on a new order and not the previously existing order. I am not sure if that is correct.

Concerning #2 - It seems to me a license should be canceled in this situation but I am not sure how this is intended to work. I see in the commerce_license.module a hook_commerce_order_update implementation but it only cancels licenses when an order status = 'cancelled' and not when status = 'cardonfile_payment_error_hard_decline'. What is intended?

Concerning #3 -  I think this could be a symptom on #2. Maybe if the license had been cancelled a new recurring order would not be made? BUT because of #3 this order will attempt to renew again at the end of the new billing cycle, starting this issue all over again.

I know this is a specific issue. Any help is appreciated.

It would be nice to know what is suppose to happen when a renewal is declined.

** Update **
I have found that in commerce_license_billing.module on line 340 is where the additional recurring order is being created. Reviewing this code, I see nothing that would stop this regardless if the renewal failed.

To test, I added the patch below (above Line 340 on Line 322). This code completes the renewal process immediately if the order did not complete. This prevents the additional recurring order from being made. Additionally it prevents the new billing cycle from being made and prevents the license from being extended. All good things IMO.

The only thing it doesn't do is revoke the license. That is okay for my use case. With a couple of more lines of code, the licenses could be revoked too.

My main question is still:
Am I creating new functionality for my use case because Commerce License Billing does not deal with card declines?
OR
Is there something wrong with how my install is behaving and this patch should not be needed?

*** commerce_license_billing.module 2016-01-12 16:26:46.000000000 -0800
--- commerce_license_billing_patched.module 2016-01-12 16:25:28.000000000 -0800
***************
*** 311,316 ****
--- 311,325 ----
    }
    $order = $billing_cycle->getOrder();

+   //If the order did not renew successfully do not create a new recurring order.
+   if ($order->status!='completed') {
+     // The billing cycle has been deleted in the meantime. Nothing more to do.
+     return array(
+       'status' => ADVANCEDQUEUE_STATUS_FAILURE,
+       'result' => 'Order had not renewed successfully.',
+     );
+   }
+
    $licenses = commerce_license_billing_get_recurring_order_licenses($order);
    foreach ($licenses as $license) {
      // Apply scheduled changes.

Just providing my updates to help the conversation. :)


texts: What is the equivalent of Drupal.settings.basePath?

texts: I'm trying to get the site URL in JavaScript. In Drupal 7, this is stored in Drupal.settings.basePath. What's the Drupal 8 equivalent?


texts: Durpal 8 on install new module, insert data in new created table

texts:
I created a new table into the new schema and I want to insert default data into it.
How can I do this in the module.install file ?


texts:
I opened my form in a jQuery modal dialog using the Simple Dialog module. I am unable to do any sort of validations on it.
Is it a limitation of the module? Would it validate if I use any other method of creating a  modal dialog form, such as using a CTools modal dialog, or using the Drupal overlay?


texts: How to fix 'Cannot redeclare ctools_content_process' problem after sql-sync?

texts:
I'm encountering a really weird bug with Drupal. I'm running Debian's Drupal in a multisite configuration on the same host with both the dev and live websites. I know it's not ideal but this is a constraint I cannot avoid for a variety of reasons.

So I have my sites (e.g. dev.example.com and www.example.com) and I sync them with drush sql-sync. Right after doing so, I cannot access the synced website anymore and Apache throws the following errors:

PHP Fatal error:  Cannot redeclare ctools_content_process()
(previously declared in /etc/drupal/7/sites/www.example.com/modules/ctools/includes/content.inc:18)
in /etc/drupal/7/sites/dev.example.com/modules/ctools/includes/content.inc on line 84

To make my website work again, I have to manually do a find-replace in MySQL to change any instance of dev.example.com to www.example.com in tables field_data_body and field_revision_body.

I reckon the problem is linked to CTools (and hence to views), but I have no idea why. Have any of you ever encountered such a problem?


texts: Best method of importing a large csv file with fields containing multiple values and sub-fields like paragraphs and field collections

texts:
I exported an old Drupal 7 site using the Views data export module. Now I need to import this back into my new Drupal 7 site, but some of my fields contain multiple values and fields that have sub fields in them (field collections).

What would be the best method of importing this?
Do I have to write my own custom module using the migrate module or use feeds?
And how do I deal with importing data into a field collection or a field with multiple values?


texts: How do I alter a bundle and programmatically add a form with a custom form mode?

texts:
I have created a custom entity type called custom_enitity and new bundle scores, using UI. Also got custom form display called score to add score via custom route. I keep getting the following error message.

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity
type custom_entity in
Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (line 108 of
core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php)

The content of my_module.routing.yml is the following.
custom_entity.score:
  path: '/entry/{entry_id}/score'
  defaults:
    _entity_form: custom_entity.score
  requirements:
    _role: 'administrator+judge'
  options:
    parameters:
      entry:
        type: entity:entry

The folder hierarchy is the following: custom_entity/src/Form/CustomEntityScoreForm.php. The class in the file is CustomEntityScoreForm which extends ContentEntityForm.
How do I add a bundle (scores) to the routing file? What am I missing?


texts: Custom story-node-form.tpl.php not working

texts:
I have created a custom node add form for story content type. Though this appears as expected but do not working. Problem is when i click on the Submit button then this form just redirect me again in node/add/story path instead creating the story page!Here is what i have did (Here i have used bartik theme):

  template.php

    function bartik_theme() {
    return array(
    'story_node_form' => array(
    'arguments' => array('form' => NULL),
    'template' => 'story-node-form',
    'render element' => 'form',
    ),
    );

  story-node-form.tpl.php

<?php print drupal_render($form['title']); ?>

<?php print drupal_render($form['body']); ?>

<?php print drupal_render($form['actions']); ?>

<?php print drupal_render($form['additional_settings']); ?>

<?php print drupal_render($form['actions']); ?>

Now if i click on the Submit button then this story creating form just redirect me again in node/add/story path instead creating the story page! What i am missing here? Thanks


texts: How can I make my site only accessible to logged-in users?

texts: I want to make my site accessible to logged-in users. How can I achieve this?


texts: How can I create multiple dashboards with Open Atrium?

texts: By default each Open Atrium group has its own dashboard. What I'd like to do is to create multiple dashboards (pages?) for each group. My goal is to create separated dashboards with different contents, just like website's pages. Any idea on how to do this with Open Atrium?


texts:
while googling and reading documentation and API, I've seen multiple solutions for "combining" 2 forms into one, and thus creating a multistep form.

What I want though, not even sure if it's doable, is to "split" my (huge) user registration form into 2 steps, where the value of one field (the only one in step 1) would determine which fields should show up in step 2.

I wouldn't like to drop the entire registration form and re-create it in code or in another way and somehow re-implement the whole user registration process. Is that possible?

EDIT: to avoid misunderstandings, what I need to do is an "actual" multistep form, with submitions between steps, and not some front-end handling. That is, I want the whole thing to be javascript independant.

EDIT2: to clarify even further, the task is figure out how/if possible to pretty much split any "edit" form to 2 parts. The current question does ask about the user/edit and/or user/register form specifically, but in order to come up with a more generalized solution, one might also want to split a node/edit form in to 2 parts. That's what I am really asking about. Splitting an entity/edit form in to 2 (or more) steps.


texts:
how can i use ajax in pager

$pager = [
  '#type' => 'pager',
];

return [
  '#theme'      => 'news_filter',
  '#articles'   => $articles,
  '#categories' => $categories,
  '#count_res'  => count($nids),
  '#pager'      => $pager,
  '#attached'   => [
    'library' => [
      'news_filter/news_filter.assets',
    ],
  ],
];

it's very urgent thank you for answering me


texts: I've Featured some Paragraph Bundles, but they are not showing up on the remote site

texts:
I've Featured some Paragraph bundles and have included them as part of a module.

I've merged these files to my remote site and want to 'activate' the Feature to have the Paragraph Bundles appear. I see my Feature there on the remote site and can 'Revert' it to update it but nothing happens - I don't get my new Paragraph Bundles in the existing list, nor do I get any error messages.

Would anyone know what's going on?

What I've pushed up is:

module_name.features.field_instance.inc

function module_name_field_default_field_instances() {
  $field_instances = array();

  // Exported field_instance:
  // 'paragraphs_item-module_name-field_grid_number_columns'.
  $field_instances['paragraphs_item-module_name-field_grid_number_columns'] = array( etc...

And

module_name.features.inc

function
module_name_paragraphs_info() {
  $items = array( etc...

And in my module's .info file I have included, eg:

features[features_api][] = api:2
features[field_instance][] = paragraphs_item-module_name-field_grid_number_columns
features[field_instance][] = paragraphs_item-module_name-field_paragraphs
features[field_instance][] = paragraphs_item-module_name_item-field_image
features[field_instance][] = paragraphs_item-module_name_item-field_text
features[field_instance][] = paragraphs_item-module_name_item-field_title
features[paragraphs][] = module_name
features[paragraphs][] = module_name_item

Is there anything I'm missing?


texts: How to embed Twitter  and E-mail links inside a webform?

texts:
I want to embed inside a webform a Twitter and E-mail button,so
as the user to post/share the page to his Twitter account or e-mail it.
How to do that?
Thanks


texts: imagecache external (contrib module) not showing all files

texts:
I am using the imagecache_external module to set the size of images from external urls. For some reason, some images are displayed and some are not. The all have the tag structure of

<image typeof="foaf:Image" src="http://[path]/sites/default/files/styles/thumbnail/public/imagecache/externals/50fda6daf05096f6b200b2a054a38084?itok=cHTsorEg"

but some are just blank images. I know that the external image is valid because when I display it in a normal image tag, it works fine.


texts: Is it possible to automatically create a .install file for a module?

texts:
I have a content type that I want to install as part of a module or install profile. Is there anyway to automatically create all the field_create_field and field_create_instances code that would go in hook_install or do I have to do all that manually?

Is there any other way to capture the settings of a content type so I can migrate it and include it in an install profile?


texts: granularity of views filter on date field

texts:
I have a content type which has a date field. That date field collects:

Year
Month
Day
Hour
Minute

I've created a view with a filter on that field. The granularity I can filter with only goes down to day. Even if I use operator: is greater than and Relative date: now, the contents of the view only change once a day. That means that hour and minute are not taken into consideration.

Any ideas on how to solve this?


texts:
I am new to Drupal. using drupal 7

I would like to have dynamic fields in content type.
basically i would like to allow users to add a content and in that content, fields should generate dynamically.

for example if user has select  CAR the next field (MODEL) should be generated dynamically according to first one having all the model for that particular car and so on.

i know about "hierarchical select" but its not good for me. conditional fields are still under development.

search a lot but did not come out with any solution. please help.

thanks


texts:
I wanto to display Prices with no decimal Places, in shopping cart footer (commerce order: order total ), but in the shopping cart view i found nothing to which does this.
what shoud i do?


texts:
I built a custom field type using the Field API. In hook_field_validate I have some logic to validate some very custom stuff, but when I tried to add a "This field is required" validation, I realized this hook runs on the from that you fill when you're adding a field to an entity. Then, I implemented hook_field_is_empty, which I know runs when the entity saves. Problem is, even if the hook runs and the field is empty, no validation occurs (i.e. the user doesn't get the "this is required" message, and the form submits).

So, what's the right way to do a "this field is required" validation?


texts:
How can I remove the slash at the end of my breadcrumbs?

Markup:

  Главная
    /
  Управление
    /
  Конструкция сайта

Screenshot:


texts: Create a menu programmatically in Drupal 7

texts:
A newbie question guys.

Any thoughts how can I create a menu programmatically? Says I have 3 different menus I want to create. The first menu will be placed in the top left of the header. The second menu will be placed below the first menu. The third menu will be the main navigation.

Could these the menus be under the same group? Would it be a problem in styling?

Thanks


texts: On submission function is not being called in custom module

texts:
I have written a custom module for form submission the first time but submit button is not working.

Here is the code:

function my_form($form, &$form_state) {

$node = array();
$pl_name=array();
$pl_name=getplaylist_to_edit(arg(1));

$node['text'] = array(
'#type' => 'textfield',
'#id'=>'edit-playlist-name',
'#value' => $pl_name[1],
);

$node['submit'] = array(
'#type' => 'submit',
'#value' => 'Update',
'#submit' => array('test'),
);

return $node;
}

function test()
{
echo '<script>alert("You have submitted the form.");</script>';
}


texts: Can you use basic FAPI without drupal_build_form?

texts:
is there any way to use simple FAPI (such as dropdown selection box) without processing it with drupal_build_form?

The thing is, I have a page with a custom table view and a drop-down selection widget that limits the view. The only thing that I need the selection widget to do is to redirect me to '...the_page/id_of_selected_item' (or 'the_page?gid=id_of_selected_item). And it seems to me that using full form support for such a simple task (which a basic redirect surely is) is a bit of a overkill...

I know I can render the selection widget easily without the form support but then neither AJAX nor simple submit button (that would send the data trough PHP POST) works.

BTW: Is there any way to do simple PHP forms in Drupal?


texts: How to break existing node(having data in database) form into multiple steps?

texts:
I know this type of question is asked earlier also. But with me, situation is somewhat different. I have a node form with many elements. Earlier it was in a single page to create/edit the same. And like that only, we have created the node too. So, data for the node is also there in the database.

Now, I have to split the node into multiple steps(say two steps). I checked and found msnf(drupal community module) is the solution. But that works while creation of the content type only. It will not appear for the existing fields.
So, how can I achieve that?


texts: How to fix "This display does not have a source for contextual filters"

texts:
I've set up a view to produce a block of content nodes based on taxonomy. I have the filter criteria to include Has Taxonomy term (not empty). Then under advanced I added a contextual filter 'Has Taxonomy Term ID'.

But when I set it up (or edit it) there is a message:

  This display does not have a source for contextual filters, so no contextual filter value will be available unless you select 'Provide default'.

And that type (has taxonomy term ID) comes under 'provide default value'.

I don't mind all of this, but this particular example has 3 taxonomy terms that are quite similar:

Virtual meetings
Virtual classroom
Virtual seminar rooms

These block views are pulled onto a panel page, again based on taxonomy. But on each of the 3 pages there are 3 listings, instead of one!

Can anyone think of what I might be doing wrong here?

I am using Drupal 7 and Views 7.x-3.3.


texts:
How can I let users create their own playlists of a particular content type?

I have used the Flag module but it allows only a single list. I want the user to be able to create multiple lists.

I have tried the Flag Lists module but cannot seem to get it working.

Any help would be appreciated.


texts: Making content and functions maintainable in the long run

texts:
I've been playing around with drupal for a couple of weeks now and one subsisting doubt remains in my mind: what is the correct, 'Drupal' way to add your custom content? For basic text and links, a WYSIWYG editor that I've downloaded seems to be only about adequate (as it is a bit sluggish).

Because I want to extend website functionalities, like user input, I've been using .tpl.php files to modify content on specific nodes/blocks. For example, in some arbitrary file along the lines ofmytheme/templates/page--block--5.tpl.php there is code that prints to that page, like so

<?php print render($page['content']); ?>
<div>
<?php my code here... ?>
</div>

But this isn't great for the future of this project as it's essentially hard-coding. Given that I will probably one day have several people uploading content or pass it on to a different admin, what's the right way to add more advanced features for maintainability?


texts: mysql server gone away while loading drupal site in the shared environment

texts:
i am getting serious error in the production server when i deploy for the first time. Please find the below PDO exception which i am getting.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in variable_set() (line 977 of /var/www/htdocs/includes/bootstrap.inc).

I am not allowed to increase allowed packet size and wait timeout in the mysql end, because multiple sites are running on the DB and such a way we are not allowed to change php.ini also.

Is there any other solution for this problem I am facing this issue with the client for past one week not it has been very critical for me.

Could anyone please help me out to get ride of this issue? Thanke in advance.


texts: Acquia Dev Desktop Redirects to Live Site

texts:
I have a weird thing happening - I took a copy of my live site, and a dump of my database, and imported it into the Acquia Dev Desktop application to run a dev site locally. This site has worked in this manner in the past. However, when I do this now, visiting the local path (ex. localhost:8082) redirects to my live site out on the web. I believe it's something in the database, as running the code with a standard Acquia database works, but as soon as I swap in the database from my live site the redirect occurs.

Any ideas what could be causing this?? I don't have anything in rules or actions to redirect anything, and I don't know what else it would be.


texts: Update values using AJAX in field widget form

texts:
Similar questions:

Ajax wrapper replacement on a field widget form

how to create an AJAX field widget

Problem:

Get FIELD_NAME and DELTA in AJAX callback function? (See below)

What is done:

Change value of a textfield  in a widget form (see here) upon value change (jQuery event .change()) of another textfield in widget form.

Code Sample:

in hook_widget_form:

// Changes of this field fire the AJAX event
$element['value'] = ...
$element['value']['#ajax'] = array(
                    'callback' => 'some_ajax_callback',
                    'wrapper' => 'location-div',
                    'method' => 'replace',
                    'effect' => 'fade'
            );
// This field is updated upon AJAX call
$element['location'] = ...
// Here is where the actual change occurs
if(!empty($form_state['values'][$field['field_name']]['und'][$delta]['value'])) {
            $element['location']['#value'] = ...;
        }

in some_ajax_callback:

function some_ajax_callback ($form, $form_state) {
  // Where do I get FIELD_NAME, and DELTA?
  return $field[FIELD_NAME]['und'][DELTA]['location'];
}

What happens?

As it is mentioned here #default_value is not populated using AJAX so according to this #value should be used instead.

The problem is how to get FIELD_NAME and DELTA in AJAX callback function? (See above)

UPDATE (NOT WORKING!)

I managed to figure out a workaround to make this work as following:

Item to be updated receives an ID composed of field_name and delta (e.g. location-div-myfield-0 (this is necessary if multiple instances of the same field are on the same page)
Save field name (here myfield) and delta (here 0) in $field_state (in hook_field_widget_form)
Read the saved values from $field_state in ajax callback (here some_ajax_callback) and return the desired form element.

This however works if there is only one instance of the field in the form, otherwise the values in $form_state are always those of last instance.

Possible solution

Using the triggering_element of $form_state in some_ajax_callback all necessary info can be derived:

function some_ajax_callback ($form, $form_state)
{
    // This contains info about triggering element
    // Index 0 = field name, 1 = language, 2 = delta, 3 = element name
    $element = $form_state['triggering_element']['#parents'];
    $delta = $element[2];
    $field_name = $element[0];
    ...
}


texts: How do I set "has_title = false" for an existing node?

texts: I understand how to set the node attribute 'has title' via the hook_node_info() when creating a node programmatically. However, I struggle to edit this attribute for a node that has been created with the built in Drupal node designer. Can anyone please give me advice on how to modify this attribute, for example on a node such as "article"? Which hook do I use and when? Could I even modify this attribute directly in the database and therefore get this changed permanently?


texts: Flag, flag link, and flagging: create an advanced relationship

texts:
On my site I have two content types:

event – with node flag “Attend” and Entity Reference field
band

And flags:

“Attend” – node flag - with Entity Reference field
“Accept” – flagging flag – connected to “Attend” flag

Each user can create unlimited number of Bands (he is manager of each Band) and create unlimited number of Events.
On Event creation form I add Entity Reference field with list of user Bands. This way band which he choose will become an Event organizer.
And now: other Users can click on flag “Attend” in Event node. On next step they need to choose witch of their bands will participate in this event (entity reference field)

Quick example:
“User 1” create “Band A”, “Band B” and “Band C”
“User 2” – “Band D”
Events and attendance:
“Band D” is the  organizer of the “Event A”. “Band A”, “Band B”, “Band C” want to attend.
“Band  A” create “Event B”. Attend: “Band D”,
“Band D” create “Event C”. Attend: “Band B”, “Band C”

In views I create a private page with table of events of each user. I add all necessary relationships to show Events of each user with list of bands which use “Attend”.  Please imagine it as a table:

Band A – 1 event:

Event B

Band D – “Accept flag”(flag link)

Band D – 2 events:

Event A:

Band A - “Accept flag”
Band B - “Accept flag”
Band C - “Accept flag”

Event C:

Band B - “Accept flag”
Band C - “Accept flag”

User (author) creator of the event using flagging flag can decide which band he Accept for event.

Problem:
When Band D click “Accept” for Band B under Event A the status also change in Event C.
Do you think it is possible to separate this?
I hope I have described all process clear enough.
Thank you!


texts: Join User Profile fields with custom View type

texts:
In Drupal 6, I've created a custom View type that allows me to query data in my custom table. One of my fields, uid, relates to drupal users.  In the Views I create for my custom type, I can display user info for each record by using a simple join in hook_views_data():

$data['users']['table']['join']['awesome_user_submissions'] = array(
  'left_field' => 'uid',
  'field' => 'uid',
);

Now, I'd also like to display Profile fields in my view (eg: profile_first_name). Unfortunately, it doesn't appear that this will be a simple table join. How can I do this?

Solution: (thanks @googletorp)

Don't use the join I originally used (above).  Instead replace it with the following in hook_views_data(), then I can use fields from the 'users' table, as well as from the 'profile_' tables.

$data['awesome_user_submissions']['uid'] = array(
    'title' => t('User'),
    'help' => t('Relate an awesome submission to the user who entered it.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      'base field' => 'uid',
      'label' => t('user'),
    ),
  );


texts: Creating a page to display several content types

texts:
I have a website to build that requires several quite long pages, each containing several sections with quite different content in each.

A content type for each page isn't going to work as some sections would need to contain several entries, to be displayed as a slider.

So, I think, I need to create each section as a different content type and my problem becomes displaying several of these on the same page?

How can I display several content types on the same page?

Or maybe I could create a category for each page and add the types to those?


texts: Domain Access module: Adding nodes programmatically to subdomains

texts:
I am using Drupal 6 and Domain Access-6.x-2.11.
I need to programmatically add nodes to subdomains defined in Domain Access configuration. I've been looking the source code of domain.module but can't figure out how to use the api of the module to add a node to certain subdomains.

Any suggestions?


texts:
I created a TWIG template for the "Teaser" view of the user account.

I want to display a logo and change its color according to the status of the user :

When the user is logged in  Online
When the user is logged in and the last access is less than 30 minutes  Absent
When the user is offline  Offline

How to display the status of the user ?

I think it must be possible to create conditions in TWIG


texts: empty page creation and filling it with blocks

texts:
I need to create a custom page which content region can be nicely presented as a set of views blocks. I don't know whether it's possible. So the question is:

Is there any possible way to create an empty page with certain url , e.g. "mysite.org/news", and fill its 'content' variable  with some blocks without writing a module and declaring the page with php and hooks? Just from the admin interface.


texts: How to implement content access for groups of users?

texts:
I am building a Drupal 7 site, and I am quite new to Drupal. I want to assign each authenticated to a group which I define myself, for instance "friends", "family", "coworkers", "mortal enemies" and so on. I want the content access permissions to depend on this group, so that my friends and family are allowed to see all my images with cute kittens, whereas my mortal enemies should only have access to my archive of taunts and elaborate verbal abuse.

Any suggestions?


texts: What format should date (ISO date) be when using Migrate Module?

texts:
I have a large amount of date rows that I'm migrating over from a legacy application to Drupal 7. My destination field is Date (ISO Format) with year, month and day selected. What format should this be in when I'm migrating it across?

I can see that it's stored as 2010-01-01T00:00:00 in the database so I'm using prepareRow() to manipulate the data like:

<?php
public function prepareRow($row) {
  // DOB not migrated correctly - old = serialised array
  //    watchdog('temp', print_r($row, TRUE));
  if ($row->profile_dob) {
    $dobarray = unserialize($row->profile_dob);
    watchdog('temp', print_r($dobarray, true));
    $row->profile_dob = date('Y-m-d\T00:00:00', mktime(0, 0, 0, $dobarray['month'], $dobarray['day'], $dobarray['year']));
    watchdog('temp', print_r($row->profile_dob, true));
  }
}
?>

This returns the expected format for the date however the data is not populated in the database. I've tried using 'c' as the date format as well with no luck.


texts: Easy Question: Filter a View By Tax Term Menu Style Not Exposed Filters

texts:
I dont know if im having a blonde moment or not. Im sure i learnt how to do this about 9 years ago way back on drupal 4 but ....well i seem stuck.

I have a page view. /match-previews. Its using the same vocab as im using across my website. I was wanting to create a menu link in the sidebar to each football league. I have it set up with an exposed filter but really i would prefer to have it as a menu system.

Ive tried cloning the page and adding a /match-previews/% page but thats where i seem to be stuck. Maybe just making up some normal pages and making a block view for each and taking the term from the page could be the way to go.

Can anyone put me out my misery as ive been at it too long for now tonight.

Thanks

my page is here if it helps
http://ukfootballbet.com/match-previews/


texts: How do I use a drush alias to connect to a docker container?

texts:
I have a droplet setup on Digital Ocean with two docker containers, one for Drupal (using modified alpine-drupal8 image) and another running a simple mysql server.

I am able to run drush commands on this container by connecting over ssh into the droplet and running docker exec -it <container_name> /bin/sh
I have also set up an ssh server (listening on port 2222 on the same ip address) on the container itself with a little port forwarding:

ssh root@<droplet_ip> -p 2222 # Connects from remote dev machine to drupal container using ssh key

My sites/default/drush/aliases.drushrc.php file:

<?php

$aliases['container'] = array(
  'root' => '/usr/share/nginx/html',
  'uri' => 'http://default',
  'path-aliases' =>
  array (
    '%drush' => '/usr/local/bin/drush',
    '%site' => 'sites/default/',
    '%files' =>'sites/default/files/',
    '%modules' =>'modules/'
  ),

  'remote-host' => '<droplet_ip>',
  'remote-user' => 'root',
  'ssh-options' => '-p 2222',
);

?>

Starting an ssh session with the drush alias is working:

$ drush @container ssh
186203cca:/usr/share/nginx/html# ### Connected to ssh session in droplet
186203cca:/usr/share/nginx/html# which drush
/usr/local/bin/drush
186203cca:/usr/share/nginx/html# drush status
 Drupal version                  :  8.1.8
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  <removed>
 Database port                   :  <removed>
 Database username               :  <removed>
 Database name                   :  <removed>
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  <removed>
 Administration theme            :  seven
 PHP configuration               :  /etc/php7/php.ini
 PHP OS                          :  Linux
 Drush script                    :  /usr/local/bin/drush
 Drush version                   :  8.1.3
 Drush temp directory            :  /tmp
 Drush configuration             :
 Drush alias files               :
 Install profile                 :  standard
 Drupal root                     :  /usr/share/nginx/html
 Drupal Settings File            :  sites/default/settings.php
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp
 Sync config path                :  sites/default/files/config_vxs7qxuAqrfCtOXdbGYLvLAIKl1_bN4J_BvmrEn1l1EUIsn4Du_CKck2QWYSmkNDgUVfdZUZVQ/sync

However, I still can't seem to run actual drush commands:

$ drush @container status
env: can't execute 'drush': No such file or directory

My theory is that the port forwarding is not working correctly, and drush is trying to run on the container, not the droplet

This may be related to my issue: Why does drush say "command not found" when I try to execute remote commands?

Update:

A little more testing and I found out I can use drupal console without issues, so it seems this is isolated to drush only:

$ drupal @container cr all

 Rebuilding cache(s), wait a moment please.

 [OK] Done clearing cache(s).


texts:
I am having trouble using batch. The problem is that on the client website, there is an error in the jquery file in the jquery_update module and I am not allowed to change this because I am just building a custom module for them. So, JS won't run and batch is locked.
I want to force batch to use do_nojs such that the page is reloaded using http meta. Is there any solution I can use for that?


texts: Single Drupal installation with multiple websites

texts:
Currently, I have two static HTML folders: 1 for English webiste , and 2 for Thai website. They have the same look and feel but different menu and content. To be precise, the menu and content
in the www.example.org/th are not translated versions of the English site, they are totally different.

URL for the English website is http://www.example.org and http://www.example.org/th for the Thai website.
I want to switch to Drupal 7. So, here's what I have in the to-do list:

Theme:

Create a parent theme (www.exaple.org)
Create a sub theme for (www.example.org/th)

Panel:

I will create a Panel with "th" path for www.example.org/th and then make it use the subtheme (not sure if this is the correct approach)
Create a different menu and will put it in the Panel (not sure if this will work out that way)

Should I create Panel and different menu or Should I go with single Drupal installation that can be used to power multiple websites to get the same result as I currently have with static HTML sites?
If so, please show me some tips or sample to get started.

Thank you.


texts: Is there a way for Forena to restrict the debugging messages to selected roles?

texts:
The Forena data source has the option of displaying the generated queries on the screen via the Debug option.

The problem here is that the messages are displayed for all users or reports while this debug option is enabled, which is undesirable as it means a developer cannot be designing new queries during normal working hours.

Is there a way to restrict the debug messages to select roles only?


texts: Is there a drupal.org API for retrieving the list of available modules?

texts: Is there a drupal.org API for retrieving the list of available modules, a description of them and available versions?


texts: I forgot the password to the admin account

texts:
A few month ago I have make a web-page using drupal. I had some break due to phd thesis. Now I want to push the subject foreward and finish the page, but I have forgot the admin's password. Is there a possibility to get it, or change it?

I tried the method described on http://drupal.org/node/1023428, but I got the following errors:

  PHP Warning:
  include_once(/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/password.inc):
  failed to open stream: No such file or directory in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 83   Warning:
  include_once(/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/password.inc):
  failed to open stream: No such file or directory in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 83   PHP Warning:  include_once(): Failed opening
  '/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/password.inc'
  for inclusion (include_path='.:/usr/share/php5:/usr/share/php') in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 83   Warning: include_once(): Failed opening
  '/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/password.inc'
  for inclusion (include_path='.:/usr/share/php5:/usr/share/php') in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 83   PHP Warning:
  include_once(/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/bootstrap.inc):
  failed to open stream: No such file or directory in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 84   Warning:
  include_once(/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/bootstrap.inc):
  failed to open stream: No such file or directory in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 84   PHP Warning:  include_once(): Failed opening
  '/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/bootstrap.inc'
  for inclusion (include_path='.:/usr/share/php5:/usr/share/php') in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 84   Warning: include_once(): Failed opening
  '/var/www/localhost/htdocs/26_05_2012/zipshop/scripts/includes/bootstrap.inc'
  for inclusion (include_path='.:/usr/share/php5:/usr/share/php') in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 84   PHP Fatal error:  Call to undefined function
  user_hash_password() in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 87   Fatal error: Call to undefined function
  user_hash_password() in
  /var/www/localhost/htdocs/26_05_2012/zipshop/scripts/password-hash.sh
  on line 87

Is there a possibility to change the password just through mysql-cient?


texts: Getting the original form with error message in drupal ajax call back

texts:
I have a drupal form which accept email id and ajax call is implemented for the submit button.In addition to submit call back.The return values are collected in the wrapper and my requirement is to display the form along with an error message if the email is not valid.

I tried to return the form along with message to the wrapper from submit,but the ajax call was not happening.

Also i tried to reset the form_state array empty in the submit call back, but execution stopped at that point.

Am i on the correct track?
Please help me in solving this.Sorry for my english.


texts: How to get the value of a datetime when form submitted

texts:
I am writing a custom module in which i am declaring a $form element as #type=> 'datetime'

The code for the buildForm method is

 $form['timesave'] = array(
    '#type' => 'datetime',
    '#title' => $this->t('Select Date and time'),
  );

Now my question is how do we get the value of the field on form Submit as i have to store the value in a configuration

I have tried with

$form_state->getValue('timesave');

This is giving an array some protected methods.


texts: Best practice for avoiding module / theme / profile name clashes?

texts:
We currently have our code managed such that each site has its own theme and install profile.
These have naturally evolved in such a way that the names of these items (and their directories) tend to be the same.

For example, one site's theme and profile are both called 'dennis'

This causes problems with feature servers, and (I'm suspecting) with Aegir.

Now... it's relatively easy to rename either of these (although, for various reasons it's noticeably easier to rename the profile). Is there any sort of best practice here, ie is it normal to call the theme dennis_theme, or the profile dennis_profile? Should I apply this convention to both, or just to one?


texts: How do I set a path alias for each forum?

texts:
I created a forum on a site using the core Forum module. When we create a new forum, Drupal creates it as a taxonomy term. When we create the new forum, if we associate a path alias, that URL alias is only associated to the taxonomy term and not to the forum.
If we click on a specific forum from the index page (example.com/forum) we are sent to example.com/forum/nn.

How can I associate a path alias? I'm not being able to do it via the Pathauto module. Can someone tell me how to do it with that module or using any other solution?


texts: Adding custom meta tags to nodes, dependent on author name?

texts:
I would like to add the meta tag

`<meta name="robots" content="follow,noindex">`

to all nodes (content type is article) written by specific authors, not only for their new articles but for the few hundred that already exist.

I've installed metatag and metatags-quick, neither seem to offer the functionality I'm after. This is a drupal 7 installation.

I'd rather not have to edit the php, as I'm unfamiliar with that, but I will if I have to.

Does anyone know a way to do this?


texts: Include HTML in theme_pager_next $text variable?

texts:
Is it possible to include markup in the $text variable of theme_pager_next()? I find that whatever I set the variable to gets output as a string, rather than being rendered as HTML. Here's some example code as would be found in template.php:

    function theme_pager_next($variables){
      $text = 'test value';

      /* Remainder of function call goes here ...*/

      return $output;
    }

I would like be able to add an image to the pager text. I realize I could also use CSS background images, but would prefer to print markup to the page if at all  possible.

Is there something I'm overlooking?


texts: How to limit access to vocabulary term by role?

texts:
We have two roles: Reviewer and Editor along with two content types: Basic and Article. We have a couple vocabulary terms and taxonomy fields on each content type. Currently only users with Administer vocabularies and terms and Use the administration pages and help can edit those vocabulary terms, but they have access to add/edit/delete all Vocabulary terms (something we don't want).

How can we selectively allow only users with Editor role to be able to add/edit/delete any values in just the Tag vocabulary term?

Basic Content Type:

Fields:

Category (field_category) -> Taxonomy term field -> linked to Category vocabulary
Title
Description

Article Content Type:

Fields:

Article Tags (field_article_tags) -> Taxonomy term field -> linked to Tags vocabulary
Title
Description

Desired outcome:

Users with Reviewer role cannot access anything other than the nodes. (this is already done)
Users with Editor role should be able to access only the admin/structure/taxonomy/manage/tags/overview page (Tags overview page)
While on the Tags Overview page, users with Editor role should only be able to access that link and no other admin pages.
While on the Tags Overview page, users with Editor role should only be able to add/edit/delete any terms in the Tags vocabulary.


texts: Disclose billing cycle information on order page to customers

texts:
When customer clicks on a recurring order page he can see:

  Billing information:
  Name Lastname
  Some Address
  Some City, State 11111 United States

and then immediately after that:

  Billing cycle:
  - Restricted access -

I looked high and low, tried all the different permissions for products, orders, licenses, but can't figure out how to get billing cycle information displayed on order page. I don't know why billing cycle should be restricted for the customers.


texts: How to find image style URL from within twig template?

texts:
I'm implementing a node template that uses an image twice; once in a 'normal' way (i.e. using the image style defined in the field's display configuration for that view mode), and the other is as a css background-image property.

I need one of two things:

(ideally) a way to get the URL for a different image style of the same image.
a way to get the URL for the image field.

I'm struggling to use dump() and kint() to help myself to an answer. They both output far far too much (thanks to embedded links to "parent" etc.) and seem to not have the info I need. e.g. looking at dump(content.field_image) output the actual URL of the image is not there (so where does it come from such that it can be rendered with {{ content.field_image }}?!). kint() on the other hand dies completely if I pass an argument to it and the top-level version is again far too big to navigate. Debugging was soo much easier with phptemplate + xdebug. (Yes I know it's good that themers can't drop the database.)

There's an answer to (1) that implies you can't do it, but I don't understand why I can't get the existing URL in (2)?


texts: I Can't add node of a custom content type

texts:
I have to add a new content type to my site for a new feature i'm asked. I already added two of them before (very early in the building of the site, in fact) and it worked well but this time, when i want to add a new node, my new content type doesn't appear in the list of content types (node/add).

It appears in the admin/structure/types page but not in the node/add.

I cleared the cache and rebuild permissions but nothing happened.

I also tried to create a very basic new content type but it didn't appear either.

An earlier exchange on this forum showed it wasn't likely to be the taxonomy access control module.

If I do a clean install of drupal and create a new content type, it works but on my site, i can't do it so i don't think it is because i forgot some step.

May it be because of some problem with a third party module ?

I don't think i have installed very exotic ones but i have some (CKEditor, Taxonomy access control, Piwik Web Analytics... )

I'm turning mad so if someone has some clue, it may really help.

Thank you


texts: Is it possible to alias paths for contextually generated page views?

texts:
I have a content type with a path pattern ([category]/[english_title]) that is generated based on its field values.
In the node's page there is a block with referencing news items and a count based more link to a page with more news items.The path generated from the more link is the same as the node's alias but with /news appended to it ([category]/[english_title]/news).

For that I passed the English title as token through a hook to the more link which was fetched from the page side as an argument to be matched against. It was fine until I had some fields with special characters, especially titles with apostrophes of possessive 'S's. I am unsure about how to proceed. An easier way would be since there. There is already a news section to do something like /news?nid, but it got me thinking.

Is it possible to alias contextually generated views pages or substitute an already patterned portion of a URL with its alias?


texts: I can't change permissions for text filters

texts:
I performed a pretty massive 50,000+ node migration a few weeks ago (from Drupal 7.70 to Drupal 8.9), and just noticed today that some of the Text Filters aren't visible in content creation pages (in particular, Plain text filter, which is what I like to make the default for most fields).
I tried creating a similar filter called "Plain", but when defining the default filter for content types on text fields, though at least now the new filter is visible as on option from the select box, it won't save (it reverts back to Full HTML filter on save). Furthermore, the filter permissions page shows that something is awry as well...as I am unable to assign ANY permissions for the new filter or two of the migrated filters to any custom roles.
Clearly the migration didn't go smoothly. It took me 2 weeks to get ANY migration to work properly...so I really do no want to roll back and try again if possible. Is there any way I an fix the text filters and their respective permissions problem here?
I have full access to the server, mysql, etc. Is there something I should be looking for in particular? Or at least a DB model that I can copy?
Thanks in advance for your help.

EDIT: I just noticed that I can go into the individual user roles, and "see" the checkboxes that aren't showing up on the Permissions matrix (where you can select permissions for all users at once). Is this maybe just a rendering bug for the main permissions display page? Here's another screenshot:


texts: Adding a radio buttons in views exposed filters for published and unpublished drupal 7

texts: The above view shows articles content type, which is exposed filter.I want to add a radio buttons as i have shown in image for published and unpublished,can I get this functionality programmaticaly and how


texts: How to change term reference field according to role?

texts:
I have the following challenge: I have 4 roles, let's call them Group1 ... Group4. I have different content types and I segregate access of those types using the Taxonomy Access Control module. So users from Group1 can only view and edit nodes that have term Group1.

Now, I have the challenge to change a term reference field of these content types automatically. So if a user from role Group1 creates a new node, that node will have a term reference field with term Group1.

I don't want users to edit on their own to avoid human errors.


texts:
I do not understand how the Boolean (just for example) is validated. This is my code:

$tdm = \Drupal::typedData();
$data = $tdm->create(array('type' => 'boolean'), 1000);
drush_print_r($data->validate());

The $data->validate() returns a list of ConstraintViolations, but where is the logic of these constraints, per Drupal\Core\TypedData\Plugin\DataType\Boolean does not implements getConstraints method.

Thanks


texts: Change the submit handler of a form of a module

texts:
I installed base cart module and I need to totally overwrite the submit handler of one of its forms and not to execute its default functionality at all. From what I searched, I wrote this code in template.php :

function ThemeName_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'order_node_form'){
    $form['#submit'] = 'submit';
    $form['#validate'] = '';
  }
}

function submit() {
  return "submit";
}

But it is not working. Is it possible to do this in template.php or I need to build a module to do this? or the problem is from anything else?

Thanks


texts:
I want to filter the contents of all the views of my website. This should happen before the views pager is built. I guess I need a Views plugin then. First of all I want to create a views filter plugin, which will be recognized by Drupal.

On my way I have found an article about creating a views display extender. However this one is a display extender. I want to create a "filter extender". But I have no idea what I should specify in the annotation of the class, which resides in the

  Drupal\my_module\Plugin\views\filter

namespace.

I have tried this:

/**
  * Filters views content.
  *
  * @ingroup views_filter_handlers
  *
  *
  * @Plugin(
  *   id = "my_filter_name",
  * )
  */

But the filter won't get recognized by Drupal after a cache clear. I was setting a few breakpoints there and the class is never invoked. Has anybody a hint or a good tutorial about creating a custom "views filter plugin"?


texts: Modal Error Messages Displaying on Main page

texts:
I have a page. Once i click on Button on that page. It opens jQuery Modal.

In that Modal Box. I'm rendering Form. I have put 1 fields test as required true.

Issue is when I click on Submit button. It closes Modal Box & showing errors on Main Page.

I need that when it clicks on Submit button. It will not close Modal Box & Display errors on Modal box instead of Main page.


texts: I am placing a couple of static elements into the header, the issue is that the elements are being placed below the menu instead of below the header logo. Is this possible to put the block below the header logo image? I had to hack the css with a negative left margin and absolute top for now but it does not behave properly when elements are declared above it. (e.g. if admin logs in, or is not logged in, will affect the position vertically, etc)


texts: Pre-populate node creation form based on "base" node

texts:
I have this content type "education course" where I set the title, description, evaluation type , duration and objectives(and so on).
I want to create another content type "course edition" that would work this way : when I want to create an edition, I would choose what "course" I want to pick what "course" node to use, so it will pre-populate with the values that never change between editions.

How can I achieve this behavior?


texts:
It seems that by default all regions are rendered in Omega theme because of the Debug blocks.

Sidebar First

This is a debugging block

Is there a way to have an option to debug blocks and hide empty blocks at the same time?


texts:
where is the template_preprocess() function located? It seems that my markaspot theme (mas) call this function but I can not find this funktion in a file.

Thanks for your help.


texts: Search page shows an empty page with page.tpl.php template

texts:
I am setting up a search page in Drupal 7 and when I click on Search after entering a keyword, it just shows me an empty page.tpl.php. In other words, it just shows me the page.tpl.php template with no result in it.

Is there a way to fix it? Why is it happening?


texts: Is there a way to create field collection table dropbox for added content in form

texts:
Im creating a form in content type form format
I will enable public users to create content type for this form.

I have integrated a field collection module within this form like
adding multiple participants

The fields in the field collection contain fields for name, address, contact info, etc..
The user can add as many participants they want in the field collection.

My question is:
Whenever i try to click the button "add another Item" the whole field collection form stacks up in the page. So when I add 10 participants it will make the page longer and difficult to navigate.

What im thnking is, is there a way that i can create a table that contains the added info (displaying limited fields only) when I click the add another item.

similr to hierarchical Hierarchical Select dropbox function if you are familiar with this

Is there a module that performs similar to this?


texts:
I'm on Drupal 8 with Commerce 2.

I created a view page to display the list of products in the stores.

Here is the way of my sight :

/store/3/produits

Can not add a tab to shop pages.

I am desperate.

Can you explain why the "Edit" tab on the page is missing ?

Here is my view, it is very simple :

Here is my page "Produits", there is no tab :


texts: Add/remove roles after submitting a certain webform

texts:
I know that we can achieve this via Rules but unfortunately, there are some known issues that prevent Rules in Drupal 8 to add a role properly.

So I was wondering if it would be possible to programmatically add and remove some roles to an authenticated user after submitting a webform.

For now, I'm simply trying to add a role called styled to the logged-in user, So I created a 'Webform Handler' called webform_handler_role and added that to the webform through UI, but I still can't get it to add the role using the following code (Also note that I have Ajax enabled for the webform):

<?php
namespace Drupal\webform_handler_role\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Webform submission action handler.
 *
 * @WebformHandler(
 *   id = "userrole",
 *   label = @Translation("User Role"),
 *   category = @Translation("User Role"),
 *   description = @Translation("Adds a user role after submission"),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_OPTIONAL,
 * )
 */
class UserRoleHandler extends WebformHandlerBase {

  /**
   * {@inheritdoc}
   */
  public function postSave(WebformSubmissionInterface $webform_submission, $update = TRUE) {
    $user = \Drupal::currentUser();
    $user->addRole('styled');
    $user->save();
  }
}

And after the form submission I end up with the following error:

  "Error: Call to undefined method Drupal\Core\Session\AccountProxy::addRole() in Drupal\webform_handler_role\Plugin\WebformHandler\UserRoleHandler->postSave() (line 28 of /modules/custom/webform_handler_role/src/Plugin/WebformHandler/UserRoleHandler.php).")."


texts:
I'm trying to create a stacked page with the Panels module, using flexible layouts. It should look like this:

How can I do this?


texts: Skip user edit page on first login using fboauth

texts:
I am using the latest dev version on FBOAuth module on my site. I am using Popup for facebook login.

When the user logs in for the first time using facebook currently the user is being redirected to the account edit page. Is there a way I can skip this test, so that user will be back to the page where he came from. Later on he can go to account edit page and set the password if he wants to. Else he continue using the facebook login only.

Once the account is already connected, I am not facing this issue as the user is rightly directed to the page he came from. The issue is only with the first login using facebook.

Please let me know if there is some setting that I can enable.


texts: Migration: the "csvrownum" should start from the second row

texts:
I am importing some nodes from csv file in drupal.

I am assigning row number to one of the field of that content type.

The first row in the csv is the header which contains the column names only. The data start from the second row.

I am using the "csvrownum" for the csv row number. But it starts from the first row. It should exclude the first row as the data starts from the second row. How will I do this?

Here is my code:

$this->source = new MigrateSourceCSV($path, $columns, array('header_rows' => 1));
          //The destination CCK (boundle)
          $node_options = MigrateDestinationNode::options("en", "full_html");
          $this->destination = new MigrateDestinationNode('lot', $node_options);
          $this->map = new MigrateSQLMap(
              $this->machineName, array(
            "csvrownum" => array(
              'type' => 'int',
              'unsigned' => TRUE,
              'not null' => TRUE,
              'alias' => 'import'
            )
              ), MigrateDestinationNode::getKeySchema()
          );
          //Field mapping
          $this->addFieldMapping('title', 'Title');
          $this->addFieldMapping('field_number', 'csvrownum');


texts: How to display node details and call function in *.html.twig

texts:
I work in D8, I create a custom module first_module. By modules create a url and display all nodes by *.html.twig file.

Write code in controller.php

public function contentthree() {

  $connection = Database::getConnection();

  $query = $connection->select('node', 'n');
  $query->fields('n', ['nid', 'type']);

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

  foreach ($groups as $group) {
    $events[] = [$group->nid, $group->type];
  }

  return [
    '#theme'  => 'first_module_display',
    '#events' => $events,
  ];
}

In *.module

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

  return [
    'first_module_display' => [
      'variables' => ['events' => NULL],
      'template'  => 'first-module-list',
    ],
  ];
}

function _get_node_details() {

  $output = 'Welcome D8';

  $output .= 'Node Details';

  return $output;
}

and create templates first-module-list.html.twig and display data

{%for key, data in events %}

{%for key1, data1 in data %}

   {{ data1 }}

{% endfor %}

{% endfor %}

work fine and showing data correct. But, my question is how to call function _get_node_details() and how to render node details in first-module-list.html.twig files?


texts:
I'd like to access $user from the commandline to see what properties are available on it.  I could sdpm($user) in my code and go inspect it in my browser, but isn't there a way I can inspect it right from my terminal?

It looks like drush php could be helpful here, according to http://blog.damiankloip.net/2015/drush-php, but when I use it and do dump -a $user I get 'Unknown variable: $user'.  That's probably obvious, so I probably need to load $user into the repl first (I'm guessing)... but how?  That blog post shows how to load objects in D8, but how would I do this in D7 for $user???


texts:
I have limited experience with D8 and custom routes.

Current mobile video system for client takes a scheme-less url for the video like so

https://example.com/mobile-video/some-video-desktop.azureedge.net

The routing has worked fine until we had a vendor change for video hosting and the new URLs include slashes and query strings which may or may not be the issue.

mobilevideo.routing.yml  looks like

mobilevideo.content:
  path: '/mobile-video/{vguid}'
  defaults:
    _controller: 'Drupal\mobilevideo\Controller\MobileVideoController::content'
    _title: 'Mobile Video'
  requirements:
    _permission: 'access content'
    vguid: '^[-a-zA-Z0-9.\/?=]+'

Prior to today the validation was just '^[-a-zA-Z0-9.]+'

So testing the new URLs I am getting 404s.  But if the parameter passed to the mobilevideo.routing.yml fails validation a 404 is the correct response so I assume the issue is validation.   https://www.drupal.org/docs/8/api/routing-system/parameters-values-validation-in-routes

So I changed the validation from vguid: '^[-a-zA-Z0-9.]+' to  vguid: '^[-a-zA-Z0-9.\/?=]+' that had no effect and I also tried '.+' and also the original without ? and =   with no change.

I should note that the original URLs with no slashes worked continously through all of this and that each change was followed by clearing all caches.

Also tried removing validation entirely and that also failed so I am wondering if my path cannot include slashes in the parameter for reasons beyond validation?

What should my next step be in debugging this?

A full example URL will look like

https://example.com/mobile-video/someidhere.cloudfront.net/sessions/forty-characters-or-more-of-vguid-here.mp4?invocationId=thirty-more-chars-here

UPDATE
Based on info re optional parameters and the comments on this post I added four more parameters and default values of '' for each updating mobilevideo.routing.yml to

mobilevideo.content:
  path: '/mobile-video/{vguid}/{vguidtwo}/{vguidhtree}/{vguidfour}/{vguidfive}'
  defaults:
    _controller: 'Drupal\mobilevideo\Controller\MobileVideoController::content'
    _title: 'Mobile Video'
    vguid: ''
    vguidtwo: ''
    vguidthree: ''
    vguidfour: ''
    vguidfive: ''
  requirements:
    _permission: 'access content'
    vguid: '^[-a-zA-Z0-9.]+'
    vguidtwo: '^[-a-zA-Z0-9.]+'
    vguidthree: '^[-a-zA-Z0-9.]+'
    vguidfour: '^[-a-zA-Z0-9.]+'
    vguidfive: '^[-a-zA-Z0-9.]+'

Then updated the controller to use public function content($vguid, $vguidtwo, $vguidthree, $vguidfour, $vguidfive) { and assemble the URL based on that array.

Attempting to flush the cache gets The website encountered an unexpected error. Please try again later..  What did I miss?


texts:
I have created a view that has many fields including a link field.
I am using a twig template. my view twig name is views-view-fields--dashboard--block_3.html.twig It works nicely but I need to render a path in an anchor tag. here is my code.

{{ fields.title.content }}

        {{ fields.body.content }}
        {{ fields.created.content }}

In the anchor tag, I am getting the link but it has twig debugging wrappers. The result is bellow

and I need only the path. I have already tried the twig_field_value module. but when I {{ fields.view_node.content|field_value}}

  Error: Cannot use object of type Drupal\Core\Render\Markup as array in
  Drupal\twig_field_value\Twig\Extension\FieldValueExtension->isFieldRenderArray()
  (line 171 of
  modules\contrib\twig_field_value\src\Twig\Extension\FieldValueExtension.php).

Now I am looking for how to render the value of an anchor tag without any wrapper.


texts: Remove VAT based on company field and country

texts:
How can I remove tax based on the company field and based on the country. For example:

In the Netherlands:

A customer from a company in The Netherlands - He must pay VAT

A customer private in The Netherlands - He must pay VAT

Outside the Netherlands

A customer from a company outside the Netherlands - He must pay no VAT.

A customer private outside the Netherlands - He must pay VAT.

What I have so far is this: If the company field has a value, they don't need to pay VAT. But the problem is now, if they are living in the Netherlands and they place a order from a company they don't have to pay VAT, but people in this country (The Netherlands) need to pay VAT.


texts: Detect page redirection and execute code

texts:
I have two modules which I am trying to make work in synch.

The first module creates a dynamic page and redirects users if certain conditions are met. The redirect URL takes to following form: testsite/event/registration/success/277/466.

When the redirect happens, I want my second module to detect the redirection and pickup from when the first module left off. I am trying to make it check and determine if the user is on: testsite/event/registration/success/*/*

Is this possible and can anyone give me some direction, please?


texts:
Module: https://www.drupal.org/project/lightbox2

Once lightbox pop up, it will auto close within few second.

Am I am to stop it auto close till user click closed button?


texts:
I would like to know how to hook a function in the footer area right before the  tag. The function would produce html.

function html_footer(){
    does stuff
}
places_in_footer('html_footer()');

I've done some research on the subject but it seems like there are a lot of different methods but all of them are deprecated. So I'm not sure what the right method would be.

For example in wordpress it would be:

function your_function() {
    echo '
This is inserted at the bottom
';
}
add_action( 'wp_footer', 'your_function' );


texts: Sort content of views with drag and drop

texts:
I use Drupal 8, but I can not figure out how to sort views with drag and drop.
The client needs to sort the items of the views in a very personal way.

Do you know some way?


texts:
Is there a simple way to look at BLOB data that Drupal 7 stores in some tables?

There is a trick to configure phpmyadmin but apparently it's not working with version 3.3.9.2 that comes with MAMP.


texts:
Possible Duplicate:
  How do I hide Drupal nodes that shouldn’t be directly accessed from users and search engines?

I was wondering what is the best way to hide a node page?

I am using a content type (book page) to create my books and I have a library page (a view) to list all the books, I dont wan to have any individual book pages visible to the users.

I have tried playing with node access modules and they didn't work for me.

I would still like to the access level to TRUE so I can refer to that node from other nodes/views by reading their content, but I don't want the users to see that particular node page.

How do I do that?

Many thanks


texts:
Using the Migrate module, I created an import task that creates and updates user info from a csv file. The update is launched using drush.

drush -l http://localhost.atrium.com mi Utilisateur --update

All the users are updated appropriately but the user roles, which are not in the migration mapping, are reset for every user that's updated.

How can I avoid that and keep the user roles for every account that's updated ?

Thanks !


texts: twig check if image style or view mode exists

texts:
I have a site design the i need to implement.
in this design I have a grid and in the grid I can put any content (node/paragraph) that i choose.
the image of the content changes size and ratio in relation to its location in the grid.
I created display modes for the nodes and i use twig tweak to render it in the right display mode for example:

{{ drupal_entity('node', content['#node'].id , 'box_grid_1x2') }}

for the paragraphs I add my image style directly in the paragraph template:

{{ content.field_image.0 | merge({'#image_style': 'box_grid_1x2'}) }}

because its a little more dynamic than this and my 'box_grid_1x2' is actually a variable that can be set by the user I want to verify that my image styles of view modes do exist before printing them and if they dont I want to print a fallback display\image style.

how would you do it?
Thanks for your help.


texts: How to use Rules to redirect a user based on URL argument?

texts:
I'm using Drupal 7 and the Drupal Commerce module. I'm now able to capture an argument passed by URL using Rules (thanks to this helpful thread). However, I'd now like to be able to redirect the user to one page if the argument equals one thing and send them to a different page if it equals ANYTHING else. Anyone know how to do that?

I tried using 'Page Redirect' as an action in Rules, after the action of capturing the argument in the URL (Action > Provide URL argument value), but there's no option in the Page Redirect action to send users somewhere based on the argument value.

So for example, I have users coming to the site with urls like so:

membership-renewal/?ID=promo1

Currently Rules is recognizing that they are using that URL and it's reading 'promo1' value using [ID:value] replacement pattern...I can print it out to the screen so I know it's reading it.

But I don't know how to then use that value to inform a page redirect for example.

Anyone know?


texts: Javascript only runs when logged in as admin

texts:
I created a test site. I put the JS into the template.php:

drupal_add_js('jQuery(document).ready(function(){jQuery(".foomo").accordion({ collapsible: true, active: false, animated: true});});', 'inline');

File permissions are set as described here.

If I load the website as 'admin' the accordion is collapsed as I want.

But why doesn't open or close the accordion for any other user?


texts: How to hide all tabs (local tasks) except the user account tabs?

texts:
I want to hide all tabs (local tasks) for non-admin users except the tabs on the user account page (for example, I want to hide tabs on nodes of all content types).

To hide the tabs, I added a check for admin permission in my theme template: templates/menu/menu-local-tasks.html.twig

{% if user.hasPermission('administer nodes') %}
  {% if primary %}

{{ 'Primary tabs'|t }}

{{ primary }}

  {% endif %}
  {% if secondary %}

{{ 'Secondary tabs'|t }}

{{ secondary }}

  {% endif %}
{% endif %}

This works, but it hides the tabs on the user account page as well.

I tried to find a more specific template of menu-local-tasks for the user account. I turned on twig debugging, but these were the suggestions:

All of these affect the entire site; there is no way to target just the user account local tasks.

Is there a way to do this with theme templates?  I chose this approach rather than trying to unset the local tasks in a hook because in a template you can do it in just a line or two of code.


texts: How to create tabbed menu consisting of views and a contact form while having unique paths for each tab?

texts:
I'd like to create a tabbed menu of my support page like this:

           | FAQ | Contact us |

I'm using views accordion to create a view for my FAQ, but I'm using the contact form for my Contact form.

How can I combine them in a same menu tab while having each tab have its own path so that I can theme the current tab using a:active and for seo purposes?

I've tried quicktabs and block tabs, which work but doesn't give me separate paths. The node tabs module comes close but it doesn't seem to be able to work with a form.

I'm thinking I might need to build it programmatically using a custom module and hook_menu: How can I create a simple tab? but I'd prefer not going into that if possible


texts: Content in website does not show under the right website name

texts:
I have created the contents,

And I want the content should be display like www.kvamsdanl.no.

But It was displaying like www.kvamsdanl.no/node/3(or with one of these numbers 1 , 2 or 5).

How do I achieve this thing ?

Please anyone help me to sort out this issue?


texts:
On a Drupal 8 installation, with CKEditor enabled for Full HTML format, when I paste text from Word with cmd+V, the source code includes format that makes the code dirty.

Example:

Lorem ipsum dolor.

How can I force it to clean the code from Word?


texts:
in Drupal 6, is there a way to list by programmation (function or SQL code) the dependancies of a node ?

For exemple, I have videos that are nodes. Thoses videos are refered in other nodes. Before deleting the video I need to update the nodes which refer it.
I have the module "Node Dependencies" that lists the dependencies of a node in the UI, but I need to get this list with code.

Is it possible ?

Thanks.


texts: How can I print a referenced media extension

texts:
I am working in the node template. In my content type I have a referenced field to media called 'field_event'. I created a new media type called 'document'. Inside document there is a file upload field called 'field_document'.
I need to print the file name, size and extension all separately in table cells.
Example: Myfile | 80kb | pdf

This renders the file, link and name.

{{ content.field_event }}

Gives me: mypdf.pdf 80.00 KB, This is the name of my pdf

This prints out only the name

{{ node.field_event.entity.name.value }}

Gives me: This is the name of my pdf

How can I get the file extension? I have tried these.

{{ node.field_event.document.entity.field_document.entity.filesize.value }}

{{ node.field_event|field_target_entity.field_mime_type.value }}

{{ node.field_event|field_target_entity.field_mime_type.entity.filemime.value }}

I am using twig tweak


texts: Does using Drupal.ajax() offer any benefits over jQuery.ajax()?

texts:
I'm updating a node's references (list of them - rendered entities) manually with AJAX and experiencing performance problems.

$.ajax() is used to call a view rendered with the simplest page.tpl.php ever: print render($page['content']).

The filters are simple exposed filters that I pre-handle in the URL level so the url looks like this: /url-of-view?argone=foo&argtwo=bar&template=minimal. The view is then built up, rendered, and returned to the client.

The problem is when the site is at it's peak hours this URL (normally) is being bombarded and the server becomes slow to borderline unresponsive.

Will using Drupal.ajax() instead of jQuery.ajax() give me a performance boost here, or should I look at querying the node data manually instead of relying on Views?


texts: Migrate sub_process plugin is not working

texts:
There are a couple of questions that are closely related to this on this forum that I have reviewed several times.  None of them seem to address the issue specifically.

I have a target field (with subfields) that is set to unlimited.

The Source that I'm "migrating" from is JSON. The Target, in this case, is an address field on a node.

To simplify and debug the migration. I created a constant as a source for the values that I want to assign to field_locations/country_code.

The code in the migration configuration YAML is

source:
  constants:
    title_suffix: ' (Imported from remote file)'
    country: 'GB'
    countries:
      -
        country: US
      -
        country: CA
....

process:
  field_locations:
      plugin: sub_process
      source:
        - constants/countries
      process:
        country_code: country

If I replace the implementation of the sub_process plugin and use get, I update the target field (subfield actually) with:

field_locations/country_code: constants/country

The destination row is updated perfectly - though of course I can only et

For reference: This is what the entity should look like with repeating values set. How do I get that to work with this migration? I'm guessing there is something pretty simple I'm missing


texts: Disabling Wysyig profile profile for particular content type

texts:
I am using CKeditor with wysiwyg profile .
I want to disable this Wysyig profile for a particular content type.
cant find a better way.
please help me out with any module if its there or any configuration setting if its possible


texts: How to add a "?destination=URL" to the node links

texts:
I am trying to override node links by using hook_node_view_alter(), so my code looks like:

$cancel_link = 'admin/some_path/'.$found_id.'cancel';

$build['links']['node']['#links']['cancel'] = array(
        'title' => t('Cancel'),
        'href' => $cancel_link,
        'html' => TRUE,
        'attributes' => array(
          'title' => 'Cancel',
        ),
      );

and it works fine. But I also need to add "?destination=URL" to links and unfortunately, trying several different approaches didn't work for me. In particular:

I copied the whole Good Example code from https://www.drupal.org/docs/7/theming/overriding-themable-output/how-to-add-a-destinationurl-to-the-request-new-password and replaced my code with:

$build['links']['node']['#links']['cancel'] = l(t('Request new password'), 'user/password', array('query' => array('destination' => 'homepage', 'foo' => 'bar'), 'attributes' => array('title' => t('Request new password via e-mail.'))));

but the link didn't show up at all.

Example on https://www.zyxware.com/articles/5195/how-to-set-destination-as-the-link-value-in-the-l-in-case-of-urls-with-parameters didn't work.

Tried to adapt the accepted answer on use URL with query as URL destination as:

  $query_string = array('destination' => 'service/922');
  $url = url($cancel_link, array('query' => $query_string));
  $build['links']['node']['#links']['cancel'] = array(
    'title' => t('Cancel'),
    'href' => $url,
    'html' => TRUE,
    'attributes' => array(
      'title' => 'Cancel',
    ),
  );

unfortunately, it is also giving %3Fdestination%3Dservice/922 in the browser address bar. What I am doing wrong here?

Addition: Using dpm() I've figured out the above examples all output ready to use links like Request new password

However, if I dpm the link in my function it still gives raw array:

(Array, 4 elements)
title (String, 6 characters ) Cancel
href (String, 33 characters ) admin/some_path/id/cancel
html (Boolean) TRUE
attributes (Array, 1 element)
title (String, 6 characters ) Cancel

And I wonder is it possible to add destination at this stage at all or do I have to intercept the link at a later steps like for example while themeing?


texts: Tab Tamer Module only does but so much. I want to hide a tab for anonymous users and have it active for other admin users. This just turns it off completely. Any ideas?


texts: 200 OK on every page after updating the content

texts:
i have uploaded my localhost site to online, my site was working ok at localhost, but after uploading online whenever im upadating any content it shows me this error message on every page.Please help...

OK
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

HTTP/1.1 200 OK Date: Fri, 25 May 2012 05:40:26 GMT Server: Apache/2.2.22 (Unix) FrontPage/5.0.2.2635 X-Powered-By: PHP/5.3.8 Expires: Sun, 19 Nov 1978 05:00:00 GMT Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0 Last-Modified: Fri, 25 May 2012 05:40:26 GMT Keep-Alive: timeout=5, max=399 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 5527


texts: Ubercart override default flat rate quote

texts: Drupal 7.  Using Ubercart 7.x-3.10.  I created a shipping default flat rate quote of $7.  I created a product and gave it a flat shipping rate of $3.00.  When I check out, the shipping quote is $10 (default + product).  I don't understand how I get the product flat rate quote to override the default flat rate quote.  Could someone please point me in the right direction?  Thanks!


texts: How to get a multilevel taxonomy reference field to output as nested UL in node tpl?

texts:
I have a simple 2 level taxonomy vocabulary field but I can't seem to find a way to output the terms (labels) in a nested UL in my node TPL. There are no display formatter options at all and I can't find any info on this?

Parent 1

child 1.1
child 1.2

Parent 2

child 2.1
...

{{ content.field_my_terms }} just gives me field__items with flattened field__item.