Title in menu not parsed correctly

plugin

#1

Hello,
I did observe something interesting. I do have a staging-server on Azure (restricted) where I can see the result I want to see, but it does not work in production (Auszeit-weltweit.de). It is about the title for each page on the menu.

<div>
        <?php if($p->children()->visible()->count()): ?>
            <ul>
                <li><a<?php echo ($p->isActive()) ? ' class="active"' : '' ?> href="<?php echo $p->url() ?>"><?php echo html($p->seitentitel()) ?></a></li>
            </ul>
            <?php foreach($p->children()->sortBy('rubrik', 'asc')->visible()->groupBy('rubrik') AS $rubrik => $items): ?>
            <h5><?= $rubrik ?></h5>
            <ul>
              <?php foreach($items as $item): ?>
                <li><a<?php echo ($item->isOpen()) ? ' class="active"' : '' ?> href="<?php echo $item->url() ?>"><?php echo html($item->seitentitel()) ?></a></li>
              <?php endforeach ?>
            </ul>
          <?php endforeach ?>
        <?php endif ?>
      </div>

So, I do have a field called Seitentitel on every txt, but it only shows up when I am on that specific page, not if i am on home or any other page, in this case it only displays the folder name. Any suggestions? Seems to be a parsing issue.


#2

Worth mentioning: the titel can be customized correctly one level above. Seems that the function breaks if the url is on the sub-sub-level.


#3

What does that mean?


#4

Sorry, this was somewhat short on information. It looks like if you have domain.tld/foo/bar the function works well on foo but not anymore on bar.
And I am pretty sure it worked on domainfactoy, it did not work on hostnet and now on Hetzner, but on azure it works, which makes it difficult to debug.


#5

If you try to use another field, title or text, does that work?


#6

Added this to the list element:

<?php foreach($items as $item): ?>
                <li><a<?php echo ($item->isOpen()) ? ' class="active"' : '' ?> href="<?php echo $item->url() ?>"><?php echo html($item->seitentitel()) ?> <?php echo html($item->aktion()) ?></a></li>
              <?php endforeach ?>

and “Aktion: Aktion” to the txt, once again it is only on the page itself visible. https://www.auszeit-weltweit.de/Rundreisen/Suedafrika not visible if you change to another page. Works on Azure (webapp, php7).


#7

Is it possible that the problem is having
<?php echo html($p->seitentitel()) ?>
and
<?php echo html($item->seitentitel()) ?>
later? It is unfortunate i do not have a second server on Hetzner at the moment to try that out.


#8

But what surprises me is that “Südafrika” is displayed on all pages, so where does that come from? Is that not the “Seitentitel”?

As long as all the variables are know inside the snippet, using both $p->seitentitel() and $item->seitentitle() is no problem. After all, the right information is pulled, otherwise the url wouldn’t work either.

I have no idea what is happening there.


#9

Exactly. It is not the folder or the title. There is no other value anywhere and I was even considering spaces as a problem, but changing the word does no effect(!). I am kind of clueless. I am going to search through the IDE…


#10

Ok, something is interesting. Sometimes it works, like you can see “Country (ab 17)” in the menu. So, this is 100% from the value Seitentitel: xyz, there is no other way. I switched to Windows from OSX some while ago, I am going to look at line-endings (WIN, unix, etc.)


#11

Ok, got it. It looks like something about line endings. Switched from PHPStorm which had Windows-Encoding to VS Code and now it works. The person editing the files, does work on a Mac, so it looks like my machine was changing the line endings. And now I have a clue why Azure served it like I wanted it. At least it works now at it seems to be the best explanation.

Thank you!


#12

What i did notice too late: there were very often two .txt files uploaded by our editor. The one with the correct template was first, but who knows if the second txt file could somehow overwrite the value?! Would it be possible?


#13

I don’t think so, that wouldn’t explain why on some pages it worked and on others it didn’t.

But even the explanation with the line endings for me doesn’t really explain why it worked in one page but not in the other, but maybe I’m missing something.


#14

Ok, and yes I am not 100% sure about the line endings, too, but I did not do anything besides that. Strange case.


#15

Maybe it is some sort of caching issue?


#16

Well, reproduced at least the issue that two txt files at the same time in the folder prevent it from being displayed correctly. Deleting one of the txt files, fixes it apparently.


#17

Are the files uploaded manually by the editor? Maybe it makes sense to use the Panel if you can’t rely on editors to only ever upload two text files? If you have stray text files in a folder, this will always cause issues.