Posts by SPQRInc

    Hello guys,

    I'm struggling with a problem I do not understand.

    I would like to output a text from my Model in the frontend. This text can either be or not be formatted as markdown.

    Now my SiteController.php applies the markdown-plugin if the item from the model is saved as "uses markdown".

    This is my source:

    But now what happens on a markdown-formatted text: Is it being displayed with the HTML-Tags:

    What did I miss?

    I think I solved it.

    The problem is that I can not generate the URL using <?= $app->url('@books/id', ['id' => $item->id]);?> or something like that because I do not get $item as I'm not looping through $items as $item using PHP but I'm using a Vue-Filter and so I'm working with an JS-Array.

    Now I could continue using $url.route, but I do not get pretty URLs here. So I decided to add an URL to the JSON using the Model.

    This is what I did:

    1. public function jsonSerialize()
    2. {
    3. $data = [ 'url' => App::url('@books/id', ['id' => $this->id], 'base') ];
    4. return $this->toArray( $data );
    5. }

    Now I can access item.url.

    Now I try to write an URLResolver and keep you updated :-)

    It pushed me in the right direction, thanks. I got a little error that was removed by this.

    But: The URL is still generated like this: https://localhost/books/item?slug=dies-ist-ein-test

    I would like to rewrite it to a pretty URL like https://localhost/books/dies-ist-ein-test

    My problem is that the URL needs to be generated with VueJS. And I do not get the link between Vue and the Pagekit routing.

    Hello again,

    working on my new extension I just stumbled over another issue related to the routing.

    My view generates a description list that is filtered "on the fly" using Vue.js.

    This is the part:

    1. <dl class="uk-description-list-line" v-for="item in filteredItems">
    2. <dt>{{item.title}}</dt>
    3. <dd v-if="item.excerpt.length">{{ item.excerpt }}</dd>
    4. <dd v-else>{{ item.content | truncate 150 }}</dd>
    5. </dl>

    Now I would like to add a link to every item that is shown. I can not use

    1. $view->url('@books/id', ['id' => $item->id])

    because $item does not exist as I'm not using a PHP-foreach to loop through the list (because the list can be filtered "on the fly").

    So now I'm using

    1. <a :href="$url.route('books/slug/', { slug: item.slug })">{{ item.title }}</a>

    And it works fine, but it generates links like this: https://localhost/books/slug?slug=dies-ist-ein-test

    Of course I can work with that, but it would be fine to get a pretty URL.

    As I can not find a documentation for this: Can I rewrite this using a custom routing ?

    Hello there,

    well - this seems to be so easy, but at the moment I'm having a dirty workaround.

    I got a computed property called "filteredItems". This "filteredItems" looks like this:

    1. { "7": { "url": false, "test": [], "id": 7, "status": 1, "slug": "dies-ist-ein-test", "title": "Dies ist ein Test" }, "8": { "url": false, "test": [], "id": 8, "status": 1, "slug": "zu-viele-items", "title": "Zu viele Items" }, "9": { "url": false, "test": [], "id": 9, "status": 1, "slug": "zu-viele-items-2", "title": "Zu viele Items - Copy" } }

    Or, if empty like this:

    1. {}

    Now I would like to show a text, if filteredItems is empty.

    But: The .length-method does not work here, so I can not do a simple

    1. <h3 class="uk-h1 uk-text-muted uk-text-center"
    2. v-show="!filteredItems.length">{{ 'No Items found.' | trans }}</h3>

    My dirty workaround is to check the length in the JS-file:

    1. if(Object.keys(result).length < 1) result = false;

    and do a

    1. <h3 class="uk-h1 uk-text-muted uk-text-center"
    2. v-show="!filteredItems">{{ 'No Items found.' | trans }}</h3>

    But this is not really elegant I think.

    Well, this is just a test-project: It displays all the books I read during my studies. The API returns the data to the frontend.

    But hopefully I'm going to release a new extension based on my new knowledge on routing within the next few days :-)

    Okay, that worked out.

    It also works if I do the following:


    Hello there,

    Here it is: My first Pagekit project: .

    It's a Website that provides information about reptiles that are kept in a terrarium.

    As you can see: The styling was not my focus. Instead of this I wrote a little extension that calculates the minimum size of a given number of animals - or, if you want to, gets the animals you can put into a existing terrarium with a size you can define.

    It also provides a calculator that returns the yearly energy costs of your equipment.

    It's a hobby-website and no one needs the extension I wrote for it, but I had a lot of fun developing it :-)