The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
load & show all com...
 
Notifications
Clear all

Question [Solved] load & show all comments at once, injecting Javascript

6 Posts
2 Users
0 Reactions
1,325 Views
Posts: 4
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@tunafish)
Active Member
Joined: 3 years ago
[#6612]

Hi,

 

I was wondering if it is possible to load all comments at once as the front end user injecting Javascript?

If there is a public Method available to do that?

Reason I ask is because I want to print out the pages with a lot of comments with AJAX pagination, I don't want to have to scroll down for each page to print..


5 Replies
Asti
Posts: 8217
 Asti
Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@asti)
Illustrious Member
Joined: 8 years ago

Hi @tunafish,

You can use the "Load all comments" for the "Comments Pagination Type" option. It's located in the Dashboard > wpDiscuz > Settings > Comment Thread Displaying admin page.

More info here: https://wpdiscuz.com/docs/wpdiscuz-7/plugin-settings/comment-thread-displaying/#comments-pagination-type


2 Replies
(@tunafish)
Joined: 3 years ago

Active Member
Posts: 4
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@asti 

Thanks for the reply but as the front end user I don't have access to the admin page. I want to load all comments with JS injecting it after the page has loaded. No Public Method or eventListener or something?


Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8217
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@tunafish,

This is not possible with wpDiscuz for security reasons.  


Posts: 4
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@tunafish)
Active Member
Joined: 3 years ago

I don't see why loading all comments could be a security issue, but hey I am not a developer.

I am not trying anything wrong or strange or something, I just want to print all the comments of some webpages using your ajax pagination without having to scroll!..

<div class="wpdiscuz-comment-pagination" style="display: none;">
<div class="wpd-load-more-submit-wrap">
<button name="submit" data-lastparentid="281344" class="wpd-load-more-submit wpd-loaded wpd-prim-button">
Load More Comments </button>
</div>
<span id="wpdiscuzHasMoreComments" data-is_show_load_more="1"></span>
</div>

Is there nothing I can do with the button?

Any help would be appreciated!

 

 


Posts: 4
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@tunafish)
Active Member
Joined: 3 years ago

OK, I have found it.

Basically 3 steps:

  • set .wpdiscuz-comment-pagination property to style="display:block"
  • set #wpdiscuzHasMoreComments attribute to data-is_show_load_more="0"
  • <button> .click()

I checked pagination with:

  • presence of #wpdiscuzHasMoreComments
  • comparing the <button> attribute data-lastparentid against the last loaded comment <div> id #wpd-comm-XXXXX_0

Hope it can help someone else!

 

function autoLoadAllComments() {
	var moreComSpn = document.getElementById('wpdiscuzHasMoreComments');
	if (moreComSpn != null) {
		var moreComBtn = moreComSpn.previousElementSibling.firstElementChild;
		var btnLastParentID = moreComBtn.getAttribute('data-lastparentid');
		var divLastParentID = moreComSpn.parentNode.previousElementSibling.id;
		divLastParentID = divLastParentID.split('wpd-comm-')[1];
		divLastParentID = divLastParentID.split('_0')[0];
		if (btnLastParentID == divLastParentID) {
			moreComSpn.parentNode.style.display = 'block';
			moreComSpn.setAttribute('data-is_show_load_more', '0');
			moreComBtn.click();
		} else { clearTimeout(flash_autoLoadAllComments); }
	} else { clearTimeout(flash_autoLoadAllComments); }
}
autoLoadAllComments();
var flash_autoLoadAllComments = setTimeout(autoLoadAllComments, 250);

 

 


Share: