Posts by SAB

    With the Link you just create a link, that does not create a new page (GET /test returns No route found).

    With the URL Alias you create a new page, that links to the referenced page ( GET /test loads /blog/into-the-wild)

    With the Redirect you create a new page, that redirect to the recerenced page ( GET /test redirects to /blog/into-the-wild)


    I think what your looking for is the Link, as you do not create a new page. You don't have to use the link picker as you can just type in an URL. With that you can e.g. create a menu including items, which aren't pages on your website.

    If I get you right, then you can.

    Choose Site > Add Site > Link. Then make sure the link type is link and don't choose your link via the link picker. Instead just enter an URL, which can be external (http:// ... ) or internal (/mysite). As long you don't use the picker and save, it should not create a route respectively a reference.

    Yes, it should

    • register() just registers the asset, but does not add it to the queue of files which file be rendered in the header. Then it makes senses that using ~ only makes sense in register, as you simply register, that your script should be loaded if another is loaded.
    • add() registers and adds the file to the queue, so it gets rendered

    Basically every uikit 2 component is already registered in the system/view module (and some more scripts):


    I think I also figured out the difference between $scripts->add() and $scripts->register(). It is related to the tilde ~ in dependencies. As I read or understand from source code, the tilde only has an effect if it is used in the register() method.

    I just want to point out, what the tilde actually does when used as prefix to dependencies in $scrips->register() on view.scripts or $styles->register() on view.styles. I always forgot it and was unsure about, what it actually does as it is not clearly (or exactly) explained in the docs.

    Code
    1. 'view.scripts' => function ($event, $scripts) {
    2. $scripts->register('my-script','path/to/script.js,[uikit, ~widget]);
    3. }

    my-script is loaded after uikit and after the script which is registered with widget.


    But with using tilde ~ as prefix for widget, my-script only gets loaded, if widget get's loaded. This fact Isn't explicitly stated in the docs.


    If use it via the Script and Stylehelper, the ~ has no affect, as $view->style() or $view->script() uses the add() method of the AssetManager which does't consider ~.


    Hope this helps somebody.

    I have to correct me, if you listen to view.styles or view.scripts, then the second argument is of instance AssetManager (see ScriptHelper line 31 or StyleHelper line 31). Thats leads to slightly changed usage:


    PHP
    1. 'view.styles' => function ($event, $scripts) {
    2. $scripts->register('highlight-js' , 'dpnblog:assets/highlight/highlight.pack.js' , ['jquery']);
    3. $scripts->register('highlight-init' , 'dpnblog:assets/highlight/highlight.init.js' , 'highlight-js');
    4. },
    5. 'view.styles'=> function ($event, $styles) {
    6. $styles->register('highlight-css' , 'dpnblog:assets/highlight/styles/atom-one-dark.css');
    7. }

    Actually there are two methods for adding (register and add), but I don't understand whats exactly the difference. They use register in the docs, so I chose this one.

    Code
    1. 'view.content' => function ($event, $view) {
    2. $view->scripts('highlight-js' , 'dpnblog:assets/highlight/highlight.pack.js' , ['jquery']);
    3. $view->scripts('highlight-init' , 'dpnblog:assets/highlight/highlight.init.js' , 'highlight-js');
    4. $view->styles('highlight-css' , 'dpnblog:assets/highlight/styles/atom-one-dark.css');
    5. }

    That shorter version should also work?! Why do you listen to site and then register inside it a listener to view.content? You should be able to subscribe to it directly. Every event prefixed with view. has as second argument the View.php object.


    You could also listen to view.scripts or view.styles (for better understanding in reading code)

    saurinadev please use shortcuts for paths


    pagekit does register following shortcuts by default:


    in theme: access folder via theme: and views via views:

    in extension: access folder via extension-name: and views via views:extension-name

    If you would like to add script or css at an known render of a template path you know (omit the .php and prefix view.), or even change the template of this render, then see below. This is done in your index.php.

    Code
    1. 'events' => [
    2. 'view.system/site/position' => function ($event, $view) use ($app) { // system/site is actually a shortcut!
    3. $event->setTemplate('views:extension-name/your/custom/template.php'); // instance of ViewEvent.php
    4. $view->script('custom','extension-name:js/custom.js',[...]);
    5. $view->style('custom','extension-name:css/custom.css',[...]);
    6. }
    7. ]

    Hope this helps. Cheers ;)

    They plan to bring Yootheme Pro to Pagekit once they finished it. And a more complete builder you can't find currently out there. And to design and code a good builder is not such an easy task ...

    Generally you can add scripts like this:

    $view->scripts('name','path/to/script, ['defer' => true, (...) ])

    You can define as many options you would like. The problem is, that only two are relevant when the tags are rendered:

    You just would have to add some line of codes and it would be possible. But the problem is, that you cannot overwrite this render as it is triggered:

    PHP: pagekit/app/modules/view/src/Helper/ScriptHelper.php
    1. /**
    2. * {@inheritdoc}
    3. */
    4. public function register(View $view)
    5. {
    6. $view->on('head', function ($event) use ($view) {
    7. $view->trigger('scripts', [$this->scripts]);
    8. $event->addResult($this->render());
    9. }, 5);
    10. }

    Dirty way would be to listen to scripts, do $event->addResult(customRenderFunction()), then delete every assets from the scriptmanager, so the original, following $event->addResult($this->render()) will get nothing. Just a guess how I would try to solve that :D.


    P.S You should be able to acces the scriptmanager via App::scripts() or $app['scripts'].

    Fosphatic Duke You mean add js & css from frontend?

    You can add css and js files promised based in your vue.js application. Take a look at: pagekit/app/system/app/lib/asset.js

    yns.wtf compiling uikit 3 less and javascript - that's a thing did not manage to implement.


    Optimal case would be to require uikit as npm package. Then via pagekit's npm install, automatically compile all uikit files.

    • compile LESS (customizing uikit 3) files placed in /less to /css
    • compile Uikit JS components to /js
    • compile Uikit custom icons to /js

    As I know, UIkit goes to node_modules if you install it with npm?