Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Kind of have an interesting scenario here where I'm trying to manage multiple front-end templates from a single install of CouchCMS. Reason being, I want to be able to push updates to a single git repo and be able to update all templates from a single instance.

To do this, I'm currently doing the following:

index.php
Code: Select all
<?php require_once('couch/cms.php'); ?>

  <!-- Template ID -->
  <cms:smart_embed "template_1" />

<?php COUCH::invoke(); ?>


/couch/snippets/template_1/default.php
Code: Select all
<!-- Editable Fields -->
<cms:embed 'template_1/editables.php' /> // stores all of my editable fields

<!doctype html>
<html lang="en">
<head>
...
<!-- Stylesheets -->
  <link rel="stylesheet" href="<cms:show k_admin_link />snippets/template_1/css/styles.css" type="text/css">
  <link rel="stylesheet" href="<cms:show k_admin_link />snippets/template_1/css/custom.php" type="text/css">
...
</head>
<body>
...
</body>
</html>


My custom.php file is suppose to be a couch managed CSS file where I can update some css via the admin. However, placing the files in the snippets folder breaks functionality of the custom.php file as well as doesn't render styles.css file. I assume because of the .htaccess permissions for the snippets folder which is denying access.

Ultimately my goal is to be able to have template_2, template_3, etc all managed from the snippets folder, and to control which template renders on the front-end, I would just change the value of <cms:smart_embed "template_x" /> in my main index.php file.

Is there a proper / possible way of achieving this? Hopefully that all makes sense, thanks!
AJ, have you seen this topic Editable CSS? That is about making a CSS file a Couch template..
I advise to check Conditional Fields topic if you haven't seen it yet.

From the looks of your code (and our emails back and forth) it seems you are interested in various CouchCMS concepts and that can lead to a very costly mistake - which is 'writing tags before content'. It has led many people to rewrite everything from ground up after such attempt.

What you (and everyone) should always do is make working set of html/css/js files first. Think about desired URL scheme (seo-related and such) and user-interaction elements, forms and how admins need to manage stuff.

Only then fit Couch to generate repetitive bits of code.

You can not add/remove editable fields on-the-fly, as it happens if you suddenly change template_1 to template 2 Couch will not find previous fields (unless the new ones are identical, but I presume it is not meant to be so). Register all fields and use Conditions from the topic I mentioned. Maybe you will be able to switch styles and settings via radio buttons and checkboxes rather than editing files manually :)


If you wish so, post a couple of barebone (but feature-full, with areas to be controlled in reality) templates that you decide to manage from one place and we here will try to give it a review and suggest optimal controlling template and how it is best to go with snippets.
This is my advice, start with good examples then cut them into pieces.

P.S. Tag <cms:smart_embed> does not care about extensions. Try to keep a naming practice - php for actual sidebar items; html, inc etc. for snippets
Thanks Anton!

It looks like it may have been a .htaccess issue with my custom.php (couch css file), so I think I actually got that figured out (just needed to re-run the htaccess generator to grab the new location of my css file after initializing it as a couch file)

I appreciate all the tips, I actually have a template already built out with content but left all of that out of my post just to keep it brief. I guess I should explain a bit further on my multi template plans:

You can not add/remove editable fields on-the-fly, as it happens if you suddenly change template_1 to template 2 Couch will not find previous fields (unless the new ones are identical, but I presume it is not meant to be so).


A lot of the fields will be re-used on each template, and then some templates will inevitably have different fields. However, the template switching won't actually be an option for clients, for example, if a client orders template_1, they won't have an option to actually switch to template_2 from the admin.

My plan is to generate install-ex.php files for each template that includes all of the pre-filled / default fields for that specific template -- and then depending on which template the client chooses, I can quickly install it on their server with all of the prefilled content.

So in reality, only 1 template will actually be actively used by the client, but for my development purposes, I would like to work off a single install of couch (in case there's an admin update, I won't have to update every single install)

Although you make a good point.. during my development I wouldn't be able to easily switch from template to template to make changes without couch needing to re-register all of the fields.
re-run the htaccess generator

Enable pretty-urls only after everything is working as it should, otherwise you won't know where to look at.

Keep us posted about your success in the 'Showcase' subforum. Your setup is not ordinary and I was interested in it, but as I said, without demo there can be no decisions made. It is definitely not an ordinary setup and only practice and testing can help find the working formula.
4 posts Page 1 of 1