texts:
How can I change the date format in my comments?

Right now it looks like this:

  Sat, 09/01/2012 - 12:00

I want it to look like this:

  Saturday, September 1, 2012

I was able to achieve this in page.tpl.php in a section where I just display the date, but have no idea where to do this so it works for my comments too.


texts: Change URL of site, server and folder remains the same

texts:
I want access an old site on a new domain. The server and folder remains the same. I have pointed the new domain to the old Drupal site and updated settings.php to include

$base_url = 'http://www.newurl.com';

I can access the site, but all links in the theme and in the control panel point to http://oldurl.com. I can navigate around the site by manually altering each URL to reflect the new domain.

I'm under the impression that updating base_url should work, and take effect immediately. Have I missed something?


texts: Make a validation form that checks a textbox against a series of passwords in database (like excel)

texts:
Here is the story: I have distributed a series of tickets in real life for my customers that the tickets has a printed number on it. So customers should visit my website in order to enter the numbers of the tickets (as a password) to have access and benefit the promoted content (like polls, galleries and so) of the website.

I have all the ticket numbers stored in an excel file.
I want to know that what is the simplest way to have a form to validate a text box against that excel file? Is there any ready-t-use module for this? Or I should find a programmer to develop some?

I am newbie to Drupal 7 but I am familiar with Content Access, Promoted Content and such modules.
Any suggestions?
Thanks in advance.


texts: Is there any problem with downloading and overwriting modules?

texts:
Theoretically for the most part is it usually a non-issue to overwrite modules ?

Typically i would disable a module then upgrade a module. Is disabling a module superfluous?

Obviously, I'll take the steps to backup my database before doing so.


texts: Pass variables from html preprocess function to page preprocess function?

texts:
In my custom theme's hook_preprocess_page() and hook_preprocess_html() functions, I often need to identify the same information. Rather than essentially running the same if statement checks in both the identify the same info, it would make much more sense to just do it once in both of them and then pass that info to the other preprocess function. How can I do this? I tried the following but it didn't work:

function myTheme_preprocess_page(&$vars){
    $vars['myValue'] = 7;
}

function myTheme_preprocess_html(&$vars){
    //$vars['myValue'] should equal 7...
}

I also tried it the other way around (setting the value in the preprocess html function and then retrieving it in the page preprocess function) but that didn't work either. Which brings up a related question: in what order are these preprocess functions, er, processed? It seems to me that the page preprocess function comes before the html one, is that correct?


texts: Using Entity Registration, how can I create a view that shows all the events that a user has NOT registered for?

texts:
Using the Entity Registration module's built-in Views integration, I was easily able to create a view showing the events that the logged-in user has registered as attending.

Content type: Event
Date field
Registration field

I created a view of registrations with a relationship of registration to node.

Now, however, I would like to create a list of the content type event but only show those events for which the logged-in user has not registered.

I can add a relationship node to registration, but I don't know how to structure the filter to remove the events for which the logged-in user has registered.


texts: How to filter nodes with taxonomy term field in a view embedded on a node?

texts:
I developing a Mp3 store with Ubercart 3. I have created an "Album" content type. I have another content Type called "Song". I want to embed a View within the "Album" node that will retrieve all songs belonging to that album. This is the preview of the "Songs" View http://www.housescent.co.za/files/songz.PNG , which I wish to attach to the "Album" node. Like in this video tutorial at 9:50 http://www.youtube.com/watch?v=0CHC8I9xZIg

Basically I wish to mimic something like iTunes when viewing an album.

P.S. I have installed the EVA: Entity Views Attachment Module and View Field Module but I have never used it. I'm also using Pathauto.


texts: How can I set the value of a taxonomy term reference to multiple terms using PHP?

texts:
This question describes how to set the value of a term reference field using PHP.  But what do I do if I want to set the value of a term reference field in the user profile to multiple terms?

I am trying to set the value to term IDs 27 and 28.  Here is my code so far:

$user->field_yourfield_name[LANGUAGE_NONE][0]['tid'] = 27;
user_save($user);


texts: Content restrictions for logged in user with specific role

texts:
We use a D7 site to market and sell products B2B. We have a special client that only wants to see a small selection of products when logged in. I can of course give them a special role and allow them permission to view content that others cannot see. But when it comes to hiding ALL the other products on the site, I'm not sure how to think... it means giving them more restrictions when logged in with a special user role.

Normally you get more access when logged in and given a special role, compared to not being logged in at all. But in this case I need to do the opposite.

Any ideas?


texts:
I want to be able to save a node when certain events happen in the browser. I.E the user changes tab. Is it possible to save a node in drupal using javascript?

Is there a javascript api tfor drupal? If not are there any contrib modules that add this? If it is custom code is needed is there an web service that can be called or would I need to role my own?


texts: How do I initialise store in-app-purchase?

texts:
I am experimenting with DrupalGap and it's great what it already provides out of the box. One feature that module  is missing is in-app-purchasing (where payments go via Apple).

Cordova provides a great cross-platform plugin with some good documentation.

This is a full example, and this a minimal example.

document.addEventListener('deviceready', initializeStore, false);

function initializeStore() {

// Let's set a pretty high verbosity level, so that we see a lot of stuff
// in the console (reassuring us that something is happening).
store.verbosity = store.INFO;

// We register a dummy product. It's ok, it shouldn't
// prevent the store "ready" event from firing.
store.register({
    id:    "com.example.app.inappid1",
    alias: "100 coins",
    type:  store.CONSUMABLE
});

// When every goes as expected, it's time to celebrate!
// The "ready" event should be welcomed with music and fireworks,
// go ask your boss about it! (just in case)
store.ready(function() {
    console.log("\\o/ STORE READY \\o/");
});

// After we've done our setup, we tell the store to do
// it's first refresh. Nothing will happen if we do not call store.refresh()
store.refresh();
}

How can I add the document.Eventlistener and the initalization function within DrupalGap?

The cordova plugin is installed, the products are set up in iTunes and the provisioning profiles with in-app-purchasing feature are created.
I have created a custom module with a menu link in DrupalGap where the user can make his in-app-purchases.

UPDATE:

This code works (Thanks, Tyler) and connects to the iTunesConnect store and pulls the requested/registered products.

You don't need a sandbox user to pull the products.

You do need to submit Apple the 3 legal documents even if you only use a development provisioning profile. It takes a few hours until the docs are submitted.

Here is another useful link (when your product is invalid): http://troybrant.net/blog/2010/01/invalid-product-ids/

/**
 * Implements hook_deviceready().
 */
function my_module_deviceready() {
// Let's set a pretty high verbosity level, so that we see a lot of stuff in the console (reassuring us that something is happening).
//store.verbosity = store.INFO;
store.verbosity = store.DEBUG; // even higher

// We register/request a product:
store.register({
id: "130points", // this is id of your product in iTunesConnect
alias: "130points_alias",
type: store.CONSUMABLE
});
// When every goes as expected, it's time to celebrate!
// The "ready" event should be welcomed with music and fireworks,
// go ask your boss about it! (just in case)
store.ready(function() {
console.log("\\o/ STORE READY \\o/");
});
// When any product gets updated, refresh the HTML.
store.when("product").updated(function (product_item) {
console.log("product_item: " + JSON.stringify(product_item)); // this is the response from iTunesConnect
});
// After we've done our setup, we tell the store to do it's first refresh. Nothing will happen if we do not call
store.refresh();
return true; // Let DrupalGap know it is OK to continue.
}


texts: Views- Show a table of users with each column indicating whether or not a user has a role

texts:
I am using Views Data Export to get data on my Drupal users into Excel.  My site has a large number of roles (Roles A - Z), and some of these are important for user statistics.

The view I use for data export is a table of fields.  I added Roles as follows:

This gives me something like RoleA, RoleC, RoleD, RoleI for each user.  This sort of data is difficult to manipulate in Excel.

What I would like to do instead is to have a column in the table for each important role that has 1 if the user has the role, or 0 if the user does not have the role.

In other words, my table looks like this now:

But I want it to look like this in Views:


texts: Is there a specific reason that views contextual filters lack the ability to specify the operator?

texts: When working with views filters, the admin can specify if the database query is equal to, contains, starts with, or greater than the value provided. Both the operator and value can be exposed to the user. Contextual filters lack this function, and must be equal to the value provided. Is there a specific reason that this was left out? I have edited the core StringArgument to give it the same operators as the StringFilter. Is there a reason (security, feature overlap) that I shouldn't submit this as a feature addition?


texts: Check if node is flagged after webform submit. Rules

texts:
I have a webform block on a node. I'm trying to send emails to the node (field email) after webform is submitted but only if the current node has been flagged (not the webform). I would presume that rules is the best option for this but cannot get it to work as I cannot access the current node to check?

Emails (webform) should only be sent to the person (node) if they have been verified (flagged).

Any help would be appreciated as I've been stuck for a while now.


texts: How to insert the title of the group in a message?

texts:
I created a custom module using the example in:

https://www.drupal.org/project/message

When a node is created, it is associated with a group:

https://www.drupal.org/project/group

Here is my module. I created in my template a reference field to the group field_group_reference

How to insert the title of the group in the message ?

Thank you

<?php

/**
 * @file
 * Holds hook implementation for the Message Activity Stream module.
 */

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\node\Entity\Node;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
use Drupal\message\Entity\Message;

/**
 * Implements hook_group_insert().
 */
function message_activity_stream_group_insert(Node $node) {
  $message = Message::create(['template' => 'mas_create_node', 'uid' => $node->get('uid')]);
  $message->set('field_group_reference', $node);
  $message->set('field_published', $node->isPublished());
  $message->save();
}


texts: Skip payment method selection in Drupal Commerce

texts:
I have just installed Drupal Commerce Module with Paybox system and i wondering how can i bypass the "payment method selection". In fact there's only one payment method currently, so i'd like to bypass that step and proceed directly from the first step of the checkout to the last checkout step where there is the Paybox Js redirection.

Anyone already doing something similar?

Regards,
Geolim4


texts: How to make a change that affect several site at once?

texts: We have two Drupal 7 and two Drupal 8 website for an airline company. We want the staff at the airport to upload a flight schedule in such a way that it will get displayed in all the four sites at once. How can I achieve this?


texts:
I know there are already several posts about this subject, but I couldn't find a similar problem.
I have several webforms on my site. Each webform has an email action, sending an e-mail to only one recipient. When submitting the form, I get a "Unable to send e-mail. Contact the site administrator if the problem persists." message. However the e-mail is sent without any problem. When looking into the dblog, I see an error:

  Error sending e-mail (from blabla@mydomain.com to )

Note that the e-mail I wrote is not the real one ;-).
So it seems that my site is trying to send an e-mail to an empty recipient (in addition to the correct recipient). If I look into the database, in the "webform_emails" table I see 1 single line for my webform, corresponding to the right recipient. So, why does webform try to send an e-mail to nothing??
Any idea?
Thanks,
Pierre


texts:
I have a entity reference setup in a block that uses the media gallery. I'm trying to get the default image to work which currently if I upload image and it shows but the default image doesn't show if an image isn't uploaded. I'm using the following code in my block twig.
{{ file_url(content.field_page_header_image[0]['#media'].field_media_image.entity.uri.value) }}


texts: Does $form_state['redirect'] require a rebuild?

texts:
I'm working on a multi-step form, and one of the last steps is a confirmation page with a 'Continue' and 'Cancel' button. If they hit cancel, I want it to go to a whole other page.

I have a custom submit handler for the cancel button, but the functionality doesn't appear to be working. I have:

function hook_form_cancel_submit($form, &form_state) {
  drupal_set_message('Cancelled');
  unset($form_state['rebuild']);
  $form_state['redirect'] = array('another/page');
}

I don't want the form to be rebuilt after cancellation, but then I wonder how my redirect would get triggered, since it exists only in $form_state?


texts: node referrer on field collection fields

texts:
I have a field that was showing node referrer well. I added field collection to the field that is being referenced to by the node referrer. Now I cant be able to see the data that was being referred to.
Has anyone experienced this while using node referrer?


texts:
I have written a module with form api which can upload image with dynamic file name. I want to upload that file with auto compression. I cannot understand how will I achieve this. How can I implement this in submit callback.
Below my code:

function MYMODULE_registration_form() {

  $form['name'] = [
    '#title'      => t('Name'),
    '#type'       => 'textfield',
    '#required'   => TRUE,
    '#size'       => 40,
    '#attributes' => ['placeholder' => t('Enter your name'),],
  ];

  $form['personal_info']['upload_pic'] = [
    '#title'       => t('Upload Photo'),
    '#type'        => 'file',
    '#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif, bmp'),
  ];

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

  $form['#attributes']['enctype'] = 'multipart/form-data';

  return $form;
}

function MYMODULE_registration_form_submit($form, $form_state) {

  $name = $form_state['values']['name'];
  $count = 1;
  $original_username = $name;
  while (user_load_by_name($name)) {
    $name = $original_username . $count++;
  }

  $validators = [
    'file_validate_extensions' => ['png gif jpg jpeg bmp'],
  ];

  $uploadCheck = file_save_upload('upload_pic', $validators);

  if ($uploadCheck) {
    $parts = pathinfo($uploadCheck->filename);
    $imagename = str_replace(' ', '_', $original_username . '_' . $count . '.' . $parts['extension']);
    $target = "public://attorneys/" . $imagename;
    file_move($uploadCheck, $target, FILE_EXISTS_REPLACE);
    $picture_fid = $uploadCheck->fid;
  }
}


texts: Form validation after drupal_build_form in hook_node_view

texts:
In hook_node_view of one node I add a node form of a different content type as follows:

global $user;
$node_form = (object) array('uid' => $user->uid,
                            'name' => (isset($user->name) ? $user->name : ''),
                            'type' => 'my_type',
                            'language' => LANGUAGE_NONE
                            );
//create form state
$form_state['build_info']['args'] = array($node_form);

form_load_include($form_state, 'inc', 'node', 'node.pages');
$form = drupal_build_form('my_type_node_form', $form_state);

//change default save button
$form['actions']['submit']['#value'] = t("Nice Save");
$form['#validate'][] = 'my_module_my_validate';

//hide few fields
if(!in_array('administrator', $account -> roles)) {
    $form['field_field_1']['#access'] = FALSE;
    $form['field_field_2']['#access'] = FALSE;
    $form['field_field_3']['#access'] = FALSE;
}

$node -> content['my_form'] = $form;

All of above works great. Form is nicely displayed, fields are hidden, submit button value is changed and additional validation handler seems to be added correctly as debug($form['#validate']) returs:

array (
  0 => 'node_form_validate',
  1 => 'my_module_my_validate',
)

default validation is trigged as one of the fields in embedded form is required and left empty Drupal as expected returns: My required filed field is required. Node is created just fine using this form.

The problem is that for some reason my custom validate handler is not called at all.

/*
 *
 */
function my_module_my_validate($form, &$form_state) {
    debug('test');
    form_set_error('', 'error');
}

Am I missing something? I could potentially use hook_form_alter but I would like to get this working correctly.


texts: Drupal Google Translate Module - Must be represented in the url

texts:
I have a Wordpress site which I'm planning on porting to Drupal to leverage more advanced functionality.

One plugin I use on the Wordpress site is for Google Translate. Most Wordpress plugins don't represent the language in the url (i.e. they use AJAX or Google Translate direct). I use a decent one which specifies the country code in the URL, and that allows me to use http://petfoodratings.org/ko/, or http://www.petfoodratings.org/de/.

Before undertaking a port to Drupal I want to know if any of the Google Translate Drupal modules do this in the same way?


texts: Unable to login into admin after theme change

texts:
I am new to Drupal and to understand the basics I created a new theme in Drupal and enabled it as default. It works fine, however, I am not being able to log in into admin. I reinstalled Drupal and the admin login works fine. When the default theme is enabled it works, but it doesn't work when my custom theme is enabled.
My .info file is -
name = My First Custom Theme
description = A custom them to understand how Drupal works
core = 7.x

stylesheets[all][] = css/style.css

regions[header] = Header
regions[content] = Content
regions[menu] = Menu
regions[left_sidebar] = Left Side Bar
regions[main_content] = Main Content
regions[footer] = Footer

And my tpl.php file is -

    <?php print render($page['header']); ?>

    <?php print render($page['menu']); ?>

            <?php print render($page['left_sidebar']); ?>

            <?php print render($page['main_content']); ?>

    <?php print render($page['footer']); ?>

I tried accessing admin page using following ways but without success -

http://www.mysite.com/user
http://www.mysite.com/?q=user

Any idea where I am going wrong ?


texts:
I made a booking form using Webform. How do I modify the CSS?
Where do I find the CSS file of the webform?

The CSS files in Drupal look nothing like in Vanilla CSS. I'm bit lost there.
I would just like to reduce the width of my rows or change how the date-picker looks like. Or to display my rows in two columns.

I don't want to touch the PHP files too much either, hence why I found the answers about this topic on this forum not satisfying.


texts: Functional test not displaying context aware block

texts:
I have a context aware block I've created.

/**
 * Provide a context aware block.
 *
 * @Block(
 *   id = "my_context_aware_block",
 *   admin_label = @Translation("My context aware block"),
 *   category = @Translation("Display some node information"),
 *   context = {
 *     "node" = @ContextDefinition(
 *       "entity:node",
 *       label = @Translation("Current Node")
 *     )
 *   }
 * )
 */

It references the current node in the build method.

$node = $this->getContextValue('node');

Everything works as expected in my "live" environment. The issue I am encountering is that my functional test is NOT displaying the block when it IS in a context in which it should show. (I haven't bothered testing a context in which the block is not supposed to show.)

  public function testSomeStuff() {
    // Create a piece of content
    $node = $this->drupalCreateNode(array(
      'title' => t('My sample node'),
      'type' => 'a_valid_node_type',
    ));
    $node->save();

    // Place the block in the sidebar
    $this->drupalPlaceBlock('my_context_aware_block');

    $this->drupalGet('node/' . $node->id());

    // Note: Whether I check the page content or the response, I don't see
    //       the block there. I am showing examples of both just for the
    //       sake of providing detail in this question.
    $this->assertContains('force phpunit to fail so that I can manually look at the text content', $this->getTextContent());
    $this->assertSession()->responseContains('some valid markup that appears in the block');
  }

I have even tested setting

protected $profile = 'standard';

and the block still doesn't appear when I'm viewing the node I created [$this->drupalGet('node/' . $node->id());].

This is on Drupal 8.2.5.

I am inside of /drupal/root/directory/core running PHPUnit from the command line as such

sudo -u www-data ../vendor/bin/phpunit ../modules/custom/my_module/tests/src/Functional/MyFunctionalTest.php

Have I discovered a bug or is there something I am missing and doing wrong?

Edit: Here are more details of the complete solution.

First off, you will need to create a user that has administrative rights and log that user in to the site.

$adminUser = $this->drupalCreateUser(array(
  'administer blocks',
  'access administration pages',
));
$this->drupalLogin($adminUser);

Then, instead of using $this->drupalPlaceBlock('my_context_aware_block');, do the following:

// Place the block in the content area
$block_url = 'admin/structure/block/add/my_context_aware_block/classy';
$edit = [
  'region' => 'content',
];
$this->drupalPostForm($block_url, $edit, 'Save block');

Note: My block didn't need any context configuration. If it did, I could have included that with the $edit array.


texts: How to include a custom menu in page.tpl

texts:
I want to code a custom menu straight into page.tpl.php. The default theme uses

<?php if ($main_menu): ?>
  <div id="main-menu" class="navigation">
    <?php print theme('links__system_main_menu', array(
      'links' => $main_menu,
      'attributes' => array(
        'id' => 'main-menu-links',
        'class' => array('links', 'clearfix'),
      ),
      'heading' => array(
        'text' => t('Main menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      ),
    )); ?>
  </div> <!-- /#main-menu -->
<?php endif; ?>

In Drupal 7 I've created a new menu called 'Footer menu'. How do I code that into my theme in the same way as the $main_menu is coded  in the default theme?


texts:
I have a node type with an image field and insert button to get the image into the text field.

Then there is a view that is getting the content of the text field and shortening it to 150 characters. But if there is an inline image at the beginning of the text the view is only showing three points that are linked to the image.

How can I exclude the inline images from views?


texts: CSS class for view display not being applied

texts:
I have a view set up with a block display. Its style is set to HTML list, which it does with no problem. But it doesn't seem to be applying the CSS class listed in the setup. What do I need to do to get this to apply?

Edited to add: Drupal 6, Views2


texts:
Here is the current situation:
i have an artist database and users can 'like' the artist with a flag button and that works great, but i need to use the 'like' data to get some other info

Case:
1. user likes artist(flag!)
2. user logs out
3. user returns to website and logs in and gets redirected to custom page

4. The custom page needs to contain nodes that reffer to the artist.

Its step 4 where i got stuck, i just don't know how to display the information from B to A in a view?

Using Drupal 6 and views 2.

Thanks!


texts:
I wish to enforce a site-wide set of attributes to content produced via CKEditor.

For example, if someone inserts a table, I want the class 'myclass' automatically added as follows:

...

I want to do this for a large number of tags.

I have tried achieving this by modifying twig templates like table.html.twig, however CK editor content does not appear to apply any template, it only renders the entire post with field.html.twig.

What is the best - or generally accepted- way to accomplish this?
I could modify the CKEditor Module directly but that would be modifying core which is not ideal.

This is a drupal 8 site.


texts: How to Insert the contents of a rendered block into the body of a node?

texts:
I need to place blocks inside body text (a youtube gallery plugin).

I’ve installed Insert Block

I’ve successfully applied patch #30

I was able to enable the module but the blocks don’t show up. I guess it is because the module is not actively maintained.

So it is not a good solution for now.

Since I’ve made my youtube playlist gallery based on youtube API, i can display my gallery with some html added to the body where i need to :

lorem

lorem

It works but it is not a very nice solution.

Is there an other way I can explore to do that ? I guess I need to create a custom filter in Drupal 8. Maybe there is an other approach or an other module ?


texts: Search excerpt with Search API (rendered HTML)

texts:
Is it possible to create a search excerpt from the Entity HTML Output (with Search API)?

What I did:

Activated highlighting and "create excerpt" within my Search index. Added "complete entity view" for the whole HTML content:

Activated the new "Entity HTML Output" field als Fulltext:

Within my search view, I added "excerpt" as a field.

But the excerpt does not show for the Entity HTML Output. Is there something wrong with my confi?


texts: How to code a views filter to exclude parents that have children

texts:
I am using the Project Modules.

Some projects have no tasks others can have one or more tasks. In SQL terminology this is a one-to-many relationship, I believe.

I think the generated SQL joins Tasks node type and Projects node type.

I am using grouping so that tasks belonging to the same project are grouped together and projects without tasks are also grouped together. The problem is that projects that have tasks appear twice--in the "header" above the tasks associated with that particular project AND in the list of projects without tasks. I want the project title to appear only in the header above the tasks associated with that particular project.

There is an Entity Reference that links tasks to projects utilizing the field_data_pmtask_pmparent table. I am not using this in my view.

How can I code a filter to omit projects that have tasks from the list of projects that have no tasks?

My View


texts: user_login_block doesn't display message

texts:
I have created an installation profile.
On one page i have added block using user_login_block form.

Now on the page there are other blocks also present.

Now when i submit the form without username and password, it should show me the form error, but it shows this message on next page reload.

I have checked $message variable is printed on the page also.

When i write any wrong password and try to login it will not show wrong username password message at that time, but when i reload the page second time at that time message will appear.

Has anyone faced such kind of situation. ?

Thanks in advance..


texts: Drupal callback :: Less CSS file with variable_get()'s

texts:
I am trying to create a custom module that programmatically creates a LESS file.

I created a menu callback that is a file. Here is hook_menu()...

$items['sites/all/themes/universal/less/dynamic.css.less'] = array(
  'page callback' => 'jobs_universal_lessvars',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK
);

Here is the callback.

function jobs_universal_lessvars(){
  header('Content-type: text/css');
  $output = '
    @color: #4D926F;
    body.notaclass {
      color:@color;
    }
  ';
  print $output;
}

And I call this to add it.

function universal_preprocess_html(&$variables) {
  drupal_add_css(drupal_get_path('theme','universal').'/less/dynamic.css.less');
}

I uploaded a static file to the above ^^ path, disabled the menu callback, and it processed/applied correctly. When I try to run this module, it's not included and I get an error saying

  LESS error: load error: failed to find
  sites/all/themes/universal/less/dynamic.css.less

Before you answer...

I have the LESS module installed
I have the LESS library uploaded correctly
I have tested that I can include a static .less file and have it process
I have tested the menu callback by manually going to the URL
I have tried it with and without calling header('Content-type: text/css');

I get it... it's not a file. But it "is", right? I could just call this function and have it create a new CSS file that's added, but it doesn't fulfil the requirements of the module. Help me? :) Programmatically creating files is very new to me!


texts:
im having problems to modify html of drupal search form. Currently it looks like this:
<form action="/" method="post" id="search-block-form--2" accept-charset="UTF-8">

        Recipe Finder
        <input title="Enter the terms you wish to search for." placeholder="Search" type="text"
               id="edit-search-block-form--4" name="search_block_form" value="Search" size="15" maxlength="128"
               class="form-text">

        <input type="submit" id="edit-submit--3" name="op" value="GO!" class="form-submit">

    <input type="hidden" name="form_build_id" value="form-eHe5OqwUBJ_6iNuySpN1domgBeOYb4utKirLlh58QHY">
    <input type="hidden" name="form_token" value="ADv5U92njeULDgBszbJ6nDHTaGTxTEJMCCL2Qk3SAMk">
    <input type="hidden" name="form_id" value="search_block_form">

and i need something like this:
<form action="/" method="post">

                Recipe finder
                <input type="text" name="search" class="search" id="search">
                <button type="submit">Search</button>

        </form>

So i need to:

Change input to a button

Put that button in same div as input and label
I dont mind having this invisible elements and i know drupal needs them.

I know i need to use hook_form_alter for this but not rly sure how to do it.


texts:
I need a search field to "pop down" under a search icon ({# Search icon #} in sample code) in my template file.

But how do i print the search block directly into a template file?

I want it to be in my menu--main--site-main-menu.html.twig

    {% import _self as menus %}

          {#
            We call a macro which calls itself to render the full tree.
            @see http://twig.sensiolabs.org/doc/tags/macro.html
          #}
          {{ menus.menu_links(items, attributes, 0) }}

          {% macro menu_links(items, attributes, menu_level) %}
          {% import _self as menus %}

          {% if items %}

          {# List #}
          {% if menu_level == 0 %}

    {% else %}

        {% endif %}

        {% for item in items %}
            {% set item_classes = [
            item.in_active_trail ? 'active',
            ] %}

            {# List item #}
            {% if item.below and item.is_expanded %}

            {% else %}

            {% endif %}

            {# Link #}
            {{ link(item.title, item.url) }}

            {# Submenu #}
            {% if item.below %}
                {{ menus.menu_links(item.below, attributes.removeClass('layout-navigation layout--large-screen-only'), menu_level + 1) }}
            {% endif %}

        {% endfor %}

        {# Search icon #}

    {% endif %}

    {% endmacro %}


texts: Is it possible to get Entity Connect and Entity Reference View Widget to work together and if so how?

texts:
It seems to me this should be a fairly common problem, but I can't seem to find and answer despite looking!

Here is my use case: I have two types of content: Activity and Participants. When I create a new Activity I want to be able to add multiple Participants to the Activity, and allow the user either to pick the Participants from a list of those already in the system, or to create new ones "on the fly".

I'm using an "Entity Reference" field in the Activity content type, to reference one or more Participants

So far, I have managed to do one part of my use case, or the other, but not both at once. Entity Connect works fine and creates a modal window in which I can create a new Participant or modify an existing one. Entity Reference View Widget also works fine, and allows me to create a view which I can then use to multi-select existing Participants. But I can't get both to play together (although the Entity Connect project page suggests it should work). Entity Connect only seems to work with the autocomplete widget, whereas Entity Reference View Widget only works with its own widget (logically!).

Has anyone been able to get these two modules to work nicely together and if so how, or should I be using another combination (References Dialog and something else for example)?


texts:
I have created a page called 'Page1' of Content type 'Article' - I have created a  View1 in Views and would like to know how to add that view to my page.

Does Views replace the needs of the 'add content' button on my admin page?


texts: How to import an external database to D8 and create a search form?

texts:
I have a MySQL database with 2000 doctors, which are accessed classicaly through a HTML form and PHP. With the form you can search with criterias like ZIP, town, target group, treatment, languages, etc. Then a result list with doctors is shown and when clicking on one a profile page is opened with all the details of the doctor.

How can I migrate this to Drupal 8? I already read a lot and often Feeds is sugggested, but unfortunately it is not yet ready for Drupal 8.


texts: Cannot configure settings for menu breadcrumbs

texts:
I installed and enabled the Menu Breadcrumb module, however I cannot access or find the configuration settings page (even when I click the configure link on the modules page). I'm currently using the STARTERKIT from Zen theme.

Is there anything else I need to enable to get it to work?


texts: Copying a CiviCRM/Drupal install from one server to another (got error)

texts:
I've tried copying a a CiviCRM/Drupal install from 1 server to another. I copied all the files within the drupal root, and the database, and changed the database details in both Drupal's settings.php file and CiviCRM's civicrm.settings.php file. Drupal now works fine - copying this over appears to have worked, and I've done so succesfully with the same method many times. However, CiviCRM is not fully working. When I visit the main CiviCRM admin page (ie. http://cea-crm.philosofiles.com/civicrm/ on my server) I see CiviCRM's sidebar boxes (indicating it's working to some extent) but, to the right of them, see:

Page not found
The requested page "/civicrm/" could not be found.

When I click on any sidebar box link, such as 'My Contact Dashboard', I likewise see:

Page not found
The requested page "/civicrm/user?reset=1" could not be found.

Presumably I've missed some change I needed to make to reflect my new server setup? I can't see anything in civicrm.settings.php I still need to change, e.g. I've added lines like define( 'CIVICRM_UF_BASEURL'      , 'http://cea-crm.philosofiles.com/' ); and $civicrm_root = '/home/myusername/public_html/d7/sites/cea-crm.philosofiles.com/modules/civicrm';


texts: How can publishers create hierarchical taxonomy terms during node creation?

texts:
I have a chicken and egg problem in terms of allowing users to classify and populate their own sections of the site.

I need users to be able to hierarchically classify their content on the fly. I think this means I can provide them with a term reference field. However, the term reference field only gives a predefined selection. The fully populated taxonomy would need to exist before hand.

I'd like to use taxonomy based URLs to make everything seamless: i.e. /section/subsection/node. I just don't know how to get lay users to easily populate these taxonomies on the fly.

Is there a widget which would allow users to add terms to a term reference field during node creation? AFAIK, only tags can be created on the fly, which doesn't help my URL system.


texts: How to merge posts from 5 different website and import one post to drupal by feeds

texts:
I want to create a music reference website With drupal 7.So explain my diagram and want to help me .

I specified 5 other music website that give direct download link to users.in other 5 sites musics post with a title + description + download links.such as all other websites that post download music or software.
I want to take ONE post Title of these websites + ALL direct links and import to drupal .So for every imported music post I have a Title + 5 download direct link from 5 defferent website.So user can Go to my site and download A music from 5 download link from 5 defferent sites.

1- I can give Titles of new posts from feed (rss) of these sites.

2- How Can I merge 5 titles of these sites to One title (equivalent music titles) - for example titles of one website post is "free download of music from SINGER called SONGNAME" .
This Title take and other 4 sites title merge or ignore Then Download links Attached (link url ONLY) to same Post.

3- I want to import and show only URL of Download links to user.without upload it to drupal or filefield modules.only url.no file.

please Help me.how can I do it?
I Worked with feeds module previously.


texts: What step am I missing installing drush with Composer?

texts:
From my project root, where composer.json and composer.lock are, I tell composer to require drush/drush. It seems to do what it should, but upon completion it seems drush is not installed.

$ composer require drush/drush
Using version ^8.1 for drush/drush
./composer.json has been updated
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing webmozart/path-util (2.3.0)
    Downloading: 100%

  - Installing symfony/var-dumper (v2.8.13)
    Downloading: 100%

  - Installing jakub-onderka/php-console-color (0.1)
    Downloading: 100%

  - Installing jakub-onderka/php-console-highlighter (v0.3.2)
    Downloading: 100%

  - Installing dnoegel/php-xdg-base-dir (0.1)
    Downloading: 100%

  - Installing nikic/php-parser (v2.1.1)
    Downloading: 100%

  - Installing psy/psysh (v0.7.2)
    Downloading: 100%

  - Installing pear/console_table (v1.3.0)
    Downloading: 100%

  - Installing consolidation/output-formatters (1.1.0)
    Downloading: 100%

  - Installing consolidation/annotated-command (1.4.1)
    Downloading: 100%

  - Installing drush/drush (8.1.5)
    Downloading: 100%

Writing lock file
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles

$ drush
The program 'drush' is currently not installed. You can install it by typing:
sudo apt install drush


texts: Get custom fields from users table in global user object

texts:
I've altered users table and added two new fields directly using MySQL workbench

first_name
last_name

If we add new fields by config > people > site information > manage fields, it does not allow adding drop-down list. So, directly added using MySQL workbench.

Now I was able to alter user_register_form and added above two fields with validation.
At the time of creating new user, the values of first_name and last_name gets stored in users table.

Now, how to get those two fields when user logs in?

i've used below code to print user object

global $user;
$user_full = user_load($user->uid);
print_r($user_full);

Any help would be appreciated, thanks !!


texts: How do I crop an image without cutting off parts?

texts:
I'm using Image Crop Widget (8.x-2.2) and Crop API (8.x-1.5). I'm trying to add "padding" to the cropping area so that I wouldn't have to cut my images at awkward places.

In the above picture, I have a blue rectangle that must be cropped into a square. However, in #1, it cuts off a bunch. I'm looking for a solution in order to accomplish #2, to include "extra space" beyond the picture so that I don't have to cut off anything.

Hopefully, the colour of this added space, or padding, would be white, (or customizable).


texts: How to use field widget to create field in code?

texts:
Is there possibility to use field widgets to create these kinds of fields? I can't find any information how to use it while form creating.

I found something like this http://devblog.com.au/using-the-date-widget-with-drupals-form-api
but I'm looking for another widgets info (how to use it).

In addition, I don't use the entity type in this case (custom structure).


texts: Save the #default_value of custom fields when editing comments

texts:
I added a field select list comments in a hook_form_alter. When you select and save the comment, I do not know how to preserve the value of this field when editing this comment.
My Code

function comment_author_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'comment_node_zayavka_form') {
    $query = db_select('node', 'n')
      ->fields('n', array('type', 'uid', 'title', 'nid'))
      ->condition('n.type', 'brigada_type', '=');
    $result = $query->execute();
    $brigade_list = array();
    foreach ($result as $value) {
      if ($user->uid != 1) {
        if ($value->uid == $user->uid) {
          $brigade_list[$value->nid] = $value->title;
        }
      }
      else {
        $brigade_list[$value->nid] = $value->title;
      }
    }
    $form['select_brigade'] = array(
      '#type' => 'select',
      '#title' => t('Select brigade'),
      '#options' => $brigade_list,
      '#description' => t('Please select the team that was sent to you with reference to this application.'),
      '#required' => TRUE,
      '#default_value' => variable_get('comment_field_brigade_selection', 0),
    );
  }
}


texts: Drupal Multilanguage domain specific with PORT not working

texts:
I have setting up drupal 7 with 2 languages:

English Default
Spanish

Also, Point 2 domains for each language from language configuration settings

www.drupal-experiment.local:90 (English)
es.drupal-experiment.local:90 (Spanish)

Setting.php
Base URL set in /sites/default/settings.php file.

  $base_url = "http://www.drupal-experiment.local:90";

Can anyone look at my configuration, where I have missed something so, Other/inner links are not getting PORT with given URL.

e.g. If I try to login it will submit data to URL without PORT number.

  http://www.drupal-experiment.local/

See attached screen-shots for configuration set for domain with PORT 90.

  Languages list

  English Language Configuration

  Spanish Language Configuration


texts: Re-use value entered in component in previous webform page on following page in markup

texts:
I'm creating a webform with multiple pages.  On the first page, I ask for "Name" (textfield), and on the second page, I would like to have a markup component that incorporates the value entered for "Name" on the first page.

I have tried using webform's token system in Webform 3.x and the new token functionality in Webform 4.x, as well as hook_form_alter(), all to no avail.

In regard to the later, in glue.module I defined:

function glue_form_alter(&$form, &$form_state, $form_id) {
  if (preg_match("/webform/i", $form_id)) {
   dsm($form);
  }
}

and the resulting array displays the "name" component value (from page one) as empty on page two.

Would someone please help me?


texts: Format of the JSON returned by the Services module

texts:
I have a big doubt about the JSON format the Services module (for Drupal 6) generates.

When I view the XML, all is OK.

<result is_array="true">
 <item>
  <nid>9</nid>
  <vid>9</vid>
  <type>producto</type>
 </item>
</result>

When I view the JSON, I see this:

[
 {
  "nid": "9",
  "vid": "9",
  "type": "producto",
 }
]

What I really is something like this:

[
 {
  "item":{
    "nid": "9",
    "vid": "9",
    "type": "producto",
  }
 }
]

How do I do this? Is there any configuration in the Services module that I can use to change the output, or do I need writing code?
I know the function to render JSON output.


texts: devel module use anonymous user as author in generate content?

texts: i have been created 'job' content type, i used 'Devel module' to generate content of 'job' type, but in some 'jobs' its taking anonymous user as a author, but i don't want anonymous user as author, so what should i do to avoid anonymous user as a author?


texts:
I created a module in order to define a few functions that I would like to use from a workflow rule. The workflow rule is triggered by an event and runs a php code snippet. The php snippet that it runs is simply a function call to the function that I defined in my module.

However each time my rule executes the code, I see an error in the httpd error_log - call to undefined function. I ran the module through php lint, and I enabled it, flushed caches, and even restarted httpd for good measure. Still I get the error "PHP Fatal error:  Call to undefined function" in the log.

I'm new to modules and Drupal programming so I must be missing something, but I thought functions defined in drupal modules (modulename.module) are global?

BTW I followed the instructions here.

Edit1: I defined my functions in module.module (not .inc...)


texts: How to create a Notification system in D7?

texts:
I am new to Drupal and was wondering if there is a module that can serve as a Notification system for logged-in users on my site?

Since my nodes consist mainly of images generated by users, I would like for logged in users to be able to see how many members liked their images, made a comment, followed them, etc.

P.S. I read almost all similar posts here and none of them provided any clear explanation. Pointing to active sites that already use "these module(s)" would be of great help.

Thanks in advance,
Milos


texts: How to automatically render submenu block in sidebar?

texts:
I want to automatically render a submenu in a block placed in sidebar (Drupal 8). This submenu could be one of those I setup in Main Navigation menu but could also be one of other custom-made menus.

What I have done by now is:

Create a new independent menu either replicating each of Main Navigation submenus or for each of my custom-made menus.

Place one block per menu/submenu in sidebar.
Make them visible/invisible according Visibility -> Pages.

Placing Main Navigation block also in sidebar is a no-go as it shows all equal-level menu entries.

I suspect this could be done in a more efficient way using views but I haven't figured out how.

Any ideas?


texts:
I'm displaying a form on admin url :admin/settings/custom. In the page argument I pass array('custom_admin_form'), to the menu item. In the form function I'm writing form elements to display folder and file names present in the public folder. I get those values through the code below:

$dir_path = variable_get('file_public_path', conf_path(). '/files') ;
$fileslist = glob($dir_path . "*.*");
$dirs = glob($dir_path . '/*' , GLOB_ONLYDIR);
foreach($dirs as $directs){
     $names = explode('/', $directs);
     $fnames[] = end($names);
}

How can I display the results in the form function? I tried it using print, echo, drupal_render but nothing is working. I've also used #markup element, but it was displaying array(), not the values of array.


texts: How to get rid of CKEditor and recover access to admin pages?

texts:
I can't access anymore to many module's admin page (especially CONTENT : bueditor, wysiwyg, smileys. And MEDIA : IMCE or Imagepicker) since I uninstall CKEditor. I don't know if that's exactly linked but since then, when I go to admin/config/content/ I get "Advanced Forum", "Text Format", and "CKEditor" even if I've uninstalled it.

Of course, when I click on "CKEditor", I get a normal PHP error :

Fatal error: require_once() [function.require]: Failed opening required '*****/sites/all/modules/ckeditor/includes/ckeditor.admin.inc' (include_path='.:/usr/lib/php5') in *****/includes/menu.inc on line 501

BUT if I try to force access, like typing admin/config/content/bueditor or admin/config/media/imce, I'm redirected to admin/config/content/ or admin/config/media

P.S.: I'm on D7.


texts: How to access all images uri in node's field in custom module?

texts:
I already know I can get an url for field of node this way:

$src = file_create_url($node->get('name_of_image_field')->entity->uri->value);

The problem is, my field name_of_image_field has multiple images. How to access them all?


texts:
In my custom D7 module, I'd like to link to admin/reports/dblog/, however, I'd like to have it filtered by a certain type so when you navigate to that link, the type is already filtered for you.

Is this possible?


texts: How to Write Browser Tests on Custom Theme?

texts:
I'm writing front end tests for a custom webform. These tests work fine when testing on the webform page of the form.
$this->drupalGet('/webform/custom_form');
$this->assertResponse(200);

However, testing the form using a custom theme and the page that the form is displayed on, does not work and the assertion fails returning a 404 response.
<?php

namespace Drupal\Tests\test_module\Kernel;

use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\webform\Functional\Element\WebformElementBrowserTestBase;

class WebformValidationTest extends WebformElementBrowserTestBase {

  public static $modules = [
    'webform',
    'test_module',
  ];

  public static $testWebforms = ['custom_form'];

  protected $defaultTheme = 'custom_theme';

  /**
   * Test custom_form page from site with custom_theme theme install.
   *
   * @throws \Exception
   */
  public function testThemeFormPage() {
    $this->drupalGet('/page-that-displays-form');
    $this->assertResponse(200);
  }
}

I have also tried creating a submodule that imports the full config and installs all dependent modules from the site. This also did not work.
Is writing front end tests for specific nodes something that is possible with Drupal Browser Tests? If not, how does one write tests for webforms (validation, fields, display, etc)?
Thanks.


texts: Custom Field Type hook_field_widget_form() not showing #title values

texts:
I have created a custom field type. When creating a piece of content with this field type I get a select list and a text area like the image below. However, I have stated that the '#title' for the select list is Label and the textarea is Value.

These '#title''s I've given them do not show up. From looking at other modules that provide a field type that has multiple elements on its widget form seem to be doing it the same way but their titles show up.

function civsearch_property_labels_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  if (isset($items[$delta]['label'])) {
    $default_label = $items[$delta]['label'];
  }

  if (isset($items[$delta]['value'])) {
    $default_value = $items[$delta]['value'];
  }

  // We are unserializing the variable_get because the string that was
  // serialized with variable_set was a serialized array. So we need to run the
  // unserialize process one more time.
  $options = array();
  $list_items = unserialize(variable_get('civsearch_property_labels', ''));
  foreach ($list_items as $list_item) {
    $explode = explode('|', $list_item);
    $options[$explode[0]] = $explode[1];
  }

  $labels = $element;
  $labels += array(
    '#type' => 'select',
    '#title' => t('Label'),
    '#options' => $options,
    '#default_value' => isset($default_label) ? $default_label : '',
    '#suffix' => '<br \>',
  );

  $values = $element;
  $values += array(
    '#type' => 'textarea',
    '#title' => t('Value'),
    '#default_value' => isset($default_value) ? $default_value : '',
  );

  return array(
    'label' => $labels,
    'value' => $values,
  );
}


texts:
I am using drupal 7 and would like to customise my login form block.

function theme_form_alter(&$form, &$form_state, $form_id) {

if ($form_id == "user_login_block") {
        $form['links'] = Null; // Remove Request New Password and other links from Block form
        //$form['links']['#markup'] = t('Forgotten Password?') . ' ' . t('Forgotten Password?') . ''; // Remove Request New Password from Block form
        //$form['links']['#markup'] = ' ' . t('Register') . '' . ' ' . t('Forgotten Password?') . ''; // Remove Request New Password from Block form

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

    $form['name']['#attributes']['class'][]= array("nui-input");

    $form['name']['#title'] = Null; // Change text on form
    $form['name']['#attributes'] = array('placeholder' => t('username'));
    $form['pass']['#title'] = Null;
    $form['pass']['#attributes'] = array('placeholder' => t('password'));

}

}

In the above code the following line does not seem to have any effect on my field :

$form['name']['#attributes']['class'][]= array("nui-input");


texts: Can a Event Service be coupled to a route

texts:
I have created a custom service and have hooked into the "event_subscriber"  via tags in my custom service.yml

  demo_api.exception_handler_subscriber:
      class: Drupal\demo_api\Response\Handler
      tags:
          - { name: 'event_subscriber' }

With in this custom service I'm listening into KernelEvents::RESPONSE

public static function getSubscribedEvents()
{
    // For this example I am using KernelEvents constants (see below a full list).
    $events[KernelEvents::RESPONSE][] = ['onResponse'];
    return $events;
}

The problem is I have some API request and I'm modifying the response for these request and returning a modified json format.

public function onResponse(FilterResponseEvent $event)
{
    $response = $event->getResponse();
    $apiFormatter = new ApiFormatter();
    $response->setContent(
        json_encode(
            $apiFormatter
            ->wrapResult(
                json_decode(
                    $response->getContent()
                )
            )
        )
    );
}

This is causing any web pages to respond as json.

I would like to limit this service to these API calls only and not be called on each request.

Any advice would be grateful.


texts: How can I rollback to previous theme/subtheme or disable last used theme by using text editor only?

texts:
I get a broken page; both the backend and frontend are not loading.

I'm guessing I made a mistake while configuring a bootstrap subtheme/starterkit (using a combination of method 1 from the README file and a youtube tutorial on activating and modifying subthemes)

Right after activating it I got a "500 Server error."

I was able to load the page by replacing the modified files with the original files, but that kinda threw all previous work to the trash (I guess I can live with that), but it would still be nice to know how to manually change theme by modifying the code directly with text editor, so in the future we all can benefit from this knowledge.


texts:
I have the simple view to display a list of nodes of a particular type. But I can't get it to sort by post date! I tried over and over, ascending and descending and it just won't sort!

I don't know what to do...

In the preview this is the sql statement:

SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created
  FROM node node  WHERE (node.type in ('homepage_feat_video')) AND (node.status <> 0)

There is no sort directive. But I added a sort for sure!

EDIT: discovered that when I change the style to something other than table - it works. but why doesn't it work in a table?


texts: How can I use jQuery 1.7 without having issues in the admin pages?

texts:
Is anybody successfully running jQuery 1.7?
I'm using a jQuery component on my pages which requires jQuery 1.7 or later. This version causes some unwanted side effects in the admin UI, such as checked checkboxes that don't reveal additional controls when available, or field widget not being active.

I was wondering if there's a solution that could let me easily work with jQuery 1.7.

I saw this answer before asking. As far as I understand, there are 2 separate issues: updating src of the jQuery to 1.7.x, and updating the javascript used by admin. I tried to use the latest jquery_update development snapshot, and apply a patch, but it does not solve the above-mentioned problems with UI.


texts: entity_load failure: Adding revision capability to entity with existing data and unticking "create new revision" still creates a revision

texts:
I am having trouble with entity_load returning an empty array on an entity api custom entity which previously was fine. The only change I've made is to add revision support which apart from creating the revision table etc. has also created a revision ID column in my custom entity table and filled this with NULL by default.

In troubleshooting why this is and trying to pin down if the revision is causing my problem, I've come across something which seems peculiar to me: creating an Article and unchecking "create new revision" still creates a revision.

My custom entity revision table is currently completely empty and I've been debugging and stepping through the code within entity_load but I cannot see where the problem is.

Where is my problem with the entity_load? Is the new revision being created despite unchecking the option a localised problem?


texts: Variable to check if the page is of some other Content Type

texts: The variables $page and $teaser are very helpful but is there a way to check if I'm in a different kind of Content Type? For example, if I made a content type named Products, what can I type in my template file page.tpl.php which will display HTML only if the page being viewed is of type Products?


texts: Entity forms : Can't assign the new field to parent 'group'

texts:
I working on web based diary,

In the diary there are 21 days where every day is a Parent 'Group' with field type Vertical tab. Every day has 16 fields which are same for every day.

I am able to create successfully 17 days without any problem but after that I am not able to assign fields to any parent 'Group'.

after selecting parent and clinking save it reload the page without saving the configuration.

There is no error or any message to help identifying the problem, I am new with Drupal and don't have any idea why it is happening, I try Google and couldn't find any information that could help.

I was wondering if there is any way to find the logs and errors. Or if there is any limitation on the number of fields/group.

Thank you very much for the help.


texts: CSS not working after Commerce AJAX processed on field

texts:
I have got a problem with css after Drupal processes radio buttons on Drupal Commerce product page. Radio buttons are formatted (images instead of typical radio)

Formatted radios

After clicking any of radio buttons:

The HTML:

    Pack size

            <input type="radio" id="edit-attributes-field-pack-size-50-grams" name="attributes[field_pack_size]" value="50 grams" checked="checked" class="form-radio ajax-processed">  50 grams

            <input type="radio" id="edit-attributes-field-pack-size-100-grams" name="attributes[field_pack_size]" value="100 grams" class="form-radio ajax-processed">
            100 grams

The SCSS is:

    #edit-attributes-field-pack-size {
        overflow: hidden;
        input {
            opacity: 0;
        }

        label[for|="edit-attributes-field-pack-size"] {
            display: block;
            width: 102px;
            height: 102px;
            background: url('/sites/all/themes/blissout/img/radio.png') no-repeat;
            text-indent: -1000px;
            overflow: hidden;
        }
        label[for|="edit-attributes-field-pack-size-50-grams"] {

        }
        label[for|="edit-attributes-field-pack-size-100-grams"] {
            background-position: -102px 0;
        }
        label[for|="edit-attributes-field-pack-size-500-grams"] {
            background-position: -204px 0;
        }
    }

And it works perfectly until the ajax is "preprocessed" on radios. That Ajax calculates the price depending on the size of selection (it's drupal commerce code). It's different product variation but the classes doesn't change.

I have tried putting CSS into html.tpl.php. If the trigger('create') is solution could someone describe me step by step how to write js/jquery code for it?


texts: Form API multiple select drop downs in a paragraph

texts:
I am trying to recreate the following paragraph in a custom Drupal form.

How do you create multiple selects in a single paragraph?


texts: Cannot hide Superfish sub menu on active pages

texts:
I am using the horizontal NavBar style with Superfish.  When I'm in a section, I do not want its sub-navigation bar to show up.  I only want to see the sub-pages listed whenever I mouse over the parent link.

Example:  Main section is called Products, and I have a sub-section called T-Shirts.  If I click on T-Shirts or Products, it displays the sub-navigation without having to mouse over the Products link again.  The sub-navigation menu becomes persistent when in that section.  I only want to see the list of Products sub pages if I mouse over the main Products link.

I tried setting Path Class to blank instead of "active-trail," but that jacked it up.  Also tried hiding .active-trail with CSS, but no luck there either.

Wondering if this is a Drupal issue with Menu settings or a Superfish issue?

Thanks in advance for the help!


texts:
I asked this question a while back and it was answered correctly and helpfully.

However, I'm currently looking for a different solution.

I need a way to create a custom argument which I can use to specify a different xml document source, like in the following:

drush mi migration_test --xml=test.xml

Can anyone advice how I can create the custom --xml argument ?


texts: site redirecting to core/install.php after migration

texts:
I have migrated my site to different server and I am redirected to install.php page.

Here is the steps I have done:

zip whole site and extract it in new server.
export database and import it to new database (using phpmyadmin)
modify database credential in site/defaults/setting.php

any idea why drupal redirects to install page?


texts: Limiting Views diplays to a role — two displays are stuck together

texts: I have a View with two displays, one for role1 and one for role2. When I set the access control for the first display to role1 and save the View, then set the access control for the second display to role2, it changes the first display to only be accessible to role2 as well. Have I encountered a bug, or could there be some set of configuration options causing this?


texts: WYSIWYG module is not finding my custom plugin

texts:
I am building a custom plugin. I have the WYSIWYG module 7.x-2.x-dev. I have followed the instructions here.

I realize that this question is similar to this and this. However I think this may be a slightly different issue so I am going to try a new thread.

Pertinent code:

<?php
/**
 * Implements hook_wysiwyg_editor_settings_alter().
 */
function my_module_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
  $settings['extraPlugins'] = 'my_plugin';
 }
}

/**
* Implements hook_wysiwyg_include_directory().
*/
function my_module_wysiwyg_include_directory($type) {
switch ($type) {
  case 'plugins':
    // You can just return $type, if you place your Wysiwyg plugins into a
    // sub-directory named 'plugins'.
    return $type;
 }
}
/**
* Implementation of hook_ckeditor_plugin().
*/
function my_module_ckeditor_plugin() {
 $module_path = drupal_get_path('module', 'my_module');
 $plugins = array();
 return array('my_plugin' => array(
  'name' => 'My Plugin',
  'desc' => t('Custom plugin to add button styles in the WYSIWYG.'),
  'path' => $module_path . '/plugins/my_plugin/',
 ),);
}

/**
 *  Implements hook_wysiwyg_plugin().
 */
function my_module_wysiwyg_plugin($editor, $version) {
 switch ($editor) {
  case 'ckeditor':
   $module_path = drupal_get_path('module', 'my_module');
   return array('my_plugin' => array(
    'filename' => 'plugin.js',
    'path' => $module_path . '/plugins/my_plugin',
    'buttons' => array(
      'style_1' => t('Style 1'),
    ),
    'load' => TRUE,
    'internal' => FALSE,
  ),);
 break;
 }
}

This produces a blank area where the CKEditor should be and the error logs still say that it is looking in the sites/all/libraries/ instead of my custom module folder. Any ideas on what I am missing?


texts:
When you expose a filter date on views you get something similar to the following:

When you expose the post date you get:

The former is a lot more useful. Is there a way you can get the post date to look the same?


texts:
I am working with files in a Drupal module. I added this form:

$form['Background_image'] = [
  '#type'               => 'managed_file',
  '#title'              => t('Image'),
  '#progress_message'   => t('Please wait...'),
  '#progress_indicator' => 'bar',
  '#description'        => t('Click "Browse..." to select an image to upload.'),
  '#required'           => TRUE,
  '#upload_validators'  => ['file_validate_extensions' => ['jpeg jpg png gif']],
  '#upload_location'    => 'public://backgroundimage/',
  '#default_value'      => $this->options['Background_image'],
];

The file is added properly. Once the file is uploaded a remove button appears allowing to remove the file and upload a new one. The problem is that this button is not working. How can I remove an uploaded file?


texts:
I'm using Acquia DevDesktop application on Mac, I installed a new website on that , everything seems Ok but when I got to the installed path and try to update Drupal core with drush up faced with

➜  thunder-8.x-1.0-core drush up
Command pm-update needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal         [error]
environment to run this command.
The drush command 'up' could not be executed.                                                                                [error]
Drush was not able to start (bootstrap) the Drupal database.                                                                  [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a configured database. In this case you can select another
site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See `drush topic
docs-aliases` for details.
 * connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed
shell. See http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version         :  8.2.5
 Site URI               :  http://default
 PHP executable         :  /usr/bin/php
 PHP configuration      :
 PHP OS                 :  Darwin
 Drush script           :  /Users/yms/.composer/vendor/drush/drush/drush.php
 Drush version          :  8.1.10
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Users/yms/Sites/devdesktop/thunder-8.x-1.0-core
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default

In the issues reported I found about this problem, adding Mysql path to PATH resolve the problem, but in my case when I type mysql on command prompt it works correct and that means The mysql path is added to PATH. but I don't know why Drush couldn't find the database connection.

Also in my connection to db Acquia used 127.0.0.1 So changing localhost to 127.0.0.1 is not the solution


texts: Using Features to create module with nested field collections

texts:
I'm using Fred Parke's method to create a content type module by first building the content type and then turning it into a feature and exporting it. It works perfectly well, except for when I include field collections that are nested, one inside another. The exported source code doesn't seem to include those, even when I manually select the field_* types for export.

Is it possible to export nested field collections in a feature? If the answer is yes, how can I achieve this?

At this stage, I'm looking at doing it in Wordpress and embedding the result in an iframe, which should tell you how desperate I am.


texts:
Drupal 7.24

I have been stonewalled by an interesting problem on a D7 site. Essentially the cache_menu table was getting very large but not just in items (6300 odd) some of the items are enormous.

Its a new record for me, one of the items is 1.24 mb and 26 of them are between 800k and 1mb.

The site went down when it was being git with slightly elevated traffic, its running on a load balanced AWS cluster with RDS at the back, there's no lack of resources for a 20 simultaneous connections site.

i truncated the cache_menu and regenerated everything by browsing the site and all but a few of the items are gone now but there are still the 1.2mb one and a handful of the 800kb ones.

I followed this link -  http://drupal.org/node/1234830 from here Huge cache_menu table and it appears that this particular issue has been resolved for 7.13+ so i am thinking its something architectural going wrong.

There's no core hacks, we've got an impressive search system using a logic server network (running on SOLR externally) that does hook into taxonomy terms. The site is essentially a portal of links.

Could someone give me some pointers on where to start track this issue down?

edit: CID/sizes in cache_menu, query:

SELECT cid, LENGTH(`data`)/1024 as `size KB` FROM cache_menu WHERE LENGTH(`data`)/1024 > '300' ORDER BY `size kb` DESC;

Result

links:management:tree-data:en:ec99d3452fef1ede622e66c68ba908b1dad455aa71f5e68648aeec6488b89c88
1094.2188
links:main-menu:all-cid:0:1:en
839.4873
links:main-menu:tree-data:en:ec99d3452fef1ede622e66c68ba908b1dad455aa71f5e68648aeec6488b89c88
815.6230


texts: Create Relation between two vocabulary terms in views expose filter

texts:
Suppose if i have 2 vocabularies in which first vocabulary name is "Country" which contain some country names and Second is "Cities" which contain some cities names. If i want to select a particular country from "country" expose filter and i want that only few selected cities will automatically appear in "cities" expose filter. So that user dont have to go through all the list of cities of all the countries.

Is it possible with drupal views or any contributed module ? otherwise i have to do it with jquery hide/show .


texts: How to track the number of clicks on a link?

texts:
I have created a views in grid settings. I have displayed 5 columns and 4 rows n this view. Over all i have 20 items present in this view.
In each item i have a link field. This view is very similar to  http://www.amazon.com/ (What Other Customers Are Looking At Right Now). Now i would like to track the number of clicks on each link. The result should contain the user who clicked it or how many number of times it has been clicked.
I am struck with this please some one help me to find a solution. By the way  I am using D7.


texts: Allow user to filter View by Month only using a D/M/Y date field

texts:
I have a simple date (birthday) field in my View, and I have added that field as an exposed filter. I want to be able to filter by just the month, so that the View can return a list of users whose birthdays are in the month of July, for example. Currently, the exposed filter also requires that I choose a year, which makes the filter un-usable. How can I filer based on just the month and nothing else?

Thanks!


texts: How to add a menu item to main menu: hook_menu() or menu_link_save()?

texts:
I just want to programmatically add some menu items to the main menu, but none of the answers I found worked. Some answers suggest using hook_menu(), others suggest using menu_link_save(). I followed what reported in Can I add a custom link to "Main Menu" via hook_menu? but it just doesn't work. There's no new item added, neither in the UI nor in the database.

function mymodule_menu() {
  $items['my/path'] = array(
    'title' => 'Title',
    'page callback' => 'page_creator_function',
    'access callback' => TRUE,
    'menu_name' => 'main-menu',
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

Also I found How and where do I programmatically add a menu to the Navigation menu?. Answer #2 says that using menu_link_save() is the way to go, but I could not get it to work. Do I have to place the code in a certain location or a special hook?

$item = array(
  'link_path' => 'my_path',
  'link_title' => 'Title',
  'menu_name' => 'main-menu',
  'weight' => 0,
  'language' => 'en',
  'plid' => 0,
  'module' => 'menu',
);
menu_link_save($item);

Since both answers didn't work out, it seems that I am missing a crucial point. Could anyone say what's going on here?


texts: Invalidate cache of views block for anonymous users

texts:
I have a view display block that needs to be updated every 8 hours.
I tried Views Custom Cache Tag module https://www.drupal.org/project/views_custom_cache_tag but I could not make it work. I set my tag for the view block display and then invalidate this tag with the each API call, but the block does not get updated.
I am looking for programmatical solution of flushing the cache of view blocks without changing the rest of the content.


texts: Override (shorten) breadcrumbs on Views page

texts:
I'm using Views 3 and I DON'T want the contextual filter to tack itself onto the end of the breadcrumb. In fact, for the whole view, I want only the static breadcrumb Home » My View Name. That's it. Nothing changed or added no matter what contextual filter I click, as long as I'm inside the view.

I tried doing an array_slice($breadcrumb) inside my view's tpl.php file but it seems to have no effect. However, in the same template, $breadcrumb[] = 'salamanders' gives me the word 'salamanders' as the second to last item in my breadcrumb. It does this regardless of whether I have my contextual filter set to override breadcrumb or not, and also irrespective of what text I've actually entered to override it with, when override enabled.

I've tried overriding the breadcrumb in hook_page_alter() inside a custom module as well. Again, I can add to but not subtract from the breadcrumb.

How do I remove elements from my breadcrumb when Views insists on tacking things on to it?


texts: hook_views_pre_render(&$view) seems to be called after the pager rendering

texts:
I am designing and ecommerce store and I am trying to sort the products by availability using a hook_view. My function product_eta_seconds return the current eta of a product. Here is my module:

function availability_sort_views_pre_render(&$view) {
  if ('uc_products' == $view->name && 'page_1' == $view->current_display) {

    $view->result = array_reverse($view->result);
    $deliveryTime=array();
    foreach ($view->result as $viewRow){
        $deliveryTime[] = product_eta_seconds($viewRow->nid);
    }
    asort($deliveryTime);
    $view->result = sortArrayByArray($view->result,$deliveryTime);
  }
}

function sortArrayByArray($array,$orderArray) {
    $ordered = array();
    foreach($orderArray as $key=>$value) {
        if(array_key_exists($key,$array)) {

                $ordered[$key] = $array[$key];
                unset($array[$key]);
        }
    }
    return $ordered + $array;
}

The problem is the view->result returns only 9 items (my pager value) so when I look at page 2, there are results that should show up on the 1st page (with a lower eta). Is there a solution to get all items of the view without the pager and apply the pager, when the view is rendered ? Any other solution would suit though.


texts: How to call User::load with dependency injection

texts:
I have code that worked, but I wanted to clean it up and use dependency injection. I'm working in a BlockBase that implements ContainerFactoryPluginInterface.

class DefaultBlock extends BlockBase implements ContainerFactoryPluginInterface {

I need to access some information from the user object. Right now I'm using Drupal\Core\Session\AccountProxyInterface. This works fine, but doesn't give me all the information I was expecting. I have a contrib module adding a field to the user. I can access that field if I use User::load($id) however, I get the warning that...

  User::load calls should be avoided in Drupal classes, use dependency
  injection instead

So I'm trying. And failing.

This code works...

$userIdx = \Drupal::currentUser()->id();
$userx = \Drupal\user\Entity\User::load($userIdx);
$countryx = $userx->country_iso_code_2;

But when I clean that up and do it the right way, I can't get that country_iso_code_2 information.

Here is the code I'm "trying" to work with...

<?php

namespace Drupal\country_selector\Plugin\Block;

use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a 'DefaultBlock' block.
 *
 * @Block(
 *  id = "default_block",
 *  admin_label = @Translation("Country switcher"),
 * )
 */
class DefaultBlock extends BlockBase implements ContainerFactoryPluginInterface {

  protected $account;

  /**
   * Class constructor.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountProxyInterface $account) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->account = $account;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('current_user')
    );
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];

    $userIdx = \Drupal::currentUser()->id();
    $userx = \Drupal\user\Entity\User::load($userIdx);
    $countryx = $userx->country_iso_code_2;

    $userId = $this->account->id();
    $country = $this->account->country_iso_code_2;
    .....

When I debug, I see that:

  $userx is Drupal\user\Entity\User

  $user is Drupal\core\Session\AccountProxy

So I get that I'm working with two different things. I just don't understand how I'm supposed to call something like User::load with dependency injection.

I hope that makes sense. Would love some advice!


texts: How to hide empty blocks supplied by the User Relationship module?

texts:
I am trying to hide a module supplied block (User Relationships action block) from appearing on nodes posted by the logged in user. The block shows as empty on those pages.

I have tried php in the block visibility rule, I have tried the Context module, I have tried a template, to no avail except that with a template the block no longer shows anywhere regardless of the template having code inside it or not.

Otherwise, the visibility rules work if I limit visibility to specific paths.

It also looks like I am having problems hiding other module supplied blocks like the search block.

Interestingly enough, when I enable the Devel Themer module, the action block no longer shows on posts by the logged in user as it should but appears on others (this is the result I am trying to achieve.) Unfortunately, this module has other serious issues and I cannot leave it enabled permanently.

Combined with the fact that I haven't found any other complaint about this situation, this leads me to believe that the UR action block, by design, should not appear on the logged in user's posts and that I should not be facing this problem.

Does this mean I have a broken database somewhere?

Can anyone guide me on the diagnosis and possible repair of this situation --like, maybe, going into the database for a manual fix?

P.S.: In the database, the action block shows a size of NULL and a sort of NULL. Is this normal?


texts:
I've got a Drupal view that contains a jumplist of items filtered by taxonomy (which is pulled from the current page URL).

The problem is that I need this jumplist to work without a page reload (so using AJAX).

I've tried a few different things and done a lot of Googling, but come up with nothing.

I've read that you can expose filters to users and use this for Ajax filtering, the problem with this seems to be that you can't populate a select element with values from the database when using a filter, it looks like the filter values have to be hard coded or user defined, so this looks like a no go.

Is there any way of accomplishing this? Or am I going about this in the wrong way?


texts: Why am I getting a JSON dump when saving a node?

texts:
I've read about this issue elsewhere and the primary culprit has been Views and the jQuery Update module...particularly having jQuery set to anything but v1.5. I'm getting the JSON dump when saving a node:

[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"my_theme","theme_token":"yyYQcgn3UELRKecX6yTsTIV8lKutRmg3bBIpqbjACzE"}},"merge":true}]

I need jQuery 1.7 for an image rotator that I'm using and I found a patch for jQuery Update that allows you to set the version of jQuery for admin and and front-end so I have 1.5/1.7 set respectively and yet I'm still seeing this issue. I have confirmed that jQuery v1.5.2 is being loaded. I do see that jquery.form.min.js v2.69 is being loaded from the jQuery Update module along with jquery.cookie.js...could these be causing the problem?

This is the URL after clicking save and seeing the JSON dump:

http://mydomain.com/views/ajax?title=test&sitename=&type=All&uid_1=&status=All&vid=All&language=en&__utma=1.98635126.1382890057.1383491752.1384184897.6&__utmz=1.1382890057.1.1.utmcsr%3D(direct)|utmccn%3D(direct)|utmcmd%3D(none)&Drupal_toolbar_collapsed=0&Drupal_tableDrag_showWeight=0&has_js=1&SESS0e1269226b42fa1c68bd46a4609d8d90=YIk12tixVnxuF9Om77vikXdp7Il8oxAYukuDswiCJoI&__utmc=1&SESSe5a8c6595a55e490f10153304dbfc1ee=El6m94kqyvIsFjx_IDJkC6-nujMMHCed4oVBpPNnvXA

The error only seems to occur when I edit a node after searching for it on the Find content page. I'm using the Administration Views module as well.

All modules have been updated as well as core (7.23). I have the jQuery admin overlay disabled in an attempt to solve the problem. Is there anything else I can check/do to alleviate this issue?

Now that the issue is repeatable, I disabled jQuery Update and still received the same JSON dump, so that's not the issue :s


texts: Programmatically Access custom user field

texts:
I added a Node-reference field (machine name: field_node) to all users at:

example.com/admin/config/people/accounts/fields/

I am now working in a custom module & hook_node_access

How do I access the Node-reference field programmatically when the user is logged in?


texts: Get submitted value of a select list error on #options - Drupal 7

texts:
I have seen this block of code in a few places as the correct method:

$selected_index = $form_state['values']['select_field'];
$display_value = $form['select_field']['#options'][$selected_index];

So here is my code for it:

$key1 = $form_state['values']['field_setup_time3'];
$reservationStartPadding = $form['field_setup_time3']['#options'][$key1];

But I get this error with my code:

Notice: Undefined index: #options in ... blah blah blah

I am using a List (integer) running a select list with 4 options in it. Is options not the right choice here? I just need the numerical value from the user selected dropdown list when they submit the calendar booking.

Thanks!


texts: Drupal 7 dynamic dropdown list options An illegal choice has been detected

texts:
I have created a node type of Advertisement which holds all the information for adding new advertations to the website, including categories.

there are 3 levels of categories and i need to make a seperate box for them. The content type which i created through the GUI of drupal already has a term reference select box for category, sub category, and level 3 category..
So i made a module and implemented hook_form_alter and i added the #ajax attributefunction

<?php
adverts_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'advertisement_node_form') {
      $topLevelTermArray = array('_none' => ' - Select a value -');
      $topLevelTerms = array(5275, 5245, 5299, 5341, 5702, 5681, 5826, 5555, 6039, 5592, 5776, 5994, 6027, 5451, 5852, 6016, 5496, 5475, 6049);
      foreach($topLevelTerms AS $value) {
        $term = taxonomy_term_load($value);
        $topLevelTermArray[$term->tid] = $term->name;
      }
      $form['field_specific_category']['und']['#prefix'] = '
';
      $form['field_specific_category']['und']['#suffix'] = '
';
      $form['field_sub_category']['und']['#ajax'] = array(
        'callback' => 'ajax_sub_category_callback',
        'wrapper' => 'field_specific_category_replace',
      );
      $form['field_sub_category']['und']['#prefix'] = '
';
      $form['field_sub_category']['und']['#suffix'] = '
';
      $form['field_sub_category']['und']['#options'] = array('_none' => t('- Please select a category -'));
      $form['field_specific_category']['und']['#options'] = array('_none' => t('- Please select a sub category -'));
      $form['field_category']['und']['#options'] = $topLevelTermArray;
      $form['field_category']['und']['#ajax'] = array(
        'callback' => 'ajax_category_callback',
        'wrapper' => 'field_sub_category_replace',
      );
  }
}
?>

And 2 callback functions

function ajax_category_callback($form, $form_state) {
  $subCats = array();
  $tree = taxonomy_get_tree(5, $form_state['values']['field_category']['und'][0]['tid']);
  foreach($tree AS $term) {
    $subCats[$term->tid] = $term->name;
  }
  $element = $form['field_sub_category']['und'];
  $mainCatTerm = taxonomy_term_load($form_state['values']['field_category']['und'][0]['tid']);
  $element['#title'] = t('Sub categories for @cat.', array('@cat' => $mainCatTerm->name));
  $element['#options'] = $subCats;

  return $element;
}

function ajax_sub_category_callback($form, $form_state) {
  $subCats = array();
  $tree = taxonomy_get_tree(5, $form_state['values']['field_sub_category']['und'][0]['tid']);
  //var_dump($form_state['values']['field_sub_category']['und'][0]['tid']);
  foreach($tree AS $term) {
    $subCats[$term->tid] = $term->name;
  }
  $element = $form['field_specific_category']['und'];
  if(empty($tree)) {
    $element['#options'] = array('_none' => '- No specific category -');
  } else {
    $mainCatTerm = taxonomy_term_load($form_state['values']['field_sub_category']['und'][0]['tid']);
    $element['#title'] = t('Sub categories for @cat.', array('@cat' => $mainCatTerm->name));
    $element['#options'] = $subCats;
  }
  return $element;
}

But when i go to node/advertisement/edit and i select a category and sub category is show's:

An illegal choice has been detected. Please contact the site administrator.

How can i get that error too dissapear?


texts: Drupal Commerce - Reference Product in another product

texts:
I am building a Drupal Commerce based site and now I am facing the following issue.

I have created some T-Shirt Products like,

T-Shirt (White)
T-Shirt (Black)
T-Shirt (Blue)

And also created a product display called "Shirts". In that product display I created a new node "T-Shirt". Since The "size" is an attribute to the product type so I am having a select box to select the color while viewing the "T-Shirt" content.

But the problem comes here. As per my need, if the user selects "Color - White" while viewing
the product display, we need to add another product "Blue-Jeans" to it. So that means, White Shirt and Blue Jeans will go together in cart if selected.

I am using inline_entity_form to reference products in a Product display (Same as Commerce Kickstart Demo "Tops" product display). How can I achieve this functionality?


texts: Custom Views Field Formatter for List - show all values and indicate selected/not selected

texts:
new Drupal user here so please forgive any rookie assumptions or questions I may have.

I need to get all values (even those not selected) from a select list field in a view.

I'm trying to create a view that lists all the values in a select list. The list consists of when something is available (e.g. Winter, Spring, etc.). It's just as important to know when something is available as it is when it's not. However as I'm sure you already know, it only returns those items selected and not everything I need.

I've tried messing with the "rewrite results" trying Loops, IfElse, Multiple duplicate fields, etc.  Is this even possible and if so what the best way to go about it.  Thanks in advance for any guidance.

Edit:

Example:
Product_Name: product 1 Availability: Winter | - | Summer | Fall.

So I would want it to return all list options (selected or not), (" - " instead of "Spring" above because Spring is not selected for product 1) so I can write out the availability or add a " - " for not available.


texts: Passing a custom variable from preprocess view to a template file

texts:
I am preprocessing a view in order to create a custom variable and then pass it to a view template file.

I have added the following code to the template.php file:

function mycustomtheme_preprocess_views_view(&$vars) {
    $view = $vars['view'];

    $currentpath = current_path();
    $path_alias = drupal_lookup_path('alias',$currentpath);

    // define the custom variable
    $vars['mycustomvariable'] = '';

    if ($view->name == 'mycustomviewname') {

        foreach($view->result as $key => $result) {
            $tid = $result->tid; // get the taxonomy term's ID
            $termpath = drupal_get_path_alias('taxonomy/term/' . $tid); // term's path
            // if the current path is same to the one of the term
            if ($termpath == $path_alias) {
                // give a value to the custom variable
                $vars['mycustomvariable'] = 'blablabla';
            }
        }
    }
}

Then in the views-view-list--mycustomviewname--block_1.tpl.php file, I try to print the variable like this:

<?php print $mycustomvariable; ?>

But I am getting the error:

  Notice: Undefined variable: mycustomvariable in include() (line 18 of
  views-view-list--mycustomviewname--block_1.tpl.php)

I have spent a considerable amount of time on this issue and used dpm and print_r to print out variables, arrays and objects but I cannot seem to find solution to this issue.

Any help would be appreciated. Thank you in advance.


texts: What are the key differences between Drupal 7 and Pressflow 7?

texts:
I am currently using Drupal 7.
I heard Pressflow is another solution for high performance sites.

If you have experience with both systems, what is the benefit of migrating from Drupal 7 to PressFlow 7 ? What are the major differences between D7 and Pressflow 7 ?


texts: CKEditor Bootstrap 4 plugin for accordion

texts:
I want to integrate Bootstrap Accordion to CKEditor in Drupal 8.
I created a custom module and linked the bootstrap plugin. When I got to edit the toolbar, the button shows there and I add it to the active toolbar. But in the actual create page, the button doesn't show.
I used drupal console to create the module code.
I can confirm that the plugin.js file loads. I have tried this in a standalone(without Drupal) ckeditor install. And it works fine. Here is a working version. https://github.com/hirani89/ckeditor


texts: What is the default operator in Rules module conditions?

texts:
I have an issue on production site that I cannot reproduce.

The Rule below should trigger an email if the new content is published. But emails are being send even if content is not published.

{ "rules_content_new" : {
  "LABEL" : "Notify new content",
  "PLUGIN" : "reaction rule",
  "OWNER" : "rules",
  "REQUIRES" : [ "rules" ],
  "ON" : { "node_insert--article" : { "bundle" : "article" } },
  "IF" : [
  { "data_is" : { "data" : [ "node:status" ], "value" : "1" } },
  { "data_is" : { "data" : [ "node:field-custom" ], "value" : "13" } }
  ],
  "DO" : [
  { "mail" : {
  "to" : "test@mail.com",
  "bcc" : "[site:full-mailing-list]",
  "subject" : "[node:title]",
  "message" : "new content available",
  "from" : "test@from.com",
  "language" : [ "" ]
  }
  }
  ]
  }
 }


texts: How to print a field in a view only when it appears first?

texts:
I have a View which lists products (nodes). In the View, I first display the taxonomy the node belongs to, and then the title and image of the product. I have ordered the query by taxonomy. The problem is that I get a repeated taxonomy for each row of the View (each product). How can I display the taxonomy just once, the first time it occurs, and then all the products belonging to that taxonomy, then another different taxonomy and its products and so on...

Now I have this result

Sports
    - The great book of soccer
Sports
    - Practicing tennis
Sports
    - Mastering Chess
Science
    - Quantum Mechanics
Science
    - Cold fusion

and I want this result

Sports
    - The great book of soccer
    - Practicing tennis
    - Mastering Chess
Science
    - Quantum Mechanics
    - Cold fusion


texts: how to add only modify cache-tags to purger queue on node save?

texts:
I have the purger module installed, when i edit a node and save it without change anything, this is what i see in the purger queue :

Is it possible to alter the way to add tags in the purger queue ?

I want add just tags who is needed.

Because with the tag menu, on every node save, the whole varnish ll be clear because the menu is on every page.


texts: Which is the better module for shopping cart?

texts:
I would like to use a shopping cart module in my site.

Can any one suggest which would be the better one with basic functionality like displaying content (media), cost, adding to cart, billing, etc. It must include all necessary features of a shopping cart.

Will Ubercart fulfill the basic requirements?


texts: Is it okay to ignore the error notices I get on a Drupal site?

texts:
My Drupal 7 site has many error notices like

  Notice: unserialize() [function.unserialize]: Error at offset 225 of
  305 bytes in variable_initialize() (line 943 of
  /site/includes/bootstrap.inc).

or

  Call-time pass-by-reference has been deprecated in drupal_load() in bootstrap.inc

The site still works inspite of the errors. Is it okay to ignore these error notices?


texts:
I have installed the CKEditor module, the CKEditor library and the CKFinder library.
I have modified correctly the file config.php and the file settings.php, but when I want login in my site, I don't get the permission for access. If I comment the variable cookie_domain I can access at the site and all working properly, but I get a message error that say: "You are using a feature that requires $cookie_domain to be set, but it is not set in your settings.php file (CKFinder is enabled in the Advanced profile)". What can I do?


texts: How to prevent bots to enter specific pages on my site by a capture

texts:
On my Drupal 7 site I have some pages that should not be entered by bots like the google bot or any other bot. All this pages are under a specific path like:

www.example.com/xyz/*

I have configured my robots.txt to prevent all bots to enter xyz/* but I would like to add a higher obstacle. I thought, for example, about a capture.

I there a way in Drupal 7 to restrict access to all pages that have an specific path by a capture or does anybody have a better idea how to achieve my goal?


texts: Getting index of item in items inside twig template

texts:
If I use any loop in Drupal, I can get loop.index to get the index of looped item. - Ref#1

For example -

    {% for tag in content.some_array %}

{{ tag.content }}

    {% endfor %}

This is a field containing paragraph type -

field--field-container.html.twig

and its content is {{items}} ({{items|length}} gives the desired count)

The above template iterate through it's items and include the following template multiple times-
paragraph--multiple-blocks.html.twig
and its html is

    =====CONTENT=====

But I cannot get the loop.index (Ref#1) in the paragraph--multiple-blocks.html.twig template. I tried (surely google search shows all links visited) kint() debugging but could not get anything related to the count or index of the item iterated.

I will be grateful to any guide/help (don't want to code in PHP) close to get this done in twig files will.


texts: Assigning global var to session variable?

texts:
I want to assign the user name to a SESSION variable, yet this is not working.

$_SESSION['loveleytest'] = $user;
$_SESSION['thelovelytest2'] = $user->name;

What should I do?


texts:
When I copy a link and put into CKeditor (drupal)

After I switch back plain text it changed to be like this:

&lt;iframe width="420" height="315" src="//www.youtube.com/embed/q4Rgh5JNWf4" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

How can I solve this?