description: > Base example for rendering a sequence navigation.
48{
51 $r =
$DIC[
'ui.renderer'];
52 $df = new \ILIAS\Data\Factory();
54 $request =
$DIC->http()->request();
55
57 private array $seq_data;
58
60 protected UIFactory
$f,
61 protected UIRenderer $r
62 ) {
63 $this->seq_data = [
64 ['c0', 'pos 1', '<div style="width: 100%;
65 height: 500px;
66 background-color: #b8d7ea;
67 display: flex;
68 align-items: center;
69 justify-content: center;">
70 placeholder for the segment at position 1</div>'],
71 ['c0', 'pos 2', '<div style="width: 100%;
72 height: 700px;
73 background-color: #f6d9a1;
74 display: flex;
75 align-items: center;
76 justify-content: center;">
77 placeholder for the segment at position 2</div>'],
78 ['c1', 'pos 3', 'the segment at position 3'],
79 ['c2', 'pos 4', 'the segment at position 4'],
80 ['c1', 'pos 5', 'the segment at position 5'],
81 ];
82 }
83
84 public function getAllPositions(
85 ServerRequestInterface $request,
86 mixed $viewcontrol_values,
87 mixed $filter_values,
88 ): array {
89 $chunks = $viewcontrol_values['chunks'] ?? [];
90 $chunks[] = 'c0';
91 return array_values(
92 array_filter(
93 $this->seq_data,
94 fn($posdata) => in_array($posdata[0], $chunks)
95 )
96 );
97 }
98
99 public function getSegment(
100 ServerRequestInterface $request,
101 mixed $position_data,
102 mixed $viewcontrol_values,
103 mixed $filter_values,
105 list($chunk, $title,
$data) = $position_data;
106
107 $segment = $this->f->legacy()->segment($title,
$data);
108
109 if ($chunk === 'c0') {
111 $this->f->button()->standard('a segment action for ' . $title, '#')
112 );
113 }
114 return $segment;
115 }
116 };
117
118 $viewcontrols =
$f->input()->container()->viewControl()->standard([
119 $f->input()->viewControl()->fieldSelection(
120 [
121 'c1' => 'chunk 1',
122 'c2' => 'chunk 2',
123 ],
124 'shown chunks',
125 'apply'
126 )
127 ->withAdditionalTransformation(
$refinery->custom()->transformation(
128 fn($v) => ['chunks' => $v]
129 ))
130 ])
131 ->withAdditionalTransformation(
132 $refinery->custom()->transformation(fn($v) => array_shift($v))
133 );
134
135 $global_actions = [
136 $f->button()->standard(
'a global action',
'#')
137 ];
138
139 $sequence =
$f->navigation()->sequence($binding)
140 ->withViewControls($viewcontrols)
141 ->withId('example')
142 ->withActions($global_actions)
143 ->withRequest($request);
144
147
148 return $r->render(
$out);
149}
withSegmentActions(Button\Standard ... $actions)
Segments MAY add actions to the sequence.
The SegmentRetrieval defines available stops for the sequence and builds it's segments.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc