texts: Inside Panelizer, is there a trick to formatting image fields?

texts:
Summary
In Panelizer, I have created one Panel. In Content for this panel there is an image field. I can find no option to change the image style.

From Manage Display in the content type,  I am able to select Image Style for various display settings but this makes no difference to the image in the Panel in Panelizer.

Where am I not looking?

Details
In Panelizer for Content Type = (Person), first row on the left "Full Page override" I clicked "Panelize" and "Provide Default Panel". I think I have created one Panel. In the Content for this panel, I have placed an image field (field_person_image) in the right column.

In Panelizer on R of field_person_image is a gear listing-
-"Settings". Formatter options for can select This Node, override title, change label position. There is an option for "Select a formatter" but the only option is "Image". There is no option to change the image style.
-Style which offers Pane Style for this node (rounded corners)
-Visibility rules
-Locking
-Caching

In Structure > Content Type > Person > Manage Display,  I am able to select Image Style for various display settings. Changing from Large to Medium to Small (using Default, Full Content) makes no difference to the image in the Default Panel in Panelizer.

This similar sounding question also has no answer. Using Image 7.43. There are no results at Issues for Drupal Core (Drupal.org) about Panelizer and image formatting.

What am I missing?


texts:
I'm trying to use Drupal 8, with a custom theme, due big structure differences for my requirements I have a page--front.twig.html and a page.twig.html, I would like to create template parts as used in phrozn oder in a normal Symfony2 project, for example a footer.html.twig and a header.html.twig. These templates are saved under a subdirectory /parts/.

But when I call this templates as normal I just receive a string with the name of the template.

For example:

{# in page.html.twig or page--front.html.twig #}
{% include 'parts/footer.html.twig' %}

Returns the file name as string:

parts/footer.html.twig

It's possible to do that with Drupal 8?


texts:
  Test Committee 1

Test Committee one description

  Test Committee 2

Test Committee 2 description

This is the array string i got when i do a print_r($header); in my template.

<?php
                    $doc = new DOMDocument();
                    $doc->loadHTML($header);
                    $links = array();
                    $arr = $doc->getElementsByTagName("a");
                    foreach($arr as $item) {
                    $href =  $item->getAttribute("href");
                    $text = trim(preg_replace("/[\r\n]+/", " ", $item->nodeValue));
                    $links[$text] = $href;
                    }
                    $serch = $_GET['combine'];
                    $arr = array();
                    $arr =  explode(" ", $serch);
                    foreach($links as $key => $value) { ?>
                    <?php if ( stripos( $value, $arr[0] ) !== false ) {?>

<a href="<?php echo $value; ?>"><?php echo $key; ?>

                    <?php } }
            ?>

This is my code to print the result and search the link title in the array. I need to add the body field (views-field-description) to result display and need to search the keyword ($serch = $_GET['combine'];) inside the body (views-field-description) content.

The title search works fine for me. How can i add it.


texts: Prevent Bootstrap from rewriting forms/buttons

texts:
I've found a conflict between the Bootstrap theme and the dropdown_language modules, whereby Bootstrap appears to rewrite the output of the form defined by the module. The module uses a form item type of 'dropbutton', and in its expected state, clicking either the current language label (in this case, English) or the dropdown arrow, will open the menu. But in bootstrap, the current language label acts as a submit button and just refreshes the page without doing anything.

Bartik:

Bootstrap:

The entire HTML output of the form is massively different too, and a large amount of the classes added have been ignored during the rewrite. Compare the output of bartik's and bootstrap's HTML output:

Bartik:

English

        <button type="button">List additional actions
        </button>

Polish

Bootstrap:

  <button class="button js-form-submit form-submit btn-default btn" data-dropdown-target="#dropdown-item" type="submit" name="op" value="English">English</button>
  <button class="btn-default btn dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Toggle Dropdown
  </button>

English

Polish

So my question is, what do I need to do to prevent this output modification from happening? Does the problem lie with Bootstrap or the dropdown_language module's implementation? Looking at dropdown_language's code, it appears to be doing everything normally. Can it be overridden with a theme function? I saw something utilising theme_button but that's only D7. Thanks in advance


texts:
I would like to add
 tag or &nbsp; character to html menu, but when I type Home
 Page, it does display as plain text, but I want to break that words by two lines.

How can I modify my template.php file with hooks, to allow html tags in menu titles?


texts: Integrate fivestar module with schemaorg module

texts:
Possible Duplicate:
  Google Rich Snippets and Facebook Open Metagraph

I am using D7. I have a content type with a field of type fivestar. I am using schemaorg module to add RDFa to the HTML markup.

However fivestar doesn't work with schemaorg out of the box. I tried using microdata which claims to support fivestar but it didn't. I read in some forum/issue that the dev version is currently worked upon to support fivestar and still has issues.

I need help on integrating schemaorg module with fivestar. Anybody out there who has done this or something similar?


texts: How do I import product category based on taxonomy vocabulary?

texts:
I have a products catalog based on taxonomy vocabulary, as advised the term reference field is on the product content type.

Products imports are working fine, but when I try to import product displays the mapping for term reference (Category vocabulary)does not appear in the target list.

I'm using Feeds 7.x-2.0-alpha8, Commerce Feeds 7.x-1.3, Commerce Kickstart 7.x-1.19 and Drupal Core 7.22

Thanks in advance


texts:
I want to create a new paragraph item to a user bundle. This is the code:

$name = "Test";
$userdata = user_load($user->uid);
$paragraph = entity_create('paragraphs_item', array('field_name' => 'field_userdata', 'bundle' => 'userdata'));
$paragraph->setHostEntity('user', $userdata);
$paragraph->field_name[LANGUAGE_NONE][0]['value'] = $name;
$paragraph->save();

But nothing happens, no errors, no new entity..
Are there differences to adding to a node bundle?

Thank you!


texts: Add a prefix to all path with hook_url_outbound_alter and/or hook_url_inbound_alter

texts:
I'm trying to add a prefix to all path aliases, without changing the URL's destinations (internal path) of my website.

I'm setting a $_SESSION var with hook_init() when a visitor arrive on the website. This $_SESSION var is determined by the incoming URL of the visitor.

The website is should be accessible by different URL like:

http://www.mydomain.com/ (default)
http://www.mydomain.com/thisevent
http://www.mydomain.com/whatevent ...

So if the $_SESSION var is "thisevent", I'd like to change all default path like this:

http://www.mydomain.com/some-page into
http://www.mydomain.com/thisevent/some-page
http://www.mydomain.com/another-page into
http://www.mydomain.com/thisevent/another-page ...

I think this could be done with hook_url_outbound_alter() and/or hook_url_inbound_alter() but I can find any clear examples to implement my goal.
I found this post but the author didn't post his solution.

Any help appreciate.
Thanks


texts: How to use hook_init in a custom module?

texts:
I am trying to use a hook_init within my custom module to add a js file. The problem is I do not see where the script is being called or executed on the front-page.

/* Implements hook_init. */
function hook_init() {
  if (drupal_is_front_page()) {
      drupal_add_js(drupal_get_path('modules', 'myInfo') . '/myScript.js');
  }
}

name = My Info
description = My Info Evaluation.
core = 7.x
version = 7.x-0.1-dev

I even tried to remove the hook_init and referenced the JS within the module info, but no luck. What am I missing here?


texts: I need a preprocess function to inject category name in my node

texts:
Hello I need to display the category name of the article (it is in taxonomy) inside my node. Here is the function

function mytheme_preprocess_node(&$vars) {
        $node = $vars['node'];
        $vars['category'] = "category here..";
    }

With my devel_themer module I manage to find out where this category is:

field

Please if someone help me how to insert the category in $vars['category'] thanks!


texts:
I've got the media module installed, but I'm not seeing the Media browser at all when I go to upload images.

Do I need to do something special to enable the media browser?


texts: How do I pass parameters to the form builder?

texts:
I have the following routes in module_name.routing.yml.

module_name.usergroup_delete:
  path: 'module_name/usergroup/delete/{arg1}'
  defaults:
    _form: '\Drupal\module_name\Form\DeleteUserGroup'
    _title: 'Delete User group'
  requirements:
    _permission: 'access admin menus'

This is the code in module_name/src/Form/DeleteUserGroup.php.

namespace Drupal\module_name\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

class DeleteUserGroup extends ConfigFormBase {

  public function getFormId() {
    return 'delete_user_group';
  }
/**
 * General form for switching all nodes from one user to another.
 */
  public function buildForm(array $form, FormStateInterface $form_state,$product_code) {
  $form['_product'] = array(
        '#type' => 'value',
        '#value' => $product_code,);
//get the user group and username to display the confirmation message
$result = db_query('select field_p_group_name_value from {content_type_usergroup} ctu'
        . ' where vid=%d',$product_code);
    while ($row = $result->fetchObject()) {
      $user_group = $row->field_p_group_name_value;
    }

return confirm_form($form,t('Are you sure you want to delete "' .$user_group. '" User Group?'),
        isset($_GET['destination']) ? $_GET['destination'] : "function_name",t('This action cannot be undone.'),t('Delete'),t('Cancel'));

  }
/**
 * #submit callback for node_adoption_transfer_form().
 */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_values = $form_state->getValues();
  //if ($form_state['values']['confirm']) {
    $param = $form_state->getValue('_product');
    drupal_set_message(t('Group ' .$param.' will get deleted.'));
    db_query('DELETE FROM {content_type_usergroup} WHERE vid = %d', $param);
    //delete the users of the usergroup too
    db_query('DELETE FROM {usergroup_user_map} WHERE group_id=%d', $param);
    drupal_set_message(t('usergroup has been deleted.'));
    drupal_goto('function_name');
  }

  protected function getEditableConfigNames() {
    return "delete_user_group";
  }

}

I am getting the following error:

  DeleteUserGroup::buildForm() must be compatible with
  Drupal\Core\Form\FormInterface::buildForm(array $form,
  Drupal\Core\Form\FormStateInterface $form_state)

Why?


texts: What is causing this duplicated node issue?

texts:
I have the following error: When I create a new node from the new data of my external database (inserting a new row in the external database), the new node is duplicated (but it doesn't have type, language, user); this causes the following error:

  Invalid argument supplied for foreach() en /path/web/my_proyect/sites/all/modules/cck/content.module on line 1284.

With my other module, I first extract all the rows of my external database, and convert them in nodes.

I don't know why; I debugged my code, but I don't understand that it is causing the problem.

This is the code of my module.

/* Implement of Hook_cron */
function node_db_extension_cron(){
  inspectAddHoteles();
  drupal_flush_all_caches();
}

function getHotelFromDrupal() {
  $type = '[my_type]';
  $query_nid = "SELECT count(nid) count FROM node WHERE type LIKE '%s'";
  $result_start = db_query($query_nid, $type);
  $cantidad = 0;

  while ($row = db_fetch_object($result_start)) {
      $cantidad = (int) ($row->count);
  }

  return $cantidad;
}

function getHotelFromExternal() {
  db_set_active('external');

  $result = db_query("SELECT count(id) count FROM [my_table]");
  $cantidad = 0;

  while ($row = db_fetch_object($result)) {
      $cantidad = (int) ($row->count);
  }

  db_set_active('default');

  return $cantidad;
}

function inspectAddHoteles() {
  global $user;

  $cantd_actual_hotel = getHotelFromDrupal();
  $cantd_final_hotel = getHotelFromExternal();

  /* With the count of nid of drupal and id of db external, i verify if exist new rows  because the count of nid of content and id of rows of my db externa should be equals if don't exists new rows on my db external */

  if ($cantd_actual_hotel < $cantd_final_hotel) {
    db_set_active('external');

    $cant_add = $cantd_final_hotel - $cantd_actual_hotel;
    $query = "SELECT * FROM [my_table] ORDER BY id DESC LIMIT %d";
    $additional = db_query($query, $cant_add);

    db_set_active('default');

    while ($row = db_fetch_object($additional)) {
      $node = new stdClass();
      $node->uid = $user->uid;
      $node->type = 'my_type';
      $node->title = $row->title;
      $node->body = $row->body;
      $node->created = time();
      $node->changed = $node->created;
      $node->promote = 0;
      $node->sticky = 0;
      $node->format = 2;
      $node->status = 1;
      $node->language = 'es';
      //All field of my content type

      $nodo_1 = node_submit($node);
      node_save($nodo_1);
    }
  }
}


texts: Live content migration to a separate server for important content

texts:
My clients are now spending a lot of money daily on creating content on my system. A few hours lost could be quite bad for them, and in turn, for me.

Most of the site is fine on daily backups, but there is a content type I'd like to offload onto a backup server when nodes are created or updated. Is this possible? Preferably sending a node object and related files.

I haven't had an issue in a long time but I'm feeling the stress with their investment.


texts: I installed the Drupal Encrypt module and enabled it. However, I wonder how this module actually works. Does it encrypt all the submissions from the browser that the user/admin key in like 1) Login  2) Add/update node  3) Contact form/webform and decrypted again in the server before saving to the database ? Any tool to test this process? I'm looking a way to protect all the submissions or update over the internet which may be captured or exposed especially in the public area when using those free Wi-Fi. Please advise.


texts: creating menu items with children (sub items)

texts: i want to have a menu option called Info in my 'main menu', which has children of Policies and Contact. how can i set it up so that when a user clicks on Info, it just shows the child options in the drop down underneath Info and doesnt display a node? I only seem to be able to achieve what I want by setting up a blank dummy node which Info is linked to. I'm using Superfish, but i dont think thats relevant.


texts:
I am creating a custom form and storing data in custom table. I was wondering if there is any method to apply field level permission like

$form['value']['#permission'] = array('access this field');

I know I am having field permission module to apply permission on core fields but how I can achieve this?


texts: How to add an autocomplete field with pure javascript

texts:
I'm implementing the javascript library Annotorious which allow to add annotations on an image. My goal is to be able to link content with part of the image select with Annotorious. When we select a zone, Annotorious open a form we can personalize to add information we want link with the zone. In my case, I added a fieldtext but I want it uses the autocomplete but I don't know how to activate this behavior.
Regarding the code in core/lib/Drupal/Core/Render/Element/FormElement.php, the form element add the class 'form-autocomplete' and the attributes 'data-autocomplete-path' equals to the url of an autocomplete function on his input and inject the library core/drupal.autocomplete. Regarding this, I tried to reproduce the same behavior. But I guess something is missing because my field doesn't query my endpoint when I typed in it but I don't know why. I was also thinking this maybe doesn't work because it's add by javascript after the loading of the page but in this case, I don't know how to solve this problem.
Here my code:
My widget field:
class ImagePinWidget extends ImageWidget {

  public static function process($element, FormStateInterface $form_state, $form) {
    $element = parent::process($element, $form_state, $form);

    $element['preview']['#attributes'] = array('id' => array('my-image'));

    $element['#attached']['library'][] = 'my_module/image-pin';
    $element['#theme'] = 'image_pin_widget';

    return $element;
  }

}

My my_module.libraries.yml
recogito-annotorious:
  version: 1.x
  css:
    component:
      /libraries/annotorious/annotorious.min.css: { minified: true }
  js:
    /libraries/annotorious/annotorious.min.js: { minified: true }

annotorious-toolbar:
  version: 1.x
  js:
    https://cdn.jsdelivr.net/npm/@recogito/annotorious-toolbar@latest/dist/annotorious-toolbar.min.js: { type: external, minified: true }

image-pin:
  version: 1.0.0
  css:
    component:
      css/image-pin.css: {}
  js:
    js/image_pin.js: {}
  dependencies:
    - core/jquery
    - core/drupal
    - core/drupalSettings
    - my_module/recogito-annotorious
    - core/drupal.autocomplete
    - my_module/annotorious-toolbar

image_pin.js:
(function ($, Drupal, drupalSettings, Annotorious) {

  'use strict';

  Drupal.behaviors.redacto_form_image_pin = {
    attach: function (context) {
      var config = {
        image:'my-image',
        widgets: [
          Drupal.behaviors.my_module_image_pin.nodeSelectorWidget,
        ],
      };

      var anno = Annotorious.init(config);

      Annotorious.Toolbar(anno, document.getElementById('toolbar'));
    },

    /**
     * Dynamic behavior when the status changes.
     *
     * @param $status
     */
    nodeSelectorWidget: function (args) {

      // Adding the autocomplete field
      var createField = function() {
        var input = document.createElement('input');

        input.classList.add('form-autocomplete');
        input.setAttribute('data-autocomplete-path', '/fr/autocomplete/custom');

        return input;
      }

      var container = document.createElement('div');
      container.className = 'nodeselector-widget';

      container.appendChild(createField());

      return container;

    }

  };

})(jQuery, Drupal, drupalSettings, Annotorious);

I precise the path /fr/autocomplete/insects return correctly a json list of content and autocomplete create in a usual form works correctly with it. Example of autocomplete I do in an usual drupal form with this custom autocomplete:
$element['test_autocomplete'] = [
     '#type' => 'textfield',
     '#title' => t('Autocomplete Articles'),
     '#autocomplete_route_name' => 'my_module.custom_autocomplete',
   ];


texts: Different Terms&Conditions on multi-site

texts: I use Legal module to display terms & conditions to the user, but now I need to create different T&C text for different sites created with Domain Access. Is it possible?


texts:
How do I show only language specific and translated taxonomy terms in a field which references a taxonomy?

In my xyz content type I have taxonomy reference fields. While translating the content created using "xyz" content type, I would like to show only language specific taxonomy terms (either translated or created in that specific language).

How can I achieve this?

As suggested by Clive I have created a entity reference view which shows only languages specific and translated terms. Here is the screen shot of the same.

But when I link that view from product category field which is of type entity reference it shows taxonomy terms in default language i.e. English in my case instead of Spanish Language but the terms are filtered as per language i.e. Spanish.
Here is the screen shot of the same.

Can somebody please suggest if I am missing a step here ?


texts: In Drupal Commerce, how can I decrease stock of product B when buying product A with rules?

texts:
I'm having some issues writing some rules for my site.

Let's say I have two products. B and C, as well as a combined product called A. Buying product A should decrease the stock of B and C by 1, but the stock of product A should also always be the lowest stock of B or C.

I can't, for the life of me, find out how to do this, and googling has turned up zero results.


texts: Any Modules to help with price caculator?

texts:
Ive made a booking form using Drupal 6, where bookings are a content type and you create a node of that type to make a booking.

I now need to add a price calculator. When creating a booking node, one of the CCK fields you fill in is distance. I then need the price to be calculated from the rates below, and that value to be given to another CCK field.

Rates:
0-5 km $20/ mile
5-10 km $15/ mile
10-20 km $10/ mile
20-30 km $5/ mile

So if the distance was 11km, the price would be 11 x 15 = 165. Also, the rates table needs to be editable by the site admin.

Can any modules do or at least help with this? I could probably manage to do the calculations and change the price field value with jQuery. If the table was shown on the page then jQuery could grab the values from it, and the table could be editable by the admin so the rates could be changed. Im far from a jQuery expert though and I love Drupal's ability to do powerful stuff without writing code.
Thanks


texts:
What are the steps needed and modules required to convert a large number of nodes from one content type to another, both in Drupal 7. They are fairly simple. If you know of a good tutorial that would be great too.

All my searching seems to bring up migrate which I thought was from 6 to 7.

I've tried node convert but I'm not sure how to use actions or if it can do many nodes at once.

And would it be possible for the URL alias and the taxonomy selections to be transfered?


texts: Different css of #main-content at differnt page url?

texts:
I have set the css of the main content in theme css as,

#main-content {
    background:#CCC;
    box-shadow: 0 0 1px #0F4C6A;
}

So it gets apply to the every page/node/content whatever I create which is quite common. For some pages I do not want this css to apply to #main-content. Is there any way I can achieve this?


texts: How can I change the value of a field in node / [id] / edit?

texts:
I should change the value of a field before it is rendered. I tried with [NAME_MODULE]_node_view but it is not invoked when I edit the node.

Thank you so much.


texts: It is it difficult/time consuming to set up a Drupal site that users pay to subscribe to?

texts:
I have never implemented a payment system in Drupal but it looks like I will have to do it in the very near future. I have plenty of Drupal experience, including writing custom modules, but I know nothing about payment systems.

I know of the Ubercart and Drupal Commerce modules and presume this is the standard way to go when setting up payment system for a Drupal website.

Basically I need to let users pay for monthly subscriptions for the site, and then money will be automatically taken from users' accounts on a monthly basis, until they cancel the subscription or it runs out.

Is this difficult/time consuming to set up? Will it take a weeks to implement for someone like myself with no prior experience in this area? How long rougly would I be looking at to get this set up?


texts: Provide unique values from a user profile field in a content type field (How to use DISTINCT in ER View)?

texts:
My users profiles contain a field with department name.

How can I make the unique values from department available in a select list within a content type field?
i.e. Sales, Marketing, IT, etc. (to avoid duplicates).

UPDATE:

I created Entity Reference > Select List > User (target type) + a view with ER that contains the user profile field department, but Query settings DISTINCT still doesn't get rid of the duplicates.

I even tried views_distinct module with Filter Repeats.


texts: Image styles not generating when an unrelated htaccess rule is active

texts:
Having a very bizarre problem on Drupal 8.4.4.

I have a custom module which accepts an image through a POST request and saves it as the submitting user's profile picture. This module has been in place for at least a year and has been working fine until recently.

This is the relevant section of code:

$syncfile = $_FILES ['file'];
if (isset ( $syncfile )) {
    if (strpos ( $syncfile ['type'], 'image' ) !== false) {
        $ext = explode ( "/", $syncfile ['type'] );
        $extension = $ext [count ( $ext ) - 1];
        $imgname = \Drupal::currentUser ()->id () . "_" . $pd->imagedate . "." . $extension;
        $img_dir = make_jpeg_target_size ( $syncfile ['tmp_name'], 3000 ); //this is a function that just resizes the image
        $img = getimagesize ( $img_dir );

        //save image to drupal's filesystem
        $path1 = "public://profile_images/";
        $path2 = \Drupal::service ( 'file_system' )->realpath ( file_default_scheme () . "://" ) . str_replace ( "/", DIRECTORY_SEPARATOR, "/profile_images/" );
        $file = File::create ( [
                'uid' => $user->id (),
                'filename' => $imgname,
                'uri' => $path1 . $imgname,
                'filemime' => $img ['mime'],
                'status' => FILE_STATUS_PERMANENT
        ] );
        $file->save ();
        $fid = $file->id ();

        //delete existing profile image and replace with this one
        if (isset ( $user->field_profile_image->target_id )) {
            $f1 = File::load ( $user->field_profile_image->target_id );
            \Drupal::service ( 'file.usage' )->delete ( $f1, 'file', 'user', $user->id () );
        }
        \Drupal::service ( 'file.usage' )->add ( $file, 'file', 'user', $user->id () );
        $user->field_profile_image->target_id = $fid;
        $user->save ();
    }

I also have a rule in the conf.d file for my site to block external access to files of the apk, log, and pdf filetypes. This has also been in place for a while. The rule is not in .htaccess as that is part of drupal upgrades and would get overwritten.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?<my domain> [NC]
RewriteRule \.(pdf|apk|log)$ - [NC,F,L]

Very recently, not sure exactly when, these two things have not been working together. When I disable the conf.d rule and make no other changes, and then test the module code, the new image shows up resized in the styles folder but the pdf/apk/log filetypes are not blocked. When I re-enable the code, the filetypes are blocked, but images sent to the module are not created in the styles folder. I am testing with different images and timestamps each time.

Neither Drupal nor Apache report any errors when this fails either, and Drupal verbose logging is enabled. The user's profile is making reference to the image that should be in the styles folder, so it's understood by the system that the resized image should exist, but the image is simply never put there and it draws a blank.

If I disable the apk/log/pdf block rule, the upload resize happens with no issue. This makes no sense as the block rule is not written to affect images. This has only stopped working in a recent upgrade, but not sure which one.

I tried this suggestion, but it did not fix the issue.


texts: How to group two fields while creating content type?

texts:
I wanted to a content type which get number of title and links. And I want an option which allows the user to add more title and links. The fields in the content type are

   1. Promotional Image
   2. Image Alternative Text
   3. Title
   4. Links

In the above mentioned field. I wanted to group only the Title and Links field. I wanted to give add more option for those two fields alone. Can anyone tell me how this could be done. I cant establish a link between those two fields. At present when I select the 'number of values' option in field settings it gives me add more button to each field but I am not able to link those two fields with any relation. Can anyone please suggest me a solution?


texts: Updating a taxonomy term, with extra fields - taxonomy_term_update does not exist

texts:
In Drupal 7, I am trying to update and delete some taxonomy terms in the proper way. So, instead of attacking the database directly, I am using taxonomy_term_delete for deleting by tid. However I cannot find taxonomy_term_update and about taxonomy_term_save, it seems not to have access to the extra fields that I added (a few fields, text and integer).

How can I make the following pseudocode to work? ( this does not pretend to work, it is just some pseudocode in a dialect of Drupal to make the question more understandable )

 $term = taxonomy_term_load ( $tid )   // or equivalent function
 $term->extra_field_1 = 23; // extra_field_1 would be numerical
 taxonomy_term_save($term) // o taxonomy_term_update or equivalent

Result: the extra_field_1 value of that term ( with tid = $tid ) is set to 23.


texts: Get values from views exposed filter in hook_views_pre_view

texts:
I would like to get the current values from an exposed filter in hook_views_pre_view().

For example, if the input filter has some value I would like to change de pager: number of items, the problem is how to get this value from views without using $_GET because I don't think it will work with views ajax.

What is the right way to get current exposed filters values from a view?


texts: comment body size in hook_form_comment_form_alter

texts:
What is the correct syntax to alter the size of the comment form body text area?  I can't for the life of me find it in devel dpm.

$form['comment_body']....something....


texts: Is there a way to run a shell script on a custom cron?

texts:
I'm new to all this so maybe this isn't the best solution, but I've created a shell script cache warmer.

wget --quiet http://www.example.com/custom-sitemap.xml --output-document - |
egrep -o "http://www.example.com/[^<]+" | wget --delete-after -i -

I can also do this with drush commands too using the cache warmer module.

I need to figure out how to run these commands every couple of hours.

My understanding was that I could create a custom cron job with Elysia cron that ran the script on my server, but now I am confused if this is possible / how to implement.

When I go to the script section and write the following:

*/15 * * * * custom_cron

I am told it it is an invalid line.

Can you make custom timed cron jobs then use the elysia cron API to make a module call my shell script?

Thanks!


texts: How to programmatically add a field to a view depending on another field and reorder fields then

texts:
I broke a site yesterday using views global php, even if it was working in the preview, so I'm a bit nervious about that php in database and I'm trying to implement the same thing with Views API.

Depending on the key value of a hidden field in the current display, I need to put a custom text. Something like (global php version) :

if( isset($data) && isset($data->field_field_statut_depart) ) {

  switch(  $data->field_field_statut_depart[0]['raw']['value'] ) {

    case 1:
      $text = 'ABC';
      break;
    case 2:
      $text = 'DEF';
      break;
    //and so on

  }
  print $text;
}

I'm trying to build it with hook_views_pre_view(&$view, &$display_id, &$args) but I can't find the required field_statut_depart value in  dpm($view).

Maybe it's not the right hook ?

EDIT : after applying solution described in the answers below (views_post_execute hook) and 12 hours running, I'm facing a strange behaviour : the changes made by  views_post_execute hook are not stable : after clearing caches, they are visible for a while but raw data (without my function applied) is displayed then ! I'm afraid it's still not the right place to do that. Any help is welcome.


texts: When i created custom template for view page using 'theme information' in views,it's not affecting the page.What is the proper way to create template for view pages?


texts: How to reindex a particular node in Drupal 8?

texts:
I want to index particular node on update, insert how to do it in Drupal 8?

In drupal 7, we use the function function _node_index_node()

I want to use the same function in drupal8 for my Drupal 8 Site.

I have searched the drupal 8 change log, I have got [NodeSearch::indexNode()] function.
I have inherited node search in my class and used the above mentioned function but i get an error  "class not found" .

Is anyone familiar with this function? Please provide me inputs on how to do this in drupal 8.
I am new to Drupal 8.


texts: I don't know the process to theme inside regions in Drupal 8. I have the knowledge to theme regions by putting {{ page.XXX }} in the twig file (with regions declaration in the YML file) .But for example I have the "Content" region containing 2 blocks: Page Title and Main Page Content. How can I do to theme only the Page Title or the Main Page Content block in the twig file, also with the fields inside the blocks (text, title and such). Any help is most appreciated.


texts: Where is links__system_main_menu defined?

texts: I searched for links__system_main_menu, but just find usages of this theme. Where is it defined?


texts: Why do users with permission to post commenst get "You do not have permission to post a comment"?

texts:
I have some users with roles administrator, authenticated etc. All such user roles have permission to post a comment.

But when posting a comment it is showing error "You do not have permission to post a comment." along with "Your comment has been queued for review by site administrators and will be published after approval."

How can I solve this issue?


texts: How to set the page title as the default in a drop list box?

texts:
I have a website that has links to inner pages on its home page.
When the user clicks on any of the link to an inner page, i need the title of the page that is opened to be set as the  value in the field in the webform that is present on the inner page.

Say, for example a inner page has the title "Attractions'. The inner page has a webform that has a field A.

When the "Attractions" page is opened during navigation, how can we make the "Attractions" (page title) value to be set in the webform Field A?


texts: Commerce Module - Changing product in a display node makes the image revert back to default

texts:
I am having some trouble with the D7 Commerce module.

I have a t-shirt product type with three fields; 'shirt size','shirt color' and a image. Each shirt that is a different size but the same color uses the same image. Shirts with different colors use a different images.

For one product display node, I select a small,medium,large shirt size for both white and black colors. So 6 products total for one node. This way the user can select color and size for the shirt on a single page.

When a user selects a different color the image changes to that color version of the shirt, which is great. However whenever the user chooses a different size after already picking a non-default color, the image reverts back the the default color+image. So the user would have to select the color again. Or
even worse, not realize that the color changed and order the wrong color.

How can I make it so the color+image doesn't change back to default when a different size is chosen?


texts: Passing JS settings local to an instance of a field

texts: When attaching a behavior to an object there are two parameters, context and settings. As I understand, settings object is global to all the page. But what to do if I need to send different settings to different widget instances on a single page?


texts:
Installed Lightbox2 plugin in my Drupal site. And created a image field. Copy the field--custom_field.tpl.php on my template folder. With the following:

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
     <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?>

    <?php endforeach; ?>

Now, i must include this code in my tpl file.

image #1

But i don't know how can i do? Thanks.


texts: Change sort order for view when exposed filter text field submitted

texts:
I have a view that by default is ordered by date. It has several exposed filters one of which is for filtering by text (we use it as a search field). I'd like the view sort to change to Relevance when a user submits a search but I also want to set it so it only does this once in case the user changes the sort order and then modified their search string. Is this possible? I'm using Better Exposed Filters, fwiw.
The view content source is "content datasource" from the drupal search api.


texts: How can i restrict /admin login page to a particular IP only?

texts: I want to restrict the http://www.mysite.com/admin login page to a particular IP only. Do you have any suggestion?


texts: Show content that referenced to a user to him

texts:
In my site I have a content type with a user reference field.

I want to create a view to show  contents to a user that are referenced by this user reference field.

How would I do this?


texts:
I want to execute code before cache is cleared, for example for the menu cache:

// Clear menu cache
$cache = \Drupal::cache('menu');
$cache->deleteAll();

I want to intervene when the cache clear is called, right before it is deleted. I've read the documentation on Drupal::cache and the Cache API but didn't find a solution. Do note that I want to do this using core code only, no contributed modules.


texts: How to create dynamic query for inner join on same table?

texts:
I want a dynamic query to do inner join on same table.

My query is:

SELECT t1.table1 FROM table1 t1 INNER JOIN table2 t2 ON t1.id = t2.id AND t1.name = t2.name"

I want to join table1 and table2 based on id and name present in table2.

What is the equivalent dynamic query in Drupal for this?
How this can be achieved?


texts: Does the drush up command work on multisite?

texts:
I have to update all sites on a D7 multi-site installation. I normally deal with single installation and I use drush up to update the core, modules and db. I have no prior experience with a multi-site installations.

I read this article on how to install drush for multi-site but I would like to know if running drush -l mysite1.com up will actually work before running it.

Kindly help if you have prior experience in this matter. Thank you.


texts: how to specify which region of panelpage can be displayed with php

texts:
I am using a page--front.tpl for my frontpage.

It overrides a panelpage whice i use for my frontpage.

I can display the content of my panelpage with <?php print $content; ?>

Is it possible to specify which region of my panelpage i can print with php?


texts: How to make each header in a table clickable and add a chart to it?

texts:
I have used the Views module to display an external database (which is working fine), but I want to make each header clickable and add a chart.

Is there a module to do this, or is there a way I can do this?

I found a few charting modules; some are good but they require me to create each chart manually, using the style and the data gets feed to it dynamically. The problem is that my tables have many headers; I flip the rows and columns but there are over 100 headers in it.


texts: is there anything like $view_mode in user-profile.tpl.php

texts:
in node.tpl.php you have variable $view_mode, is there anythings like that in user-profile.tpl.php?
user is bundle like node, and you can define different view modes for it.


texts: Reject Form Submissions with URL in them

texts:
I have a client who is using Drupal and has an email contact form.  The problem is they are getting spam sent through the form daily.

I have tried the Re-captcha plugin, captcha plugin, Anti-spam (Askimat), and Honeypot plugins.

The offenders are using programs like XRumer which is capable of solving captcha's and none of these plugins have been able to stop the bots.

So I am asking others if they have any advice on how to stop these contact form spam submissions?

Since this particular form shouldn't have a legitimate reason for a URL in the body section, possibly I could detect URL's and then return an error if they are present when a form is submitted?


texts: Is it possible to generate an URL object from a path?

texts:
Can I generate a

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Url.php/class/Url/8.2.x

from a simple path, e.g. "/products/widget" ?

(assume /products/widget exists in the system and is a canonical path)


texts: Generate reports of similar web forms results

texts:
In Drupal 7, I want to generate a report of similar webforms (same fields but created 2 webforms to handle multilingual translations) results. All the fields in my both webforms are same. I tried to use Views to fetch the results of both webforms, which is not working.

Any idea on how to achieve this?

I did this to get the filename of teh fid saved in webform_submitted_data table.

Added SQL:

SELECT wsd.nid, wsd.sid, fm.filename,
       MAX(CASE WHEN wsd.cid = 2 THEN wsd.data END) fn,
       MAX(CASE WHEN wsd.cid = 3 THEN wsd.data END) ln,
       MAX(CASE WHEN wsd.cid = 4 THEN wsd.data END) email,
       MAX(CASE WHEN wsd.cid = 5 THEN wsd.data END) ph,
       MAX(CASE WHEN wsd.cid = 6 THEN wsd.data END) tr,
       MAX(CASE WHEN wsd.cid = 7 THEN wsd.data END) upr,
       MAX(CASE WHEN wsd.cid = 9 THEN wsd.data END) coc
  FROM webform_submitted_data wsd LEFT JOIN file_managed fm ON wsd.data = fm.fid WHERE nid IN(66,67) GROUP BY wsd.sid;


texts: How to fix the garbled text in my text editors?

texts:
When editing my nodes all of my saved data is displayed garbled. This is the warning I get on my node/edit pages: "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/."
The other odd part is that the contents of the database field and the contents of the output are correct. Just the contents of the text editor is garbled.
How can I fix this?

UPDATE: I have another content type that has a file field, and I have some pdfs loaded in those fields and those pdfs are the ones that are showing up in my text editor. Does anyone know why that would happen?


texts: How to set up a repeated “field set” with unlimited time and event?

texts: I am planning to set up a “patient visiting record” , the repeated “field set” is time and events, for instance, “2017-12-15, the first visit, patient has stomach pain”, “2017-12-30, the second visit, patient has vomiting, has a rash on the left leg[image upload]”....every time when I click on “add item” the “time and event set” will pop up as one field. And the series “daily like” records will show on the patient record page, of course every patient will have their own page. The records of course are only accessible for admin. Is that possible to realize?


texts: Programatically retrieve a block and print it in a page

texts:
I have a form, generated by the Webform module, which is available as block. Now I want to retrieve the form itself and print it in a page.

How can I achieve this, programmatically? I'm using Drupal 7.


texts: How do I make ugly URLs such as "/index.php?main_page=about_us"?

texts:
I'm converting a Zen Cart site to Ubercart and need to keep Zen Cart’s ugly URLs for SEO purposes. The site is top ranking on Google Search for their keywords and I’ve been advised that changing the URLs to something cleaner could potentially hurt rankings.

I wonder if there is any way to give a node a URL like http://example.com/index.php?main_page=about_us?

By default Drupal encodes special characters, so it tries to make my URL /index.php%3Fmain_page%3Dabout_us and I also get a 403 error.


texts: How to bypass CAPTCHA during Behat functional testing?

texts:
We have a site that uses the CAPTCHA and CAPTCHA After modules to protect forms from invalid submissions. We're doing some functional and BDD testing using Behat and the tests are sometimes triggering the CAPTCHA After thresholds, causing the CAPTCHA to be displayed. Is there an easy way to bypass the CAPTCHA, when performing tests?

I realize that we can probably override the CAPTCHA After threshold settings in the database, if the tests are running on the same machine. However, it would be nice to also be able to run the tests from a different machine than the web server hosting the site. I think that something like an IP whitelist might work, but I haven't found anything along those lines yet. Before we start coding something like that, anyone have a better idea?

Thanks!


texts: I was wondering, is there anything like webform calculator for entity forms?


texts: Using preprocess node variable in page.tpl.php

texts:
I've set up a couple of variables in my template_preprocess_node(). How can I access them within a page template? I can access the $node variable, but it doesn't seem to have been preprocessed.

How can I force preprocessing?


texts: Are entity IDs assigned per entity or across the board?

texts:
I'm building an electronic parts database in D7 and want to create a custom "part" entity with bundles for resistors, capacitors, etc.

I also need to autocreate an atomic serial part number common to all bundles, i.e no separate part numbering system per bundle.  I was going to use the Serial module but it only works with nodes.  In D6 I did everything in nodes for a similar application and just used the NID, but this parts DB really wants a cleaner solution using entities. I'd like to use the entity ID as the serial part number but only if it's unique per custom entity type.

Question is: Does each custom entity type I create have its own set of entity IDs or is it like in D6 with nodes where NIDs apply across all content types?


texts:
I can't figure out how to select all aid's from the areas table that do not exist in the field_data_field_area_parent table.

It almost works, except it returns Windy Ridge with an "aid" of "11".   I am guessing that this is because "IN" is the same as "ANY", and the number "1" is in the subquery results.

How can I use NOT EXISTS instead of NOT IN?

function verb_get_parent_areas () {
  $query = db_select('areas', 'a');
  $query->distinct();
  $query->fields('a',array('name','aid','parent','latitude','longitude','description'));
  $subquery = db_select('field_data_field_area_parent', 'p');
  $subquery->fields('p', array('entity_id'));
  $query->condition('a.aid', $subquery, 'NOT IN');

  $result = $query->execute();
  while ($record = $result->fetchAll()) {
    $areas = drupal_json_encode($record);
  }

  return $areas;
  exit;
}

I've thought of trying this, but it returns nothing.

function verb_get_parent_areas () {
  $query = db_select('areas', 'a');
  $query->distinct();
  $query->fields('a',array('name','aid','parent','latitude','longitude','description'));
  $subquery = db_select('field_data_field_area_parent', 'p');
  $subquery->fields('p', array('entity_id'));
  $query->notExists($subquery);

  $result = $query->execute();
  while ($record = $result->fetchAll()) {
    $areas = drupal_json_encode($record);
  }

  return $areas;
  exit;
}


texts: 2 servers with 2 local memcached: flush both

texts:
I have servers and 1 memcached server linked by the network. When I add 2 memcached on the 2 servers, locally, it's drastically faste !

So I've configured Drupal to use memcached on 127.0.0.1, except for sessions.
The sessions are the only data hosted on the network server (MC 3).

DRUPAL 1    DRUPAL 2
 MC 1         MC 2
   \            /
    \          /
     \        /
        MC 3
      Sessions

It's fine, except for the cache flush because when I do a drush cc all, Drupal 1 will only flush MC1, and Drupal2 only MC2, but not both.

The idea is to force Drupal to clear all the memcached, but to use only the localhost + MC3.

What is your advice, add a hook to clear both servers?


texts: How should I prevent second page of site's front page from being indexed?

texts:
My website's second page has the URL http://example.com/node?page=1

I've got the marinelli theme installed.

For SEO purposes, what should be done for the second page node?page=1 of blog listings? Should I disallow it from robots.txt or do something else?


texts: How does the Drupal template engine work?

texts:
I've just started learning about Drupal 7's theme system. I need to know how the template engine handles php, html, and css inside its template files and how it interacts with Drupal core to make its final output onto the page.

Basically, when we load a Drupal page in browser, what does the template engine do?


texts:
To control the number of search results showing in a solr site search page there is a text field in admin/config/search/apachesolr/search-pages/core_search/edit

In advanced option tab, there is an option called Results per page to specify its count. but I need to alter the pagination displayed in search page. It displays 1 to 9 pagers by default I want them to be 5. what should I alter??


texts: Count number of values within a field that accepts unlimited values

texts:
I have an image field which can contain unlimited values. How can I display the number of image values contained within this field in views?

I'm using Drupal 7.


texts: How to unlink the teaser title from the original content?

texts:
I have a page having list of teasers populated using views for a certain content type. Now, I want the title of the teaser not to be a link to the original content/node. I want the title in same format but not to be a link. Please help if anybody know how to do it.
I am using Drupal 7.


texts: How to use value passed to views_embed_view as a filter?

texts:
I want to embed a View in a node template. I understand that I can use views_embed view to do that, and pass values to it.

$my_arg = $node->nid; //the nid of the node that I want to use as filter
print views_embed_view('my_test_view', 'block_2', $my_arg);

How can I use that value as a filter ? I want that view to list nodes that have a field with the same value as the passed to the function


texts:
I am using the following code to display a date popup in my drupal 6 custom module.

 $form['intelligence']['start_date'] = array(
    '#type' => 'date_popup',
    '#date_year_range' => '-100:+0',
    '#description'=>'Start',
    '#prefix' => '
 ',
    '#date_format' => 'Y-M-d',
    '#default_value' => date('Y-M-d',  time()),
    '#suffix'=>'
'
 );

But I am getting default date blank.

I have gone through Date popup form field doesn't show the default value correctly and
string espected but array given in custom pop_date field #default_value , but no success .

Can anybody tell, what the issue is with this code? Actually I need $_POST['start_date'] as the default value. But for testing purpose I put date('Y-M-d',  time())


texts: How do I make a multi item table order list for Drupal Commerce?

texts:
I have several items that should be allowed to be ordered on one page using Drupal Commerce. Take the example of dairy products. There should be a table of dairy items a person can purchase such as milk, cream, butter, and cream cheese. Each of these items should be viewed as a row of a table in the dairy page. The customer should be able to mark the number of each item they want to purchase and submit the form using a purchase button at the bottom of the table. How is this done using Drupal Commerce? The checkout view does just this. Is it possible to create views that do this too?

Here is an image of the checkout form that does this.


texts: How do I integrate the Color module in my theme?

texts:
I have installed drupal 8.4.2 and created a subtheme with base theme
   bootstrap. I want to customize settings adding the color module, but
   really I do not know what steps I am missing.

I have enabled color module (it's in core)
I have copied (from bartik) the color directory and files
I have edited color.inc to have  my custom color schemes
I  have edited THEME.theme adding this:

function MYTHEME_process_html(&$variables) {
  // Hook into color.module.
  if (module_exists('color')) {
    _color_html_alter($variables);
  }
}
function MYTHEME_preprocess_page(&$variables, $hook) {
    // Hook into color.module
    if (module_exists('color')) {
        _color_page_alter($variables);
    }
}

As a result I have white page with no rendering. (It's not cache issue) and I guess my problem is with .theme file
I'd like to know where to find the instructions (drupal.org has not much). Thanks


texts: Why do I get a fatal error when clicking on the permissions tab in admin/people?

texts:
Steps to reproduce:

Log in as administrator
Click on People
Click on the Permissions tab

This navigates to admin/people/permissions. Here is the complete source code for that page:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2048 bytes) in /.../includes/common.inc on line 6300

Why am I getting this error and what can I do about it?

Notes:

my php.ini file contains the following line: memory_limit = 128M
.../sites/default/settings.php contains the following line: ini_set('memory_limit', '512M');
If I go to Reports/Status report and scroll down to PHP memory limit, it says 128M


texts: Sub Menu's are not coming under main menu

texts:
I am using this code to fetch menu's in drupal. I have given Home as parent menu and other are sub menu's like submenu1, submenu2 etc. But in front end they are not coming under Home menu. Only Home menu appear on front end.

<?php if ($main_menu): ?>
     <?php
          // This code snippet is hard to modify. We recommend turning off the
          // "Main menu" on your sub-theme's settings form, deleting this PHP
          // code block, and, instead, using the "Menu block" module.
          // @see https://drupal.org/project/menu_block
          print theme('links__system_main_menu', array(
            'links' => $main_menu,
            'attributes' => array(
              'id'=>'s5_nav',
              'class' => array('menu'),
            ),

          ));
          ?>
    <?php endif; ?>


texts: What is the best way to allow user Edit one Form?

texts:
I want to make a dynamic website using Drupal 7 that allow user to edit any part of the site

this site has more than 10 pages each page has a different content and structure

should I make a content type to each page and add one node to each cck and give permission to site admin to edit this node

Or there is another way (I don't want to make a lot of cck because it make a lot of tables in database) also I need to edit only

I want the best way to make it

Thanks


texts:
I found the code below to print a watcher link in a block, but it is for Drupal 6.

<?php
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    $node = node_build_content($node, false, true);
    print $node->content['watcher']['#value'];
  }
?>

Does anyone know how to get the same thing done for Drupal 7?


texts: How to mark a Message as 'viewed' when a user sees it in a View?

texts:
I'm displaying a user's Messages (created with the Message module) in a View. I'd like to flag them once they're viewed and thought that a Rule could do this easily. I've set the Rules Event to "A message is viewed" and the Rules Action to "Flag a message", but for some reason the viewing event is not triggered. I tried hovering the Message, visiting the referenced node's page and visiting Content > Messages, but nothing runs the Rule.

Did anyone experience the same problem before? Maybe this is a bug in the Message module (I've reported it at https://www.drupal.org/node/2291695), but I'd like to know whether you've already found a solution for this.

Ultimately, I'd like the Rule to be activated when a user hovers the Message or clicks it (I've already made sure that he/she will then be redirected to the referenced node/comment).


texts:
I have a Drupal 8 site that is using a bunch of custom views with REST endpoints. These views contain a bunch of content nodes on them which make up a single page.

I have been able to generate an XML sitemap of the views by using Simple XML Sitemap module but I am wanting to know if (and how) it's possible to generate a JSON sitemap of all the views and the paths that are associated with REST but dynamically?


texts: How do I get a block configuration value in a module?

texts:
I created a custom block that contains a form field.

This is my blockSubmit() method.

public function blockSubmit($form, FormStateInterface $form_state) {
    // Save our custom settings when the form is submitted.
    $this->setConfigurationValue('my_text_field', $form_state->getValue('my_text_field'));
}

Now I want to access the my_text_field value from outside the custom block class.


texts: How can I hide node titles only for displayed nodes, and not node edit forms?

texts:
I have a little function to hide my node titles via template.php:

function mytheme_alpha_preprocess_page(&$vars) {
  if (isset($vars['node']) && $vars['node']->type == 'episode') {
    $vars['title_hidden'] = TRUE;
  }}

This function hides the title on the node edit form too, but for that form I need a title.

How can I avoid changing the node edit form in my function?


texts: Attach a Webform to user registration form

texts:
Is there any way to do this in Drupal 7?

I want new users send some documents via Webform on registration.

The reason is that I don't want to save these documents as an user profile field.


texts: How can I change the order of the list of countries provided by the Countries module?

texts: I have a Drupal 7 site that uses the Countries module.  I would like to show the United States first in the list and the rest of the countries then in alphabetical order (by default, the module displays all countries in alphabetical order).  This is a common feature on many sites so I'm hoping there's an easy way to do this.


texts: Clean and easy way to add meta tags to my D7 website

texts:
I'm looking for a easy way to add meta tags to my D7 website. Not that I'm afraid of code or anything like it, but the content managers (Marketing => biggest IT noobs you've ever seen) want to add meta-tags by using the Drupal UI.

I've checked the MetaTags Quick-module, but it seems like this module is only capable of adding path-meta tags. Are there any alternatives? Or what is the most clean way to add meta tags do my Drupal 7 website?


texts:
After moving my drupal installation to another domain (and server) ajax calls end up beeing redirected from the login-page to the target and back until the timeout is reached.

Why the target redirects the request to the login page and how to stop this?


texts:
I installed the Unsubscribe module. I have also set this module's permissions for both authenticated and anonymous user.

.

Now the unsubscribe checkbox is appearing on the edit account form, but not yet on the user register form, where I want it to appear too.

Is there a way to do so? As an alternative, do you know any other module that provides a similar function/feature?


texts:
I need to create a site that is editable for the client. The site is pretty basic: home, about, contact, etc. On each page there are different blocks of text. Like on my homepage, I have different sections like a basic text, "3 reasons" boxes, etc.

I have a content type "pages" with the title and the basic text, which is fine. But how do I create the 3 boxes? Do I create a custom content type for them too? If so, how do I add them on the front page with the text as well?

I heard a bit about the Views module. Would it be useful in my case?


texts: Display Only the Product Add to Cart Button

texts:
Drupal 8.4.2

On both the commerce-product and the node--product level, I can get the add to cart button to show, but it also renders the product variation fields as well.

If I have content that does not have variations and only a single price, how can I render just the "add to cart button" in the commerce form?

I've been all through config via the admin panel and feel I am just missing something obvious???

My question would be: How do you render just the add to cart button on the product level, or node level (via reference) via the admin panel?


texts:
I want to write a page that works like this:
http://www.albemarlegallery.com/artists.php

i.e. when I hover over a link from one block, an image in another block updates

How can I do that?

Thanks


texts: How to change the author of a node after payment using the rules module?

texts:
I would like to use the rules module to change the author of a node after payment.

Even though I have limited experience with the rules module, I am sure it is possible to do.

This is what I'm looking for:

Client pays for existing node.
Ownership of the node is transferred to that client.

Any help would be greatly appreciated!


texts:
In my panel in "Taxonomy Term Template" I have shown the children terms in the current parent term page. Now I need to attach/associate an image to each term to make it look nice. I do see the option of selecting the term image field in the panel settings but that field shows the current parent term's image not of the children.

I have already added images for each term in my vocabulary.

I'm on Drupal 7.

Here is the screenshot to elaborate the scene.


texts: RuntimeException when running drush commands in root folder

texts:
I am setting up a local site for development on a ubuntu server 18.04 VM.
I pull our repo into my windows machine and then mount this onto the VM as a shared folder.
I run composer install and it finishes completely, but when I go to my site's docroot folder and run
drush st or drush cr, I get the following error message:
RuntimeException: Drush::$container is not initialized yet. \Drush::setContainer() must be called with a real container. in Drush\Drush::getContainer() (line 151 of /media/sf_anothercnas2/vendor/drush/drush/src/Drush.php).
Drush command terminated abnormally due to an unrecoverable error.

Drupal installation went through successfully. In my composer.json,
I have "drush/drush": "9.7.2"
Composer show confirms that the local drush version installed is 9.7.2 but when I run
drush --version, it returns 8.1.16


texts:
Drupal website unexpectingly takes all data from .dev db, thow settings point the main db.

Is there any way to fix that?


texts: View with content from Media gallery links to node not working

texts:
So i have a couple of nodes I made with the media gallery module. Then made a view called 'most recent photoalbums' with I put inside a block to be displayed on the frontpage.
The problem is that characters %5B and %5D are being generated against will and make the links to the nodes not work when clicked.
So, hovering over an image in such a view

So with display set as block, everything is left as default except the following:
Format:
Show: fields

Fields:
Content: title - nothing fancy here when it comes to settings just linked to node

Content: Gallery media - here obviously is the problem

No labels set whatsoever
uncheck exclude from display
Formatter set to Media
File view mode: Preview
Multiple field settings fieldset: 'Display all values in same row' checked, Display type: 'unordered list', 'Separator: Display 4 values starting from 0' - 'reversed' unchecked - 'first and last only' unchecked.
Style settings fieldset: only 'add default classes' checked.
Rewrite settings fieldset (where it's at):
'Rewrite this output as fied' unchecked,
'Output this field as link' checked,
'Link path': node/[title] (I tried all replacement patterns as suggested ),
'use absolute path' unchecked,
'Replace spaces with dashes' checked,
'External server URL' unchecked,

Transform the case: no transform, all the textfields under

Link class, title text, rel text, Prefix Text, suffix text and Target are left empty,
'Trim this field to a maximum length' unchecked,
'strip html tags' unchecked, under 'preserve certain tags'  -> 'remove whitespace' checked,      'Convert newlines to HTML br tags' unchecked.


texts:
In a Drupal 7 site taken over from an ex-colleague, sessions for anonymous user always are generated as this screenshot shows.

The security-scanning service provider always claims:

  Our company also observed that the application sets the  SSESSd84a1fe63b666c4294afc5029aa95bfd cookie prior to authentication and it doesn't update the value of the session cookie even after authentication but, as the user is not able to fix the session by updating the cookie, it was not reported as a separate finding.

I'm a novice Drupaler. I installed a new Drupal 7 site from scratch, and there isn't a session cookie, but there is one in Drupal.org. I also checked contributed modules in my site, disabled the most suspicious 2 modules (login_destination and betterlogin), still no luck. I added a line "ini_set('session.cookie_lifetime', 0);" in settings.php file, no luck again. I don't know how to do next.


texts: Use sites.php to point https and http to diffent sites

texts:
I've got several Drupal sites on different domains running on the same code using sites.php.

What I want to do is point the same domain to different sites depending on whether it's accessed via http or https.

For example, in sites.php
$sites['http://www.example.com']='site1';
$sites['https://www.example.com']='site2';

However, the above doesn't work. It looks like you can't specify protocol in sites.php.

Thanks,

Robin


texts: View is returning two default results when no value in filter is being selected. Why?

texts: I have created a view to display node's title and added exposed filter for filtering content. When the view page is loaded it is returning two nodes , I do not know on what basis it is returning those two nodes.I want no result should be displayed until I select some value in filter.Please suggest ??


texts:
Why is that I cant import taxonomy terms with feeds, it says it imported 23 terms, but they are nowhere to be found....

I used term name, url alias, term id in mapping then imported it via feeds, nothing happens, it says that the terms were imported but tehy are not

vocabolary is called category...


texts: What is your way to add images into panels - simple and fast?

texts: How can you upload images into panels simply and fast? That's all I need - images in panels, simple and fast. thanks.


texts: What's wrong with the autocomplete in the search textbox using apache solr?

texts:
I have apache solr version 4.x and Drupal 7.39. I just want to create solr search in Drupal.

I have installed Apache Solr Search, Apache Solr Autocomplete (tried both dev version and recommended version), Facet API modules. I have created the search page, everything is fine except the autocomplete in the search textbox!

Is there anything need to be change? Is there any other workaround for this?


texts:
Goal: Print/dump $formState values to debug
I am altering a form and the functionality works:
$form['elements']['location']['deparment']['#ajax'] = [
  'callback' => 'myAjaxCallback',
  'event' => 'change',
  'progress' => [
    'type' => 'throbber',
    'message' => t('Verifying entry...'),
  ]
];

but what I want is to be able to print out $formState in myAjaxCallback
function myAjaxCallback(array &$form, FormStateInterface $formState){
 $response = new AjaxResponse();
 print_r($formState); //I've tried, with memory_limit=-1 . it just hangs
 dump($formState); //gives me File upload exceeds. This comes from issue with using dump in ajax
                     https://drupal.stackexchange.com/questions/250078/ajax-submission-leads-to-an-unrecoverable-error-occurred-the-uploaded-file-l

 return $response
}

I have also read https://www.drupal.org/docs/drupal-apis/javascript-api/ajax-forms and tried their Debugging AJAX Callback Functions, which has:
$response = new AjaxResponse();
$debugOut = @Kint::dump($formState); //but this uses dump too, which gives me ajax errors

so dd($formState->getValues()); kind of works. This is what it shows me. So, as you can see, I can now see the variables. It's not the best, but readable.

whereas if I go to [website]/webform?ajax_form=1 , it's not even readable.

I am running out of ideas to be able to debug the variable $formState .


texts: Mediafront Youtube playlist feed playlist problem

texts:
I installed the MediaFront 7.x-2.0-rc2 module and MediaFront: Youtube Playlist Feeds 7.x-2.0-rc2.

I want a player with the playlist on the side.  The feed imports fine and creates the nodes.  In my player, I have the video, but for the playlist, I have blank videos, each with a "Sample Title" title.  When I click on a blank video, it correctly plays the video in the main player, so the view knows about the other videos.

What am I missing?


texts: View block with contextual filter on taxonomy term name in URL doesn't work

texts:
Say, I have taxonomy vocabulary 'fruit' with terms like 'apple', 'pear' and 'grape'.
Through content type 'Healthy', 'Healthy' content is made using a entity reference field to choose a term from the 'fruit' vocabulary.

Now, on a page with path /food/good/apple, a views block is placed that should show content related to taxonomy term 'apple'.
I've tried to make a contextual filter in the views block like this:

When the filter value is NOT available > Provide default value > 'raw value from URL'
And for 'Path Component', I checked 3 (for the third position in the url, 'apple').
This however doesn't return any content.
When I remove the contextual filter, the block shows all Fruit content items.

Can this even be accomplished without using contrib modules?
Any help on how to get the right setup would be welcome!


texts: How to programmatically build Drupal in a Continuous Integration workflow

texts:
My team is relatively new to Drupal. One thing we have struggled to understand is how to work with it from a DevOps point of view. I realize this is too large a subject for one question so I have a more specific question that gets at the heart of the matter.

How does one provision a Drupal instance? By "provision", I mean create a provisioning script that builds my CMS (we're only using Drupal for that purpose) starting with a clean virtual machine with only OS and web server. The script would install and configure Drupal and its modules and connect to an existing database containing my content. Or perhaps I can even have it add my content to Drupal instance with an empty database. I'm just not sure what makes sense.

What I am trying to avoid is the uncertainty and non-reproducability that comes with doing everything interactively via Drupal's UI. I realize that Drupal has lots of techniques for exporting various things but there doesn't appear to be any coherent overall picture. Every bit of advice is of the form, "If you want to do (some specific thing), this is how you might do it." Or, even worse, "This worked for me." Neither of these things gives me much confidence or, more importantly, gives decent "best practices" advice that tells us what Drupal's designers intended.

There are some Drupal "best practices" articles but they don't go much beyond advice such as, "Do a backup before changing anything." I need more useful advice.


texts: How to override the menu_tree without affecting the admin menus

texts:
I've worked out how to override theme_menu_tree() using this code in template.php.

function myTheme_menu_tree($variables) {
  return '<nav class="menu">' . $variables['tree'] . '</nav>';
}

However, I've noticed that this is affecting other menus as well.

How do I target only non-admin menus?


texts: How do i create a payment method+gateway with a custom function called by the gateway to determine whether payment is successful?

texts:
We're looking to use a payment gateway - SecurePay in this case - that allows merchants to save credit card details in their system and then trigger payments against that credit card again for future checkouts by sending a token representing that credit card, without the user re-entering the details, and we don't need to store credit card numbers in our database.

The native handling of credit cards by UberCart, along with the uc_securepayxml module was great for the initial transaction, and storage of credit card number + token with SecurePay but the validation step on the checkout screen meant that it looks like I'll have to set up an alternative payment method + gateway to manage the sending of tokens for payment.

The problem that I'm having is getting Ubercart to fire the function that is supposed to either return success or failure when the order is finally submitted when I don't use the 'credit' payment method.

To be clear, the issue isn't (so far :P) sending the data off to SecurePay, it is convincing UberCart to use the return value of my custom function to determine whether a payment is successful or not, without using the supplied Credit Card module.

Here is all the relevant code (I think) that I'm currently using, so some advice on what needs to change or even just a working example would probably be enough to answer my question!

Using Drupal 6 and UberCart 2, and I cleared the Drupal cache a few times, btw.

<?php
/* This function creates a new payment method */
function uc_securepaytoken_payment_method() {

  $methods[] = array(
    'id' => 'sptoken',
    'name' => t('SecurePay Token'),
    'title' => t('SecurePay Token'),
    'desc' => t('Pay by triggering a tokenised payment through Secure Pay.'),
    'callback' => 'uc_payment_method_sp_token', /* I believe this callback function just sets some strings for display in various places and the validation when submitting on the checkout page, is that right? */
    'weight' => 1,
    'checkout' => TRUE,
  );

return $methods;
}

/*
* This function sets up the payment gateway,
* I believe that if the 'sptoken' key in the $gateways array matches the ID of the payment method,
* the function named in the value should be fired when I want to process a payment
* (NB - This doesn't actually seem to be happening)
*/
function uc_securepaytoken_payment_gateway() {

  $gateways[] = array(
  'id' => 'securepay_token',
  'title' => t('SecurePay Tokens'),
  'description' => t('Process credit card payments using SecurePay Tokens.'),
  'settings' => 'uc_securepaytoken_settings_form',
  'sptoken' => 'uc_securepaytoken_charge',
);

return $gateways;
}

function uc_securepaytoken_charge($order_id, $amount, $data) {

  /*
  * This is the function that I want to use to process a payment
  * and return success or failed, at the moment it doesn't seem to be working
  * and dpm() doesn't display anything, Ubercart simply always completes checkout without doing this
  */

  }

?>


texts: Drupal Queue is not processing with hook cron

texts:
All my code is here, the queues are created in backoffice, but the action in the worker call back is never processed. !  I lean the node creation in my function inalco_publications_queue_worker is seemingly not executed at all. I run many times the cron.

  $queues['inalco_publications_queue'] = array(
    'worker callback' => 'inalco_publications_queue_worker',
    // One second max runtime per cron run.
    'time' => 60,
  );

  return $queues;
}

/**
 * Implements hook_cron().
 *
 * hook_cron() is the traditional (pre-Drupal 7) hook for doing "background"
 * processing. It gets called every time the Drupal cron runs and must decide
 * what it will do.
 *
 * In this example, it does a node creation of all Inalco publications linked to REVUE
 */
function inalco_publications_cron() {

       $num_updated = db_update('node')
        ->fields(array(
          'title' => 656655,
          'status' => 1,
        ))
        ->condition('type','test_queue_api', '=')
        ->execute();

    $numeros_revue_bodies = "SELECT entity_id, body_value FROM {field_data_body} where bundle = :bundle";
    $result = db_query($numeros_revue_bodies, array(':bundle' => 'inalco_numero_revue'));

    $queue = DrupalQueue::get('inalco_publications_queue');
            foreach ($result as $row) {

                $queue->createItem($row);
                watchdog('inalco_publications', 'Numero de revue / Entity #ID -'.--$row->entity_id);

            }

  //drupal_flush_all_caches(); // ultra lent ...
}

function inalco_publications_queue_worker($data){

   drupal_set_message(t('Dequeued: %item', array('%item' => $data->body_value)));
   $html_obj = new simple_html_dom();
   $html_obj->load($data->body_value);

   foreach($html_obj->find('li li') as $bt) {

                $node = new stdClass();
                $node->type = "inalco_publication";
                node_object_prepare($node);
                $node->language = LANGUAGE_NONE;
                $node->title = $bt->children(0)->plaintext;
                $node->uid = 1;
                $node->body[$node->language][0]['value'] = $bt->outertext; /// remmettre english
                $node->field_publication_type[$node->language][0]['tid'] = 692;
                $node->path['pathauto'] = FALSE;
                $node->field_auteur_publication_non_ref[$node->language][]['value'] = $bt->children(1)->plaintext;
                $node = node_submit($node);
                node_save($node);

   }

}


texts: I need to clone a colorbox image link (the first of all colorbox links on the loaded page) and add it onto a div-tag. how could I do that with javascript/jquery? thnx!


texts: Using ImageField to add an inline image (save thumbnail, and when clicked open with colorbox)

texts:
Here is what I usually do in my websites:

Have an option for adding image in the WYSIWYG editor of my choice
User can upload the image
User can resize the image in the WYSIWYG editor
Have the Image Resize Filter enabled for the Input Format
When user resizes the image, it automatically saves the thumbnail and adds a lightbox/colorbox related attribute so that the image is opened using one of these libraries.

What the problem is now? I have come across a "not very tech-savvy" customer that is displeased with the way that the images are added right now as he cannot grasp any of the regular concepts for images.

Based on his description I reached to the conclusion that I need to implement the following workflow:

A straightforward filefield (imagefield) where he can press the "Browse" button and then the "Upload" button.
He will then write his text in the "Body" field and that's it.

My Requirements:

I don't mind if he cannot see the image when he is editing the node
Only one image will be allowed per node
I want to pre-edit the image's vspace, hspace and alignment (e.g.5px 5px
left)
I would also like if I could use the Image Resize Filter for the uploaded image so that only a thumbnail appears in the actual node (teaser and full view) and the original image appears in a colorbox
I don't mind if I will have to edit the node.tpl.php or any other theme file
It's needed that the image is added with the body of the node (e.g. at the start of the text)

What I've tried so far:

I have watched the MustardSeed video for Image Resize Filter along with ImageField Insert module (now it's called Insert) but there are some complex steps in there that my customer cannot comprehend (e.g. adding Vspace, Hspace, Alignment or even manually resizing the image). I would like to give my customer as few options as possible.


texts:
After reading the post about linkedin on IT security and this issue I would think that having a default Drupal 6 installation without, for example, the phpass module should be considered quite insecure, since the passwords are stored in a way which doesn't require much force to guess and check.

Should I run and install phpass on every Drupal 6 site?


texts: What are the database tables related to comments in Drupal 7?

texts:
I received a lot of spam comments in one of my websites running on Drupal 7. I googled for a solution to delete them in bulk and came up on

DELETE FROM comment WERE status = 0

The query worked but the database size did not shrink significantly and I realized out that in addition to the 'comment' table there was another table called

 field_data_comment_body

which housed the body of the comment.

I would like to know which all tables are related to comments in Drupal 7


texts: file field populate files in custom form

texts:
I'm trying to make custom form and add file field to it. Besides, I want to add uploaded files to this form. Here is the code.

function node_stage_stage_report_form($form,&$form_state,$nid)
{
   $stage_node = node_load($nid);

   $langcode = 'und';
   $bundle = "node_stage";
   $entity_type = 'node';
   $field = field_info_field('stage_report');
   $instance = field_info_instance($entity_type,'stage_report',$bundle);
   $items = $stage_node->stage_report;
   $form['#parents'] = array();

   $element = array(
     '#entity' => $stage_node,
     '#entity_type' => $instance['entity_type'],
     '#bundle' => $instance['bundle'],
     '#field_name' => 'stage_report',
     '#language' => $langcode,

     '#field_parents' => array(),
     '#file' => array(),
     '#columns' => array_keys($field['columns']),
     '#title' => check_plain($instance['label']),
     '#description' => $instance['description'],
     '#required' => FALSE,
  );
  $result = field_default_form('node',$stage_node,$field,$instance,$langcode,$items,$form,$form_state);

  $result2 = field_view_field('node',$stage_node,$field['field_name']);

  if(is_array($result))
     $form =array_merge($form,$result);
  else
    $form[] = $result;
  $form['submit']= array(
    '#type' => 'submit',
    '#value' => t("Add files"),
  );

 return $form;

}

The current way using field_view_field is not correct as I want to make the field look like in edit form. So, what's the way to do it in custom form?


texts:
I'm working on a module, which includes a page that displays a select from a database table. The page content is getting cached for long periods, so is out of date for users.

What's the simplest way to set the cache timeout for this page to a shorter time (or even set that page to never cache)?

(As an aside, I intend to turn this table into an entity and integrate with Views later on, but I need an interim fix).


texts: how to send the Sequential request in custom services module

texts:
I have two request
1. /............./endpoint/retrieve
2. /............./endpoint/create

In this case 'retrieve' request only working, if i am send the request as 'create' it's call the same callback function, but i am using different callback function in this following code

This is my hook_services_resources

function module_rest_services_resources() {

  return array(
    'new_note' => array(
      'retrieve' => array(
        'help' => 'Retrieves a note',
        'file' => array('file' => 'inc', 'module' => 'module_rest'),
        'callback' => '_module_rest_retrieve',
        'access callback' => '_module_rest_access',
        'access arguments' => array('view'),
        'access arguments append' => TRUE,
        'args' => array(
          array(
            'name' => 'id',
            'type' => 'int',
            'description' => 'The id of the note to get',
            'source' => array('path' => '0'),
            'optional' => FALSE,
          ),
        ),
    ),
      'create' => array(
           'help' => 'Creates a note',
           'file' => array('file' => 'inc', 'module' => 'module_rest'),
           'callback' => '_module_rest_create',
           'access arguments' => array('create'),
           'access arguments append' => FALSE,
           'args' => array(
             array(
               'name' => 'data',
               'type' => 'int',
               'description' => 'The note object',
               'source' => array('path' => '0'),
               'optional' => FALSE,
          ),
        ),
      ),
    ),
  );
}

what i need to change in this code, to access the both 'retrieve' and 'create'


texts: Access a custom field type value set in preSave, in hook_entity_presave()

texts:
I have a custom field type, that generates a value in a preSave hook.

class AutoGeneratedItem extends FieldItemBase implements FieldItemInterface
{
  // ** Snip **

  public function preSave()
  {
    // Set value here
  }

  // ** Snip **
}

Apart from that, I have a custom module, which has it's own presave hook.
Where I would like to use the auto generated value of the custom field type.

function HOOK_entity_presave($entity)
{
    $autoValue = $entity->auto_generated_field->value;
}

However, in the presave hook the value of the auto generated field is still NULL, how can I make my presave hook fire after the preSave in the custom FieldType?


texts: Include custom Product Fields in an email

texts:
I have added a new "Courses" Product Type that has a field called "Course Link". The store admin can add a url to this field and we want to email the value to the customer after they purchase.

I have a Rule to fire on "Completing the checkout process" with action "Send HTML e-mail" and the email includes the token [commerce-order:commerce_line_items]  This is all working except my "Course Link" field is not included in the email. I do not have a token for "Course Link" field listed to include in the email.

I do have the "Course Link" field included under "Product Types > Courses > Manage Display > Line Item". Not sure what that even does.

My question is what should I be looking at to do this.

Try to bring it into scope in my current emailing Rule? Possibly through a Component that loops through line items and provides a value back?
Add it in the View that drives the [commerce-order:commerce_line_items] token?
A module like Commerce Messages or Commerce Invoice Receipt?
Some other approach?


texts:
crontab -e displays

*/5 * * * * /persistent/sitename/scripts/cron-curl.sh
~
~
~
"/tmp/crontab.XXXX1FOZWa" 1L, 51C

Why is it not running every 5 minutes?


texts: How to create a view of all the nodes sorted by date width header per each year

texts:
I need to create a view like this:

2012

node/1, node/2

2011

node/3, node/4

2010

node/5, node/6

The nodes have to be grouped by date and add the header with the year.

I don't want to create one view per each year but just one view. Shall i do it using taxonomy?


texts: Programmatically load the page variant being used on path or node object

texts:
I'm attempting to be able to load a page variant given a specific path. My ultimate goal is to loop through all the links in a menu, find out what page_manager variant is being used and load the context data from that variant. I'm able to grab the data just fine if I manually supply a page id. Below is me obtaining the data from the about page I've created in page manager.

$page_storage = \Drupal::entityTypeManager()->getStorage('page');
$variant_storage = \Drupal::entityTypeManager()->getStorage('page_variant');
$about = $page_storage->load('about');
$about_variant = $about->getVariants();
$about_variant = reset($about_variant);
foreach($about_variant->getContexts() as $context){
    $label = $context->getContextDefinition()->getLabel();
    if($label == 'Icon'){
        var_dump($context->getContextValue());
    }
}

This works just fine. But what if I want to load the context data of each link in a menu? These are links that I can't anticipate. Also some of these links will be regular pages and some will be actual nodes that also have their own variant.

I can load the nodes from the route like so

$params = \Drupal\Core\Url::fromUserInput($path)->getRouteParameters();
if (isset($params['node'])) {
    $node = \Drupal\node\Entity\Node::load($params['node']);
    //We have a node which I don't know how to get the variant of
} else {
    //We have a regular page that I don't know obtain the id of
}

But even though I have the node I have no idea of a way to interface with it in a way that allows me to obtain the page variant I'm using. If it's a regular page, then as long as I have the page id of it I can load the page variant like I have done before, but I don't know how to obtain that.

So ultimately I suppose I need to be able to programmatically obtain two things

How to obtain the page id from a page given its path
How to see the page variant being used on a node

UPDATE: I did manage to obtain the page with this line

$page = \Drupal::entityTypeManager()->getStorage('page')->loadByProperties(['path' => $link]);

Still not sure how to grab the variant the node is using yet though.


texts: Ctools content types- What do I need to do to get my content to render in the right place?

texts:
I have some panels on my site.  Previously, I was using custom content panes with the PHP filter to call functions in a custom module.  The custom function had lots of print() statements and I simply dumped a bunch of HTML to the screen.

Now, I am trying to reform my bad programming practices by moving the custom content panes into Ctools content types.  I successfully created a content type, but when I call my function (in my custom module) full of print() statements, all of the HTML gets dumped to the top of the page, instead of where the content type has been placed within the panel.

Reading through articles online, it appears this is because the content pane expects me to return something it can render, not directly print() the HTML.  Is there another PHP function I can use to gather up all the HTML I was previously using print() for?  What is the correct way to output a bunch of HTML in a ctools content type?

(If this seems obvious, please bear with me.  I'm not a programmer by training and I'm probably in a bit over my head.)


texts: How do I query a MySQL view in Drupal 7?

texts:
I have created a database view and I would like to show the results in a Drupal Page. The view has some pretty complex SQL behind it, so trying to use the Views module isn't possible.

I just want to do SELECT * FROM VIEW_X and display the results on a page in PHP.

I know how to do this in Drupal 6, but how is it done in Drupal 7?


texts: Modify the registration page in the membership entity module

texts: I am new to drupal.  I would like to remove some of the fields on the registration page of the Membership Entity module and add others.  The new fields that I add need to be saved into the database.  I think I can do this with alter hook but I haven't had success.  Can someone post a code example of how to do this?


texts:
I am creating a custom paginator in Drupal 7.

The paginator is working fine, the only problem is that every time I click to the next page button, increases the step in 2 (For example I can see pages 0,2,4,6,etc...)and that's because the submit button is executed twice and increases the number of the page by two.

As you can see in the callback I use AJAX to replace two different sections on the page, and that might be the cause.

Any idea?

Submit function:

function club_paginator_form_submit($form, &$form_state) {
$values = $form_state['values'];

if ($form_state['triggering_element']['#value'] == '>')
{
    $form_state['values']['current_page'] = intval($form_state['values']['current_page'])+1;
}
else
{
    $form_state['values']['current_page'] = intval($form_state['values']['current_page'])-1;
}

$form_state['rebuild'] = TRUE;

}

Forms:
(...)

$form['next'] = array(
    '#name' => 'paginator-next',
    '#type' => 'submit',
    '#value' => t('>'),
    '#weight' => 5,
    "#ajax" => array(
        "callback" => "ajax_club_paginator_next",
        "effect" => "fade",
    ),
    '#prefix' => '
'.$page.'
',
    '#attributes' => array('class' => array('button')),
    '#submit' => array('club_paginator_form_submit'),
);

(...)

Callback:

function ajax_club_paginator_next($form, &$form_state)
{
    $page = intval($form_state['values']['current_page']);

    $html = '';
    $html .= '
';
    $html .= draw_clubes_page($page);
    $html .= '
';

    $paginator = '
';
    $form = drupal_get_form('club_paginator_form', $page);
    $paginator .= drupal_render($form);
    $paginator .= '
';

    return array(
        '#type' => 'ajax',
        '#commands' => array(
            ajax_command_replace("#club-paginator-content-replace", $html),
            ajax_command_replace("#paginator", $paginator)
        )
    );
}


texts: How to install an existing Drupal profile with drush?

texts:
Seems like searching for the answer on Google just leads me to how to create make files and profiles.

I know how to do that.
I also know how to install Drupal with drush.

But I want to install one of the many existing Drupal profiles, like Drupal Commons, Commerce Kick Start, etc. with drush.

I would have thought it would have been just an easy process to find the profile's makefile and run that. Drush will take care of the rest.
But I can't find the repositories where these makefiles sits.

Some direction would be appreciated.


texts:
We would like to set up a test site where we can experiment with various operations which, if they fail, would be messy to clean up, but I am running into a problem with clean URLs.  First, some background.  We run multiple sites off this one account, some D6 and one D7.  It is the D7 one where we want a test site.  Because of the multiple sites from one code base, I have Drupal installed in directories under a bin directory, one for each current release.  Then, the directory corresponding to each website is just a symbolic link to the corresponding Drupal release directory.  So, when I install a new release, I unpack it into a new directory, copy over the site directory, and create a new link to the new directory.

For the test site, I set up the DNS so that test.whatever.com points to a test directory, just like the other directories and that directory is symbolically linked to the same Drupal release as the main site.  Under the sites directory, I have done the setup so that each site has its own database.  I can do the ?q=user thing to get a login prompt and can log in, but whenever I try to navigate somewhere I get "The requested URL /content/articles was not found on this server."  So, this tells me that clean URLs is broken.

But, of course, because of the site structure, test.whatever.com is pointing to the same Drupal 7.43 release directory as the main site and they have the same .htaccess file, which is the standard one that comes with 7.43.  But, I am failing to find any real guidance on how I have to modify the .htaccess to make this setup work.  I have looked at https://www.drupal.org/getting-started/clean-urls, but an unable to puzzle how to adapt what is there to this situation.


texts: Populate Taxonomy Term reference field in node

texts:
I'm using data from JSON to create new nodes on my Drupal 8 website. So, I have a createNode method that create these nodes.

Here is the code I'm using

  protected function createNode($json) {

    foreach ($json as $row) {
      $node = Node::create(array(
        'type' => 'product',
        'langcode' => 'en',
        'uid' => '1',
        'status' => 1,
        'title' => $row['title'],
        'field_code' => $row['code'],
        'field_manufacture' => $row['manufacture'],
        'field_product_type' => $row['type'],
        'field_barcode' => $row['barcode'],
        'field_packages' => $row['packages'],
        'field_pallet' => $row['pallet'],
      ));

      $node->save();
    }

  }

The problem is with field_manufacture and field_product_type, those are entity reference field to taxonomy term. I'm getting term name and I need to match it in vocabulary or add it if doesn't exist.

Any idea how to do that?


texts:
I'm trying to set the value of a taxonomy term entity reference field with a POST operation in JSON:API.
const data = {
  data: {
    type: 'node--page',
    attributes: {
      field_text: {
        value: `${values.textFieldValue}`,
        format: 'basic_html',
      },
      field_ref_term: {
        type: 'taxonomy-term--my-vocabulary',
        id: '9ca0cdc7-384c-4aa4-8ce9-d6c97fc2f44b',
      },
    },
  },
};

However, that gives me this error:

Unprocessable Entity: The following relationship fields were provided
as attributes: [ field_ref_term ]

What am I supposed to do to fix this?


texts: How to add a tpl file to a block from a custom module

texts:
I have a custom module that build a block. I'm trying to add a tpl file, but I don't get nothing.
This is my code:

<?php
/**
 * Implements hook_block_info().
 *
 * This hook declares what blocks are provided by the module.
 */
function tados2_block_info() {
  $blocks = array();

  $blocks['block_with_tpl'] = array(
    // info: The name of the block.
    'info' => t('Tados2 example: block with tpl'),
    'status' => TRUE,
  );

  return $blocks;
}
/**
 * Implements hook_block_view().
 *
 * This hook generates the contents of the blocks themselves.
 */
function tados2_block_view($delta = '') {
  switch ($delta) {
    case'block_with_tpl':
      // The subject is displayed at the top of the block. Note that it
      // should be passed through t() for translation. The title configured
      // for the block using Drupal UI supercedes this one.
      $block['subject'] = t('Tados2 block with tpl');
      // The content of the block is typically generated by calling a custom
      // function.
      $block['content'] = t('Hola mundo');//_tados2_block_with_tpl_contents();
    break;
  }
  return $block;
}
?>

I'm trying to move the content to a tpl.php file.

This what I'm trying:

<?php
/**
 *
 * Implementen hook_theme
 *
 */
function tados2_theme(){
  return array(
    'tados2_block' => array(
      //'render element' => 'elements',
      'template' => 'tados2_block',
      'variables' => array('title' => NULL, 'content' => NULL),
    ),
  );
}
/**
 * preprocess function
 *
 */
function template_preprocess_tados2_block(&$variables) {
  dpm($variables);
}
?>