Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Out of the box, Couch does not support native multi-site installations.

However, if you have several websites, you can have *some* features managed from one place. Share your real-life experience here. Maybe we can figure out the way to improve on current situation.

What we already have is:
a. tool to store changes in database - 'db_persist' tag.
b. tool to get information passed to a page - 'gpc' tag.

Let's say, you need to do something (what is your need? - share!).
- Then we first, follow a link to login in remote Couch isntallation.
- Second, pass information to be updated (like approve all comments in blog, update picture, create a new page, update text, etc..) to the page it is stored on.
- Third, a special script reads all the incoming info (it executes if logged-in admin) and does the dirty job.

This is it.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Came across this topic in my search and just wanted to bump this and see if anyone may have a solution to our scenario.

Basically we're going to be managing multiple client's websites using Couch. What I'm trying to wrap my head around is a way to use a single set of couch files for multiple installs. Each client would have their own separate config file in order to connect to the DB, but then I'd like to use a single code base for the rest of the couch files.

This would allow for easier updates, and only needing to maintain a single base of code, vs needing to go in and update every single client's file base when/if we need to make changes.

Any ideas on how this could work?
There are several components to do what you might like.
Main idea is to organize code so that distribution can be automated without complications.

Part I - CMS-related code management - I keep my code in one place. I have a private offline repository of code, which consists of modded tags, new tags, functions, admin-panel customizations etc. Modifications, validators, shortcodes etc - all is kept in separate files and autoloaded from their subfolders and is stored in main folder '/couch/addons/community-mods'. Physically it is inside /couch/addons folder, so it is safe there. I never modify couch native files, because it is not recommended practice and custom code should not get overwritten if couch is updated on github.

folders.png
folders.png (36.65 KiB) Viewed 3615 times


I also moved /couch/config.php and /couch/addons/kfunctions.php to the site's root for quick access - '_config.php' and '_kfunctions.php'. Couch doesn't overwrite them but still it helps. I also created symlinks to /couch/addons in '/mysnippets' folder which helps for faster access, because I work mostly with snippets. And I have /config-local, /config-server folders, as well as /htaccess-local, /htaccess-server folders because the settings are different between VPS and local PC.

Part II - I need to only update embeddable snippets of code. See http://docs.couchcms.com/miscellaneous/smart_embed.html I never touch main php files, which are dropped in site's root. 100% of my php template files contain the following structure -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title="Index" clonable='1' nested_pages='0' gallery='0' dynamic_folders='1' order='0010' routable='0'>
    <cms:smart_embed 'template_editables' />
    <cms:smart_embed 'template_config' />
    <cms:smart_embed 'template_routes' />
</cms:template><cms:ignore>
/*

    Index..

*/
</cms:ignore>
<cms:set my_debug='0' />
<cms:smart_embed debug=my_debug 'html_afore' />
<!DOCTYPE html>
<html lang="<cms:show k_lang />">
    <cms:smart_embed debug=my_debug 'html_headers' />
<body>
    <cms:smart_embed debug=my_debug 'html_hero' />
    <cms:smart_embed debug=my_debug 'html_master' />
    <cms:smart_embed debug=my_debug 'html_trail' />
</body>
</html>
<?php  COUCH::invoke(); ?>
<?php //COUCH::invoke( K_IGNORE_CONTEXT ); ?>


Snippets, especially smartly-embedded snippets are the best way to maintain code in chunks, possibly updating it with perfect precision, only those parts that need attention. (If site's footer for page-view is updated, I replace file on server 'html_trail/index-page.trail' (according to my naming structure) and that's it. Same reasoning applies to template editable fields and their configs, they are kept in snippets to the most comfotable work with code and with updates). Smart embed allows any extension, so when I work in code editor I can immediately see which file I need, editable fields are 'index.fields', home-view code is 'index-home.master', configuration of template and fields is 'index.config' etc.

Part III - is a more deeper level of code-chunking, aka snippet inheritance via cms:block-cms:extends tags, which enables us to avoid editing and overwritting any snippets, but just drop a new file that will be automatically picked as most relevant (similar to smart-embed tag, but works with smaller and granular pieces of code) - viewtopic.php?f=5&t=10984

There are possibly other moments that I forgot to mention. All these work environment improvements were done incrementally over the 4 years span since OP. This process never stops. I am sure you probably have some more ideas and plans about managing websites from single place. We can discuss those as well. If this post is not what you wanted, PM me, I can help.

P.S. That repo mentioned is not online or on git, it is a bunch of zip files (I am not a github fan). For each new installation I take what I need and fking unzip them in one click. Every zip already contains the proper folder structure, so the pieces go like a lego. Today it looks like this (probably I should add a couple of files from this week's work).

Attachments

Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
My Workflow for CouchCMS Development

For my CouchCMS projects, I’ve set up a workflow that simplifies managing and updating the core files while leveraging modern development tools. Here’s how I approach it:

1. Central 'couchcms-core' Folder
In my Dropbox, I have a 'couchcms-core' folder that always contains the latest version of CouchCMS. I leave the core files untouched but have modified the 'config.php' to point to a parent folder called 'config'. This folder contains my custom 'config.php' file. This setup ensures that my projects are independent of the core files, making updates much easier.

2. Starting New Websites with DDEV
When setting up a new website, I use [DDEV](https://ddev.com/) to create a consistent local development environment. I configure it quickly with a single command:
Code: Select all
ddev config --project-type=php --docroot="./" --php-version=8.1 --webserver-type=apache-fpm
This generates a '.ddev' directory containing a 'config.yaml' file. I manually modify the database version within the 'config.yaml' file. I include the following lines to configure MySQL 8.0:
Code: Select all
database:
    type: mysql
    version: "8.0"
Finally, I create a file named 'docker-compose.mounts.yaml' in the '.ddev' folder containing the following content:
Code: Select all
services:
  web:
    volumes:
      - "$HOME/Dropbox/Code/couchcms-core/couch/:/var/www/html/couch:rw"
In this setup, the volumes key is utilized to mount a directory (couch) from the host machine into the Docker container.

Then, I start the project with:
Code: Select all
ddev start
3. Installing Dependencies
Once my environment is up and running, I install the necessary frontend tools. These usually include:
    - Tailwind CSS for a utility-first approach to styling.
    - Alpine.js for interactive elements without heavy frameworks.
    - esbuild for bundling and minifying CSS and JavaScript.

4. Easily Managing Updates
Since my projects rely on a central 'couchcms-core' folder, updating to a new version of CouchCMS is straightforward. I only need to update the core files, and my custom configurations remain intact. This makes the process quick and seamless.

5. Future Improvements
As I’ve recently started working with CouchCMS again, I’m actively looking for ways to expand and improve my workflow. For instance, I am examining ways to install and activate addons more efficiently, possibly outside of the 'couchcms-core' directory, which could make the process even more streamlined.

This is how I approach my projects. I'm still learning and constantly looking for ways to optimize my workflow. Let me know if you have any suggestions or feedback. We can learn from each other.
martijnbokma wrote: I’m actively looking for ways to expand and improve my workflow. For instance, I am examining ways to install and activate addons more efficiently, possibly outside of the 'couchcms-core' directory, which could make the process even more streamlined.

This is how I approach my projects. I'm still learning and constantly looking for ways to optimize my workflow. Let me know if you have any suggestions or feedback. We can learn from each other.


Hi, you may want to look at this topic viewtopic.php?f=2&t=13475&p=39166#p39166 where I have successfully moved all addons, tweaks etc into a theme folder with drag-drop switch for easiest configuration of addons for a project.

Also here is a tip that allows to move theme folder outside of your couch-core/theme subdir.



This is how I moved my theme from site/couch/theme/mytheme too just site/mytheme. Only change needed is to set site's URL in config setting. It helps to minimize folder jumping working with codes
Code: Select all
   // 26.
    // If the admin-panel uses a custom theme, set the following to the folder-name of the theme.
    // Theme folder is expected to be within the 'couch/theme' folder. No leading or trailing slashes please.
    //define( 'K_ADMIN_THEME', 'sample' );
    define( 'K_ADMIN_THEME', 'ryazania' );
    define( 'K_THEME_NAME', trim( K_ADMIN_THEME, " /\\" ) );
    define( 'K_THEME_DIR', dirname(K_COUCH_DIR) . '/' . K_ADMIN_THEME . '/' );
    if( !defined('K_SITE_URL') ) die( 'Please define your website\'s URL in config.php' );
    define( 'K_THEME_URL', K_SITE_URL . K_ADMIN_THEME . '/' );


Permalink https://t.me/couchcms_chat/1002
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
5 posts Page 1 of 1