Drupal StackExchange

Get Checkbox Value From Another Form

1 day 9 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

1 day 10 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

1 day 11 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

1 day 12 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

How to export custom module form content as PDF file in drupal 7?

1 day 14 hours ago

I have a custom module with some form fields. I want to submit this form and generate pdf file of user filled values in new tab. I am trying with TCPDF but it doesn't display any fieldset ( as border ).

In submit funciton , I am taking $form array and using drupal_render($form) that render form values as html ( if I print ). If I pass this html to WriteHTML($html, true) , it gives pdf but there is no styling left on that form.

atyagi

The Facebook Autopost module "user hasn't authorized the application"

1 day 15 hours ago

I have a problem with the Facebook Autopost module for Drupal 7.28): After publishing a node, I get an authorization error.

Facebook SDK threw an error: OAuthException: (#200) The user hasn't authorized the application to perform this action

I have checked permissions "Publish Actions", "Publish Stream", "Manage Pages" for Administrator role in fbpermissions module.

Also, I have submitted "manage_pages" in my app but cannot submit "publish_actions" because of this:

It looks like you haven't made any API requests to access content with the publish_actions permission in the last 30 days.

Don't know what to do now. Have no idea why it's not working and what Facebook app permissions are missing. Was googling it for an about 2 hours. Checked all found solutions... none of them worked...

Jazi

Set node to flagged by default

1 day 18 hours ago

I'm using flags on my site as a way of filtering content through views, when a user views a certain node content type, I have a rule setup which resets the value of my flag and sets it against that user for that node, the views will reference this information and change their output accordingly.

The problem I have at the moment is what happens when anonymous users enter the site for the first time, they have no flag set, and thus none of the views show anything, until they travel to one of these special nodes.

What I'm looking for is: is it possible to set a flag to a default value, so that everyone has this node tagged until it gets changed?

Andrew Morris

Drupal Planet

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

1 day 10 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