texts: Can the confirmation URL be different based on different selections made using conditionals?

texts:
Hello all of you super helpful people. :)
Drupal 8
Webform: Version: 8.x-5.19
I have created a webform which requires the person completing the form to select one of 4 options and whatever they select determines what fields they see or not.
One of the fields, when selected, needs to take the person to a different URL upon submission, but I am having a difficult time finding out if this is even possible to do...
EXAMPLE
Select:

Home (submit button takes you to the confirmation page)
Work (submit button takes you to the confirmation page)
Campaign (submit button would take you to a different URL (internal or external)

Does this make sense? Is this even possible to do?
Any assistance with this would be greatly appreciated!
Thank you!


texts: What's the proper way to create a new page option?

texts:
I want to show comments of a node on a separate page instead of on the node page.
Since this is just a "comment archive" and not active I would like a simple solution without a big module or a lot of code.

I can "hack" the node--mytype.tpl.php page to show comments when the "?archive" is in the URI:

    $uri =  check_plain($_SERVER['REQUEST_URI']);
    if (strpos($uri, '?archive') > 0){
        print render($content['comments']);
    }
    else {
        print l('View Comment Archive', $uri.'?archive');
    }

This works fine, even with the comment pager. I'm curious what the "proper" way in Drupal would look like.


texts: How to remove href from last breadcrumb?

texts:
I'm altering breadcrumbs using the theme_menu_breadcrumb_alter function and was wondering what can I do to make the last breadcrumb non-clickable (i.e. it should be just text, not a link).

I tried making the href value to an empty string but that just returns a link to the base URL.

How can I do this?


texts:
Folks, I need a module that will give me the ability to collect service requests from anonymous users and will return to them an estimated price, so a quoting engine basically.  I need the information they submit to also be summarized and sent in an email to a sales rep.

I know about Ubercart, but it seems to be overkill for what we need.  Does anyone have experience with it and can vouch for it as far as this problem goes?

EDIT: Further elaboration on collecting service requests.  The requestee selects a few services that they require, and in what quantity, and this request is forwarded to a sales rep who then prices out the request and contacts the requestee via email with a price quote.  Really I see this as a one way mechanism where requests are just submitted, and then the rest of the conversation is carried out either over the phone or via email.


texts: I want to track if a user has visits a page in my book content. Is there a a module?

texts:
I want to be able to keep track of pages in a book and strike out the link in the list of pages if the user has already visited the page. Is this possible?

What's the best module to do this?


texts: How to add a new row to the registration form?

texts:
I'm using LoginToboggan module. Via this module user can register or login.

And now I want to add another row to this form. For example: Phone number or Age.

How can I achieve this? Or is there another way of achieving this?


texts: Deleting the "Language" module - a dangerous move?

texts:
Drupal 8 comes natively with a module called "Language". This module will be installed even in English websites.

Uninstalling this module from UI or from drush pmu language --- is it a dangerous move?

I ask since when I did drush en language I got the message:

  language was installed successfully
  language defines the following permissions: administer languages

I wasn't sure if that's something good because I then remembered that the module comes natively with the system so I removed it with drush pmu language.

I was afraid this "radical" move could do some damage at least in time being. From a Drupal programmer's standpoint, can this be dangerous or cause wired behaviors in time being?


texts: How to add confirm form with form alter?

texts:
I would like to add a confirm form for the edit page of an entity (commerce product in this case), which only appears when an certain form field has a certain value.
I did succeed to set up a confirm form for a custom form as described above, but to add it in a existing form, I guess I have to use hook_form_alter().
But I don't understand how to implement it. Can anybody help with in example or some hints, how to start, please?
I tried to implement it with an additional custom submit handler, but it does not work:

/**
 * hook_form_FORM_ID_alter
 */
function MY_MODULE_FOMRM_ID_form_alter(&$form, &$form_state, $form_id) {

  // Add custom submit handler
  $form['#submit'][]  = 'MY_MODULE_submit_handler';

}

/**
 * Custom submit handler
 */
function MY_MODULE_submit_handler($form, &$form_state) {

  // If a certain field has a certain value add a confirm step
  if ($form_state['field_description']['und'][0]['#description']) == "Something") {
    return custom_misc_form_confirm($form_state);
  }

}

/**
 * Returns the drupal confirmation form
 */
function MY_MODULE_form_confirm(&$form_state) {

  $path = "path/to/form";
  $title = t('Are you sure you want to to this on %entity?', array('%entity' => drupal_get_title()));

  $text = "A Text";

  // Tell the submit handler to process the form
  $form_state['confirm'] = true;
  return confirm_form($form, $title, $path, $text);
}


texts:
I am running a Drupal 7 site that does a call to an external service using Feeds Module, creates nodes from that coming JSON.

The Feeds Module grabs an image, download it, and generate 4 different image styles. Usually in Drupal, you upload the image that goes through Imagecache, and boom the image is re-sized, why because after node_save you go to node_view that grabs a function which does the real resizing.

In my case, i do not view the nodes, so the images does not get generated unless i run a whole view/page i created with all images so they get generated.

I tried to curl and request the page on a time interval for the page to get generated but it seems you have to really view the page.  What would a solution for this problem be ?

Would doing a batch operation to just view the nodes using node_view help ? What else ?

Note that on each Feeds request the site creates around 50 nodes X 4 images = 200 image.

Help is much appreciated.


texts: Cannot edit any content Panes in Panopoly installation, getting JS error

texts:
When I try editing any pane on my site, I get this:

The following error is in my Web Inspector console:

  TypeError: 'undefined' is not a function (evaluating '$('.panopoly-textfield-autosubmit, .panopoly-textarea-autosubmit', context)
        .once('ctools-auto-submit')')

  TypeError: 'undefined' is not a function (evaluating '$("select.ctools-master-dependent")
          .once('ctools-dependent')')
  `

I've tried changing Jquery Update settings, updating Panopoly to the newest version (along with the modules). No luck.


texts:
I am getting the following error:

  Drupal\Core\Field\FieldException: Attempt to create a field body that
  does not exist on entity type node. in
  Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 286
  of core/modules/field/src/Entity/FieldConfig.php).

Context is that I recently switched from one branch to another and did some config imports.

My guess is that this is related to a field.storage issue? What precisely would be causing this error? I'd provide more information about my content types, but I really don't know at this point where it can be narrowed down to.

I'm not finding any real sources on this particular error.


texts: Several NFS folders for one Drupal instance

texts:
I'm using vagrant & virtualbox to create drupal websites on my Windows local machine.
My actual drupal website is under a Windows folder, shared with my guest(ubuntu) by using a Windows NFS server (winnfsd).

After playing with NFS mount caching options, I understood that my website becomes really fast when enabling it.(specially files attributes caching with high actimeo parameter)

The website becomes fast, but it's almost unusable to developp at the same time:

Changes in my Windows text editor (Sublime Text) are not seen by Linux.
Sass/compass/gulp also don't see changes made in Windows if actimeo is superior to few seconds.

And when there is no NFS cache at all, I could see that lots of NFS operations are logged by my NFS server logs. Every Drupal files are accessed even several times to get attributes, nslookup, read, access...

So my idea was to make several NFS mounts, with different NFS caching options.

Drupal core files never changed => really long NFS cache
Contrib modules changed rarely => really long NFS cache
Custom modules change often => NO CACHE
My Themes change often => NO CACHE

So here is my question, is it good assumptions ?
If yes how do we make those kind of multiple NFS shares ?
I thought about Symlinks ?
Any one tried this approach ?


texts: Custom Profile Type and UPS Shipping Service

texts:
I have an issue that I have been wrestling with for a few months now. I have a B2B site that needs a separate "Drop-shipping" shipping address field from the default shipping address that comes with commerce shipping. The fields need to be different because the client wants the default shipping address field to be constrained to only items in the users address book (controlled by the client, not the customer and created by the site admin when adding new registered users) but allow the second "Drop-shipping" added field to be an editable address form for drop-shipped addresses.

So, using the module "Customer Profile Type UI" I created the "Drop-shipping Information" profile type. Using "Checkout Pages" module I created a new page named "Drop-shipping Information" positioned before the checkout page, with a drop-shipping check-box. It is obviously the first page the customer will see when entering the check-out process, and before the checkout page, so that I can capture a Boolean value that will drive which check-out pane ("Drop-shipping Information" or just "Shipping Information" address fields) are shown on the checkout page.Then I use rules and "Change pane properties" to disable the "Shipping Information" pane if the user has selected "Drop-shipping" on the first page, and vice-verse if not. All of that works properly.

The problem is, when "drop-shipping is selected and a valid address provided, when moving from the checkout page to the shipping services page (with UPS enabled and tested to return rates), it returns the rates for the "Shipping Information" address, and not the "Drop-shipping Information" address.

I realize that rules may only be hiding the default "Shipping Information address form (which is including a default shipping address from the customers account profile) ... but how do it make it use the address in the "Drop-shipping Information" address form instead?

Not sure what I am doing wrong, and I see no configuration options to change the behavior. Can someone tell me what I might be missing or perhaps provide an alternate method (that doesn't require custom coding) after reading the details of my requirements above? Either way, you should know that I am not a developer, and could use at least some mid-level instruction on what I have missed or need to do.

Thanks in advance for any serious help. :)


texts: 1 parent nodetype with 2 subnodetypes - show all subnodes in a viewlist

texts:
Here is the situation: Using D7 and views 3.

I have made a nodetype 1.

I have two nodetypes 1a and 1b (node referenced to nodetype 1).

I want to show all nodes (1a and 1b) attached to nodetype 1 in a views-list when showing nodetype 1.

Contextual filters can only show one subnodetype correct.

Any suggestions?


texts:
I am creating a Field plugin, where I have requirement as below

Field name : Question

Properties:

Question Text : String

Question Type : integer (0,1,2)

Question Options : Array of Strings

I defined schema like this. I am not sure if I am doing it right for Question Option

public static function schema(FieldStorageDefinitionInterface $field_definition) {
    $schema = [
        'columns' => [
            'question_text' => [
                'type' => 'varchar',
            ],
            'option_type' => [
                'description' => 'Option Type: 0 = radio, 1 = checkbox',
                'type' => 'int',
                'default' => 0,
            ],
            'question_option' => [
                'type' => 'varchar',
                'serialize' => TRUE,
            ],
        ],
    ];

    return $schema;
}

And for property definition I have following

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {

    $properties['question_text'] = DataDefinition::create('string');
    $properties['option_type'] = DataDefinition::create('integer');

    $properties['question_option'] = DataDefinition::create('string');

    return $properties;
}

Please let me know how can I do it for the question_option.

--

Thanks


texts: D7: How to deal with the variables visibility?

texts:
Now I have some variables collected from POST

$a = $_POST['a'];
$b = $_POST['b'];
$c = $a * $b

I need to use them in 2 functions: hook_form() and the callback mail_send() the function that format and sends my email with form elements.

I have implemented the following hooks:

function MYMODULE_page() {...}
function MYMODULE_form() {...}
function MYMODULE_form_submit($form, &$form_state) {
mail_send($form_state['values']);
}

//a custom callback mail function call in the submit.
function mail_send($form_values) {}

...

Now I don't know where to place those variables to have maximum visibility:

if I place them in MYMODULE_form() the show up in the form but they are not available in the mail_send().
if I place them outside everything they are not available inside functions.
if i place them inside a hook_init() the same as above.

I need a place where all variables are visible. Thanks


texts:
Possible Duplicate:
  How can I add a “weight” functionalitiy to nodes?

I have views of node for example 10 last of news,I want when create a views of node , I can set this weight, means that create own list.
for example , I chose first node , second node ...

please help me


texts: How do I load multiple nodes by a user reference?

texts:
I have a content type "property", with an owner field (field_user_ref) which is a user reference.

I want to loop through all of the properties, given a specific user_id.

$user_id = 18273;

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'property')
  ->propertyCondition('field_user_ref', $user_id)
  ->propertyCondition('status', 1);

$result = $query->execute();  // ERROR

if (!empty($result['node'])) {
  $nids = array_keys($result['node']);
  $nodes = node_load_multiple($nids);

  foreach ($nodes as $node) {
    echo "<br>".$node-title;
  }
}

But this gives an error..

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node.field_user_ref' in 'where clause': SELECT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type AS entity_type FROM {node} node WHERE (node.field_user_ref = :db_condition_placeholder_0) AND (node.status = :db_condition_placeholder_1) AND (node.type = :db_condition_placeholder_2)

"field_user_ref" is the name of the field..  property.field_user_ref, so not sure what should be the format here..


texts: How to disable cron from running while another time consuming process takes place?

texts:
We bulk upload nodes on our Drupal site.
Those nodes need to be Solr indexed all at once, without having to wait for cron to index them.
The cron job indexes apachesolr_cron_limit nodes per run. As a result, if I have 40.000 records, I have to wait too long.

A solution I implemented is, creating a button which indexes all remaining. The button runs the code below.

function mymodule_index_all_remaining() {
  variable_set('cron_safe_threshold', 0); // Doen not work.
  module_load_include('inc', 'apachesolr', 'apachesolr.admin');
  $env_id = apachesolr_default_environment();
  apachesolr_index_batch_index_remaining($env_id);
  variable_set('cron_safe_threshold', 10800); // Does not work.
}

My problem is that we have cron running every 3 hours and when the cron begins (while the mymodule_index_all_remaining is still running), I get HTTP 502 error.
The same error occurs if I try to  index the remaining from admin/config/search/apachesolr Index all queued content.

So I need to alter the cron interval, which can been seen under admin/config/system/cron, "Run cron every".
This interval is stored in a static variable cron_safe_threshold.
I tried to set it to 0, but it doesn't work. I cannot change settings.php as I really want cron to run evey 3 hours when the indexing does not run.
Is there another way to pause cron jobs from running while another process takes place?

Do you recomment another way to index remaining without having the 502 error?


texts:
Currently we use the Domain Access module to make a couple of domains.
Our current domains are for example:

www.domainemployer.com
www.domainclient.com

But our client now wants it to be like this:

www.domain.com/employer (<--- previously domainemployer)
www.domain.com/client (<--- previously domainclient)

I don't see if this is possible with the domain access module. Can anybody point me in the right direction?

Should we do this with rewrite rules (but is this going to clash with the current existing rules)?


texts:
Our client has a calendar that shows events in two ways:

Non-authenticated users see public events that are available for everyone to see.
Authenticated users see those public events and events that are in organic groups that they are a member of.

The client would like users to be able to download an ICS file of events that they're entitled to see. This should be authenticated each time a request is sent. There should be one URL for all users, that they can plug into their calendar client. There should be some authentication to make sure they are allowed to access those events.

We tried Secure Site but on my local machine it kept segfaulting - we spent two days looking into that problem and couldn't solve it, and on the basis that I'm the one that needs to do the work, we chose to use Services, Services Views and Services Basic Authentication instead.

We've got a calendar view, and I set up a Date iCal display on it, just so I can get all of the appropriate fields and filters. (It could have been anything - a page or block - I just chose this one.)

I also set up a Services display that returns the data. Finally, I added a custom REST server response formatter that reformats the Services display as an ICS, ready for use in calendar applications.

I can use cURL to retrieve that data and everything there seems to be okay. However, I don't seem to be able to get the basic authentication working.

There should only be one URL that user needs to be able to enter into their calendar, for example:

https://user:password@example.com/endpoint/views/calendar?display_id=feed_1

And that should retrieve the correct output for the user, regardless of what they've got on their calendar. (So no separate authenticated/unauthenticated views.)

However, I don't retrieve what I want to retrieve: if I access the page in my browser or directly through Apple Calendar, I only ever get the public events, regardless of what account information I use (and yes, I'm using the correct user information). According to the report log, no sign in occurs.

But, if I access it through cURL on the command line, no matter whether or not I include a username/password, I get the authenticated, private events. Each time, I get "session opened for username" in the report log.

I've tried changing various settings around in the Resources section of the Services view, but to no avail. I can't seem to find any documentation online either, and I've spent the best part of two days looking now.

However I don't know if I've just gone about this in completely the wrong way, because there is a lack of documentation and I've pieced all of this together from various tutorials and documentation pages, most of which are for Drupal 6.

Extra info: this is on my localhost. I don't know much about developing in a local environment, is it possible that I need to set something up on my machine for this to work?

Latest versions of Drupal and Services, Services Views and Services Basic Authentication.

Update 12th June:
It looks like this won't be possible with Services Basic Auth on our setup. The module checks the PHP_AUTHORIZATION setting which doesn't get set when using a CGI/Fast CGI server setup - unfortunately it looks like that's what we're using ...

While I could rewrite everything to send off a request that checks your username/password, e.g. access example.com/calendar.ics and have the script check there, it's not possible to send your username and password through that URL such as username:password@example.com/calendar.ics.

So I'll be looking for another solution. Any suggestions are appreciated.


texts: Manage 2 separate page cache for the same URI

texts:
We have a multilingual website build with Drupal 7.

We have a IP detection for detect Chinese users. Chinese laws do not allow the use of certain JS librairies. In our case, for one page, we use Google Map for all the users in the world, and we replace the library with Baidu Map for Chinese IP.

The problem is that if the first user is Chinese, then Drupal will cache the page with BaiduMap. Anonymous users from all the world will then have the page with Baidu Map even if there aren't Chinese (since it is the same URI).

We can detect if the IP is Chinese or not. So, how can we handle 2 separate page cache according to the user IP and then call the right cached page ?


texts: How do you recycle a css file from a different theme into your new theme?

texts:
I really like the form.css from Corolla. I have built a new theme, but would like to reuse Corolla's form.css.

Downloaded form.css from Corolla theme
Saved it to sites/all/themes/my_theme/css

Now what? Do I need to add a reference to this css file in the main css file? New to site building / theming, so our of my element.

Thanks - keb


texts: Programmatically set value of Boolean radio button field in form

texts:
I am using a custom field in the profile2 module for when a user registers. The field is a Boolean field using the radio button widget.

I want to programmatically set the value for the field using hook_form_alter().

I have managed to successfully set the #default_value using:

function mymodule_form_user_register_form_alter(&$form, &$form_state) {
  $form['profile_company']['field_employees']['und'][0]['value']['#default_value'] = 0;
}

But this code does not actually check the No button, so it looks like nothing has been selected and when the form is submitted it throws an error saying that that field is required and nothing has been selected.

How can I get the code to actually check one of the buttons as well as setting the default value, based on values that I want to pre-fill the form with?

The code above would work fine with a text field, It just doesn't work with a Boolean field using radio buttons.

I have spent a while on this and can't seem to find an answer. I thought maybe I need to use the field #after_build property or possibly JavaScript?

I'm attaching a screen grab of my field settings.


texts: How do display a secondary menu within a drupal node without the node displaying as a actual menu item

texts: I have created a menu with a teaser view with the teasers linking further to nodes.  The problem I have is I would like the secondary navigation to continue to persist with the node that the teaser page links to.  The secondary navigation always drops when I go to the actual node. However I don't want these nodes to be menu items. How do you keep a node within the secondary navigation structure without making it an actual menu item?


texts: Drupal behaviors not attached after Ajax load

texts:
I'm facing a weird problem on my clean Drupal Installation
I attached a js library to page with this

function fs_gal_preprocess_page(&$variables) {
    $variables['#attached']['library'][] = 'fs_gal/fs_gal';
}

This js file I have:

(function ($, Drupal, drupalSettings) {
  'use strict';
   Drupal.behaviors.GalJs = {
    attach: function (context, settings) {
        alert("Gal");
    }
  };
}) (jQuery, Drupal, drupalSettings);

In my custom theme I created a Ajax call:

$('.button a').on('click', function (e) {
    e.preventDefault()
    $.ajax({
        type: "POST",
        url: "path-to-controller",
        cache: false,
        success: function(htmlText) {
            $('.text-container').html(htmlText);
        }
    });
});

After clicking the button, the text is correctly replaced in the .test-container but the library is not re-attached to the newly changed DOM.
Do someone know a technique to re-attach all behaviors to the content injected after an Ajax call ?

Many thanks for your help


texts: How to add module libraries to the page through an admin page?

texts:
Looking for some guidance on how to create a custom module, mymodule, that will pull all the libraries from the custom module and display it in an admin screen. Once the libraries are displayed, I want to be able to set Add to Pages (checkbox) for each library to determine if it should be added to the nodes. It would be ideal if the setting became a configuration.

The goal is to be able to add any libraries I need to the custom module, but selectively add them to nodes using hook_page_attachments. How would I do this?

I initially tried this, but couldn't find a way to get all the libraries.

mymodule.libraries.yml

library1:
  version: 1.x
  header: true
  js:
    path/to/library/file1.js

library2:
  version: 1.x
  js:
    /path/to/library/file2.js

mymodule.module

/**
 * Implements hook_page_attachments().
 */
function mymodule_page_attachments(array &$attachments) {
  $libraries = [
    'mymodule/library1',
    'mymodule/library2',
  ];

  foreach($libraries as $library) {
    $attachments['#attached']['library'][] = $library;
  }
}


texts: How to use more than 2 versions on jquery?

texts:
I want to use bootstrap theme and it requires jquery 1.9, but when I set 1.9, ajax enabled views do not work. I am using views 3.14. There are few contrib modules which require older version of jquery. So in jquery_update I can set "default drupal" for admin pages and 1.7 for the site.

How to get 1.9 as well for my site with no conflicts?

I have found jquery multi module during search, but do not know if it is what I am looking for.

Secondly, Can I use this module with jquery update enabled?


texts: Some fields I have deleted in the past still show up in translation strings, how to get rid of them?

texts:
Some old fields that I deleted still show up in translation strings, so they are still somewhere in the database, but they don't show up under fields list.

I saw an article over here on function field_purge_batch :

https://api.drupal.org/api/drupal/modules!field!field.crud.inc/function/field_purge_batch/7

Is that what I need to do?

Where do I put the code:

function field_purge_batch

7 field.crud.inc    field_purge_batch($batch_size)

Is there a module for this, do I have to change code?


texts: How can I customize a menu to be intuitive for my users: show user name, have dropdown items

texts:
I am looking to create a user menu. The menu when not logged in should have two options: 1. create account 2. sign in. These items will be displayed in-line.

Once logged in, I want the menu to have two options: 1. account name 2. sign out

When logged in the "account name" menu item will have a drop down with menu items linking to the various user tabs present in the user backend.

Information: I am working with a theme I downloaded. The main menu has a fairly extensive dropdown function but I do not know how it is doing it. If I could figure that out then I could apply that to the user menu for the function I want.

The reason I want this done: I had a potential customer loose interest and leave my site because he could not figure out where he could download his files from. So I figured I needed to create a easy to understand user menu.

Thanks for your help!

Drupal 7
link to my website: sonikloops.com


texts: How can I limit displayed nodes by term reference from current user?

texts:
I am trying to create a view that to show content classified by taxonomy term and the hierarchy level of the logged in user within that taxonomy vocabulary.

For instance, the content is organized in 10 different levels of a taxonomy ranking, and each user is progressing through each level of that taxonomy (in an educational pathway), and we want to show all content of those levels that the user has reached and could have possibly have gone through up to that point.

For example if the user has reached level 5 (or has been given that rank by admin), the view will show all content for levels 1 through 5, but not anything higher.  If user is level 7, then the view will show all content with taxonomy 1 through 7 but nothing higher.

How can I do that? How can I reference the user in a view and take their taxonomy term to limit the view's content based on that?


texts: Site in offline mode, any way to debug how this happened?

texts:
I came in this morning to find my companies site in offline mode. I personally checked with the only other site admin, and none of other users have the ability to turn off the site. I was using the Backup module prior to me leaving last night, but I've backed up hundreds of times and never encountered the module leaving the site in Offline mode.

Would there be any logs or any location in the database where this activity might be logged? We don't allow users to login to our Drupal site, just our own editors and a

I've tired Googling answers but I haven't got very far :(

running Drupal 6.x


texts: How to use Drupal Commerce subscription products?

texts:
I created a site which has premium membership and want users to pay for those memberships.
I have installed commerce_sp on my site but I don't know how to configure it and use it.

When a member pay for a membership for 1 year, for example:
Subscription validity: 2014-09-25 13:45:00

but I don't know why, when I check this member again every once in a while. the Subscription validity has changed to: 2015-09-24 13:45:00.

And I check this member again tomorrow,the Subscription validity has changed again:2017-09-22 13:45:00.

I don't know why the subscription validity change again and again.

I was very confused, anybody know why?


texts: How to programmatically set custom display settings for an RSS feed?

texts:
I am using Drupal 7 and Views 3.0-RC1.

I have defined an RSS feed for a view, but the full node content keeps showing up instead of the teaser. I believe it is because of these two issues:

http://drupal.org/node/1211008
http://drupal.org/node/1137116

The steps that appear to work are to:

Enable a custom display for RSS,
Configure the RSS custom display truncate the teaser and hide extra fields,
Enable the view to display full text for RSS.

I need to make this work programmatically as part of a features module.

The first step is easy. I do it with the following code in my .module file:

    function mymodule_entity_info_alter(&$entity_info) {
      $entity_info['customtype']['view modes']['rss'] = array (
        'label' => t('RSS Feed'),
        'custom settings' => TRUE,
      );

The last step is easy, as I can export the view.

The middle step has me stumped. I can't figure out how to set the display properties on the RSS display. I suspect it has something to do with field settings, but I can't seem to pull the pieces together. Any suggestions?


texts: How to apply one AJAX to all form elements?

texts:
#ajax is

  used by: button, checkbox, checkboxes, image button, password, radio, radios, select, submit, tableselect, textarea, text_format, textfield

Sadly, form is not on the list. But on one form, I need to apply ajax to all form elements. With possible exception of submit button, but it will be hidden if javascript works, so it is not an issue, literally all elements is OK.

Is there any neat way to do it?

Currently I'm writing something like this:

$ajax_code = array(
  'callback' => 'poll_choice_js',
  'wrapper' => 'poll-results',
  'method' => 'replace',
  'effect' => 'fade',
);

And then in each element:

  '#ajax' => $ajax_code,

But it will be easy to forget to add this line to some elements in future, so I'm looking for a way less prone to errors.

Reason: My wrapper is actually outside a form and is used for preview, I need to update preview every time anything changes. Form will never need to be submitted. Ajax will never change form elements.


texts: Syntax for using getValue to get value in an array

texts:
I created a form for a block plugin. I'm attempting to save the values to the form after submitting. However I'm having trouble saving the values if they are within an array.

For instance

public function blockForm($form, FormStateInterface $form_state){
    $form['plugins_string_text'] = array(
      '#type' => 'text_format',
      '#title' => $this->t('Block contents'),
      '#format' => 'full_html',
      '#description' => $this->t('This text will appear in the block.'),
      '#default_value' => $this->configuration['plugins_string_text-submit'],
    );

    $form['header']['margin-top'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin Top (pixels)'),
        '#default_value' => $this->configuration['header']['margin-top-submit'],
        );
    $form['header']['margin-bottom'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin Bottom (pixels)'),
        '#default_value' => $this->configuration['header']['margin-bottom-submit'],
        );
    $form['header']['margin-left'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin Left (pixels)'),
        '#default_value' => $this->configuration['header']['margin-left-submit'],
        );
    $form['header']['margin-right'] = array(
        '#type' => 'textfield',
        '#title' => t('Margin Right (pixels)'),
        '#default_value' => $this->configuration['header']['margin-right-submit'],
        );
}

    public function blockSubmit($form, FormStateInterface $form_state) {
        $this->configuration['plugins_string_text-submit']  = $form_state->getValue('plugins_string_text');
        $this->configuration['header']['margin-top-submit'] = $form_state->getValue('header','margin-top');
        $this->configuration['header']['margin-bottom-submit'] = $form_state->getValue('header','margin-bottom');
        $this->configuration['header']['margin-right-submit'] = $form_state->getValue('header','margin-right');
        $this->configuration['header']['margin-left-submit'] = $form_state->getValue('header','margin-left');
}

This is saved to the form properly

$this->configuration['plugins_string_text-submit']  = $form_state->getValue('plugins_string_text');

However each of the lines below display the entirety of the 'header' array instead of the individual margin values.

$this->configuration['header']['margin-top-submit'] = $form_state->getValue('header','margin-top');
$this->configuration['header']['margin-bottom-submit'] = $form_state->getValue('header','margin-bottom');
$this->configuration['header']['margin-right-submit'] = $form_state->getValue('header','margin-right');
$this->configuration['header']['margin-left-submit'] = $form_state->getValue('header','margin-left');

What is the proper way to use getValue to reach an element within an array. Or is there another function I should be using?


texts: Programmatically deleting a filefield content and the associated file?

texts:
If I do the usual

unset($node->myfilefield["und"][0]);

Would that take care of the actual deletion of the file as well on node_save?


texts: How to call js and css file and replace the script in code

texts:
I'm trying to display a map in node page, it's working but the code doesn't look professional.

function customodule_block_info() {
    $blocks['customodule'] = array(
        'info' => t('Google Map Exemple'),
        'cache' => DRUPAL_NO_CACHE
    );
    return $blocks;
}

function customodule_block_view($delta = '') {
    $block = array();
    switch ($delta) {
        case 'customodule':
            $block['content'] = '<!DOCTYPE html>

';

    };
    return $block;
}

I want to know how hook_block_view can read the css and js files?


texts:
I am running Drupal 6.22 and updated the Video module to version 6.x-4.4 and FFmpeg Wrapper to 6.x-2.0-alpha1. Before I was using the swftools to show the videos, but now I wanted to try the HTML5 way. So there are videos in mp4-format (placed in the folder "original") and the converted ones in flv-format (in folder "converted"). After the discribed updates unfortunately no video is showing up - the problem seems to be quite similar. When I edit the content type ("Manage fields" --> "Display fields") and I select "Generic files", everything works as expected. A link to the mp4-File is displayed. But when I choose "Video" the path to the file is missing (only the jpg thumbnail is working correctly), it outputs only this whitout any  tag:

<video width="600" height="338" preload="auto" controls="controls" poster="URL TO JPG HERE.jpg" autoplay="autoplay">
</video>

Do you have any idea on how I could find the problem?


texts: Why are not all stylesheets in mytheme.info being loaded?

texts:
I have a strange issue, when I include the last CSS file (assets/fonts/montserrat/style.css), then the assets/css/style.css doesn't get loaded. It seems to have to do with duplicate naming of files, when I rename the stylesheet to montserrat.css, the issue is gone.

How do I solve this issue while keeping the naming of files intact?

mytheme.info:

name = mytheme
description = My custom theme
core = 7.x

stylesheets[all][] = assets/plugins/bootstrap/css/bootstrap.min.css
stylesheets[all][] = assets/plugins/font-awesome/css/font-awesome.min.css
stylesheets[all][] = assets/css/style.css
stylesheets[all][] = assets/css/custom.css
stylesheets[all][] = assets/fonts/montserrat/style.css


texts: How to override views-view-row-rss.tpl.php in Views RSS page?

texts:
I created custom template. It's located under templates dir of theme. Inside view settings, template is detected, however I am gettings always old RSS output (cache cleared). I want to add CDATA to description field.

It seems that my custom template is just omitted

Template file name: views-view-row-rss--feed.tpl.php


texts: Drupal handle and process POST request webhook from activecampaign

texts:
I'm trying to make a small Drupal project with ActiveCampaign.

I already implemented the activecampaign webform and it works but what I want to do is use the webhooks that activecampaingn can offer for me using POST hits to my website url to create new users using their email address and first + lastname.
In the automation tools of activecampaign I can specify at wich URL the POST webhook is sent and I have an array of variables wich contains data about the subscriber.

What I need is a way to catch this POST hits sent by activecampaign in my Drupal and then I can manage to extract the variables sent and make the user accounts.

Wich way would you recommend for this?
Can module Drupal Services do this?


texts: field_get_items / value when creating new content

texts:
I think I am about to lose my mind .. how in earths name do I get the value of a field in a widget during creation? I created a custom field widget, and during creation of new content I want to be able to do the following:

I want to create a custom field that I can attach to any content type. This custom field has two elements, a textfield to search for products in MySQL. And a selectbox. The selextbox should get filled with options that match the letters that the user types in the textfield.

I checked field_get_items and a lot more, but I just cannot get it. The code below has elements from a form that I made, so please just overlook those parts. I used DPM($something); everywhere trying to see if I can see the value of $element['searchfield'] anywhere ..

$items = field_get_items('node', $node, 'searchfield'); .. doesnt work, but from what I understand this is only to be used after the node is created .. ie to retrieve the added values, I NEED the values during runtime ...

/**
* Implements hook_field_widget_form().
*/
function field_zoekproduct_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  switch ($instance['widget']['type']) {
    case 'field_zoekproduct_field' :

      $element['searchfield'] = array(
        '#title' => t('Zoek naar een product'),
        '#type' => 'textfield',
        '#maxlength' => 115,
        '#size' => 55,
        '#weight' => 0,
'#default_value' => 'zoek...',
'#attributes' => array('onfocus' => "this.value = '';"),  //when textbox gets focus the default value will be removed
'#ajax' => array(
  'event' => 'change',
  'callback' => 'zoekproduct_zoek_getypte_text',
  'keypress' => true,
  //'effect' => 'fade',
  'wrapper' => 'dropdown-second-replace',
),
    );

// with the piece of code below in a form module I can get the value of the textfield in $selected and
therefor am able to fill my select with options from the database that match $selected .. now How do I do the same with a custom field????

$options_first = zoekproduct_maak_een_eerste_selectie();
$selected = isset($form_state['values']['searchfield']) ? $form_state['values']['searchfield'] : key($options_first);

$element['overzicht_producten'] = array(
'#type' => 'select',
'#title' => t('Overzicht producten'),
'#prefix' => '
',
'#suffix' => '
',
'#size'=>1,
'#validated' => TRUE,
'#options' => zoekproduct_zoek_naar_getypte_text($selected),
'#default_value' => isset($item['overzicht_producten']) ? $item['overzicht_producten'] : '',
'#ajax' => array(
  'event' => 'change',
  'callback' => 'zoekproductfield_selecteer_product',
  'wrapper' => 'find_product',
),
);

      break;
  }
  return $element;
}


texts: Change the heading User Accounts in user Registration Page

texts:
I am trying to change the heading in User Registration Page from User Account to Registration.

I tried pre-processing, but in the page variable title is empty and I can only see rendered html.

I also tried using the following code in the settings.php file, but it doesn't seem to work.

$conf['locale_custom_strings_en'][''] = array(
  'USER ACCOUNT' => 'Registration',
  'Add new comment' => 'post new comment',
);


texts: tableselect does not work for me somehow 1

texts:
Array
(
    [table] => Array
        (
            [#type] => tableselect
            [#header] => Array
                (
                    [field_name] => FIELD NAME
                    [field_type] => FIELD TYPE
                    [no_of_values] => NO OF VALUES
                    [display_fields] => DISPLAY FIELDS
                    [field_label] => FIELD LABEL
                    [required] => Required
                    [product_type] => Product Type
                )

            [#options] => Array
                (

            [field_colour_pro] => Array
                        (
                            [field_name] => field_colour_pro
                            [field_type] =>
                            [no_of_values] =>
                            [display_fields] => 1
                            [field_label] => color
                            [required] => 0
                            [product_type] => shirt
                        )

                    [field_description] => Array
                        (
                            [field_name] => field_description
                            [field_type] =>
                            [no_of_values] =>
                            [display_fields] => 1
                            [field_label] => description
                            [required] => 0
                            [product_type] => test_pro_v
                        )

                )

            [#multiple] => 1
        )

$header = array(
    'field_name' => t('FIELD NAME'),
    'field_type' => t('FIELD TYPE'),
    'no_of_values' => t('NO OF VALUES'),
    'display_fields' => t('DISPLAY FIELDS'),
    'field_label' => t('FIELD LABEL'),
    'required' => t('Required'),
    'product_type' => t('Product Type'),
  );

  $rows = array();
  foreach(commerce_product_types() as $product_type => $product_type_array){
    $field_info = field_info_instances('commerce_product',$product_type);
    foreach($field_info as $machine_name =>$field_details){
      $rows[$machine_name] = array(
        'field_name' => $machine_name,
        'field_type' => $field_details['type'],
        'no_of_values' => $field_details['cardinality'],
        'display_fields'=>1,
        'field_label' => $field_details['label'],
        'required' => $field_details['required'],
        'product_type'=> $product_type,
      );

    }
  }

  $form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#multiple' => TRUE,
  );

//  print_r($form);
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );

return $form;

I tried to get the tableselect form #type into operation it does not work and gives empty row even when each row has values,I would like to help me find any silly mistake which I am making out here

Here is image of how the table select looks which is empty


texts: how drupal decide execution order of same hook in different modules?

texts:
if there is two modules A and B and both have same user_login hook. so when i log in. out of A_user_login() and B_user_login() function which one called first.and how drupal decide
execution order of these two function


texts:
What's the procedure for including a base migration class that some of my migrations extend? I have some common functionality across multiple migrations class and would not like to repeat the code in all classes.

My question is how do I "register" my base class with Migrate? I need it to get autoloaded. Perhaps if I just include it in the module's list of files?


texts: How to manually check if a username and password is correct?

texts:
There are a lot of answers on how to log in as a specific user. But I can't find any answer on how to check if the username and password is valid without logging in. I want to be able to do something like this:

$username = "bla@bla.com"
$password = "blablabla"

$valid = checkIfValidDetails($username, $password);

I simply want $valid = true if the username and password is correct, and false if not.

How can I do that?


texts:
When I create a new content or update existing content gets index immediately on solr search api index.
But I have added custom field to search index using entity_info_alter I have added custom field.
The custom field gets updated on Solr only on cron job runs. I want it to update when I create/update any content.

How it can be achieved?


texts: Add content type to a taxonomy - Drupal 7

texts: Hello everyone I have content type named contact where I have many fields like name, email, phone, country... and a taxonomy named organization with fields name, acronym and contact. What I try to do is when I create a new term of this taxonomy I have the possibility to add contact. Many thanks in advance


texts: setting the url to a function in a custom module

texts:
I am trying to make a link in a view which, when clicked on, will call a function in a custom module to make a database call. I have made a link by making a Global:custom text field (because thats the way it seemed I had to do it from some posts online), set it to a path accompanied with some arguments. I made a custom module used the hook_menu:

function example_menu() {
$items = array();
$items['path_name'] = array(
'title' => t('Example'),
'page callback' => 'my_callback',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}

where function my_callback does a database call.

When I click on the link I just get a blank page with nothing on it. Which pieces am I missing here? The first thing I thought was that I needed to route the link to a page (hence the name 'page_callback') but how would I do this? All I really want done is a database call, I don't mind if you stay on the same page.

EDIT:
Additionally, what I have found is that on the content management page there ares some errors on top which tell me that I'm missing arguments 1 through 4 (there were four arguments), which definitly can be part of the problem. The function starts off:

function example_my_callback($staff_action, $first_name, $last_name, $email)

and the url for the link was path_name?staff_action=[varible name found in views]...etc
Is there any issue here?


texts: Map or Edit Query String Values in Views?

texts:
As part of a port of a non-Drupal site to Drupal, I need to map a url query string to filters.

For example, if I have this query string and slect filter selected on Site A (Non-Drupal)

Site A

Value 1 | Value 1

Value 2 | Value 2

Value 3 | Value 3

www.sitea.com/?value=value%1

Site B:

Value 1 |1

Value 2 |2

Value 3 |3

www.sitea.com/?value=1

Site A cannot be edited. Is it possible to either edit the values in Site B to match that of site A (within views only, not actual field data) or map the query string, so that Views will see  "www.sitea.com/?value=value%1" and display "www.sitea.com/?value=1"

I know I can change the Filter identifier (i.e. ?value)  on the filter settings tab but how can I changed the values themselves?

In reality, they are far more complex than this so I'd like to avoid HTACESS.


texts: Drupal 8: The proper alternative to exit(); for terminating a request

texts: Does anybody know how to avoid the brutal PHP built-in exit(); function and use the "right" Drupal 8 class method to terminate the request? If so: a bit explanation would be appreciated.


texts: What core configurations should be used in settings.php for a production site?

texts: Can someone please share Drupal core configurations that should be included and/or excluded from settings.php to make the site both performant and secure?


texts: why are my form_alter changes not saving?

texts:
I have a form_alter function in my .theme file, I am trying to change some of the text in my user_register form, and some of the text I change is changing, but some of it shows that it is changing if I print that field out after changing it, but the change doesn't show up on the page. Do any of y'all know why?
Here is the function:
function [site_name]_form_user_register_form_alter(&$form, &$form_state) {
  $form['account']['mail']['#title'] = "Enter your email"; //These changes show up on the page
  $form['account']['mail']['#description'] = "Enter your business email to be used to sign in to [Site Name]."; //These changes show up on the page

  $form['field_first_name']['widget']['#title'] = "Enter your name";
//These changes show up if I print these variables after these lines, but the changes don't show up on the page
  $form['field_first_name']['widget']['#description'] = "Enter your business email to be used to sign in to [Site Name].";
//These changes show up if I print these variables after these lines, but the changes don't show up on the page
  /*$form['field_account_type']['#theme_wrappers'] = array('container');
  $form['field_account_type']['widget']['#title'] = " Step 2: Select your current role.";
  $form['field_account_type']['widget']['#description'] = "Your role will help us determine what type of account to create.";*/ //These changes worked when they were being used, but I don't need them anymore
  $form['field_receive_updates']['widget']['value']['#description'] = "";

  $form['actions']['submit']['#value'] = "Request Registration"; //This change shows up on the page
}


texts:
I've got a modules that supplies a bunch of blocks. I'd like to be able to display them individually as stand-alone pages. I can embed them into nodes, but then I'll need to create each node manually. Ideally I'd just create a menu entry specifying which specific block I'd like to display.

Is there anything out there that can do that? I'm looking for basically the inverse of http://drupal.org/project/nodeblock.

Thanks.


texts: How to make Drupal STOP stripping away  tags

texts:
Very simple HTML submitted in "Full HTML" mode via the editor (rich text disabled).

Not only does Drupal smash all the empty space, the also strips away the  tag wrapping a div.

The Institute for Disease Modeling

develops

quantitative decision-making tools for the eradication and control of infectious diseases


texts: How to assign alt text to current inline images

texts:
Let me set the scope first, these images are not uploaded from an image field, they are uploaded from CKeditor, via imce or ckeditor_image2. Therefore, they are in node body, together with other text (isn't that the worst scenario you can imagine?).
Now how do I approach this accessibility improvement after already having hundreds of potential images without alt text.


texts:
I created a timeline view and it works fine, still, I need to add translatable nodes, I added another display and replace it in the page that I want, my problem is when I change the page to the other language, it's showing me all the nodes that I made in content types that related with the timeline.
How can I add only the translatable nodes to the other view display?
is there another way to add these nodes? appreciate any help with this issue.


texts:
I'm using Drupal 7 and Ubercart 3. Using pathauto I generate clean url's. However there are two paths to my catalog pages.

product_main_category/category

product_main_category/category-0

I think it has something to do with the fact that there is a catalog path and a taxonomy path, but i don't know why. My installation is very basic so i would assume a lot of people should have seen this problem before.


texts: Selling art with Drupal Commerce - how to approach?

texts:
I have a fair amount of experience with Drupal 7 but I'm confronted with some requirements that I simply don't know how to think about in terms of Drupal modules, etc. I'm not looking for a step-by-step tutorial; I'd just like to know how I can implement this roughly so I know which direction to head in.

I'm making a personal site for a friend who is an artist. We defined a custom content type, work of art, that allows her to add each piece she has created.

She wants to sell some works of art and simply list others (never sell).
Of the works of art for sale, for some the originals will be for sale, while for others only reproductions will be for sale.
For reproductions, users need to be able to choose from among different sizes.
Even after a work of art is sold, she would like to keep the node published so visitors can see it, though it should no longer be available for sale.

I've already built a gallery of the works of art in Views.  Ideally, I would be able to add the option to purchase each work directly on its node page rather than building a separate store.

Is this going to be relatively straightforward to do in Drupal Commerce?  What is the general approach I should take to this, given the requirements above?


texts: Remove tasks and index when creating a menu tab from views

texts: I am using views to create a menu tab for my views page and it works fine accept it comes with two unexpected tabs: Tasks and Index, which are showed in the photo below. Is there any way to remove them? Thanks.


texts: Drupal Date Repeat Module has no delete option

texts: I'm using a custom content type with the drupal date field inserted with the date-popup calendar.  The content type allows for multiple dates however there is no delete option, so they just keep piling up.  The content type is used to run the event module I created.  Any ideas?


texts: Improvements in Drupal Gardens way: How do I place an input filter selector in CKEditor?

texts:
I would like to know how to achieve two improvements in WYSIWYG in the same way Drupal Gardens does.

The first one is to place Input filters selector as a dropdown selector within the WYSIWYG toolbar, which saves a lot of space and looks cleaner.
The second one is to place two tabs in order to switch from HTML code and WYSIWG Editor.

I created a site and exported the file as to see which modules Drupal Gardens uses, but I didn't find the correct one.


texts:
There are plenty of articles on creating 'related content views', but what I need is a view of all content tagged with different terms of a specific taxonomy.

I've tried creating a view with the Taxonomy Term ID Contextual filter set to Exclude under 'More', but I'm still getting related content.


texts:
I'm trying to find a way to display the number of resuts in a solr search.
I need to display it in search-results template.

Thanks for any hint


texts: How can I edit the string "Send this user a private message" in Privatemsg

texts: Is it possible in the Privatemsg module (7.x-1.3) to edit the string "Send this user a private message" to something else without directly editing the modules code?


texts: Setting View Filter Operator to "Greater Than Or Equal To"?

texts: I have a view for which I've set different exposed filters and users can search for objects of different criteria. However, I want some fields to be searched by "Less than/Greater than or equal to" what the user types. I don't have those options in the operator field. Some people seem to have them however.


texts:
I'm not very much knowledgeable about making PHPUnit and Drupal testing setup.

I am having problems regarding database calls.

I tried to setup phpunit test.

Inside my module/some_module. I installed phpunit by running

composer require --dev phpunit/phpunit ^8

This is my module/some_module/composer.json

{
    "autoload": {
        "classmap": [
            "src/"
        ]
    },
    "require-dev": {
        "phpunit/phpunit": "^8"
    }
}

This is my module/some_module/tests/SampleTest.php

<?php

use PHPUnit\Framework\TestCase;
use Drupal\nat\Controller\SampleController;
use Drupal\Core\Controller\ControllerBase;

final class SampleTest extends TestCase
{
    public function testCanFilterData(): void
    {
        $this->getMockBuilder(ControllerBase::class)
            ->getMock();

        $class = new ReflectionClass(SampleController::class);
        $method = $class->getMethod('filterData');
        $method->setAccessible(true);

        $obj = new SampleController();
        $args = [1, 2, 3];
        $method->invokeArgs($obj, [$args]);

        print_r($foo);
    }
}

This is my module/some_module/src/Controller/SampleController.php

<?php

namespace Drupal\some_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class SampleController extends ControllerBase {
    public function index()
    {
        $ids = [1, 2, 3]
        $data = [];

        $data['some_data'] = $this->filterData($ids);

        return [*
            '#theme' => 'test_template',
            '#data' => $data,
          ];
    }

    private function filterData($ids)
    {
        $connection = \Drupal::database();
        $query = $connection->query("SELECT
                id, name
            FROM products
            WHERE id IN (:ids[])",
            [
                ':ids[]' => $ids,
            ]
        );

        return $query->fetchAll(\PDO::FETCH_ASSOC);
    }
}

When I ran phpunit tests/NatTest.php, I am getting this error:

1) NatTest::testCanBeCreatedFromValidEmailAddress
Error: Class 'Drupal' not found

So my question is how can I test this? I can't mock Drupal because I actually want to execute a database query from Drupal. How can I do this?


texts: Pager Gone when I edit query in "views_pre_execute"

texts:
Today I faced a strange problem.

Indeed I tried to manipulate SQL QUERY of a view in "views_pre_execute" event.

I made a module with name "modify_view_query" and created related function in my module.

function modify_view_query_views_pre_execute(&$view) {
}

the view name is "view_products" so I added this condition to the function.

function modify_view_query_views_pre_execute(&$view) {
    if($view->name=="view_products") {

    }
}

Then I retrieved the SQL query and tried to inject.

function modify_view_query_views_pre_execute(&$view) {
    if($view->name=="view_products") {
        $sqlStr = $view->build_info['query'];
    }
}

The original Query is

SELECT DISTINCT(node.nid) AS nid, node.type AS node_type, node.vid AS node_vid,
    node.title AS node_title, node.language AS node_language,
    node_data_field_product_brand.field_product_brand_value
        AS node_data_field_product_brand_field_product_brand_value,
    node_data_field_product_brand.field_product_dosage_value
        AS node_data_field_product_brand_field_product_dosage_value,
    node_data_field_product_brand.field_product_package_value
        AS node_data_field_product_brand_field_product_package_value,
    node_data_field_product_brand.field_product_drug_category_value
        AS node_data_field_product_brand_field_product_drug_category_value,
    node_data_field_product_brand.field_product_indication_value
        AS node_data_field_product_brand_field_product_indication_value,
    node_data_field_product_brand.field_product_type_value
        AS node_data_field_product_brand_field_product_type_value,
    node_data_field_product_brand.field_product_patient_advisor_nid
        AS node_data_field_product_brand_field_product_patient_advisor_nid

    FROM {node} node LEFT JOIN {content_type_product} node_data_field_product_brand
    ON node.vid = node_data_field_product_brand.vid

    WHERE
        (node.status = 1)
        AND (node.type in ('%s'))
        AND (node.language in ('%s'))
        AND (SUBSTR(node.title, 1, 1) = '%s')
        GROUP BY nid ORDER BY node_title ASC

I want to inject an OR condition to my code.
indeed I want to replace SUBSTR(node.title, 1, 1) = '%s' with SUBSTR(node.title, 1, 1) = '%s' OR SUBSTR(node.title, 1, 1) = '%s'

So I used string replacement function as follow.

$sqlStr = str_replace("SUBSTR(node.title, 1, 1) = '%s'","SUBSTR(node.title, 1, 1) = '%s' OR SUBSTR(node.title, 1, 1) = '%s'",$sqlStr);

Finally I set the parameter and new SQL string for the view.

    $view->build_info['query_args'][2] = 'A';
    $view->build_info['query_args'][3] = 'B';
    $view->build_info['query'] = $sqlStr;

The Final Function is

function modify_view_query_views_pre_execute(&$view) {
   if($view->name=="view_products") {
    $sqlStr = $view->build_info['query'];
    if($view->build_info['query_args'][2] == "A" || $view->build_info['query_args'][2] == "B")
    {
        $sqlStr = str_replace("SUBSTR(node.title, 1, 1) = '%s'","SUBSTR(node.title, 1, 1) = '%s' OR SUBSTR(node.title, 1, 1) = '%s'",$sqlStr);
        $view->build_info['query_args'][2] = 'A';
        $view->build_info['query_args'][3] = 'B';
        $view->build_info['query'] = $sqlStr;
    }
   }
}

every thing works fine. But the problem is when I use this code to manipulate the query the PAGER is disappeared.
I am sure that this code causes the problem because when I disable the module or comment the function Pager appears but again when I active the module or un-comment the codes Pager disappears !!!

Please help me. What is my mistake ??


texts: How to obtain the machine name and field type of the fields of a content type filtered by those created by the user?

texts:
I have a content type News to which I added the following fields:

Label | System Name | Type
Image | field_image | Is a image
Related content | field_related_content | is a Paragraph
Date | field_date | Is Datetime type

What I'm trying to do with a custom module is, I want to get the machine names of each field and the type of field that I defined.

Is it possible to obtain data from only those that I generated?
That is, for example, the created fields, or the update field or those that come by default do not appear, in some way filter the ones that I defined as the user in the content type.

For example, after some form of processing the type of content, only result in:

$result = [

  'field_image' => [
     'type' => 'image',
   ],
   'field_related_content' => [
    'type' => 'paragraph' // i don't know if the type is Entity reference revisions in reality
   ],
   'field_date' => [
    'type' => 'datetime'
   ]

];

Thanks.


texts: I have 4 facets set to filter results by taxonomy terms but only one of the four filters work

texts: I'm using Apache SOLR with Facet API and am having trouble getting my facets to show. I have 4 facets that are set to filter results by taxonomy terms. Each filter uses a different vocabulary. For some reason only one of the four filters work. The other three don't even show up. Any ideas as to why this is happening?


texts: How to use hook_views_data_alter to display select list on user reference field?

texts:
I want to allow administrator to edit user reference field value on the fly when browsing entities list (view as table). In every row select list with user to choose should appear.

Current code:

function rpke_document_assign_views_data_alter(&$data) {
    $data['field_data_field_assignee']['applicant_chooser'] = array(
        'real field' => 'field_applicant_target_id',
        'field' => array(
            'title' => t('Applicant chooser'),
            'help' => t('Applicant chooser based on select list. Extends views_handler_field_user_name'),
            'handler' => 'rpke_field_handler_applicant_chooser',
        ),
    );
}

field_assignee is custom CCK field add to entity based on node.

When I try to add this field to a view I am getting error:

  Invalid column name 'field_applicant_target_id'.


texts: Don't load jQuery, even when modules have it as a dependancy

texts:
How can I stop jQuery being loaded in Drupal 8, even when modules which use jQuery are on the page?
I have an existing style guide which I'm pulling into a Drupal 8 site. I already have all the JavaScript including jQuery as part of the style guide and I want to keep this separate from Drupal.
For anonymous users everything works fine. However admin users have access to the admin toolbar. This loads in Drupal's own version of jQuery which conflicts with the style guide's and causes the admin toolbar to break.
I tried adding this to my theme's libraries file:
core/jquery: false
core/jquery.once: false
core/jqueryui: false

Inspecting the page it did appear to block some jQuery references but not all of them:

However when I remove my entries from my theme's libraries file I can see that in fact all of the same jQuery files are being loaded, so I don't actually think it achieves anything.

I know that normally one would not load in jQuery themselves and just use Drupal's version, but the style guide requires the latest version and is also consumed by other applications so I cant change it very much.


texts: Module to import github content onto local drupal server

texts: I want to be able to put content from github into the sites/default/files folder of drupal so I was wondering if there was a way to do this.


texts: How do I export all of my customers (not users) from Drupal into a CSV file?

texts:
I'm working on integrating a new accounting system and crm (Xero & Capsule) for a client - and they have just under 10,000 clients - only stored in their Drupal website. I need to export these with all their details (e mail, full name, address etc) - into a csv or excel file.

Currently under Store Administration I can "View Customers" - but this gives me no option to export.

But under Reports > Customer Reports it gives me the option to export each page to a csv - however the information is not what we need - it only gives me usernames.

Any suggestions?


texts:
I just created a content type with a field:images.
Then I added some content and I create a View to show these content. Then the view shows the images (from the images field)
Everything works fine but when I logout the anonymous user can not see the images.

As you can see in this picture I have "checked" Access content for anonymous user. But it doesn't work...

.

What I need to do to make the images visible for anonymous users is to have 'checked' View field_images. You can see the picture.

my question: do I need to checked on every field I create to make them visible to anonymous users? Is there any way to set that any new create field should be visible to anonymous users.

Thanks


texts:
So I figured I'd create a configuration for my module. I created a normal form with some fields to let the users configure the module with variables. I also added a button which would do an ajax-call to a service. Problem is, this button is within the form, meaning it submits the form aswell.

$form['products']['update'] = array(
            '#type' => 'button',
            '#ajax' => array(
                'path' => '/products/update',
                'event' => 'click'
                ),
            '#value' => t('Update Products')
);

I just want the button to actually call this service (/products/update) and not act like a submit button. This worked in beta3 but is not an annoying feature in beta4, preventing the actual service call. How do I fix this?


texts: How can I filter by a term when on a sub-page of that term?

texts:
I have a non-hierarchical taxonomy and 2 content types.

I need to make these pages with Views:

Mysite.com/something/termA/ContentTypeA
(This will display nodes of content type A that are tagged with termA.)

Mysite.com/something/termA/ContentTypeB
(This will display nodes of content type B that are tagged with termA.)

Mysite.com/something/termA/ContentTypeA
(This will display nodes of content type A that are tagged with termA.)

Mysite.com/something/termB/ContentTypeB
(This will display nodes of content type B that are tagged with termB.)

In actual fact there are a lot of terms so I need these pages to be from 1 or 2 Views (EG with dynamic filters). I cant just make 4 Views with static filters.

I could create 2 Views, one for each content type. Filtering by the content type is simple so my issue is just that I need to figure out how to filter by a term when you are on a sub page of that term, not on the term's page itself.

Eg filtering by termA on this page is easy:
Mysite.com/something/termA/

But how do you filter by termA when on this page?
Mysite.com/something/termA/ContentTypeA


texts: Embedded view results being lost when form_set_error is being called

texts:
I have a page (user profile.tpl.php) with a custom form and a view embedded in the tpl.php file.

The custom form is defined in a custom module, with validation and submit hooks, and the view is being displayed programatically like so:

$view = views_get_view('accounts_for_user');
$view->set_display('panel-pane-1');
$view->set_exposed_input(array('field_customer_number_uid' => $user->uid));
echo $accountsView->preview();

The form is also being displayed programatically (in a jquery ui dialog):

echo drupal_render(drupal_get_form('custom_mod_change_password_form'));

This is my validation hook:

function custom_mod_change_password_form_validate($form,&$form_state)
{
    $oldPassword = $form_state['input']['old-password'];
    $newPassword1 = $form_state['input']['new_pass1'];
    $newPassword2 = $form_state['input']['new_pass2'];

    if ($newPassword1 != $newPassword2)
    {
        form_set_error('old-password',t("Password and confirm password do not match."));
    }
    global $user;
    $account = user_load($user->uid);
    if (!user_check_password($oldPassword,$account))
    {
        form_set_error('new_pass1',t("Old password is invalid."));
    }
}

Now this works on initial load and displays fine. The problem is that when there is a validation error, the view shows it's no result message instead of the actual fields.

Any ideas on what might be the problem?


texts:
I try to get drush to run by calling just 'drush' and not 'vendor/bin/drush', I'm working with OSX Sierra. This doesn't work out as I want hope someone can help me with this.

When i follow the instructions here:
http://docs.drush.org/en/master/install/

When at point 3:
If you want the convenience of calling drush instead of ../vendor/bin/drush, copy the examples/drush.wrapper file to your Drupal root and modify to taste.

I get stuck. I copy the drush.wrapper file to my root and rename it to drush . Then I edit the path to:

cd "`dirname $0`"
vendor/bin/drush.launcher --local "$@"

Because I'm in the root I removed the ../ before vendor. When I save all I stil get:

  bash: drush: command not found

When I try going to: vendor/bin/drush.launcher it runs perfectly. What am I doing wrong?


texts: Relative date filter views block is cached for anonymous users

texts:
Drupal 7.74, views 3.24 (latest)
I have a view which uses a date field to filter and shows on: less than or equal to "now"
I display the view in a block.
With caching for anonymous enabled, (caching blocks disabled),  the view block is not shown when the date has passed (works for authenticated users)
Is this normal behaviour, am I missing something, or do I need to disable caching for the pages this block will appear on?
Thanks!
Edit: If I save the node in question, or run cron, the views block displays for anonymous users. Am I going to have to trigger something like that with Rules?


texts:
I'm developing a pretty basic module catalog_request that creates a form. I'm replacing the form's default submit button <input ..type="submit" /> with a <button ...>click</button> using following in form definition.

function catalog_request_form($form, &$form_state) {

    /**
     * form fields here
     */

    $form['fieldset_submit']['the_submit_button'] = array(
       '#type' => 'markup',
       '#prefix' => '<button class="btn submit">',
       '#markup' => 'Send Request...',
       '#suffix' => '</button>',
    );

    /* ... */
}

and have defined other two form related functions

function catalog_request_form_validate($form, &$form_state) {
    drupal_set_message(t('The form was validated'));
}

function catalog_request_form_submit($form, &$form_state) {
    die('submitted');
    //drupal_set_message(t('The form was submitted'));
}

The problem

My submit function catalog_request_form_submit isn't being called. I've read numerous articles online but none resolved my issue. Following didn't work

Adding '#submit' => 'catalog_request_form_submit', to
the_submit_button key
Adding '$form['#submit'] => 'catalog_request_form_submit'; to end
of catalog_request_form function
Adding '$form['#submit'][] => 'catalog_request_form_submit'; to
end of catalog_request_form function

I've read that adding something along the lines of $form['actions']['#submit'][] = 'custom_function'; could solve the problem but I'm not sure how to adapt it for my form.

I know that having '#type' => 'submit' for the submit button makes the form work but I want a button tag.

My problem is exactly When altering the submit button, the form does not work but it doesn't have a solution (only an answer that ignores the question's point)

P.S. I do not develop for drupal frequently so I might be missing something very obvious.

Any help will be greatly appreciated. thanks


texts: How do you make nodes automatically publish one by one after specific time?

texts: I'm going to do a comic site. I saw the MemeCenter. It automatically publish comics after 10 minutes. Is there a module to do this on Drupal?


texts: How to prevent a block from being cached?

texts:
After login. I'm adding one sidebar block. Once I clear cache then only updates variable or it's value.

namespace Drupal\test_demo\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides 'Sidebar' Block
 *
 * @Block(
 *   id = "sidebar_block",
 *   admin_label = @Translation("Sidebar Block"),
 *   category = @Translation("Sidebar Block"),
 * )
 */

class SidebarBlock extends BlockBase {
  public function build() {
    return [
      '#markup' => $this->t('Sidebar'),
      '#cache' => [
            'max-age' => 0,
          ]
      ];
  }
}

In mytheme.theme

function theme_preprocess_block(array &$variables) {
  echo $variables['elements']['#id'];
}

How can I stop that block to being cached. So once I refresh the page. It loads the value immediately.


texts: How can we assign points to users in the site?

texts: I want to give points to users in the site, like if a user creates an account then he should be awarded some points even if I want to award points for the  activities like if user visits a page, if a user posts a comment etc.


texts: Having different theme elements for different pages

texts:
I am trying to wrap up an HTML theme into a drupal template and I cannot get right idea on how to do this.

I am having a front page, that is unique in it's elements. Then, I am having another page that only keeps the header from the front page, and footer. On this page, I am having some boxes, in witch the content should be nodes. How can I do this?

After that, I am having different pages where I need to add their elements from the admin panel as content. So, there will be more categories, and I need to list the elements from each category into some pages that have different style.

Also, there are regions like footer, where I have some logos ( images ) that again, they need to be nodes and added/edited from the admin panel as content.

Can someone point me to the right direction?

I have tried to create some pages from the admin panel, and tried to use files like page--.tpl.php to have a page in witch I should add nodes/content as the page elements but it is not rendering. Neither if I try lie page--node--.tpl.php or things like that.

I have searched on google for a few hours but I haven't mnaged to get the propper solution.

Thank you in advice!

Best regards,
Alex


texts: Get content of selected option after user select any option from select field

texts:
I have created a content type, This content type form having a select box.

I need to develop a functionality like once the user select any option from select field the following textbox should having options like auto-complete data to respected selected option.

I can not create taxonomy and dependency because the database is very large. unable to add all data to taxonomy.

I want to do it by using ajax on change option. How can I achieve this?.

Can anyone suggest the easiest method?


texts:
This question is specific to Drupal 7, and I'm pretty sure that I already know the answer to this, namely that I won't be able to do what I want, but I thought I'd pose it to you Drupal experts.

Is it possible to extend Drupal's user_access() function to provide a more complex logic for permissions? I know it is possible to create an access callback function that provides more complex logic, but I want it so that every function that calls the user_access() function will implement this new logic for determining permissions.

So, how do you extend Drupal's user_access() function to run your own functions too to check access?


texts:
I created many fields for content type.Now I don't need these fields anymore.
I deleted the fields from the content type but the fiels data remains in the database.

How can I delete the field and all its related data?


texts: transferring drupal site from one domain to another?

texts:
I have two domains: domain1.com & domain2.com

In my FTP folder, I have a folder inside my root folder which is named "home"

I installed and developed my site as domain1.com/home

Now I want to point domain2.com to the site files in the folder 'home'. I copied the files over, and when I now access domain2.com/home -- site comes up without CSS or any theming, clicking on node information gives "Internal Server Error"

Any ideas how this can be solved?

I have tried setting $base_url = 'http://www.domain2.com' in my settings.php (it was not set earlier), but that did not help - what else can I do?


texts: Possible to prepopulate an inline entity form multiple with a url parameter?

texts:
Is is possible to add multiple entries into an inline entity form field with url parameters

I am able to populate almost any other field with the prepopulate module, just having difficulty with the IEF.

Scenario:

I have two content types of quote, and sales order. each of which has an entity reference of inventory (another content type) which has IEF as its widget.

I want to be able to create a sales order off of the quote, and bring over all the values of the entity reference field to the quote. The issue is i want to maintain the data on the quote, but be able to edit the "same" data on the sales order.


texts: How to add two extra buttons in a form to do extra actions with form data

texts:
I have a simple custom form with 3 submit buttons - one that calls the default hook_form_submit and generates a table. The submit as the rebuild as TRUE:

$form_state['rebuild'] = TRUE;

that shows the complete form with the 3 buttons and the tables.

I need the 2 extra buttons to call different functions but I need inputs from the form itself or the table array.

At the moment, with the code I have, I can't access the form data and also, the tables created by the main submit disappear when I click the 2 extra buttons.

My code:

function MYMOUDLE_form($form, &$form_state) {
    $form['container']['submit'] = array(
        '#type' => 'submit',
        '#value' => t("Submit Form"),
    );

    $form['container']['export_1'] = array(
        '#type' => 'submit',
        '#value' => t("Export - 1"),
        '#submit' => array('MYMOUDLE_export_1'),
    );

    $form['container']['export_2'] = array(
        '#type' => 'submit',
        '#value' => t("Export - 2"),
        '#submit' => array('MYMOUDLE_export_2'),
    );

    return $form;
}

function MYMOUDLE_form_submit($form, &$form_state) {
    # do my stuff - generate tables
}

function MYMOUDLE_export_1($form, $form_values) {
    dpm($form_values);
    $someData1 = MYMODULE_handleFormData1($formValue1, $formValue2, $formValue3);
    drupal_set_message('Action for export 1 was done successfully.');
}

function MYMOUDLE_export_2($form, $form_values) {
    dpm($form_values);
    $someData2 = MYMODULE_handleFormData2($formValue1, $formValue2, $formValue3);
    drupal_set_message('Action for export 2 was done successfully.');
}


texts: Drupal 7 Private Files - How to override security in custom module

texts: Is there a hook to override access to images stored in the private file system when theme_image_style is used to output the image?


texts: drupal_add_js() 'setting' not being set on form submit

texts:
I have a form and on that form the #submit action it calls a function that saves some data.   Now what I need to do is  I need to pass some data back to the website confirm page to be used by JavaScript. To do this I used drupal_add_js() 'settings' but this does seem to work? The data never gets set.
From what I've read I think it might be something with the form redirecting during the submission process and the JS is getting lost?


texts:
i'm updating role using hook user update like this :

function my_module_user_update(&$edit, $account, $category) {
  //print_r($account->field_my_field['und'][0]['value']);exit;
  if($account->field_my_field['und'][0]['value'] == 1 ) {
    $uid = $account->uid;
    $role_name = 'Spanish';
    if ($role = user_role_load_by_name($role_name)) {
      user_multiple_role_edit(array($uid), 'add_role', $role->rid);
      //print "1";print_r($role);exit;
    }
  }
  elseif($account->field_my_field['und'][0]['value'] == 0 ) {
    $uid = $account->uid;
    $role_name = 'Spanish';
    if ($role = user_role_load_by_name($role_name)) {
      user_multiple_role_edit(array($uid), 'remove_role', $role->rid);
     //print "2";print_r($role);exit;
    }
  }
}

but it is not working : user's role is not updating
my hook_update_user is correctly called,
i clear cache after all change in script ,
i have syslog and database logging enabled to see the error log, but there is no error

When i doing like this (with just one condition), it's working , i have no problem : user's role is correctly updated accoding the condition

function my_module_user_update(&$edit, $account, $category) {

     if($account->field_my_field['und'][0]['value'] == 1 ) {
       $uid = $account->uid;
       $role_name = 'Spanish';
       if ($role = user_role_load_by_name($role_name)) {
            user_multiple_role_edit(array($uid), 'add_role', $role->rid);
          //print "1";print_r($role);exit;
       }
    }

}

any ideas ?


texts: How to access variable from a Drupal behaviour in another function?

texts:
Im working on JavaScript which is within this function.

(function($) {
      function initForms() {

        $('.header').once('header-form', function () {
            // my code here
        });

      }
}

In a separate Drupal behaviour I have a variable that I need to access:

(function($) {
  Drupal.behaviors.myModule = {
    attach: function(context, settings) {

      var someVar = something;

    }
  }
})(jQuery);

How can I access the variable someVar in my first block of code?


texts: What is the difference between user_is_anonymous() and user_is_logged_in()?

texts: What is the difference between the two functions? When should one be used instead of the other?


texts: Taxonomy term reference field only from top level terms of a vocabulary

texts:
I have a multilevel taxonomy term vocabulary

Degrees and
i. Specializations

I'd like to use it in two content types. In one case only the top level terms should appear for users, while in other case users can choose only from the 2nd level (this one can be solved by Hierarchical Select module).

Is there any extension of taxonomy form elements that can limit the level that  users can choose from?


texts:
I am trying to alter the "reply" links added to Nodecomment comments when the nodes are listed beneath the topic. The problem I have is that I want users to be restricted to the inline submit form, but Nodecomment is adding links to the standalone reply page.

While trying to ovveride the links using hook_link_alter(), I ran into an issue with Nodecomment comments are treated much like regular comments in that hook_link_alter() doesn't seem to be run on them. Here is an example:

/**
* Alter module links.
*
*/
function mymodule_link_alter(&$links, $node) {

    // This is an example of altering links that works as expected
    if (isset($links['comment_add']) && node_access('create', $node)) {
      $links['comment_reply'] = array(
        'title' => t('reply'),
        'title' => t('Link altered'),
        'href' => 'http://example.com',
      );
    }

    // This is an example of altering nodecomment links failing.
    // When rendering a list of topic replies, the comment_reply link
    // will not be altered.
    if (isset($links['comment_reply']) && node_access('create', $node)) {
      $links['comment_reply'] = array(
        'title' => t('reply'),
        'title' => t('Link altered'),
        'href' => 'http://example.com',
      );
    }
}

I am looking for solutions which can (ideally) be packaged in the site's custom module rather than theme.


texts: Thumbnails not being generated from symlinked directory

texts:
We have set up a symlink that points outside the webroot. The symlink points to a directory that contains images.

The images are accessible on the site, but Drupal is not creating thumbnails of the images, so these are showing up as broken images.

If the directory is a regular directory and not a link, then the thumbnails are generated correctly.

Why does the symlink not work correctly? Is it related to this issue?


texts: How do I iterate through images using file_create_url()?

texts:
I am trying to add Lightbox feature to images. This is the code I used in the node template.

<a class="lightbox" href="<?php echo file_create_url($node->field_images['und'][0]['uri']); ?>" data-plugin-options='{"type":"image"}'>
 <?php print render($content['field_images']); ?>

This works fine if I have the "field_image" limited to 1 value, but in my case the field_image can have several values (the user can upload several images).

For the first image $node->field_images['und'][0]['uri']) is correct; for the second image the path would be $node->field_images['und'][1]['uri']).

So how should I iterate through multiple images?

UPDATE(per @Clive feedback):
Here is my updated code:

<?php if ( ($items = field_get_items('node', $node, 'field_images')) ) {
  foreach ($items as $item) {
   $uri = $item['uri']; ?>

<a class="lightbox" href="<?php print $uri ?>" data-plugin-options='{"type":"image"}'>
<?php print render($content['field_images']); ?>

<?php
}
}
?>

I have 2 issues with it: The URL is not correct per my comment below. Second on every iteration it prints all images. For example if I have 2 images: it prints {img1/url1, img2/url1} and then on the next iteration it prints {img1/url2, img2/url2} instead of img1/url1 on the first iteration and then on the second iteration img2/url2.

How would I modify the 'print render($content[]);' to print partial content?

How  would I modify the $uri to print the full URL path?

UPDATE2(per @Rupesh feedback):
Here is my updated code:

<?php if ( ($items = field_get_items('node', $node, 'field_images')) ) {
  foreach ($items as $item) {
   $uri = $item['uri']; ?>

<a class="lightbox" href="<?php print file_create_url($uri); ?>" data-plugin-options='{"type":"image"}'>
<?php print render($content['field_images']); ?>

<?php
}
}
?>

Now the only issue I have is that on every iteration it prints all images. For example if I have 2 images: it prints {img1/url1, img2/url1} and then on the next iteration it prints {img1/url2, img2/url2} instead of img1/url1 on the first iteration and then on the second iteration img2/url2.

Now I need I modify the 'print render($content[]);' to print a partial content on every iteration. For example on first iteration it will be print render($content[][0]); and on second iteration it will be print render($content[][1]); etc.

Something like that (it does not work, with a blank page )

<?php for ($i = 0; $i < count($content['field_images']); $i++):
 print render($content['field_images'][$i]); ?>
 endfor;
?>

The count is wrong, it outputs 17 instead of just 2 images.
What would I change in in the code above to get it to work?

Thanks.


texts:
I can get CSRF token to be generated on particular route by putting _crsf_token in a routing file, but on visiting that route , I keep getting an Access Denied error.

Removing CSRF token line from the routing file gives me back access to the access instantly.

What could be possibly wrong?

I have tried to make sense of Menu Callback and CSRF but don't think it is related to my problem.


texts:
Drupal allows you to create "extra fields" through hook_field_extra-fields.

I'd like to be able to load javascript (among other things) in my module, based on the presence of one of these fields, but I can't seem to find a hook that will fire before it renders.

I've tried hook_preprocess_HOOK (for mymodule_preprocess_field), but that didn't work. You can detect for it on hook_preprocess_node, but that doesn't work if the field is being rendered individually, or a in a view. Any ideas?


texts:
Using the EntityQuery API I am trying to add a group by clause to the query, however, it doesn't seem that one exists.  The EntityQuery API does not have a groupBy() method.

Current Code:

$nodes = Drupal::entityQuery('node')
    ->condition('type', 'thing')
    ->condition('field_num_1', 'value', '=')
    ->condition('field_num_2', 'value', '=')
    ->range(0, 10)
    ->sort('title', 'ASC')
    ->execute();

Ideal Code:

$nodes = Drupal::entityQuery('node')
    ->condition('type', 'thing')
    ->condition('field_num_1', 'value', '=')
    ->condition('field_num_2', 'value', '=')
    ->groupBy('field_num_3')
    ->range(0, 10)
    ->sort('title', 'ASC')
    ->execute();


texts: Unknown directories /pipermail /poll accessible in Drupal 7

texts:
My Drupal 7 install, has the Simplenews and Polls modules enabled, but Simplenews is set to subscribe registered members only, and Polls are only open to authenticated users. Yet, the mysite.com/pipermail and mysite.com/poll directories are accessible to anonymous view.

The mysite.com/poll directory returns a page with the Drupal theme only, and the word "Polls" in the page title, and no other data. The mysite.com/pipermail directory returns a blank page, absolutely no data.

These directories are not seen anywhere in the directory tree when I checked using File Manager in cPanel. This is a CentOS 5.10, php 5.4 install. How does one check Drupal's internal directory tree, especially to verify whether the permissions are correctly set on these unknown directories?

How do I remove these problematic directories? Also, is it possible that this flaw can be maliciously attacked, say by ftp upload means, etc.?


texts: How to ensure that node access check results are enforced everywhere?

texts:
I am trying to do this without hook_node_grants because, for some reason, it messes with the nodes that are being controlled by the 'Group' module. The Group module itself used to use Node grants, but they got rid of all of its implementations back in July of this year.
For my use case, in addition to grouped nodes, I need private nodes that can allow for access based on field values. And right now to achieve this I am using hook_node_access in a custom module.
The issue with this is that it doesn't work for all the other things, like views and I do not know how many others there are. So, this I'd like to know:
Is there a way to do the access checks once and have them enforced everywhere? ( is hook_access_query_alter the way to do it)?
If there isn't a unified way to go about it? How many access checks should be implemented for a secure approach?


texts:
How to setup subscription for a particular role using the ecommerce module.
I want certain users to only be able to access certain content using a role. On registration I want the user to have to pay for a subscription to access special content.


texts:
I am trying to have all my taxonomy terms to look different from each other.

Is there  a way for me add specific CSS classes to differing taxonomy terms?


texts: Minimum password length for registration form

texts: For user registration, I have disabled "Require e-mail verification when a visitor creates an account." to allow user create their own password at the registration form. Now, I wonder how to limit the password characters to minimum 6? I have tested several times, it seems drupal doesn't restrict any password characters even user keys in just 3 characters.


texts:
I'm using the webform module for a contactform. But when the submission doesn't validate the user can't click away the alert box.

×

Look's like there is no js function attached. Is there a setting in the module for closing the alert box or should you implement it yourself?


texts: Using the Commerce Kickstart distribution to sell non-standard products

texts:
I've been using the Commerce Kickstart distribution for physical products and it work great.

Now I find myself in a situation which could be the common for many of us.

I need to start a new project where the product to sell is a Parcel Delivery Service. Very similar to this one: http://www.parcel2go.com/

Then, from my point of view, the process is:

  1) The user enters required data (Collection, Destination, Weight,
  etc)

  2) Clicks the button "quote"

  3) System generates a single product with a calculated price (based on
  the data entered by the user)

  4) The user add the product to the cart and follows the checkout in the standard way

The difference is that there is no previously created products in this site. I think that  there is just one product which I can call "Delivery Service" but this product has no price. This price will be generated on the fly by a formula using the data entered by the user.

Is this the right approach?

Can I use the Commerce Kickstart distribution for this case? If so, which other module could be useful for this case?


texts: Using References module, is it possible to only show nodes created by the logged in user in select list?

texts: I made a node reference field and it gives me a select list of all the nodes of a specific content type. However I only want the select list to show the nodes made by the logged in user. Is there any way to set conditions some way?


texts:
I have extended services module and created a custom web service to get and post data.
The problem is on the first rest call I get proper response but on the next response I receive "null" where as in my local environment the code works fine.

here is the code:

    $api = array(
    'pe_quiz_api' => array(
      'operations' => array(
        'retrieve' => array(
          'help' => 'Retrieve a quiz',
          'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'includes/pe_quiz_api.services'),
          'callback' => '_pe_quiz_api_resource_retrieve',
          'args' => array(
            array(
              'name' => 'qid',
              'optional' => FALSE,
              'source' => array('path' => 0),
              'type' => 'int',
              'description' => 'The qid of the quiz to retrieve.',
            ),
          ),
          'access arguments' => array('access content'),
        ),
        'create' => array(
          'help' => 'Create a quiz submission',
          'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'includes/pe_quiz_api.services'),
          'callback' => '_pe_quiz_api_resource_create',
          'args' => array(
            array(
              'name' => 'submit_data',
              'optional' => FALSE,
              'source' => 'data',
              'description' => 'quiz submission entry',
              'type' => 'array',
            ),
          ),
          'access arguments' => array('access content'),
        ),
      ),
    ),
  );
  return $api;


texts:
I am trying a configuration where I have drupal commerce setup in different subdomains representing different stores using domain access and domain access entity.

My issues is that when i enable paypal wps rule as payment method, the same information that I have for receiver in one subdomain is copied over to all subdomains. Is it possible to have a unique payment method details by each subdomain? So products purchased from one subdomain are processeed by its own unique payment method details?  Can rules be used to identify which domain the order is from and process it for payment details for that domain?