Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Hi,

Am trying to display the 2 most recent news item on the index page of my site. Unfortunately am not able to do so as i keep getting the ERROR: Tag "pages": masterpage 'news.php' not found. Here's my code from the index page

Code: Select all
<?php require_once('admin/cms.php'); ?>
<cms:template title='Home Page' />
<cms:pages masterpage='news.php' />

<!DOCTYPE html>
<html lang="">
    <head><!-- edited to make code short --></head>
   
    <body>
        <div class="container">
           
            <?php require_once('includes/brand.php'); ?>
            <?php require_once('includes/navigation.php'); ?>

            <section>
                <cms:editable name='main_content' type='richtext'>
                <div class="col-md-4">
                    <h1>Title</h1>
                    <p>some text</p>
                    <p>some more text</p>
                </div>

                <div  class="col-md-4">
                    <h1>Title</h1>
                    <p>some text</p>
                </div>
                </cms:editable>

                <!-- News area -->
                <div class="col-md-4">
                    <cms:embed 'news_sidebar.html' />
                </div>
            </section>
           
        </div>
    </body>
</html>
<?php COUCH::invoke(); ?>


This is the code for news_sidebar.html

Code: Select all
<h1>Latest News</h1>
<cms:pages masterpage='news.php' limit='2'>
<h3><cms:show k_page_title /></h3>
<cms:excerptHTML count='30' ignore='img'><cms:show news_content /></cms:excerptHTML>
<p class="clearfix"><a href="<cms:show k_page_link />" class="btn btn-success pull-right"> Read More...</a></p>
</cms:pages>


The code for new.php is

Code: Select all
<?php require_once('admin/cms.php'); ?>
<cms:template title='News' clonable='1'>
    <cms:editable name='news_content' type='richtext' />

    <cms:editable name='news_photo'
        crop='1'
        width='610'
        height='150'
        type='image'
    />
</cms:template>

<cms:if k_is_page >
<!DOCTYPE html>
<html lang="">
    <head>
        <!-- removed this part to make code short -->
    </head>
   
    <body>
        <div class="container">
           
            <?php require_once('includes/brand.php'); ?>
            <?php require_once('includes/navigation.php'); ?>

            <section id="news">
                <!-- news post area -->
                <div class="col-md-8" id="news-list">
                    <!-- news post -->
                    <div class="post">
                        <!-- Post Title -->
                        <h3><cms:show k_page_title /></h3>
                        <!-- Post Data -->
                        <p><cms:date k_page_date /> &bull;</p>
                        <div class="hr dotted clearfix">&nbsp;</div>
                        <!-- Post Image -->
                        <img class="img-responsive news-photo" alt="" src="<cms:show news_photo />" />
                        <!-- Post Content -->
                        <cms:show news_content />
                        <!-- ./post content -->
                       
                        <!-- navigation buttons -->
                        <p class="clearfix">
                            <a href="news.php" class="btn btn-success pull-right">Back</a>
                        </p>                   
                    </div>
                    <hr>
                </div>
                <!-- ./news post area -->

            </section>
    </body>
</html>
<cms:else />
    <cms:embed 'news_list.php' />
</cms:if>
<?php COUCH::invoke(); ?>


What am I doing wrong?
Hi mena :)

Frankly, I don't see anything wrong with the code (though the line highlighted below is redundant as it does nothing)
<?php require_once('admin/cms.php'); ?>
<cms:template title='Home Page' />
<cms:pages masterpage='news.php' />

I trust you have made certain that the template is indeed named 'news.php'. As a confirmatory test, hover your mouse on that template's entry in the admin sidebar and you'll see the name, as recognized by Couch, in a tooltip.

If your setup is online, you may PM me the FTP/Couch access creds and I can take a look at the issue for you.
To add to @KK's answer, if news.php is not in your site's root then you should specify the entire path:
Code: Select all
<cms:pages masterpage='my_folder/news.php'>

I've made that mistake more than once.
tim wrote: To add to @KK's answer, if news.php is not in your site's root then you should specify the entire path:
Code: Select all
<cms:pages masterpage='my_folder/news.php'>

I've made that mistake more than once.


Thanks for your contribution, news.php is actually in the site's root.
Thanks for entrusting me with your site's creds, @mena.

I logged into Couch's admin-panel and found that that there was only a single registered template (about.php).

Neither news.php nor index.php are currently registered (a registered template appears in the admin sidebar).

That would explain why cms:pages couldn't find news.php - it does not exist as far as Couch is concerned.

Please log into the admin-panel as super-admin and then visit news.php in your browser. Make sure it appears in the admin sidebar. Then visit index.php to repeat the process.

Once the templates are registered, I don't think you'll face the problem you reported.

Hope it helps.
KK wrote: Thanks for entrusting me with your site's creds, @mena.

I logged into Couch's admin-panel and found that that there was only a single registered template (about.php).

Neither news.php nor index.php are currently registered (a registered template appears in the admin sidebar).

That would explain why cms:pages couldn't find news.php - it does not exist as far as Couch is concerned.

Please log into the admin-panel as super-admin and then visit news.php in your browser. Make sure it appears in the admin sidebar. Then visit index.php to repeat the process.

Once the templates are registered, I don't think you'll face the problem you reported.

Hope it helps.


Many thanks to you. After manually accessing the news.php page, everything worked perfectly as it should. Thanks again.
This is an update to an old post. I ran into errors like 'ERROR: Tag "pages": masterpage 'index.php' not found.' These errors did not allow a single one of my pages to be registered. It took me a couple of hours to find a solution, so I thought I'd post it.

Background: I had "cloned" a completed, working couch site, because I like the layout and styling very much. To do this, I copied all the files into a new web root, and created a new database. I modified the config.php file with the new database name and credentials. Then I opened the web root in my browser.

Database initialization ("installation") went fine. Then, while logged on as admin, I tried opening one of my 3 "blog" type pages, to get couch to "register it. These 3 pages all have "clonable" set to "1".

This is where I saw the error. The three clonable pages are "index.php," "reports.php," and "blog.php." When I tried to open "index.php," the error would complain about not finding "reports.php." When I tried to open "reports.php," the error would name a missing "index.php."

I tried to remove from index.php all references to the other clonable pages. Those references were all via "embed" statements, with the references actually residing in files in the "snippets" directory. I simply commented out all the "embed" statements in, say, index.php, and tried again to open it in the browser. Still I got the error, and no page could be registered. I even tried starting over with a fresh database, but that didn't work.

Finally I tried temporarily renaming the "snippets" directory. This allowed the pages to register. Then I gave snippets it's original name, and everything works.

I think that couch parses the content of "snippets" even when there are no references (in the file one is trying to register) to any file in snippets. Is that correct? It appears that if there is a "pages" statement in a snippets-embedded file referencing a masterpage that is not yet registered, it will cause a fatal error. If this is the case, you might want to make that error non-fatal, to allow registration of pages.

I hope this report helps someone!
Lloyd, it appears your templates were 'cross referencing' each other, Removing the reference from one of the templates would have solved the issue.

As you mentioned, you tried doing exactly that by commenting out all the "embed" statements.
It surprises me that it did not work as expected. Is it possible that you happened to use the HTML style of commenting (i.e. <!-- -->)? Because that wouldn't stop Couch tags from being executed - for that one needs to use the <cms:ignore></cms:ignore> tag.

Anyway, since your aim was to 'clone' a complete working Couch site, the recommended way is the following which would have resulted in a perfect copy -
https://docs.couchcms.com/miscellaneous ... erver.html
Hi KK that's exactly right, I used html comments to "comment out" the embed statements. Now I remember that once before that gave me trouble! I think, because of all the difficulty this caused me, next time I'll remember to use the <cms:ignore></cms:ignore> tag!

Also, I'll look at the info you referenced on cloning a site.

Thanks very much for your help.

Edit: To make it clear to others: The html commenting nomenclature (<!-- -->) works for all html elements, and can and should be used to "hide" ordinary css and javascript in couchcms templates. But it will not "hide" couchcms tags in template files, since couch templates are pre-processed (parsed) by couch, and this parsing finds and executes couchcms tags even if they are inside html commenting tags. (If this is not completely accurate, someone let me know and I'll correct it.)
Regarding the link you sent to information on site "cloning" (https://docs.couchcms.com/miscellaneous ... erver.html), that's very useful, but in my case I only wanted to copy the site's design (all the template files, snippets, etc.) but none of the page content. My use of the word "clone" was not very precise.

I would have had no trouble at all if I had properly commented-out the couch embed tags, which were causing the circular reference.
12 posts Page 1 of 2