Blog Post to Template

  • So where is template.php stored? You could write an overwrite for that specific view.


    Have a look at https://pagekit.com/docs/devel…me#overwrite-system-views

    http://prntscr.com/h6g3s3


    template.php is what I use for the page that page needs to get access to the $post variable in order to achieve what I want.


    I tried to do this in SiteController.php by the $view but that messed up everything

  • Alright. It's a bit tricky...

    At first you need to edit index.php


    At first we need to use some stuff:


    Code
    1. use Pagekit\Application as App; // Only needed if you are using the second attempt
    2. use Pagekit\Blog\Model\Post;


    Now we need to add this:




    You see - it's quite an ugly workaround - but it works ;)


    You can access all these values in template.php


    Code
    1. dump($app->module('blog')->posts); // First attempt
    2. dump($app->cache()->fetch('posts')); //Second attempt
    3. dump($view->data); //Third attempt
    4. dump(Pagekit\Blog\Model\Post::findAll()); //Fourth attempt



    The fourth attempt is quite bad style. Even worse than the other ones ;)


    You should also check, whether the blog extension is installed.


    This will do the trick:



  • Currently I'm at trainee but as a quick glance at this I see the workaround I will tweak a couple more things for needs but I see this work, Thanks for the amazing help! Ill show my code when Im done so other ppl can use it in-case they want this aswell and I will describe it.


    Credits to you!

  • Currently I'm at trainee but as a quick glance at this I see the workaround I will tweak a couple more things for needs but I see this work, Thanks for the amazing help! Ill show my code when Im done so other ppl can use it in-case they want this aswell and I will describe it.


    Credits to you!

    SPQRInc I got home and I directly switched my clothes for my doctor jacket and started to get to work, more info on how I get there and figure out from the point you brought me I will tell in my blog.

    But this is I think the best way I could handle my case for specific a Single Blog Post, Thanks for getting me started on that event that helped me a lot.


    The Event:


    Template.php:


    Code
    1. $view->data["post"]