view comments & add comment window section

This is the right place to report general bugs, make suggestions or ask for help.
dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

view comments & add comment window section

Post by dart » Thu Jun 03, 2021 6:56 pm

Is there any way to make the 'comments & add comment' section to always show without having to click on it?

NorfolkGreg
Posts: 26
Joined: Wed Dec 30, 2020 9:58 pm

Re: view comments & add comment window section

Post by NorfolkGreg » Wed Jun 30, 2021 11:31 pm

I'm very new to FlatPress and can find no way to force this within the Admin interface.

However, in my brief testing it appears that once a comment is made then the Add Comment box will appear automatically under the first comment.

Overall, the Comments facility appears a little clunky. I find that when you click on the Add Comment link the entire page redraws so, if you are commenting on a long post, you have a lot of scrolling to do. Surely that ought to be done for you, if it is not possible to coe the page so the comment box simply opens on the page forcing the fotter a little further down. And, if you are in the habit of deleting comments, and you enable the LastComments plugin then also enabling the LastComments Admin becomes essential as you need to rebuild the index after each comment deletion.

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: view comments & add comment window section

Post by Arvid » Sat Jul 10, 2021 11:03 am

dart wrote: ↑Thu Jun 03, 2021 6:56 pm Is there any way to make the 'comments & add comment' section to always show without having to click on it?
In fact, there is. But this is not an option in the admin area; instead, the templating system allows you to completely freely change the output of your blog to your needs.

The following steps will add the detailled comments to the entry page for the default theme Leggero v2, you may need to adapt this to the theme you use on your blog.

The entry page
At first, clicking on an entry title on your entry overview page will bring you to the single entry (e.g. http://example.org/index.php/2021/04/21 ... flatpress/ - the URL might look different according to your PrettyURLs plugin settings).
fp-interface/themes/leggero/entry-default.tpl defines how this page looks like.
At line 29, you'll find:

Code: Select all

				{if !(in_array('commslock', $categories) && !$comments)}
				<li class="link-comments">
				<a href="{$id|link:comments_link}#comments">{$comments|tag:comments_number} 
					{if isset($views)}(<strong>{$views}</strong> views){/if}
				</a>
				</li>
				{/if}
There's a little programming logic there: The "if" section makes sure that the following will only be displayed if none of the entry's categories is locked for comments. The following lines define the HTML code that will be display under your entry, including

Code: Select all

<a href="{$id|link:comments_link}#comments">
which is the "3 comments" link that leads to finally seeing the comments.

The entry's comment page
When clicking this link, you will be lead to the comments page of the entry, http://example.org/index.php/2021/04/21 ... /#comments (see the trailing "/comments" that tells FlatPress to display the comments page, and the "#comments" that tells your browser to scroll down to the comments section as soon as the page is loaded).
The output of the comments page of the entry is defined by fp-interface/themes/leggero/comments.tpl, which is pretty interesting: In line 6, entry-default.tpl is included, we inspected this file a minute ago! So what is in entry-default.tpl, will be shown at line 6, and then, there come the comments: The whole section

Code: Select all

{comment_block} 
... 
{/comment_block}
defines how the comments are being displayed.

And finally: Putting the comments to the entry page
Now it's as simple as you might already think: Why not just taking the whole {comment_block} section from comments.tpl and insert it into entry-default.tpl?

Code: Select all

	<div itemscope itemtype="http://schema.org/BlogPosting" id="{$id}" class="entry {$date|date_format:"y-%Y m-%m d-%d"}">
				{* 	using the following way to print the date, if more 	*} 
				{*	than one entry have been written the same day,		*} 
				{*	 the date will be printed only once 				*}
				
		{$date|date_format_daily:"<h2 class=\"date\">`$fp_config.locale.dateformat`</h2>"}
		
				<h3 itemprop="name">
				<a href="{$id|link:post_link}">
				{$subject|tag:the_title}
				</a>
				</h3>
				{include file=shared:entryadminctrls.tpl}
				
				<span itemprop="articleBody">
				{$content|tag:the_content}
				</span>
				
				<ul class="entry-footer">
			
				<li class="entry-info">Posted by <span itemprop="author">{$author}</span> at
				{$date|date_format}

				<span itemprop="articleSection">
				{if ($categories)} in {$categories|@filed}{/if}
				</span>
				</li> 
				
				{if !(in_array('commslock', $categories) && !$comments)}
				<li class="link-comments">
				<a href="{$id|link:comments_link}#comments">{$comments|tag:comments_number} 
					{if isset($views)}(<strong>{$views}</strong> views){/if}
				</a>
				</li>
				{/if}
				
				</ul>
			
				
	</div>
	
<!-- the following is the comments block "borrowed" from comments.tpl! :) -->
	
		{comment_block}
		<ol id="comments">
		{comment}
			<li id="{$id}" {$loggedin|notempty:"class=\"comment-admin\""}>
				
				<strong class='comment-name'>
				{* 
					using this tag combo, the name is displayed as a link only
					if user entered a URL.
					
					Syntax is quite intuitive:
					"if $url is not empty, show $name between a tags, 
					else default fallback on displaying plain $name"
					
				*}
				{$url|notempty:"<a href=\"$url\" rel=\"nofollow\" title=\"Visit $url\">$name</a>"|default:$name}
				</strong>
				
				{include file=shared:commentadminctrls.tpl} {* this shows edit/delete links*}
				
				<p class="date">
				<a href="{$entryid|link:comments_link}#{$id}" title="Permalink to {$name}'s comment">{$date|date_format:"%A, %B %e, %Y - %H:%M:%S"}</a>
				</p>
				
				{$content|tag:comment_text}
				
			</li>
		{/comment}
		</ol>
		{/comment_block}
This is what we wanted to achieve: The comments are shown on the entry page, without having to explicitly click on the comments link.

Hope that helps you, let me know!
All the best,
Arvid

dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

Re: view comments & add comment window section

Post by dart » Sat Jul 17, 2021 11:52 am

So the entire 'comments.tpl code' is transfered to replace the 'entry-default.tpl' ?

dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

Re: view comments & add comment window section

Post by dart » Sat Jul 17, 2021 4:35 pm

ok - entered it in entry_default.tpl - but all looks the same.
Still have to click on 'add comment'.

Code: Select all

	<div itemscope itemtype="http://schema.org/BlogPosting" id="{$id}" class="entry {$date|date_format:"y-%Y m-%m d-%d"}">
				{* 	using the following way to print the date, if more 	*} 
				{*	than one entry have been written the same day,		*} 
				{*	 the date will be printed only once 				*}
				
		{$date|date_format_daily:"<h2 class=\"date\">`$fp_config.locale.dateformat`</h2>"}
		
				<h3 itemprop="name">
				<a href="{$id|link:post_link}">
				{$subject|tag:the_title}
				</a>
				</h3>
				{include file=shared:entryadminctrls.tpl}
				
				<span itemprop="articleBody">
				{$content|tag:the_content}
				</span>
				
				<ul class="entry-footer">
			
				<li class="entry-info">Posted by <span itemprop="author">{$author}</span> at
				{$date|date_format}

				<span itemprop="articleSection">
				{if ($categories)} in {$categories|@filed}{/if}
				</span>
				</li> 
				
				{if !(in_array('commslock', $categories) && !$comments)}
				<li class="link-comments">
				<a href="{$id|link:comments_link}#comments">{$comments|tag:comments_number} 
					{if isset($views)}(<strong>{$views}</strong> views){/if}
				</a>
				</li>
				{/if}
				
				</ul>
			
				
	</div>
	
<!-- the following is the comments block "borrowed" from comments.tpl! :) -->
	
		{comment_block}
		<ol id="comments">
		{comment}
			<li id="{$id}" {$loggedin|notempty:"class=\"comment-admin\""}>
				
				<strong class='comment-name'>
				{* 
					using this tag combo, the name is displayed as a link only
					if user entered a URL.
					
					Syntax is quite intuitive:
					"if $url is not empty, show $name between a tags, 
					else default fallback on displaying plain $name"
					
				*}
				{$url|notempty:"<a href=\"$url\" rel=\"nofollow\" title=\"Visit $url\">$name</a>"|default:$name}
				</strong>
				
				{include file=shared:commentadminctrls.tpl} {* this shows edit/delete links*}
				
				<p class="date">
				<a href="{$entryid|link:comments_link}#{$id}" title="Permalink to {$name}'s comment">{$date|date_format:"%A, %B %e, %Y - %H:%M:%S"}</a>
				</p>
				
				{$content|tag:comment_text}
				
			</li>
		{/comment}
		</ol>
		{/comment_block}

dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

Re: view comments & add comment window section

Post by dart » Mon Jul 19, 2021 6:18 pm

It took a while for some changes to respond.
The result is the list menu and all that follows the list ends up in the bottom.
The live post area extends to fill its place.
However, the comments section remains how it was before.
I can't figure it out is why sice the only change was a borrowed section added to the entry_default'

I tried a couple of times starting fresh since I have the original backed up... and
both times got the same resilts.

regardless, I appreciate the suggestions you made.
Judging from past experience, I have noticed that an open view of the comments window gets more comments.
the total amount of views remain about the same except for the interaction with the viewers.
That was the only reason I had inquired about this.

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: view comments & add comment window section

Post by Arvid » Tue Jul 27, 2021 10:13 am

Okay, fresh start. There are two possibilities to display the comments: On your blog's overview page, and on each blog entry.

To have the comments displayed for each entry on your overview page and on each entry's page, the changes described above work for me.
My entry-default.tpl:
entry-default.zip
(1.07 KiB) Downloaded 108 times
Essentially, adding the comments block to this file makes the comments a part of the entry. Whereever the entry is displayed (on the overview page, or on the entry's page itself), the comments will be shown.
The output is as follows:
1.jpg
1.jpg (94.15 KiB) Viewed 5698 times

To keep the overview page free of comments (which looks better to my eyes), and display the comments just on each entry's page, the solution is even easier.
How do we get to an entry's page? By clicking on the entry title on the overview page. We could now simply change this link so it will lead us directly to the comments page of the entry (where the comments are shown) instead of the entry page (where they are not).
In entry-default.tpl, you'll find:
<h3 itemprop="name">
<a href="{$id|link:post_link}">
<!-- this will lead to the entry page, but you'll have to click on the comment link ("3 comments") there to actually see the comments -->
{$subject|tag:the_title}
</a>
</h3>
Just change this to:
<h3 itemprop="name">
<a href="{$id|link:comments_link}">
<!-- this will directly lead to the comments page of the entry - exactly where you get to by clicking on the "3 comments" link on the entry page :) -->
{$subject|tag:the_title}
</a>
</h3>
Please give that a try, especially the second suggestion might be what you're looking for.

All the best,
Arvid

dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

Re: view comments & add comment window section

Post by dart » Fri Jul 30, 2021 12:29 pm

Bingo ! :D

The replacement code for the entry-default.tpl worked perfectly.
... and the overview is usually without comments anyway.

Thank you Arvid !

dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

Re: view comments & add comment window section

Post by dart » Wed Aug 04, 2021 1:58 pm

Just noticed - when [read more] is clicked, it shows original linking of the post without the comments window.

is possible to apply the 'comments window', to posts where the [read more] added ?

A big percentage of my posts contain [read more]

I checked thru the code @ the panel & have found nothing in feference to [read more]

dart
Posts: 58
Joined: Sun May 30, 2021 4:46 pm

Re: view comments & add comment window section

Post by dart » Wed Aug 04, 2021 6:52 pm

found this in '/plugin.readmore.php

Code: Select all

<a href=\"" . get_permalink($id) . "#readmore-{$id}\">" . $readmoreString . "</a></span>";}

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests