Simple display of database items

  • Hi, can anyone help me?

    I've just trying to build a very simple extension that simply returns data from the database.

    I've got an extension called 'happenings', I've added a script.php (plus added some placeholder entries via myPHPadmin). I've set up my src controller, model, and the view.

    When I test it i'm just getting an error page displaying all sorts of stuff I don't understand.X(

    I'm reaching the end of my tether and tempted to just use vanilla php.

    I've attached the 'happenings' extension that should go into a 'brightday' vender folder.





    1. <div id="happening">
    2. <?php foreach ($stuff as $thing): ?>
    3. <p> <?= $thing->title ?></p>
    4. <?php endforeach ?>
    5. </div>

    That's it.

    I've looked at other extensions, read some more about symfony php, I've read, but I just see where I'm going wrong.;(

    Any ideas?

    Many Thanks,

    • Helpful

    Try `$stuff = Stuff::where( [ 'active', 1 ] );`

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • Ok, that fixed something, I'm not getting any errors anymore which is good! Thank you SAB

    But I'm not getting any data, checking the debug toolbar it doesn't seem to be querying the database. I've changed a few names as I wasn't sure if it was a naming issue to start with.

    I'm just trying to get data from the database and show it on the site in a page, that's it. I've looked through other extensions trying to find an answer, like the blog, but as they are more complex I'm getting lost, I've been trying to strip it back to absolute basics.




    So I can print "Test" but not data in the db.

    I've double checked the database table does exist (with test data) and is named correctly.

    I don't have an app/bundle file but I'm not using vue or javaScript. I have not settings tabs, nothing in the admin, just front end public view.

    Any ideas? Anyone tried to do this? Or has an example?

    Many Thanks in advance.