Two pretty basic questions I have…
First question: I seem to be unable to edit the project description and title in my panel, while I can still do this with the raw .txt file in my file structure. I think I’m missing something in my blueprints/projects.php. Can someone point out what I’m missing?
<?php if(!defined('KIRBY')) exit ?>
title: Projects
pages:
template: project
files: false
fields:
title:
label: Title
type: text
text:
label: Text
type: textarea
Second question: very straightforward… For some reason, (email) tags in (site.txt) file are not rendering as email links. I know I must be doing something incorrect.
(email: mail@benfehrmanlee.info text: mail (at) benfehrmanlee.info)
It delivers this on the page:
Thank you!
How do you output the text form your site.txt file. For kirbytags to render, you need to use the kirbytext()
method:
<?= $site->text()->kirbytext() ?>
(Change text()
to your field name)
As regards the first problem, you have posted the projects.yml
blueprint, but what is showing in the panel seems to be a single project. Do they use the same template? What is the name of the text files of these single projects?
What is the name of your .txt file for the page you showed in your screenshot?
Thanks again for your help @texnixe, I see what I did wrong. First problem solved, was missing “Fields” section of the individual project.yml blueprint.
As for the email question, the rest of the text block delivers as expected, its only the email link which does not… The name of that .txt file is (site.txt)
<p class="overlay-text">
<?php echo $site->text()->html() ?>
</p>
Yes, but the html()
method does not render the link, you have to change that to kirbytext, as I said above:
<p class="overlay-text">
<?php echo $site->text()->kirbytext() ?>
</p>
```
I understand, so sorry. Thanks again.
With the code:
you get <p ...> <p> ... </p> </p>
(nested “p”-tags).
This is not html5 valid (de: SELFHTML: Referenz:HTML/p).
Yep,
You could create a plugin to remove the p tags (several already exist):
<?php
function kirbytextRaw($content) {
$text = kirbytext($content);
return preg_replace('/(.*)<\/p>/', '$1', preg_replace('/<p>(.*)/', '$1', $text));
}
field::$methods['kirbytextRaw'] = function($field) {
return kirbytextRaw($field->value);
};
And in your code replace:
<p class="overlay-text">
<?php echo $site->text()->kirbytextRaw() ?>
</p>
Credit: https://github.com/jbeyerstedt/kirby-plugin-kirbytextRaw/blob/master/kirbytextraw.php
Or you change the code e.g. to:
<div class="overlay-text">
<?php echo $site->text()->kirbytext(); ?>
</div>
or “span
” instead of “div
” (two times!).
May be you have to change your CSS too…
yeah, not necessary, there is no need for the
tag in this case. Thanks for all the input!