We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Blog

Using Sections in the Blog App

We are trying to access whether Sections in the new Blog App can be used on a site I currently work on where we now use the Blog App for general Blog posts and the News App for News Releases.

The data entered for each type of post - controlled by the respective post.html files - are very specialized for each type of post.

If we were to use Sections in the Blog App - One section for News Posts, and One section for general Blog Posts - would the data fields being entered for both types of posts need to be controlled by the same post.html file?

Sue Stewart

Sue Stewart 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2637 points
Perch Support

You can have multiple different post types, distinct from the sections functionality. The two can work together but aren't explicitly linked.

I have not been able to find how to define two different Blog post types in the documentation. Can you point me to the documentation or describe how to do this please? How would I set up blog to choose to enter a news or general blog with different templates controlling what fields are entered? The way I am understanding Blog is the fields displayed to be entered when a new post is created are controlled by what is defined in post.html. How do I set it up to have multiple post types to select?

Drew McLellan

Drew McLellan 2637 points
Perch Support

See here: http://docs.grabaperch.com/docs/blog/template-tags/

"The master template for a blog post is post.html. You can add alternative post templates by placing the in the templates/blog/posts folder."

Once you've done that, you can pick the post type from the edit form.

So I have put two templates in perch/templates/blog/post/. One is a copy of post.html for my general blog post and I named it blog_post. One is a copy of the post.html I have been using from the news app and I named it news_post. I left post.html in perch/templates/blog/post.html and it is the same template as perch/templates/blog/posts/blog_post.

I then attempted to enter a new blog post and the post entry form still has the fields defined in my perch/templates/blog/post.html template with a new field to select post type. My blog_post and my news_post templates should have different fields. The news_post template contains several custom fields.

I did select the news_post type and no change of fields. I saved it as a draft and no change of fields. I am assuming I still have something not set up right because I can not access the news_blog entry template once selecting the type.

Do I now need to do something to perch/templates/blog/post.html?

Drew McLellan

Drew McLellan 2637 points
Perch Support

Do your new post templates appear in the select box on the post edit form?

Yes, after Allow comments with the label Post type towards the bottom of the form.

Drew McLellan

Drew McLellan 2637 points
Perch Support

Ok, so if you pick a different template from the list and save, you should then get that template's fields.

When I pick a different template and save it just tells me I have not entered the required fields on the default template.

Drew McLellan

Drew McLellan 2637 points
Perch Support

Are the required fields different between the two?

For testing purposes, I made my two templates exactly alike except the news template now has one additional field that is not required. So now the required fields between the two templates are exactly the same. They were not before.

Also, I put the new news template at perch/templates/blog/post.html just to make sure it renders correctly. It does.

Still when I select either of the templates in the drop down list of Post types, I get the error message to please enter the required fields. No template change to the one I request.

Help.

Drew McLellan

Drew McLellan 2637 points
Perch Support

Is it a server-side message or a client-side message?

Not sure. It says "! Please fill out this field" with orange begind the "!".

Here is the template.


<title><perch:blog id="postTitle"> by </title> <style type="text/css"> .blogaddthis img{ margin: 0px; padding: 0px; } </style> <div class="hentry"> <h1> <a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="entry-title"> <perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /> </a> </h1> <p class="entry-published date"> <perch:blog id="postDateTime" type="date" label="Date" time="true" format="%B %d %Y" divider-before="Meta information" /> <perch:if exists="authorGivenName"> by <perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" /> </perch:if> </p> <perch:if exists="image"> <div> <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Post Image" order="4" />" alt="<perch:blog id="postTitle" />" /> </div> </perch:if> <perch:blog id="thumbnail-image" type="image" label="Thumbnail Image (50x50)" width="50" height="50" order="5" suppress="true" /> <div class="description entry-content"> <perch:blog id="postDescHTML" type="textarea" label="Post" order="2" editor="ckeditor" textile="false" markdown="false" required="true" html="true"/> </div> </div> <div > <p><strong> <perch:if exists="postLocation"> <perch:blog id="postLocation" type="textarea" editor="markitup" markdown="false" encode="false" label="Location" textile="false" size="s" order="6"/>, </perch:if></strong></p> </div> <perch:blog id="excerpt" type="textarea" label="Excerpt" editor="ckeditor" html="true" order="3" suppress="true" /> <perch:blog id="image" type="image" width="50" height="50" crop="true" suppress="true" />
Drew McLellan

Drew McLellan 2637 points
Perch Support

That sounds like your browser enforcing a required field. Which field is it?

It was reporting that my first required field - the title was not entered. I also had the description as a required field.

Those required fields were added to my template with the recent Blog App update, because they were on the supplied sample template suggested to use as a base for this new version of the Blog App that includes sections.

I removed the required fields and I can now get past this and the templates will swap when the post type field is changed and the post is saved.

What does happen though, is a system generated title is inserted in the title field when the post is saved to get the post template to change. Then you have to alter it when you are entering the post. Also, one needs to remember to select draft with the save of the empty template, because a post with just the system generated title is actually saved and will probably appear on your site, just because you did a save to switch post template types.

I personally can work around these quirks, but I would not want to subject a client to them.

I also checked this required field thing in IE, Firefox, and Chrome. Happens in all of them. Additionally, for your info, the blog form, which used to render with a perfect layout in Chrome, now only renders with a perfect layout in Firefox. It is not really bad in the other browsers, just a few alignment issues. Is there a Perch CSS file I should be adjusting for this?

Drew McLellan

Drew McLellan 2637 points
Perch Support

What problem are you seeing with the form?

Is there a way I can send you the three screen shots from the three different browsers so that you can see how they differ?

Drew McLellan

Drew McLellan 2637 points
Perch Support

Sure, if you pop them online you can embed them in this thread.

My apologies, when I expanded the windows to do screen shots, the form alignments improved. IE 11 does get script errors however if you care.

Drew McLellan

Drew McLellan 2637 points
Perch Support

Of course I care. What are the script errors you're seeing?

When you add a post:

Line: 99 Error: NotSupportedError

print screen from debugger at

alt text for image