Initial commit
This commit is contained in:
commit
65e0da7e11
1397 changed files with 596542 additions and 0 deletions
36
site/OFF_plugins/popnoire.php
Normal file
36
site/OFF_plugins/popnoire.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
// UPDATE TRACKS INDEX OF ALL RELEASE EACH TIME SOMETHING HAPPENS WITH A RELEASE
|
||||
|
||||
// Each time something happens with a page
|
||||
kirby()->hook('panel.page.*', function($page, $oldPage = null) {
|
||||
// If the page is a release
|
||||
if($page->intendedTemplate() == 'release') {
|
||||
|
||||
// Get all artists
|
||||
$artists = site()->index()->filterBy('intendedTemplate', 'artist');
|
||||
|
||||
// For each artist
|
||||
foreach ($artists as $key => $a) {
|
||||
$index = 0;
|
||||
|
||||
// For each release of the artist
|
||||
foreach ($a->children()->published() as $key => $p) {
|
||||
// Get all tracks of the release
|
||||
$tracks = $p->tracklist()->toStructure();
|
||||
|
||||
// For each track
|
||||
foreach ($tracks as $key => $t) {
|
||||
|
||||
// If the track has and audio file
|
||||
if($file = $t->audioFile()->toFile()) {
|
||||
// Update the track index
|
||||
$file->update(['trackIndex' => $index]);
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue