I am looking for a concept to create a campaign page.
The structure is comparable to a blog.
However, only the most recent article should be displayed in the frontend, and it should always be accessible via the same link, for example: www.website.com/aktion/
The children will have the following structure and naming:
20231201_aktion ← most recent article 20231101_aktion 20231001_aktion 20230901_aktion
The following questions arise:
How do I display only the latest article?
Do older articles have to be changed to “unlisted”?
How do I change my route if the title (timestamp) of the current article is dynamic?
Here is a panel screenshot for a better visual representation.
The current action page is “listed” and the expired action pages have the “draft” status.
The URL of the current action always changes.
However, this link is not communicated in the newsletter, only the link to the main page.
Well, what you tried above doesn’t make sense, first() returns a single page, not a collection, that’s why you are getting the error.
Ok, so the page aktionen actually exists, so no need for a route, anyway?
As I said above, in your aktion template, all you need to do is to render a single page, i.e. the latest from the collection of subpages. So no collection to loop through.
Unfortunately, I have a logical comprehension problem and for this reason I have not expressed myself clearly. I am therefore referring to the starterkit for my explanation, as the structure is well known here.
Did I understand correctly that with your suggestion, only one item is displayed on the “Notes” overview page? In the case of the starterkit, that would be the article “Exploring the universe”.
My aim is not to display a “Notes” overview page, but to link directly to “Exploring the universe”. The page “Notes” is not needed anyway if there is only one article.
The link www.kirby-starterkit.com/notes/
should lead directly to www.kirby-starterkit.com/notes/exploring-the-universe
and then next month to www.kirby-starterkit.com/notes/exploring-the-next-month
Can I achieve this with a route?
I have to admit that I have about 1% experience with routes
I hope I have now been able to formulate my question more clearly.
Many thanks for your patience.
I have the impression that we are talking at cross purposes.
So let’s start over again. I assumed that you always wanted to display the current campaign under the aktion link.
Or using the Starterkit example: In January the notes page shows the content of the subpage “Exploring the Universe”, in February “Through the desert” and in March “Across the ocean”.
Your last post, on the other hand, is more about a redirect. So, if I visit notes in January, I am redirected to notes/exploring-the-universe, in February to notes/through-the-desert and so on.
Two different things, both possible.
My proposed solution referred to the first option, always the content of a single subpage when a user visits the notes page. And then ideally block direct access to the subpages (via the note template or a route, to prevent duplicate content).
Please disregard the previous articles to avoid confusion.
My idea relates to the realization of a landing page with a fixed link that is communicated in a newsletter.
A page that only displays one article makes no sense. In the panel, however, it does, because the monthly articles are managed there. That’s why I think the starterkit example with notes is also very good, as the articles are structured by date.
The name of the monthly article always changes: www.kirby-starterkit.com/notes/exploring-the-universe www.kirby-starterkit.com/notes/himalaya-and-back
but only the link www.kirby-starterkit.com/notes/ is communicated in the newsletter.
This means that when www.kirby-starterkit.com/notes/ is called up, the user must be redirected to www.kirby-starterkit.com/notes/exploring-the-universe.
I assume that this is best realized with a route, right?
My difficulty now is to define a route for the case that the link changes monthly.
The following route works if the link of the monthly article does not change:
I would like a route with a placeholder. But my idea does not work (I know very little about how routes work):
return site()->visit('notes/(:any)');
I hope I was able to describe my question clearly.
UPDATE:
I have now implemented the selection of the current action in the panel (related articles). Only one action can be selected there at a time. There is also the question of how (with a route?) you can always be redirected to the current action.
You don’t need a route, in your template, you can either directly display the selected article (like you would with your route) or redirect to the selected article.
Ah, that makes sense!
The template doesn’t care whether I render a list of related articles or the article directly.
Why make it complicated when it can be made simple?