Jump to content

dotnetic

Members
  • Posts

    1,037
  • Joined

  • Last visited

  • Days Won

    15

Posts posted by dotnetic

  1. Please find attached an improved version in vanilla javascript which is much smaller 2.4 kb instead of 6.75 kb and more efficient without using a scroll listener. Tested in Firefox and chromium based browsers on windows. Please report if it does not work somewhere else.

    I didn't change the TinyMCE plugin, so I don't now if it still works.

    QuickSave.zip

    • Like 1
  2. 14 hours ago, sebibu said:
    // 2 x PHP Warning: Attempt to read property "value" on null in .../Latte/templates-sections-header.latte--27db76d0dd.php:53

    This is basically saying that you are trying to read the value property of a category which is not available, as it is null.

    You could check the existence of category first and then check if the value is not empty, if you use the following comparison:

    <body n:class="$page->category && $page->category->value !== '' ? $page->category->value">
     // or
      <body n:class="$page->category && $page->category->value ? $page->category->value">

     

    • Like 1
    • Thanks 1
  3. On 3/14/2024 at 10:45 AM, millipedia said:

    accidentally uploading a config-dev file to a live site

    Same happened to me, as my IDE auto-uploaded this file because I had checked a setting to "upload a changed file" on save. Somehow it thought I changed the config-dev.php and uploaded it. Site was not reachable after that.

  4. Let's assume you want to change the title of a an edit page.

    You could hook ProcessPageEdit:execute in a file like site/ready.php like described here.

    Adapt the template name in the following code to your needs:

    $wire->addHookAfter('ProcessPageEdit::execute', function (HookEvent $event) {
      $pageEdit = $event->object;
      $page = $pageEdit->getPage();
      if ($page->template != 'shop') {
        return; // return early
      }
      $this->wire('processHeadline', 'My new headline');
    // or modify the existing headline
    //  $headline = $this->wire('processHeadline');
    //  $this->wire('processHeadline', $headline . " - " . date('d.m.Y', $page->created));
    });

     

    • Like 1
  5. The method you are looking for is headline

    You could hook ProcessPageEdit:execute in a file like site/ready.php like described here.

    Adapt the template name in the following code to your needs:

    $wire->addHookAfter('ProcessPageEdit::execute', function (HookEvent $event) {
      $pageEdit = $event->object;
      $page = $pageEdit->getPage();
      if ($page->template != 'shop') {
        return; // return early
      }
      $this->wire('processHeadline', 'My new headline');
    // or modify the existing headline
    //  $headline = $this->wire('processHeadline');
    //  $this->wire('processHeadline', $headline . " - " . date('d.m.Y', $page->created));
    });

    For easier finding and helping others in the future, I made a support post out of this: 

     

     

    • Thanks 1
  6. 2 minutes ago, nurkka said:

    What is the benefit of a remote staging version for a single developer

    That isn't a question of one or multiple developers. I mostly use a staging server to showcase new functionality before it will get added to the live server.

    3 minutes ago, nurkka said:

    I understood, you would clone the database to local and continue working on the website locally, and later copy everything back to remote. But then I would overwrite the changes my client and the users have made in the meantime.

    We use RockMigrations to ensure our development environment matches the live server. This allows Bernhard and me to add new fields and templates without risk of overwriting existing data during uploads, as any changes are automatically migrated

    • Like 1
  7. First of all: Great module, I really like to have an overview, because I got many templates (20) with access roles
    Improvement suggestion: I would like it even more if it just modifies the standard template overview instead of adding a new one. What do you think of that?

    • Like 1
  8. 26 minutes ago, da² said:

    he doesn't want the image to be loaded below a certain screen size

    If that is what he wants, it can be achieved with using the picture element and source

    <picture>
        <source media="(min-width: 1440px)" srcset="https://placekitten.com/1024/800">
        <img src="no-image.png" id="hintergrundbild">
      </picture>

    so the image would only load on screen size at 1440px and above. The no-image.png could either be replaced with a blank image or a low res version, which will never get shown, because the element is hidden by default. But sure, it will produce a 404 if the image does not exist.

    I adapted my codepen, to reflect these changes.

    I am not saying that da2's solution is wrong. It is just another way to do it. But I think the version with using an image is much more flexible.

    • Like 1
  9. Hi Bernhard, you could just use an image tag inside of the body with object-fit.

    The advantage of this method is that you even could use different images for different resolutions if you want to. Another advantage is that you do not land in specifity hell because the style attribute has a very high specifity.

    I created a small codepen example, that you could use as a base: https://codepen.io/jmar/pen/oNmmJeB

    • Like 1
  10. Welcome to our lovely community, Rasso. I hope you are enjoying the benefits of ProcessWire as much as I do.

    We had the discussion about replicating / syncing fields on the server many times. I use RockMigrations as a reliable and working module for this.

    You write code with migrations and they get executed as soon as you save the file and refresh the admin.

    A migration can be inside the site/migrate.php file, or in a migrate method inside of your custom module, or somewhere else.

    Here is a possible example of a migration:

    $rm->migrate([
        'fields' => [
            'body' => [
                'label' => 'Content',
                'type' => 'FieldtypeTextareaLanguage',
                'inputfieldClass' => 'InputfieldTinyMCE',
                'tags' => 'generic',
                'contentType' => 1,
                'langBlankInherit' => 1,
                'inlineMode' => 0,
                'height' => 500,
                'lazyMode' => 1,
                'features' => [
                    0 => 'toolbar',
                    1 => 'menubar',
                    2 => 'stickybars',
                    3 => 'spellcheck',
                    4 => 'purifier',
                    7 => 'pasteFilter',
                ],
                'toolbar' => 'styles bold italic pwlink pwimage blockquote hr bullist numlist anchor code',
                'rows' => 15,
            ],
            'home_intro' => [
                'label' => 'Home Intro',
                'type' => 'textarealanguage',
                'tags' => 'generic',
                'inputfieldClass' => 'InputfieldTinyMCE',
                'rows' => 5,
                'inlineMode' => 1,
            ],
            'subheadline' => [
                'type' => 'text',
                'inputfieldClass' => 'InputfieldTextLanguage',
                'maxlength' => 100,
                'tags' => 'generic',
            ],
    ],
    'templates' => [
            'basic-page' => [
                'label' => 'Standardseite',
                'fields' => [
                    'title',
                    'navtitle',
                    'seo',
                ],
            ],
            'imprint' => [
                'label' => 'Impressum',
                'fields' => [
                    'title',
                    'body',
                    'seo',
                ],
            ],
    ]
    ]);

    With the migration you can also create pages and even fill them with content (if you want that)

    $rm->createPage(title: 'About us', name: 'about-us', template: 'basic-page', parent: '/');

    There is no sync between fields or templates you create in the admin and RockMigrations (there was a YAML option once, but I don't know if it still exists), but you get an easy to copy code in each fields edit section, that you can copy directly over to your migration.

    image.thumb.png.949711e0585a834b1c16da762b6fdf48.png

    I am also in favor that migrations should be a core feature of ProcessWire, but Ryan does not approve. So we have to stick with what we have, and RockMigrations is a great solution.

    • Like 2
  11. I am as many others love ❤️the Latte template engine, and I use RockFrontend to integrate it into ProcessWire.

    One cool feature of Latte is, that you can easily create a comma-separated (or any other separator) list of items, where the last item does not have a separator (comma) afterwards, without needing PHP.

    Take this code as an example

    {foreach $pages->get('/myparentpage')->children as $item}
    	{$item->title|noescape}{sep}, {/sep}
    {/foreach}

    Which will output a list like: first title, second title, third title

    If you want to know more use cases take a look at the documentation at https://latte.nette.org/en/tags#toc-first-last-sep

    • Like 5
  12. On 10/30/2022 at 8:58 AM, pwired said:

    By the way ... did someone mention that Docker Desktop is no longer free like it obvious was before ?
    I don't mean if you are running a company with 250+ employees

    You don't need Docker Desktop for ddev to run at least on WSL or Linux (not sure about MacOS, but they recommend using Colima). You just can use the free open source docker-ce (docker engine).

  13. On 10/29/2022 at 8:54 AM, bernhard said:

    The biggest benefit for me is that you get a real unix dev environment. So if you have some special need for your server (eg creating thumbnails from PDF via poppler-utils you are out of luck with laragon). With DDEV you simply add poppler-utils to the config of the web container and you can develop everything locally and it will work the same on the live server.

    I confirm this. This is one of the main benefits. Also every project can have its own configuration, for example if you need to run an old PHP or MySql version (which you shouldn't). Best part is, you can run the projects simultaneously.

    • Like 3
×
×
  • Create New...