Forum for discussing general topics related to Couch.
13 posts Page 1 of 2
I've downloaded CouchCMS to have a play with, and it looks very interesting. I've been studying the documentation for the answer to a simple question, though, without success. Maybe I'm just having a stupid day (it happens), so I wonder whether someone could help me out?

I have a static site which consists of a number of pages with very similar structure, such as common headers and footers, etc., with a few sections here and there which require CMS functionality (as in user-editable content). What I'm looking for is the best way to have some kind of master page type functionality, whereby each of the pages follows the standard template but with a different main content section. So, the template (master page) would be something like this:

Common header section including nav menu
[Placeholder for main content]
Common footer

Just to be clear, the 'placeholder for main content' is NOT intended to display a user-editable area, it's for the HTML specific to the different pages, which may vary greatly.

I looked at cms:embed for the header and footer, but I want to be able to do things like set the titles of the individual pages and have page-specific JS and CSS, so unless I've misunderstood something (likely enough), this doesn't seem the right way. In fact, what I'm after is kind of the opposite of this - rather than embedding snippets into my page, I want the components of my page to be embedded into areas in a masterpage.

This is such a fundamental templating requirement that I'm sure CouchCMS can do it and I've just not worked out how yet. Any help would be appreciated!
Hi, Johnny2R and Welcome :)

I couldn't understand, actually, why you need cms in the first place. You said there is no cms-manageable content in your pages inside placeholder, i.e. page content is some static data. I can only try to imagine what's this is all about :)

So, did I get you correctly that your js/css/meta tags are bound to the name of the page? I must ask you to give us then some example of what you actually need. Thanks!
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
No, I said "with a few sections here and there which require CMS functionality (as in user-editable content)". So some pages require CMS functionality, hence my investigation of CouchCMS. But users/editors will not be creating new pages, they will only be managing content in existing sections.

I'm not sure what you mean by "your js/css/meta tags are bound to the name of the page".

It could be that I could do what I want simply using some other templating tool like Smarty or Twig, but I wonder how they would mix and match with CouchCMS? It's probably straightforward enough, in fact, with straight PHP, but I haven't worked with PHP for a while.

LATER: What I'm talking about was something like this, except using CouchCMS tags:

http://antanova.com/blog/code-bits/asp- ... ges-in-php

But I can just do exactly this, I suppose, and put any 'cms:editable' sections in the 'content' area shown in the example.
Hi @Johnny2R,

I think we are having trouble in understanding your use-case.

Could you please post screenshots of some of the pages (possibly marking out areas that you'd like to set via the CMS)?

That should help us in getting a grasp of the problem.

Thanks.
Johnny2R, thanks for the link, I studied it. It helped a lot :) so, thanks.

I would then suggest you taking a look at this piece: http://docs.couchcms.com/tutorials/port ... /blog.html It is crucial in answering your questions about how Couch treats 'pages' and 'templates'. I think, after reading this we can be on par with terms and their meanings.

While, I agree with @KK about screenshots and samples, I think that tutorial (with the link above) is sufficient to let you see the strong and weak sides of Couch. I'd appreciate your fresh thoughts on this, so please don't hesitate to share with us :)
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
trendoman, thanks, but I did in fact look at the documentation before posting my question (as I always do), and didn't find my answer there.

kk, my use case is extremely simple, and the link I posted is exactly what I'm talking about. I was just wondering whether I could make use of some CouchCMS tags in doing this. I'm simply trying to avoid repetitive copy and pasting for producing multiple similar pages, with all the hassle and maintenance nightmare that entails.

As it happens, I went ahead with the technique in the article I linked to and found it works fine for me.

Code: Select all
<?php require_once('couch/cms.php' ); ?>
<cms:set title="Test Page"/>
<cms:template title= "<cms:show title/>"/>

<?php
$page=new StdClass;
$page->title    = "<cms:show title/>";
$page->template = "includes/master.php";
?>

<?php ob_start(); /* head   */ ?>
    <meta name="description" content="Test page meta description">
<?php $page->head = ob_get_clean();?>
<?php ob_start(); /* content*/ ?>
  <div>
<h1>Real Content</h1>
  <cms:editable name='left_content' label="Left Content" type='richtext'>
            <p>Blah blah</p>
       </cms:editable>
</div>

<?php $page->content = ob_get_clean();?>
<?php ob_start(); /* foot   */ ?>
    <script type="text/javascript"></script>
<?php $page->foot = ob_get_clean(); ?>
<?php include_once $page->template ?>
<?php COUCH::invoke(); ?>


The page-specific head, content and foot sections get slotted into placeholders in the template (template in the general, not CouchCMS, sense) called 'master.php', which has all the banners, regular headers and footers and general page structure.

The page comes up in the admin area just as it should.
Hi, thought I'd jump in to offer up another couch concept that *may* work similar to your intentions.

Having read your comments here and looked at the link you provided, I believe some things about couch should be clear. To the best of my knowledge, we cannot strictly prohibit users from creating pages (Unless one of the lower access levels prevents this? @KK I've never really looked into access levels below admin). So if a user can edit an area, he/she can also create a page of a cloned template. What I mean is, if you have an admin/editor that can edit some parts of the site, they will be able to edit any. You can hide templates from them with the "hidden='1'" parameter in the template tag, but for cloned templates this would hide the entire template from anyone lower than the Superadmin, which hides ALL pages, if you want some to be editable this obviously doesn't work.

With that said, a cloned template is the only way you will achieve your "Master template", non-cloned templates all have separate PHP template files which is a lot of copy-pasting.

The code used from the link provided probably does work, but I would be wary of it having any "Unknown" issues later on, raw PHP and couch don't always play nicely together (PHP before executes couches execution) Though it does seem like it could work. Let me offer an alternative, all couch, method.

I believe you could achieve the master-child relation by using the "Nested pages" concept. It's a slightly different form of a cloned template, and while it's advertised mostly as a "Menu maker" (It certainly does this) it can be used as the "master" template to the site.

You can read up more on it here: http://docs.couchcms.com/concepts/nested-pages-aka-menu-maker.html please let me know if you think this is any closer to what you desire, KK, Trendoman and myself may be able to help to fit this around your use-case if you believe this concept will at least achieve part of your needs.
Image
@Johnny2R, would you mind also posting your master.php? I would like to replicate this on my local environment :) Thanks

@Bartonsweb, thanks for coming to this thread! As to your note about regular registered users, I think, anyone below admin can't even login to backend ;) So admins or s-admins are permitted to commit changes to content, and the rest just 'login' to the website and be taken wherever the wind blows.
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
trendoman, below is my master page (with a few things changed to make it more general, and the navbar removed). As you can see, for each page using this template, you need to set a title and some body content, and potentially some extra stuff for the head and JS footer (I test with 'isset').

Code: Select all
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Meta Goes Here">

    <title><?php echo $page->title; ?></title>
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Alegreya:400,300,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">

    <link rel="stylesheet" href="css/layouts/custom.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
   
    <?php

    if (isset($page->head)) {
        echo $page->head;
    }
    ?>

</head>
<body>

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 banner"><img src="img/banner.png"/></div>
    </div>
</div>


<div class="content">
    <div class="container-fluid">
        <div class="row">
            <?php echo $page->content; ?>
        </div>
    </div>
</div>

<div class="content">
    <div class="container-fluid">
        <div class="row footer">
            <div class="col-xs-12">© 2016 CouchCMS Testing</div>
        </div>
    </div>
</div>
<?php

if (isset($page->foot)) {
    echo $page->foot;
}
?>

</body>

</html>



@Bartonsweb, interesting observations about the access levels. In my case so far, a normal Admin user does not appear to have the capability of creating new pages, but that is presumably because the test templates I've done so far have not been marked as clonable? From the ACCESS CONTROL section on http://docs.couchcms.com/concepts/users.html, it does look as if you have decent control over who can do what, though.
13 posts Page 1 of 2