Currently I’m using Kirby for a multilingual site.
The content structure:
/content/home/home.en.txt
/content/home/home.de.txt
/content/home/home.fr.txt
Each file with variables like: headline, metadata, text, and more
And for the template:
/site/templates/home.php
Until now all works as it should.
Now our customer wants to show different content on the homepage depending on some “variables”.
My Idea was to change the content structure a little bit:
/content/home/home.en.X.txt
/content/home/home.en.Y.txt
Is it possible to set all meta-information on home.en.txt and all content stuff (like ‘text’) in “home.en.X.txt”?
No, you can only ever have one content file per language.
What sort of information are we talking about? Why would you want to separate meta data from the text in a different file? Could you provide some more information what sort of changes the client wants to have on the homepage depending on what exactly? Only for a single language? For all languages?
In general I agree, but the nature of dynamic pages is that their content changes and usually a homepage is such a dynamic page that must not always show the same stuff?
If you structure your content differently, for example using a structure field instead of a text field, then you wouldn’t have the need for different text files. For example, use select fields to select the products to show etc. Use checkboxes to determine a state that you can query in your templates. Use if statements to query a language and show different snippets for each language. There are so many options…
But I still. don’t see what variable X is…
Or, you could use two text fields and then use a checkbox to determine which of the two to use.
I was playing around with this idea, but my “Text” variable for one site is around 180 lines of text.
And I think it’s more readable with I could outsource the “Text” in a seperate file for each case.
You could use a tabs plugin or use two subpages instead. As I said, you have to find an alternative, because more than one text file is just not possible.
This is serving different content on the same URL, and is a big no-no to me. You better redirect based on your conditions (set in a controller) to dedicated pages then.
@texnixe, I agree on the dynamic nature of the home page which means it changes over time. Not that it serves different content conditionally.
It would basically be a redirect to the same page with a parameter or query string added, unless you get your params/search strings for free with a GET request from a form anyway.
create a second page (or a subpage) which holds content unique to “X” (e.g. “/home/x”).
In the home controller I would check condition
If “X” is met, redirect to the same URL, but with a URL parameter (e.g. “/home/cond:x”)
In the same home controller check if there is a “cond” URL param set. If set, prepare the extra variables you need in the template by loading (“/home/x”). If the “cond” URL param isn’t set, load the “default” stuff which is in “home” anyway
It’s choosing between an overload of subfolders, or an overload of if-clauses. It’s a messy request anyway
Who’s gonna manage the content for those “conditions”? It will probably be messy for them too.
As @bvdputte said, you only need one subfolder for the alternative version. It’s really not much different from your original idea… Unless you need different content for each alternative.