Comments (4)
@MikeHarrison could you please share the code for the virtual pages in here as well? So probably the artwork and images models
from kirby.
Hi,
Sure no problem, they are below:
site/models/artwork.php
<?php
class ArtworkPage extends Page
{
public function children(): Kirby\Cms\Pages
{
$images = [];
if($image = $this->mainImage()->toFile()):
$images[] = [
'slug' => $image->name(),
'num' => 0,
'template' => 'lightbox-image',
'model' => 'lightbox-image',
];
endif;
if($this->additionalImages()->isNotEmpty()):
foreach ($this->additionalImages()->toFiles() as $image) {
$images[] = [
'slug' => $image->name(),
'num' => $image->sort()->value(),
'template' => 'lightbox-image',
'model' => 'lightbox-image',
];
}
endif;
return Pages::factory($images, $this);
}
}
site/models/lightbox-image.php
<?php
class LightboxImagePage extends Page
{
public function image(string $filename = null): Kirby\Cms\File|null
{
if (!$filename) {
return $this->parent()->images()->template('image')->findBy('name', $this->slug());
}
return parent::image($filename);
}
}
I do also have a minimal example set up in the Plainkit if that is of use, I can send a zip file over
from kirby.
Hi!
Is there anything else I can do to help with getting this diagnosed or addressed? I am keen to find a resolution if possible - is it a bug, or an error in my implementation?
from kirby.
I have got this working now, with help from @texnixe . Updated model is below for reference, I will close the issue as it was my implementation not a Kirby problem.
<?php
class ArtworkPage extends Page
{
public Pages|null $children = null;
public function children(): Kirby\Cms\Pages
{
if ($this->children instanceof Pages) {
return $this->children;
}
$images = [];
if($image = $this->mainImage()->toFile()):
$images[] = [
'slug' => $image->name(),
'num' => 0,
'template' => 'lightbox-image',
'model' => 'lightbox-image',
];
endif;
if($this->additionalImages()->isNotEmpty()):
foreach ($this->additionalImages()->toFiles() as $image) {
$images[] = [
'slug' => $image->name(),
'num' => $image->sort()->value(),
'template' => 'lightbox-image',
'model' => 'lightbox-image',
];
}
endif;
return $this->children = Pages::factory($images, $this);
}
}
from kirby.
Related Issues (20)
- Trailing link is broken when rendering writer field with `widont()` HOT 1
- Ctrl + S in structure field containing date fields clears content HOT 3
- Impossible to remove date field content HOT 1
- Using the quickstart guide creating a new kirby project with composer leads into a frontpage with missing images HOT 4
- Adding role-specific `preview` permission to blueprint results in Panel error HOT 2
- [Panel] Email Dialog: Wrong translation key for title field
- Duplicated pages with copy files enabled still links to original files UUID HOT 1
- Page tables load very slow in 4.2 HOT 16
- Date field behaves weird when "display" MM/YYYY is used
- Search in panel shows old results when response times from server vary HOT 1
- Calendar not working with empty date field included in a structure field
- Unsaved changes bubble clipped and wrongly position on active/hovered tab HOT 1
- Files: don't run thumb processing if image smaller than the `create` dimensions HOT 2
- Hide page view options dropdown with no actionable options HOT 3
- Unexpected issue with sorting on setting the num prop when creating pages in code. HOT 4
- Failing Test for DateTest
- Non existing files throw error 500: the thumbnail configuration could not be found
- `k-table`: index column too narrow for high indexes
- File browser doesn't start at current page HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kirby.