texts:
I am trying to render a simple button with a submission handler. I tried two  methods, and this is the code I used.

First method

mymodule.module

function mymodule_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $type = $entity->bundle();
  if ($type == "property") {
    $build['#attached']['library'][] = 'mymodule/custom_styling';
    $build['mymodule_btn'] = [
      '#type' => 'submit',
      '#value' => 'Generate PDF',
      '#submit' => ['mymodule_generate_pdf'],
      '#weight' => -1,
    ];
   }
}

function mymodule_generate_pdf() {
  // ...
}

Second method

mymodule.module

function mymodule_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $type = $entity->bundle();
  if ($type == "property") {
    $build['#attached']['library'][] = 'mymodule/custom_styling';
     return \Drupal::formBuilder()->getForm(Drupal\MyModule\Form\MyModuleForm::class);
  }
}

MyModuleForm.php

namespace Drupal\MyModule\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Generate the button.
 */
class MyModuleForm extends ConfigFormBase {

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

  /**
   * {@inheritdoc}.
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['mymodule_btn'] = [
      '#type' => 'submit',
      '#value' => 'Generate PDF',
      //'#submit' => ['mymodule_pdf_generate_pdf'],
      '#weight' => -1,
    ];

    return $form;
  }

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

  /**
   * {@inheritdoc}.
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // ...
    \Drupal::formBuilder()->submitForm('mymodule_form', $form_state);
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
  }
}

The first method generates the button, but the submission handler is not executed. The second method doesn't even generate the button.

How can I fix the code I wrote?


texts:
How to add type="module" to script added in MODULENAME.libraries.yml when i do:
my-library:
  version: 1.x
  js:
    js/App.js: { }

I get
<script src="/modules/custom/MODULENAME/js/App.js?v=1.x"></script>

I need to add type="module" to script tag like:
<script type="module" src="/modules/custom/MODULENAME/js/App.js?v=1.x"></script>

I have tried:
my-library:
  version: 1.x
  js:
    js/App.js: { type: module }

But i doesn’t work.
Is this possible to add a script of type module?


texts: How can I prevent a particular page being cached?

texts:
I have activated the cache on my Drupal 8 site, and of course all pages are cached as expected.

However, I'd like to have a specific page bypass that cache.

In my controller I built the page as follows:

public function myPage() {
  return [
    '#markup' => time(),
  ];
}

How can I tell Drupal not to cache my page?


texts: Trying to manually print Commerce receipt in custom module but stuck on printing total/adjustments

texts:
I have a custom module that displays the Commerce receipt at the checkout complete screen. I have it all working except for the adjustments (tax, shipping, discounts) section.
In my custom module I have:
 $renderable = array(
      '#theme' => 'commerce_order_receipt',
      '#order_entity' => $order,
      '#billing_information' => NULL,
      '#shipping_information' => NULL,
      '#payment_method' => NULL,
      '#totals' => NULL,
      //'#totals' => $this->orderTotalSummary->buildTotals($order),
    );
    if ($billing_profile = $order->getBillingProfile()) {
      $profile_view_bulder = \Drupal::entityTypeManager()->getViewBuilder('profile');
      $renderable['#billing_information'] = $profile_view_bulder->view($billing_profile, '');
    }
  }else{
    $renderable = NULL;
  }

The commented line: ('#totals' => $this->orderTotalSummary->buildTotals($order), ) is what calls and generates the totals to pass to the receipt theme template but since it's in a custom module the "$this" part is not functioning.
The line was originally in commerce/modules/order/scr/Mail/OrderReceiptMail
Any tipes on how to get that method call to work in my module?


texts: How do I add a pager for the following code?

texts:
On the page--product.tpl.php I use node_load() to get all the nodes of a content type. I want to shows 15 post titles per page. How do I add a pager to the page?

I am using the following code.

$terms = taxonomy_get_children(arg(2));
foreach ($terms as $term) {
  $whole = taxonomy_select_nodes($term->tid, TRUE, 1, array('t.created' => 'DESC'));
  foreach ($whole as $nid) {
    $node_this = node_load($nid);
    echo '
'.$node_this->title.'
';
  }
}


texts: Getting a linkable table of children in hook_block_view from taxonomy_get_children (Drupal 7)

texts:
I am trying to programmatically create a block that will display all of the children of the term being referenced by the current page in a linkable table (so that I can click on any of the taxonomy terms and then go to their page).  So far I have managed to create an ordered list of children names with the following code:

function children_view_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'children':
      $path = explode('/', drupal_get_path_alias($_GET['q']));

      $tid = array_pop($path);
      $term = taxonomy_term_load($tid);
      $children = taxonomy_get_children($term->tid, $term->vid);
      $stack = array();

      foreach ($children as $child) {
        array_push($stack,$child->name);
      }

      $theme_args = array('items' => $stack, 'type' => 'ol');
      $content = theme('item_list' , $theme_args);

      $block = array(
        'subject' => t('Children'),
        'content' => $content
      );
    break;
  }
  return $block;
}

But what I really want is a table that might contain some other details about the taxonomies but more importantly I would like each taxonomy in the list to be a link that will take me to that taoxnomies term page.  I image the reason these terms are not linkable is because I am only passing the name into the array but when I tried to pass the actual term into the array I get an error from the theme module.  How would I make these linkable?  Also, I imagine that I could change the ordered list into a table by replacing the 'ol' in the call:

      $theme_args = array('items' => $stack, 'type' => 'ol');

with a table but I am not sure what I would pass instead of 'ol' and I could not find any documentation about this.  Could anyone link me to such documentation?


texts:
I want to show a block when a user visits his/her own profile page at /user.
The public user profiles have paths of "/member/[username]".

When I limit the block to "user" it won't show up. When I limit it to "member/*" it will show up both on the own profile and on the public profiles.

Is the "user" url something special?


texts: How to login when you have a default page setup with panels?

texts:
I have been messing with panels.  I set a default layout page that basically has no content and is set for all the pages at the moment.  I logged out like a dummy and now when I go to website/user/login it gives me a blank page.  Is there another way I can login?

Thanks!


texts:
I am trying to replace drupal_realpath with realpath. What I did is

$stream_wrapper = new DrupalStreamWrapperInterface();
$file_path = $stream_wrapper->realpath($img_path);

But it gives me this error: Cannot instantiate interface DrupalStreamWrapperInterface. Any idea how do I use DrupalStreamWrapperInterface::realpath?


texts: How to change the button name after click on it using ajax

texts:
I am a newbie in drupal. I created a form that perform ajax action. How can I change the button name after click by using ajax.

function auktion_fav_form($form, &$form_state, $auktion_id) {
  form['add_to_fav'] = array(
    '#type' => 'submit',
    '#id' => 'submit',
    '#value' => t($value),
    '#ajax' => array(
      'callback' => 'auktion_fav_submit',
      'wrapper' => 'submit',
      'method' => 'replace',
      'effect' => 'fade',
    )
  );
  return $form;
}
function auktion_fav_form_submit($form, &$form_state) {
  $form['add_to_fav']['#value'] = "remove from favourite;
  return $form['add_to_fav'];
}


texts: How to create a task which run at cron time and send emails to users?

texts:
Is there a module (based on cron) which can be used to check a date value form a field and to send email to users 2 days before the date?

If there is not, how can I implement this to work with cron?


texts: How to add Shipping method for commerce flat rate module?

texts:
i am working on drupal commerce's "shipping" part, i want to create two methods for shipping as
1.Free Shipping
2.Express 2-day Shipping
for USA .

For "free shipping" condition is if order total is greater than $100 then we can use "free shipping" else it should apply rate $4.

for "Express 2-day Shipping" condition is if order total is less than $140 then we  can cost $12 else it is free.


texts:
I am wracking my brain to try to figure out how to retrieve a custom content type's edit form programatically.

For example, I created a content type called "address", and have this:

$form = drupal_get_form("address_node_form");

But it does not work. I get back this warning:

  Warning: call_user_func_array() [function.call-user-func-array]: First
  argument is expected to be a valid callback, 'node_form' was given in
  drupal_retrieve_form() (line 771 of
  /home/richardp/public_html/drupal7/d7/includes/form.inc).

I know that in D6 you also had to include an object where you specify the type, but I have tried this and it still doesn't work.

When I try simply $x = node_add("page"); I get a white screen of death, presumably because I ran into a PHP error.

Am I supposed to be including a file first or something like that?


texts:
I'd like to change the Date format of recent log messages (/admin/reports/dblog) in Drupal 8.9.1 from short date to something with the time. In Drupal 7 using watchdog I just edited the view and it was done. Since moving logging into core, I can't figure out where to edit the view. There is no view listed for Recent Log Messages or dblog and I can't find any other way to edit the date format. It's not an option in /admin/config/development/logging.
I know I can change Short Date globally to include time but I'm hesitant to change it everywhere just for an admin page. It seems like my only option is to create a new view with what I want and then replace the Recent page altogether.
Any help would be greatly appreciated.


texts: How do I alter the default node URL rendered in a view?

texts:
I have a view that shows a list of node titles, where the node title is linked to the node detail page. I want to alter the node URL with a custom one.

How can I alter the node URL?


texts: How prevent authorized users from responding to comments?

texts: How do I ensure that only administrators can reply to comments in sites such as content type? That is, if an authorized user views a node of the "content" type, he can leave a comment on it, but cannot reply to other comments, and a user with the administrator role can reply to all comments. How do I do this in Drupal?


texts: Update the author_uid for an entity registration

texts:
I'm looking to update the author_uid for an Entity Registration in Drupal 7 programatically. I want to replace all anonymous users with the UID of 0 with another UID lets say 2 upon saving the registration. I have tried three different solutions thus far to no avail.

Solution 1) Update the author_uid in the $form_state prior to saving the registration form.

<?php
function registration_form_alterations_form_alter(&$form, &$form_state, $form_id) {

    if ($form_id == "registration_form") {
        dpm($form);
        dpm($form_state);
        $form['#submit'][] = 'registration_form_alterations_custom_submit';

    }
}

function registration_form_alterations_custom_submit($form, &$form_state) {
    //  submit handler code
    dpm($form_state);
}

This didn't work because author_uid isn't available to be altered in form_state to the best of my knowledge.

Solution 2) Update via hook_entity_presave. I'm not sure this will work because I can't seem to isolate the actual registration entity to update the author_id in hook_entity_presave.

Solution 3) Use rules... Which doens't allow you to update the author_uid. A rules message screen comes back with a message about the value not being writable/editable.

Does anyone have any additional thoughts on this. Sorry I know its a bit of a weird request, but we have a user that wants anonymous registrations reassigned to them so that they can manage additional details associated with the registrations.


texts: How to open Fontello Icons in new tab or window?

texts: Coding/CSS/HTML is not my area of forte at all. I've figured out that this  (more or less) is how to make an external link open in a new window or tab. I'm working on a website that uses Fontello Icons for social media links and I'd like those links to open in a new tab/window so the individual would be able to keep a tab open with my website. Any and all help is appreciated!


texts:
I want to override the login page using panels. I found a tutorial that shows me how to do it using Panels Everywhere, but that overrides the whole page (with site_template).  I just want to override the page content.

Is this possible?


texts: How to redirect logged in users accessing /user/login to specific page?

texts:
This is a very specific case.

When a user is already logged in, and then tries to visit the login page, /user/login, they are redirected to their user page, /user.

This is a problem for me and I need them redirected elsewhere. To be clear, I'm not asking the much-asked question "how to redirect users after login". I'm already using r3042login and login destination.

The case explained

My site runs http and https for authenticated users. What's happening is that the user access the http site, then clicks login, logs in on https. Then the user presses Back, or a bookmark to the http site and they are not logged in (because they have a different session). So then they hit log-in, which redirects to the https site, which thinks "ah, you're already logged in!", and presents the user page. The user page is not of any interest to my users.

Ideally I'd have it such that once the https session was started, any access to the http site bounced them over to https again, until they logged out.


texts: How to create a 'button' which is linked to a Media Document with custom Link text?

texts:
I am trying to create the ability for a content editor to add a button to an entity which links to a Media Document. Essentially the requirements are that we can upload a file and that file is reusable so we don't have to upload every time and the text on the button is customisable.
Currently when I add a media reference field it just outputs the file as a download link using the Filename as the link text. I was hoping to be able to use something like Linkit but this just works in the WYSIWYG at the moment and also Linkit doesn't allow you to add the file within the same node form.
An interface like the link module would be fantastic. Where we could select the file in the URL field and then set the link text below.

Is there anything which currently exists to do this? or maybe could someone point me in the right direction to code something that works this way? Possibly I could add an accompanying field to the below widget where you can leverage the media library whilst allowing for custom 'link text'.


texts: View/edit permission of calendar ENTRIES based on role

texts:
I run a Drupal 7 site with several forums. Access to some forums is restricted based on user role permissions, e.g. users with user role 1 have access to forum 1 etc. I need a calendar functionality on my site. When a user with the user e.g. role 1 creates an event in the calendar, he should be able to decide which users with which user roles are able to see that event (either by creating the event when he is in the access restricted forum according to that role or by choosing the role from a drop down menu, both two possibilities will work for me, one is sufficient). The end result I'd like to have is that different users with different roles can look at the same calendar and see different entries based on the roles they have. They are supposed to see every entry that has been made available for at least one role the possess. They must not see entries that have only been made available for user roles that they do not possess.

So far I've tinkered around with the calendar module, views, rules and context. I have yet to find a way to make this work. Does anyone have an idea how to implement this?

Best regards!


texts: How to get a view result programmatically without exposed filters respected

texts:
I have some views of display page which I do not want to show to public if there would not be any result when accessed without any exposed filters set. I have a custom views access plugin and a custom access checking class which can handle the access granting.
My idea so far is that I would like to run the view a first time during access checking without exposed filters. In this way I could find out if the view would ever deliver any results. I tried it in the following way:
  $view = Views::getView($view_id);
  $view->setDisplay($display_id);
  $view->setArguments([$politician_id]);
  $view->execute();
  $result = $view->total_rows;

The problem is: as soon as an user comes to this page with query parameters in the url set by exposed filters these exposed filters are used for this view query as well. I did not find any way to tell the class in $view to execute without exposed filters. I even tried to set these exposed filters data in the following ways but even then the filter data in the query parameters is still used to filter the result set:
  $view = Views::getView($view_id);
  $view->setDisplay($display_id);
  $view->setArguments([$politician_id]);
  $view->initDisplay();
  $view->initHandlers();
  $view->setExposedInput([]);
  $view->exposed_data = [];
  $view->exposed_raw_input = [];
  $view->execute();
  $result = $view->total_rows;

I want to achieve that in this way because I want to use this logic for several views. It would be so smart to simply re-use the arguments and filters set in the views instead of hardcoding a new custom database query as the settings in the views might change. I hope someone can help me.


texts: Adding ".xml" at the end of custom route path

texts:
I am trying to create custom route which will look like a xml file like this example.com/my/custom/path.xml and I am getting NGINX 404, it won't even goes to Drupal.

I tried to research but I could not find anything helpful. Although I found out that if I use other types of extensions it is working, e.g. example.com/my/custom/path.html and example.com/my/custom/path.yml is returning Drupal response from my custom controller.

I suspect there is some config issue with .htaccess or in web-server config but I am not sure yet what is it that prevents .xml extension to work in route paths.


texts: (nginx) File field upload progress not working, but upload progress in FileField Sources works

texts:
Drupal 7.14, FileField Sources 1.4, Nginx, php cgi. File upload limit 1000MB. Using Chrome as browser

Everything has been configured fine.

I've tested using FileField Sources, upload about 700MB through Remote URL. Everything including the progress bar works without problem, even it takes too long time up be uploaded.

But when upload from my computer;

If upload small file, the upload progress is visible, but not showing any progress even the file uploaded as usual.

If upload large file, it will be same as above. But it will timeout (timeout after 30 seconds if using Chrome) (if using Opera, the timeout sometime after 17 seconds, sometime after 5 seconds).

The timeout error in Opera:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/field_hcuba/und/0/form-j39oCcFwF3Y4J8hBu8A1HHms9oDs3xuhYIgLoZ0MQ2Q
StatusText: n/a
ResponseText: 413 Request Entity Too Large
nginx
ReadyState: undefined

The timeout error in Chrome:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/field_hcuba/und/0/form-1smxhyxT7Xw1F6zjZul2gRxkMI7DNF8pkPRTUyW35SU
StatusText: n/a
ResponseText:
ReadyState: undefined

This only happen in Nginx server. In Apache, all works without problem.


texts: How do I add additional query arguments through the Views API?

texts:
I've implemented hook_views_query_alter($view, $query) where I'm replacing a field with a subquery (which returns a single COUNT value). However, even though it works very well to replace the field with a subquery, I'm having trouble adding one
or more arguments to that subquery. Say I've got this query :

SELECT tid, (SELECT COUNT(*) FROM {download} AS d WHERE d.tid = t.tid AND d.updated > :timestamp) AS downloads FROM {track} AS t

I'd like to get a track and the number of downloads for that track after a certain point in time. I would thus need to set the ':timestamp' argument for the query. However, I can't figure out how to do that for Views.

Does anyone have experience with this? Either how to provide a subquery as a field (and not condition as in "WHERE) or how to just set an extra argument directly on the $query object.


texts: Loading content alone for each page from drupal to other site?

texts:
How to load only content in a page (exclude header & footer) from once specific drupal site to another non-drupal site page.

Like, if I click on link on non-drupal site it should open up drupal content of respective link page without header and footer in a new popup.

I know Iframe and webservice are options to do.

Is there any other way to load content for specific page in drupal to non-drupal site ? Thanks in advance.


texts: How to collect payments for the missed periods with the hard decline status?

texts:
Scenario: A user's credit card expires and he misses to pay his recurring monthly fee. Two months later he updates his credit card and because the license never expired the system picks it up and continues to successfully charge his card on file for consequent periods, but unfortunately not for the previous.

And it's not clear how to charge for the missed payments with the "Payment failed (hard decline)" status. Any suggestions?

Edit: I had to delete my own answer:

  It was not obvious for me that I needed to use Commerce Dunning module
  to re-charge for the missed payments.

after trying the Commerce Dunning module, because unfortunately for hard declines it only sends notifications without attempting to re-charge for the missed period even if a customer updated his credit card. Per description on https://www.drupal.org/project/commerce_dunning:

  If it was a hard decline that led to the failure, the customer needs
  to update their credit card, so notifications regarding that are also
  scheduled.

So unfortunately it is still not clear how to collect payments for the missed period.


texts: Table 'watchdog' was not locked with LOCK TABLES on custom module

texts:
I am creating module that need to lock table:

db_query('LOCK TABLES {eventi_list} READ');

$is_booked = _is_booked($uid, $nid);
if (! $is_booked) {
  $is_booked = _is_booked($uid, $nid, 'eventi_waiting_list');
}

if (! $is_booked) {
  $amount = _get_free_amount($nid);
  if ($amount > 0) {
    $insert = db_query("INSERT INTO {eventi_list} (uid, nid) VALUES($uid, $nid)");
  }
  else {
    $time = time();
    $insert = db_query("INSERT INTO {eventi_waiting_list} (uid, nid, created_at) VALUES($uid, $nid, $time)");
  }
  $update = db_query("UPDATE {content_type_event} SET field_event_places_amount_value = field_event_places_amount_value - 1 WHERE nid=$nid");
}
db_query('UNLOCK TABLES');

I am getting error (4 similar warnings):

Warning: Table 'watchdog' was not locked with LOCK TABLES query:
INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (19, 'php', '%message in %file on line %line.', 'a:4:{s:6:"%error";s:12:"user warning";s:8:"%message";s:139:"Table eventi_waits was not locked with LOCK TABLES query: SELECT count(nid) AS count FROM eventi_waits WHERE nid=201 AND uid=19";s:5:"%file";s:95:"D:\tools\xampp\htdocs\drupal\sites\bartenders.localhost.com\modules\\custom\eventi\eventi.module";s:5:"%line";i:115;}', 3, '', 'http://bartenders.localhost.com/bartender/book/201/%3Fdestination%3D/eventi/justin-knows', 'http://bartenders.localhost.com/eventi/justin-knows', '127.0.0.1', 1303900341) in D:\tools\xampp\htdocs\drupal\includes\database.mysqli.inc on line 135

What can I do with this, turn off database reporting?


texts: How to migrate PDF files to specific node

texts:
I have a directory with PDF files and I have 45 nodes of content type Download. I have to migrate each PDF file to specific node. All PDF file names I read from a CSV. Before these PDF files, I had to migrate title (drupal default field) , external title and a checkbox field to each node. I did it successfully, but migrating PDF files is I guess different and a lot more difficult.
Here is my code for migrating PDF files
id: program_files
label: Migrating files for Download content type.
migration_tags:
  - file
source:
  plugin: csv
  path: 'modules/custom/csv_migration/sources/downloads.csv'
  header_row_count: 1
  ids: [constants/file_source_uri]
  keys:
    - PLACEMENTPATH
  fields:
    0:
      name: field_document_file
      label: 'Download file'
  constants:
    file_source_uri: [public://import/program]
    file_dest_uri: ['public://download/files']
destination:
  plugin: 'entity:file'
process:
  file_source:
    -
      plugin: concat
      delimiter: /
      source: [constants/file_source_uri, PLACEMENTPATH]
  file_dest:
    -
      plugin: concat
      delimiter: /
      source: [constants/file_dest_uri, PLACEMENTPATH]
  filename: PLACEMENTPATH
  uri:
    -
      plugin: file_copy
      source:
        - '@file_source'
        - '@file_dest'

Once I run command drush ms it displays me migration id (program_files), but after that when I run drush mim program_files, it throws the error like this.
In Connection.php line 744:

  Placeholders must have a trailing [] if they are to be expanded with an array of values.

The thing I notice once I start drush mim program_files is that directory download is created in sites/default/files, since I defined that in YML, but no files are transfered.
What am I doing wrong? Please, help.


texts: How to validate file is selected or not on ajax processed jquery validation

texts:
I am trying to do jquery validation on file upload for file is select or not. I want when user click on upload before submit check file is selected or not. if not stop ajax request. Any Idea to validate it?

$videoForm['profile_photos']['images']['field_photo'] = array(
    '#parents' => array('video', 'field_photo'),
    '#id' => 'field_photo',
    '#type' => 'managed_file',
    '#title' => 'Photo <em>(optional)</em>',
    '#field_name' => 'field_photo',
    '#process' => array(
    'm_customer_profile_image_remove',
    'm_customer_profile_image_upload',
    'file_managed_file_process',
        'customer_profile_image_preview',
    ),
    '#upload_location' => 'public://' . $user->uid,
    '#limit_validation_errors' => array(array('video', 'field_photo')),
    '#upload_validators' => array(
        'file_validate_size' => array(64*1024*1024),
        'file_validate_extensions' => array('gif jpeg jpg png')
    )
);


texts: Determining current user's relationship to node author

texts:
I'm currently using User relationships module, and setting the UR-Node access module so that nodes can only be viewed by users related to the author.

However, I want to have a public display version of the node for search engines, sharing links, and also for a button to say 'You need to become friends with x to see this node'.

So, I was thinking of using the User relationships API to determine the users' relationship, and output two different displays in the tpl.php file.

Does anybody know how to determine the relationship programatically? I'm stuck.

(I've done this in the Views I've made, it's just in the nodes, that I'm having trouble)


texts: Send html-Mail to new simplenews subscriber

texts:
I have installed simplenews and I want to send follow-up HTML-Mails to newly newsletter subcribers after one, two and three weeks. It only works to send a mail immediately after subscribtion (via rules), but not with the time delay (via rules and rules scheduler)

What I did:
I created a new rule with the event "a user has been subscribed". I added an action with a new component "send follow-up emails" with the identifier "Follow-up email for [mail:value]"
In the component I use [mail:value] as recipient address. As data type I choose "User", but I think, thats wrong. The simplenews subscribers are not registred users. No idea which data type I need.

Any Ideas?


texts:
Is there such thing as a post-save type of case in the node_api function or any other type of function? This question is in reference to a question I posted What operation should I use to write node's information in an email when the node is saved?

I want to be able to have something happen after pressing the save button, but AFTER the saving into the database has been completed. I have tried 'update' and 'insert' and they don't seem to work.

EDIT: heres my code

case 'presave':
    {
        if(($node->type == 'team_practice_info') | ($node->type == 'schedule'))
        {

            if(!empty($node->field_alert[0]['value']))
            {
                if($node->field_alert[0]['value'] == 'on')
                {
                    //email out to everyone an email about the content change/update
                    $query = db_query("SELECT *
                                       FROM {content_type_athletics_alert}
                                       JOIN {content_field_team}
                                       ON content_type_athletics_alert.nid = content_field_team.nid
                                       WHERE content_field_team.field_team_nid =
                                            (SELECT field_team_nid
                                             FROM {node}
                                             JOIN {content_field_team}
                                             ON node.nid = content_field_team.nid
                                             WHERE node.nid = %d)", $node->nid);
                    $rows = array();
                    //db_fetch returns an array of the next row in the query
                    while ($row = db_fetch_array($query))
                    {
                        //pull out the email from the array, then send an email to each subscriber
                        $email = $row['field_email_address_value'];
                        $first_name = $row['field_first_name_value'];
                        $last_name = $row['field_last_name_value'];
                        $t_id = $row['field_team_nid'];
                        $t=node_load($t_id);
                        $sport = (current($t->taxonomy));
                        $team = $t->title.' '.$sport->name;

                        alert_message_mail_send($email, $first_name, $last_name, $team, $node);
                    }
                    //reset the alert checkbox to off
                    $node->field_alert[0]['value'] = 'off';
                }
            }
        }
    }

   break;


texts:
Using Feeds, I am trying to import products from a source CSV.  One of the CSV columns contains the quantity of items in stock.  The goal is to map it to a product 'Stock Status' field.  If the quantity field is greater than zero, 'Stock Status' is 'In Stock'; if zero, 'Stock Status' is 'Out of Stock'.

I didn't see a Feeds Tamper plugin or combination of plugins that would work and my attempts to use Rules so far have failed.

Thank you in advance for any help.


texts: Hi Im using D6 do I have to make the meta output so people can see the meta data if I select to not output the meta tags so viewerss will not read my meta data will this affect my search engine optimization (do the robots still read my meta or not?)


texts: Large amount of entity revision cleaning leads to connection abortion

texts:
I am trying to remove revisions from each entity type which has the revision feature via drush command.
The amount of entities are quite a lot: around 10K nodes, 2k paragraphs.

On localhost everything is fine.
But in the cloud the drush_print($log) successfully runs and the following error appears:

 [warning] PDO::beginTransaction(): MySQL server has gone away Connection.php:1165
 [warning] PDO::beginTransaction(): Error reading result set's header Connection.php:1165

In Connection.php line 1165:

  SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

The two environments are close to identical. Any suggestions where could I start to investigate?


texts: After indexing items are not visible, solr server

texts:
After indexing the items aren't visible on the page. The index does work, but after refreshing the page, the indexed items aren't shown on the page.

View index > Queue all items for reindexing > Index now > {the indexing operation works but the items don't show}

I installed the facet api and search api again, but nothing changes.

Warning messages in solr:

XML parse warning in "solrres:/schema.xml", line 537, column 89: Include operation failed, reverting to fallback. Resource error reading file as XML (href='schema_extra_fields.xml'). Reason: Can't find resource 'schema_extra_fields.xml' in classpath or '/Users/{namePC}/Desktop/solr-4.10.2/drupal-search/solr/collection1/conf'

Multiple requestHandler registered to the same name: /update ignoring: org.apache.solr.handler.UpdateRequestHandler

[collection1] PERFORMANCE WARNING: Overlapping onDeckSearchers=2

I'm using a solr server. Does anyone know what the problem is?


texts: How to debug why some content is not migrated from D7 to D8?

texts:
I am using migrate_plus to migrate from D7 to D8 and so far it has been a fairly smooth process.

I have a particular content type that has 10 nodes in D7 but will only migrate one of them to D8.

After running the migration, one node is reported to exist and is successfully migrated. There are no messages related to the migration so I don't have any issue to remedy, yet only one of the ten nodes are migrated.

Can anyone suggest a way to dig into why this might be happening and/or how to get the missing nodes to migrate?


texts: In the past, I have used the Fusion theme for designing web sites. Recently I started using the Omega theme, and realized a big problem with it. I went to look at it in IE, and it looks terrible. In Fusion, there is an IE fix in which, there is a separate css file for ie. I can't seem to figure out how to do this in omega. I know that there has to be a way, because the acquia site is themed in Omega, and it looks fine in IE. how is it that I go about fixing this problem?


texts:
I have a content type form with some fields attached. I'm looking for an easy way of skipping core validation for one of those fields. I guess what I'm looking for is something like this:

$form['foo']['#check_valid'] = FALSE;

This could possibly be achieved using #limit_validation_errors, but this would require some work. Can this be achieved without too much of a hassle?


texts: Enable/disable a menu item programatically depending on a variable value

texts:
I need to show a menu item only in certain moments. Imagine that I've a form with some options. If 'A' is selected, I need to enable a menu item that has a form for adding information about 'A'.

I have done a module that has a hook_menu like this:

> function secciones_menu() {
>
>
>   $items = array();
>
>       $items['secciones'] = array(
>           'title' => t('Crear Sección'),
>           'description' => t('Crear Secciones'),
>           'page callback' => 'drupal_get_form',
>           'page arguments' => array('secciones_wizard'),
>           'access callback' = TRUE,
>           'type' => MENU_NORMAL_ITEM,
>           'menu_name' => 'main-menu',         'customized' => 1, // Must be 1 in order to not dispaly the link in any language
>           'language'  => 'es', // language is required in order to make the item translatable   );

return $items; }

And then have my form for 'A'. So how I can enable or disable the menu item, depending a variable value?

Thank you !

EDIT 1:

What I've done is change the access callback and the menu type:

function agenda_menu() {

  $items = array();

  $items['agenda'] = array(
        'title' => t('4. Crear agenda'),
        'description' => t('Crear agenda'),
        'parent'=>array('Configurar Revista'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('agenda_wizard'),
        'access callback' => 'agenda_access_callback',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'menu_name' => 'main-menu',
        'customized' => 1, // Must be 1 in order to not dispaly the link in any language
            'language'  => 'es', // language is required in order to make the item translatable
  );

  return $items;
}

And then I've done the next code:

function agenda_access_callback(){

    //db query
    //insert that query in $options array
    foreach ($result as $row) {
        $options[$row->id_seccion] = $row->id_seccion;
    }

    if(isset($options)){ //if the array is not empty
        return TRUE; //the menu item is visible
    }
    else{
        return FALSE; //otherwise, is not visible
    }
}

Ok, this is what I have done, but it doesn't work. Any idea? Thank you.


texts:
I'm implementing hook_menu to add a new tab to the user account page. I'd like to pass a URL as the page callback (a local URL for an existing page on the site). the page_callback parameters just accepts a function name.
How would I go about using that to pass a URL?


texts: How to detect when a user navigates to a taxonomy term page and access that terms data?

texts: I'm making a custom directory navigation using the PHP code filter, and putting the code in a block. I need to detect when a user navigates to a taxonomy term page, and extract data related to the term so I can display the children of that term, just like a web directory.


texts: Views aggregation compress using multiple fields combination

texts:
Good day,
I saw Views Agreggation allows to group+compress una field only.
I need to have a grouping action of a combination of fields, this is how I can figure it out:

TABLE:

product | color | origin  | value
----------------------------------
p0001   | green | america | 150.00
p0002   | green | america | 180.00
p0003   | red   | africa  | 180.00
p0004   | red   | asia    | 180.00
p0005   | red   | america| 180.00

I need this GROUPED RESULT:

product     | color | origin  | value
----------------------------------
p0001,p0002 | green | america | 330.00
p0003       | red   | africa  | 180.00
p0004       | red   | asia    | 180.00
p0005       | red   | america | 180.00

Both, color and origin are my keys to group, and the value is a sum, product is grouped comma separated.

I do not know if it was clearly explained. Thanks


texts:
I'm on hook_form_alter for the config edit form. The code runs for all fields, but it's critical that the code figures out the name of the field it is on.

When I load the formobject, I can see the field_name perfectly when I print_r the array. But I can't figure out how to pull it out. Something like $name=$field['field_name']

The field name is 'field_plan_purpose' I need to get that in a variable in the code.

My code minus all of things I've tried:

$field = $form_state->getFormObject()->getEntity();
print '<pre>';
print_r($field);
print '</pre>';

Here is the top part of the array that gets printed:

Drupal\field\Entity\FieldConfig Object
(
    [deleted:protected] =>
    [fieldStorage:protected] => Drupal\field\Entity\FieldStorageConfig Object
        (
            [id:protected] => node.field_plan_purpose
            [field_name:protected] => field_plan_purpose <--- HOW DO I GET THIS
            [entity_type:protected] => node
            [type:protected] => text_long
            [module:protected] => text
            [settings:protected] => Array
                (
                )

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

            [deleted:protected] =>
            [schema:protected] =>
            [propertyDefinitions:protected] => Array
                (...

As you can see, 'field_name' is in there. Does anyone know how I can pull that out and reference it directly?

A few things I've tried:

    // print_r($field->getEntityKey('#field_name'));
    // getEntityType()->getKey('field_name')
    // $field['field_name']  $field['field_name:protected']
    // $field['id']
    // $field->getKey('field_name')
    // $field->definition['field_name'];
    // print_r($field->definition);

EDITED ******* SOLUTION

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

   $field = $form_state->getFormObject()->getEntity();
   $field_name = $field->getName();
   print $field_name;

}


texts: Conditionally load JS based on whether or not a field has data?

texts:
I'd like to load a javascript file only if a specific field has data. Can this be done with a preprocess function in template.php? Something like:

if this field is not empty
  add the js to the page footer
else do nothing

Is there a more efficient way?


texts: Attaching comments to blog post promoted to front page

texts: I have 'blog posts' that are promoted to the front page. We would like to have the ability to have users posts comments on these posts through the front page without having to click through to get to the posts page.


texts: Is There A Way To Remove Kickstart Demo Product Types Without Emptying Database?

texts:
Is there are a (safe) way to delete the demonstration Product Types in Commerce Kickstart 2 without the entire Drupal install?

It appears that the Commerce Kickstart 'Reset' function simply empties the entire db. (yikes).

I've read many discussions on this but they tend to go back to 2011. I was hoping there was a more current (and hopeful) answer. We want to get rid of all the 'Drinks', 'Tops', etc. but keep the Products/Types and other content we've created.


texts: How to consume custom fields in RSS feeds

texts:
I'm sharing data between two Drupal sites using the Aggregator and Views modules (created a Feed to look at a content type).

This works, but the problem is that the source server places CCK fields within the description field, so when I try to use those fields in the destination view (e.g to filter content), the view doesn't about the CCK fields.

Is there anyway to make the CCK fields render as regular fields in the RSS? Like title or author?


texts:
I have a case scenario in which different organic groups can have different themes. Using "Themekey" I allow the user to select a theme when the group node is created and it works fine. When the user is on the group's home page the right theme is selected but when you click on any content (i.e. group content type) that belongs to that group the theme goes back to the default theme. Is there anyway to apply the parent group theme to all content automatically?

Thank you.


texts: D7 in sub directory - Not able to log in

texts:
I have a Drupal site I need to show for portfolio reasons so I have installed it in a sub directory.

I have changed the rewritebase to /subdir

Initially without that change I was served the homepage just fine but no interior pages. With that change I was able to get deeper into this site but when I went to login the backend it loaded forever and spit out this error:

  Additional uncaught exception thrown while handling exception.

  Original

  PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC; Array ( [:alias] => user [:language] => en [:language_none] => und ) in drupal_lookup_path() (line 176 of /home/content/k/c/l/name/html/fsubdir/includes/path.inc).

  Additional

  PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:284:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT source FROM {url_alias} WHERE alias = :alias AND language IN (:language, :language_none) ORDER BY language ASC, pid DESC; Array ( [:alias] =&gt; user [:language] =&gt; en [:language_none] =&gt; und ) ";s:9:"%function";s:20:"drupal_lookup_path()";s:5:"%file";s:61:"/home/content/k/c/l/name/html/subdir/includes/path.inc";s:5:"%line";i:176;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://mydomain.com/subdir/?q=user [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => 173.10.171.18 [:db_insert_placeholder_9] => 1354293470 ) in dblog_watchdog() (line 157 of /home/content/k/c/l/name/html/subdir/modules/dblog/dblog.module).

Can anyone point me in the right direction to get this resolved?


texts: Need to automatically rotate the result of a view once a week (Sunday night)

texts:
The view (block) displays content (field collection items) on my home page.  I had it set so the client could choose what to display by checking a boolean field.  The view works fine, but now the client has decided they would like the content to be chosen randomly and for it to be automated (to change on a weekly basis).  I need every user to see the same content displayed and I need the same content to stay up a whole week.

What is the best way to accomplish this?  I've tried setting the display to show only 1 and sort on random with the view cache set to 6 days/6 days.  I'm just not sure how reliable this will be.


texts: Multiple pieces of data attached to multiple states

texts:
I want to have two fields attached to each state a user selects on a multiple select form field - they can select as many states as they want.

Each state will then have a text field and a date field attached to it.

How do I do this? I can can't figure out a way to make this data optional.

So basically it would go as follows:

State
textfield associated with state
date associated with state

and this, up to 50 times, but optional aside from one instance.


texts: Change the path used by a route dynamically

texts:
Taxonomy terms have a canonical path of /taxonomy/term/{taxonomy_term} by default, which displays a View with content tagged with that term.
For certain taxonomies I would like to use a different view, dependent on the taxonomy bundle, so I can't just override the path entirely.
For example, "article" tags should link to /articles/{taxonomy_term}, "product" tags to /products/{taxonomy_term}.
My idea is to override the entity.taxonomy_term.canonical route adding some kind of callback that generates the path dynamically based on the taxonomy_term. Is this possible?


texts: How to output child links based on the current page

texts:
When landing on a page which has a menu item that is a parent to other pages menu items, I would like to be able to show a list of those child menu items. I am using the following code.

$trail = menu_get_active_trail();
menu_build_tree('main-menu', array(
  'expanded' => array($trail[1]['mlid'])
));

However, the returned array looks like this (with a lot of unnecessary removed).

array
'49950 PKY Truck Beauty 312' =>
array
  'link' => &
    array
      'menu_name' => string 'main-menu' (length=9)
      'mlid' => string '312' (length=3)
      'plid' => string '311' (length=3)
  'below' =>
    array
      '49952 Seminars 314' =>
        array
          'link' => &
            array
              'menu_name' => string 'main-menu' (length=9)
              'mlid' => string '314' (length=3)
              'plid' => string '311' (length=3)
      '50000 HDMA Breakfast 316' =>
        array
          'link' => &
            array
              'menu_name' => string 'main-menu' (length=9)
              'mlid' => string '316' (length=3)
              'plid' => string '311' (length=3)
      '50000 MATS Concert 315' =>
        array
          'link' => &
            array
              'menu_name' => string 'main-menu' (length=9)
              'mlid' => string '315' (length=3)
              'plid' => string '311' (length=3)

Notice how 314, 315, and 316 are 'below' 312? They are siblings in my menu structure, and that seems to be verified by each one having the same value for plid (311).  Obviously I can fix this by passing the array through another function, but I can't help but think I'm just missing something.


texts: Is safe adding uid=0 in users table just to use $_SESSION?

texts: I read many articles about adding it, but I'm not encouraged to use it yet. People says that Drupal doesn't add this user because MySQL Auto-increment starts at 1. So, about adding uid=0, is it a good practice? Is it widely used? What possible problems could I have with it? Thanks. :)


texts: Display blocks on taxonomy and content type pages

texts:
I have a taxonomy menu block. I need to show this block on some taxonomy term pages for a particular vocabulary and on some content type node pages in second sidebar region (bartik theme).

How can we achieve this? Is there any module available? Or can we do it programmatically using a custom module or in the theme's template.php file?


texts: Drush does not run remotely, SSH does not see Drush

texts:
I had Drush 4.
Then I deleted Drush folder and installed Drush 8 through Composer for my user.
Now drush command works on a server for my user.

Then I try to invoke drush from my local computer it does not work:

drush @myalias status -v
Loaded alias @myalias from file /home/myuser/.drush/site-aliases/aliases.drushrc.php                                                                                [notice]
Begin redispatch via drush_invoke_process().                                                                                [notice]
Calling proc_open(ssh myserver 'env COLUMNS=199 drush  --verbose --uri=my.site.com --root=/my/web/path  core-status 2>&1' 2>&1);
env: drush: No such file or directory
End redispatch via drush_invoke_process().

So I localized the problem - Drush does not work through SSH, but it works on the server under the same user.

ssh myalias 'drush'
bash: drush: command not found

I tried  unsuccessfully:
Add export PATH="$HOME/.composer/vendor/bin:$PATH" or  PATH="~/.composer/vendor/bin:$PATH" to
.bashrc and .bash_profile.

But it works:  ssh myalias  '~/.composer/vendor/bin/drush'


texts: Error when I try to make a local translate.

texts:
I get this error when I try to make translation:

  Not saved locally due to invalid HTML content.

take a look a my capture, first one shows the text to be saved as the translation, and the second capture shows the error message:


texts: Establish whether a node is NEW in a custom #submit function

texts:
I need to test whether a user is creating a new node as opposed to editing an existing node in a custom #submit function added to a node edit/creation form.

I can access the node via

$node = $form_state->getFormObject()->getEntity();

$node->id() - gives the new node ID so cant be used.

$node->get('nid')  - also gives an gives the new node ID so cant be used.

$node->isNew() - This is actually FALSE in this hook despite it being new content.


texts: Hide/Show certain fields with rules based on userpoints

texts: Is there a way to show/hide certain fields using rules and only show those fields by spending userpoints?


texts: hook_node_insert PDOException exception issue

texts:
I am attempting to programmatically insert some field data when a new node is being created using the following code:

function mymodule_node_insert($node) {

    $dialects = array('en-AU', 'en-NZ', 'en-US');

    node_object_prepare($node);
    foreach ($dialects as $dialect) {
        $node->translations->data[$dialect]['entity_id'] = $node->nid;
        $node->translations->data[$dialect]['entity_type'] = 'node';
        $node->translations->data[$dialect]['revision_id'] = 3;
        $node->translations->data[$dialect]['language'] = $dialect;
        $node->translations->data[$dialect]['source'] = 'en';
        $node->translations->data[$dialect]['uid'] = 1;
        $node->translations->data[$dialect]['status'] = 1;
        $node->translations->data[$dialect]['translate'] = 0;
        $node->translations->data[$dialect]['created'] = time();
        $node->translations->data[$dialect]['changed'] = time();

        $node->field_page_body[$dialect] = $node->field_page_body['en'];
    }
    node_save($node);
}

However, I recieve the following error:

I understand it's complaining about the same node ID being saved twice but I'm not sure how to avoid this exception and update my new node with the programmatically set data?

It's important I execute my code at hook_node_insert because there are hundreds of nodes to be imported later and they all need the same treatment.

The same code works when tested in mymodule_init().


texts:
I need to create a views block, that is shown on a node page that outputs a link to the next node that comes in the sort logic (defined in a view).

The module flippy does not work as it does not respect filters.

I am pretty sure that this can be achieved in views only.

How would I set up a view?


texts: Anonymous user can view unpublished content

texts:
Is there any way anonymous users can access unpublished pages using view?

I have a REST api for a custom content type that has setting of unpublished content and I want anonymous users can access it.


texts: Why is INPUT field size different across platforms? OS X vs Windows?

texts:
I have a drupal created form where I have set the size of the form:

$form['myform']['#size'] = 22;

Now on my windows machine on Chrome / FF / IE / Safari it is a specific size, visually.

When I go to view the same form on my Macbook the same INPUT field is significantly smaller in Chrome / FF / Safari on OS X ??? Even though both obviously have the size = 22 setting?

Why is it not rendering the same size across all platforms??


texts: How to save the user submitted values of a multi-step user registration form?

texts:
I would like to create a multi-step user registration form in Drupal 6. The form_alter details are below

function caubo_registration_form_alter(&$form, &$form_state, $form_id) {
if ($form_id != "user_register") return;
 if (isset($form_state['storage']['page']) && $form_state['storage']['page'] == 2) {
caubo_register_page_two($form, $form_state);
return;
}
$form['submit']['#value'] = "Next";
$form['#submit'] = array('caubo_register_form_submit');
return;
}

// Second page of registration
function caubo_register_page_two(&$form, &$form_state) {
  $form['company_name'] = array(
'#type' => 'textfield',
'#required' => 1,
'#title' => 'Company Name',
'#default_value' => '',
'#size' => 50,
'#maxlength' => 50,
);
  $form_state['storage']['page'] = 3;
return $form;
}

function caubo_register_form_submit($form, &$form_state) {
switch ($form_state['storage']['page']) {
case 0:

  $form_state['rebuild'] = TRUE;
  $form_state['storage']['page'] = 2;
  $form_state['storage']['page_one_values'] = $form_state['values'];
  break;

case 3:   // This is form submission, insert into Database
  insert_values($form, $form_state);
  break;
}

function insert_values(&$form, &$form_state){
$insert = "INSERT INTO user_detail_values SET
            mlm_plan='binary',
            user_name='admin'";
$result = db_query($insert);
}

But in the last step the function insert_values() is not called, the submitted data's not inserting into the database. I have searched in google, but i didn't get the solution. How to fix it ?


texts: When showing Fields as the format on a Views RSS feed, what should I set the GUID to?

texts: I have a Views feed that I want to show as fields to customize the display.  As you can see from the screenshot, I have configured the fields in the appropriate rows.  However, I don't know what to set as the GUID.  Should it be the title?  The link?  Is there a "default" setting for this?


texts: Reusable views behavior, but none of the known plugins

texts:
I would like to create a reusable behavior for D7 Views 3.

E.g. the purpose could be to display exposed form and pager in one line with css float. Or it could be to move one part of the exposed form to a sidebar block.

I know I could create a pager plugin or an exposed form plugin. But what if I already chose a specific plugin for each of these? E.g. better_exposed_filters for the exposed form.

Theme overrides, preprocessors, CSS?

The effects I am thinking about can be achieved with overridden views-view--page.tpl.php, theme preprocessors, and css overrides.

However, the question is, what should trigger these effects?
The typical strategy would be to write e.g. a views-view--myview--page.tpl.php (and similar strategies in css and preprocessors).
But this will hardcode a specific view id, and won't be easily reusable on other views. Or I have to hardcode even more view ids.

What I want instead is to be able to activate the behavior in the views configuration. So when I clone the view, the behavior will also be activated in the clone.

Abuse other plugins types?

One idea I had was to "abuse" the view header plugins. So I would create a header that does not do anything by itself. But then a preprocessor would change the template for any view where this header is activated.

I am sure this works and it does provide the reusability, but it feels wrong, and will be confusing to anyone using it.

Custom settings with hook_form_alter()

Maybe.. a new checkbox in my view where you can enable specific extra behaviors. Is this a good idea? What would be the natural place for such a setting?


texts: How to configure the default visibility to "Only the listed pages" when adding a block?

texts:
When adding a block to the site:

Home » Administration » Structure » Blocks

the default setting for visibility is set to "All pages except those listed." is there a way to set the default setting to "Only the listed pages"?

I'd guess that this possible w/ a custom module but I'd rather avoid that.


texts: Links stopped working for logged in admin user

texts:
Please help me with this urgent problem:
after some modifications all links on my site stopped working. I can hover them and see the url, but on click nothing happens. No WSOD, no error page, just no action at all. As if the link behaviour is gone. When I log out by typing .../user/logout in the adress bar, all links work as normal.

System: drupal 7 with open atrium latest version

Modifications I made just before the problem started:
- installed colorbox library
- added sites/default/files/* in colorbox>advanced>exclude pages (why? because I could'nt get colorbox working and some site mentioned to do this, can't find back the link)
- cleared cache

Problem is: I can navigate to /admin/config/media/colorbox, I can delete 'sites/default/files/*' from the excluded pages, but I can NOT submit the form so the changes take effect, because links don't work.

Please help, I've googled every possible search combination, but no result...

What else could have caused this problem?

Many thanks in advance.


texts:
I'm struggling to add metatags fields to my panels pages using the Metatags module (or in any other way). I'm using the latest version of the Metatags module (8.x-1.14), and there is no option in the - admin/config/search/metatag/add -  to configure fields for a panels/ page manager page.
Can anybody help?


texts: Is there a drush script to disable all caches?

texts:
I mean all of the caching options under admin/settings/performance. I frequently use drush sql-sync to keep my development copy up-to-date with the server. However, the server must have all of the caches turned on, obviously.

So I wonder: must I visit admin/settings/performance every time I update my db? Or is there a Drush script for that?


texts: Dynamically change email recipient in webform based on dropdown list

texts:
I have a reservation form for booking restaurants. All restaurants are added dynamically into the webform using Webform Views Select.

When the user selects resturant1, that restaurant should get an email of the reservation. Restaurants are nodes and, when I add them, I add an email field too, so this is in the database. But still I can't figure out how to make this work.

I know I need to use rules but I'm not really sure how to set it up.


texts: Using composer to install Drupal 8 on Debian 9 (Stretch)

texts:
I have already installed various Drupal 8 sites using composer in various environments and I am trying to do it now on a Debian 9 server>

I have done the installation in a sub-directory of /var/www/html (the standard document root on Debian 9). This directory and all directories under it are owned by root (and that is different from Debian 8 where these were owned by www-data) and readable by all other users.

Aside the standard enabled apache2 site (that I have given a servername because otherwise it captures all htpp requests to the machine), I have created a second virtual host with the following configuration file:

<VirtualHost *:80>
ServerName xxxx.be
ServerAdmin xxxx@gmail.com
DocumentRoot /var/www/html/xxxx/web
<Directory "/var/www/html/xxxx/web">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/xxxx/error.log
CustomLog ${APACHE_LOG_DIR}/xxxx/access.log combined
</VirtualHost>

I have enabled the site and restarted the apache2 server. Now I want to proceed with the Drupal installation but accessing http://xxxx.be, I get:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at xxxx@gmail.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error.log.

In the access.log file I find:

192.168.178.150 - - [15/Aug/2017:19:13:28 +0200] "GET / HTTP/1.1" 302 583 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
192.168.178.150 - - [15/Aug/2017:19:13:28 +0200] "GET /core/install.php HTTP/1.1" 500 799 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"

In the error.log file:

[Tue Aug 15 19:13:28.611964 2017] [core:error] [pid 24071] [client 192.168.178.150:53144] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

When I try to go via the standard enabled site (http://.../xxxx/vendor/drupal/core/install.php), I get a white screen and in the access.log I see that the installation script is started but I get errors:

[Tue Aug 15 19:25:14.592850 2017] [:error] [pid 24072] [client 192.168.178.150:53174] PHP Warning:  require_once(/var/www/html/xxxx/vendor/drupal/autoload.php): failed to open stream: No such file or directory in /var/www/html/xxxx/vendor/drupal/core/install.php on line 34
[Tue Aug 15 19:25:14.592940 2017] [:error] [pid 24072] [client 192.168.178.150:53174] PHP Fatal error:  require_once(): Failed opening required '/var/www/html/xxxx/vendor/drupal/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/xxxx/vendor/drupal/core/install.php on line 34

I know this must be a configuration error somewhere but I cannot find what it is.

Suggestions are appreciated.


texts: How can I disply the regex match in a view?

texts:
This is a Drupal 7/Views 3 question.

I am using a regex as a filter in a view to select Body fields with certain characteristics. However, when it comes to displaying the field, I don't want to display the entire body, just the match or matches.

For instance, for the following filter on the Body field for a match on regex:

<h[23456]>[^<]*[.!?:;,][^<]*</h[23456]>

I want to display a views Body match column which only displays any regex matches, not the entire Body field. So in this case I only want to display headings that have punctuation in them which are contained within the body.

This will not display to the public, so I'm not concerned with whether it's pretty, only whether it's readable. So it doesn't matter whether it displays HTML as HTML or as plain text.

However, the Rewrite Results field in the fields edit does not provide an option to match on regex for displaying the text.

How can I accomplish this?


texts: 500 error: Output filter: Response body too large

texts:
I recently copied a drupal 7 site from my development server to my production server. Everything on the site seems to be working as expected, except for when I log in as the admin user and try to access admin/modules. When I go there I get a 500 "Internal Server Error" page. In the server's error log, I get: ModSecurity: Output filter: Response body too large (over limit of 6291456, total not specified). [hostname "(my hostname)"] [uri "/drupal/index.php"] [unique_id "T4JOln8AAAEAAFLlyE4AAAAK"]

(unique_id changes every time I get the error, but the other parts don't.)

Any idea what could be causing this?


texts: Fontawesome icons showing above label instead of inline with textfield

texts:
After installing fontawesome module on drupal 8 site, I tried the following:

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['street1']['widget']['#prefix'] =
      '';
}

The "envelope" icon shows up quite alright -but its showing above my "Street Address" label, instead of inline before the actual input textfield.

Viewing source of my page shows the following:

        Street address
        <input class="js-text-full text-full form-text required" data-drupal-selector="edit-street1-0-value" type="text" id="edit-street1-0-value" name="street1[0][value]" value="" size="60" maxlength="255" placeholder="" required="required" aria-required="true" />

Clearly the fontawesome "i class" tag is actually above the "label" tag.
Please any ideas how to remedy the situation and show the icon just to the left of the textfield?

I guess the question boils down to how to append something directly to a text field using #prefix in a drupal 8 bootstrap form, since doing form['field_name']['prefix'] appends to the field label instead. Any help with this please?

Thanks


texts:
I have an interesting question.
There is a custom module that defines form -> form validate and form submit

I am not allowed to touch this module, still I want to execute another custom action on submit (OR validate).

I have added
$form['#validate'][]='_custom_validator';  in my hook_form_alter
So the $form array has two functions that validate.
And that seems to work, the problem is I have to "copy-paste" the validation code from the other module (the code inside hook_form_validate).(To prevent any incorrect form validation).
This is considered as a bad design pattern.

Question:
Is there somewhere a property that defines the order of the validations ?

Cheers


texts: How to pass same contextual arguments to two view blocks programmatically?

texts:
I'm trying to pass same arguments to views. Here is my code:

$view = Views::getView('taxonomy_articles');
            if (!empty($age)) {
              $view->setDisplay('block_6');
              $view->setArguments([$term->tid, $age_args]);
              /*
               * override term name with age param
               */
              $termURL = Url::fromRoute('entity.taxonomy_term.canonical', array('taxonomy_term' => $term->tid, 'age' => $age));
              $termName = \Drupal::l(t($term->name), $termURL);
            }
            else {
              $view->setDisplay('block_1');
              $view->setArguments([$term->tid]);
            }

My else part gets executed and array of term ids goes to block_1, my view block machine name.

What I want is similar like:

              else {
                  $view->setDisplay(['block_1','block_7']);
                  $view->setArguments([$term->tid]);
                }

Is this possible? Can we pass array to $view->setDisplay ???


texts:
I'm trying to use this hook in order to alter a breadcrumb link :

hook_menu_breadcrumb_alter(&$active_trail, $item)

The hook don't seem to be called.

I've tried :

Using the hook on a theme
Using the hook on a custom module (breadcrumb_finder_fix)
Clearing all caches using Drush

I have the Devel module installed and activated, and the following doesn't produce any output.

function breadcrumb_finder_fix_menu_breadcrumb_alter(&$active_trail, $item) {
    drupal_set_message(krumo($active_trail));
}

Any ideas ? Directions ? Please advise.

OBS : I've read this answer : https://drupal.stackexchange.com/a/7659/12647


texts:
I am using Drupal 8 and I used the Views data export module which handles XML and JSON as exporting formats.

Is there any way to export data in Excel format?


texts: Change field requirements on validation?

texts:
I am new to Drupal so forgive my newb question.

I am trying to remove the required true from a form field if a user clicks on a certain button  so i tried to do it via form validaiton:

$form['#validate'][] = 'my_from_after_build'; //Calls function

function canvas_from_after_build($form, &$form_state) {
  echo "this is the form after building";
  $form['field_title_tag_list_article']['widget'][0]['#required'] = FALSE;
  return $form;
}

but it still gives a "this field is required" error.


texts: drupal chat with trusted contact only drupal commons

texts:
I am integrating the Drupal chat with Drupal commons module . Now its working .but my actual need is to integrate this with only for trusted contacts is it possible .

If yes means how I need to configure this ?


texts: Different front page for anonymous users and authenticated users

texts:
I have an app in Drupalgap. I would like to display a different frontpage for anonymous users and authenticated users, for example /dashboard for the first and /user_listing for the last.

I have read "Display Different Text for Anonymous and Authenticated Users", but it is not the same scenario. (/user_listing has ['access user profiles'] as access_arguments.)

I also have tried with drupalgap_goto() without succeed.

How can it be done?


texts: Create a View to reference content, get paragraph field and influence how it is rendered?

texts:
I am trying to create a Paragraph type that lets a user specify a node to reference, and a couple of checkboxes that influence how content from that node is rendered.

I can create a view that gets me the resulting node's Paragraph item that I am after, but how do I influence how certain things are rendered or not rendered from another Paragraphs field values? Would it be easier to load the node instead of use a View, and pass a flag into the render process somehow and "see" it in node preprocess and/or get the Paragraph id from the node, and do the same (rendering wise)?


texts: How to give edit permission only to specific fields in node edit in?

texts:
I have content type with some cck fields:

- task time
- task status
- task executor
- task category

and of course title/body and other drupal node default fields.

each node of this content type will be assigned to a user selected from site users in task executor field.

I want the when the executor logins view all fields of assigned to task(node) but only can change (edit) the value of task status field. node edit doesn't do that.

I try to use 'Content Permissions' of cck module but it is not what I really need. it doesn't have control on title and body field and also the user can only see the fields he has edit permission on them in node edit page.

What can I do?

I hope I could explain my question clearly.

Thank you.


texts: How to make URL arguments available as tokens in Rewrite Results of a Field in a View?

texts:
Is it possible to make URL arguments, e.g.

http://mysite.com/arg1/arg2/arg3

available as tokens in the rewrite results settings for a field in views e.g. for the above these would be available for use (among other existing tokens) as:

[arg1] [arg2] [arg3]

Background

I am developing Views using OpenLayers maps with filtered items place in an overlay on them. When the user interacts with the map to remove items, I want to retain the position of the map (an not have it revert to a default zoom and position) when the page reloads. By being able to access the URL arguments i.e. longitude and latitude, I can then rewrite the filter URL so that these are sent back to the page.

But I'm sure there are other scenarios that don't use maps that people would find answers to the question useful for.


texts:
I am getting this notice when adding a content type in Drupal 7.24.

  Notice: Array to string conversion in token_replace() (line 102 of /var/www/html/includes/token.inc)

What does it mean? Could I reinstall the modules to fix it?


texts: Save values from Commerce Profile to User Profile with Rules?

texts:
The response to this question indicates that the solution is to save values from the Commerce Profile into the required field(s) of the User Profile using Rules. I can't figure out how to do this!

I created a new Rule, triggered by event "After saving a new commerce customer profile" (though I might well need to integrate this rule into the Commerce Profile creation rule for it to work with required fields. For now, I've just removed the requirement.) Here are the actions that I've picked out as looking like good candidates for doing what I want:

Data

Add a Variable (Does this mean save a variable with a value, or just instantiate a variable? Where?)
Add an Item to a List (What list? Where?)
Set a Data Value (How is this different from "Add a Variable"?)

Entity (Are User profiles Entities?)

Create Entity (Use this to create the new User profile?)
Save Entity (Will this save values to the Entity?)

Are any of these going to do what I want? Am I on the wrong track entirely?

Thanks.


texts: How to add a condition based on a line-item's product type in a rules tax component?

texts:
In Drupal Commerce, when you create a tax rate of a particular type, let's say a "VAT low" of type VAT, a rule "Calculate taxes: VAT" is created, as well as a rule component "Calculate VAT Low".

Now I want to make the "Calculate VAT Low" component conditional on the product type of the product referenced in the line item. The examples for conditions in the tax component that I found, however, use data selectors of the order like address, not a line item.
Other examples of using conditions based on the product type referenced by the line item are configured at the level of the rule, not the component (e.g. here). The commerce-line-item:commerce-product:type does not seem to be available when adding conditions to a component.

Is it possible to make tax components conditional on the product type of the line item? Or should I create a separate rule for each tax rate component rather than use the default "Calculate taxes: VAT"?


texts: How to pass a parameter into a form upon creating?

texts:
I have a form, which contains an additional field. And I want to initiate the field via the form constructor.

class ServicesForm extends FormBase {

    private $service_type;

    public function __constructor($_service_type){
        $this->service_type = $_service_type;
    }

The form is created in a controller.

class ServicesController extends ControllerBase {

    public function getServices($service_type){
        $data['form'] = \Drupal::formBuilder()->getForm('\Drupal\palom_services\Form\ServicesForm');

        return $data;
    }

Could you clarify me, how to pass the parameter $service_type to the form inside the controller method ?

Maybe, should I do it without FormBuilder and getForm ?


texts: Hide the displayed article in a most viewed/popular sidebar

texts: In an article panel page, i have a sidebar with the Most Viewed articles as per RAdioactivity module. If the main article that I am viewing is one of the Most viewed, I want to hide that article link in the sidebar but instead display the rest of the Most Viewed articles links. How can I do this using Panels, mini Panels, views?


texts: How do I create a view to list documents for a user basing visibility on 2 condition?

texts:
I have a taxonomy called 'sub-agency' and all users have one or more sub-agency connected with him.
I have a content type called 'documents' which have a taxonomy term field [connected to sub-agency taxonomy] and a user reference field.

Now I want a view who displays documents shared with
logged user sub-agency OR have him in user reference field.

How can I achieve this?


texts: Dealing with hook_cron when configuration is required

texts:
What's the best way in dealing with functions that require configuration in a hook_cron?

Example (pure fiction):

My hook_cron calls function_close_ticket, this function has various variable_gets all of which have defaults but those defaults may not be relevant to the users setup (they are however relevant to a default casetracker setup), especially if the user has customised casetracker a lot.

Would I be best leaving as is and letting hook_cron fire or wrapping the function inside in a call to get the state of a user configurable variable? Or is there some other way of dealing with this problem?


texts: Is there an input filter to add the class clearfix to all  tags?

texts:
I have a lot of inline images in my content. Most of the time I want to have some sentences and an image grouped together. To get a nice layout I have to mannually add class="clearfix" to all <p> tags. This is especially anoying because the class often gets lost when I edit the text in the wysiwyg editor.

Is there an input format, or some other easy way to do that automatically?


texts:
I have create a EventSubscriber like this:

<?php

namespace Drupal\custom_session\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * Class SessionInitial.
 */
class SessionInitial implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = ['setSession'];

    return $events;
  }

  /**
   * This method is called whenever the kernel.request event is
   * dispatched.
   *
   * @param GetResponseEvent $event
   */
  public function setSession(Event $event) {
    // Start request.
    kint($_SESSION['page']);
    $route_name = \Drupal::routeMatch()->getRouteName();
    if ($route_name == 'view.frontpage.page_1') {
      $_SESSION['page'] = 'Home page';
    }
    else {
      $_SESSION['page'] = 'Other page';
    }
    // End logic.
    kint($_SESSION['page']);
  }

}

Every request I'll check prev $_SESSION['page'] and process logic.

But each request $_SESSION['page'] all has same value Other page.

Test step by step:

1, Go to home page (router name is **view.frontpage.page_1)**

2. Refesh browser with url home page but debug result is the same:

Also last request was set $_SESSION['page'] to Home Page.
I don't know why. Someone can help me. Thanks!


texts: How can I programmatically create a media object and a new file and associate the file with the media object?

texts:
I am trying to programmatically create a media object and a file, and then associate the file with the media object.  The first part works--I can successfully create the media object and file.  But the second part fails--the media object has no file associated with it.

Here is my code:

//Begin handling file uploads
$file = file_save_data('hey dude', 'public://2019-07/my_example.txt', FILE_EXISTS_REPLACE);

$media_arr = [
  'bundle' => 'file',
  'langcode' => 'en',
  'uid' => '0',
  'name'=> 'Test Name',
  'created' => date('U'),
  'changed' => date('U'),
  'moderation_state' => 'published',
  'file' => [
    'target_id' => $file->id(),
  ],
];

$drupalMedia = Media::create($media_arr);

$drupalMedia->setName('Test Media Object')
  ->setPublished(TRUE)
  ->save();

my_example.txt is created in the files directory, and the media object "Test Media Object" is also created, and I'm able to attach it to a node.  But there is no file in the new media object!  Am I missing something here?


texts: Entity create access based on a custom field

texts:
Is there a way to allow/prevent users to create a new entity based on an entity field? Because the checkCreateAccess() / hook_entity_create_access() function is not receiving the actual entity as a parameter, just the bundle.

Is is ok to do a check on 'hook_entity_presave()' and throw an exception there?


texts: How to share Drupal code across multisites that are each in subdirectories?

texts:
I have two websites on my own server (I have full control of the Apache config, etc.)

I want to install Drupal 'into' each of them, in a subdirectory of the site root.

I'd like to share a Drupal codebase between the two.

And, I'd like to have the URLs appear without the subdirectory.

My problem is I can't figure out how to do all at once.

I can get to this easily,

/src/www
  /website1
    /drupal1
       ...
       sites/website1.com/themes/website1.com
       ...
    /other_stuff_1a
    /other_stuff_1b
  /website2
    /drupal2
       ...
       sites/website2.com/themes/website2.com
       ...
    /other_stuff_2a
    /other_stuff_2b

But I'm not sure how to share the Drupal7 code in this case.  Do I have to use symlinks or something?

I'd appreciate any help or ideas.

Frank


texts: Unable to connect to local MySQL db using drush sql-sync

texts:
I'm attempting to use drush sql-sync to sync my prod database to my local dev copy, and everything seems to work until drush attempts to log into the local MySQL. When it does, it throws this error:

"ERROR 1044 (42000) at line 39: Access denied for user 'drupal_user'@'localhost' to database 'mydb'"

I'm using a group alias file (e.g. mysite.aliases.drushrc.php), and I have my two aliases defined like so:

$local_sites = '/Users/steve/Sites/';
$aliases['local'] = array(
  'uri' => 'default',
  'root' => $local_sites . 'mysite/public_html',
  'path-aliases' => array(
    '%files' => $local_sites . 'mysite/public_html/sites/default/files',
    '%dump-dir' => '/Users/steve/Sites/mysite',
   ),
);

$aliases['prod'] = array(
  'uri' => 'default',
  'os' => 'Linux',
  'root' => '/cluster/www_system/www/www.mysite.org/current_build/public_html',
  'remote-host' => 'control.cphwf01.local',
  'remote-user' => 'sedwards',
  'path-aliases' => array(
    '%files' => 'sites/default/files',
    '%dump-dir' => '/scratch',
   ),
);

I run sql-sync with --verbose, and I can see the file created on the remote server, and then copied to my local.  However, where it fails is at this line:

Calling system(mysql --database=mydb --host=localhost --user=drupal_user --password=mypass --silent < /Users/steve/Sites/mysite/mysiteLeW4G5);

If I paste this command to the command line like so:

mysql --database=mydb --host=localhost --user=drupal_user --password=mypass

it connects just fine. Now, I do notice that the temp dump file is then deleted, but it's there at the time sql-sync is attempting to connect.  Any ideas why this would be failing?

On a side note, what flag do I need to pass to sql-sync to get the dumped file to persist on my local once it's been created? That way I can test w/o having to dump from the server every time. It would also be way to just dump from the remote to my local w/o actually importing into the local db.

Thanks.

EDIT: I've run sql-conf for my local site (with --show-passwords) and it shows the correct information for the local copy.

EDIT 2: Following the advice here, I used the root user, and the sync worked.  However, this still doesn't make sense, since using the drush generated connection string with the db user/pw from settings.php at the command line works fine.


texts: Giving custom argument value in 'q' variable

texts:
We want to use  a custom template page when a specific value is given for the q variable in url .

For example if we give http://localhost/drupal/?q=xyz/123   , we want to use a custom template page say page-xyz.tpl.php ..

Have a hunch that hooks and template.php file may be the key components here but not sure what to exactly do.


texts: How do I unset/hide certain fields from being indexed by the core search module?

texts:
If a content type has additional text fields, search core automatically indexes them because search core extracts all text from the result of node_view()

I can easily add extra index data via MODULE_node_update_index( $node ). This particular hook argument, $node, is passed by value and not by reference which means I can't unset certain items.

I hook into node_view, and alter it there but I don't want to change the output of the node normally, only when it's being indexed.


texts:
I've built a custom user profile. All the values I want to display are outputting correctly, bar one. The only difference between the fields is the one that doesn't render is an integer, whereas the ones that do render are all varchars.

Is there a specific way of grabbing the value of the field if its an int?

I'm using something like the following:

function render_element(&$element) {
  if (is_array($element)) {
    show($element);
    return drupal_render($element[0]);
  }
}

And then outputting them with this:

$user_fields = user_load($user->uid);
render_element($user_profile['field_phone']); //varchar
render_element($user_profile['field_number']); //integer


texts:
I have difficulties with getting a render Date (ISO) field from code. The field has machine-name field_date. By default, the Date field has three formatter: "long", "medium" and "small". The default formatter for node is set to "medium". (I've checked that, if the field is displayed in usual node's view, it's formatted as it should be)
 Here's the code:

$node = node_load($nid);
$field_date = field_get_items('node', $node, 'field_date');
$render_field_date = field_view_value('node', $node, 'field_date', $field_date[0]);

But the output I get is in "long" variant. Drupal.org says that by default it uses "default_formatter" which is defined in date_field_formatter_info() (having inspected the code, I figured out that that 'default_formatter' actually means 'long'). Well, I want it to be formatted in "medium" way. I write these lines:

$render_field_date = field_view_value('node', $node, 'field_date', $field_date[0], array('type' => 'medium') );

but it's still in its "long". What is wrong with the code?


texts: How can I tidy up an auto increment field in a table from within a module?

texts:
How can I tidy up an auto increment field in a table from within a module, so that a table like this (the 'id' field being auto incrementing):

id title
1  foo
3  bar
7  fee

becomes:

id title
1  foo
2  bar
3  fee

Is there a function, like serial_field_tidy or something?


texts:
I want to run some code to add php varible in js file just after my rule run. Rules doesn't support adding js.

I can make action to rule using hook_rules_action_info but that does not work because adding js via rule action doesnt not work.

Is there a hook for rules which I can use in my module to check if a specific rule has been fired? and using that hook I can run my code just after rule run.

Thanks!


texts: Styling two views using the same template file?

texts: I have two views that are pretty similar so I want them to use the same template file. However, in views I can only select templates that have a name unique to that view meaning two views can't use the same template. How can I accomplish this?


texts: Create a PDF with one result from a view

texts:
I have a view with information from a specific database table and I want users to be able to generate a PDF with the results from one row, which would contain all the information from the row. So far, I've only been able to generate a PDF of an entire view instead of one result. I'm not sure how to "tell" the PDF which view result to generate as a PDF.

Note: This is a different way of asking a question I previously posted, which I think was too confusing at this point.


texts: Is there a CCK fieldtype that would display a static field?

texts:
I'm looking for something like the 'textfield' CCK fieldtype, except instead of displaying a label and an edit box with a value - it would just display a label and a value as text during both edit and view operations.

So for example, as a textfield it might display like this:
label: [value]

as a 'static' CCK fieldtype it would display like this:
label: value

I've tried disabling a textfield, but our User Experince folks don't like the fact that the field has a box, but yet really never becomes editable.

Thanks for all your help,
Greg


texts: Change default text (-Any-) of select option in Exposed View Filter

texts:
I am using views exposed filter.

I want to change the text -Any- into something else.
How can I do that (without using jquery/javascript) ?


texts:
I'd like to display the number of unique node views (= how many times the full node page is visited by a unique user) in my nodes' teasers. I've tried to use the Statistics module, but in that case, all reads are stored.

Is there a way to only count the unique views? Which code should I use in my node.tpl.php file to display this information?


texts: Help me understand this Fatal error: Call to undefined function EntityDefaultMetadataController::bundleOptionsList()

texts:
With updated modules to recent releases,
Recently this error started appearing when executing 'Modify entity values' in views bulk operations. It happens on all the views in the site.
Indications where to start digging is much appreciated.

Fatal error: Call to undefined function EntityDefaultMetadataController::bundleOptionsList() in /home/cdt/public_html/sites/all/modules/views_bulk_operations/actions/modify.action.inc on line 173


texts:
We use Paragraphs quite extensively in our site. We have about 10 bundles available.

What we' like to do is alter how the paragraphs are displayed on various pages; Ie, we'd like to remove bundle a and display only bundle b. Then, in an alternate view, we could have only bundle c and none others displayed.

Short of writing some page/node/paragraphs alters I'm looking for a nice clean way I can achieve this. Maybe 'view modes' for an entire paragraph.

Note paragraphs behave similarly to field collections, so any suggestions for FC are welcome also.


texts: Hide Panel Page Title from anonymous users

texts: I need some custom code to hide a panel page title from anonymous users. I want authenticated users to see the title of the page, but not anonymous users. By page, i mean the entire panel page containing different panes. Thanks.


texts:
Is there any way to know which Panel varient is being used, when I'm viewing the node or term? I know there is the panel page listing and that shows the varients, but it is difficult to know which nodes are using this varient.

I'm asking because I have a site, node template panel has over 20 different varients, some are in use some are not. Attempting to document them is painful.

Thanks!


texts:
I have a project plan content type. I would like to be able to change the "start date" field value to the current date, and set the "deadline date" field value to 2 weeks after. Then I would like to convert this data into a file (eg. pdf) which I can then attach to another entity.

The majority of this can be achieved using the Set Data Value action in Rules module; except of course for converting the data into a file. The module FillPDF comes quite close although it only allows for converting Webform data to pdf and not node data.

The following modules are able to convert nodes to pdf, however they do not have Rules integration: PDF using mPDF, Printer, email, PDF versions

What is the best way to achieve this?


texts: Best way to convert PHP block to improve site

texts:
I've just taken control over a Drupal site which the old admin used php blocks. I normally work on Joomla sites but from research and advice from others PHP blocks don't help the site in the long run.

What's the best way forward when some of the PHP blocks are set to some pages in a set area.

For example PHP block 1 is only on the Home Page's Sidebar where PHP block 2 is on Page About Us and Contact Us' Sidebar.

Just some background, This is the first Drupal site I've worked on and know only bits and pieces about Drupal apart from the general how it works and some extra details. If I've missed some research or reading which could aid in this issue which you can direct me too, this again would be great help.


texts: How to increase the performance of my website in Drupal 7

texts:
I have tested my website on http://www.webpagetest.org/, and I found my website performance is very bad. I have used minifying of CSS and JavaScript, and reducing the pic size; performance is still very bad.
How do I solve this problem?


texts: Solution how to import contents of a .txt file into a body field?

texts:
Are any solution how we can import content of text (.txt) file with feeds into body field?

We don't have any problem with standard feeds import with CSV file and files into field file. We just need solution how we can import content of separate text file into body field.

Thanks


texts: How to filter views block by content type

texts:
I added two content types for views slideshows.
I added slides to both content types.
I created a views slideshow block using one content type.
I cloned the above view > Now, I have two views slideshow blocks.

Now, both blocks are linked. Updating one setting updating the other. How can I do the settings so views block1 filtered by content type1 and views block 2 filtered by content type2?


texts: Can't set PHP block visibility programatically

texts:
Heres my code:

$blocks['membership_package_information'] = array(
    'info' => "Membership Package Information",
    'visibility' => BLOCK_VISIBILITY_PHP,
    'pages' => membership_block_visibility(),
  );

function membership_block_visibility() {
  if(arg(0) == 'checkout' && arg(2) == null) {
    return true;
  }
  else {
    return false;
  }
}

I'm trying to limit the block to only show on the first page of the drupal commerce checkout page (checkout/[order-id]) and not the second (checkout/[order-id]/review) but its not working. When I put this code in the PHP visibility section of the block UI page, it works. I'd rather it be in my module, why wont it work? It seems that the UI settings are being picked up and not whats in my block.


texts: I have a drupal form  with a drop down list of teams like team A, team B, Team C and on submit it goes to page /team-page/[team-id] and displays the particular team details.So how do I do if I have to select all team data? because my page only accepts team ids and I want to use /team-page/all.


texts: Where can I alter the path of the anchor around a views items title?

texts:
I have a view with several items and they link to their respective nodes.
However I also have an external URL field which if populated needs to replace the path around the title of the views item.

I've been looking for a hook that builds this title path and associates it with the title but so far have not had any luck.

I thought hook_views_pre_render() might have it but the title is just a string.


texts: Display entity as options_select multi-select

texts:
Below is my code for the view. I have tried multiple = true, multiple_values=true, multiple = multiple. None have worked.

->setDisplayOptions('form', [
    'type' => 'options_select',
    'weight' => 0,
    'settings' => [
        'match_operator' => 'CONTAINS',
        'size' => '60',
        'autocomplete_type' => 'tags',
        'placeholder' => '',
    ],
])


texts: Drupal 8 Display True/False instead 0/1 on checkbox value in ConfigFormBase

texts:
By default the boolean fields' value displayed as 0/1 when user filled the checkbox field under custom configuration form. Need to render True/False instead of 0/1.

$form['newfield'][$id]['required'] = array(
  '#type' => 'checkbox',
  '#default_value' => ($config[$id]['required'] ? $config[$id]['required'] : $field['required_disabled']),
  '#disabled' => $field['required_disabled'],
);

public function submitForm(array & $form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $config = $this - > config($this - > configId);
    $fields = static::getFields();
    $values = $form_state - > getValues();
    $values = $values['newfield'];
    foreach($values as $key => $field) {
        $config_values[$key] = array('visible' => $field['visible'], 'required' => $field['required'], );
    }
}


texts: Display message instead of redirecting to Access Denied page

texts:
I'm using Commerce Auction module for an auction site. I want to display a message when the auction time out occurs for a certain product and at the same moment the user clicks on place bid tab.

Scenario:

Created an auction item
Started bidding with different users.
When auction time out just occurs and at the same moment any user clicks on Place Bid tab that user is redirected to Access Denied page.

Now instead of redirecting to access denied page, how to display a message on the same page?

I have set a rule for mailing purpose on the same event. I also tried using "display message" rule for this event. But still it is displaying Access Denied message. I want to show different message only for this event.