Problems, need help? Have a tip or advice? Post it here.
15 posts Page 1 of 2
Please can I check that this is legitimate and won't cause problems with Couch.

On the current website I'm converting to Couch I have a number of HTML pages which contain lists of various kinds of info - for example on the home page a list of quotes + quote source displayed within a slider.

I am only interested in displaying the LIST - there will be no need for a link from each item in the list to a detail - PAGE VIEW / cloned page (as in the classic example of a blog and as shown in the tutorial).

So, I have been doing a bit of experimenting as a new person on the Couch ... I was wondering if I actually needed to bother with PAGE VIEWs and setting up the xxx.html file in the snippets folder. The home page - with the list of quotes - index.php - has the following at the top:

Code: Select all
<cms:template title='Home Page' clonable='1' commentable='0'>

<cms:editable name='quotation_text' type='text' />
<cms:editable name='quotation_source' type='text' />

</cms:template>


Followed by the HTML markup which includes:

Code: Select all
<cms:pages masterpage="index.php" >
                 
<li>
   <p><cms:show quotation_text /></p>
   <h5><cms:show quotation_source /></h5>
</li>   

</cms:pages>


So index.php is referencing itself with the cms:pages tag. It is giving the results I want on index.php and allows new quotations to be added with no problems. From the Admin panel you can click on VIEW a new page / quotation added and, for example, index.php?p=14 is viewable with all the correct page formatting.

Is this the correct approach to displaying list items?

:? thanks!
Hi,

Couch does not force you into impementing ANY view at all - I mean, if you choose to do so you can even skip the list-view as well.

Let me explain -
there is nothing wrong at all with your solution and you can go ahead with using it. As for me, I would have implemented it this way (would look 'semantically' better) -
Create a separate template named 'quotes.php'. This template will only have the two editable regions you mentioned
<cms:template title='Quotes' clonable='1' commentable='0' executable='0'>

<cms:editable name='quotation_text' type='text' />
<cms:editable name='quotation_source' type='text' />

</cms:template>

This template will only serve to create the data entry screens in the admin panel.
We will not implement any kind of view (i.e. it will have no HTML markup) - in fact, if you notice, I have set the executable='0' in the template's definition which will actually prevent this template from being accessed via browser e.g. as http://www.yoursite.com/quotes.php

So how do we display the data?
You can display the data of this template on any other template by using the regular cms:pages tag with the masterpage parameter.
e.g. I can now display a list of the quotes (i.e. data from the cloned pages of quotes.php) on my homepage (index.php) simply by using -
<cms:pages masterpage="quotes.php" >

<li>
<p><cms:show quotation_text /></p>
<h5><cms:show quotation_source /></h5>
</li>

</cms:pages>

This was only to illustrate that there is no compulsion of implementing the views.
You can keep on using the solution you have arrived at without any apprehension.

Thanks
hi KK - thanks for your reply ... I like the idea of keeping things 'semantic' - and have tried out your suggestion. I am now getting a variety of errors - not sure of the cause - could it be because I have leftovers in the DB of the previous page set up?

What is happening is this:

In the Admin panel for index.php there is a message: No Editable Regions defined. Curiously if I click on 'View' I am shown http://localhost/LPV/index.php?p=20 i.e. a cloned page.

Front end I am seeing the error: Error: masterpage: "quotes.php" not found.

I have tried sorting this on my own, but am stumped!

What I would like to end up with is a page showing a List View (of quotes) and also other editable regions - I thought I was about to achieve this, but I'm not quite there.

Any suggestions? Thanks as usual.
I have somehow managed to get what I was aiming for! I'm still a bit confused, but I think the key to getting it to work was to access quotes.php in my browser and then refresh the Admin panel and it appeared as a template in its own right, rather than entangled with index.php. I also recreated the database and started afresh.

I did set executable to '0' - but I can still access quotes.php in the browser - all I get is "powered by Couch" - is this correct?

As you can probably tell I'm not really able to explain what has happened and how it's gone right. But the important thing is - it is now working and I will be able to repeat what I've done. It's all about the learning curve - sometimes it's about taking a leap of faith, doing it, and it begins to make sense further down the line!
Front end I am seeing the error: Error: masterpage: "quotes.php" not found.

If I'm not mistaken, this error would only be generated if the 'quotes.php' file physically did not exist, or had not been visited so couch was unaware of it. Did you create a new file 'quotes.php' in the same folder as your 'index.php'?
...could it be because I have leftovers in the DB of the previous page set up?

If you visit your template while logged in, all changes you have made in the php file will be registered with couch. You will be provided with an option to delete the contents of old editable regions in the admin panel, therefore removing 'leftovers' from the db. It would not cause you any problems either way.
In the Admin panel for index.php there is a message: No Editable Regions defined.

This is not an error message, and shouldn't be a matter of concern. In this case, it is merely a statement of fact. You moved your 'index.php' editable regions to 'quotes.php', therefore they no longer exist within 'index.php'. Since you now utilize 'quotes.php' for your cloned quotes pages, I think it would also make sense to remove clonable='1' from your 'index.php'. I hope my explanation has made sense.

** Edit
You seem to have figured it out, glad it's working for you. :P
cheesypoof - thanks, your reply just crossed over with my 2nd posting - which just crept in above your very helpful info. You are totally correct, Couch was unaware of quotes.php - and I happened to solve it in my own rather haphazard style.

My only query now is that I wouldn't want quotes.php to be accessible (now that Couch is aware of it) - and the parameter executable='0' doesn't stop me accessing quotes.php in the browser)??
Quote from the documentation(emphasis added):
executable

If this parameter is set to '0', non-super-admin users will be unable to access the template and all its cloned pages via their URLs. This is usually done when a template is used only to define editable regions that will be used to capture data in the admin panel. The captured data is then usually displayed on other templates by the use of either pages tag or get_custom_field tag.

In this case since you are logged in as the super admin, you are able to 'view' the page. Everybody else however is considered a non-super-admin user, including average website visitors. In this situation, since there is no actual 'content' to display, both you and the average visitor would see the same thing(as you correctly stated): 'Powered by CouchCMS'. Lets say you added some 'content' to 'quotes.php', right outside of the template tag like this:
Code: Select all
<cms:template executable='0'>...</cms:template>Potato is awesome.

Only you would see "Potato is awesome.", an average visitor would not see it at all.
all clear, cheesy you're a star!
I'd just like to add one small thing to cheesypoof's explanation -
A super-admin can access a non-executable template just like the normal templates (else he won't be able to add the template to Couch).
However, every other person will be given a 404 Page not found error.
From a non-admin's perspective, a non-executable template simply does not exist.
KK, I did not realize this was the intended behavior, to give a 404 error. I am receiving the correct 404 status codes in all nonexistent situations, however the actual 404 template is not being displayed in certain instances. This happens when the physical template does exist but the requested cloned page or folder does not, as well as a template with executable set to 0.
Example:
http://www.website.com/news/does-not-exist.html
http://www.website.com/news/does-not-exist/
http://www.website.com/globals.php

I know all of these requests are being handled by couch because of the "<!-- Page generated by CouchCMS -->" in the page source. I have followed the steps in the documentation for custom 404 pages, and am a bit confused because I thought I had this working on previous couch versions. I am running 1.2.5-rc1 at the moment. It should be noted this problem only exists on the live hosted website, as my local wamp server is handling these situations correctly. I don't mean to hijack the thread.
15 posts Page 1 of 2