Site prev next
This commit is contained in:
parent
e86468e3fb
commit
92c9819fdb
|
@ -29,6 +29,7 @@
|
||||||
"drupal/page_manager": "^4.0@RC",
|
"drupal/page_manager": "^4.0@RC",
|
||||||
"drupal/panels": "^4.8",
|
"drupal/panels": "^4.8",
|
||||||
"drupal/paragraphs": "^1.17",
|
"drupal/paragraphs": "^1.17",
|
||||||
|
"drupal/quick_node_clone": "^1.18",
|
||||||
"drupal/simple_sitemap": "^4.1",
|
"drupal/simple_sitemap": "^4.1",
|
||||||
"drupal/social_media_links": "^2.9",
|
"drupal/social_media_links": "^2.9",
|
||||||
"drupal/yaml_editor": "^1.2",
|
"drupal/yaml_editor": "^1.2",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "79223df96df990c3b850f7ecb6441e64",
|
"content-hash": "e8b3c553a92e6d3283d8e7a0a0a7d159",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asm89/stack-cors",
|
"name": "asm89/stack-cors",
|
||||||
|
@ -6286,6 +6286,61 @@
|
||||||
"source": "https://git.drupalcode.org/project/profile"
|
"source": "https://git.drupalcode.org/project/profile"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "drupal/quick_node_clone",
|
||||||
|
"version": "1.18.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.drupalcode.org/project/quick_node_clone.git",
|
||||||
|
"reference": "8.x-1.18"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://ftp.drupal.org/files/projects/quick_node_clone-8.x-1.18.zip",
|
||||||
|
"reference": "8.x-1.18",
|
||||||
|
"shasum": "ab17077eccb24e5c651fedc5056a50051882a13d"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"drupal/core": "^8.8 || ^9 || ^10"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"drupal/group": "^1 || ^2 || ^3",
|
||||||
|
"drupal/paragraphs": "1.x-dev"
|
||||||
|
},
|
||||||
|
"type": "drupal-module",
|
||||||
|
"extra": {
|
||||||
|
"drupal": {
|
||||||
|
"version": "8.x-1.18",
|
||||||
|
"datestamp": "1707833857",
|
||||||
|
"security-coverage": {
|
||||||
|
"status": "covered",
|
||||||
|
"message": "Covered by Drupal's security advisory policy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packages.drupal.org/8/downloads",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "vilepickle",
|
||||||
|
"homepage": "https://www.drupal.org/u/vilepickle",
|
||||||
|
"role": "Maintainer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Neslee Canil Pinto",
|
||||||
|
"homepage": "https://www.drupal.org/u/neslee-canil-pinto",
|
||||||
|
"role": "Maintainer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Quickly clone a node with regular fields.",
|
||||||
|
"homepage": "https://www.drupal.org/project/quick_node_clone",
|
||||||
|
"support": {
|
||||||
|
"source": "https://git.drupalcode.org/project/quick_node_clone",
|
||||||
|
"issues": "https://www.drupal.org/project/issues/quick_node_clone"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "drupal/redirect",
|
"name": "drupal/redirect",
|
||||||
"version": "1.9.0",
|
"version": "1.9.0",
|
||||||
|
|
|
@ -91,6 +91,7 @@ module:
|
||||||
pathologic: 0
|
pathologic: 0
|
||||||
persistent_login: 0
|
persistent_login: 0
|
||||||
q2d_mod: 0
|
q2d_mod: 0
|
||||||
|
quick_node_clone: 0
|
||||||
redis: 0
|
redis: 0
|
||||||
responsive_image: 0
|
responsive_image: 0
|
||||||
search_api: 0
|
search_api: 0
|
||||||
|
|
|
@ -9,6 +9,7 @@ dependencies:
|
||||||
- ctools_block
|
- ctools_block
|
||||||
- node
|
- node
|
||||||
- panels
|
- panels
|
||||||
|
- q2d_mod
|
||||||
- views
|
- views
|
||||||
id: node_view-panels_variant-0
|
id: node_view-panels_variant-0
|
||||||
label: Sites
|
label: Sites
|
||||||
|
@ -188,6 +189,19 @@ variant_settings:
|
||||||
- ''
|
- ''
|
||||||
html_id: ''
|
html_id: ''
|
||||||
css_styles: ''
|
css_styles: ''
|
||||||
|
585c2156-c9db-4940-8382-0744350facf6:
|
||||||
|
id: prevnextsite_block
|
||||||
|
label: 'PrevNext Site Block'
|
||||||
|
label_display: '0'
|
||||||
|
provider: q2d_mod
|
||||||
|
context_mapping: { }
|
||||||
|
region: third
|
||||||
|
weight: 0
|
||||||
|
uuid: 585c2156-c9db-4940-8382-0744350facf6
|
||||||
|
css_classes:
|
||||||
|
- ''
|
||||||
|
html_id: ''
|
||||||
|
css_styles: ''
|
||||||
page_title: ''
|
page_title: ''
|
||||||
layout: layout_threecol_25_50_25
|
layout: layout_threecol_25_50_25
|
||||||
layout_settings:
|
layout_settings:
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
_core:
|
||||||
|
default_config_hash: 6XRelHPjACQVOo9yRQMmbXt-ysCA2Pt6l762bxQQbdw
|
||||||
|
langcode: fr
|
||||||
|
exclude:
|
||||||
|
node: { }
|
||||||
|
paragraph: { }
|
||||||
|
text_to_prepend_to_title: 'Clone of'
|
||||||
|
clone_status: false
|
|
@ -18,6 +18,7 @@ dependencies:
|
||||||
- filter
|
- filter
|
||||||
- locale
|
- locale
|
||||||
- node
|
- node
|
||||||
|
- quick_node_clone
|
||||||
- system
|
- system
|
||||||
- toolbar
|
- toolbar
|
||||||
_core:
|
_core:
|
||||||
|
@ -35,6 +36,10 @@ permissions:
|
||||||
- 'administer nodes'
|
- 'administer nodes'
|
||||||
- 'administer users'
|
- 'administer users'
|
||||||
- 'change own username'
|
- 'change own username'
|
||||||
|
- 'clone actualite content'
|
||||||
|
- 'clone partenaire content'
|
||||||
|
- 'clone site content'
|
||||||
|
- 'clone static content'
|
||||||
- 'create actualite content'
|
- 'create actualite content'
|
||||||
- 'create content translations'
|
- 'create content translations'
|
||||||
- 'create partenaire content'
|
- 'create partenaire content'
|
||||||
|
|
|
@ -15,6 +15,7 @@ dependencies:
|
||||||
- filter
|
- filter
|
||||||
- locale
|
- locale
|
||||||
- node
|
- node
|
||||||
|
- quick_node_clone
|
||||||
- system
|
- system
|
||||||
- toolbar
|
- toolbar
|
||||||
id: editeur
|
id: editeur
|
||||||
|
@ -27,6 +28,7 @@ permissions:
|
||||||
- 'access site in maintenance mode'
|
- 'access site in maintenance mode'
|
||||||
- 'access toolbar'
|
- 'access toolbar'
|
||||||
- 'administer nodes'
|
- 'administer nodes'
|
||||||
|
- 'clone site content'
|
||||||
- 'create actualite content'
|
- 'create actualite content'
|
||||||
- 'create content translations'
|
- 'create content translations'
|
||||||
- 'create partenaire content'
|
- 'create partenaire content'
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\q2d_mod\Plugin\Block;
|
||||||
|
|
||||||
|
use Drupal\Core\Block\BlockBase;
|
||||||
|
use Drupal\Core\Block\Attribute\Block;
|
||||||
|
// use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||||
|
use Drupal\Core\Link;
|
||||||
|
use Drupal\Core\Render\Markup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a 'Prevnext' Block.
|
||||||
|
* @Block(
|
||||||
|
* id = "prevnextsite_block",
|
||||||
|
* admin_label = @Translation("PrevNext Site Block"),
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class PrevNextSite extends BlockBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function build() {
|
||||||
|
$return = null;
|
||||||
|
/** @var Drupal\node\Entity\Node */
|
||||||
|
$node = \Drupal::routeMatch()->getParameter('node');
|
||||||
|
if ($node) {
|
||||||
|
$nodetype = $node->getType();
|
||||||
|
if($nodetype === "site"){
|
||||||
|
$num = $node->get('field_numero')->getString();
|
||||||
|
$allSites = \Drupal::entityTypeManager()->getStorage('node')
|
||||||
|
->loadByProperties(['type' => 'site', 'status' => 1]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
usort($allSites, function($a, $b){
|
||||||
|
$numA = $a->get('field_numero')->getString();
|
||||||
|
$numB = $b->get('field_numero')->getString();
|
||||||
|
if ($numA == $numB) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($numA < $numB) ? -1 : 1;
|
||||||
|
});
|
||||||
|
$prevnode = null;
|
||||||
|
$nextnode = null;
|
||||||
|
foreach($allSites as $index => $site){
|
||||||
|
$n = $site->get('field_numero')->getString();
|
||||||
|
if($n === $num){
|
||||||
|
$prevnode = $index - 1 >= 0 ? $allSites[$index - 1] : null;
|
||||||
|
$nextnode = $index + 1 < count($allSites) ? $allSites[$index + 1] : null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = [
|
||||||
|
'#cache' => [
|
||||||
|
'max-age' => 0,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($prevnode)) {
|
||||||
|
$prev_link_title = Markup::create('<span>Précédent</span>');
|
||||||
|
$prev_options = ['absolute' => FALSE, 'attributes' => ['class' => 'prev-site']];
|
||||||
|
$prev_link_object = Link::createFromRoute($prev_link_title, 'entity.node.canonical', ['node' => $prevnode->id()], $prev_options);
|
||||||
|
$return[] = $prev_link_object->toRenderable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($nextnode)) {
|
||||||
|
$next_link_title = Markup::create('<span>Suivant</span>');
|
||||||
|
$next_options = ['absolute' => FALSE, 'attributes' => ['class' => 'next-site']];
|
||||||
|
$next_link_object = Link::createFromRoute($next_link_title, 'entity.node.canonical', ['node' => $nextnode->id()], $next_options);
|
||||||
|
$return[] = $next_link_object->toRenderable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
// return [
|
||||||
|
// '#markup' => $this->t('Hello, World!'),
|
||||||
|
// ];
|
||||||
|
}
|
||||||
|
public function getCacheMaxAge() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue