Hi Kirbys and Kirbyettes
I am working on a website and just trying to output the content from one of my .txt files to the page. I also looked at blueprints, but trying to get it to work with the .txt files first.
- In Example I have a file called company.txt with the content of:
Title: My awesome site
----
Headline: Awesome Headline
----
Subline: Awesome Subline
My understanding is, i want to echo out the field “Headline” in my template.
This would be: <php echo $page()->heading()
Which does not work.
I have checked the documentation, as well as forum but could not find the appropriate content.
Thank you in advance!
Your php tag is not correct (question mark missing),
<?php echo $page->heading(); ?>
or with the short echo tag:
<?= $page->heading(); ?>
Thanks for the reply, sorry, did not include this in the post.
That has not been working unfortunately
Oops, sorry, your field is not called heading
but headline
had corrected that in my code but I guess that is not the problem. Can´t seem the echo out the headline. I have multiple fields:
- headline
- subline
- leftcolumn
- rightcolumn
Afaik these can be named anything right? So when in my template this would be:
<?= $page->myfieldname(); ?>
Exactly, maybe you are in the wrong template then? A text file called company.txt
will be rendered with a template company.php
, or if that doesn’t exist, with the default.php
template.
And if you have created the file manually, have you added the separators (----
) between fields? (Yes, you have, weren’t visible)
Pro tip: Always use three backticks before and after a block of code to render it as code!
@pixelijn Thank you for your help.
I found the problem. I created a multisite which rendered “…/de/referezen”
After deleting the multisite which removed the “/de” the field is rendered.
Stupidity…
Thank you nevertheless! The support here is great!
In a multilanguage context, your text files need to have the language extension, e.g. company.de.txt
etc.
1 Like