Jump to content

spoetnik

Members
  • Posts

    76
  • Joined

  • Last visited

Posts posted by spoetnik

  1. On 2/12/2024 at 5:06 PM, rastographics said:

    Thanks @cwsoft and @zoeck. I've used custom page classes for a while but I don't think to full potential so I'm sure these resources will get me to the next level of what is possible. 

    My reason for coming to this thread is I'm trying to have a more elegant way of using htmx by using "partials" on the php side, and I read that latte will let me break the html up into partials better than the regular php templates. Excited to hopefully use latte to make the htmx experience better. And just overall structure my processwire projects better.

    Inspired by this reading? https://htmx.org/essays/template-fragments/#known-template-fragment-implementations

    • Like 2
  2. What you describe @bernhard would be what i'm looking for. It would even be more ideal if I could expose a component via a HTMX-api. That way I don't have to maintain a separate htmx component. 

    What I mean bij JSON api, is the AppApi integration with Twack

    On 10/28/2021 at 11:00 PM, Sebi said:

    Long time no see! I just released version 2.2.0 of Twack.

    With this, Twack now uses the new feature from the AppApi module (if installed) and registers its own route 'tpage' for page calls. This means that the JSON outputs of Twack components can now be requested easily through this Api endpoint:

    Route                                        Description
    /api/tpage/                             Calls the root page of the page-tree
    /api/tpage/42                        Will call the page with id=42
    /api/tpage/my/test/page      Calls your page with path my/test/page

    I would be cool if the output could also be just html, and preferably a part of the template, or component.

  3. I am looking for good way to implement htmx, and creating some sort of API for this.

    The API should return 'parts' in HTML to replace parts in the DOM. These returned parts could be components. 

    As Twack works with components, and has (JSON)API support, would Twack be the ideal base to build a HTMX frontend on? And how would i do this? Any suggestions?

  4. Thanks for you answer. Actually I don't need the count, but don't want any "Brands" without references. This is my final code:

                                <ul class="list-inline">
                                    <?php
                                        $brands = $pages->find('template=brand');
                                        $brands = $brands->sort('-numReferences');
                                        $brandCount = 0;
                                        foreach($brands as $brand):
                                            if($brandCount > 5) break;
                                            if ($brand->hasReferences) {
                                                $brandCount ++;
                                                echo "<li class='list-inline-item'><a href='/auctions/?brand=$brand->id'>$brand->title</a></li>";
                                            }
                                        endforeach;
                                    ?>
                                </ul>

     

  5. I have products referencing to brands using a page reference field.

    Now I want a list of brands, ordered by number of references.

    I found the function $page->references(), but how do I sort this?

     

                                    <?php
                                        $brands = $pages->find('template=brand');
                                        $data = '';
                                        foreach($brands as $brand) {
                                            if ($brand->references()->count()) {
                                                $data .= "<li class='list-inline-item'><a href='/auctions/?brand=$brand->id'>$brand->title</a></li>";
                                            }
                                        }
                                    echo $data;
                                    ?>

    Thanks for any suggestions!

  6. Thanks @LostKobrakai. Looked into the 'Dynamic Roles' Its looks like an abandoned module from Ryan, but the up-to-date fork from @matjazp works. I saw your comment,

    , and that's exactly the same problem I have with this module.

    I would love to use this module as a base, or write a pull-request to have this functionality, but I am not skilled enough to do that.

    The hook into 'PageFinder::getQuery' scares me to add the selector ```saas_id=user()->saas_id``` to my Saas module.

  7. Here is my setup:

    My Dockerfile:

    #
    # PHP Dependencies
    #
    FROM composer:1.7 as vendor
    
    COPY web/ /app
    
    RUN composer install \
        --ignore-platform-reqs \
        --no-interaction \
        --no-plugins \
        --no-scripts \
        --prefer-dist
    
    #
    # Frontend
    #
    FROM node:latest as frontend
    
    COPY --from=vendor /app /app
    
    WORKDIR /app/site/templates
    
    RUN npm install --global gulp-cli && \
        npm --prefix /app/site/templates install gulp /app/site/templates && \
        npm --prefix /app/site/templates install /app/site/templates && \
        gulp build
    
    #
    # Application
    #
    FROM php:7.2.7-fpm-alpine
    
    COPY --from=frontend /app /var/www/html
    
    WORKDIR /var/www
    
    RUN apk add --update $PHPIZE_DEPS \
            freetype-dev \
            libjpeg-turbo-dev \
            libpng-dev \
        && docker-php-ext-install iconv pdo pdo_mysql mysqli opcache zip \
        && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
        && docker-php-ext-install gd \
        && rm -rf /var/cache/apk/* \
        && chown -R www-data:www-data .
    
    # set recommended PHP.ini settings
    # see https://secure.php.net/manual/en/opcache.installation.php
    RUN { \
    		echo 'opcache.memory_consumption=128'; \
    		echo 'opcache.interned_strings_buffer=8'; \
    		echo 'opcache.max_accelerated_files=4000'; \
    		echo 'opcache.revalidate_freq=2'; \
    		echo 'opcache.fast_shutdown=1'; \
    		echo 'opcache.enable_cli=1'; \
    	} > /usr/local/etc/php/conf.d/opcache-recommended.ini \

    My dev_docker-compose.yml:

    version: '3'
    services:
        web:
            image: nginx:alpine
            volumes:
                - ./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf:delegated
                - ./etc/ssl:/etc/ssl:delegated
                - ./web:/var/www/html:delegated
                - ./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template:delegated
                - ./logs/nginx/:/var/log/nginx:cached
            ports:
                - "8000:80"
                - "3000:443"
            environment:
                - NGINX_HOST=${NGINX_HOST}
            command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
            restart: always
            depends_on:
                - php
                - mysqldb
        php:
            build: ./
            image: app:latest
            restart: always
            environment:
              MYSQL_HOST: ${MARIADB_HOST}
              MYSQL_PORT: 3306
              MYSQL_DATABASE: ${MARIADB_DATABASE}
              MYSQL_USER: ${MARIADB_USER}
              MYSQL_PASSWORD: ${MARIADB_PASSWORD}
            volumes:
                - ./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini
                - ./web:/var/www/html:delegated
                - ./assets:/var/www/html/site/assets:delegated
        composer:
            image: "composer"
            volumes:
                - ./web:/app
            command: install --ignore-platform-reqs
        myadmin:
            image: phpmyadmin/phpmyadmin
            container_name: phpmyadmin
            ports:
                - "8080:80"
            environment:
                - PMA_ARBITRARY=1
                - PMA_HOST=${MARIADB_HOST}
            restart: always
            depends_on:
                - mysqldb
        mysqldb:
            image: mariadb:${MARIADB_VERSION}
            container_name: ${MARIADB_HOST}
            restart: always
            env_file:
                - ".env"
            environment:
                - MYSQL_DATABASE=${MARIADB_DATABASE}
                - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
                - MYSQL_USER=${MARIADB_USER}
                - MYSQL_PASSWORD=${MARIADB_PASSWORD}
            ports:
                - "8989:3306"
            volumes:
                - ./data/db/mysql:/var/lib/mysql:delegated

    my prod_docker-compose.yml

    version: '3'
    services:
        web:
            image: nginx:alpine
            volumes:
                - ./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf
                - ./etc/ssl:/etc/ssl
                - ./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template
                - ./logs/nginx/:/var/log/nginx
                - webroot-volume:/var/www/html
            ports:
                - "80:80"
                - "443:443"
            environment:
                - NGINX_HOST=${NGINX_HOST}
            command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
            restart: always
            depends_on:
                - php
                - mysqldb
        php:
            image: app:latest
            restart: always
            environment:
              MYSQL_HOST: ${MARIADB_HOST}
              MYSQL_PORT: 3306
              MYSQL_DATABASE: ${MARIADB_DATABASE}
              MYSQL_USER: ${MARIADB_USER}
              MYSQL_PASSWORD: ${MARIADB_PASSWORD}
            volumes:
                - webroot-volume:/var/www/html
                - ./assets:/var/www/html/site/assets
        mysqldb:
            image: mariadb:${MARIADB_VERSION}
            container_name: ${MARIADB_HOST}
            restart: always
            env_file:
                - ".env"
            environment:
                - MYSQL_DATABASE=${MARIADB_DATABASE}
                - MYSQL_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
                - MYSQL_USER=${MARIADB_USER}
                - MYSQL_PASSWORD=${MARIADB_PASSWORD}
            volumes:
                - ./data/db/mysql:/var/lib/mysql
    volumes:
         webroot-volume:

     

    • Like 2
  8. So, I have build a form, and I can call this in my template like:

    <?=AddPostForm/>

    After submitting this form, the data is passed to a function with all the input values to add the post.

    Where do you sanitize your data? Is that the responsibility of the form, before passing the data to the function, or do you expect the function to sanitize the data before handling it?

  9. I am playing with the setup in a sandbox.

    Do I understand it right?

    For each private group, I create Role, and a Template.

    Then on the Temaplte of the Parentpage I set Role permissions, so only people in that Role (Group) can view and create Children?

     

    So Group -> Role -> Template Access?

  10. I am using Bootstrap3 for my one page template.

    I would like to be able to open a link in a bootstrap modal. I can't find a CKeditor modal plugin or something. Tried using the 'ProcessWire Edit Link Process' module, and add target="_modal", so I could strreplace something, but this gets stripped by CKeditor.

    Any suggestions how I could open a link, created in CKeditor, in a modal?

  11. Thanks Lisandi for the recommendations.

    I had nginx serve the static files, but this wasn't the fastest option. Now Apache serve the static files, and ik enabled gzip, caching etc. 

    I am familiar with cloudflare for another site I am building. That client has his customers all over the world, so a CDN release benefits. This is all Dutch, so I don't see anly real benefits of cloudflare here.

    I will look into the SEO module, thanks.

×
×
  • Create New...