texts:
We are looking to create a content type that will allow users to create reviews. Each review (node) when created it will be tagged with one taxonomy term.

For example, any user can write a review for Phone > LG > G3

One of the fields for the reviews content type will be RATING. The rating
will be five star and later will be used on a view to show an average score for the particular taxonomy term (product).

Based on the example ablove show an average score for LG G3 phone. Which will be shown in a view.

Should we use a list field (1,2,3,4,5 as options) for the RATING field? Or is better to wait until the Fivestar module is more mature? Haven't even used Fivestar but it seems that it will do what I am talking about. Or am I wrong?


texts: I want to include custom css only for one content type, is that possible?


texts: Creating a custom login system by developing a new module

texts:
I've created 2 files:

login_process.info
login_process.module

I've created the table "user" in the database that Drupal is using. I want to display a custom login form with fields "Username" and "Password".

Assuming the data from Username and Password fields are in the correct format(proper validations), when the submit button is pressed, a query is done and data to check if the values matches that found in the table.

If no result is found, it displays an error message

else it redirects to to the welcome page.

Here are the codes:

login_process.info

name = "My login process module"
description = "Performs login process"
core = "7.x"
version ="7.x.1.0"
package = "Login/Register"`

login_process.module

<?php

/*
*Implements hook permission
*/

function login_process_hook_permission()
{
 return array(
    'submit login_process' => array(
      'title' => t('Submit login form'),
      'description' => t('Submit the login form')
    ),
  );
}

/*
* Implements hook menu
*/

function login_process_hook_menu() {
  $items = array();
    $items['login-process'] = array(
  'title' => 'login',
  'type' => 'MENU_NORMAL_ITEM',
  'access arguments' => array('submit login_process'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('login_process_form')
    );
    return $items;
}

/*
* The login form
*/

function login_process_form($form,&$form_state)
{
  $form['Username'] = array(
  '#type' => 'textfield',
  '#title' => t('Username'),
  '#size' => 20,
  '#maxlength' => 20,
  '#required' => TRUE,
  '#description' => t('Please enter a valid username'),
  );

  $form['Password'] = array(
  '#type' => 'textfield',
  '#title' => t('Password'),
  '#size' => 20,
  '#maxlength' => 20,
  '#required' => TRUE,
  '#description' => t('Please enter a valid password'),
  );
  $form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Add item')

  );
  return $form;
}
/*
* Validation handler for the login_process_form
*/

function login_process_form_validate($form,&$form_state)
{
  print('
'.print_r($form_state['values'],1).'
'); die();
  if (!preg_match("/[a-zA-Z]/",$form_state['values']['Username']))
  {
    form_set_error('Username', t('Username must contain only alphabets'));
    return FALSE;
  }
  return TRUE;
  //add more validations for Username and Password
}

/*
*Submit handler for the login form
*/

function login_process_form_submit($form,&$form_states)
{

  $username = $form_state['values']['Username'];
  $password =  $form_state['values']['Password'];
  $results = db_query("SELECT Username,Password FROM user WHERE Username='".$username."' AND Password='".$password."'"));
  if(is_null($results))
  {
    form_set_error('Username', t('Wrong username or password. Try again!!!!'));
    return FALSE;
  }
  else
  {
  echo "Welcome".$form_state['values']['Username']."Logout" // it will be better if it is displayed in a block
  }
}

It neither display errors nor the login form created from the module. Can anyone help me here? Do I have to install additional modules to make it work?

Most of the codes are based from Daily dose of Drupal episode 16 to 22.


texts: Unique Taxonomy Term Requirement Across Vocabularies

texts:
I haven't used taxonomies much so I'm hoping for a quick explanation on an issue for a site I'm working on.
Let's say I have two vocabularies.  Portland and Seattle.  In each one I want to have a term called "Services".
Is that not allowed?  I added "Services" to the first vocabulary - but when I attempt to add it to the second - I receive the following error:
A taxonomy term with name Services already exists.

Shouldn't it be the Vocabulary->Term combination that makes it unique?  Why would the same term in different vocabularies be an issue?


texts: How to hide Forums from anonymous users?

texts:
I installed Forum module.
So, I have 'Forums' link in 'Tools' menu corresponding to the path /forum defined in forum.routing.yml in which access is defined by _permission: 'access content'.
In my site, anonymous users are allowed to "View published content", so they can see the 'Forum' link.
I don't want anonymous users to be able to see forums and, therefore, the forum topics.
I thought to override the _permission of forum.routing.yml but I don't know how to do that?
How can I do that?

Or is there another solution?


texts: Drupal Calendar, why some events appear as "all day" events even if they are not "all day" events?

texts:
Why some events appear as "all day" events even if they are not "all day" events in Calendar Views?

As you can see, these events have just a start date defined at 00:00. But they are not "all day" events:


texts: Expose a custom view filter based on custom field in another node

texts:
I want an user configurable boolean view filter, displaying child nodes in an hierarchy based on a value, canDisplayOthers, in the master node.  The master/children are joined by a field setID.

I tried to do a self-join, adding a view relationship based on setID, but setID is not in the list of relationship fields.

Using Php, the recipe in:

https://ohthehugemanatee.org/blog/2013/12/26/44497-people-are-wrong-how-to-never-use-views-php/

says to use a handler.  My handler would return a boolean, something like:

class mymodule_handler_field_isDisplayable extends views_handler_field {
  /**
  * Render the name field.
  */
  public function render($values) {
    $value = $this->get_value($values);
    /*
       How can I get current node ID (nid) here?

    */
  }
}

and a hook_views_data something like:

function mymodule_views_data() {
  // Basic table information.
  $data['mymodule_ToDisplay'] = array(
    'table' => array(
      'group' => t('Global'),
      'base' => array(
        'title' => t('ToDisplay')
        ),
      ),
    'name' => array(
      'title' => t('ToDisplay'),
      'field' => array(
        'handler' => 'mymodule_handler_field_isDisplayable',
      )
    ),
    'filter' => array(
    'handler' => 'views_handler_filter_boolean',
    )
  );
  return $data;
}

I can't figure out:

in mymodule_views_data, what is this thing called 'table'?
how do I get the setID or current nodeID into the mymodule_handler_field_isDisplayable function?

In curiosity;
- what is the minimal hook_views_data?
- Where is a good place to find where hook_views* parameters are explained?

I am using drupal7 and views 3

ADDITION  15 July 2014

Geoff, below, kindly mentioned that the problem would be easier if I created a master node content type.  I created a masterNodeType content type, containing the fields:

setID
canDisplay

Now, masterNodeType and childNodeType have the common field, setID, but I can't see setID when I configure the view relationship.  How do I get setID, and/or masterNodeType into the view relationship?  What is the criteria for those view relationship components?


texts: Views: Select nodes having a specific field empty

texts:
I know how to create a filter to show nodes having a specific field empty, using Is equal to operator, But I want to expose this filter to visitor in form of checkbox. I want a check box for example with title "Show nodes that doesn't have an image".

Is it possible using Views 3?


texts: Existing module for logged in user image upload

texts:
I'm looking to build an image upload website. The only feature needed is the ability for logged in users to upload images.

Is there an existing module for this?

I could just build a custom module for a form; but i wanted to find a decent module to build this before investing time into it.

Required:

Image upload restricted by user role
Each Image upload becomes either node

Some wants:

Image cropping


texts: 8.3: How to create a node via REST with html?

texts:
I have a Drupal 8.3 setup and working and want to add content via REST. I can create nodes fine, but only in plain text. I can't figure out and can't find any documentation for how to submit content as html so it could have formatting.

I found a comment that had examples for submitting comments with basic html with the body specified like:

{"content_body": {"format": "basic_html", "value": "Hi"}

But when I tried to do something similar with the 'body' tag for posting to /entity/node, it returns a 422 response with this message:

Unprocessable Entity: validation failed.\nbody: Body: this field cannot hold more than 1 values

For reference, this is basically the hal+json body of the post (minus the taxonomy stuff not relevant to this question):

{
  "body": {
    "format": "basic_html",
    "value": "This is the body of the test"
  },
  "title": {"value": "Test One"},
  "type": {"target_id": "Article"}
}

If I drop the 'format' tag from the body dictionary, everything works fine... except the tags are displayed and not interpreted as html.

Thanks in advance.


texts: Drupal Exposed filter with auto-submit works only once

texts:
I have a View with an exposed filter that uses Ajax and auto-submit. Now, the problem I have is that it works only once.

For example, there is a check-box and when I tick it, the Ajax comes to action and the filtering is done. But when I try to use any other filter, or the same check box nothing happens. Do you guys have any idea?

Note that I've made some modifications to the view template and the views-exposed-form template.

Thanks!


texts: How to set different root folder access for different roles in elFinder

texts:
I'm using drupal 7.69 and elFinder 2.1.46.
A private page is showing elFinder browsing window with 2 root folders

root1
   |-dir1
   |-dir2
root2
   |-dir3
   |-dir4

I am trying to setup 2 roles:

role 1 has r/w access to root1 and r/o access to root2
role 2 has r/o access to root1 and r/w access to root2

I've gone through the Drupal permissions, but they apply to all folders and files served by elFinder.
I've looked at profiles in Configuration > Media > elFinder, but it does not seem like there is anything about level of access in there.
I have read through https://github.com/Studio-42/elFinder/wiki/Simple-file-permissions-control which advises to set the access rights in connector.php, but the Drupal module version also advises to delete connector.php after install for security purposes.
Finally, older messages on gitlab seem to imply that there is no refined file-level permission control options in the Drupal module yet.

My questions:

Is it possible to set different access rights on folders (root folders at least) for different roles?
If so, how is it done?

thanks.


texts:
I have a D6 site that uses both a geography taxonomy and a category taxonomy to organize 10s of thousands of nodes.  XML sitemap does a great job with automatically listing the individual taxonomy pages (all of geography A or all of category B) and the nodes themselves.  But I have views set up that show pages for "Category B in Geography A" such as http://example.com/myview/brooklyn/web_designers

I know that you can use xmlsitemap_custom to add these views results one at a time.  Is there any way to automate adding the entire cross section of the two taxonomies?  I want to add the view for every combination of the two taxonomies to the site map.


texts:
I just attempted to add an e-mail address link to a drupal page putting

Contact us

on the page. I then preview it, and no content shows up but the title. I remove the link and all the text is back again. What is causing this and how can I fix it? The strange thing is I have pages made earlier that already have mailto links on them.

Edit: I've tried this with both filtered and full HTML. I also have Invisimail installed, which does some e-mail filtering.

(I also couldn't get filtered html to turn a e-mail address into a hyperlink, but then discovered it was because it was in a  block.)


texts:
Hello everyone how are you?
I created a ConfigEntity with some fields:

Title (textfield)
Body (CKEditor)

After that I insert the first item:

Title = "Hello World"
Body = "This is a test"

And now I need to translate this Entity to show "Title" and "Body" in the Spanish language. E.g:

Title = "Hola Mundo"
Body = "Esto es una prueba"

How can I do this?
Thank you so much.


texts: Populate node image field with files submitted by webform?

texts:
Just wondering if this can be done in any way.

I have a block webform which is shown in a give node, let call this node Page-1.

The Page-1 node has a multivalue image field.

You can attach files to the webform (using https://www.drupal.org/project/webform_multiple_file).

Now let's say I submit the webform with 3 images attached, then my question: is there any way to populate the image field of the Page-1 node with those images?


texts: Entity reference field definition to auto create entities

texts:
I have a field definition set up like below. I want Drupal to do all the heavy lifting for me, so my definitions are minimal and rely on Drupal defaults:

    $fields[$field] = BaseFieldDefinition::create('entity_reference')
        ->setSettings([
            'target_type' => 'target_entity',
            'handler' => 'default',
            'handler_settings' => [
                'auto_create' => true,
            ],
        ])
        ->setDisplayOptions('form', array(
            'weight' => $weight,
        ));
    ;

target_entity is just a simple bundleless entity.

This creates an entity reference auto-complete field in forms, but if I type something that doesn't match any existing entities, Drupal will say that no matching entities found and will refuse to create a new one.

How do I make the auto_create setting work?


texts: Drupal CKeditor changed inline Image dialog

texts:
Building a new site with Drupal 7.26 and the latest CKeditor library 4.3.2 (and CKEditor Module).
In the latest CKeditor Program the Image properties dialog has changed!

On CKeditor 4.0 the dialog looks like:

On the CKeditor 4.3.2 the dialog looks like:

How can I get the "Link" and "Advanced"  tabs back in 4.3.2 ???


texts: drupal 7 + services 3 - inserting nodes with select fields

texts:
I'm using Drupal 7 + Services 3 to create nodes with POST and JSON. Everything works fine, except field types of select - entity reference select or plain text.

The entity reference uses the autocomplete widget, while the text select is a plain radio button.

This is the format I'm using:

"field_urgency": {
    "und": [  {  "value": 1    }   ]
}


texts: Which event should we subscribe to if we want code to be triggered when a new user registers?

texts:
I noticed that account.set is the event invoked for a user account.
I want to create an event subscriber which adds a callback invoked when a new user registers on the site. I am not sure whether account.set is the correct event.
Are there other better events for this?


texts: Drupal.behavior unexpectedly triggered by Ajax callback

texts:
I work on a sandbox project which provides a Responsive Tabs to Accordion Panel style. Everything works fine except that once the page loaded, any Ajax callback (i.e add to cart or colorbox) seems to trigger the js function of my module.

The way js function is set in plugins/styles/reponsive_tabs.inc

function theme_responsive_tabstoaccordion_panels_style_render_region($vars) {
  //...
  $element = array(
    //...
    '#attached' => array(
      'js' => array(
        drupal_get_path('module', 'responsive_tabstoaccordion_panels') . '/plugins/styles/responsive_tabstoaccordion_panels.js' => array('type' => 'file'),
      ),
      //...
    ),
  );
  //set the wrapper id to give to responsive_tabstoaccordion_panels.js
  drupal_add_js(array('responsive_tabstoaccordion_panels' => array('tabstoaccordion_panel' => '#'.$tab_id)), array('type' => 'setting'));

Drupal behavior in responsive_tabstoaccordion_panels.js

(function ($) {
  $.fn.extend({
    easyResponsiveTabs: function (options) {
      //the main js function which is triggered
      //...
    });

    Drupal.behaviors.responsive_tabstoaccordion_panels = {
      attach: function (context, settings) {
        $(settings.responsive_tabstoaccordion_panels.tabstoaccordion_panel).easyResponsiveTabs({
          //Set options
          type: 'default',
          //...
        });
      }
    };
})(jQuery);

I guess it has to see with the way I attach my function to Drupal.behaviors ?


texts: How to redirecting add to cart form in drupal commerce programatically?

texts:
I just wants to redirect the add to cart form to a different page. After click on add to cart button i do not wants to go cart page. i just want to go thank you page.

for that i am altering the form

 if($form_id == 'commerce_cart_add_to_cart_form_1'){
            $form['submit']['#value'] = t("Submit Event");
            $form['#submit'][]= 'post_event_save';
    }

by using the above code i am able to redirect to post event save page but it will not stop in that page again redirect cart page after executing this post_event_save function.

what i have tried post_event_save function

drupal_goto();
$form_state['redirect'] = false;
$form_state['rebuild'] = TRUE;

by printing the form_state variable

[#validate] => Array
                (
                    [0] => commerce_cart_add_to_cart_form_validate
                    [1] => tasteusa_commerce_add_to_cart_form_validate
                )

            [#submit] => Array
                (
                    [0] => commerce_cart_add_to_cart_form_submit
                    [1] => post_event_save
                )

            [#after_build] => Array
                (
                    [0] => commerce_cart_add_to_cart_form_after_build
                    [1] => context_form_alter_node_after_build
                    [2] => test_commerce_after_build
                )


texts: How do I redirect after saving the user account with $user->save()?

texts:
How can I redirect users in a custom module after saving a user account with $user->save()? It always goes to the user profile after saving and I want to redirect to a custom page.

function user_update_redirect(&$form, $form_state) {
  $value1 = $form_state->getValue('panel');
  $value2 = $form_state->getValue('type_of_user');
  $storage = \Drupal::service('entity_type.manager')->getStorage('taxonomy_term');
  $user = \Drupal::currentUser();
  $user = user_load($user->id());
  $user->set('field_panel', $value1);
  $user->set('field_type_of_user', $value2);
  kint($user);
  $user->save();
}


texts: Is it possible to group taxonomy list items by content type?

texts:
I'm working on a website which uses a single vocabulary for three different content types. I'm looking for a way to group list items by content type.
To illustrate, I got three content types:

Manual
News
Blog

And I got lots of vocabulary terms which might be used by all three content types:

Rabbits
Cats
Dogs
Frogs

When I select a vocabulary term it will show all the relevant content, sorted by the publication date, like so:
Rabbits

Rabbit escaped from show-ground
Feeding your rabbit
Why do rabbits have such big ears?

However, I'd like to group the items by content type:
Rabbits
Manual

Feeding your rabbit

News

Rabbit escaped from show-ground

Blog

Why do rabbits have such big ears?

I've tried the default 'Taxonomy term' view but found it wouldn't quite work because it affect other vocabularies as well. I also tried the Taxonomy Display module but didn't really understand how it works (I got some configuration options but no view I could change).
Is there a function that could check the vocabulary and the list items' content types and then group them by content type?


texts: How to use AJAX for an exposed filter form of a Views block?

texts:
I have a View, in a block, assigned to a region. I have enabled Ajax for the view.  Pagination works with Ajax. Exposed filters do not. Exposed filters "submit".

I am definitely willing to cut corners at this point, so if there's a method that can be done with a simple JS function I will do that.

I believe that the problem is related to using the exposed form as a block. When "exposed form in block" is set to "no" ajax filtering does work.

update/solved:
I disable "exposed form in block" which I was using to change the position the filters. I then edited the view's template to get the position where I wanted it. so this is "solved" but I am not sure why it didn't work before.


texts: Add conditional stylesheet CSS for internet explorer only

texts:
The following methods can be used to add CSS for specific versions of IE:

Paste the code into html.tpl.php:

<!--[if lt IE 9]><link type="text/css" rel="stylesheet" src="/sites/all/themes/mytheme/less/ie.css"><![endif]-->
Make use of the plugin Conditional Styles
Use drupal_add_css() function

I have always used option #1 above, and adding yet another plugin for something so simple seemed crazy. BUT working with LESS and calling in statically means the file does not get processed by the LESS pre-processor, so the question:

How do you include a stylesheet using drupal_add_css() for specific versions of IE?


texts: Taxonomy view : add token term_name in url

texts:
I have a view overriding taxonomy term pages with the help of Panels. I defined that pattern in URL aliases : destinations/[term:parents]/[term:name].

Now I'd like to set a clone of that view, slightly different in its filters, with the same panelizer variant (or a variant clone), following URL pattern :destinations/[term:parents]/[term:name]/foo where foo is a fixed word.

How could I do that please ?


texts: How to show dynamic text on node/add form with Panels (using AJAX)?

texts:
I am using Panels. There is an entity reference field (project) on a content type. It shows the title of nodes where the user is the creator using the viewreference module.

On the node/add form, is there a way to show a field (body) from the node when the user selects a specific project? I am ok with contexts in panels and views, some some general thoughts might help already quite a lot.

Thanks for any tipps.


texts: Pass variable to form-element twig file on contact form only

texts:
I want to pass a variable to the form element twig file only when the contact form is viewed.
However the approach below does not work. The variable isn't available in the template file.

function module_test_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
    // Determine Contact Form
    if($form_id === "contact_message_feedback_form")
    {
        $form['actions']['preview']['#access'] = FALSE; // Disable Preview Button
        $form['is_contact_form'] = TRUE;
    }
}


texts: Pagers of two different contents are conflicting

texts:
There are two contents in my website, say CA and CB, I created a view for each one and it displays 10 items and for the rest of the items pager is used. CA is in the sidebar first region and CB is the main content which lists some thing. the Use AJAX:Yes configuration is used for CA and Use AJAX:No for CB is used. the problem is when the next link in CB pager is clicked and the page goes to www.example.com/content?pager=2 both CA and CB are going to the second page of the 10 contents. why they are conflicting and how do I can solve this problem?

thanks


texts: Redirect if nothing is select in the View's jump menu

texts:
In D7, I have a view that produces a jump menu. As a default label for the jump menu I display "Please select category".

At the moment if I click submit while  "Please select category" is selected, it just reloads the page. I want to be able to redirect to another page instead (only if nothing has been select in the drop down). How do I do it?

Thank you


texts:
function send_xml_form_user_profile_form_alter(&$form, &$form_state){
    $form["#submit"][] = 'send_xml_edit_account_submit_function';
    drupal_set_message('
' . print_r($form['#submit'], TRUE) . '
');
}

function send_xml_edit_account_submit_function($form, &$form_state) {
    drupal_set_message(t("ahoy"));
}

the modules name is send_xml.module.

this code drupal_set_message('
' . print_r($form['#submit'], TRUE) . '
'); displays

Array
(
     [0] => user_profile_form_submit
     [1] => send_xml_edit_account_submit_function
)

but this code drupal_set_message(t("ahoy")); isnt displaying...

anyone ring a bell?

it's quite annoying to have problems which you cant find the reason why... does anyone experience this before? if yes, would please so kind to share your solutions to me. thank you very much! :)


texts: Bitnami Installation forcing me to flush caches while theming

texts:
I recently set up a Drupal 7 installation on an AWS ec2 instance with Bitnami.

When I'm theming, or editing any kinds of files in the sites directory a regular browser refresh won't show the changes, I need to hit Flush all caches > Css and Javascript to view the changes.

I've disabled caching in Development > Performance, and I don't have Advanced Agregation installed or anything.

Is there something to the Bitnami installation, or ec2 that could be caching the theme files?


texts: How to re-upload an image but not removing it

texts: I have an image field which has 1 value limited. I need to change the uploading photos frequently, and I hope the old images will not be removed. Is it possible to achieve this?


texts: Disable language prefix for non-default languages

texts:
I'm migrating a plain multilanguage HTML site to Drupal 7. One of the requirements of the migration is to preserve the current URLs of each page. Right now, the site has three languages and has URLs like these:
www.example.com/files/content1/es.html
www.example.com/files/content1/en.html

I've Internationalization and Pathauto modules enabled, and set the pattern for the node alias like this:
files/[node:title]/[node:language].html

However, the i18n module adds a prefix to the URL, like this:
www.example.com/es/files/content1/es.html
www.example.com/en/files/content1/en.html

In Language options, in Detection, I've enabled URL.
I've been able to remove the prefix for the default language, but I'm unable to remove it for the other languages. So, in the end, I have URLs like these:
www.example.com/files/content1/es.html
www.example.com/en/files/content1/en.html

How can I remove the prefix for the other languages too?

Thank you in advance!


texts: Certain CSS Not Loading In IE7 And IE8 When CSS Is Aggregated and Compressed

texts:
When enabling "Aggregate and compress CSS files" on Drupal 7.15, a few styles don't seem to load in IE7 and IE8. Two issues involve CSS3 Pie not working, and one involves regular styling. Because of this I don't think its a CSS3 Pie issue.

When I inspect one of the elements that is supposed to have a drop shadow, I can see the line Behavior: url(../sites/all/themes/revo/PIE.htc); is there. However it's not taking affect.

Any help would be greatly appreciated!

I am not using more than 31 style sheets
I have tried the following in the settings.php file

$conf['css_gzip_compression'] = FALSE;
$conf['js_gzip_compression'] = FALSE;


texts: How can I output aliases in a print function, so I can render links using aliases instead of nid?

texts:
I have a theme using a views tpl file that is making it impossible for a View to link to node content using the node’s aliases' that i’ve set up. For example it is linking to the default node/36 instead of projects/projectname.

the view contains a grid of ‘thumbnail like content’ wherein each image links to it’s corresponding node. the views template file is renderering links as shown below:

<a style=" background-image: url('<?php print $thumbnail;?>'); "
class="w-inline-block portfolio-photo portfolio-1"
href="<?php print drupal_get_path_alias('node/').$row->nid;?>">

It’s hardcoding /node/ as a directory and use the function $row->nid

Is there an alias equivalent to nid? Instead of node/36 it the url should be project/projectname

To rewrite the above code using pseudo code it would be…

<a style=" background-image: url('<?php print $thumbnail;?>');"
class="w-inline-block portfolio-photo portfolio-1"
href="<?php print drupal_get_path_alias(‘projects/‘).$row->alias;?>”>


texts:
I have an exposed sort on my view by "has taxonomy term with depth".  I want it to default to "Any " but it keeps on defaulting to one of the choices.  Is there a way to make it default to Any? I dont see the option for the default choice.
thanks.


texts:
Possible Duplicate:
  Drupal search - 2 search pages using their own settings

I would like to have 2 pages: - http://domain.com/search-1 - http://domain.com/search-2

Where search-1 is limited to results of contenttype blog and search-2 is limited to results of contenttype news.

I've been looking for contrib modules but cannot find anything. Please help me out, thanks.

Cheers, Wietse


texts: Using Drush on a Drupal 8 site installed via Composer

texts:
I had a Drupal 8 project installed from Drupal 8 sources what had been downloaded from Drupal 8 site. Recently I heard a good thought that it would be more comfortable to have the project originally installed via Composer. I did the migration and now the project has a structure likewise installed via Composer. That is, it has the "web" subdirectory with Drupal 8 files, the "vendor" directory isn't included in Drupal files and so on.

The site worked successfully after migration.

However, I ran into a problem. Namely, after migration, I couldn't use Drush on the project. The following error appeared upon trying to execute a command "drush cr".

Command cache-rebuild needs a higher bootstrap level to run - you will need to invoke drush from a     [error]

more functional Drupal environment to run this command.
Command cache-rebuild requires Drupal core version 8+ to run.

My colleagues advised me to install Drush-launcher from GitHub as a shell for original Drush. I did it, this problem seemingly disappeared. But I ran into a next one. Namely, Now I can't use Drush for projects made on Drupal 7.

Could you clarify me, is it possible to set up original Drush for sites installed via Composer and without using the Drupal launcher?


texts: Is it possible to request multiple nodes in one request using Services?

texts: I would like to be able to make one request to the Services module node resource and have it return more than one node in the response. Is this possible?


texts:
I want to show main menu links in the sidebar. I have placed that menu block in sidebar region from admin side.

But based on the current URL, i need to display that particular menu item.

Item1 (item1)
  Item1_Sub1_item1 (item1/sublev1)
     Item1_Sub1_Sub2_item1 (item1/sublev1/subsublev1)
     Item1_Sub1_Sub2_item2 (item1/sublev1/subsublev2)
  Item1_Sub1_item2
     Item1_Sub1_Sub2_item1
     Item1_Sub1_Sub2_item2
Item 2
  Item2_Sub1_item1
     Item2_Sub1_Sub2_item1
     Item2_Sub1_Sub2_item2
  Item2_Sub1_item2
     Item2_Sub1_Sub2_item1
     Item2_Sub1_Sub2_item2

If the current url is / (home), then my menu should diplay all menu item
If the current URL (item1/sublev1) match to menu item (Item1_Sub1_item1) then only the parent and child of that menu should be displayed as below

Item1 (item1)
  Item1_Sub1_item1 (item1/sublev1)
     Item1_Sub1_Sub2_item1 (item1/sublev1/subsublev1)
     Item1_Sub1_Sub2_item2 (item1/sublev1/subsublev2)

If the current URL (item1/sublev1/subsublev1) match to menu item (Item1_Sub1_Sub2_item1) then only the parent and child of that menu should be displayed as below

Item1_Sub1_item1 (item1/sublev1)
  Item1_Sub1_Sub2_item1 (item1/sublev1/subsublev1)

I have overridden the menu--main.html.twig file using theme suggestion and using menu--main-sidebar.html.twig file to design the menu.

Any idea how to achieve this? My guess is,

I need to create a block programmatically to do all these operations
Display that block in my html.twig.file

If I am right, how to do that in theme? If i am wrong, what else need to do?

For info I am already using Menu_block module, but I can't place block for each URL. So i want to program it.


texts: Preprocess SCSS with Zen Theme on MS Server

texts:
I'm getting familiar with the official documentation of Zen Theme on Drupal 7. I'm wondering about the SASS- and SCSS-Files. The CSS-Interpreter can't understand these files ofcourse. I read about gulp.js which is the preproccessor for SCSS-Files. I also read about the server nodejs - what I used years before - that gulp.js needs for action. I read it here: getting started SASS and Compass

Can someone explain me, how dose MS Server with no Drush works to handle SCSS with gulp.js-File - what is not been found in the Zen Theme-Folder by me - to preprocess clean CSS-Files?


texts: How do I get the route name of a view page?

texts: In my custom submit handler I want to redirect to a view page Url, let's suppose my view name is team and its path is /admin/team, I find out I should  use $from_state->setRedirect('route'); but when I tried $from_state->setRedirect('/admin/team'); Faced with error, How can I get view route name in?


texts: When I create a link in a menu containing localhost it doesn't naturally work from outside. When I create a link with my public IP address it doesn't work from inside. Can I use some Drupal variables for this purpose containing the site name?


texts:
I have to add some data to body of my content type, how do I add it in hook_node_save. I tried adding it like shown below but it's not getting saved.

function mymodule_node_save($node) {
$node->body = 'test string';
}

Also when I do dsm($node) in the above function, the $node->body doesn't contain the string I added.


texts:
I am trying to send pdf through using mime mail module + mailsystem module + smtp authentication module

function send_mail(){
$to='xx@gmail.com'; $subject='xxxx'; $message='aaaaa';
$from='x123@gmail.com';
$my_mail_token = microtime();
$message = array(
'id' => $my_module . '_' . $my_mail_token,
'to' => $to,
'subject' => $subject,
'body' => array($message),
'headers' => array(
'From' => $from,
'Sender' => $from,
'Return-Path' => $from,
'Content-type' => 'text/html; charset=UTF-8',
 ),
);
 $attached=$message['params']['attachments'][]  = array(
'filename' => $filename,
'path' =>DRUPAL_ROOT.'sites/default/files/pdf'.'/'.$uid.'/'.$filename,
'filecontent' => file_get_contents('sites/default/files/pdf'.'/'.$uid.'/'.$filename),
'mime' => 'application/pdf',
'Content-type' => 'application/octet-stream',
'encoding' => 'base64',
'disposition' => 'attachment',
'list' => TRUE
);
$system = drupal_mail_system($my_module, $my_mail_token);
//unlink('sites/default/files/pdf'.'/'.$uid.'/'.$filename);
$message = $system->format($message);
if ($system->mail($message)) {
return TRUE;
}
else {
return FALSE;
    }
}

This is the code its sending two files as mail attachments instead of one. Why its doing that i cant understand. Looking for help.


texts: Sending email only to active (unblocked) users of the site

texts:
How can I send email and notifications to the active (unlocked) users of the site? What modules do I need for that? Could you explain it clearly?

Already I'm using messaging, notifications and the Mass contact module.
If I send mail through the Mass contact module, the blocked users also receive mails.


texts: Prevent Anonymous users info to be displayed in my views

texts: I am making a list of users for views categorised in my table, however, there are users that are "Anonymous" and i dont want them to show up in the table. Is there any way of fixing it?


texts: Retrieve / call facet blocks from non search page

texts:
I am trying to load full facet blocks on non search page to put them in cache.

What I am doing is looping through items with taxonomy $tid, then

$params = array('fq' => 'tid:' . $tid);
$current_query = apachesolr_drupal_query('apachesolr', $params, '', 'search/site');
$response = apachesolr_do_query($current_query);
$facet_block = module_invoke('facetapi', 'block_view', $block_id);

When I dsm $response->request, on each iteration I always see the first $tid in the query string ("q.alt=tid..."). The result I get is the same block for every terms, on each apachesolr_do_query requests.

Anyone got a clue on what is going on there ? The purpose of this is to generate cached facet blocks from non search pages, for several tid as the apache solr search parameter.


texts: How to use select2 in form API drupal 7?

texts:
Hei please help me using select2 in drupal 7
I'trying to make custom module and form type is select using form API drupal 7

can anyone give an example using select2 module in custom form API


texts:
Is there any object oriented Drupal way to add a base field definition to an existing entity?
Of course I am familiar with hook_entity_base_field_info(), but I am trying to keep my .module file size to a minimum and I was wondering if there is a way to achieve that with a different approach.
I thought of decorating or extending the entity, but after some research, I stumbled upon these issues that suggest those two options aren't yet possible or elegant, as far as I understand.

Allow entities to be subclassed using "bundle classes"
Create a generic way to decorate Entity classes

Am I wrong in that?
Is there anyone that has had the same case and found a different approach?
Edit:
TL;DR answer is that trying to replace this specific hook, will cause more confusion, rather than improve code clarity.


texts: Productivity tool to help me add multiple fields at once

texts: Is there any Drupal productivity tool that will help me create multiple fields at the same time? I'm taking about about the actual creation of the fields under /admin/structure/types/manage/node_type/fields. I have a hundred of fields to create and it seems tedious to keep hitting the save button every time I create one.


texts:
When adding content I entered a date which is February 2013 within a Date field type but it is displayed as raw data such as 2013-02-01T00:00:00 for the token that is listed as [node:field_fact_sheet_date].

If I instead change the token to [node:field_fact_sheet_date:custom:F Y] or                                                     [node:field_fact_sheet_date:custom:F,Y] then nothing is listed.
However it is working when I use [current-date:custom:F Y] and displayed correctly as August 2013.  How do I get the token for a date field type to display as a custom format?


texts:
How can I add page templates for different Languages in my Drupal 6?

For example, if I want to make different page template for Bulgarian language, page-bg.tpl.php doesn't work.


texts: Does anyone know how to use the Ubercart UC VAT module?

texts:
I have to implement different VAT for different products (regardless of the category). Some products can have 19%, some 4%, some 6%, and some they don't have a VAT rate at all.

So far I couldn't even specify a global 19% vat.

I don't understand how this is handled. I've searched for documentation but it's almost nonexistent.


texts: Module hook to add_js to any entity type?

texts:
I want a hook that will let me conditionally add js/css to the page depending on the type of entity.

Since I am putting this in a module I cannot use a theme hook (because if the theme already defines the hook then Drupal will crash).

Ultimately, I want to do something like:

// SWTICH BY ENTITY TYPE
switch($entity_type){
    case 'eform':  // entity forms
        drupal_add_js( $theme_path . '/scripts/ajax_forms.js');
        break;
    case 'view':  // view pages (making this one up)
        drupal_add_js( $theme_path . '/scripts/fancybox.js');
        break;
}
// SWTICH BY CONTENT TYPE
switch($content_type){
    case 'services':
        drupal_add_js( $theme_path . '/scripts/fancybox.js');
        break;
}
// SWITCH BY NID
switch($nid){
    case '293': // Homepage
        drupal_add_js( $theme_path . '/js/global.js');
        break;
}

Right now I'm using hook_node_view to check content type & nid.  Works great for nodes, but doesn't help me with non-nodes.


texts:
I have an entity "metric" that has specified the following admin ui config:

'uri callback' => 'metric_entity_uri',
    'admin ui' => array(
        'path' => 'node/%/config',
        'controller class' => 'MetricEntityUIController',
 ),

Now I'm trying to add that node/%/config link as a tab on my node pages next to "View" and "Edit" via hook_menu:

$items['node/%node/config'] = array(
    'title' => 'Admin UI',
    'page callback' => 'metric_entity_uri',
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
);

Unfortunately this doesn't work, I guess because the path is already taken, it works if I take another path/callback thats not used yet. What do I have to change to get my link working?


texts:
We are using the drupal_http_request function to send some data to salesforce. We've been told that one of the fields is being cut off and that they are receiving incomplete data. When I examine the response object (via a debugger), I'm seeing all the data that was sent out. Am I correct in my assumption that none of the data is being truncated on the Drupal side of things?

  //I see all the data here that was sent out.
  list($response, $result->data) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
  $response = preg_split("/\r\n|\n|\r/", $response);

We are using the Rules HTTP Client. The request object data is being set in a rule:

orgid=00ZZ00000zzzzz
retURL=http://example.com
recordType=012U00000001eYn
Sender_IP__c=[entityform:field_salesforce_context]
email=[entityform:field-email]
name=[entityform:field-contact-form-first-name] [entityform:field-contact-form-last-name]
description=[entityform:field_please_provide_as_much_det]
00NU000000zzzzzz=[entityform:field_category]
external=1

The actual code that calles drupal_http_request is this:

 $data = str_replace("\r\n", '&', $data);
 $data = explode('&', $data);
 foreach ($data as &$item) {
    list($name, $value) = explode('=', $item, 2);
    $value = urlencode($value);
    $item = "{$name}={$value}";
 }
 $options['data'] = implode('&', $data);

 // Max redirects.
 $options['max_redirects'] = empty($max_redirects) ? 3 : $max_redirects;

 // Timeout.
 $options['timeout'] = empty($timeout) ? 30 : $timeout;

 // HERE
 $response = drupal_http_request($url, $options);
 if (isset($response->error)) {
    return;
 }
 else {
    return array('http_response' => $response->data);
 }

When I set a breakpoint here and step through the code all the data is present. The response object looks good:

data:
"

http://example.com">

if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('someURL'); }  else if (window.location.replace){ window.location.replace('someURL');} else {;window.location.href ='someURL';} �
�"

code:   200

protocol:  "HTTP/1.1"

status:  "OK"

request:

"POST /servlet/servlet.WebToCase?encoding=UTF-8 HTTP/1.0
Content-Type: application/x-www-form-urlencoded
User-Agent: Drupal (+http://drupal.org/)
Host: gsa-peo.my.salesforce.com
Content-Length: 1536
orgid=00ZZ00000zzzzz&retURL=http%3A%2F%example.com&recordType=012U00000001eYn&Sender_IP__c=127.0.0.1&email=bsmith%40example.com&name=Bob+Smith&description=Sed+ligula+ipsum%2C+scelerisque+vel+fermentum+id%2C+aliquam+ac+risus.+Ut+sed+euismod+lectus%2C+non+congue+massa.+Nam+est+nisi%3B+laoreet+in+vulputate+eget%2C+porta+nec+eros%21+Nulla+non+aliquam+leo%2C+et+ornare+ligula.+Morbi+egestas+augue+a+purus+suscipit+placerat.+Proin+cursus+iaculis+risus%2C+id+ultricies+nullam.&Sed ligula ipsum, scelerisque vel fermentum id, aliquam ac risus. Ut sed euismod lectus, non congue massa. Nam est nisi; laoreet in vulputate eget, porta nec eros! Nulla non aliquam leo, et ornare ligula. Morbi egestas augue a purus suscipit placerat. Proin cursus iaculis risus, id ultricies nullam.=&=&Sed ligula ipsum, scelerisque vel fermentum id, aliquam ac risus. Ut sed euismod lectus, non congue massa. Nam est nisi; laoreet in vulputate eget, porta nec eros! Nulla non aliquam leo, et ornare ligula. Morbi egestas augue a purus suscipit placerat. Proin cursus iaculis risus, id ultricies nullam.=&=&Sed ligula ipsum, scelerisque vel fermentum id, aliquam ac risus. Ut sed euismod lectus, non congue massa. Nam est nisi; laoreet in vulputate eget, porta nec eros! Nulla non aliquam leo, et ornare ligula. Morbi egestas augue a purus suscipit placerat. Proin cursus iaculis risus, id ultricies nullam.&00NU0000004z903=General+information&external=1"

url:
"slaesforce URL"


texts: Deduct 10% transaction fee when user donates userpoints to another user using rules - Drupal 7

texts:
I want to use rules to deduct 10% of the transaction amount from a donor each time he donates userpoints to another user using the userpoints_donate contrib module. Currently there are no rules events or actions from the userpoints_donate contrib module

possible events: user donates points to another user

possible conditions: donation_amount <=> a particular value

possible actions: grant points to donor = (donation_amount * -0.1, i.e grant -10% of donation_amount to donor)

How can i achieve this? Thanks


texts: How to check if a user has any previous order?

texts:
I am working on Drupal Commerce site. Want to know if the customer is new or old. If customer has previously ordered any item from our website we can consider him old customer else if he is ordering first time he will be considered the new customer.

How can I get these values in a custom module?


texts: Associating Multiple Date/Location Pairs to Node

texts:
I'm attempting to create a custom content type in Drupal to represent concerts.  Each concert has a title, description, and multiple dates and locations (the concert may be performed on more than one day at different locations).

Since dates and locations are dependent on each other, I thought that the Field Collection module would be ideal for me.  This module allowed me to group the date and location field and add multiple values; however, when I try to display the concerts in a calendar in Views (I've tried both Calendar and FullCalendar), I can't find a way to display the title of the concert because it is now in a separate entity.

Is there any way I could make my current content type work, or is there a better way to do this?


texts: Custom block for anonymous users is shown to every user

texts:
I have a simple problem that has me stumped. I created a block with custom "login" and "create an account" links, which I only want to display to anonymous users, naturally. I deployed the block using a Glazed Builder drag&drop feature, but it's showing up for all users. I also set the block so that it should not show up on /user/ or /user/* but it is showing up on http://example.com/user and http://example.com/user/login, etc.

I used drush cc all and am using an incognito window in Chrome, but cleared the browser cache anyway.

I'm on Drupal 7.54. I am using Glazed Theme from SooperThemes, which allows us to place blocks using a drag & drop editor. The block is still in the "disabled" list in the block list for some reason.


texts: How do I add multiple custom CSS classes to Views references field?

texts:
As a follow up to this question I need to resolve the same issue for References module, in concrete the views integration.

When defining References Views display, no CSS classes can be added to rows (in difference to other display types like Page or Block).

So I try to output taxonomy tags with custom CSS classes using fields and get this:

Tag1, Tag2, Tag3

Now again I would need to output every taxonomy tag as a separate class. I would need spaces instead of - so the output would be something like that:

Tag1, Tag2, Tag3

I suppose that there is a bug in "references_plugin_style.inc" file from References plugin...


texts:
I know that you can create user programtically and set a role:

 $roles = array(
      DRUPAL_AUTHENTICATED_RID => 'authenticated user',
      4 => 'Member');
$fields = array(
    'name' => $username,
    'mail' => $email,
    'pass' => $password,
    'status' => 1,
    'init' => $email,
    'roles' => $roles,
    );
  //the first parameter is left blank so a new user is created
  $account = user_save('', $fields);

and this code works fine.
However, I am going to be porting this code to different sites (and back to mine, when I need to do testing on my dev site), and I'm trying to figure out if I'm going to have role id conflicts. Instead of using the above code, and I do the following instead?

$roles = array(
      DRUPAL_AUTHENTICATED_RID => 'authenticated user',
      "site-member" => 'Member');

and thereby never having to worry that I am overwriting a role?


texts: Difference between field widget price textfield and price with currency?

texts: What is the difference between the widget field price textfield and price with currency that you can use on the commerce price field?


texts:
I want to accomplish something very similar to how drupal blocks admin works. I have a series of combos which need to be rendered side by side in a tabular fashion (not using CSS).

I have dumped the $form object of the blocks module and i can't quite figure out how they do it??? Any ideas?


texts:
From what I read about Drupal 8 themes there does not appear to be anything to order CSS file loading. As you know, CSS cascades down to a specific order when there is a conflict with an element. Since I have a class that is named the same as Twitter Bootstrap which is loaded from the CDN from the page.html.twig, I can usually modify a bootstrap class by having the CSS file that loads last as that can trump the bootstrap class that loads earlier. I have not discovered how to set an external library like Twitter Bootstrap in the libraries.yml file so it's in my page.html.twig file. So here is my THEME.libraries.yml

global-styling:
  version: 1.x
  css:
    theme:
      css/reset.css: {}
      css/style.css: {}
      css/htme-elements.css: {}
      css/tabs.css: {}
      css/messages.css: {}
      css/block-editing.css: {}
      css/wireframes.css: {}
      bootstrap/bootstrap.css: {}
      bootstrap/bootstrap.min.css: {}
      css/layout.css: {}
      css/default.css: {}

The default.css should load last which has the class I would like to override in bootstrap, but after

drush cache-rebuild

I find that the element is choosing the bootstrap element. OK, let me put the default.css element highest in the stacking order in case Drupal is putting in a different order. But after rebuilding my cache again, I find that bootstrap still "wins."

The closest thing in the Drupal docs was to perhaps add stylesheets-override in my THEME.info.yml

stylesheets-override:
  - system.theme.css

How should I set the order so that I can use the external Bootstrap files and load in my default.css last?


texts: Add JavaScript 'effects' to be used with AJAX form submissions

texts:
Consider the following code:

        $form['actions']['submit']['#ajax'] = array(
            'wrapper' => 'apple-node-form',
            'callback' => 'node_add_callback',
            'method' => 'replace',
            'effect' => 'fade'
        );

This will produce a JavaScript fade animation. But how can I define my own animations? For example, 'effect' => 'myCustomAnimation'.

I'm really just looking for a way to be able to define my own JavaScript function, and have that function handle the AJAX request. I could just call .ajaxComplete() on the document and have a series of switch statements in there that figure out what to do with the response. But that's a bit hacky, and the switch statements (as well as the initial response parsing) would be additional logic. If I can just define right there in the $form array PHP code the JS function to be used, no ugly switch statement would be necessary.


texts: Output the width & height of an image using a particular image style

texts:
In Drupal, you can use the following in a field--field-image.tpl.php file to output an image as a URL using a particular image style:

<?php foreach ($items as $delta => $item): ?>
<?php echo image_style_url('thumbnail', $item['#item']['filename'] ); ?>
<?php endforeach; ?>

This will output all images as a URL with the Thumbnail style.

I would like to get the width and height values of that image (with the thumbnail style). How can I do it?

I would like to do it without having to install any extra modules.


texts: Add element to the beginning of form, via hook_form_alter()

texts:
Using Drupal 7, I'm trying to utilize Drupal Form API in combination with hook_form_alter to place my added inputs at the beginning of the form.

I thought the best way to do this was to create a new form element like so:

$form['program_list'] = array(
    '#type' => 'select',
    '#title' => t('Select a preferred Program'),
    '#options' => $program_list,
    '#weight' => -1,
);

I read the documentation, and it looks like there is a #weight attribute. I tried setting the weight to either 0 and negative integers, but my added inputs are still at the bottom.

I then used var_dump() to check the weights of my Webform-generated inputs. They were as I expected: a 0-based, incremental weight index.

I also tried placing the elements in $newform then  using $form = $newform + $form, but that as well placed my new inputs at the bottom of the form.

What am I doing wrong?


texts: For some reason the pricing attributes don't work but my real question is: How could I get the pricing attribute's form to display in a popup?


texts:
I have simplenews module installed on drupal 7.50

When accessing #overlay=node/add/simplenews

I get a NOT FOUND, so I cannot create any newsletter content. Tried to flush cache but didn't work. Any ideas?


texts: How to keep the size of the database reduced?

texts:
I found out a very simple D7 site with less than 150 nodes had database dumps of 65M (gzipped). Which caused my entire server to become slow during the nightly database dumps.

After some searching I found this useful query:

SELECT TABLE_NAME, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES WHERE table_schema = "DRUPAL_DATABASENAME_GOES_HERE";

With that I immediately found the culprit: the sessions table.

After a TRUNCATE sessions my dump is now <1M (gzipped).

How can I make sure this site's dump doesn't blow up again in the future?
I found periodic purging of watchdog and sessions tables? on drupal.org, but it's from 2007.


texts: How to automatically fill in a form on click?

texts:
I have a very simple form (FormAPI, not Webform) and the behavior when clicking the submit button is to both send an email and insert the form values into the database.

Under this same form, I have a database query which allows me to print a list of all latest form submissions. I'd like to add a "reuse this submission" link next to each form submission and would like this link to fill in the (empty) form fields to easily reuse past submissions, optionally tweak them a bit, and send them again easily.

I'm pretty sure it needs Ajax/Javascript and wonder how complicated it would be to implement this? Maybe alternatives exist and I'd be interested in those options as well to achieve this behavior.

Thanks.


texts: best way to restrict endpoints such as /node or /filter/tips

texts:
I am looking for the best way to restrict access to drupal pages such as /node, /filter/tips and /filter/tips/plain_text etc.

Do I add rewrite rules to the .htaccess file?


texts: How to migrate content using migrate-manifest?

texts:
English is not my native language so please be patient.

I'm totally new to Drupal development so I was learning how to migrate from Drupal7 to Drupal8 due to some work necessities to test a POC, the idea is to migrate the configurations and then import some content in a controlled way. At this moment I had installed the necessary modules on my Drupal 8 site:

Migrate Drupal
Migrate Manifest
Migrate Plus
Migrate Tools

Then as is indicated in Drupal Documentation, imported the configurations using:

drush migrate-upgrade --legacy-db-url=mysql://db7_user:@127.0.0.1:3306/drupal7_site --legacy-root=http://drupal8_site --configure-only

This give a list that I have imported (with some errors due to some custom modules), then I created a manifest file. So in this step I have some doubts, because neither the migrate-upgrade or the migrate:template:list commands give me information about some specific content which I need to migrate. So this brings the question, how to use migrate-manifest module (or others modules if necessary) to migrate content from Drupal 7 to Drupal 8. I really appreciate an answer more detailed than the current documentation.

Some links that I also have reviewed:

https://www.chapterthree.com/blog/drupal-to-drupal-8-via-migrate-api
https://api.drupal.org/api/drupal/core%21modules%21migrate%21migrate.api.php/group/migration/8.2.x
https://www.metaltoad.com/blog/drupal-8-migrations-part-2-migrating-users-drupal-7-site
https://webikon.com/cases/migrating-to-drupal-8


texts: Respecting permissions in getStorage('taxonomy_term')?

texts:
Edit: I just realized that Taxonomy permissions are not native to Drupal core, they are the result of a module we activated: Permissions by Term.
(This will explain why they are not being respected by Drupal). The rest of my question still stands though:

I am able to fetch all the terms in a taxonomy programmatically, by doing the following:

$vid = 'TAXONOMY_NAME';
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, 0, NULL, TRUE);
foreach ($terms as $term) {
   $tid = $term->id();
   $term_name = $term->name;
   //etc.
}

However, I noticed that if I apply "Permissions" to a term, this is not respected. For instance, if a term is limited to "Administrator" only, you will still see it as a "Authenticated User", (non-Administrator).

How can I amend the above code so that it only returns the terms that the logged in user has permissions for?

Edit: I know the answer has to do with using:

$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$access_check_service = \Drupal::service('permissions_by_term.access_check');
$allowed = $access_check_service->isAccessAllowedByDatabase($TERM_ID, $USER_ID, $langcode);

I'm just not sure of the proper implementation...

Many thanks!


texts: How to display multiple loops for same content type?

texts:
I have a content type called "Principle". I have 15 Principles and for front-end reasons I need to display them using 5 loops, each loop should print 3 principles. Each loop will print a row. For that I have created a field called field_row_number.

What's the best way to achieve this? I have tried Views with blocks but that only prints the 15 principles as a list.

I need to be able to add all the CSS classes I need to the HTML. So the generated markup would be something like this:

Principle 3

Principle 4

Principle 5

details for Principle 3 go here

details for Principle 4 go here

details for Principle 5 go here

I need to generate the above structure 5 times using field_row_number.

I'm fairly new to Drupal. Any suggestions?


texts: Problem in understanding how to manage templates

texts:
I'm new to Drupal (and more precisely to version 9), I've been reading resources and tutorials about custom theme creation for 3 days.
I can't figure out how to organize my templates and especially which templates I need to declare.
Let me explain, I have declared two new content types: Webinar and Expert Advice.
For each of these two elements, I want to define a template for :

display the list of these entities
display the details of an entity

1)
This is where I have trouble understanding what I have to declare, I thought I was going to declare:
page--webinar.html.twig and page--expert-advice.html.twig: to display the list of each of these entities
but I realize that I don't know how to manage the display of the details of these entities in another page ? Should I declare a new template like article--webinar.html.twig? Or is it more of a node--webinar.html.twig concept?
2)
How do I indicate which template to use for which type of content?
I discovered a hook:
/**
 * Implements hook_theme_suggestions_page_alter().
 */
function example_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    $suggestions[] = 'page__' . $node->bundle();
  }
}

But I don't think this code automatically allows me to explicitly redirect to a list template or a content detail template
I apologize in advance if these questions may seem basic to you, but they pose a real problem of understanding and I currently do not understand with the resources I have studied for the moment
Thank you very much for your response


texts:
I have a site working on drupal 6 , and i uses drupal's default email function drupal_mail() to send emails , but unfortunately its not sending email and gives me "email not send , please contact site administrator" error , is there any smtp settings i need to include ?

When i tried like follows :

$to = "test@example.com"; // to e-mail address
$from = "test@example.com"; // from e-mail address
$subject = "text to display in e-mail subject"; // subject of e-mail
$body = "text to display in e-mail body";
//params is the array passed to hook_mail function
$params = array(
    'subject' => $subject,
    'body' => $body,
    );

if(drupal_mail('test', 'information', $to, language_default(), $params, $from)){
     echo "mail send successfully";
}

it gives me mail send successfully message but mail is not delivered .


texts: What is good way to hide update.php file?

texts:
I will like to know what is the correct/better way to hide update.php file on the production server.

Currently when you try to access update.php file, Drupal shows default access denied page with info about how to edit settings.php file which I think is bit more revealing than is required.

Any suggestions or best practices ?


texts: How to add description like: "Comments for paragraph 1" to comments

texts:
I have written a module that allows users to put comment on each paragraph. So in comment form there is a field that asks the user which paragraph do they want to put comment on.
I have to mention that I have added a column to my comment table, which saves that paragraph number.

function Annotations_form_comment_form_alter(&$form, &$form_state, $form_id) {
$form['paragraph_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Which paragraph you want to put comment on?'),
    '#required' => TRUE,
    '#size' => 10,
    '#maxlength' => 2,
    '#default_value' => !empty($form['#entity']->paragraph_id) ? $form['#entity']-   >paragraph_id : NULL, // set the default value to the current paragraph value
     '#weight' => $form['subject']['#weight'] + 1, // place after the subject   field by setting the weight to +1 of subject weight
);

$form['#validate'][] = 'annotations_form_comment_form_validate';
$form['#submit'][] = 'annotations_form_comment_form_submit';

 }

I also have Annotations_form_comment_form_validate  and Annotations_form_comment_form_submit functions for validation and submitting.

I have also written the following code to sort the comments based on the number of the paragraph. So first you see the comments on paragraph 1, and then 2, etc.

    <?php

  define('COMMENT_SORT_OLDER_FIRST', 1); // default
  define('COMMENT_SORT_Paragraph', 2);
 /* Alter node type form: allow user to decide comments sorting */
  function Annotations_form_node_type_form_alter(&$form, $form_state) {
  $form['comment']['comment_default_sorting'] = array(
 '#title' => t('Sort'),
 '#type' => 'select',
 '#options' => array(1 => t('Older first'),
                     2 => t('Paragraph Number')),
 '#default_value' => variable_get('comment_default_sorting_' . $form['#node_type']->type, COMMENT_SORT_OLDER_FIRST),
 );
  }

  /* Alter comments query */
 function Annotations_query_comment_filter_alter(QueryAlterableInterface $query){
  if ( ($node = $query->getMetaData('node')) && (get_class($query) == 'PagerDefault')             ) {
  $sort = variable_get('comment_default_sorting_' . $node->type,              COMMENT_SORT_OLDER_FIRST);
    if ($sort == COMMENT_SORT_Paragraph) {
  $orderby =& $query->getOrderBy();
  $expressions =& $query->getExpressions();
  if (isset($orderby['torder'])) {
      unset($expressions['torder']);
      unset($orderby['torder']);
      $orderby['c.paragraph_id'] = 'ASC';
  } else {
    $orderby['c.cid'] = 'DESC';
    }
   }
 }
}

I want to have a line like: " Comments on Paragraph 1 " and then show the comments for paragraph 1, and the same for rest of the comments.

Does anybody know how can I do that  or which hooks I can use? Do you know some other modules or examples that do something similar, so it will give me some idea that how to do it?


texts: How to give space between two blocks in drupal 7?

texts: How to give space in between two blocks in a responsive single page website in drupal 7? Example: we created two blocks about us and ethics in one row through drupal admin .We want to give vertical space between these two blocks!!


texts: Viewing an image file breaks if view mode has responsive image style

texts:
I have an image file that I am viewing programmatically. When I set the image format to "responsive image" in file display settings, it breaks with an error

Error: Call to a member function getMetadata() on null in file_entity_preprocess_responsive_image_formatter() (line 488 of modules/contrib/file_entity/file_entity.module).

My render code:

$file = File::load($fid);
$build = [];
if ($file) {
  $view_builder = \Drupal::entityTypeManager()->getViewBuilder($file->getEntityTypeId());
  $build = $view_builder->view($file, 'embed');
}

"embed" is the file view mode that sets the image to display as responsive.

There seems to be missing the "item" in the build array resulting from this, which is expected to be a fielditem. Am I doing something wrong?


texts: Arranging tab menus created by views module

texts:
I've created 3 different view and added them to a tab menu.

now these 3 menu items are sorted alphabetically and the default tab menu is printed as middle item .

I wanted to sort them using menus but tab items doesn't exist there .

  How can I reorder tab items created by views module?


texts: some css of same file getting processed some not

texts:
In my custom theme I have two stylesheets; style.css and nice-menu-custom.css.

If I would change some silly old css for testing - like body{color:lime;} it would affect the site as normal. However, some other css changes to the same file that get uploaded just simply don't affect the site. None of the width or float properties are working I have the impression.

You would think I'm just not writing proper css, but the thing is if I make the same changes in firebug, it works fine. for instance body{width:50%;} does it's job when using firebug, not when uploading that same code from my stylesheet (i.e. the same stylesheet as from which I upload the changes that DO work) on the server.

I verified if the new changes actually uploaded by trying to upload the changes, shutting down the FTP program and then starting a different ftp program to see if these changes would be stored on the server. And they were.

Made sure:
Caches were cleared often
CSS Compression turned off

So in short: if I go and see in chrome developer tools, to read my stylesheet from the server, under the 'resources' tab -second from left, I can see the changes to my stylesheet that I uploaded and should work. Yet when you look at the site the changes aren't made. Plus if I made the same changes using the developer tools themselves, under the first tab 'elements', the changes would actually take effect. I just don't understand.


texts:
I am new to Drupal and currently working on a theme from scratch. I have been using the tutorial How to create a simple Drupal 7 theme from scratch to help me. I have got most the things working required for the site I am working on apart from the header. I would like to add an image to the header which would be floated to the left of the text.

So far I have tried to create a content type with an image and assign it to the header block I have created. When I tried assigning a content type the header disappeared.

Any suggestions?


texts:
I am trying to run a group of tests(Simpletest) for my custom modules through Jenkins.

Firstly I tried drush test-run (...) which has been removed from drush.
Then I tried php scripts/run-tests.sh --xml logs_tests [GROUP_NAME], but for every test class it returns /usr/bin/daemon: unrecognized option '--url'. I haven't defined any URL, maybe is something Simpletest specific.
Finally, I created a fairly simple Phing task <exec command="php scripts/run-tests.sh --xml logs_tests ${group_name}" error="build_error"/> only to get the response Unknown argument: --url, from Phing this time.


texts: Using Slick Carousel with Views - How to setup a slideshow with View

texts:
I'm trying to setup a slick carousel slideshow. I've created a content type for the images and added a few nodes to the content type with images. I then created a View block...but see no option to format with 'slick carousel'. This article says to choose 'slick carousel' instead of format: unformatted list (but I don't see this option).

The only place I see the ability to choose 'slick carousel' is in the content: image field itself under 'Fields'. But when I choose it there - not surprisingly - it shows no results. If I leave it as the default it shows the images. But, of course, I want not just a block of the images from the nodes but a SLIDESHOW.

Does anyone know how to make this work with Slick Carousel? Thanks.

Note: I have installed the required libraries and the .min.js file


texts: Module to separate the links of menus by language?

texts:
A few days ago I found a module to separate the links of menus by language. Given a localized menu then you get the links separated by languages. Very useful I think.

But now I can't remember its name. Does anyone know it?


texts:
How can I rebuild the node access permissions?

drupal node:access:rebuild returns the following error message.

  [Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "node:access" namespace.

I am using Drupal Console 0.11.3 and Drupal 8.2.0-rc2.


texts: is there a way to generate dummy content for paragraphs?

texts: I am working in Drupal 8. Is there any way, with devel, to generate dummy content for paragraphs to visually get a feel for how things would look? Is there a module or script to accomplish that might work?


texts: How do I modify the _trackPageview output of the Google Analytics Drupal 7 module?

texts:
I am working with the Google Analytics (googleanalytics) module in Drupal 7 and I need to get search categories added to the code. The module itself doesn't seem to offer any hooks in for an operation like this. I am considering trying to go into the storage of drupal_add_js to modify it. But I don't like how hacky that is.

So my next thought is to modify the module. But I would rather not do this to a contrib module. So any thoughts? I have been also wondering if I can push _trackPageview twice to Google on the same page, with the second time being with the search query and category. But I don't know how Google Analytics will work with that option.


texts: What's the easiest method for migrating content from Drupal 7 to another Drupal 7?

texts:
I have two drupal 7 sites and one of them has about 21 content types that does not exists in the other drupal 7 site. It's not a data merge so it's more of a data copy. I know there is the migrate module, but that seems a bit overkill for something like this as I am not merging data into an existing content type. It should just create a new content type on the new site and import all the fresh datas in.

What's the best approach or modules that should be used in this scenario?

I have never used migrate module before, so I'm assuming it's pretty complex as it can deal with many types of data. I remember there was a module which let you copy content from one site into the other.

The only complexity here is that these content types have node references and entity references associated to them. What issues might arise from that?


texts: How to data compare the price or, subtotal in Ubercart flat rate shipping quotes

texts:
Using Drupal 7.43 and Ubercart 7.3.9
I am trying to set up flat rate shipping for two parameters.

For orders with a subtotal above $34.00
For orders with a subtotal below $34.00

Unfortunately, there are no options under data comparison for the Subtotal... Only the Order total.

Or, I would like to create a flat rate shipping rates that vary by price ranges.

For products with a price above $34.00
For products with a price below $34.00

Can't figure that one out either. Any help will be greatly appreciated!


texts:
I need to add a custom filter to the drupal views.i created the view to list some user fields. Drupal view path is like this /user/1/cj. Then i want the details of user with id=1.
How can i give the filter like this


texts: Cannot display a custom user field in php in Drupal 7

texts:
I added an array field with three possible values to the user. It is called field_user_school_category.  I am using Drupal 7.

I want to extract the field value for the current user and use it in a page in an if statement (in php text format). I just can't get the extract code to work. I can't even get the value to print - see code below. What am I doing wrong?!

The field is currently set up to accept multiple values. (I know I need to probably loop through to extract any other values later on). I have also tried using $school['und'][0]['safe_value'] instead of $school[0] amongst a myriad other things.

Any ideas or help would be very gratefully received.

Thanks Sheila

<?php
global $user;
$account = user_load($user>uid);
$school = field_get_items('user', $account, 'field_user_school_category');
$schoolcat = field_view_value('user', $account, 'field_user_school_category', $school[0]);
print $schoolcat;


texts:
How to Add query parameter from url to all links on the page? Basically I want to get the Query parameter from url and then attach that on all the links on the page.
JQuery or PHP, Any solutions?

Please suggest. Thanks in Advance!


texts: Synchronizing Database Configuration Across Environments

texts:
I am the sole developer on a Drupal 7 site, and I need advice. I use Git, having a 'master' branch (the published version of the site) and a 'dev' branch (the experimental features for future versions of the site).

Using Capistrano for deployment, I've gotten it fairly easy to deploy the two branches to their respective URLs, but I'm up against this wall where I'm not sure how to merge the 'dev' branch database into the 'master' branch after the new features are ready for production.

With a lot of Drupal's structure stored in the database, like Content Types and Views, what solutions are there for merging database changes from the 'dev' branch's url to the 'master' branch's url? So far, I've been writing down the changes I make and then recreating them on the production site before I merge the dev branch back into the master branch.


texts: How to specify media formatter on /media/[id] page?

texts:
I have Media 2.x installed and every file (since they're entities) has its own page accessible via /media/[id].

I can't figure out how to set a formatter for displaying the media there. It always renders the original image, or a default image for other media types like PDF or EPS.

For all content types, you can do it via their display settings as well as the file types settings under admin/config/media/file-types respectively, but these have no effect whatsoever on the display on /media/[id] entitiy pages.

Any ideas on how I can achieve this?
(Specifically, I want to use PDFpreview module to display previews of PDF files uploaded as well as display images with an image style and not rendering the original one).


texts: How to make a reset form button without type 'markup'?

texts:
My situation:

I built a form with FAPI. I display the results in a table like this:

function grap_contact_repository_form_submit($form, &$form_state) {
  ...
  $form_state['results_table'] = array('#markup' => grap_contact_repository($matches));
  $form_state['rebuild'] = TRUE;
}

The grap_contact_repository function returns a theme_table.

My problem:

Because of the results_table that already uses a #markup type, I can't build a reset button for my form using '#type' => 'markup' too. (Because all the results table will be clickable too).

I'm looking for an alternative to make this button work. I tried this:

$form['clear'] = array(
  '#type'       => 'button',
  '#value'      => 'Réinitialiser',
  '#attributes' => array('onclick' => 'this.form.reset();'),
);

or this: (http://www.blue-bag.com/blog/drupal-form-api-reset-button)

  $form['reset'] = array(
    '#type' => 'button',
    '#button_type' => 'reset',
    '#value' => 'Réinitialiser',
    '#validate' => array(),
    '#attributes' => array(
      'onclick' => 'this.form.reset(); return false;',
    ),
  );

But it doesn't work. The onclick works if I put another JavaScript like alert. I have nothing in my JS errors console.

Does someone have an idea to make it work?

Thanks a lot :-)


texts: What to do when a module is uninstalled but leaves some features enabled?

texts:
I just disabled and uninstalled a module. Problem is that I still see some features that were created by this module at: "admin/structure/features"

How can I delete these features? I don't see any "features" table in the database.

UPDATE
I think I wasn't clear enough, sorry. It is not a feature module, it is standar module called "md_portfolio". This module creates the features you can see in the capture.

There are not any modules with the names you see in the capture in sites/all/modules

Update2 the features are shown as "enabled" in the capture but NOW they are disabled (I took this capture when I had them enabled)


texts: create node with a field and it updates another field in a view, elsewhere on the site

texts:
(using D7) I'd like a user to be able to create and save a node of a certain content type and have it so the value or setting of one of the fields called "location" will then update the same field (or another field that tells the user the "location") that's part of a view elsewhere in the site? I'll also want to plot the "locations" of things on a map using openlayers later on.
I've looked at rules so far and haven't seen how to do it with rules, but I'm new to rules. And I've seen entity reference, which looks like it takes the place of D6's node reference, but I'm not sure how to use it in this way. So how can I do this?


texts: render fieldsets as vertical tabs - not as form - but as output

texts:
I created an entity. The content is shown in fieldsets like this:

$build['pricing'] = array(
  '#type' => 'vertical_tabs',
);

$build['pricedef_kauf'] = array(
  '#type' => 'fieldset',
  '#title' => t('Price'),
  '#group'=> 'pricing',
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  '#tree' => TRUE,
  '#attributes'=> array('class' => array('vertical-tabs-pane')),
);

But it is not recognized as vertical tab as I hoped. Only the class vertical-tabs-pane is added. The js is not called!?


texts: I am using the Diff (http://drupal.org/project/diff ) module for Revisions. It displays the revisions by date/time. However, the client has asked for incremental version labelling. Can this be achieved in Drupal?


texts: twig debug what does % mean - name of page.twig

texts:
I wonder about the "%". What does that mean?

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'page' -->
<!-- FILE NAME SUGGESTIONS:
  * page--node--31.html.twig
  * page--node--%.html.twig
  * page--node.html.twig
  x page.html.twig
-->

And what names are possible? I need a page for a specific and custom block for viewing the whole content.
I need something like this, but do not know how to do it right.

page--node--[my-custom-block]


texts: Call preprocess_node (or get variables) from Twig template?

texts:
I have the following content types (for a simple LMS) defined:

Lessons, for which there are rather complex rules for handling view access.
Courses, which contain entity references to one or more Lessons.

Now, in the Twig template for rendering a Course node, I am trying to create a "table of contents" (a list of Lessons), using the following snippet:

  {% for key, lesson in content.field_lessons %}
    {% if lesson['#node'].title.value|render|striptags|trim %}

        <a class="list-group-item list-group-item-action
           href="{{ url('<current>') }}/?lesson={{ lesson['#node'].nid.value }}">
          {{ lesson['#node'].title.value }}
          {{ (*****) ? 'LOCKED' }}

    {% endif %}
  {% endfor %}

This works well. However, the problem with this code is the line that I marked with (*****): I would like to do a simple access check, i.e. I would like to check, if the user is allowed to view the Lesson. If not, the label "LOCKED" should be added.

In my implementation of function THEME_preprocess_node I have already defined such a check that is called whenever a Lesson is rendered:

function THEME_preprocess_node(&$variables) {
  ...
  $node = $variables['elements']['#node'];
  $variables['viewaccess'] = $node->access('view');
  ...
}

But can I call the preprocessing function for a Lesson from within the Course template to receive the variable viewaccess?

Another idea would be to modify the above snippet as follows:

  {% for key, lesson in content.field_lessons %}
    {% if lesson['#node'].title.value|render|striptags|trim %}

        {{ bamboo_render_entity('node', lesson['#node'].nid.value, 'toc_entry') }}

    {% endif %}
  {% endfor %}

so, I am now rendering the Lesson using Bamboo Twig and the output ... is fully handled by the Lesson template, which works fine. The problem now is that a Lesson that the user does not have view access for, is not rendered at all.

Now, I'm stuck. Can anybody offer any ideas?

Any help would be much appreciated.


texts: How to flag if a 'webform' exists on a page?

texts:
I an fairly new to Drupal and have a custom module in which I need to write some PHP logic. It needs to insert a flag basically, on any page which contains a 'webform' of any kind.

I see the webform api page, but I don't see anything which would just tell me if a webform is on a page.

I have tried this if statement to insert my little flag - but it is showing on every page.  I assume because drupal calls every page a form?  so technically my code bit is flagging every page?

if (function_exists(form_id)) {
    $variables['s.event4'] = "event4";
  }

Any help?


texts: Putting an image with a space in the filename inside of a Panel

texts:
We have images that are being uploaded with IMCE to our Drupal installation.  Some of these images have a space in the filename.  The ones with spaces in the filename work on normal content pages, but if we try to put them in a Panel (such as in a custom content section), the filename gets truncated up until the first space.

Example: Trying to insert this image inside of a panel:

"/sites/default/files/marketing/Annual%20Pricing%20image.png"

will result in the following code on the site:

Starting at the %20 for the space, the remainder of the filename gets cut off except for the file extension.

For reference, the source code from CKEditor inside of the panel:

Good image:&nbsp;

Bad image:&nbsp;

Is there anything that I can do to prevent this from happening?


texts: I can't get hook_form_alter or hook_form_FORM_ID_alter to add placeholder text to the search input

texts:
I know this has been asked but so far none of the accepted answers for this issue are working for me. I am attempting to add placeholder text to the default search form block. I am using a theme we'll call MyTheme, which is a copy of Bartik and is otherwise working exactly as expected.

I have tried adding the following functions to MyTheme.theme:

function MyTheme_form_search_block_form_alter(&$form, &$form_state, $form_id) {
    $form['edit-keys']['#attributes']['placeholder'][] = t('Search');
}

And

function MyTheme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    if ($form_id == 'search_block_form') {
        // Add placeholder text
        $form['keys']['#attributes']['placeholder'] = t('Search');
    }
}

And many, many variations on those. I have tried both functions with and without "\Drupal\Core|form..." included. I have tried both with 'keys' and 'edit-keys'. I have tried both with and without the empty '[]' after placeholder. Nothing has worked.

In every case, using hook_form_FORM_ID_alter simply fails to do anything at all, while using hook_form_alter causes a 'white screen of death'.

I don't understand what I'm doing wrong.

UPDATE: Now out of the blue Drupal has decided to change the id for the form input to 'edit-keys--2' for some reason. I've tried using that in the functions as well.


texts: What is the picture field in the node object?

texts:
print_r($node) outputs:

stdClass Object
(
    [nid] => 4
    [type] => grouptype
    [language] => fa
    [uid] => 1
    ....
    [title] => sample group
    ....
    [name] => roshd
    [picture] =>
    ....
)

What is picture and how can I upload a picture into this field?


texts: RSS feeds: How to reformat/rewrite/restyle? Using views? e.g. convert youtube text list of videos into thumbnails?

texts:
How can a RSS feed be reformatted/rewritten/restyled to be more useful?

For example Youtube RSS feeds from the video uploads of a youtube user appear as a plain text list by default.

Are there drupal module(s) or a solution out there that parses this content to be able to transform it into something more useful? E.g. in the case of youtube, make it show the list as thumbnail stills of the videos uploaded.


texts: Why does composer-patches not work half of the time?

texts:
I am really trying to leverage Composer for workflow and while it is mostly smooth, a big pain point currently is the patch process.

It seems like half of the time, modules are just deleted, and nothing happens.

Here is some recent output.

I added a patch for search_api_solr, and ran composer update for the module:

➜ cd ..; composer update drupal/search_api_solr
Gathering patches for root package.
Removing package drupal/search_api_solr so that it can be re-installed and re-patched.
Deleting docroot/modules/contrib/search_api_solr - deleted
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files

Uh... it seemed to be aware that there was a patch, but all it did was delete the module and nothing more. I had to follow that with composer require drupal/search_api_solr:1.x-dev to get it back.

Other times, I notice when I am just updating a module to its latest version, it will nuke anything listed in the patch list, and not always download them back.

I really don't understand the rhyme or reason here. What is the proper way to ensure this always works?

composer.json:

   "extra": {
        "patches": {
            "drupal/better_formats": {
                "Settings have no affect on the field if it is in a Paragraph bundle.": "https://www.drupal.org/files/issues/better_formats_paragraphs-2754029-27.patch"
            },
            "drupal/core": {
                "Improve the Views integration for DateRange fields": "https://www.drupal.org/files/issues/improve_the_views-2786577-129.patch"
            },
            "drupal/image_popup": {
                "Image popup sometimes doesn't work for anonymous users.": "https://www.drupal.org/files/issues/image_popup-attach_dialog_library-2894624-2.patch"
            },
            "drupal/paragraphs": {
                "Removed paragraphs are not unpublished.": "https://www.drupal.org/files/issues/removed-paragraphs-are-not-deleted-2741937-25.patch"
            },
            "drupal/search_api_solr": {
                "Removed paragraphs are not unpublished.": "./patches/comment-missing-files-that-breaks-everyones-tests.patch"
            }
        },


texts: Turn off Drupal caching without Access to admin panel

texts:
I'm using Drupal 7 on WAMPP , Windows 7

Background: Drupal on my local box is copy of working project, but this local version I can not login like admin , because it doesn't store session. It doesn't give out any PHP Error.

So I guess I have to turn off cache to find out , is there any PHP Error appearing.

Read that there is such thing as drush , but is it possible to use from Windows ?

But the main question , is how to stop caching on Windows 7 without Admin access !?


texts: Hierarchy between terms from different vocabularies in Drupal 7?

texts:
Is there a way to have a hierarchy of terms by reusing the same terms that reside in different vocabularies? There seem to be so many different options for dealing with taxonomies in Drupal 7 that it feels very daunting to figure out...

For example, let's say I want to make a directory of athletes for different sports. I've created 3 vocabularies, each with several terms:

Vocabulary: Sports
* Soccer
* Basketball
* Baseball

Vocabulary: Divisions
* Division 1
* Division 2

Vocabulary: Teams
* Team 1
* Team 2

Each type of sport will be divided into Divisions and then into different teams per Division.

The hierarchy looks like:

Soccer
* Division 1
    --Team 1
    --Team 2
*Division 2
    --Team 1
    --Team 2

Basketball
*Division 1
    --Team 1
    --Team 2
*Division 2
    --Team 1
... and so on for each sport.

Since the terms for vocabularies Divisions and Teams are always the same, I'm thinking it would make more sense to be able to reuse the same terms under those two vocabularies instead of creating the same terms over and over again for each sport, each division...etc.?

Is that even possible and if so, what would be the best way to go about implementing it?


texts: Taxonomy term view page for  terms with same name but with different term id?

texts:
I have several taxonomy terms that have the same name but different term id in a same hierarchical taxonomy vocabularies. I would like to display them in the same term view page.

Example:

-line-1       (tid=1)
   -station-1 (tid=2)
   -station-2 (tid=3)
   -station-3 (tid=4)
-line-2       (tid=5)
   -station-3 (tid=6)
   -station-4 (tid=7)
   -station-5 (tid=8)

station-3 of line-1 and station-3 of line-1 have the same name "station-3" but they have different term id.

What I would like to do is to have just one term view page with one path that displays nodes tagged with both station-3 of line-1 and station-3 of line-1. but not separate two term pages like /taxonomy/term/4 and /taxonomy/term/6

Is there anyway to do this?
And please feel free to change the title if it is not appropriate.


texts: How can I make my brand new module dependent on a minimal version of Drupal 7 that's required for it to work OK?

texts:
I am developing a brand new module (there isn't any site using it yet). It requires a specific Drupal version, as it uses the hook_taxonomy_term_view() hook that was introduced in Drupal core version 7.17.

I want to avoid my module being enabled on a site using, for example, Drupal 7.16 or any earlier versions of Drupal core. Higher versions of Drupal, above 7.17, should be fine.

My Question: How can I make my module dependent on that Drupal 7.17 version, which is a minimum for my module?

Note: I don't need (have to worry about) a solution for sites where the module is already installed. So there is no need for it to be disabled somehow in such pre-7.17 Drupal versions.


texts: Swap prices in Ubercart based on Attribute price

texts:
I am implementing a down-payment/multi-pay option on a higher-priced product, and I want to offer it as an attribute. Let's say the product costs $1,000... I want to be able to offer it at full price like a normal product, but also offer the customer the ability to only pay $500 at the time of purchase. If they choose that $500 option/attribute, their card will be charged for five additional monthly payments ($100 each plus a service fee amount, via the UC Recurring Payments and Subscriptions module) so that they pay the full amount plus fees over that time period.

By default, the Ubercart product attributes simply add their dollar amount to the dollar amount of the product. How can I use the attribute dollar amount instead of the product's dollar amount when that attribute is selected? One workaround would be to add a "no, I want to pay the entire amount now" attribute and price it with the normal product price, but that would not be ideal.

Thanks!


texts: How to add a menu tab programmatically to a views page?

texts:
I have a view page showing fields of an entity. The pages URL set in Views is

entity/%

Now I would like to add some tabs to this views pages that I can't generate with views it self, but have to do it programmatically. Si I tried:

function MY_MOODULE_menu() {
  $items['entity/%eid/edit'] = array(
    'title' => 'Edit',
    'page callback'   => 'MY_MODULE_entity_edit_callback',
    'access callback' => true,
    'page arguments' => array('eid'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 100,
  );
  return $items;
}

As a menu of the type is MENU_NORMAL_ITEM with the base path entity/% is created by the mentioned view, I thought this should simply work, but it does not: The tab does not show up. (Of course I cleared all caches). Did I got something wrong?


texts: CTools - How to limit the result of ctools_export_load_object()?

texts:
How can I limit the result of ctools_export_load_object? Imagine I have something like this:

$result = ctools_export_load_object('mytable', 'conditions', array('date' => '1337020900'));

Also, What is the difference between ctools_export_load_object() and db_query()?


texts: term field permission for authenticated user

texts:
I have installed the tern_fields module.

I have added a term field to the taxonomy vocabulary. The specification of that field is.

type: File
widget: image

Now when I try to upload an image for a taxonomy term, it works fine for the admin but when I try to upload an image for a taxonomy term as a site manager then it gives me the following error.

The selected file test.jpeg could not be uploaded. Only files with the following extensions are allowed: png|gif|jpg|jpeg.

Where the site manager is a user role.
and in the permissions for the site manager against the term_fields module, both check boxes are checked. administer term_fields and upload term files.

what is the problem now?


texts: How can I create a view that shows image file fields which do not have any data?

texts:
I'm using Drupal 7 and I have a content type, Picture, which includes an image field.  Users use this to add image to the site.

Sometimes, however, there is no data on the server.  For example, if I copy the database from my production to my testing server, the image files will be registered in the db but they don't actually exist on the testing server, so the pictures cannot be displayed.

I would like to create a view that shows these images-- the data is in the DB, but the file does not actually exist.

I created a view for my content type Picture and added the following Filter Criteria

Image: fid- empty
OR File size- empty (Through File Usage: File relationship)

However, this does not show pics that exist in the DB but not in the filesystem.

Is there a way to do this in views, or is there no way to test if the file actually exists?


texts: file_create_url printing different addresses on live and local installations

texts:
I'm using the following code to print out the path of an image uploaded through theme-settings.php:

<img src="<?php print file_create_url(file_build_uri(theme_get_setting('my_setting')); ?>" />

Locally, everything works fine -- the path renders as I expected:

http://localhost/drupal/sites/default/files/image.jpg

When the site is online, however, the same code renders the following address:

http://www.mydomain.com/sites/default/files/public%3A//image.jpg

Does anyone know why public:// would be printed out on a live server but not on a local installation? My guess is that the problem is related to the use of file_build_uri.

I'd like to find some code that prints out the URL correctly on both live and local installs. Perhaps I'm not using the best approach with the API to achieve this end?


texts: Services can not create an user with role

texts:
I follow this answer How to create user with role(s) through REST service?

{"name":"user343","pass":"kes35@r4","mail":"user343@sample.com","status":"1", "roles":["4"]}

But When I check the created user, It role still is '2' (authenticated user)


texts: Display long text fields as type text input not as textarea on node forms

texts:
I have some fields which are configured as long text fields, which I need to display as <input type="text /> instead of <textarea></textarea>.

I'm trying to find the correct naming convention so that I can have some theme overrides in my templates folder.

Is that the correct approach?  Is there documentation about overriding specific field outputs on edit screens?


texts: Drupal alter some javascript of contrib module?

texts:
I am working on a project that implements the Drupalchat module.
Everything works perfectly, but the client requests some custom changes.

They want people to be unable to have private conversations with eachother, but they do need to be able to see eachother!

They can only chat in the public chatroom, that Drupalchat provides by default.

A moderator user (drupal user role) however can chat privately with other users.

Is there a clean way to "hook" into the drupalchat.js file and alter the behaviour for this?

I have found the portion of code that needs to be altered, but of course I don't want to hack the contrib module.

I tried IRC about this, but nobody seemed to have a clue how to implement this.

Anyone done something like this in the past?

Thanks in advance!