Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I am doing the tutorial and all is going well. But here is something that confuses me, not as in the steps, but the logic behind it.

During the Blog section of the tutorial, it is explained that

each single entry will get the url "blog.php?pg=x" with x a number; and if that ?pg=x postfix does not exist, it will fallback to "blog.php".

I totally get this. What I don't understand, why embed the blog_list.html page into that php, and then change codes in there, instead of creating blog_list.php, and then have it connected somehow? I understand you need to add a connection which might be totally unnecessary, but it's confusing to use html inside a php page, and then have some of the changes in the html, and some in the php (in the tutorial, the sidebar changes are done in the php, while everything else before were in the html).

Does anyone know what I mean here :lol:
Hi,

If the overlap between the PHP template and the embedded HTML snippets is confusing for you, let us simplify things. Following is a revised version of blog.php
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Blog' clonable='1' commentable='1'>
   <cms:editable name='blog_content' type='richtext' />
   
   <cms:editable name='blog_image'
      crop='1'
      width='610'
      height='150'
      type='image'
    />

</cms:template>

<cms:if k_is_page >
   <cms:embed 'blog_page.html' />
<cms:else />
   <cms:embed 'blog_list.html' />
</cms:if>

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

As you can see, the blog.php template above contains *zero* HTML markup.
It only serves -
1. to define the template and hence appear in the admin sidebar and be accessible from the browser as http://www.yoursite.com/blog.php
2. define all editable regions etc. for the template
3. work out whether it is being accessed in the page-view or the list-view and then call the right HTML snippet.

The new 'blog_page.html' you see above will contain all the code present in the original blog.php at the following location -
Code: Select all
<cms:if k_is_page >
   .. cut all code present here in original blog.php and paste it in blog_page.html ..
<cms:else />

So now you have a strict separation between the PHP and HTML files.
Does this make thing any easier for you?
Do let me know.
Then your tutorial is incorrect. There, blog.php is derived from blog.html which in turn started as single.html, which is a page that has full markup for the single entries. So my blog.php, never has been empty. Can you check your tut and source files?

Edit:

Rename blog.html to blog_list.html and then rename single.html to blog.html.


And then later it said:

Rename blog.html to blog.php.
Oh wait, your reply is actually a suggestion for me 8-)

Sorry, but yes, I got it. May I suggest to change that in the tut as well? I have now arrived at the part 2, specifically the sidebar section, and when it says to do changes in the php, while before that working in the html, that instantly made me wonder if it's a typo.
4 posts Page 1 of 1