Drupal StackExchange

Use ajax to save modal / dialog form instead of page reload

1 month 3 weeks ago

I'm looking for a way to save modal & dialog forms through ajax instead of redirecting the user after the form submit. Ajax is quite unknown territory to me.

I've found several interesting topics here already:

jQuery UI Dialog attempt to submit a form using AJAX redirects me to the actual form page instead of AJAX submitting

How to close modal after form submit?

I tried all answers shown there, but without luck. I'm using Drupal 9 and it seems that the code can be slightly different between 8 & 9 versions. I tried digging in the documentation pages on drupal.org but can't seem to find anything useful to my case.

Apoc

How can I return a different number of results per page for a view if a user is accessing the site with a mobile device?

1 month 3 weeks ago

I have a large number of views that show member profiles. Right now, I only show 8 members per page, because on a mobile device it takes a very long time to scroll.

However, for the desktop, I could easily show 20 members per page.

Since there are a large number of views, I don't want to do this if I have to duplicate all of them and change the pager settings. Is there another way to return a different number of results per page if the user is on a mobile device?

Patrick Kenny

Exposed filters in Block for Page View do not filter results

1 month 3 weeks ago

I have below content types with following related fields setup in a Drupal7 setup.

Activity Fields: Name, Body and Image.

Event Fields:

  • Date
  • Location: Term Reference for Taxonomy Location
  • Activity : Term Reference for Taxonomy Location
  • Organiser: Entity Reference for Organizer node (as 1 event will have only 1 organizer)

Organiser Fields:

  • Location: Term reference for Location taxonomy
  • Activity: Entity Reference for node Activity.

I have setup a Page View named Experience, with Listing of Events on right sidebar and on left sidebar i want to display the Filters.

I have managed to Expose the filter with BEF, however these filters don't give any result after changing value. Though they are set to Use Ajax.

Also other filters like Organiser and Location are autocomplete fields, these fields do not show-up any value on entering text.

Kindly help

UPDATE: Here's the SQL Query

SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, 'node' AS field_data_field_event_date_node_entity_type, 'node' AS field_data_field_event_image_node_entity_type, 'node' AS field_data_field_event_location_node_entity_type, 'node' AS field_data_field_event_amount_node_entity_type FROM {node} node LEFT JOIN {field_data_field_event_club} field_data_field_event_club ON node.nid = field_data_field_event_club.entity_id AND (field_data_field_event_club.entity_type = 'node' AND field_data_field_event_club.deleted = '0') WHERE (( (node.status = '1') AND (node.type IN ('event')) AND (field_data_field_event_club.field_event_club_target_id IS NOT NULL ) )) ORDER BY node_created DESC LIMIT 12 OFFSET 0
SNaushadS

Altering ImageField Widget with FUpload enabled

1 month 3 weeks ago

I need to alter the ImageField Widget so that I can add some fields other than the Description, Alt and Title fields. I'm able to do this when I select the file field widget type as Image Uplaod, but when I select the FUpload widget type, the changes don't take effect. Here's the code I'm using:

function bridge_widgets_imagefield_extended_widget($element, $extra_values) { // If you need the field or widget to conditionally add a FAPI field, use these. $field = content_fields($element['#field_name'], $element['#type_name']); $widget = $field['widget']; if( $element['#type_name'] == 'property_gallery' ){ global $user; user_load($user); return array( //This will Replace the Textfield with dropdown select for the description 'revise' => array( '#type' => 'checkbox', '#title' => t('Revise This Description'), '#default_value' => isset($extra_values['revise']) ? $extra_values['revise'] : 0, '#attributes'=>array('class' => 'revise-check') ), 'revisedby' => array( '#type' => 'textfield', '#maxlength' => 64, '#title' => t('Revsied By'), '#default_value' => ($extra_values['revise']==0) ? NULL : $extra_values['revisedby'] , ), 'revisedon' => array( '#type' => 'date', '#title' => t('Date'), '#default_value' => ($extra_values['revise']==0) ? NULL : $extra_values['revisedon'] , ), ); } }
user2014

Map or Edit Query String Values in Views?

1 month 3 weeks ago

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.

Sam

Use safe_key in webform emails

1 month 3 weeks ago

I want to be able to send the safe_key through the internal email.
The website was doing this before, and for some reason is not any longer.

I've tried %value[safe_key] and %safekey.
I read some information here, but no one seemed to have an answer that worked.
Is there another token that works? I saw %email[key] but was not sure that it would map right.

Jane

Infinite Redirect Loop with PURL and spaces_og

1 month 3 weeks ago

I created a calendar feature for organic groups, and tried to enable it in a group with spaces_og. The page refreshes saying changes have been saved but the feature is still disabled. In the logs, there is a message that purl prevented a redirect loop.

I realize spaces is still in dev with d7. Is this a known issue? Did I do something wrong when creating my feature, or is there a better way to create features for use in organic groups?

Arosboro

How do I display the language settings (Site language field) on the user registration form?

1 month 3 weeks ago

I'm trying to display the user's language settings field on the registration page, but no success so far.

I've tried using a template (form--user-register-form.html.twig). This works for other fields, like mail, name, but I don't know how to access the language setting field.

I also tried form_alter (both in the theme and module MODULE_user_register_form_alter), and set $form['language']['#access'] = true; This hook doesn't seem to work at all, nothing happens when I try to use it (print out variables for example).

keszthelyi

Drupal Planet

Acquia Developer Portal Blog: Maximizing Learning and Networking: Insights from DrupalCamp New Jersey

1 month 3 weeks ago

A DrupalCamp is a one- or two-day event that centers on the Drupal open source web content management system, and tends to bring together people from a geographical region. The goals are primarily, of course, knowledge sharing and increasing awareness of and helping to grow the Drupal community. It's not easy to do this without also increasing awareness and knowledge of the tools we all use along with Drupal as well, which makes the gatherings all the more valuable.