texts: In which template file is the create new account/log in/request new password page rendered?

texts: I would like to not render the request new password tab (/user/password), when I am not the log in page (/user). In which template file does drupal get told to render the create new account/log in/request new password page? Drupal 7, Bartik.


texts: Migrating dates in the same timezone: convert arguments to subfields?

texts:
I have a migration that is successful except for the timezone.

$this->addFieldMapping('dest_date', 'source_date');

For some reason the above code causes a timezone conversion to happen between the source date and the destination timezone. The migration seems to assume the source is in UTC and needs converted to Chicago time, giving me a result that's six hours later than it should be. The source date is in fact from the same timezone, so I want to avoid converting it.

$this->addFieldMapping('dest_date', 'source_date')
  ->arguments(DateMigrateFieldHandler::arguments('America/Chicago', 'America/Chicago'));

The above code works perfectly, but when I run my migration I get this error:

  The field mapping arguments() method is now deprecated - please use subfield notation instead.

However when I try to use subfield notation, I end up with the same problem again that I did when I had no arguments/subfields at all:

$this->addFieldMapping('dest_date', 'source_date');
$this->addFieldMapping('dest_date:timezone', 'source_date:timezone');

The above code doesn't seem to help at all, (edit: This is not surprising, as my field doesn't seem to have "timezone" as a subfield.) and the migration still seems to assume the source is in UTC and needs converted to Chicago time.

How do I convert my arguments to subfield notation without breaking them?


texts:
I created a bunch of products, but I need to style them per the designer's design. I know that I have to overwrite the template from /modules/contrib/commerce/modules/product/templates/commerce-product.html.twig but where do I put it in my theme?

Does it go to the root of my templates folder? What is the correct way to style the single product page?


texts:
Whenever I add any content on my website, I get this warning.

  Warning: in_array() expects parameter 2 to be array, string given in
  _drupal_http_use_proxy() (line 1100 of /var/www/html/includes/common.inc)

I am not sure why it does that, and how do I solve it?
Can anyone help?

PS: I don't know what tags should I use for this question.

EDIT1: Executing

  dpm(variable_get('proxy_exceptions'));


texts:
I have a gmap view that I have set a contextual filter(taxonomy term Id).I want to pass to this contextual filter the tid from the URL.The URL has the format
?q=gmap-view&tid=8 .So I want to grab the number 8 from the URL to pass it to the contextual filter.How can I do that?Do I need to select 'Provide default value'  and then use Php code?What php code should I write if this is correct?
Thanks in advance


texts:
How can I make my main menu link text dynamic?

My solution:

I tried to use Felix's answer, below, but it would not work for me. Obviously, the method suggested by Felix has worked for others and it is used in core (user.module, for example). However, I was able to conditionally alter my main menu link text at the theme level. I added this to template.php:

/**
 * Conditionally alters preprocess links variables.
 */
function MY_THEME_preprocess_links(&$variables) {
  if (MY_FUNCTION()) {
    if (isset($variables['links']['menu-562 active-trail']['title'])) {
      $variables['links']['menu-562 active-trail']['title'] = 'New blog';
    } elseif (isset($variables['links']['menu-562']['title'])) {
      $variables['links']['menu-562']['title'] = 'New blog';
    }
    if (isset($variables['links']['menu-563 active-trail']['title'])) {
      $variables['links']['menu-563 active-trail']['title'] = 'New notes';
    } elseif (isset($variables['links']['menu-563']['title'])) {
      $variables['links']['menu-563']['title'] = 'New notes';
    }
  }
}


texts: How to render Messages in an AjaxResponse?

texts:
I have a modal form which when submitted calls submitModalFormAjax(). I am trying to get the messages that were previously created and use an AjaxResponse command to print the messages to the modal's parent page.
I have this code:
  $response = new AjaxResponse();
  \Drupal::messenger()->addMessage($this->t('Form Submitted Successfully'), 'status', TRUE);
  $allMessages = \Drupal::messenger()->all();
  $html = \Drupal::service('renderer')->render($allMessages);

  $response->addCommand(new AfterCommand('div[data-drupal-messages-fallback]', $html));
  $response->addCommand(new CloseModalDialogCommand());

$allMessages seems to contain what I expect and it looks like a render array; but the render call returns nothing. If I replace $html with a simple string; it does print as I expect.
What am I missing here? What is returned from \Drupal::messenger()->all() and how do I render it?


texts: string espected but array given in custom pop_date field #default_value

texts:
Possible Duplicate:
  Date popup form field doesn’t show the default value correctly

I'm trying to set a default value for my custom date_popup field. To be precise I'm trying tho set the field to the first day of the current month. But if I can populate the field without errors I can figure out the rest.

At first I was trying to input a string value:

#default_value = '1/1/2012'

This results in no errors but also the field will remain empty.

I've looked trough some issues including this one and noticed that I had to use a date() as value.
But this also results in an empty field using the the following code:

'#default_value' => date('d/m/Y'),

Which I think should give todays date?

Finally I used the following code:

'#default_value' => array('day' => 1, 'month' => date('m'), 'year' => date('Y')),

which populates the field but gives me:

  Warning: strlen() expects parameter 1 to be string, array given in
  date_default_date() (line 114 of
  /home/quickstart/websites/nieuwesite/sites/all/modules/date/date_api/date_api_elements.inc).

Of course I'm trying to build this field in hook_form(). for reference here is my whole field:

$form['click_stats_date_start'] = array(
'#type' => 'date_popup',
'#title' => t('Start date'),
'#label_display' => '',
'#date_format' => 'd/m/Y',
'#date_year_range' => '-1:+0',
'#date_label_position' => 'hidden',
'#default_value' => array('day' => 1, 'month' => date('m'), 'year' => date('Y')),
'#size' => 20,
'#required' => TRUE,
);

So my question is how do I populate the date_popup field on the first load without errors?


texts: User approval needed to reference (entity reference) their profile (profile2)

texts:
Here is the use case:

User registers, and creates "Employee Profile" (using profile2)
Admin user creates node of type Location
Location node references (using entity reference) user's "Employee Profile," and then displays all the employees at a location (using the Views module, and EVA)

It is all complete, but users whose profile is being referenced needs to give permission before their profile is displayed in the Location node.


texts: Merging new contents with new functionalities

texts:
Assuming a situation when you develop a new functionality on a local copy of an already published site for quite a while, during which period the client adds new content over and over again.

How do you then merge the new additions from both sources? Do you use Features or something else? What's the safest way to go?


texts: Creating a Youtube block using Views for Embedded media field module

texts:
I created a content type called Videos.

In it there is a file field with a Embedded Media Field widget, and using the Media: YouTube module to post Youtube videos.

I created a block showing links to the latest 10 nodes of content type Videos.

This works fine.  However now I want to create another block showing a thumbnail of the latest video and if a user clicks on it, it will take the user to the node of that video.  I have played around in Views and there doesn't seem to be a way to expose the thumbnail of a video.

Any suggestions?


texts: How to make Ajax request from a drupal page?

texts:
I have tried to make an Ajax request from drupal page. But output data is not correct . I have tried this

Ajax code:

function searchemail()
{
var email =$('#email').val();
    alert(email);
        $.ajax({
        method: "POST",
        contentType: "application/json; charset=utf-8",
        url: "emailcheck.php",
        data: "email="+"test",
        success: function(ret){
     alert(ret);
        },
        error: function(x,e){
            alert("error occur");
        }
    })

}

Output Code

<?php

echo "test"+$_REQUEST['email'];

But it prints only a 0 instead of 'test'


texts: On View Rewrite Results I don't see additional options like Add Read More button when checked "Trim this field to a maximum length"

texts:
Can anyone help me? Because earlier this options were displayed when I checked "Trim this field to a maximum length". May be it depends on some settings?

I can't upload image to show you what I mean. But try to explain.
I have a view block which displays some articles of the content type. I have some fields of content type to display. One of them is Body. I want to trim it because it can be very long and set "View more" link to the current article. I choose "Trim this field to a maximum length" in the "Rewrite Rules" of the field but nothing happens, additional options aren't shown to me, so I can't set number of characters to display, title of "View more" link, path and etc.


texts:
I'm expanding my language learning site and need a bit of help if it's possible.
I am wanting to link to YouTube videos (that's easy). But I would like to have a captions field. As the video plays the captions would appear in the field. I need to do this so that the user can copy and paste the caption and there will be two lines of captioning "Language 1" and "Language 2." I might in the future add a second field below the captions that would give a grammar explanation to the caption being displayed as well.

The only thing I have found while searching around is: https://www.drupal.org/node/1927080 but it puts the captions into the video.

+---------------------------------+
|                                 |
|              VIDEO              |
|                                 |
+---------------------------------+
+---------------------------------+
|                                 |
|           LANGUAGE 1            |
|                                 | <= Changes based on video time
|           LANGUAGE 2            |
|                                 |
+---------------------------------+
+---------------------------------+
|                                 |
|            GRAMMAR?             | <= Changes based on video time
|                                 |
+---------------------------------+


texts:
I'm building a Webform in Drupal 8. One section has repetitive grouped elements that could be added more than once. For instance, it's something like:

Where they could add more if they want. If this was a node, I'd use Paragraphs to create a bundle for the language name, writing proficiency and speaking proficiency, and they'd be able to add as many as they like. I'm not sure how to do it in the new D8 Webform module though. I know something like Webform Add More kinda works (though, it's really just hiding a preset number fieldsets until they're needed, not creating them dynamically), but I can't figure out anything else even close to that.

Should I just make a set, static number? Or is there another way? I know Webform is totally different now in D8, with YAML config files and how the data is stored; should I try to just make my own custom field in code?


texts: Request a new password using username only

texts:
We don't want to use email id for request a new password.
How can we accomplish this without customizing/touching to core module.


texts: How to pass variable from module to other theme

texts:
I would like to pass variables from my custom module to some of my custom themes.
The most tutorials are concerning using hook_theme function but as I understand, it works only for creating new theme functions (new tpl files) inside module, where the hook_theme is defined. But I would need to alter theme definition of some custom theme in
/sites/all/themes folder from my custom module
/sites/all/modules

In particular, I need to add a variable into thems's html.tpl.php file. I would like to use custom module to define variable, because I need to make database queries to fill variable with value, and db queries should not be done in theme.

I have tried implementing hook_theme_registry_alter.
I have tried to add variable like this:

function mymodule_theme_registry_alter(&$theme_registry) {
$theme_registry['html']['variables']['test'] = 'test value';
}

but I got error "Undefined index: #children in template_process_html"

Can anybody help?


texts: some images not displaying after migrating to local host

texts:
I copied a website from the server to local environment and after seeing that everything is displayed I noticed that the images in all blog posts are not being displayed. I googled this problem and found that a lot of people had it before me and tried applying their ways to solve the problem but none of them were successful for me. I think I am missing something. Please correct me if there is something I might have missed.
Here's a list of things I have done

Compared the image paths and both are the same src="/sites/default/files/image.jpg"
Checked the .htaccess file in sites/default/files and no differences there too
Cleaned the cache

It is not a multisite and it is drupal ver 7.31


texts: How to programmatically set node alias on node save

texts:
I need to set a special path alias for nodes created by users in the template.php file of my theme. the pathauto module is enabled.
I already tried the solutions that are given in the following links

Create path alias programatically when node is created
How To Set Node Path/Alias Programatically
Programmatically set path alias

But none of them worked. Here is a few codes I tried but I failed.

function THEME_nodeapi(&$node, $op, $a3=NULL, $a4=NULL){
    if($node->type == "image"){
        switch ($op){
            case "insert":
                $default_node_path = 'node/'.$node->nid;
                $alternate_url = "SOME SPECIAL PATH";
                path_set_alias($default_node_path, $alternate_url, 0, '');
                break;
        }
    }
}

or this one

function THEME_insert($node){
    $path = "SOME SPECIAL PATH";
    $node->path = array('alias' => $path, 'pathauto' => FALSE);
}

function THEME_node_insert($node){
    $path = "SOME SPECIAL PATH";
    $node->path = array('alias' => $path, 'pathauto' => FALSE);
}

or

function THEME_nodeapi(&$node, $op, $a3=NULL, $a4=NULL){
    if($node->type == "image"){
        switch ($op){
            case "insert":
                $node->path = t("SOME SPECIAL PATH");
                break;
        }
    }
}

How can I do set path alias programmatically ?

UPDATE

I tried this code that recommended by @Ajit S and it didn't work again

<?php
    function THEME_node_insert($node){
        $alias = "arar/".$node->nid;
        $lang_code = "en";
        $path = array(
          'source' => "node/{$node->nid}",
          'alias' => $alias,  // Any alias that you want to set.
          'language' => $lang_code,  // Optional, if you are working on a multilingual site.
        );
        path_save($path);
    }


texts: How to change the user profile edit page?

texts: What is the best way to change the user profile edit page? I need to add a new field alongside the password.


texts: Why does the upload progress bar reset at 40% when uploading large files?

texts:
I'm uploading a 5 GB file and the upload progress bar resets at 40%.
When it gets to 40% it starts counting again from 0%.
Eventually the file does upload completely but this is not good UX.
I was wondering if any knows how I can make the progress bar reach 100% like it should.
EDIT:
Here are some configuration settings requested in the comments:
post_max_size = 6G
upload_max_filesize = 6G
default_socket_timeout = 60
max_execution_time = 7200
max_input_time = 7200

This doesn't happen for smaller sized files.
When uploading the 5G file, the file upload does end. It doesn't get to 40% again after it resets to 0. It seems to get stuck at 19%.
All this time the file is being correctly uploaded to the temporary directory like it should. Like when the bar reaches 40% the file will continue to upload the temp file until it reaches the full 5G.


texts: How to trigger JavaScript/jQuery on AJAX-enabled ImageField submit?

texts:
I'm trying to trigger a JavaScript event when an AJAX-enabled ImageField submit button is clicked.

I've tried variations on delegate(), submit(), and click(), but no joy.

This is something similar to what I'm trying:

$('#edit-field-image-und-0-upload-button').mousedown(function () {
  alert('hi');
});

I read the documentation I could find on Drupal's AJAX forms, but haven't found what I'm looking for yet.


texts:
I'm generate views content with this:

<?php echo views_get_view('xtr')->preview('block_1', array(1)); ?>

But I need to add slidewrap class only if the content available.

Below is what I've tried which not working:

<?php if (views_get_view('xtr')->preview('block_1', array(1))): ?>

<?php echo views_get_view('xtr')->preview('block_1', array(1)); ?>

<?php endif; ?>


texts: What is the correct name to give to a taxonomy term page template file?

texts:
I have a taxonomy term page, which is not a view. It just lists all the content for the taxonomy. I would like to customize this page, and I have tried all permutations and combinations of names for the template file. The template file just won't work.
I have tried page--taxonomy--term--5.tpl.php, page_taxonomy_term__5.tpl.php.

What is the right filename to give to the template file, in this case?

I am using Drupal 7.


texts: How to filter 1 view with two fields based on 1 contextual filter?

texts:
I having a view which result in a table with three fields like:

                 field1, field2,field3
row1 with values 100,    110,   503
row2 with values 200,    520,   110
row3 with values 300,    530,   210

All numbers are nid. All fields are in different node types.
I'm calling /foo?nodeid=110.

I'm trying to setup a view so that row3 is not displayed anymore and I can eventually have a table with row1 and row2 with the values of field1.

I tried a lot but do not get it. If I have one contextual filter I can filter the table on field2 and if I have another contextual filter I can filter on field3. But I cannot combine them like a normal filter like and/or.

Any suggestion how to solve this?

Note: For now my view is a table but in the end I will use it under webform so it then will be a webform display with a webform selection list.


texts: Multiple regions in a zone with different widths

texts:
I am using Omega / Delta / Context on my local environment and created a sub-theme with omega-tools. I want to add more regions to the footer section. I want the regions to be similar to that of Postscript One-to-Postscript Fourth.

Im not sure if ill be able to explain well in words, hence i have taken screen-shots of what i intend to do and what am i doing to get it and the output. http://pho.to/2qA1P (Sorry for the external link, i don't have enough reputation yet to share more images)

How do i want the layout:
I want the regions Footer Links One, Footer Links Two, Footer Links Three, Footer Links Four to appear between: Footer First and Footer Second.
In this order:

    Footer Zone        Column Count: 12 Cols
    Footer First       Width : 12 Cols
    Footer Links One   Width : 3 Cols
    Footer Links Two   Width : 3 Cols
    Footer Links Three Width : 3 Cols
    Footer Links Four  Width : 3 Cols
    Footer Second      Width : 12 Cols
    Footer Zone

and i have accordingly changed the region Weights and Widths in above regions, under Zone Configuration.

However, in the actual result the Footer Links regions are not displayed within Footer First and Footer Second regions.

Strangely, when i created a Delta and applied it to a Path with Context, i get the output exactly as i intended.

Please help me on how to fix this.

Alternatively, i was thinking to get Footer Link regions under a separate Zone and place 2 new zones above and below this zone with regions Footer First and Footer Second. Not sure if this is the correct way.

Kindly help. Thanks.


texts: How to go to external website from within a module?

texts:
I have created a custom module in which when a user enters a valid id, it should them take them to an external website. The problem I am having is redirecting to the external website. The code I am using in my module is to do the redirection is:

  // clear out the output buffer
  ob_start();
  while (ob_get_status()) {
    ob_end_clean();
  }
  return header("Location: $external_url");

This doesn't work. What should I be using to accomplish this?

Thanks.


texts: Clear Varnish Cache (and maybe Views?) for Home Page when new story posted

texts:
Drupal 7.

I run a site for a large publishing company.  We're on Acquia Cloud, using Varnish to serve cached pages to anonymous users.  Home page has a couple Views - one is a running list of news stories, and the other a Featured slider.

My minimum cache lifetime is set to 5 minutes, and Expiration of Cached pages to 15 minutes. On each View I have Content-based caching enabled.

I'd like to have new stories immediately shown on the home page. I believe I should only have to worry about the Varnish cache, that Content-based caching on the Views should be handling those caches, though to be honest I'm unsure of how to accurately test all this.

I read up on some things, and I found modules like Cache Expiration or Purge, and I think I'll also need to install Rules and maybe Cache Actions.  I just figured I'd post here to see if someone else had experience with this and could offer some direction.


texts:
I have an app (cordova/phonega) and a Drupal 7 site. In Drupal 7 site I have "HybridAuth Social Login" that permit to my users to register and login with FB/G+/other social networks.

Now I want to permit to the app's users to login to my site via social too. Via "service" module I can permit my app's users to use Drupal credential for login, but I want use the social login.

So I want this:
app's user insert social login in my app, the app call social site and check for login/password. If login/password are correct my app must call Drupal 7 site and login the user. If the user is not a Drupal user, my Drupal site must to create user, too.

Is this possible? How?


texts: How to count the number of votes for each star in fivestar?

texts:
I'm using Drupal 7, Voting API and Fivestar.

I try to count the number of votes for each star, and display the percentage, like :

It is at present possible to have only the number of total vote.

How can I achieve this?
With Voting API (hook_votingapi_results_alter) or Views ?

For information, i'm using comments for rating nodes.


texts:
i need to modify users payment and shipping address format to enable user select a city via drop list, so i installed Address Field Estonian format handler, it works perfect before last drupal core update 7.38, now it shows 500 internal server error.

When i reviewed dblog report i found this warning:

Warning: array_combine() [function.array-combine]: Both parameters should have at least 1 element in addressfield_format_address_et_generate() (line 49 of  .../sites/all/modules/addressfield_egypt/plugins/format/addressfield-estonia.inc)

code is

/**
 * @file
 * A specific handler for CH.
 */

$plugin = array(
  'title' => t('Addressfield optimized for Estonia'),
  'format callback' => 'addressfield_format_address_et_generate',
  'type' => 'address',
  'weight' => -80,
);

function addressfield_format_address_et_generate(&$format, $address, $context = array()) {
  if ($address['country'] == 'EE') {
    unset($format['street_block']['premise']);
    $format['street_block']['#attributes']['class'][] = 'addressfield-container-inline';
    $format['street_block']['thoroughfare'] = array(
      '#title' => t('Address'),
      '#size' => 30,
      '#required' => TRUE,
    );
    $places = _addressfield_estonia_places();
    $counties = array_keys($places);
    $format['locality_block']['administrative_area'] = array(
      '#title' =>  t('County'),
      '#required' => TRUE,
      '#prefix' => ' ',
      '#render_option_value' => TRUE,
      '#attributes' => array(
        'class' => array('administrative_area'),
        'x-autocompletetype' => 'administrative_area',
        'autocomplete' => 'administrative_area',
      ),
      '#weight' => -10,
      '#empty_value' => '',
      '#options' => array_combine($counties, $counties),
    );
    $format['street_block']['#weight'] = 80;
    $format['street_block']['postal_code'] = $format['locality_block']['postal_code'];
    unset($format['locality_block']['postal_code']);
    $format['street_block']['postal_code']['#weight'] = 100;

$locality = $address['administrative_area'] ? $places[$address['administrative_area']] : array();
***$format['locality_block']['locality'] = array(***
  '#title' => t('City/Parish'),
  '#type' => 'select',
  '#options' => array_combine($locality, $locality),
  '#empty_value' => '',
  '#required' => TRUE,
  '#render_option_value' => TRUE,
);
if ($context['mode'] == 'render') {
  $format['street_block']['postal_code']['#prefix'] = '
';
  $format['locality_block']['locality']['#suffix'] = '
';
  $format['locality_block']['administrative_area']['#suffix'] = ', ';
}
if ($context['mode'] == 'form') {
  if (!isset($format['#wrapper_id'])) {
    $format['#wrapper_id'] = drupal_html_id('addressfield-wrapper');
    $format['#prefix'] = '
';
    $format['#suffix'] = '
';
  }

  // AJAX enable it.
$format['locality_block']['administrative_area']['#ajax'] = array(
  'callback' => 'addressfield_standard_widget_refresh',
  'wrapper' => $format['#wrapper_id'],
);
}

}
}

function _addressfield_estonia_places() {
  $list = array(
    'Harju maakond' => array(
      'Keila linn',
      'Loksa linn',
      'Maardu linn',
      'Paldiski linn',
      'Saue linn',
      'Tallinn',
      'Aegviidu vald',
      'Anija vald',
      'Harku vald',
      'Jõelähtme vald',
      'Keila vald',
      'Kernu vald',
      'Kiili vald',
      'Kose vald',
      'Kuusalu vald',
      'Nissi vald',
      'Padise vald' ,
      'Raasiku vald',
      'Rae vald',
      'Saku vald',
      'Saue vald',
      'Vasalemma vald',
      'Viimsi vald',
    ),

);
  return $list;
}

Would you please inform me where is problem as i'm not PHP expert?

Thanks in advance for your sincere cooperation.


texts: Rate/VotingAPI - Add class to button if user has voted

texts:
I want to add a class to a button after the user has voted to display another picture.

This was posted here as a solution for Drupal 6.

<?php
  // Print all rate buttons
  foreach ($links as $link) {
    if ($results['user_vote'] == $link['value']) {
      // user has voted
      $class = 'voted';
    }
    else {
      // user has not voted
      $class = 'not-voted';
    }
    print theme('rate_button', $link['text'], $link['href'], $class);
  }
?>

I couldn't get it to work, so I assumed that I had to convert it to D7 first. However, I have no skills of converting code, so a little help would be nice.


texts: D8 - Twig naming for content type failing

texts:
I have a content type I added with the machine name news.

Per this post and this page I have set up node--news.html.twig pushed to Acquia successfully and cleared all caches.

The answer on this post says my file name should work.

This page says same thing: "Content specific node templates is simple - node--[content-type-machine-name].html.twig, e.g. node--article.html.twig, clear the cache."

I have twig debugging enabled and if I add page--node--336.html.twig it works as expected.  Debugging output using node--news.html.twig:

<!-- FILE NAME SUGGESTIONS:
   * page--node--336.html.twig
   * page--node--%.html.twig
   * page--node.html.twig
   x page.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/fimc/templates/page.html.twig' -->

I have also tried page--node--news.html.twig with no success.

What am I doing wrong?


texts: How do I delete existing payments from a Commerce Order when user presses go back button?

texts:
Using Commerce Kickstart 2.

A customer selects a Payment type at /checkout/123/payment
Then he/she goes to Review /checkout/123/review

If the customer hits 'Go Back', the previous payment is still in the system. Obviously, what we want is to clear out the previous payment data connected to the order so that only one payment transaction is present for any given order at any given time.

I looked in Rules and there is a reaction rule called component_rules_payment_component_delete_all but what it seems to do is zero out previous payments not actually remove them, which seems wrong. We want to delete any payments until the last one when the order is completed.

So... where do I hook into (and what function do I call) to delete payment data for the current transaction id when the user hits the Go Back button?


texts: Handling dynamic URLs through my custom module

texts:
I have written a custom module and have defined a menu inside the module as test. This menu uses a function named mymodule_test() to render contents. The code written for this menu is working perfectly OK and I am getting expected output on /test page.

Now, I want to define some more menus that use the same mymodule_test(). I understand that I can define more menu items in the mymodule_menu() as below.

$items['test-1'] = array(
  'title' => 'Test',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('mymodule_test'),
  'access arguments' => array('administer mymodule'),
  'type' => MENU_NORMAL_ITEM,
);

However, I am planing to use more than 100 such menu and believe this is not the best way to achieve this. Please guide me in the right direction to achieve the same.

This is to note that these menus will be dynamic in nature so I cannot hard code it in the module file.

I am using Drupal 6.


texts:
Views 2 for Drupal 6 had settings for the arguments passed to a view.
Does Views 3 for Drupal 7 still have those settings? Have those settings been renamed, or removed?

This is the partial screenshot that I see when I edit the taxonomy term view (the screenshot appears blur because I resized it to 70% of its original dimensions).

If this makes any difference, the screenshot is for the development snapshot of Views (7.x-3.x-dev), used together the development snapshot of Chaos Tools (7.x-1.x-dev).


texts: Drupal custom module code working differently for logged in users and anonymous users

texts:
I have the below simple if else condition for a custom module form page in buildForm method for recommendation submission. I would like my form to be displayed to all user who visit for the first time and submits and cannot submit again from the same url. If the url is used again it should just display the thank you message(if already submitted). The below code wrks perfectly if the user is logged in. Like if the user is logged in, he comes and submit, thank you message is displayed everything is saved in DB correctly. The problem comes when anonymous user comes. The page loads as expected. But after filling up the details and submit button is clicked. It reloads and the same form is displayed again(instead of the thank yo message) and then if I submit again it displays validation errors even though the fields are there and gives the thank you message. Can anyone explain me why its behaving differently for logged in and anonymous users.

    public function buildForm(array $form, FormStateInterface $form_state)
    {
       if($this->CheckRecommendationStatus())
       {
          $form = array();
          $form['form_label'] = [
          '#type' => 'processed_text',
          '#text' => t('<h3Thank you already submitted
'),
          ];
        }
        else if($this->validateUrl())
        {
           $form = array();
           //it will have controls and submit button.if submit is clicked those values will be saved
        }
        return $form;
     }
     //This below method check the Database whether already the submission is made or not
     public function CheckRecommendationStatus()
     {
           $this->setUniqueIdentifier(htmlspecialchars($_GET["rec"]));
           $query = \Drupal::database()->select('m_tablename', 'mr');
           $query->fields('mr',array('id'));
           $query->condition('mr.column_name',$this->getUniqueIdentifier());
           $query->range(0,1);
           $results = $query->execute()->fetchAll();
           return $results;
     }


texts: How to get user statistics for charts and graphs?

texts:
Q: How can I get statistics of specific user fields?

I want to display a chart using the answers users have provided in their profile. It should appear on the landing page.

Something like

Age
favorite color
month of registration

I have tried to get data from public fields but I can't figure out how to do so with field data that is not visible to unregistered users.

I appreciate any help.


texts:
I enabled the forum module, and when I add a comment on a forum post, there is no body field. I disabled both the Comment and the Forum modules, and re-installed them, but I still have the same problem.

If I manually create a body field (field_comment_body), I get the following error message:

  Notice: Undefined property: stdClass::$comment_body in comment_admin_overview() (line 107 of /var/www/lms/modules/comment/comment.admin.inc).

Is there any solution to make the comment body appear as it happens with other content types?


texts: How do I define a computed field equal to the concatenation of two fields of my custom entity?

texts:
I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, userID, created, changed. I created it with baseFieldDefinitions.

I want to have a computed field nomprenom = nom ." ".prenom
Here is the corresponding code:

$fields['nomprenom'] = BaseFieldDefinition::create('string')
  ->setLabel(t('Nom et Prénom'))
  ->setComputed(TRUE)
  ->setClass('\Drupal\association\NomPrenom');

The code of class 'NomPrenom' is here:

/**
 * @file
 * Contains \Drupal\association\NomPrenom.
 */

namespace Drupal\association;

use Drupal\Component\Utility\String;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\TypedData\TypedData;

/**
 * A computed property for defining 'Nom Prénom'.
 */
class NomPrenom extends TypedData {

  /**
   * Cached processed value.
   *
   * @var string|null
   */
  protected $processed = NULL;

  /**
   * Implements \Drupal\Core\TypedData\TypedDataInterface::getValue().
   */
  public function getValue($langcode = NULL) {
    if ($this->processed !== NULL) {
      return $this->processed;
    }

    $this->processed = $this->get('nom')->value ." ". $this->get('prenom')->value;
    return $this->processed;
  }

  /**
   * Implements \Drupal\Core\TypedData\TypedDataInterface::setValue().
   */
  public function setValue($value, $notify = TRUE) {
    $this->processed = $value;

    // Notify the parent of any changes.
    if ($notify && isset($this->parent)) {
      $this->parent->onChange($this->name);
    }
  }

}

When I try to add a new Person, I get a PHP Fatal error:

  Call to undefined method Drupal\association\NomPrenom::setLangcode()

Why?


texts: How to store Views templates with a module instead of a theme

texts:
I have created several views templates that are currently stored in my active themes directory.  In would prefer these templates be stored within my module directory.

My question is, how can I bring these theme files (views-view-field.tpl.php for example.) into my modules directory and have them be seen by Views?

Looking at the Views modules, I can see that default templates are stored in views/theme, but I don't see how it has been implemented.


texts: How can I modify a user's last access date using Rules?

texts:
Goal

I want to make a Rule that automatically changes the user account last-access date to "now" for certain users.

Use case

I have a view that displays users by last access date, but I need some users to consistently appear near the top of the search results.  Previously, I simply assigned all the users that I needed at the top to a specific role, and then sorted the view so that that role came first, but the problem with such an approach is that the same users always appear at the top in the same order.  I want the order to look a bit random, so I want to update the access date with a rule that automatically re-schedules itself every x hours.

Problem

I can write a rule that re-schedules itself.  However, to update the "last access" date, when I use the Set a data value action, I receive the following message:

  The selected data property doesn't support writing.

How can I get around this and refresh the last access date in Rules?  I can write a custom rules action if necessary, but I don't know what to put in the action to reset the access date.


texts: Why do I get a backup file that has three different sizes?

texts:
I am using Drupal 7 site on a remote server (bluehost). I cleared the cache before the backup.

When I am using the backup and migrate module, and use admin -> config -> back up - the size of the file is 456 kb.
When I am using the my php admin interface, and Export the specific database - the size of the file is over 22 MB.
When I am looking at the database interface of bluehost, it's written that the same database is over 176 MB.

I know that I am missing something, but I can't figure out the answer.

What is the difference between the databases? Which one should I save?


texts: Create tar.gz file after image style is generated

texts:
I would like to achieve this effect: When an style image is saved, a tar.gz file containing that image is generated in the same directory containing the style image.

How can I achieve this?


texts:
I have a custom view for editing contents for the authors. When I'm logged in as a use with this author role this view is displayed with the 'frontend' theme. But I need it displayed in 'backend' theme.

I absolutely don't know how to get this view displayed in another theme.


texts: Get list of webforms that can be created by the current user

texts:
Testing Webform in Drupal 8, I've found something strange when trying to get the list of the available webforms that a user can create.

My test environment: I've created a role, a user that belongs to that role and 3 webforms. In the "Access" tab of each of the webforms I've unchecked "Anonymous user" and "Authenticated User" and allowed access only to "Administrator" in 2 of the webforms. In the last one, I gave "create" access to my specific role.

Then, for testing purposes I created a rest service with the following code:

public function get()
{
    // Load all the available entities
    $entities = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple(NULL);

    // Check the access of the current user to each of the entities
    $forms = array();
    foreach( $entities as $entity_id => $entity )
    {
       $forms[] = array( "$entity_id" => $entity->access('create', NULL) );
    }

    return new ModifiedResourceResponse($forms);
}

I expected to get:

[{"webform1":false},{"webform2":false},{"webform3":true}]

But I get:

[{"webform1":false},{"webform2":false},{"webform3":false}]

In fact, I returned the $entity object as JSON and I found that the entity references the following permissions: "create", "view_any", "update_any", "delete_any", "purge_any", "view_own", "update_own", "delete_own". If I expand the tree, then I can see that inside the "create" permission of my webform3 entity, the permissions are properly referenced (Object->access->create->Roles->My Role is present only in the last form).

But the ->access('create') function is always returning false. The same goes for "view_any" and the other permissions. The only permission that returns true for all the forms is "view".

Is there any way that I can do this? :

    $entities = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple(NULL);
    $forms = array();
    foreach( $entities as $entity_id => $entity )
    {
       if( $entity->access('create', NULL) )
       {
           $forms[] = $entityid;
       }
    }
    return new ModifiedResourceResponse($forms);

Thanks and best regards.


texts: How can I ensure that availability calendar only show one month at a time?

texts:
I'm displaying a calendar on a basic page and I have specified that I want the monthly views to show only 1 at a time.  1 per col / 1 per row.

For some reason 3 are displayed.

my calendar can be seen at seosolutions.london

How can I only display 1 month at a time? can I hard code this anywhere?


texts:
I need to reorder my views results before display it.

This is my query

SELECT
commerce_product_field_data_field_magazine__field_data_field_numero.field_numero_value AS commerce_product_field_data_field_magazine__field_data_field, node.nid AS nid
FROM
{node} node
LEFT JOIN {field_data_field_magazine} field_data_field_magazine ON node.nid = field_data_field_magazine.entity_id AND (field_data_field_magazine.entity_type = 'node' AND field_data_field_magazine.deleted = '0')
INNER JOIN {commerce_product} commerce_product_field_data_field_magazine ON field_data_field_magazine.field_magazine_product_id = commerce_product_field_data_field_magazine.product_id
INNER JOIN {field_data_field_tipo} field_data_field_tipo ON node.nid = field_data_field_tipo.entity_id AND (field_data_field_tipo.entity_type = 'node' AND field_data_field_tipo.deleted = '0')
LEFT JOIN {field_data_field_numero} commerce_product_field_data_field_magazine__field_data_field_numero ON commerce_product_field_data_field_magazine.product_id = commerce_product_field_data_field_magazine__field_data_field_numero.entity_id AND (commerce_product_field_data_field_magazine__field_data_field_numero.entity_type = 'commerce_product' AND commerce_product_field_data_field_magazine__field_data_field_numero.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('magazine')) AND (field_data_field_tipo.field_tipo_value IN  ('rivista', 'dvd')) ))
ORDER BY commerce_product_field_data_field_magazine__field_data_field ASC

and it works fine but I need the same view with a different ordering

ORDER BY ABS(commerce_product_field_data_field_magazine__field_data_field)

because the result's now order like

1 10 11 2 3 4 ..

but I need

1 2 3 4 10 11 ..

How can I achieve this changing of ordering?

ps_ I can't change the text field type to int because I have some value like '5-6'


texts: What is best way to combine multiple fields in template preprocess?

texts: I have 3 fields I want to join into one line to wrap inside some tags.  Is template.php in a preprocess function the best place to do this?  I won't need the fields after I join them, so I assume I call hide() on them as well?


texts:
I'm trying to make a simple "Filter By..." option section for a View such that when someone wants to narrow results they can do so by clicking a checkbox or link and getting a shorter list, narrowed by their choice option.  One sees this all the time in online shopping, where you filter products by brand, type of item, price, etc., to narrow down the list to something close to what you're looking for.

Is this done by creating (for example) 8 separate clones of the View, then adding a filter on each and linking to this new view??  Or can this be done as a function of the one lone View itself?

It's easy to see this working for "products" being filtered by "cameras," "lenses," "brand," and "price."  4 new clones with different filters added to each to display the properly sifted results.  Link to the new sub-view and voila.

That was my approach.  Then I realized the gotcha is that if I want to have "Lenses" and a "Price" category...or "Cameras" with "DSLR" or "Point and Shoot" AND a Price category...suddenly this gets to be a nightmare of dozens or even hundreds of cloned views.

I have a hunch that Drupal's got this covered in a far easier way.  Is there a module that allows me to make a simple block that will have a toggle for different categories?


texts: Passing extra image data (EXIF date) to the browser upon adding an image in a form

texts:
I am currently using EXIF module to import the DateTimeOriginal tags but it does not display the tag in the form right after uploading the image and I would really prefer to see that info while still filling the form as it affects what I should fill in manually.

I noticed that the image size is displayed next to the image file name after the image has been uploaded, found the code in core/modules/image/image.field.inc that basically hard codes what will be rendered to be sent back to the client in an ajax response. I added a call to exif_read_data() right there and appended my DateTimeOriginal tag after the file size and it works fine!

But surely editing core files is not the right way to do that - there must be some hook to use but I can't seem to figure out which one. Besides I would prefer my tag (and maybe other info like image width and height etc) to be neatly accessible via js on the client to update other fields in the form dependent on it.

I would appreciate any advice on what is the right place to put that code.


texts:
D7 content type with file field. On edit page, displays attachment(s) with Remove button, but cannot remove. Get blue "spinner" for a few seconds.

Also issue with upload of file field. Upload action get blue "spinner", then no indication of file uploaded. If you SAVE node, file is attached.

No errors in D7 error logs or in PHP logs.

Was wondering if this is jquery version related. Anyone else experience same problems?


texts:
I'm using Media, version 7.X, and I'm looking for a module that creates a display widget as a gallery for a "file" field.

I'v tried Media Gallery but I can't use "dev" versions.

Any suggestion?


texts: Centering resizable images in recursive divs with CSS

texts:
I'm working on theming an image gallery content type I created through which a user uploads several images and as a result see a list of images on the page.

I use Responsive Images and Styles module so the images don't have a fixed size. The effect I want to have is that these images align in a row and are always centered, having equal spaces/gutter width between them, regardless of browser resizing. So adding media queries the final result will be a one column page, so one image top of another, in iPhone viewport and three-four column page, images lying side by side, on a desktop screen.

The complicated part is Drupal has so many divs one inside another and I'm not sure if I'm following the right steps to achieve this effect. Though it could be simple it became problematic with these recursive divs.

So if someone can guide me through these divs and help me figure out how to achieve this aligment I would be really grateful. Every reply is important for me so don't hesitate to come up with comments and solutions of every kind.

Thank you in advance!


texts: How to set defaults for a custom Views display?

texts:
I'm maintaining a module that provides a new type of Views display (extending the built-in views_plugin_display_page).

When the user chooses to add my type of display, I'd like to set up some sensible defaults, like creating a default url path, a default display_title, and some defaults for the additional options my module defines in the display's options_form.

How do I set these defaults?


texts: Services 3 JSON format [null] at end of all result

texts:
I am using services module recently i have noticed that i am getting all responses along with [NULL] at the end. So my app dev team is unable to parse the JSON.

What i am doing wrong ? What may be the possible causes for this ?

I think it happens with my custom module only.
But i am sure i am using  drupal_json_output with sufficient parameters.

I have posted this question a few weeks ago, but my app dev tem fixed it. Now i am facing it again. Any help ?

/**
 * Implementation of hook_services_resources().
 */
function noteresource_services_resources() {
  return array(
    'gymcam' => array(
      'actions' => array(
        'sendmail' => array(
          'help' => 'Send gymcam to admin',
          'callback' => 'gymcam_sendemail',
          'access callback' => 'gymcam_resource_access',
          'access arguments' => array('sendmail'),
          'access arguments append' => TRUE,
          'args' => array(
            array(
              'name' => 'uid',
              'type' => 'int',
              'description' => 'The uid of the logged in user',
              'source' => 'data',
              'optional' => TRUE,
              ),
          ),
        ),
      ),
    ),
  );
}

function gymcam_sendemail($data) {
  $data = array('status' => 'error', 'msg' => 'Mail not sent');
  drupal_json_output($data);
}


texts:
I am trying to call ajax call within form. here is my code

<?php

function clicktell_form_alter(&$form, &$form_state, $form_id) {
    //print_r($form);

    if($form_id=='user_register_form') {

        $form['choice_wrapper']['poll_more'] = array(

            '#type' => 'submit',

            '#value' => t('More choices'),

            '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),

            '#weight' => 1,
            "#executes_submit_callback" => FALSE,

            '#ajax' => array(

                'callback' => 'poll_choice_js',

                'wrapper' => 'poll-choices',

                'method' => 'replace',

                'effect' => 'fade',

            ),);

    }
}

function poll_choice_js($form, $form_state) {
    print_r($form_state);
    return $form['choice_wrapper']['choice'];

}

when i click on more choice button it is not calling poll_choice_js function. i checked this in firebug but didn't get any result

Thanks


texts:
I am trying to update multiple flag links on a page. When I update the links the ajax functionality is gone.

This is the code I am trying to use. Any ideas?

$(document).bind('flagGlobalBeforeLinkUpdate', function(event, data) {
var $wrappers = $('.flag-wrapper.flag-' + data.flagName + '-' + data.contentId).not(data.link);
var $newLink = $(data.newLink);
$('.flag-message', $newLink).hide();
$wrappers = $newLink.replaceAll($wrappers);
Drupal.attachBehaviors($wrappers);
});

*edit- I have 2 flag links on a page(the same link). When I click one I want the other link to update. The problem is that the other link doesn't attach to the ajax event.


texts: table content_type_answer show to merge it with node table

texts:
I have a {content_type_answers} and this table doesn't has a title row, how can i merge it with {node} to get node titles?

$result = db_query("SELECT {node}.title, {node}.nid FROM {content_type_answers} cta, node WHERE {cta}.nid = {node}.nid");
while($node = db_fetch_object($result) {
    $nodes[] = array($node->title, $node->nid);
}

Question: how can i select {node}.title from table {content_type_answers} if in this table no title row at all?


texts: Remove field-collection-view and field-collection-container fromt field output

texts:
I am using the following modules:

Paragraphs
Field Collection

I am trying to Foundation 5 classes to re-create the zurb foundation orbit slider with unlimited slides. Initially my problem was limiting what seems to be unnecessary Drupal
 tags and classes so I could control the HTML output as much as possible. My workaround was simply installing Fences which gave me great results. I have the debugging turned on in the settings.php file to just make sure my naming conventions are correct and to make sure my code is outputting correctly. So far it is but with one slight problem.

So far I have spent days trying to nut out why the output of my field collection "field_add_image" is rendering a containing div of
, nested within that is another containing div which the field collection out is located. Each item is nested within another div tag like so
. This has an unlimited field which can be added to a paragraph item.

I went into the field collection module to identify where the classes to these containing div's were added which seem to be using the field_collection_field_formatter_view() which I found in the function within the module file.

I have installed Fences as well, which may be conflicting. the settings of Fences is set to:

Override the default wrapper markup with Fences lean markup (single
div wrapper)
Use Drupal's default classes" set as the default classes

All the fields are outputting the correct HTML output which is great, but for the life of me I cannot remove those two containing divs.

Here is the folder structure of the files I have copied from the systems folder within Drupal core and placed in templates folder. Below is the naming conventions I used with the machine names.

Theme name

jacob_d7_theme

Field collection name

field_add_image

Paragraph Bundle

paragraphs-item--scrolling_image.tpl.php code below

<?php print render($content['field_add_image']); ?>

Fields in field_add_image

Banner Image: field_3_col_img1
Caption:  field_caption

Templates folder includes

Paragraphs

paragraphs-item--scrolling_image.tpl.php

All code in document

<?php print render($content['field_add_image']); ?>

Fields

field--field_add_image.tpl.php
field--field_caption.tpl.php

Both of these field files have the same code in them to remove any unneccesary div containers for fields.

<?php foreach ($items as $delta => $item): ?>
<?php print render($item); ?>
<?php endforeach; ?>

I have also experimented with but with no avail.

field--field_add_image--scrolling_image.tpl.php
field--field-add-image--scrolling-image.tpl.php

I am not sure what I am missing as all the custom template files that I have made work they just keep getting contained by those two divs.


texts: Add to cart link for product that sends user directly to checkout?

texts:
I'm working on a Drupal 6 site with Ubercart 2.9. I need to create a link for a single product that adds that product to the cart and proceeds directly to the checkout page. The link would be in an email blast, and by clicking it the user would completely skip the product's node/page, would skip the Cart page, and would be deposited directly onto the Checkout page where they can enter their payment/shipping info and proceed.

Possible? If so, how?


texts:
I'm trying to setup a drupal 7 multisite using subfolders for example:

example.com/site1

example.com/site2

In my drupal sites folder I have sites1 and sites2 according to sites.php I should be able to set it up as the following:

$sites['example.com/site1'] = 'site1';
$sites['example.com/site2'] = 'site2';

However this doesn't work, I can definitely see a site at example.com but am unable to see any of the sites in the sub folder.


texts: Custom template for a specific page within module for Drupal 7

texts:
I'm writing a module for Drupal 7 that gives every user with the right permissions a new page in his profile. I want this page to only display the Drupal header and a div with a specific ID, for a JS web app to attach itself to. AFAIK, the easiest way to do this would be by using a template file that only prints those two things.

From what I read in Create a template for a custom page in Drupal 7?, I just need to create a page--user--%--POD.tpl.php file, which I have
 (the new page resides at the path user/%/POD). I have als added this file to my .info file.

name = Module with some template problems

...

files[] = page--user--7--POD.tpl.php

As a way of minimizing factors, I've started by creating a page for user 7 only, but this will have to work for any user eventually. I have uninstalled the module, cleared all caches and reinstalled it again, but it still doesn't get used when I browse to user/7/POD.

Any help would be greatly appreciated.

According to https://drupal.org/node/1089656, the correct hook suggestion that I need to implement would be page--user--POD.tpl.php. I've renamed my template file accordingly. No success yet.


texts: How to query entities/nodes that does not have the field "field_parent" with EntityFieldQuery?

texts:
I'm using the Entity reference module and want to select all nodes that has no parent defined. I'm trying with:

$query = new EntityFieldQuery();
$children = $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'page')
    ->propertyCondition('status', 1)
    ->fieldCondition('field_parent', 'target_id', null, 'IS NULL')
    ->execute();

.. but that does not give anything as the field "field_parent" is missing and not set to NULL. If I use IS NOT NULL I get all nodes that has a parent.

How can I select all nodes that has no parent (or is missing the field "field_parent")?

Thanks to Clive I managed to solve this in the following way:

$query = new EntityFieldQuery();
$children = $query
    ->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'page')
    ->propertyCondition('status', 1)
    ->addTag('filter_no_parent')
    ->execute();

/**
* Implements hook_query_TAG_alter()
*/
function mymodule_query_filter_no_parent_alter(QueryAlterableInterface $query) {
    $query->leftJoin('field_data_field_parent', 'p', 'node.nid = p.entity_id');
    $query->isNull('p.field_parent_target_id');
}


texts: Views contextual filter navigation links?

texts:
Assuming a view with a contextual filter based on a field "category" that is a select list with a limited number of values: what is the best approach to dynamically generate a simple list of links (based on available values) at the top of the view to allow a user to navigate the categories? I want to expose the values as links and keep the clean url structure that contextual filters create. See screen below for reference.

In the past, I've hacked together a basic hard-coded solution using hook_views_pre_render and the l() function, but I'm wondering what the best practice would be.


texts:
I suppose this is something about theming, but I haven't found a way to do this. I'm using the Pixtures Reloaded subtheme of Adaptive Themes.

I have a group of pages that need to have the structure:

     Pretitle
     Title
     Subtitle
     Body

that should come out looking like this:

A true story:
               The Amazing Thing
              And Why it's Amazing
This is the story of...

The title and subtitle are centered.

When I create a "Basic page", I have to specify a title for the page, and that title is displayed at the top-left of the page. I tried two ways to get something to be shown before the title.

First I defined a block called "Pretitle" and placed it in the theme's region called "Secondary content", which in the "Block region demonstration" is shown as being above the title. But when I displayed the page, the pretitle was exhibited under a big banner that said "Pretitle". That's not okay.

Next, I deleted that and defined a text field called "Pretitle" and placed that above the title in the Field Manager. When I displayed the page, the pretitle appeared at the very bottom of the page, under a line that said "Pretitle:". Again, not okay.

Aside from not seeing how to get a line of text to appear before the title (without a banner saying that it's a pretitle), I also have not a seen a way to get the title to be centered horizontally on the page.

I'm guessing this problem is because there's something really simple about composing pages in Drupal that I don't know about. Can you tell me what I'm missing?

Please don't give an answer that requires writing my own module because I'm not nearly ready to do that yet.

Thank you.


texts: How do I incorporate a browser file search into a Drupal form?

texts:
This question extends a previous one. The previous answer stated that the pop-up window to search the user's computer for a file to upload is called using .  I am not certain how to make the call from within the form_submit function and have searched the core code for an example without success.  I know that add content has a widget to add an image file, but I cannot find the code generating it. I even did a file search for the word "Browse" which is the title of the button without finding a single file.

Does anyone have an example of how I would direct a call to a browser function from within the Drupal form?  OR Does anyone know where the add content form widget for adding a file is at?


texts: Theme preprocess for module's template variables using dynamic path

texts:
I am doing templating for a module that adds a block in the module's folder so that the template can be there, and it may be overridden in the theme if desired. I want the module to support different "sources" (but only one will be active/used at a time), which may each have a separate template and variable preprocessing. I have hook_theme() working, and the template works. But the .vars.php file I have contains the preprocess function, and it doesn't get called.

Here is a basic example of what I have:

/MODULE.module

function MODULE_theme($existing, $type, $theme, $path) {
  $source = '';
  switch ($source) {
    case 'SRC_A':
      $path .= '/sources/SRC_A/theme';
    default:
      $source = 'default';
      $path .= '/theme';
  }

  return array(
    'MODULE_block' => array(
      'path' => $path,
      'variables' => array('data' => array(), 'source' => $source),
      'template' => 'MODULE-block',
    )
  );
}

/MODULE/sources/SRC_A/theme/MODULE-block.tpl.php

(contains template HTML with references to PHP variables)

/MODULE/sources/SRC_A/theme/MODULE-block.vars.php

/**
 * Implements template_preprocess_HOOK() for theme_MODULE_block().
 */
function template_preprocess_MODULE_block(&$vars) {
  // Add variables before they get to the template file.
  $vars['some_key'] = 'some_value';
}

I originally was trying to modify the $template value in hook_theme() to MODULE-block--SRC-A, but I decided that didn't matter, and if only one template is active at once I should just call them all MODULE-block.tpl.php regardless of the source, since they are all in different folders.

The template works, and adding a template in my theme will correctly override it. But the .vars.php file with the preprocess function does not seem to do anything unless it is in my actual theme and is THEME_preprocess_MODULE_block instead.

I'm still pretty new to this, but I looked at a lot of pages online, and there aren't any similar examples in my code base that have a module-specific .vars.php file that is located in the module's folder rather than in the theme.

I do not know what I am doing wrong. Any ideas?


texts: Block body translation for Full HTML content

texts:
After block creation and put HTML content in body field I can't translate this content because of:

  The string blocks:block:1:body for textgroup blocks is not allowed for
  translation because of its text format.

If I change to plain text I can translate block but it is treated as plain text while displaying. Do I have to create another block with the same HTML content (translated) and select to display only in specific language?


texts: How to programmatically check whether field on form has changed in hook_form_alter

texts:
In rules you have the ability to check whether a field in a form has been changed by negating node-unchanged:field-xyz = 123.

I want to check whether a field has changed programmatically with the $form and $form_state.

How would you do this?


texts: Problem with integer field format in Drupal 7

texts:
I just created an integer field for one of my content types. I'm using it to display a value for a year. However, when it is displayed, it is putting in a space between the 1000s column and the 100s column; so, for example, "1991" is displayed as "1 991".

I'm guessing this is something to do with the formatting of the field. Can anyone tell me how I can correct this or change the formatting?


texts: Make a copy of the live site for localhost testing

texts:
I'd like to copy my live site so I can run it on localhost and test some modules before installing them on the livesite.

Is there a step-by-step way to do this? I have access to PHPyAdmin, so I can easily export the database. I know there's more to it than just exporting, thought.


texts:
We have a custom module, mymodule, that we are using to create a custom block programmatically. We tried to do the following and it does enable the module successfully, but i get the following warning.

What is the argument that needs to be passed in?

  Missing argument 1 for mymodule_update_8501()

mymodule.install

function mymodule_install() {
  // Run update on install.
  mymodule_update_8501();
}

function mymodule_update_8501(&$sandbox) {
  // Do something.
}


texts: How can I overwrite existing menu tree manipulators?

texts:
Or: how can I prevent unpublished nodes' menu items to be removed in the menu select when the user does not have the bypass node access checks permission, but may actually edit various unpublished nodes?

Im facing the problem that in the node form, the menu item options are missing some menu items because the related node is unpublished although the user may actually see and edit those nodes.

In /core/lib/Drupal/Core/Menu/MenuParentFormSelector.php the function getParentSelectOptions builds the options list which is then used in the node edit forms.

The function is:

  /**
   * {@inheritdoc}
   */
  public function getParentSelectOptions($id = '', array $menus = NULL, CacheableMetadata &$cacheability = NULL) {
    if (!isset($menus)) {
      $menus = $this->getMenuOptions();
    }

    $options = array();
    $depth_limit = $this->getParentDepthLimit($id);
    foreach ($menus as $menu_name => $menu_title) {
      $options[$menu_name . ':'] = '<' . $menu_title . '>';

      $parameters = new MenuTreeParameters();
      $parameters->setMaxDepth($depth_limit);
      $tree = $this->menuLinkTree->load($menu_name, $parameters);
      $manipulators = array(
        array('callable' => 'menu.default_tree_manipulators:checkNodeAccess'),
        array('callable' => 'menu.default_tree_manipulators:checkAccess'),
        array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
      );
      $tree = $this->menuLinkTree->transform($tree, $manipulators);
      $this->parentSelectOptionsTreeWalk($tree, $menu_name, '--', $options, $id, $depth_limit, $cacheability);
    }
    return $options;
  }

The critical part in that function is the manipulator
 'menu.default_tree_manipulators:checkNodeAccess'.

The manipulator (/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php) does the following thing (public function checkNodeAccess):

if ($this->account->hasPermission('bypass node access')) {
  $query->accessCheck(FALSE);
}
else {
  $access_result->addCacheContexts(['user.node_grants:view']);
  $query->condition('status', NODE_PUBLISHED); // <<< wtf?
}

TL;DR

So it assumes "either a user may bypass all node access checks or hide all unpublished nodes from the menu select" - which is weird...

How can I overwrite this?


texts: how can I get a list of all of the permissions a user has?

texts:
if I have the current user object, how can i get a list of all of the permissions he has in drupal 8 custom module ?  I dont want to check for one particular permission which would be $current_user->hasPermission("permission_name").

I want to get the entire list of his permissions.

thanks


texts: Sub-directories in module's templates directory

texts:
I have created a module in Drupal 8, which contains a large number of custom templates - these only theme the module's output, and don't override existing template files.

I would like to place these templates in sub-directories of the module's templates directory - for example:

templates/account
templates/orders
etc

If I place a template in a sub-directory, and set the renderer to use a #theme such as 'account/list_block' then the block doesn't render at all, but I get no errors.

However, critically, if I keep my template in the subdirectory but change #theme back to 'list_block' I get the following error:

Template "modules/contrib/mymodule/templates/list-block.html.twig" is not defined
(Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "modules/contrib/mymodule/templates/list-block.html.twig"
 in the Drupal theme registry.).

Doing the above to deliberately break things would indicate that in the first example Drupal knows the template exists, and where to find it (in the account sub-directory of templates), but is choosing not to render it. Very odd.

Is what I'm looking to do possible?


texts: How can I alter variables sent to a paragraph bundle template within a module?

texts:
I need to preprocess the field values of a paragraph bundle to "send" additional variables
to the template (paragraphs-item--xxxx--full.tpl.php). I want to avoid putting too much php logic into the paragraph template.

I am searching for something similiar to the node_view hook for a paragraph item. Is there a fitting mechanism or maybee a module providing such an hook?


texts:
I'm trying to convert old code written in standard HTML/PHP/Javascript/JQuery into a format (more) consistent with Drupal. The code consists of a form with interactive elements (regulated by Javascript functions) and a table produced with AJAX that can be manipulated (column sorting, page selection) with AJAX. I'm currently having trouble with Drupal AJAX.

I initially tried to simply use a callback function, but it seems that AJAX does not work from a callback. Here's some info (although it's D8, not D7). The following demo code fails to attach AJAX (verified with developer web inspector) but successfully creates the textfield element.

<?php

function test_main_form($form, $form_state) {
  $form['test1'] = array(
    '#type' => 'textfield',
    '#name' => 'test1',
    '#ajax' => array(
      'callback' => 'my_callback_function',
      'wrapper' => 'my_target_area',
      'method' => 'replace',
      'event' => 'blur',
    ),
  );
  $form['my_target_area'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );
  return $form;
}

function my_callback_function($form, $form_state) {
  $form['my_target_area'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );
  $form['my_target_area']['result'] = array(
    '#type' => 'markup',
    '#markup' => 'You have selected: ' . $_POST['test1'] . '
',
  );
  $form['my_target_area']['test2'] = array(
    '#type' => 'textfield',
    '#name' => 'test2',
    '#ajax' => array(
      'callback' => 'my_callback_function',
      'wrapper' => 'my_target_area',
      'method' => 'replace',
      'event' => 'blur',
    ),
  );
  return $form['my_target_area'];
}

After additional digging, I found that the advised method (following Examples module, ajax_example -> add_more) uses $form_state['rebuild'] = TRUE
which reloads the entire page, allowing form elements to be included/excluded based on prior inputs. This could work, but my current code depends heavily on Javascript functions, some of which create custom form elements that would be reset/removed by $form_state['rebuild'] = TRUE. It is significantly more difficult to implement the form rebuild than a callback function. Is there any way to include AJAX within a callback function?


texts: How do I append HTML after a form title?

texts:
This is the output I want:

Name!

The only way I can think of is to concatenate my HTML to the form title value

'#title' => t('Name') . '!',

This kind of works, but is ugly: the output is:

Name!

The #suffix property won't do because it adds my HTML outside of the form element's wrapping div.

Any ideas. Thanks.


texts: Hide flag field from certain nodes in view

texts:
I'm new to Drupal, so I may be missing some "obvious" things

I've installed the flag module, so users can flag their content to make it appear on top of other views. The thing is, when I display the list of content to the user (including both published and unpublished nodes), flag shouldn't be available if the node is unpublished

I tried to alter the view using the hook hook_views_pre_render, but I don't seem to have access to the flag content for removing (I guess my hook is being called after the flag hook, but I'm not certain about that). I tried this:

function mymodule_views_pre_render{
  switch ($view->name) {
    case 'usernodes':
      foreach ($view->result as &$row) {
        //Custom field with publish states, 3 means it is published
        if ($row->field_publish_state[0]['raw']['value'] !== '3') {
          //Unset the two values related to flags I could find
          unset($row->flagging_node_entity_id);
          unset($row->flagging_nodeuidisnotnull);
        }
      }
      break;
  }
}

But the flags are still rendered

What I think could work:

I could use the hook hook_views_post_render, and edit the second parameter ($output) but it feels wrong to actually override the HTML output (it would become a messy code)
I could change it using some Javascript, when the page loads, but it doesn't feel right
Using Views PHP and then inserting a Global PHP field (as noted by code.rider below), but users have access to views and they could make a mess with that field

What would be the best way to hide the flag field for certain rows?


texts: Adding an editable field to a custom block module

texts:
I have a custom module that registers a 'block' and echoes some HTML content.

I want to make this customisable to admin users, which means enabling 'Configure' for the block: with one textfield, and a drop down when you can select a node of a specific type.

How do I go about starting this:
A) Enabling 'Configure' for the block
B) Choosing/Coding Fields that store variables, seen when you click 'Configure'
C) Echo the variables in the block module code

Thanks for your help!


texts: I am using Panels and in that i need one pane not to be shown on certain page. how can i do that?

texts:
I am using Panels and in that i need one pane need not to show on certain page. how can i do that ?

I tried using visibility rule in Pane by using String: Rule Path but it is not working. Please help on how can i achieve this ?


texts: how does links__system_main_menu() work?

texts:
How does the below code work at a high level?

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'),
  ),
));


texts: Accuracy of numbers provided by the "Statistics Advanced" module?

texts:
We use modules Google Analytics and Statistics Advanced, in Drupal 6. It is clear from the numbers that they provide very different readings.

Can anyone give any accuracy analysis for the Statistics Advanced module, perhaps by comparison with Google?


texts: How to submit a field collection from a form into a created node

texts:
I would really appreciate if somebody could help me with this :)

I have a field collection called field_formations. Inside it I have 2 fields:

field_technologies - (reference to a taxonomy).
field_diploma -(how it's also a field collection which contain 2 other   fields:
field_name(reference to a taxonomy)
field_establishement (text plain)
               ).

I've created a form with 3 field forms
technology
diplome_name
establishement

and into the submit form i would like to submit values of this forms into  the node created at first.

I tried to setValues like this :

$node->field_formations->field_technologies->setValue($values['technology']);

but it dosen't work
Can any body have a suggetion??

PS : I'm using drupal 8


texts:
I wish I could provide a more specific example of this, or some event that seemed to trigger it, but here's the best I can do:  I have happily used my admin overlay for most of my CMS work for months now in D7 with the Bartik theme.  And the other day, mysteriously it became the case that when I am browsing my site, I will "fall out" of admin overlay mode sometimes.

I just am suddenly on a page as an anonymous viewer would be, with neither the overlay, nor the standard edit, track, etc. content tabs of an admin user.  I can still hit the back button, to return to it, and I can still directly enter administrative menus, but an occasional page, and not always the same ones, cause me to fall out of admin mode.

Does this sound like any behavior anyone could identify, or help me identify a process in order to identify?


texts: Media Library uploaded images don't get the derivatives generated with the Image Style Warmer module

texts:
I am using Drupal's Image Style Warmer module to generate derivatives for images uploaded to Drupal. But it is only working if the images are uploaded through "Content->Media" tab. I was trying on my localhost.

For images uploaded though the pages themselves using Media Library, when running the Image Style Warmer, it does not create derivative images.

Did notice that for images uploaded through Media Library the permissions look like below (seems I don't have read permission)

For images uploaded through Content->Media tab it has below permissions (these images work). It had my username listed with all permissions.

Both images were created in same folder. So Why does the images have different permissions? also how do they get set? and how would it be fixed (i mean what permissions to set where?)


texts: is it possible to code custom ahah effects?

texts:
I'm just getting into D6's FAPI ahah property and I was wondering - in addition to the "stock" effects, is it possible to use jQuery to create custom effects?
I'm trying to get a horizontal slide.

Thanks!

Stephanie


texts:
There was one very useful contributed module named Hosting Advanced Cron. It allowed me to set cron interval per site, instead of set just global for all (and you can even disable cron on specific sites). hosting advanced cron

For Aegir 3, there is no such release and development seemed to be stopped. There is a fork on Github by omega8cc, but it is not functional (doesn't work, has error and notice, has debug statements left on), so does anyone have a solution or a replacement for such a useful feature for Aegir 3?


texts: Not able to export nodes from one drupal site to other drupal site?

texts:
I have 2 instances of same drupal project, where contents are different. I want to export contents from one drupal site to other drupal site.
I tried content syn module:
      I Was not able import single node having file field value.
    node_export module:
       Not able to import node

Anyone is having any idea, which is the best approach to transfer the contents between 2 drupal sites?

Error when tried with content sysn module:
Symfony\Component\Serializer\Exception\InvalidArgumentException: No "file" entity found with UUID "514d82d9-e933-4be6-9dfb-3435b58d3531" for field "0". in Drupal\content_sync\Normalizer\EntityReferenceFieldItemNormalizer->constructValue() (line 88 of /var/www/html/drupal8/modules/contrib/content_sync/src/Normalizer/EntityReferenceFieldItemNormalizer.php).


texts:
I'm implementing a way for providing documents to different users for download on Drupal 8.

Each document has a category (implemented as own nodes).

Some categories are global.
Some categories are specific for different users.
This is controlled by an additional field you can select a user from.

When creating a new document, only "legal" categories are supposed to be selectable.
Legal are: Corresponding and global categories.

Using Business Rules I'm able to update the list of categories depending of the selected user using a view with a contextual filter.

But I have trouble to add the global categories to the list, independent of the selected user.

Ideally I would make use of two filters combined with and OR condition. But since one of my filters is contextual, I'm not sure if that works.

My next idea would be to "union" two views. One containing only global categories and one containing the specific categories contextual.
But I'm also not sure if that works.

Could someone nudge me into the right direction what's the way to go here?


texts: Can I use hook form alter to add an attribute to a webform field?

texts:
I am trying to use hook form alter to add an onchange attribute to a select field but it is not working. Is it possible or is there something wrong with my module code?

function addonchange_form_alter(&$form, &$form_state, $form_id){
  // target a single form
  if($form_id == "webform_client_form_22"){
    $form['submitted']['company']['#onchange'] = 'changevalue';
  }
}

Thanks for any help.


texts: Render image from $node - no image style applied

texts:
I read tons of solutions how to render an image in a PHPtemplate where I have the whole node in $content, however I don't get how to render it using a $node object, including the given image style etc.

So I got all the code working and can access the node title for example via:

$node->title

How do I generate the proper HTML for this node (in this example the machine tag is field_slideshow_image)?

This line does not work, it gives me a 404 for the image URL:

<img src="<?php print image_style_url('slideshow', $node->field_slideshow_image['und'][0]['uri']); ?>" />

however, it contains at least the name of the actual image…

Update:

I found out that I have to force an image creation if there was none before, so now it works using:

$image_uri      = $node->field_slideshow_image['und'][0]['uri']; // or any public://my_image
$style = 'slideshow';
$derivative_uri = image_style_path($style, $image_uri);
$success        = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);

$new_image_url  = file_create_url($derivative_uri);
echo $new_image_url."

";
echo "";

However, the image style "slideshow" does not get applied! I tried it with the default "thumbnail" and that one works well.


texts: Disable Drush backend messages by default

texts:
I am having a problem with drush backend message, how do I disable "--backend" by default ?

command:
$ drush make drupal-org.make drupal

result:
$ drush make drupal-org.make drupal
DRUSH_BACKEND:{"type":"notice","message":"Command dispatch complete","timestamp"
:1364518974.3749,"memory":6182608,"error":null,"packet":"log"}

 DRUSH_BACKEND:{"type":"memory","message":"Peak memory usage was 6.36 MB","times
tamp":1364518974.375,"memory":6183144,"error":null,"packet":"log"}drupal-7.21 do
wnloaded.    [ok]

everything is working properly but I do not want to see the "backend json" output on the console.

$ drush --version
drush version 5.0-dev

$ git --version
git version 1.8.0.msysgit.0

$ uname -a
MINGW32_NT-6.1 PC 1.0.12(0.46/3/2) 2011-07-20 17:52 i686 Win7


texts:
I have installed 'Ubercart Discount Coupons' module and managed to add a rule to configure the automated discount. But now all the normal code type discounts have stopped working....

Only when I remove the automated discount rule the normal code discounts will works.

I am struck on the production site.

Screenshots:


texts: I want to use my own code to determine if a user has edit access on certain fields.  hook_field_access for Drupal 7 looks right.  Is there a comparable hook for Drupal 6?


texts: How to get url path info into a form variable

texts:
I am creating a module for Drupal 7 that has form that will appear in a block. What I would like to do is get the url for the page that the block appears on (when displayed to the user) and store it in a hidden variable so that it can be processed later. Is this possible and how would you go about doing it?

Thanks


texts:
I keep getting this error message:

  Warning: require_once(): Unable to allocate memory for pool. in Database::loadDriverFile() (line 1742 of /home/site/public_html/includes/database/database.inc).

I am not sure what the problem might be. It started when I installed Varnish 3.0; I couldn't get it to work, so I reverted back to my previous configuration with only APC. Now, I keep getting the message, and it is also visible to anonymous users. I have disabled the system help block from all themes, and turned off error reporting, but it still appears.

I also have mod-pagespeed enabled.


texts: How to add 100 contributed modules into git repository fast?

texts:
I use a git repository, and Drush to manage Drupal projects.

What I would like to do now is to add more then 100 contributed modules to the git repository to keep track on these modules as well.

If I am forced to add contributed modules manually, I have to do the following steps over 100 times:

drush dl <contributed module name>
git add .
git commit -m "<contributed module name> <contributed module version> imported"

I would like to avoid or limit this manual task.
Is there any automated way to do this?


texts: How to process a multiple values field (comma separated) in a Rules Action?

texts:
I am using modules "SMS Framework",Clickatell for sending message and I have configured all the settings which was required. I have also created a rule where node (Article) be saved and send a message.

It is working good when I use single mobile number but unfortunately it is not working when I use multiple mobile number with comma separated.


texts: How do I add a field to a view that shows the user that published the node?

texts:
I am using Drupal 6.22 and the module Revisioning to create an approval process for the creation of new nodes. An "Author" user role can create the initial draft of the content and the "Moderator" user role must sign in to review and approve. Once a Moderator approves the content, they may publish it.

Revisioning does not allow an easy mechanism to display the particular user (of user role "Moderator") that published the content. According to this issue, the maintainer of the module will not build that feature: http://drupal.org/node/611586

I am attempting to create this feature myself. I have installed and configured the Workflow module, as referenced in the thread above. Each node now has a "Workflow" tab that shows the history of the Workflow states and it is possible there to see the username of the user that published the node (along with all other state changes, which my client does not care about). I have not been able to find a way to pull this information into a View field in order to display it in a View.

Is this possible?

I am happy to provide any additional information that may be useful in providing a solution. Thanks!


texts: I'm pretty excited about Drupal capabilities in general and consider it as probably the most solid free CMF with a really powerful API. One of the things I'm concerned about is the resources it takes. A basic installation with localization generates about 90 database tables (WordPress generates  11). Can this be optimized or, if it cannot be, does it really matter, does it affect performance?


texts:
I let anonymous users publish content on my site, but the content must be reviewed before to be  published. The following is my ways to do that:

Using CCK, I created a content type and unchecked the publish option.
I gave the permission to create/edit/delete the content type to anonymous users.

This allows anonymous users to publish the content, but when they save the node they get an "Access denied" error.

What's the difference between what I do and using Workflow module?
Is there a way to redirect the page, and make the anonymous users see the node they created?


texts: Simplenews is not Activated Automatically for Users

texts:
I'm using Simplenews module for newsletters. My newsletter is set to subscribe users automatically on account creation. However the status remains inactivated after creation.

How can subscriptions be automatically activated?


texts:
Can I provide default site's uuid static in Drupal 8. I am using docker with Drupal 8 and during configurations import the site is rebuild with docker resulting in different uuid each time. After that I am not able to import configurations.

Thanks


texts: Wildcard Loader function called multiple times (_load)

texts:
I have a loader function which is called excessively whenever the user accesses the page. Naturally, I only need it to run once per page request, instead, it is called multiple times. Earlier the _load() ran only twice with MENU_CALLBACK, then I tested it with the default MENU_NORMAL_ITEM and it increased to four. Although I've changed it back, and cleared my cache, it still runs four times now, and I only want it to run once.

My question is, why is my loader function being called multiple times? Any insight would be greatly appreciated.

$items['daycare/%isValid/home'] = array(
    'title' => 'Daycare Admin Home',
    'page callback' => 'daycares_home_page',
    'load arguments' => array(0),//Passes 1st part of url 'daycare' as 2nd arg
    'page arguments' => array(0),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
);

function isValid_load($pageID, $pageType){
    /*Do stuff to validate wildcard part of URL. Will throw 404/403 if invalid*/
    return $pageId;
}


texts:
I am building a small custom module that will change the value of a comment's body when the comment in posted. So far I have:

function comment_loader_comment_insert($comment) {
}

So pretty much nothing, just that I want to use hook_comment_insert to change after the comment has been posted.

So what do I need to affect the comment body?

[I am a student who is just learning php and drupal, so clarity is appreciated]

edit:

code so far:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function comment_loader_form_comment_form_alter(&$form, &$form_state, &$form_id) {
  $form['#validate'][] = 'comment_loader_comment_form_validate';
}

/**
 * Implements hook_form_validate().
 */
function comment_loader_comment_form_validate($form, &$form_state) {
  $new_body = 'some text';
  $form_state['values']['comment_body']['#object']->comment_body['und'[0]['value'] = $new_body;
}

Still doesn't have any affect. I am no working in a development environment so I don't know if there are errors.


texts: How to replace "Enter quantity" text for Production variation?

texts:
I'm working on Drupal commerce kickstart.

On Product variation, I need to change the text Enter quantity to Enter your quantities and change Add to Cart to Buy Now.

I tried with form alter it works to change Add to Cart to Buy Now but its not working for Enter quantity to Enter your quantities.

Can any one help on this?


texts: How to get the selected items (with VBO) in the buildConfigurationForm of a custom Action

texts:
I have made a custom action which have a configuration form:

class MyAction extends ConfigurableActionBase

Thus, I have the opportunity to create a form that allows the user to set some options. This form is created inside

public function buildConfigurationForm(array $form, FormStateInterface $form_state)

I need to get the list of the selected items that will be processed at this stage in order for me to exclude some option in the configuration form. In my use case, I need to exclude some option depending of the bundle of the selected entities (by my VBO view)


texts: I need get the MID for specific Entity Drupal 8

texts:
I am using the message module, so I have an entity of type 'message', as for the children I can get the machine name or the Uuid.

The problem I have is that by means of a 'hook_update_n' I need to update a field. The code I am using is:

function hook_update_8001() {

  //Change content in text field for 'caregiver_referral_incomplete'.
  $field_value = array(array('value' => 'Hello My formatted text', 'format' => 'basic_html'));

  entity_load('message', 2166)->getTemplate()->set('text', $field_value)->save();
}

With this structure, I need the Mid, but I only have the machine name or the Uuid, some way to find it with that data?


texts: How to integrate Field collection module in Views?

texts:
I have created fields and grouped together with Field collection module. I have attached the group field (containing 4 fields), to user account settings in :  admin/config/people/accounts/fields.

Now I am trying to display the content of this field-collection into a view, however I can not do it!

Views 7.x-3.0-beta3 do not allow me to specify the current user and to get in a table the  field-collection contents. How can I get this contents into a view-kind table?

UPDATE:
I have seen that Field collection module has a patch for Views module here: Add Views Relationship to Field Collection - patch attached which is already included in Field collection 7.x-1.x-dev. This allows me to have access at field in collection form Views, however is not allowing me to set a custom filter for the entity of which I associate the field collection. I my case is the user ID.

How can I have access to that form views ?


texts: How to add expose View filter for a derived field

texts:
I have a Drupal View looking at User profiles. One of the fields is derived, or calculated, which is done using Views PHP.

I'm trying to add an exposed filter for this View, but the expose option isn't visible.

Is there another module I use to add this?


texts: add pre-registered links to user menu via hook_menu

texts:
One step before being forced to using internationalization (i18n) module!

I'am trying to add translatable Register and Login links to secondary menu via hook_menu in way which user module dose for Account and Logout links via user_menu():

// user module:

function user_menu(){
  ...
  $items['user/logout'] = array(
    'title' => 'Log out',
    'access callback' => 'user_is_logged_in',
    'page callback' => 'user_logout',
    'weight' => 10,
    'menu_name' => 'user-menu',
    'file' => 'user.pages.inc',
  );
  ...
}

but as this two links (user/register and user/login) re pre-defined via user_menu(), I whould like to know how can I add my links to primary menu?

so simplified question is:

how can I add pre-registered links to menu via hook_menu() ?


texts: What is the correct way to iterate over multivalue items of a form element in D7?

texts:
I'm sure there is a function to help with this by I can't find it in the API docs. What I want to do is: in a hook_form_alter, iterate over all of an element's items and and manipulate them.

The example form below is from a bean form which has a multivalue field collection called field_listing_articles. I want to iterate over all the instances of that element. They are located in the form under field_listing_articles -> und -> 0, 1, 2 etc

If I do a foreach and iterate over $form['field_listing_articles'][LANGUAGE_NONE] I will pick up all the other (non-numeric) parts of the form at that level. I realise I could put an if is_numeric condition in there but I'm sure there is a more 'Drupal' way of doing this.

Any advice appreciated.

$form
--label
--title
--view_mode
--bean
--actions
--#validate
--#submit
--#parents
--#entity
--field_listing_articles
----#type
----#attributes
----#weight
----#tree
----#language
----und
------0
------1
------2
------3
------4
------5
------6
------#theme
------#field_name
------#cardinality
...etc


texts:
I want to run Commerce rule "Create a new account for an anonymous order" from code. I can create user with user_save and etc, but I like this rule and want to reuse it.
After a hour I finished with this code:

// Load reaction rule by name.
$rule = rules_config_load('commerce_checkout_new_account');
// We need $state for 'evaluate' or 'fire'.
$state = new RulesState();
// Add 'commerce_order' parameter to state.
$state->addVariable('commerce_order', $line_item_wrapper->order->value(), array('type' => 'commerce_order', 'label' => 'Commerce order'));
// Execute rule.
$rule->evaluate($state);
// How can I get created user account from $rule?
// Now I have to do user_load_by_mail().

It works but I don't think it is the best way.
I especially don't like  to create RulesState manually. I know there are setUpState() and lots of other methods. I want to find the best solution without creating new Rules component.


texts:
I have been working on a big project for months, and regularly using the Devel module.

For a while now, an empty message with empty <pre> tags has been appearing on user pages for users with access to devel debug info.

I have dragged out all of my custom modules and used notepad++ to "find in files" for "dpm", I have also used grep via ssh to search for "dpm" but it cant find any anywhere!

I also did a SQL search using phpmyadmin, and it does return a result in a BLOB file for a rule. I have been through this rule 5 times, and even exported it to check, but there is no mention of the dpm. However, when I download the BLOB file, there it is!

Scroll right to the end, and this is the only uncommented dpm left on my site.

Booking";s:18:"entity_fetched:var";s:15:"booking_fetched";}s:14:" * elementName";s:12:"entity_fetch";}i:1;r:101;}s:7:" * info";a:0:{}s:12:" * predicate";O:14:"RulesCondition":7:{s:9:" * parent";r:102;s:2:"id";N;s:12:" * elementId";N;s:6:"weight";i:0;s:8:"settings";a:2:{s:13:"entity:select";s:17:"list-product:node";s:5:"field";s:23:"field_booking_reference";}s:14:" * elementName";s:16:"entity_has_field";s:9:" * negate";b:0;}}s:2:"id";N;s:12:" * elementId";i:7;s:6:"weight";i:1;s:8:"settings";a:0:{}s:11:" * children";a:1:{i:0;r:100;}s:7:" * info";a:0:{}}s:2:"id";N;s:12:" * elementId";i:8;s:6:"weight";i:0;s:8:"settings";a:0:{}s:11:" * children";a:1:{i:0;O:11:"RulesAction":6:{s:9:" * parent";r:100;s:2:"id";N;s:12:" * elementId";i:10;s:6:"weight";i:0;s:8:"settings";a:3:{s:11:"data:select";s:39:"booking-fetched:field-remaining-balance";s:12:"value:select";s:39:"booking-fetched:field-remaining-balance";s:13:"value:process";O:21:"RulesPHPDataProcessor":2:{s:10:" * setting";a:1:{s:4:"code";s:53:"dpm($invoice_price);

Does anyone know how the hell i get rid of it?