Add initial /daily page content
This commit is contained in:
parent
34c173b1c9
commit
fb3b58cf97
15 changed files with 885 additions and 1 deletions
|
@ -30,6 +30,20 @@ function opd_daily_emails_entity_presave(Drupal\Core\Entity\EntityInterface $ent
|
|||
\Drupal::service(AddRandomCtaToDailyEmail::class)($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* @param array{'#action': string, '#attributes': array<non-empty-string, mixed>} $form
|
||||
*/
|
||||
function opd_daily_emails_form_opd_daily_emails_kit_subscription_form_alter(array &$form): void {
|
||||
$form['#action'] = 'https://app.convertkit.com/forms/3546728/subscriptions';
|
||||
|
||||
$form['#attributes']['data-format'] = 'inline';
|
||||
$form['#attributes']['data-sv-form'] = '3546728';
|
||||
$form['#attributes']['data-uid'] = 'f0c1d2b57f';
|
||||
$form['#attributes']['data-version'] = 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_token_info().
|
||||
*
|
||||
|
|
48
modules/opd_daily_emails/src/Form/KitSubscriptionForm.php
Normal file
48
modules/opd_daily_emails/src/Form/KitSubscriptionForm.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_daily_emails\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
final class KitSubscriptionForm extends FormBase {
|
||||
|
||||
public function getFormId(): string {
|
||||
return 'opd_daily_emails_kit_subscription_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<non-empty-string, array{}> $form
|
||||
* @param FormStateInterface $formState
|
||||
*
|
||||
* @return array<non-empty-string, mixed>
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $formState): array {
|
||||
$form['email_address'] = [
|
||||
'#placeholder' => 'me@example.com',
|
||||
'#title' => $this->t('What is your best email address?'),
|
||||
'#type' => 'email',
|
||||
];
|
||||
|
||||
$form['actions']['submit'] = [
|
||||
'#attributes' => [
|
||||
'class' => ['inline-flex justify-center items-center py-3 px-6 w-full font-medium text-white no-underline rounded-md border duration-200 ease-in-out hover:bg-white focus:bg-white border-blue-primary bg-blue-primary transition-color hover:text-blue-primary focus:text-blue-primary'],
|
||||
'data-element' => 'submit',
|
||||
],
|
||||
'#type' => 'button',
|
||||
'#value' => $this->t('Get daily emails') . ' →',
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<non-empty-string, mixed> $form
|
||||
* @param FormStateInterface $formState
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $formState): void {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_daily_emails\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\Attribute\Block;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormBuilderInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\opd_daily_emails\Form\KitSubscriptionForm;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
#[Block(
|
||||
admin_label: new TranslatableMarkup("Kit Subscription Block"),
|
||||
category: new TranslatableMarkup("Daily emails"),
|
||||
id: "opd_daily_emails_kit_subscription_block",
|
||||
)]
|
||||
final class KitSubscriptionFormBlock extends BlockBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param string $pluginId
|
||||
* @param array<string, mixed> $pluginDefinition
|
||||
* @param FormBuilderInterface $formBuilder
|
||||
*/
|
||||
public function __construct(
|
||||
array $configuration,
|
||||
string $pluginId,
|
||||
array $pluginDefinition,
|
||||
private FormBuilderInterface $formBuilder,
|
||||
) {
|
||||
parent::__construct($configuration, $pluginId, $pluginDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<non-empty-string, mixed>
|
||||
*/
|
||||
public function build(): array {
|
||||
return $this->formBuilder->getForm(KitSubscriptionForm::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param string $pluginId
|
||||
* @param array<string, mixed> $pluginDefinition
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $pluginId, $pluginDefinition): self {
|
||||
return new static(
|
||||
$configuration,
|
||||
$pluginId,
|
||||
$pluginDefinition,
|
||||
$container->get(FormBuilderInterface::class),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue