Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SGD8-2526: Update timeline items order #964

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions gent_base.theme
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
*/

use Drupal\block\Entity\Block;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Markup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Template\Attribute;
use Drupal\Component\Utility\Html;
use Drupal\Core\Url;
use Drupal\gent_base\FormPrerender;
use Drupal\image\Entity\ImageStyle;
use Drupal\node\NodeInterface;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Render\Element;
use Drupal\paragraphs\ParagraphInterface;

include __DIR__ . '/includes/theme.inc';
Expand Down Expand Up @@ -441,6 +441,17 @@ function gent_base_preprocess_field(&$variables) {
$timelineOdd = ($timelineItems % 2 !== 0);
$variables['items'][$key]['content']['reversed'][0] = $reversed;

$timelineItems = count($entity->get('timeline_items')->referencedEntities());
$variables['items'][$key]['content']['counter'][0] = $timelineItemTotal;
$timelineItemTotal += $timelineItems;

if ($timelineOdd) {
$reversed = !$reversed;
}

$timelineOdd = ($timelineItems % 2 !== 0);
$variables['items'][$key]['content']['reversed'][0] = $reversed;

// It's the first timeline frame.
if ($firstTimeline === FALSE) {
$firstTimeline = TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@
*/
#}

{% set items_total = content.counter.0 %}
{% set reversed = content.reversed.0 %}

{% set classes = [
'programme-slot'
'programme-slot',
items_total is odd ? 'timeline-slot-odd' : 'timeline-slot-even',
reversed ? 'timeline-slot-reverse' : ''
] %}
{{ attach_library('gent_base/modal') }}

Expand Down