texts: Taxonomy child terms list and product list view

texts:
I would like to ask about product category vocabulary and different page views for parent and child terms.

This is my use case:
I have to build drupal 7 commerce based site, products are organised in taxonomy called "Product categories". Lets have these terms in here:

Category1

Subcategory1-1

Product1
Product2

Subcategory1-2

Product3

Category2

Subcategory2-1
Subcategory2-2

Product4

Subcategory2-3

Category3

Subcategory3-1

I need to make this behavior:
Main category list page: contains list of main categories [Category1, Category2, Category3]

Main category detail page: after clicking on main category (e.g. Category1) and page contains list of child categories [Subcategory1-1, Subcategory1-2]

Child category detail page: after clicking on sub category item (e.g. Subcategory1-1) and page contains list of products [Product1, Product2]

so in general: if you click on category without products -> display child categories list of particular parent category, and if you click on category with products assigned to them display list of products...

I was googling for a while and I don't find the right solution for my use case.

Can anybody help me with this?


texts: How to display custom news from other news providers?

texts:
I want to show news from news providers of my choice to users on my drupal site. Imagine a horizontal news ticker block on the front page with individual news from different news providers. I am using drupal 7.50.

Some more details: I just want to know the way to grab/fetch/retrieve news from websites like cnn, al-jazeerah, etc of my choice to my drupal site and show them in a slider. For example yahoo has a nice news slider. I have views ticker and views slideshow modules, but it is not necessary I use them if other modules fulfill the purpose.


texts: Node content versioning and compare tool

texts:
I already know that node content versioning is supported in drupal, what I want to know is how much?

I for instance create a content type 'article' and add some extra text fields to it, The article content should have the capability to be reviewed and altered by many authors/reviewers and their changes will be saved as seperate records not impacting the real article record, only if I approve their changes will they be reflected on main article record.

Which of the functionality is currently supported and what is not?

Thanks


texts: Querying taxonomy terms with the level hierarchy

texts:
I am currently struggling against a problem I can't fix, probably because of my scarce knowledge of the Drupal API.

I  have a taxonomy tree that looks like the following one:

    SHOE BRANDS 143
         KIDS   151
         MEN    152
            STIVALE/BOOT    164
            SANDAL  165
            PANTOFOLA/LOAFER    198
            MOCASSIN    199
            DERBY   200
            FRANCESINA/OXFORD   201
            POLACCHINO/ANKLE BOOT   202
            SNEAKER 203
        OUTDOOR/SPORT   153
        WOMEN   154
            STIVALE/BOOT    166
            SANDAL  167
            POLACCHINO/ANKLE BOOT   189
            SNEAKER 190
            DERBY   191
            FRANCESINA/OXFORD   192
            PANTOFOLA/LOAFER    193
            SABOT   194
            MOCASSIN    195
            BALLERINA   196
            DECOLLETEE/PUMP 197

What I need to do is to populate a select box with the child elements of the "SHOE BRANDS" parent (which should be "KIDS" "MEN" "OUTDOOR" and "WOMEN"). After that I will populate a second select box with an Ajax call passing the tid, to get all the different shoe types.

The query I'm using to populate the first select is this one (and the problem rises here):

SELECT *
FROM node
INNER JOIN term_node AS tn
ON node.vid = tn.vid
LEFT JOIN content_type_extra_content AS xc
ON node.vid = xc.vid
WHERE tn.tid IN (SELECT th.tid FROM term_hierarchy AS th WHERE th.parent = '143')
GROUP BY tn.tid

Note the '143' which is the tid of the "SHOE BRANDS" term.

Don't know why, but I only get as output "KIDS" and "OUTDOOR" (which are the only terms with no child elements.

Am I missing something in my syntax?


texts:
In Drupal 8, what is the recommended way to add new settings to system_theme_settings form?

I tried using hook_form_FORM_ID_alter(), but I can't figure out how to save values for theme settings.

Here is some sample code:

function headroomjs_form_system_theme_settings_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['headroomjs'] = [
    '#type' => 'details',
    '#open' => TRUE,
    '#title' => t('HeadroomJS'),
  ];

  $form['headroomjs']['offset'] = [
    '#type' => 'textfield',
    '#title' => t('Offset'),
    '#description' => t('Offset'),
    '#default_value' => theme_get_setting('headroomjs.offset', 'testtheme'),
  ];
}

I tried referencing the core system_theme_settings form to see how they did it, but can't quite figure it out. I just want to piggyback this module configuration per theme.


texts: Creating a custom token that gets value of node fields

texts:
new to Drupal / PHP.

What I'd like to do is get the value of a couple fields from a node. Then create a custom token from them so I can use them in the meta tag module.  Or just get the value of a node token that's already been created.

I'm not really sure where to start, does this need to happen in the node template or a module?

At the moment I am using the following code to create a module that creates a custom token.

<?php

/**
 * Implements hook_token_info().
 */
function globalpost_custom_token_info() {
  $info = array();
  // Define a new token type.
  $info['types']['gp_tokens'] = array(
    'name' => t('GlobalPost Custom Tokens'),
    'description' => t('A token type for GlobalPost tokens.'),
  );
  // Define any new tokens.
  $info['tokens']['gp_tokens']['gp_keywords'] = array(
    'name' => t('GlobalPost Keywords'),
    'description' => t('A list of formated keywords for metatags'),
  );
  return $info;
}

/**
 * Implements hook_tokens().
 */
function globalpost_custom_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  if ($type == 'gp_tokens') {
    // Loop through the available tokens.
    foreach ($tokens as $name => $original) {
      // Find our custom tokens by name.
      switch ($name) {
        case 'gp_keywords':
          // Work out the value of our token.
          $value = "CAN I PUT ANOTHER NODE TOKEN HERE OR DATA FROM NODE's FIELD?" ;
          // Give our token it's value!
          $replacements[$original] = $value;
          break;
      }
    }
  }

  return $replacements;
}

?>


texts: White screen of death but only on log in page?

texts:
Ive got a copy of a site to work on locally. The instructions were to leave the settings.php how it is and just enter my database details into local_settings.php. Ive done this and the site works fine except except when I try and log in and go to the 'user' page at which point I get the white screen of death.

The site only works the the url doesn't have the https so this is the front page: http://mysite/

However when I try and 'user' to the end it redirect to https://mysite/user so it adds 's' to the 'http'.

Another quirk that may be relevant is that when I create a brand new site it works fine except that the admin log in doesn't work the first time. I have to use the 'Request new password' link to log in. After that I can log in and out fine.


texts:
I'm trying to use flags to create 'Out of office' functionality for my site users where user profiles are built into panels.

How can I add a flag where user can only see flag on his own profile
When user flags 'out of office' he gets displayed with a text field and then that text    field get rendered within user profile displaying 'out of office' message.

Thanks


texts: Modifying my theme's template.php requires apache restart to see changes

texts:
When I make modifications to my .tpl.php file, I assure that changes are "reloaded" by executing "drush cc all".

But when I change my template.php file, the only way I have to see the output of my new code, such as adding a simple dpm($form) statement, is by restarting apache.

I've tried:

drush cc all
Devel module -> Clear cache.
Configuration -> Performance -> Clear all caches.
Check that in Configuration -> Performance -> CACHING -> disabled.
Clear browser cache.
Test it in a different browser.

But the changes only appear when I issue /etc/init.d/httpd restart.

Any idea of why?


texts: how to send variable from .php file to .js file?

texts:
I hope someone is able to help me.
The problem is the following one:
1)I have module in which a assign the variable in order to send to the template file php.tpl

<?php
...
$testvar="Hello from alex!";
$variables['testvar'] = $testvar;
...
?>

This variable can be shown in the php.tpl file like

<?php print $testvar?>

2)I have separated .js file
How can i get access to this varuiable inside .js file?

I know how it'll be if .js file is inside .php.tpl:

<?php
$testvar="Hello from alex!";
?>
<script type="text/javascript">
var myVar = '<?php print $testvar?>';
</script>

The problem is how to do the same if these two files .js and .php.tpl are separated?


texts:
Can somebody explain how watchdog searching works? I can never get it to locate the log entries I'm looking for.

Let's say I have the following watchdog entries:

476722  10/Jun 10:31  notice    content  page: updated Protective Factors in Elementary School.
476723  10/Jun 10:31  notice    php      Notice: Undefined offset: 3 in _menu_translate() (line 777 of /var/www/html/domainnamehere/includes/menu.inc).
476724  10/Jun 10:40  notice    content  page: updated School/District Administrators.
476725  10/Jun 10:42  notice    content  page: updated Teachers.
476726  10/Jun 10:42  notice    php      Notice: Undefined offset: 3 in _menu_translate() (line 777 of /var/www/html/domainnamehere/includes/menu.inc).

All of following return "No log messages available":

drush wd-show "Undefined offset"
drush wd-show "%Undefined offset%"
drush wd-show "menu_translate"

If I want to find all of the "Undefined offset" watchdog entries, what Drush command do I have to run?


texts: How to remove malicious scripts from admin pages after being hacked?

texts:
The site running Drupal 7 was hacked and every administration page, e.g.

http://www.anysite.com/en/admin/dashboard

contains script tag in head section with malicious src attribute, e.g.

<head>
    ...
    <script src="..."></script>
</head>

Those three dots in the src attribute was only for example same as the three dots line above :) In real code there is link to malicious web gymweb.it.

How can I remove this script tag? How the head section of admin pages is constructed?


texts: Overriding nodes of a certain type with a view

texts:
I'm using a single view to display some nodes on my site, and I can't figure out how to get it to only override the three content types I want (retreat, location, and teacher) but not all of them. In the contextual filter I specified validation by those types but it seems that's just making it do nothing on nodes of other content types so their content doesn't get shown at all.

I suspect the problem is either in the contextual filter settings and/or the fact that I specified the view's path as /node/% so as to override the normal display.

Attached are my view and the full contextual filter settings. Thanks for any advice!


texts:
The below query is giving error:

PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in webform_options_submit()

What am I missing? Any suggestions/ideas will be helpful.

And, How should I use the LIKE command in this query?

  $args = array(':entities' => $_REQUEST['entities'], ':countries'=>$_REQUEST['countries']);
  $query = db_query("SELECT field_entity_value,field_country_value, filename
                   FROM field_data_field_entity,field_data_field_country , field_revision_field_file_upload, file_managed
                   WHERE ( field_data_field_entity.field_entity_value LIKE :entities
                   AND field_data_field_country.field_country_value= :countries )
                   AND field_data_field_entity.entity_id = field_revision_field_file_upload.entity_id
                   AND field_data_field_country.entity_id= field_data_field_entity.entity_id
                   AND field_revision_field_file_upload.field_file_upload_fid=file_managed.fid", $args);
  $results = $query->execute();


texts: Add a remove item button on checkout page

texts:
i have an express-checkout page and the cart is shown but i have to give the customer the chance to remove items from his cart at this stage.

i edited the view Shopping cart summary (Commerce Order) by adding a (Line Item) Commerce Line Item: Delete button (Remove)

now when i click that button the form-validation starts and the item wont be removed. any chance to fix this? a multistep-form is not an option for me.


texts: Diferences between: migrate_d2d and migrate

texts:
I need to migrate a d7 site to a d7 distribution. This is to migrate from d7 to d7.

I found this modules which I undertand will help me with this task.I've read the documentation but I don't fully understand the diferences between them.

Which one is the right module for my situation?


texts: Clearing or changing styles with the TinyMCE WYSIWYG editor in Drupal 6

texts:
On the TinyMCE tool-bar you can select a style to apply to the selected text (from a list of CSS classes that you create). However if I want to change to a different style, when I select a new style form the drop-down list, it just adds another class so the text ends up with having multiple competing classes attached.

Is this the normal behaviour - does any one else get this?

Does ayone know if there is a way to clear all styles on the selected text?


texts: How to add product details to Drupal Commerce order confirmation email

texts: Default email that is sent when user completes the checkout process contains order number and other details. I want to include additional product details and product type in this email. How can I do that?


texts: Do I need to manually destroy the EntityFieldQuery object?

texts:
I'm using an EFQ object inside a foreach loop:

  //bundle those terms with nodes they each have
  foreach($relevantTerms as $dishType)
  {
    $nodeQuery = new EntityFieldQuery();

    $entities = $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'food_menu_item')
      ->propertyCondition('status', 1)
      ->execute();

    $nodes = entity_load('node', array_keys($entities['node']));
    krumo($nodes);
  }

After the loop stops executing, am I correct in thinking one instance of $nodeQuery will remain in memory for the rest of the request? Do I need to destroy this using unset() for performance?


texts: How to add an edit and delete button to a custom html table?

texts:
I've a db_select to fetch data from sql table, and $output .= theme('table'...) to generate an html table to display these data in columns. My question is, how can I add edit and delete buttons to each row?

Also, given initially these data are stored in the sql table from dropdowns, how can I redirect to the link containing the dropdowns load again and if for example I edit a row which has data from formID=5, each dropdown then shows the corresponding data for this ID, and allow me to modify accordingly to save again to the same sql table, and update the html table's view?

Example of my current sql is:

db_select('mytable')
        ->fields('mytable', array('formID', 'field1', 'field2'))
        ->execute();


texts: In configuration>Account settings page, at the bottom of page under E-mails first option Welcome(new user created by administrator), here I want to edit the body section and need to include link for my custom page /unsubscribe. I have gone through the available tokens but I did not fine any clue


texts:
I have installed LDAP module and configured.

After that walk through admin-> configuration->people->ldap, here I added the server, in authentication I enabled the added server.

Finally in user page I selected Show option on user create form to determine how account conflict is resolved and in basic provisioning ldap block selected the added server name.

Now I want walk through people->add user, I want to create a user with ldap authentication so when I select Create corresponding LDAP entry. I am unable to check the box.

Why this? please help me on this I am breaking my head to trigger it out. Thanks in advance.


texts:
I'm using the Views Json Source module to load information from a Views Rest Export page on an other website into another website.
But for some reason the view is stuck with old information. I'm pulling in a calendar from the source site. But even though the data from the source site is changing the data in the other site is not.
To solve this I disabled cache for both views but without success When clearing cache on the source site and then the other site the data is changed.
What can I do to make the view look at the rest export on every load of the block?


texts:
I have a website that I need to add search functionality to. First though, we are running Drupal 6 with multiple sites each with its own theme. Content goes to its respective site by URL and the Themekey module. So for example:

example.com/site1 - First site and its content, theme 1
example.com/site2 - Second site, theme 2
example.com/site3 - Third site, theme 3
example.com - Primary base website. None of the above content, but everything else. Base theme.

This system has worked well for us though most developers say it's unusual.

I'm using the Custom Search module. example.com has a search box and it searches all of the sites. I've put a search box on site1 example.com/site1 and it's configured to only search site1's content types. But when you enter some criteria and click search /site1 is dropped from the URL and so you end up in the base theme example.com because the URL becomes example.com/search/node/some-criteria. What I need is for the search results to stay in site1 theme.

Putting /site1 in the results page url would keep the theme but I can't figure out how to do that. Maybe there is something in Themekey that will work but I have not been able to figure out either. Any ideas?


texts: Is there a way to force drush to enable a module and ignore dependencies?

texts: I'm getting exception 'Drupal\Core\Config\UnmetDependenciesException' with messageConfiguration objects (....) provided by cn_migrator have unmet dependenciesin .../core/lib/Drupal/Core/Config/UnmetDependenciesException.php:84 when trying to enable a custom migration module. I've checked the dependencies listed in the YAML files and can't see anything missing. I really need to push ahead, but can't find a way to force enabling this module.


texts:
I have contact webforms in all pages on footer including the front page template. I want the user to be redirected to the same page they are in and but the message that the form have been submitted should be visible.

How can i do that? Is there a built in method.


texts: Can I add external js and css via module info files?

texts: I have read that I can add js and css file via .info files. Can I add external css and js files there as well? Eg http://somewhere.com/in_a_galaxy


texts: give node author ability to position the image when uploading content

texts:
I have a field of type image "COVER IMAGE" in my blog entry content type. The users should have the power to place it wherever they like...top, down,right or left, if not more and re size it. right now it appears at the bottom of the content and of the same size as that uploaded.

Can this be done?

Regards


texts: How to create multiple variants of a page in page manager

texts:
I'm attempting to create multiple pages that use panels within a page in page manager.

For example I'm trying to create the path

127.0.0.1/brands

And have multiple pages that follow that same path like the following

127.0.0.1/brands/brand1
127.0.0.1/brands/brand2
127.0.0.1/brands/brand3

I created multiple variants for each brand in the brands page manager. I had a feeling that I could create the various subpages by using the 'Request Path' selection condition. But I've attempted the following

/brands/brand1
/brand1

and all of these lead to a 'page requested not found' when visiting 127.0.0.1/brands/brand1

Is there a way to create a sub page of a page using page manager, without creating a whole new page?


texts: How to use #element_validate and #value_callback in Drupal 8

texts:
I have followed the official Form API Documentation, but this code don't work for me on Drupal 8:

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['upload'] = array(
      '#title' => t('Upload Images'),
      '#type' => 'managed_file',
      '#upload_location' => 'public://image_example_images/',
      '#element_validate' => array('file_generic_settings_max_filesize'),
    );
    return $form;
  }

  private function file_generic_settings_max_filesize($element, &$form_state) {
    form_error($element, 'This is an error.');
  }

I have trying to remplace form_error() by $form_state->setErrorByName() but same problem, the file is uploaded and the validation is not called.

Have you a solution please ? The documentation of #element_validate is outdated ?

My objective:
Upload a lot of images, use a custom validation and insert all images thumbnails inside a

 with a field for name each images.

Example:

(After upload, display thumbnails and title field for name all each images)

Else, after upload, for display Thumbnails and other field (title and description) for each image, I need to use #value_callback, #process, #attached (manage field/display with js after upload) or an other option please ?

Thanks.


texts: Losing form_state value after second submit (ajax)

texts:
I have an form that I send with ajax:

public function buildForm(array $form, FormStateInterface $form_state) {
     ...
    if($form_state->getValue('g_actualPartIndex') == NULL){
        $form_state->setValue('g_actualPartIndex', 0);
    }
    $form = $this->setHeader($form, $form_state);

     $form['Next'] = array(
        '#type' => 'submit',
        '#value' => "Go to next step",
        '#ajax' => [
            'wrapper' => 'projekt-form-wrapper',
            'callback' => [$this, 'form_ajax_submit'],
            'method' => 'replace',
            'effect' => 'fade'
        ]
    );

    $form['#prefix'] = '
';
    $form['#suffix'] = '
';
    return $form;
}

public function form_ajax_submit($form, $form_state) {
    $form_state->setValue('g_actualPartIndex',
       (int)($form_state->getValue('g_actualPartIndex')) + 1);

    $form = $this->setHeader($form, $form_state);
    $response = new AjaxResponse();
    $response->addCommand(new HtmlCommand(
        '#projekt-form-wrapper',
         $form
    ));
    return $response;
}

As you can see, in buildForm I set g_actualPartIndex to 0 if no value is set (we enter the form for the first time). Later, in ajax callback form_ajax_submit I increment the g_actualPartIndex by one and replace old form with the new one. My setHeader(...) method displays the actual step index:

private function setHeader(array $form, FormStateInterface $form_state){
    $actualPartIndex = $form_state->getValue('g_actualPartIndex');
    $form['header'] = array(
        '#type' => 'markup',
        '#markup' => t('

            Part 1
            Part 2
            Part 3
            Part 4
            Part 5
            Part 6

'),
    );

    return $form;
}

When I load the page, I see "Part 1" with class "active". When I click "Go to next step", the form is replaced by form with "Part 2" as "active". The problem is, when I click "Go to next step" again, the form reloads... and I'm still in "Part 2" instead of "Part 3".

Is form_state losing it's value due to some rebuild or something? Or the error is somewhere else?


texts: How do I use the Save Draft module for a particular content type only?

texts:
I want to use the Save Draft module for a particular content type. When I install this module by default, it will be applied to all the content types. Please let me know how to avoid this.

I'm using version 7.x-1.4 of the module.


texts:
I want the following;
In the default login page, I want to delete this line:
Nieuw wachtwoord aanvragen (Also DELETE "request new passord) on this site: http://www.deklotvaarders.nl/user

Also I don't want that users can request new password.
Where to do that?? Which file?

Thanks so much,
Greetz,
Pieter-Jan


texts: Why the meta-tag module add "|" after the site name?

texts:
I am building a Drupal 7 site using the Metatag module.

I know that on the settings of the module there are many tokens, and that's great.

For example, the title under 'Global -> page title' is: "[current-page:title] | [site:name]".

Here it's great and I like that the "|" between the words.

But, When I am on my home page, I see that my site name the browser tab is

  Site Name |

In all the metatag settings, and in the site information settings I didn't found any token that looks like "[site:name] |".

Does someone knows why my site name is "Site Name | "?


texts:
I would like to add a style attribute to each title fields in my view. I have created one field for a color. I tried to rewrite the result like this:

[title_1]

But the style attribute will be removed. I'm using Drupal 7.

Any help appreciated.


texts: Interface Microsoft Access to Drupal database

texts:
I am wondering if anyone has ever succeeded in editing their Drupal database with Microsoft Access.

I have already figured out how to use Oracle's Mysql ODBC connector to enable MS Access to see my Drupal database. What I would like to do now is use the well-developed capabilities of MS Access to edit a few tables.

I am not interested in centrally important Drupal tables like node or user, but would be interested in editing a crm_core_contact table. More specifically, if I wanted to add a contact entity to a crm_core_contact table, would I be able to generate the uuid in MS Access, or do uuids in Drupal need to be generated by Drupal?

Could someone tell me if all of this is absolute heresy, a really bad idea, or a potentially intriguing possibility?

The first two comments below were helpful.  Responding:  (1) The reason for using MS Access rather than the Drupal database API is the ease of creating a user interface.  I've used Access for years, and it will be much easier to create Forms, Macros, etc. in Access than it will be to write PHP script to do the same thing.  As for (2), Clive's response is exactly what I was looking for.  I would like, though, to know more about the difficulties that I would run in to.  I'm not expecting anyone to do a tutorial for me, but is there documentation somewhere that describes what it takes to modify (or add) an entity?  It requires very few lines of code to create an entity and to use the entity_metadata_wrapper interface to populate it.  So is there a place that describes what is going on "behind the scenes" so that I could directly do this?


texts: How to show a field in a view taken as input in a different content type?

texts:
I made a form Company Information, which contains standard fields like Name, Address, Rating etc.

Now I am taking Rating from a different content type "Company Reviews", under Rating Field.

What I want to display various fields from Company Information and Company Reviews in a single view. I tried using the machine name in twig but somehow the view is showing values from Company Information but not from Company Reviews.

Does this sound familiar? I am sure it can be done but I am missing out something. Any help or even a direction is much appreciated, thanks.

[ UPDATE 1]

So, I was researching this for a while and just after posting the question I stumbled upon "Entity Reference", but it seems that this is not available for drupal 8
can we do this in drupal 8 somehow
https://www.ostraining.com/blog/drupal/entity-reference-views/

[ UPDATE 2]
The entity reference was suppose to show up in Add Relation under Advance Tab

And I am getting a few fields,  but not the ones I want.
neither the view is showing following entity relation

instead, I am having this on my dashboard,

so I went ahead and added Review content filter anyway, as a result, the Listing View started showing the reviews as companies, which was not the desired result, using review title as company title.

Do I require a module or should something have be-be done at content types Company Profile and Review?

[ UPDATE 3 ] The Answer is correct, Here is how did it, if anyone is interested.

It was rather simple,

Suppose you have Content-Type A, and Content-Type B, and a result View C

In Content Type A, you add a field, that is actually a Reference to Content-Type B, let's call it ref-AB. Similarly, Add add a field, that is actually a Reference to Content-Type A, say ref_BA.
Now fields of A & B Content-Type are related, and you can show them in the view.

To Show them in a view, you need to add "reference to the content" as a relation in view ( Go to view> your-view > advance > add relation). Suppose, you added ref_BA to your view, then all fields of content type B, will be available in your view.

In your view, add the field you want to show, making relation to ref_BA.


texts: Patching docroot htaccess: file not found

texts:
I tried to create my first patch file in order to reverse the overwriting of the scaffold file .htaccess after executing composer install. I get the following errors:
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/web/.htaccess b/web/.htaccess
|index 6f9123d..4ae5471 100644
|--- a/web/.htaccess
|+++ b/web/.htaccess
--------------------------

Script cd web && patch -p1 < ../patches/htaccess.patch handling the post-drupal-scaffold-cmd event returned with error code 1

This is how the patch file looks like:
diff --git a/web/.htaccess b/web/.htaccess
index 6f9123d..4ae5471 100644
--- a/web/.htaccess
+++ b/web/.htaccess
@@ -113,7 +113,7 @@ AddEncoding gzip svgz
   #
   # If your site is running in a VirtualDocumentRoot at http://example.com/,
   # uncomment the following line:
-  # RewriteBase /
+  RewriteBase /

   # Redirect common PHP files to their new locations.
   RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]

And this is how it is loaded in composer.json:
"post-drupal-scaffold-cmd": [
     "cd web && patch -p1 < ../patches/htaccess.patch"
]


texts: Debugging strange memory overflows on Pantheon

texts:
We have a Drupal Commerce site on D8.6.7 running on Pantheon Performance Small servers.  We do a bit of side processing besides normal e-commerce stuff like syncing up data, collecting emails, etc. but nothing immensely crazy.  I keep seeing tons of error messages in Pantheon that point to:

PhpSerialize
EntityStorageBase
MemoryCache

From what I can tell, these messages don't even make sense:

Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes)

We believe these are related to errors that are causing interruptions in the Commerce workflow causing certain Drupal events to not fire off.  Our Order data is becoming corrupt as a result, e.g. status being reset to Draft even though they've successfully made a payment and the payment amount is being recorded.  This results in 'missing' orders that no one sees.  I can identify these 'broken' orders via the following SQL query:

select order_id, store_id
from commerce_order
where commerce_order.state='draft' and commerce_order.total_paid__number is not null;

I cannot determine the origin of this error.  I've tried running Webprofiler, I've added logger statements directly into Core, and a whole bunch of digging in various areas.  I have yet to reliably reproduce the error and frankly, I'm not a Commerce dev so I don't know how everything is running in there and all the architectural decisions they made over the years.

Given all the possibilities, I don't know if it's even a Commerce issue or if it's related to Pantheon or some combination.  Pantheon's error messages are not helpful, I've combed through the Pantheon log messages and lined up timestamps to see if there are any coinciding error messages--none.  Same with Watchdog.  I've spoken with Pantheon customer support who keeps telling me to search the logs.

I'm at my wits end.  I'm basically just stabbing in the dark at this point.  If anyone has any tips to debug this, I would very much appreciate it.  I've been dealing with this headache for some time now and nobody is happy right now.  First occurrence I can remember being from almost back in November.  It's actually been highly aggressive recently--what started out as 1-2 incidents per week is now 10-15 per day with no equivalent increase in traffic/orders.  Very minor code changes since, just standard updates.

== ADDITIONAL NOTES ==

I disabled many non-essential modules last night.  Woke up to more error messages still
There is a bug that I initially thought was relevant: https://www.drupal.org/project/commerce/issues/3011667 but bojanz told me that it was only affecting OffsitePaymentGateways.  We're using Accept.js Authorize.net which extends OnsitePaymentBase
Added a logger statement right before return unserialize($raw); in PhpSerialize. We check the strlen to see if it's over 500,000 and then log the strlen & first 10,000 chars.  Some logged unserializes are trying to unserialize strings over 3M chars long--I don't want to get too invasive and try to see peak memory usage or anything since that would require me to unserialize before looking at peak memory usage which is starting to change the method call more and more.


texts: Redirect basic page to external url when visiting page

texts:
I'm attempting to provide a field to users to enable them to enter an external url. If they enter a url I would like that basic page to redirect to the url the user provided instead of actually opening the node. I've made some attempts by using a preprocess node hook in my custom .theme file as seen here:

function mytheme_preprocess_node(&$variables){
    $node = Drupal::request()->attributes->get('node');
    $type = $node->getType();
    if($type == 'page'){
        $redirect = $node->get('field_redirect')->value;
        if($redirect != ''){

            $response = new Symfony\Component\HttpFoundation\RedirectResponse($redirect);
            $response->send();
            Drupal::entityManager()->getViewBuilder('node')->resetCache();
            return;
        }
    }
}

And I've also tried creating a module to do it and using an entity_view hook like so

<?php

function mymodule_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
  if ($entity->getEntityType()->id() == 'node' && $entity->bundle() == 'page' && !$entity->field_redirect->isEmpty()) {
    $value = $entity->field_redirect->getValue();
    $redirect = $value[0]['value'];
    $response = new Symfony\Component\HttpFoundation\RedirectResponse($redirect);
    $response->send();
    return;
  }
}

Each of these solutions work the first time, but don't work the 2nd time or any time after that until I clear the cache. I'm assuming this is a caching issue. I've heard that using cache tags could resolve this issue but I'm not sure how I would use them. Also I'm not married to making any of these solutions work I merely want to implement some way to perform redirects on pages, it doesn't matter to me how.

Is it possible to perform redirects on node pages?


texts: Locked out of my local site after transfer

texts: I put an old site on my new machine and got it up and running, except for clean URLs. The login creds in my notes didn't work so (after a few attempts) I used mysql via drush to change the password, no dice. I also checked to be sure I had the correct user1 name and it is. Though all this, the account got blocked because of all the login attempts, which I also tried to remedy via drush, however it alert still says the account is blocked and I still can't login. I don't know where to go from here.... please help.


texts: Profile2 Registration Path loose registration field after translate URL alias

texts:
I use Profile2 and Profile2 Registration Path module. This is the original Registration Path, set in the configuration.

I tried to translate the Registration Path at Administration » Configuration » Search and metadata » URL aliases.

But when i visit for example the Belgium dutch version, i loose my extra added Profile field at my Registration form (RIZIV number)?


texts: Linking a field to a node and recording meter readings

texts:
I am trying to achieve the following :-

I have a custom content type called as Energy Meter Record that has the following fields:-
a. A field collection called as Meter Record Sheet that has the following fields in it

After Couple of entries the content looks like this localhost/ogdev/node/17

Now what i want is that when a user clicks on the meter say METER XYZ1 it gets    directed to a page that records the entry for that meter(XYZ1) and for this i have made a new content type called as Meter Log that looks like this after a couple of entries though it is manually created by me and looks like this localhost/ogdev/node/18

Now i want to link the MeterXYZ1 to a LOG where user can enter the details. How to do that so that is get prepopulated and refers to the meter? Any suggestions , am i doing it wrong and how to achieve this please guide.

Thanks :)


texts: When hook_field_load and hook_field_formatter_view are called?

texts:
I have implemented the hook_field_load() and hook_field_formatter_view() function to replace some characters in a specific field's value. But they don't seem to be called at all.
I wrote some command like exit() and print_r($field) in the hooks but nothing happens.

When this hooks are called? (and is this the correct way to do alter field values for view?)


texts: Structure menu link is wrong after use command "drush rr"

texts:
I changed structure some folder module then use command "drush rr" to registry rebuild modules but get a trouble look like picture:
 - Link "add new view","import" and "settings" not inside link "Views"


texts:
Does having more enabled modules make the site slower?
I have installed 30 modules for my site, and I am afraid that it will become too slowly.


texts: How to grant a role permission to edit terms in a specific vocabulary

texts: Is there a way/module to grant a role permission to list and edit terms in a specific vocabulary?


texts: How can i disable the submit function after finishing the textfield

texts:
i wrote a textfield and a submit button with ajax method.
The code is belowed:

$form['response']=array(
            '#type'=>'textfield',
            '#size'=>40,
            '#maxlength'=>255,
            '#name'=>$slogannid->nid,
            );

            $form['send_response']=array(
            '#type' => 'submit',
            '#name'=>$slogannid->nid,
            '#value'=>t('Send'),
            '#ajax'=>array(
              'callback'=>'send_response_callback_function',//which will receive a form and form_state as arguments,and return a renderable array
              'wrapper'=>'attach_the_new_comment_'.$slogannid->nid,//The css id of the area to be replaced by the content returned by the #ajax['callback']
              'effect'=>'fade',
              'speed'=>'fast',
              'method'=>'append',
              'event'=>'click',
               ),
            );

My problem is the ajax submit button work. However, when i finished the textfield and press the enter. The form will be sent and refresh the page.

How can i disable the enter event when i finished the textfield?


texts: Create a content type after checking out a product

texts: I am using Ubercart and I want to create a certain content type after a user checks out a different content type. I'm having the same problem with How to programmatically create a node when a payment is successful but the conversation seems to be too short that I wasn't able to understand what was going on. I'm new to Drupal development, I hope someone might be able to clarify this for me.


texts: Superfish - File not found: sites/all/libraries/superfish/sfsmallscreen.js

texts:
I just downloaded and enabled the latest (dev) version of superfish module, as well as the library... I am getting the following error:

  File not found: sites/all/libraries/superfish/sfsmallscreen.js

Should I remove this line from the libraries path:

sites/all/libraries/superfish/sftouchscreen.js

Or just download a previous (recommended) version of superfish?


texts: Clean URL that result to duplicate content

texts:
I have a drupal site running, i enable clean URL and it was working fine but at a point i have to migrate to the site to another server where i did to not border to enable the clean URL since have done that before. I later migrate the site back to the first hosting company i was using before. Now the problem is that am having duplicate URL. if i go Clean URL i will not see the check box to enable clean URL but if i remove ?q= from the url i will see the check box but when i check it and click Save Configuration, i will received this message "The configuration options have been saved" but the check box will be unchecked.

mod_rewrite has been enable in .htaccess
all permission has been set.
Since have once enable it before and the version of the drupal is 7
Help me out.

both clean and unclean URL are working on the site but the default URL is unclean.


texts: How do I correctly add cache information for breadcrumb parts?

texts:
Visiting a node Foobar a breadcrumb gets created which adds the parent menu structure like so:

$currentPluginId = $menu_link->getPluginId();
$trailIds = $this->menuActiveTrail->getActiveTrailIds('main');

foreach (array_reverse($trailIds) as $key => $value) {
  if ($value && $value !== $currentPluginId) {
    // @todo add cache per item
    $instance = $menu_link_manager->createInstance($value);
    $breadcrumb->addLink(
      new Link(
        $instance->getTitle(),
        $instance->getUrlObject()
      )
    );
  }
}

$breadcrumb->addCacheContexts(['route.menu_active_trails:main']);

So the breadcrumb looks like:

  Home > John Doe > Foobar

But if the node/ menu item of John Doe changes, the breadcrumb for Foobar stays the same.

dpm($instance->getUrlObject()->getRouteName());
dpm($instance->getUrlObject()->getRouteParameters());

gives me:

  entity.node.canonical

and

  array(
      [node] => 25 )

How can I use that for adding each breadcrumb part as cache context/ tag?


texts:
I have a node repeated on the page, once for styled dropdown menu through submenuesmall view and once as node when that submenu is selected. Submenu is styled with node--view--submenuesmall.tpl.php that is OK. But same template is used for node later instead of normal node.tpl.php

If I omit that node from submenuesmall normal node.tpl.php is used.

Is that standard behaviour and how can I fix it or did I do something wrong. All modules are up to date.


texts: Programmatically fields translation problem , there are no results

texts:
I use standard script for make translation, core Drupal7.41, Entity translation 7.x beta 5 & internalization module - all modules installed and enable.

external php script:

 $node = (object) array(
  'uid'     => 1,
  'type'    => 'article',
  'title'   => 'Test Article',
  'body'    => array('ru' => array(0 => array(
    'value' => 'Статья на русском',
    'summary' => 'Статья на русском',
    'format'  => 'full_html',
  ))),
  'language' => 'ru',
);

$node->body['en'][0] = array(
  'value' => 'English text',
  'summary' => 'English text',
  'format'  => 'full_html',
);
$handler = entity_translation_get_handler('node', $node,true);
$translation = array(
  'translate' => 0,
  'status' => 1,
  'language' => 'en',
  'source' => $node->language,
);
$handler->setTranslation($translation, $node);
node_save($node);

after i add print_r($node) and get result:

[uid] => 1
    [type] => article
    [title] => Test Article
    [body] => Array
        (
            [ru] => Array
                (
                    [0] => Array
                        (
                            [value] => Статья на русском
                            [summary] => Статья на русском
                            [format] => full_html
                        )

                )

            [en] => Array
                (
                    [0] => Array
                        (
                            [value] => English text
                            [summary] => English text
                            [format] => full_html
                        )

                )

        )

    [language] => ru
    [entity_translation_handler_id] => node-article-new-1
    [translations] => stdClass Object
        (
            [original] => ru
            [data] => Array
                (
                    [en] => Array
                        (
                            [translate] => 0
                            [status] => 1
                            [language] => en
                            [source] => ru
                        )

                    [en] => Array
                        (
                            [entity_type] => node
                            [entity_id] => 728
                            [language] => en
                            [source] => ru
                            [uid] => 1
                            [status] => 1
                            [translate] => 0
                            [created] => 1463016751
                            [changed] => 1463016751
                        )

                )

            [hook] => Array
                (
                    [en] => Array
                        (
                            [hook] => insert
                            [data] => stdClass Object
 *RECURSION*
                        )

                )

        )

I try 100 combination of code to set translation, but in site(or site UI) i dont see any changes ! But in database, next time after reload node by nid,
value of translation field i see different that when i save $node: after reload node

[translations] => stdClass Object
        (
            [original] =>
            [data] => Array
                (                 )        )

All other value are the same.
in UI

Hardly need help.


texts: Allow users to set permissions for profile fields

texts: I would like users to be able to determine whether a field is displayed publicly. For example, their real name is required for the site, but I don't want to force users to display it.


texts: how rename series legend in chart created by views

texts:
I created a chart page by using Views. But the legend is always Series 1, Series 2. Not using the label data.

I tried to find the option to replace the label "Series" with the label from the data, but I could not find it.
Anyone can help me how to use the label of the data instead of "Series"


texts:
I'm using Drupal 7 with Bootstrap 3.3.5 as a theme.
I built an English version of my website and now I'm working on Arabic version which means RTL(right to left).

When I switch to Arabic, some block's location change to right or left, I'm asking if it's possible to fix the block location? If you have any suggestion about this RTL problems it will be welcome, thank you.


texts: Do not translate the admin area / How can I set the language of the admin area to English?

texts: I am building a multilingual site with 3 languages. Lets say English, Italian and German. English is the default language. Is it possible to leave the admin area untranslatable, even I am currently seeing the actual site in different language other than the default one, just for the administrator of the site, using a module or custom code?


texts:
I created a module that should be able to display the content of a certain content type. The displaying is kinda complex and to be able to turn it off and to group everything together i created a module for this.

But in the end it should just override the normal node.tpl.php with a custom .tpl.php file. When i put the file in my template folder it gets picked up and the pages shows as intended, but i can't get it to work when the file is in module folder.

I read a lot of things about regsiter the .tpl file and preprocess but nothing that combines the pieces i need.

This is what i have so far

function apps_theme($existing, $type, $theme, $path) {
    $items = array(
        'node--app' => array(
            'template' =>  drupal_get_path('module', 'app') . '/node--app',
            'variables' => array('node' => (object)array())
        )
    );
    return $items;
}

function apps_preprocess_node(&$vars) {
    $variables['theme_hook_suggestions'][] = 'node__app';
}


texts: How to limit number of "Promoted to Front Page" option for each user/role

texts:
I want to limit the option "Promoted to Front Page" per role.
For example, a user with role "promoter" should only be able to promote 5 nodes a day to promote to front page.
And same with sticky option.

I am using 'rules_link' module as well.

Any help.


texts:
I'm calling a block in a template like so:

echo views_embed_view('sessions_by_track', 'block_1');

where the block is actually a view display. It's set to output html lists, and I want to do some jquery stuff to it, including hiding certain elements until something else is clicked on.

Here's what the list code looks like:

Big Picture

      Partnering for Success

      The Shopper Economy

I have a scripts.js file that looks like this:

$(document).ready(function() {
  alert('test');
 $('li.views-row').hide();
});

The alert works; the hide doesn't. However, when I run that line in Firebug's console after the page has finished loading, the hide does work. So it seems that the view renders after the document.ready fires. I seem to recall reading something about this before, and there was a solution, but of course now that I need it I can't for the life of me find it. What do I need to do to get around this?

Edited to add: Drupal 6, Views2

Edited again to add: I've also tried this: in template.php added this function:

function mobile_jquery_preprocess_page(&$vars, $hook) {
  $vars['embedded_sessions'] = views_embed_view('sessions_by_track', 'block_1');
  $vars['scripts'] = drupal_get_js();
}

and then calling it in my page template like so:

print $embedded_sessions;

Same result.

Edited yet again to add that I've tried adding a new region to my template, assigning the block to that region, and then printing it with print $mobileContent; in the page template. Same result - the alert runs on load, but the hide does not. The hide runs just fine in Firebug's console, so I know the selector is OK.

Edited once more for @tim.plunkett

To a file called scripts.js, located in sites/all/themes/mobile_jquery/scripts, I added this (right now there's nothing else in the file):

(function ($) {
  console.log('behavior triggered');
  // Store our function as a property of Drupal.behaviors.
  Drupal.behaviors.myHomeHideLists = function (context) {
    // Find all the li items inside context that have our desired class
    $('li.views-row)', context)
      // hide them.
      .hide();
  };

}(jQuery));

In template.php, I added this (based on this answer):

function mobile_jquery_preprocess_page(&$vars, $hook) {
  $vars['embedded_sessions'] = views_embed_view('sessions_by_track', 'block_1');
  drupal_add_js(drupal_get_path('theme', 'mobile_jquery').'/scripts/script.js', 'theme');
  $vars['scripts'] = drupal_get_js();
}

The console.log does get triggered and printed, but the list items that match the selector do not get hidden.


texts:
I have an gallery content type with a title-, image-, and text select list field. This content type is used for a gallery where the select list values works as a kind of category for the gallery(a bit like a taxonomy). Using Views I have gotten all the published values printed out group according to there select list values. However I would like to print out an headline above each of the grouped images. Like this:

headline1

item1, item2, item3...

headline2

item4, item5, item6...

The headline is one of the values from the select list field and the grouped items below is the content where this specific value is chosen from the select list field(during upload). Its easy to get stuff printed out and sorted using Views but it seems to be more difficult to get and headline in there.

Anyone know if this is possible, maybe using preprocess for views or views-view.tpl.php files? I have gotten this to work with the grouping feature for table layout, but would like to have it printed out in unformatted html instead.


texts: Image style changing does not work in view with migrated image fields

texts:
As part of migration I have image fields that have been migrated. I have views those use that image fields, but changing image styles cause nothing!

I can edit image style and its working correctly as it show previews. Views seems to be ignoring image styles and taking original images always.

Can somebody help?

Thanks


texts: Discard views filter on field from referenced taxonomy term when relationship isn't present

texts:
I want to show two content types (A and B) in one view. 'A' has a relationship with a taxonomy term 'foo', 'B' doesn't have this relationship. So the relationship isn't required. However when I use a field from 'foo' as a filter in the filter criteria no nodes of content type B are shown, the nodes of content type A are shown correctly.

Is it possible to configure the view such that it doesn't look at the filter with the referenced field for nodes of content type B?

If something isn't clear, ask me!

Thanks!


texts: How do I disable the cache clear on comment form submission?

texts:
Unless I'm reading this incorrectly, it looks as if the last thing comment_form_submit does is clear the cache. All of it. This is done so anonymous users see the comment they posted.

I have a site that does, at times, receives high comment volume and the site does not allow anonymous users to post comments, so this behavior is suboptimal for me to say the least.

What's the Drupal way to override/kill the call to cache_clear_all() when comments are submitted? Can I do this in a module?


texts: Module with block plugin not using custom template

texts:
I am struggling to get my custom module template to get use by by block plugin.

I have followed the solution given at: Twig Template for a Custom Block Plugin but continually get this error:

  The website encountered an unexpected error. Please try again later.
  Twig_Error_Loader: Template
  "modules/custom/lrg_osm/templates/block--osmnhd.html.twig" is not
  defined in Twig_Loader_Chain->getCacheKey() (line 64 of
  themes/contrib/bootstrap/templates/block/block.html.twig).
  Drupal\Core\Template\TwigEnvironment-->getTemplateClass("modules/custom/lrg_osm/templates/block--osmnhd.html.twig")
  (Line: 424)

I have tried to also fiddle the name of the twig file in various ways to not avail.

My module file structure is shown below with relevant code if anyone is able to point out the error of my ways please:

src/Plugin/Block/osmnhdblock.php

<?php
declare(strict_types=1);

namespace Drupal\lrg_osm\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;

/**
 * Provides a 'OSM Block for Home development Landing page' block.
 *
 * @Block(
 *   id = "osmnhdblock",
 *   admin_label = @Translation("OSM New Homes Development (NHD) block"),
 *   category = @Translation("LRG")
 * )
 */
class OsmNhdBlock extends BlockBase implements BlockPluginInterface
{
    /**
     * {@inheritdoc}
     *
     */
    public function build()
    {
        return array(
            '#theme' => 'osmtheme',
            '#jsonDataLocations' => 'nhd some data',
            '#title' => 'nhd some title',
        );

        /*
         '#attach' => [
                'css' => '/css/openstreetmap.css',
                'js' => '/js/openstreetmap.js',
            ],
         */
    }
}

lrg_osm.module

<?php
declare(strict_types=1);

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

    return array('osmtheme' =>
        array(
            'variables' => array(
                'title' => null,
                'jsonDataLocations' => null
            ),
            'template' => 'block--osmnhd'
        )
    );
}

templates/block--osmnhd.html.twig

{#
/**
 * @file
 * Some description
 */
#}

{{ title }}

{{ jsonDataLocations }}


texts:
How to convert string count into number? I have string count column in views i.e. by using the view aggregating I am counting the nodes of content, along with this I have field_number column i.e. from content type.

Now I want to subtracts these two column, while using math-expression its taking the string count column as string its not considering the count number.

Is there any solution to subtract these two fields?


texts: Drupal adding multiple directories to URLs creating duplicate content

texts:
I have a Drupal 7 site that is creating a seemingly infinite stream of sub-directories creating a vast amount of duplicate content. For example:

example.com/test/ - is a legitimate page.

example.com/test/test/ - is a duplicate of the above, and this goes on and on like so:

example.com/test/test/test/test/test/test/test/test/test/test/test/test - etc etc.

All of these pages are crawlable and returning a 200 code. I'm not very familiar with Drupal and I can't pinpoint what is causing this. Any ideas?

Many thanks.


texts:
I can't seem to find the answer to this anywhere.

Programmatically, I need to add new values to a custom field of a new node instance I just created via API.  I am taking input via a form and want to add that data to the custom field in the new node.  I know the columns of the custom field.

How can I do that, or where is a good reference?

(the custom field type is address, if that matters)


texts: Glossary input filter saving to node_revisions

texts:
I have been using the Glossary module and it has been working great. I add  "ADSL" into a node and if a glossary definition exists, on render it converts it to "<acronym title="Asymmetric Digital Subscriber Line">ADSL</acronym>".

However, today I noticed it has started putting the glossary term markup into the node content (saving in the database table node_revisions). When I edit the node again, it no longer contains "ADSL"; it contains the full markup generated by the Glossary input filter (<acronym title="Asymmetric Digital Subscriber Line">ADSL</acronym>).

As far as I am aware, the data is saved straight to the database before any input filter should touch it, as per Drupal Input Formats and Filters.

I am completely confused to how this is possible. Does anyone know what might cause an input filter to act so?


texts: Unable to add Quantity in Stock in Drupal Commerce 8 using Commerce Stock Module

texts:
I have enabled Commerce Stock Modules and its submodules
1. Commerce Stock API
2. Commerce Stock Field
3. Commerce Stock Local Storage
4. Commerce Stock UI

Created a Product Type ABC and added a field field_stock(field type Stock Level ) under fields section of Product Type ABC
Under Commerce >>  Configuration >> Stock
I have set the default configuration for STOCK SERVICES as - Use Default - and default value is set to Local Stock

and when I edit the products I see it as

What am I missing I have added a field but it does not show the text value where I can add quantity for a product ?


texts: How does POST action work on a drupal login form?

texts:
I was looking at the login form tag of Drupal and was surprised that it does not reference any specific page to handle login. Example:

<form action="/node?destination=node" .....>

Or if I go to the login page directly:

<form action="/user/login" .....>

or

<form action="/user" .....>

So how does this work? How does the browser know which page to submit the POST data to?


texts: What's better to do when we create a new site project?

texts:
I need an advice about beginning a new project layout in Drupal 7. Do you think it is better starting with a basic theme, or creating from zero the project with theme of mine?
I think it is probably better to begin with a basic theme also for the CSS styles that are compatible with all the browsers

What do you say?


texts: Specify a single node to load a stylesheet on

texts:
Possible Duplicate:
  Any way to add CSS for a single page/node?

How do I make it so that when a specific node loads (a page with path /some/page) that it also loads a specific stylesheet?


texts: How do Image Optimize pipelines coexist with core's Image toolkit optimization?

texts:
I have the Image Optimize module installed. I've also installed and configured Image Optimize Binaries and Image Optimize reSmush.it.
I've created a simple pipeline that processes an image through reSmush.it's magic, setting the desired quality to 80%. This basic setup allows me to apply an optimization process to images after they have an image style applied. (The Image Optimize module adds an option to the image style creation form to choose your optimization pipeline.)
From my understanding, for any particular image, core's process might look like:

Original image uploaded via image field (1200x800px, unoptimized).
In my display, I apply the image style to scale and crop this image to 300x200px.
When this image is accessed, the image is scaled and cropped to 300x200px, and then core's JPEG quality would take effect and optimize this cropped image.

With the Image Optimize pipelines, I'm not sure if core's JPEG quality settings are still used: does the image get core's optimization plus the Image Optimize pipeline? or does the Image Optimize pipeline override core's optimization? I can't seem to find an answer to this anywhere. How do these options coexist?


texts:
Make Feed Importer go to given URL which has a list of thumbnails and links to their pages and make it check/open each of those links and scrape content from there into unique nodes importing its titles and images and so on and so on?

Is this possible or does the content has to be listed in one single page to scrape it?

I've done it with just scraping from one page or .xml feed, but how do I tell my feed to check that one page for links and go to those links and scrape content from each and every link?


texts: Programmatically loading Custom block in page/node preprocessor

texts:
I've followed some previous solutions on DA to programmatically load a Custom block in my page preprocessor hook but nothing I try seems to be working.

Currently, my custom block is within Structure > Block Layout > Custom block Library under the name 'SGT Pricing Header' (Machine name: sgt_pricing_header, ID 12).

I have attempted loading it in the page preprocessor as well as the node preprocessor hooks.

Currently I have:

function THEME_preprocess_node(&$variables) {
    $block_entity = Drupal\block_content\Entity\BlockContent::load(12);// BLOCK_ID
    $block_view = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity, 'sgt_pricing_header');
    $variables['block_pricing_header'] = $block_view;
}

I have also used 'sgt_pricing_header' in place of the ID 2 with no success.

In the TWIG template, which is a paragraph template by the way, if that is relevant, I am simply trying to display the block with

{{ block_pricing_header }}

I referenced Programatically render a block in a twig template when trying to get this to work.

I also tried using Twig Tweak to display the block, without success.

{{ drupal_block('sgt_pricing_header') }}

Simply does nothing.

PHP Version: 5.6.32-1+ubuntu17.10.1+deb.sury.org+1
Drupal version: Lightning (lightning-8.x-2.17)

Not entirely certain what to try next other than simply hard code the block content into the template which I would prefer to avoid.


texts: Adding  to options on node edit and node create screen

texts:
I have an option field on my content types that allows you to select several items in a taxonomy vocabulary. The list has several child and parent items and it is really hard to read.

Is there a way I can add html around these checklist elements so that I can format them better with CSS?

I have attached a screenshot for more info.


texts: Passing context to a block field of a display suite node

texts:
I have a view that displays results of nodes.  In these nodes, I have a block field via Display Suite (a table view from Commerce Add To Cart Extras).  The block View renders fine in a full node display, since I can easily pass the contextual filter, but I need this block field to also render in the node when it's a teaser as a result of a View.

I tried looking at the Views default from context module, but I can't seem to get it.  How can I get my views in my teaser to just know what the context is within its particular node?

I hope this makes sense.


texts: How can I allow a person to create multiple orders at once, for both themselves and others?

texts:
I have a site that offers in-person trainings and I'm currently using CRM Core to track registrations.  That is working just fine, but I am having trouble coming up with a flexible way to pay for these registrations online.

Example use case:

I have a group who will be taking a class together, say 5 people.  I'd like to allow a single person (the person organizing the group) be able to register all 5 people (already possible), but then select which of these registrations to pay for, creating separate orders for those the organizer doesn't want to pay for.

Say I am registering myself, my spouse, my kid, and 2 friends.  Each registration should create a line item, but I want the first 3 (me, spouse, kid) to be on one order I'll pay for immediately, with the other two becoming separate orders each owned by the other students.

Once I figure this out, it should be easy to then send emails to the other two students letting each know a new account has been created for them w/instructions on how to log in and pay for their registration.

This seems like something others would have thought about before, but I can't find any info on how to make it happen.  Any suggestions?


texts: How to hide the "Add to cart message" on mobile site"?

texts: I'm using two different themes for main site and mobile site. I want to hide the Add to cart message on mobile site because I've created a custom window with custom messages but I want it to be displayed on the main desktop site. How can I hide it on mobile site?


texts: Drush Feature Update removing t() and l() function usages

texts:
I have a feature that currently has things like this:

'body' => '
' . t('Welcome back') . '%user:field_first_name!
',

However, using drush fu myfeature generates this:

'body' => '
Welcome back%user:field_first_name!
',

Why is this happening? (removal of t() and l() functions).

I did not create this original feature.


texts:
My site has 3 languages. In my node--service.tpl.php, I've put the following:

<?php if ($language = 'es'): ?>

<a href="<?php print $base_url . $node_url ?>">Leer más

<?php elseif ($language = 'en'): ?>

<a href="<?php print $base_url . $node_url ?>">Read more

<?php else: ?>

<a href="<?php print $base_url . $node_url ?>">Leere más

<?php endif; ?>

However, it only shows me the language es even a page en, i.e. it only shows me the first div. Any idea?


texts: How to eliminate direct access to files in private directory?

texts:
I have set up my Drupal 7 site for private files in a directory above root (../private). I also set my filefield on my node type to upload the image files to that private directory.

I have two user roles: man and woman. Both user roles can create nodes of a certain type, containing that image file field. Men can never see another man's photo; same thing for women. Men can always see a woman's photo; same thing for women.

Here are my current results:

When a man visits a woman's node, he can view the photo within the node content: http://example.com/members/76/gallery/public/photo-123

When that man views the page source and copies the image URL, he can view that image directly in his browser: http://example.com/system/files/styles/apply_simplecrop/private/pictures/1/Public/filename.jpg?itok=ABC123&sc=abcdefghijklmnop

If that man shares that direct link with another man, that other man can view that picture as well. If he shares the direct link with a woman or a non-logged-in user they are served an Access Denied message and cannot view that picture.

If a man tries to access that image URL without the "itok=" text in the link, he receives an Access Denied message.

My desired result in all of those examples above is to display an Access Denied message.

The ../private directory has an htaccess file containing Deny from all.

Am I missing a step? What can I do to securely deny direct access to those files in the way that I described above?

Thanks!


texts: View in block doesn't sort by date whereas page does

texts: I've got a 'archive' view in a block on my openblog drupal blog. In the view, the page view sorts ok, but in the block sorting by date doesn't work - it is always sorted by ASC.


texts:
I just created a custom module following this tut:
generate-programmatically-image-styles-drupal-8

It works great but the following occurs. When I create a new node and upload the image you see that for every style I have it creates a image (like the custom module should). But when I save the node all the created images are deleted?

Is this a standard function in Drupal that can be disabled? Hope someone can help me with this.

Thanks in advance


texts: How to use drupal function in simple php file inner drupal?

texts:
I want to use $user and db_query in  credit.php file. This file exist inner theme file.. here $user and db_query is not working. How to make any simple .php file to drupal file.

I am using this code but it produces an error:

/** bootstrap Drupal **/
chdir("/path/to/drupal/site/htdocs");
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


texts:
I'm using Drupal 8.1.7 and use group module. When a user display a group or an article linked to a group (/group/... or node/...), I want to specify some specific CSS for each group.

I develop a module that do the trick (verify if we display a group or an article, get the group and load a JS file that modify the CSS style of the page). Work great on my dev drupal with no cache, but when I test the module in production with cache active, the JS file seems to be load only once. Have to do a drush cr to load again the file.

There is any way to tell Drupal to load the file everytime, or don't put it in cache ? In the mymodule.libraries.yml maybe ?

color:
  js:
    js/mymodule.js: {}
  dependencies:
    - core/jquery
    - core/drupalSettings
    - core/drupal


texts: Add description to each entity reference

texts:
I'm using Drupal 8 to build a new web app. I am allowing the user to add connections to other content on the site using taxonomy entity references. I'd like them to be able to add a description to each reference - i.e. select 'Node X', and add a description about the relation to 'Node X'.

Is this possible?

Thanks!


texts:
How do you do this in Drupal 7?  I would like to place the following items that are unique to the home page:

A views_slideshow
A row of 3 large images
Some normal typed content
3 most recent Articles

I could manage this on a normal page, but I'm not sure how to put it on the home (front) page.


texts: How to disallow certain strings in signatures?

texts:
As I mentioned here, spam filters do not apply to forum signatures. This opens the door to human spammers to put their spam content in their signature. I am wondering what is the easiest way to tackle this problem? One obvious solution is to extend the signature or spam modules to fix this loophole. But that is beyond my coding capacities as I know very little of drupal API.

So I am wondering whether this can be done using some sort of preprocessing or defining some rules to check the signature for certain regexps and disallow registration/saving profile when the string is flagged as potential spam? I really appreciate your hints as I'm badly suffering from this problem.


texts: How to display image instead of a value in Drupal 7?

texts: I'm having a field 'List (text)' in my custom content type as 'Select list' with Number of values as 'Unlimited', what I'm searching is to display an image instead of a value, for an instance I'm having values like Condo, Single Family & Multi Families so for these 3 different values I'm having 3 different logos which I want to display so what should I do to get this thing done?


texts:
In my Drupal 8 multilingual site I used the link field and set it to "only internal links". If I save them, I now get the following:

<a href="internal:/node/29" target="_blank" tabindex="0">

I have path, pathauto and redirect module enabled and the link is added in a custom block library block.

When I click it, it of course links to the wrong page. Does anyone have an idea what could be the problem here? I can't find any other examples from people who have the same problem.


texts: How i can popuplate user's facebook data into my built-in drupal register form?

texts:
How can I populate an authorized user's Facebook data into my Drupal registration form?
Note: user is authorized from my Facebook application and allowed my Facebook app to access his data.

Update: I am using Drupal for Facebook, and to populate the user info I am implementing fb_form_alter inside fb.module. My code is

function fb_form__alter(&$form, &$form_state, $form_id) {
if(!($form_id == 'user_register_form')) {
return;
}
if ($GLOBALS['_fb'] && $fbu = fb_get_fbu($account)) { // @TODO - is fb_get_fbu() a performance hit here?
    try {
      $data = fb_fql_query($GLOBALS['_fb'], "SELECT name FROM user WHERE uid=$fbu", array(
                             'access_token' => fb_get_token($GLOBALS['_fb']),
                           ));
      if (count($data) && isset($data[0]['name'])) {
        $form['account']['name']['#default_value'] = $data[0]['name'];
      }
    }
    catch (Exception $e) {
      fb_log_exception($e, t('Failed to alter username for facebook user %fbu', array(
                               '%fbu' => $fbu)));
    }
}
}

I put the above code after the form_username_alter() function but with no success :(


texts: Is possible to sort a views field that is generated by custom views handler?

texts:
I have a view field that is generated by a views handler.
The logic inside the render method is as following:

function render($class) {

  if (class_hasnt_started($class)) return 'Registered';

  if (user_completed_entire_course($class)) return 'Completed';

  if (user_completed_some_classes($class)) return 'Attended x of y';

}

My question is, can such a field be sorted?


texts: How can I compare a view token with a string?

texts:
I have a view token
{{ field_category }} == Content: Category
I need a condition like
if field category == "Foo & Bar"
do something
else
do something
I wrote code
         {% if field_category == "Foo & Bar" %}

             string1
         {% else %}

            string 2

        {% endif %}

But it always goes for the else part even if the token value is "Foo & Bar"
Please help to find a solution


texts: Add JS to specific pages AFTER all other JS

texts:
I am working with JSON to theme Google Maps in the api v3.

I have my custom JSON script as an external JS file, and I am currently referencing it in html.tpl.php after the other scripts are loaded. This works great, and maps are themed, but on any pages that don't have a GMAP on them, i get the following error in Dev Tools...

  "Uncaught TypeError: Cannot call method 'addHandler' of undefined"

So I am trying to add the JS file to just the pages that have a GMAP, in template.php I use the following under the MY_THEME_preprocess_page function.

  if (isset($vars['node']) && $vars['node']->type == 'venue') {
      drupal_add_js(drupal_get_path('theme', 'MY_THEME') . '/js/mapstyle.js');   }

This loads the JS for all pages that are of the content type "Venue". The problem I am having is that the JS file is loading BEFORE the gmap scripts, and the style is not being rendered.

How do i get a JS file to load after all of the other scripts? I also need to load the JS file on a views page mysite.com/venues , but as a views page doesnt have a "node/id" alias, I am struggling to figure out how to only load the JS on that page using template.php


texts:
Is it possible via Twig to output a field's value, that uses the fields formatter. I would like to display a file field two different ways in the same twig file. The first will be a link to the file with a label to the left. The second will be the SOLR Extract text from the file, with a label on the left.

Here are the formatters I am talking about.

As shown in the second image, there are multiple options for how to display the field. Is there a way in Twig to do something like the following.

{{ content.field_name.FORMATTER_NAME_HERE }} or
{{ content.field_name[0].value | FORMATTER_NAME_HERE }}

I would like to use the URL to file and Text extracted from attachment formatters.


texts: Get total row count in views-view-fields.html.twig

texts:
How can I get the total rows number in views-view-fields.html.twig template file in Drupal 8? In Drupal 7, I can get it by the following code.

$view = views_get_current_view();
$view->total_rows;

Is there any variable to render the total number of rows in Drupal 8?


texts: Updating field in external Drupal database

texts:
I'm working on a project where I have 2 Drupal installations which occasionally need to interact with eachothers database.

So far, I've been able to set up all interactions using db_set_active and db_select/db_query/db_update statements (example below):

db_set_active(.....);
db_select(.....);
db_set_active;

Simple select queries don't pose any problem. And while update queries are being propagated correctly, they have an inherit issue: they don't call the save hooks in the target Drupal installation...

My use case: I'm database updating a boolean CCK field (in Drupal B) from 0 to 1 (through a module script at Drupal A) and Rules (at Drupal B) should trigger on this. Moreover, the field caches aren't cleared so probably going directly through the database isn't a very good way to update the field...

Any other ideas how to update fields from within external scripts? Or maybe how to execute Rules while keeping the database operations?

Thanks


texts: Cannot modify headers when adding a new user

texts:
I periodically get an error in my drupal log that I believe is generated when a user is modifying or creating an account.
Today, when adding an account as an admin, I finally saw it on the screen:

  Warning: Cannot modify header information - headers already sent by (output started at includes/common.inc:2777) in includes/bootstrap.inc on line 1486.

Here is the code referenced in the error, line 1486 is the server protocol:

foreach ($headers as $name_lower => $value) {
    if ($name_lower == 'status') {
      header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value);
    }
    // Skip headers that have been unset.
    elseif ($value !== FALSE) {
      header($header_names[$name_lower] . ': ' . $value);
    }

I am using a bootstrap theme for the main part of the site, however, this is the admin theme which uses Garland. All users see the admin theme when editing their account. To my knowledge, there is no ending php tag being used somewhere.

Note: I understand that this question has been asked numerous times but I am not satisfied with the level of detail and wanted to get down to something more specific for my instance.

Drupal 7.59.


texts: How to limit showing of a block just in home page?

texts:
I have a library book and in the first page or homepage of my website I want to show just 4 random books in center of my page.

How to set a View block to just show in home page?


texts: Facebook "like" button fetch wrong data on views

texts:
I am using Drupal 7 with views and Addthis module for facebook "like" and "share" .

I have add a "like" field to views, so every piece of content has a "like" button.
when a user click on the "Like" button, facebook fetch the wrong data. It can be the picture of different content (e.g. content from the sidebar), it can the user picture instead of the content picture, etc.

How can I fix this?
Should I use different social module that is more suitable for working with views?

Update (2/28/2014):
I spoke with addthis support, and they say I need to add the open-graph for the image. The problem is that I have many images in all the views.
Anyway, I also have the metatag module installed and inside I can define open-graph. When I atried to define the Open Graph image as the image token ([node:field_image]) of the node - nothing change, meaning it doesn't work.
When I tried to add image token to the "views open-graph" -  I didn't find one.
Can someone help me define image open graph to the views output?


texts: How to duplicate a node into an external database in Drupal 8

texts:
What I am trying to do is to save a copy of a node object after it is inserted into another Drupal database.

As it can be seen in the following piece of code, my idea is to change the database after a node is inserted. Make a copy of the node and save it. Then, return to the default database.

However, seems like entity storage manager is set to default database in node save function. Therefore, the node is getting saved inside the default database again.

//... mymodule_node_insert

$node = Node::load($id);
\Drupal\Core\Database\Database::setActiveConnection('external');
$db = \Drupal\Core\Database\Database::getConnection();

// save the node in the shared database
// Create node object with attached file.
$sharedNode = Node::create([
    'type'        => $node->getType();,
    'title'       => $node->getTitle();,
    'body_text'   => $node->get('body')->value,
]);
$sharedNode->save();

\Drupal\Core\Database\Database::setActiveConnection();

How can I make this work? Am I following a correct logic?

Any helps would be appreciated.
Thanks


texts: How do I change the Views (Entity Reference) filter via AJAX?

texts:
I have an entity form that allows an admin to select a content type (checkbox) and an autocomplete field that is tapped into a VIEWS Entity Reference (via the Reference Method).

Goal: What I would like is to have the views entity reference filter dynamically change based off the end-user selection.  Contextual Filters would have worked but I think Filters is better because of the multiple selection.

So far I have a view with entity reference and it is pulling the correct data for content 1-4.  When I use the autocomplete it does what it's supposed to. I think the next step is to use AJAX to change how the autocomplete pulls from the view by changing the FILTER.

Can you help me figure out how I can change the views filter via AJAX/JS?


texts:
For example if I've page title as "Income tax forms 2012" it should change automatically change to "Income tax forms 2013" in Y2013.

Tokens work for node body but not in title. It did not work when I tried.

Any suggestions?


texts:
Is it possible to share content/nodes in a drupal multisite environment.

For example:

Content type "Story"

Site 1- Use this content
Site 2- Don't use this content
Site 3- Use this content

It seems the drupal multisite environment suggests using table prefixes for different sites.


texts:
I would like to delete taxonomy term. Unfortunately on taxonomy -> list I can only see "edit" button next to each term (under "operations"):

How can I delete the term I added earlier?


texts: Rules: Display Message every first login per day; reset day 12:00am

texts:
I am trying to create a rule that will display a message to the user when (s)he logs in for the first time that day.  Reset has to be per day at 12:00am.

Notice: not the first time in 24 hours but the first time that day.

So if user logs in 8/30/2016 11:59 and then 8/31/2016 12:01am then both times (s)he will see message.

I tried to achieve this using event 'User has logged in' and condition: data comparison and comparing last login date with current date and time and offset 1 day.  But it's not workings.  It might be possible to do this with the custom php?

Thanks God Bless.

------------------------------------------Update------------------------------------------

9/1/2016

I need help creating the following rule:

Trigger: User logs in

Condition: User hasn't logged in this today(since 12:00AM)

Action: Display message to user

Am I doing something wrong, or can this be achieved with custom Php?
My attempt is described in first update.  Can't seem to make this work.  The message should only appear every day.

Day = 12:00:00AM - 11:59:59PM


texts: Is there a module or a detailed how-to out there that can help with creating a form to add multiple products to the cart at once for Drupal 7, Ubercart 3.0?


texts: Can't edit settings.php in Drupal 7 - Premission Denied - Can't Write to File via Cpanel File Manager

texts:
Trying to edit settings.php via Cpanel File Manager

I can CHMOD the file to anything I want and back but can't write to it.

I get the following message:

  Could not write /home/testing/public_html/sites/default/settings.php: Permission denied

Do you think Apache suEXEC has anything to do with this?


texts: Webform, validate field against another field of submitted data

texts:
I have built an event registration page.
I have a registration web form that people fill out. When they submit the form  they receive a registration code.
If they are registering additional people they need to enter that registration code in a field so that all the registrations are linked together and are searchable by the registration managers.

I want to reduce the possibility of people entering a wrong registration code by having the "Primary Registration Code" field validate against the registration code field of existing submissions.

The registration code field is generated by the webform serial module and is a hidden field on the form.

Any ideas how I can make this validation work?


texts:
I want use drupal functions in php files,I did it with below code

$path = $_SERVER['DOCUMENT_ROOT'];
chdir($path);
define('DRUPAL_ROOT', getcwd()); //the most important line
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Its ok and good fine, after this all drupal function exist,but my problem is here
when user logged in before this page when redirect to this page it not know as logged in user (it know as anonymous user ), how can have logged in user in php file ?

I try  drupal_session_regenerate() after below code but nothing happened, how can solve this problem?


texts: Recreating vocabulary and term pages by using views

texts:
Let's say I have a vocabulary named "Gallery" and terms inside of it: "One", "Two" and "Three".

Every term have a image field.

What I would like to accomplish:

After going to mysite.com/gallery I would like to have a custom view with grid of images of all terms from specific vocabulary. After clicking an image I would like to be redirected to mysite.com/gallery/[term-name] where I would have another view that would show a grid of specific fields from nodes related to this term.

I think it has something to do with contextual filters? But I'm not sure if it is possible to relate two views that way (so one would have path "/gallery" and other "/gallery/%" and one would dynamically create paths for the other), is it? :/

How would you approach a problem? Even if views wouldn't be valid solution.

PS. The main problem I'm struggling with now is to create a links in one view (/gallery) to other view (/gallery/%) :/ .

Regards!


texts:
I got taxonomy menu 'Categories' which list all Terms as menu links, so when clicked, it would open a list of items tagged with that term:

So if you click on Hats & Visors, it would open the list of hats and visors. The problem is, that it doesn't, only the first view (in this case t-shirts) works. In the rest of the views it only generates empty views container. Also if I changed filter in the T-Shirts view to filter Hats & Visors, it would work, the Hats & Visors section would show hats, but then T-Shirts section would stop working. I do not understand the problem.

My views settings:

Non-working views:


texts: Drupal 7: "Maintenance mode" message when the site is NOT in maintenance (Yes, I´ve cleared cache, 4 times now)

texts:
I get the "Operating in maintenance mode. Go online." message and the D7 site is not in maintenance mode.

The message doesn´t appears all the time, and sometimes it goes away when I refresh the page.

I´ve cleared cache. I´ve tested and it is most certainly NOT in maintenance mode.

I´ve checked Drupal Error reports, and I get this one (I don´t know it it´s related or not with the problem):

TIPO    acceso denegado
FECHA   Martes, 14 May, 2013 - 01:11
USUARIO Anónimo (-)
UBICACIÓN   http://www.liga.net/cron.php
REFERENTE
MENSAJE frontpage
SEVERIDAD   advertencia
NOMBRE DE LA MÁQUINA    xx.xxx.xx.xxx
OPERACIONES

Sometimes in a complete random way, as an anon, it appears the page "site offline". When I reload the page it´s up again...

Any thoughts on this will be very much appreciated. Thanks!


texts: How do I hide the core version to the outside world?

texts:
I was bothered in knowing with whatcms.org a version can be given for drupal 8, even a minor version - no minor version, instead, when I tried with a drupal 7.
Curiously enough in my case, I got a version slightly newer (just one minor version ahead), but I'm concerned anyway, should I not?
I'm thinking of every situation where a security update cannot be performed right away.
I don't even know how can the version be guessed from outside.
I issued a tail -f on the access log while pressing the Detect CMS button on whatcms.org, but, mysteriously, I got no log entry from there. Perhaps they cache the previous results on the same site not to perform a fetch each time the button is pressed with the same domain string input?


texts: Deducting a userpoint from the author of a quiz for each question answered correctly by another user

texts:
My site uses the quiz and userpoints modules so that users take quizzes and receive a userpoint for each correct answer. That part works fine.

What I want to achieve is to have the same number of userpoints deducted from the author of the quiz - i.e. the quiz creator 'pays' the points to the users who answer their questions correctly.


texts:
I am having some trouble understanding the concept of overriding twig templates. I have turned on debugging mode and most of the time I see overriding suggested file names like this:
<!-- FILE NAME SUGGESTIONS:
   * form-element--webform-generate-system-number-form-1--form--department.html.twig
   * form-element--webform-generate-system-number-form-1--form.html.twig
   x form-element--webform-generate-system-number-form-1.html.twig
   * form-element--webform-select.html.twig
   * form-element.html.twig
-->

however, there is one, fieldset.html.twig that does not have suggested file names.
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'fieldset' -->
<!-- BEGIN OUTPUT from 'themes/custom/bootstrap/templates/form/fieldset.html.twig' -->

now I know I can write a hook for fieldset and create a hook_suggestion, but is there an easier approach to this, such as a pattern?
fieldset--webform-generate-system-number-form-1.html.twig does not seem to work.


texts: Overriding page and browser title for a view in my module

texts: I've tried to set $variable['title'] in MYMODULE_preprocess_page_title and it works only for the page title but not the browser title (in the title bar).


texts:
I want to hook into user registration but there doesn't seem to be any hook for it anymore. This is what I see from Drupal 8.8:
hook_user_cancel
hook_user_cancel_methods_alter
hook_user_format_name_alter
hook_user_login
hook_user_logout
Furthermore I can't find any events for it neither.
So how can I hook into user registration?


texts: Change module's description from another module

texts: How can I change a description of a module from my custom module or how can I override hook_process?


texts:
I would like to let pages continue to benefit from Drupal 8 caching mechanism for anonymous users, except for a specific blocks which should update on every page refresh knowing that they are generated from Views.

Is it technically possible? How?


texts:
Hi I have a problem with Flexslider module. I use Flexslider in my view. Everything worked properly, but suddenly Flexslider does not work. I don't remember what I've changed, maybe some css files, which have nothing common with flexslider. Strange is that in a view's preview flexslider works fine.
Could anyone help me? It's the newest version of flexslider installed via drush. Thanks.


texts: Views php field or filter to a file or module

texts:
If I already have a view with a php filter or a php field, in drupal 7, how can I convert my whole view into a page? (prevent code injections or other security risks)
What is the right way to resolve this?
Writing a module or a tpl.php file?
Thanks


texts: Sort by in View do not work properly if there are more than one Sorting field

texts:
I added two Sort By fields to my View: "Sort By Title" (by string) and "Sort By Rooms" (number) - they are custom PHP Sort with functions defined in module.

When I add them separately (just one of them) they both works but when
I add them together only the last one works (the one on the bottom in section Sort criteria)... and if sorted by the first one I am getting "random" sorting results - I mean I do not see any pattern....

What is going on ... is this a bug ?

EDIT:

The query generated by the View:

Just list a of nodes with Type = 'diy_hotel'

SELECT
    node.title AS node_title,
    node.nid AS nid,
    'node' AS field_data_field_diyh_hotel_status_node_entity_type
FROM
    {node} node
WHERE
    (( (node.status = '1') AND (node.type IN  ('diy_hotel')) ))

Sorting Functions:

The function get_rooms_number_from_hotel_nid() returns an integer number.

function roomsgetter_admin_hotel_index_sort_by_hotel_name($row1, $row2) {
    if ($row1->title < $row2->title) {
        return -1;
    }
    if ($row1->title > $row2->title) {
        return 1;
    }
    return 0;
}

function roomsgetter_admin_hotel_index_sort_by_rooms($row1, $row2) {
    $a = get_rooms_number_from_hotel_nid($row1->nid);
    $b = get_rooms_number_from_hotel_nid($row2->nid);
    if ($a < $b) {
        return -1;
    }
    if ($a > $b) {
       return 1;
    }
    return 0;
}

EDIT2:

I found code that executes the sorting functions. The problem there is
that it executes ALL sorting functions defined in the view - but should
execute only the one selected by the user via dropdown (f.ex. "Sort By Rooms")
that's why I got all strange sorting results - the final sort was a combination
of all defined sorting functions...

I was able to "fix" this by altering the "views_php_handler_sort.inc" file
of drupal core. The function responsible for sorting now looks like:

function php_post_execute() {
    $sort_by = isset($_GET['sort_by']) ? $_GET['sort_by'] : $_POST['sort_by'];
    if (!empty($this->options['php_sort']) && $this->view->style_plugin->build_sort() && $this->options['id']==$sort_by) {
       $this->php_sort_function = create_function('$view, $handler, &$static, $row1, $row2', $this->options['php_sort'] . ';');
       ob_start();
       usort($this->view->result, array($this, 'php_sort'));
       ob_end_clean();
    }
}

I added the last IF conditional statement here.

Although this fixed the sorting - I have a question "is this a bug?",
should I file an issue to drupal.org ?


texts: How do I add a #process callback to a fieldset form element without overwriting the existing callbacks?

texts:
I am using the following code.

$form['my_fieldset'] = array(
  '#type' => 'fieldset',
  '#title' => t('My Title'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,
  '#access' => TRUE,
  '#process' => array('my_callback_function'),
);

If a fieldset is collapsible, it gets two callbacks at some point later.

form_process_fieldset | (Callback) form_process_fieldset();
ajax_process_form | (Callback) ajax_process_form();

They aren't added to the array with my callback function. If I look at the form array, there is only my callback; so, there is no collapse functionality.

I tried to avoid that by adding the callback in hook_form_alter(), but this is too early; the callback functions are still not there.

$form['my_fieldset']['#process'][] = 'my_callback_function'; //Not working eather

So where is the right place to add a #process callback to my own form element, so it gets added as last callback in the callback array, or at least is not destroying the callbacks implemented by this specific form element itself?

I do some calculations in the callback to set #access = FALSE for this fieldset under certain conditions. This works fine, but maybe this is the wrong way to do it.

The documentation on #process says:

  You will probably want to add to the existing array rather than writing over it, so don't follow this usage example exactly.

The documentation is not very helpful, I don't follow but there is no info how it is done right.


texts:
I am using drupal 7, and i have a problem with the modules.The problem is when I login as an administrator i cant enter to the modules tab in the admin menu. there is a message say "500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed."
how can i enable a specific module?and how i fix this issue?

Thanks for your cooperation.


texts: Connecting different content types/tables in Drupal with primary/foreign keys

texts:
I am using Drupal 7 and I want to create tables which have primary key and foreign keys using content types. Each table would be created using content types. Let's say, when I create Fruit content type, it should create a table for it, right? Then, I may have Price table, hence, I create a Price content type. Now, the Fruit id(primary key) should be connected with Fruit id in the Price table (content type). How's this possible? I don't know how to code the tables/content type schema.

Thanks for your help.