Undefined index in Perch core file

  • Hi,


    I am getting an Undefined Index in a perch core file, as follows:


    Notice: Undefined index: label in /home/user/public_html/perch/core/apps/content/modes/page.edit.post.php on line 129

    PHP version 7.4 with Perch 3.1.7

  • Hi,


    What does the directory tempaltes/pages/attributes/ in your project contain?

    Generally, it contains various files, using the .html extension that contain scripts including json and json-ld.


    When I remove the files, the errors disappear when I refresh Settings for the page, but this can be inconsistent as sometimes the errors show but at other times they do not.


    I get in red:


    Code
    1. Array
    2. (
    3. [type] => 8
    4. [message] => Undefined index: path
    5. [file] => C:\PortableApps\UniServerZ\www\perch\core\apps\content\modes\page.edit.post.php
    6. [line] => 129
    7. )

    which to me is a PHP error in the core file itself so I am hoping this is addressed in a future version because I should be able to use any code I want, that would be valid in any other template, besides a pages template so my thought is that when Perch allowed various file extensions to be used in regular templates something was missed.


    I can post some code that I used in my Pages templates but as I say the error is inconsistent and only show in versions of PHP beyond 7.4, which again lead me to believe the error is actually in Perch.

  • It is possible that Perch here excepts all the files to be directly in tempaltes/pages/attributes/. I think the next logical step would be to try to remove the sub-directories and see whether the issue persists:


    • tempaltes/pages/attributes/some_file.html
    • tempaltes/pages/attributes/another_file.html
    • etc.
  • Thanks Hussein, that has solved it. I appreciate your time.


    It would be nice though if directories could be used, as I am having to append additional information to each filename, when it would be far easier to use directories. The fact is though page attributes are very useful for me because I don't have to use PHP to generate things like service worker and JSONLD code so I am glad I can continue using the very flexible Perch CMS!


    Upon further testing, for whatever reason, Perch does not recognize either .json or jsonld file extensions; least not with respect to page attributes, which is unfortunate so I'm wondering whether this may be available in the future, to build on work previously done by Drew.