HansSchouten / PHPageBuilder

A drag and drop page builder to manage pages in any PHP project
https://www.phpagebuilder.com
MIT License
721 stars 177 forks source link

phpb_e($page->get('title')) returns an empty string #117

Closed BraindeadBZH closed 2 years ago

BraindeadBZH commented 2 years ago

Hi, I'm trying to setup PHPageBuilder on my website and everything seems to work fine. Here is my view.php of my master layout:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title><?= phpb_e($page->get('title')) ?></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="<?= phpb_theme_asset('css/uikit.min.css') ?>"/>
    </head>
    <body>

        <?= $body ?>

        <script src="<?= phpb_theme_asset('js/uikit.min.js') ?>"></script>
        <script src="<?= phpb_theme_asset('js/uikit-icons.min.js') ?>"></script>

        <!-- Run PHPageBuilder script.js files -->
        <script type="text/javascript">
            document.querySelectorAll("script").forEach(function(scriptTag) {
                scriptTag.dispatchEvent(new Event('run-script'));
            });
        </script>
    </body>
</html>

The title is always empty.

HansSchouten commented 2 years ago

Please check if the title column of the page in the page_translations table is empty.

BraindeadBZH commented 2 years ago

Thank you for your answer, the title is not empty

mysql> select * from page_translations;
+----+---------+--------+-------+-------+---------------------+---------------------+
| id | page_id | locale | title | route | updated_at          | created_at          |
+----+---------+--------+-------+-------+---------------------+---------------------+
| 10 |       4 | en     | Home  | /     | 2022-04-24 23:44:30 | 2022-04-24 23:44:30 |
+----+---------+--------+-------+-------+---------------------+---------------------+
1 row in set (0.00 sec)
HansSchouten commented 2 years ago

Hmm and if you try $page->getTranslation('title') ?

BraindeadBZH commented 2 years ago

Yes it works when using getTranslation.