Forum

Thread tagged as: Problem, Blog, CKEditor

Blog post titles in admin showing html tags

Im changed the template for blog posts, so that the post title is using a textarea, so that the writer can style the title.

The post appears normally, but in the admin where the blog posts are listed, the post title shows html <p> tags around it.

This is the part of the template for my post titles

<h1>
        <a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
            <perch:blog id="postTitle" type="textarea" order="1" label="Post Title" html="true" editor="ckeditor" />
        </a>
 </h1>
Chris James

Chris James 0 points

  • 5 years ago
Simon Clay

Simon Clay 127 points

Hi Chris, the problem with using a wysiwyg editor for titles is that it will add it's own <p> tags to your markup, and potentially, the editor would be able to change the formatting (adding further <h2> tags for example) and even insert a picture. All of these would end up within your already existing <h1> tags.

I'm guessing you're doing this because you want a slightly bigger area for people to put longer headings into?

You could use the size attribute to make the field a bit bigger size="xxl" or if you want multi line entry you could remove the html="true" editor="ckeditor" attributes:

<perch:blog id="postTitle" type="textarea" order="1" label="Post Title"  />

Thanks for that advice Simon, it's useful.

I understand your point, however, I really need to allow the editor more control over the text styling (bold, italic, font size etc - using a CKeditor plugin) and will ensure they're properly trained in not misusing the wysiwyg title field.

So, I really need to solve the original problem...?

Simon Clay

Simon Clay 127 points

Hi Chris, I understand. In that case you'd need to remove the <p> and </p> tags in each instance.

Thats the problem though Simon - the <p> tags are appearing on the blog title, but only in the Perch admin area. I dont know why they appear there or how to remove them!

Simon Clay

Simon Clay 127 points

I think it's because the region was changed from a text field to a texture field. That's the 'why' :)

the 'how'... you'd need to delete them in the Perch admin area and re-save the article (for each and every article). Or is that not working for you?

I suspect if you look at the page source you'll see the <p> tags there, although the browser is ignoring them.

Simon Clay

Simon Clay 127 points

Hang on, you mean showing in the blog admin listing rather than the blog edit page? In which case it might be that it's due to the way Perch Blog is not expecting <html> there. Which may be a problem.

Does adding replace="<p>|,</p>|"> help at all?

Its showing in both. The blog listing page and within the blog edit page itself. Both show the blog title with tags.

Any idea what the cause may be? IM just not sure if its a setting or piece of templating I've got wrong somewhere

Simon Clay

Simon Clay 127 points

It might be that it's due to the way Perch Blog App is not expecting <html> there. Which may be a problem.

Does adding replace="<p>|,</p>|"> help at all?

<perch:blog id="postTitle" type="textarea" order="1" label="Post Title" html="true" editor="ckeditor" />

Makes no difference I'm afraid - in fact that messes up the post title on the actual site!

Simon Clay

Simon Clay 127 points

Ah, ok. It might be that we can't have wysiwyg in the Titles for Perch Blog App. Can you confirm if that's the case Rachel or Drew?

Drew did suggest a few days ago I use textarea for titles if single line isn't enough

Simon Clay

Simon Clay 127 points

Hmmm, I've just tried it in one of mine and I am getting the same problem as you... <p> tags in the Blog listing in Admin. Not in the Edit page though. (I am using Redactor). Still a problem of course and any other formatting like <strong> is going to show up in there too.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Don't use HTML in your post title - it's going to cause problems everywhere. Keep the title plain text. Add an additional field if you need to use HTML - you can display that at the points where you want the HTML to be used.

ok, understood! Thanks for your efforts though, Simon!

Simon Clay

Simon Clay 127 points

Thanks Chris and thanks Drew.