-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Replace title with new title and metadata block and layout for …
…posts
- Loading branch information
1 parent
435ae37
commit 0d1ec68
Showing
9 changed files
with
191 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
...les/custom/yalesites_profile/modules/custom/ys_layouts/src/Plugin/Block/PostMetaBlock.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace Drupal\ys_layouts\Plugin\Block; | ||
|
||
use Drupal\Core\Block\BlockBase; | ||
use Drupal\Core\Controller\TitleResolver; | ||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
use Drupal\Core\Routing\RouteMatchInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Drupal\node\NodeInterface; | ||
|
||
/** | ||
* Block for post meta data that appears above posts. | ||
* | ||
* @Block( | ||
* id = "post_meta_block", | ||
* admin_label = @Translation("Post Meta Block"), | ||
* category = @Translation("YaleSites Layouts"), | ||
* ) | ||
*/ | ||
class PostMetaBlock extends BlockBase implements ContainerFactoryPluginInterface { | ||
|
||
/** | ||
* The current route match. | ||
* | ||
* @var \Drupal\Core\Routing\RouteMatchInterface | ||
*/ | ||
protected $routeMatch; | ||
|
||
/** | ||
* The current route match. | ||
* | ||
* @var \Drupal\Core\Controller\TitleResolver | ||
*/ | ||
protected $titleResolver; | ||
|
||
/** | ||
* The request stack. | ||
* | ||
* @var \Symfony\Component\HttpFoundation\RequestStack | ||
*/ | ||
protected $requestStack; | ||
|
||
/** | ||
* Constructs a new YaleSitesBreadcrumbBlock object. | ||
* | ||
* @param array $configuration | ||
* A configuration array containing information about the plugin instance. | ||
* @param string $plugin_id | ||
* The plugin_id for the plugin instance. | ||
* @param mixed $plugin_definition | ||
* The plugin implementation definition. | ||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match | ||
* The route match. | ||
* @param \Drupal\Core\Controller\TitleResolver $title_resolver | ||
* The title resolver. | ||
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack | ||
* The request stack. | ||
*/ | ||
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match, TitleResolver $title_resolver, RequestStack $request_stack) { | ||
parent::__construct($configuration, $plugin_id, $plugin_definition); | ||
$this->routeMatch = $route_match; | ||
$this->titleResolver = $title_resolver; | ||
$this->requestStack = $request_stack; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | ||
return new static( | ||
$configuration, | ||
$plugin_id, | ||
$plugin_definition, | ||
$container->get('current_route_match'), | ||
$container->get('title_resolver'), | ||
$container->get('request_stack'), | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function build() { | ||
|
||
/** @var \Drupal\node\NodeInterface $node */ | ||
$node = $this->routeMatch->getParameter('node'); | ||
if (!($node instanceof NodeInterface)) { | ||
return []; | ||
} | ||
|
||
// Post fields. | ||
$title = $node->getTitle(); | ||
$publishDate = strtotime($node->field_publish_date->first()->getValue()['value']); | ||
$dateFormatted = \Drupal::service('date.formatter')->format($publishDate, '', 'c'); | ||
return [ | ||
'#theme' => 'ys_post_meta_block', | ||
'#label' => $title, | ||
'#date_formatted' => $dateFormatted, | ||
]; | ||
} | ||
|
||
} |
111 changes: 0 additions & 111 deletions
111
...om/yalesites_profile/modules/custom/ys_layouts/src/UpdateExisting/UpdatePageTwoColumn.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...custom/yalesites_profile/modules/custom/ys_layouts/templates/ys-post-meta-block.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% include "@molecules/page-title/yds-page-title.twig" with { | ||
page_title__heading: label, | ||
page_title__meta: content.field_author|render ~ date_formatted|date("l, F j, Y"), | ||
page_title__width: 'content', | ||
} %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters