Drupal StackExchange

Filter date from current date to upcoming 7 days?

2 days 23 hours ago

I have a week type calendar view. It currently displays form SUN to SAT of the current week.

But I need to display it starting from current date to current date + 7 days

How can I achieve this?. I am using Calendar Module and created a view using it.

My view is displayed only if I add a contextual filter. With default value as current date. This adds a filter criteria from dates starting from the start of the week and end of the week.

user46121

composer install error

3 days ago

I can't install anything because of this error:

[RuntimeException] Could not scan for classes inside "/app/vendor/symfony/serializer/src/" which does not appear to be a file nor a folder

and subsequently:

Could not scan for classes inside "/app/vendor/symfony/yaml/src/" which does not appear to be a file nor a folder

I navigated to that directory and the src folder is indeed missing...

I'm using Lando and switch the PHP to 7.1. I tried deleting the vendor directory and rerunning lando composer update and lando composer install but get the same errors.

AlxVallejo

Warning: Invalid argument supplied for foreach() in form_select_options() (line 2837 of includes/form.inc)

3 days 1 hour ago

I get the following erros on selecting the selectbox. Here onchang of this field will populate another checkbox with city details id zipcode using ajax callback.

$zipcode_options = get_all_zipcodes_ascending(); // Populate Ort on auktion clone. $selected = isset($auktion->zip_code) ? $auktion->zip_code : NULL; $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected; $ort_options = _ajax_city_dropdown_options($selected); $form['zip_code'] = [ '#type' => 'select', '#title' => t('PLZ'), '#options' => $zipcode_options, '#default_value' => isset($auktion->zip_code) ? $auktion->zip_code : "", '#select2' => ['width' => '100%', 'placeholder' => t('Enter a zipcode'), 'allowClear' => TRUE], '#empty_option' => '', '#validated' => TRUE, '#required' => TRUE, '#ajax' => array( 'event' => 'change', 'callback' => 'ajax_example_dependent_dropdown_callback', 'wrapper' => 'dropdown-second-replace', ), ];

Referenced many links but cannot find a solution to resolve this issue.

References:

https://www.drupal.org/node/586576

populate drop down from results using ajax

http://techqa.info/drupal/question/203725/help-understand/solve-this-warning:-invalid-argument-supplied-for-foreach%28%29-in-views-that-requires-class-registry-clean-to-mend

developer

Get Checkbox Value From Another Form

3 days 2 hours ago

How do i get the value of a checkbox from another form/page and how do i make it so if the checkbox is enabled, it'll allow a button to be visible?

checkbox in SettingsForm.php:

$form['#tree'] = TRUE; $form['clients_enabled'] = array( '#title' => t('Enable PixelPin OpenID Connect'), '#type' => 'checkboxes', '#options' => array('pixelpin' => $this->t('Enable')), '#default_value' => $clients_enabled, );

button ion LoginForm.php:

public function buildForm(array $form, FormStateInterface $form_state) { $definitions = $this->pluginManager->getDefinitions(); foreach ($definitions as $client_id => $client) { foreach ($this->pluginManager->getDefinitions() as $client_name => $client_plugin) { if (!$this->config('pixelpin_openid_connect.settings.' . $client_id) ->get('enabled')) { $url = \Drupal::service('path.current')->getPath(); $find = 'login'; $pos = strpos($url, $find); if ($pos === false){ $value = 'Register Using @client_title'; } else { $value = 'Log in with @client_title'; } $element = 'clients_enabled[' . $client_plugin['id'] . ']'; $form['pixelpin_openid_connect_client_' . $client_id . '_login'] = array( '#type' => 'submit', '#value' => t($value, array( '@client_title' => $client['label'], )), 'visible' => array( ':input[name="' . $element . '"]' => array('checked' => TRUE), ), '#name' => $client_id, '#prefix' => '<div>', '#suffix' => '</div>', ); } } } return $form;
Callum

Retrieve contents from a JSON URL using cURL and display them in an HTML table

3 days 3 hours ago

I am trying to display contents retrieved from an external URL using JSON (the cURL method). So i wrote the below function:

function file_get_contents_curl() { //JSON URL which should be requested $gry_str = "?timezone=" . urlencode(date_default_timezone_get()) . "&dateFrom=" . date('Y-m-d') . "&dateTill=" . date('Y-m-d'); $json_url = 'https://www.example.com/json/financial-calendar.json' . $gry_str; // Initializing curl $ch = curl_init(); //Configuring curl options $options=array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_URL => $json_url); //Setting curl options curl_setopt_array($ch, $options); //Getting resutls $results= curl_exec($ch); //Getting json result string }

I want the contents retrieved to be displayed in an HTML table. So i am using this:

<script id="calendarContentTemplate" type="text/html"> <![CDATA[ <tr> <td class="calendar-local-time"><%= time %></td> <td class="region"><%= region %></td> <td class="title"><%= title %></td> <td><%= forecast %></td> <td><%= previous %></td> </tr> ]]>

and my constructed table like this:

<table class="calendar-table"> <thead> <tr> <th class="time">Time</th> <th class="region">Region</th> <th class="title">Event</th> <th class="forecast">Forecast</th> <th class="previous">Previous</th> </tr> </thead> <tbody> <tr> <td class="calendar-local-time"></td> <td class="region"></td> <td class="title"></td> <td></td> </tr> </tbody> </table>

Nothing is being displayed on the table. Am I doing something wrong? Or do I need a Drupal function to make it work? Forgot to mention that its for the front page.

I have read about the drupal_json_output() function. But I am not sure if I have to use it. When I tried using it my webpage appeared only HTML.

It is very weird, because when I open Firebug I can see in the Net section. I am receiving Status as 200 Ok for request, but the response is completely empty.

Any help is greatly appreciated.

paranod

Call to undefined function menu_load() in .../public_html/includes/menu.inc on line 579

3 days 4 hours ago

I really need your help. Actually, my journey begin with the installation Drupal and some modules. After a couple of days I suddenly get an issue "500 Internal Server Error".

I asked my hosting provider why this happened, they said "That because of the file .htaccess and you should add to this file php display error". So i did this and I get a new issue :

Fatal error: Call to undefined function menu_load() in public_html/includes/menu.inc on line 579.

By the way that's line 579 else {$return = $function($value);}. P.S I am a beginner in PHP. I really want to study Drupal more and create cool sites, but this problem...

user20059

Can not login with HybridAuth

3 days 5 hours ago

I installed Drupal HybridAuth module on my site for social authentication. I configured this module and it is displaying fine on site block. But when I try to login with any Social Media account details, it is processing correctly, but I cannot login in my site. How can I solve this? Here's a link to the site: example.com

Subhajyoti De

Drupal Planet

LN Webworks: How To Create Custom Token In Drupal: Step By Step Guide

2 days 23 hours ago

In Drupal 10, you can create custom tokens using your custom module. Before creating custom tokens, you need to have the Drupal tokens module installed on your Drupal site. This contributed module already comes with some predefined tokens. These defined tokens can be used globally.

Steps to Create the Drupal Custom Tokens

1. Begin by creating a yourmodule.module file in your custom module directory.

2. Establish your custom token type.

 

The Drop Times: Streamlining Local Development with DDEV, Docker, and NGROK

3 days 2 hours ago
Discover how DDEV, Docker, and NGROK can revolutionize your local development process. Our latest guide dives into the seamless integration of these powerful tools, offering you the most efficient way to set up, develop, and test your Drupal projects right from your local machine. Streamline your workflow and enhance productivity with our comprehensive insights!"

Debug Academy: How to create a partial date field in Drupal (i.e. Year & Month without Day)

3 days 3 hours ago
How to create a partial date field in Drupal (i.e. Year & Month without Day)

One of Drupal's main strengths is its data modeling.

But sometimes choosing the appropriate field type comes with a form widget that isn't what we're looking for. For example, using a Date field results in the form displaying a date "widget" (form input) which includes a full date consisting of a day, month, and year, and optionally a time.

How to remove the time from a date field in Drupal

Because removing the time from date fields is such a common request, Drupal allows its removal without writing any custom code.

How to hide the time Drupal's frontend

Fortunately, the date field has a highly configurable display on the frontend. By visiting the "Manage Display" page (or configuring the field's block, if using layout builder), you will have the option of selecting (or creating) a date format.

Follow these steps to change the date's output for your frontend:

ashrafabed Fri, 04/26/2024