Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-09-15 17:41:25

-P-
Member
From: Finland
Registered: 2005-09-10
Posts: 211

[issue] Comment count does not show in older imported posts.

I imported my MT entries from a text file to fresh Textpattern installation. As you can see here , comment count shows only in the new post(s) made after the import. How come?

The import script was custom made for me since my MT database was destroyed but I tested also_with_another blog on WP importing few entries via database and the problem is same. Comments are there but in the front page it doesn´t show the count.

code for diplaying my comments is
<code><div class=“postwide”>
<h2><txp:title /></h2>
<txp:body />
<div class=“posted”>
<txp:author /> @ <txp:permlink><txp:posted /></txp:permlink>
<txp:category1 link=“y” /> | <txp:comments_invite/><txp:comments_count /></div>
</div></code>

I assume I haven´t done there anything vitally wrong?… so is this a bug or a how to?

Offline

#2 2005-09-15 17:56:12

Sencer
Developer emeritus
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: [issue] Comment count does not show in older imported posts.

Ah, yes. It used to be, that comments were counted for display. Since this was quite inefficient, we switched to storing the number of comments with the articles. Unfortunately the importers were not updated. I’ll put this on the to-do list.

> The import script was custom made for me

You should ask the person who wrote the importer to add something that counts the comments and adds their number to the appropiate field. There is an appropiate snippet in the update-script:

<code> // 1.0: populate comments_count field $rs = safe_rows_start(‘parentid, count(*) as thecount’,‘txp_discuss’,‘visible=1 group by parentid’); if ($rs) { while ($a = nextRow($rs)) { safe_update(‘textpattern’,“comments_count=”.$a[‘thecount’],“ID=”.$a[‘parentid’]); } }
</code>

Offline

#3 2005-09-15 18:22:25

-P-
Member
From: Finland
Registered: 2005-09-10
Posts: 211

Re: [issue] Comment count does not show in older imported posts.

Tell you the truth, I can´t bother any more the person who did that import script, he has done his share allready. When my database crashed, It killed 5 MT blogs and he hand made the conversion needed (I don´t know much about pearl) for each import. And all he did ask back was donation for Katarina victims.

And as I posted, when testing import with Wordpress this same problem still continued so it´s not like my import was missing something. This is maybe a small thing but I need to see my comment count :D

Can I run that script myself and how? Or could somebody help me on it.

_______________________________________________

edit:

Problem solved, -kind of.

When editing some comments, I noticed that it updates the whole system and comment count in older imported posts shows after that. But guess there´s something wrong somehow since it´s not automatic.

Last edited by -P- (2005-09-15 22:36:45)

Offline

#4 2005-11-14 11:21:19

jmmygoggle
New Member
Registered: 2004-10-14
Posts: 3

Re: [issue] Comment count does not show in older imported posts.

I ran into similar problems upon importing my data exported from MT 2.661. Here’s a quick kludge in PHP to update the comments_count fields for each article in the textpattern table based on the number of comments for each parent_id in the txt_discuss table. This is probably grossly inefficent and could probably done more simply with some smart SQL usage.

NOTE: This is provided as-is and shouldn’t cause problems but was only used once on a very small site. Just thought this might help cut corners for someone in the same situation. Look over the code and make sure this won’t cause any problems.

You’ll also notice some weirdness in the formatting below where the newline symbol (\n) jumps to the next line. There are actually br tags in there that are being rendered by the browser. View source to get the real deal without all the weirdness. I also had to take out the begin/end <code><?php ?></code> tags.

<pre>
<code>
// SET THE VARIABLE BELOW TO ‘yes’ TO ACTIVATE THE SCRIPT
// SET THE VARIABLE BELOW TO ‘no’ TO REVIEW A LIST OF THE UPDATES THAT WILL BE MADE TO THE TEXTPATTERN DATABASE
$updates_activated = ‘no’;

// ENTER THE TEXTPATTERN DATABASE NAME
$dbname = ‘databaseName’;
// ENTER THE USERNAME AND PASSWORD WITH ACCESS TO THE TEXTPATTERN DATABASE ABOVE
$dbuser = ‘databaseUser’;
$dbpass = ‘databasePassword ‘;

mysql_connect(“localhost”, $dbuser, $dbpass) or die(“Could not connect: “ . mysql_error());
mysql_select_db($dbname);

$query_comments_count = ‘SELECT parentid, count( * ) as count FROM txp_discuss GROUP BY parentid;’;

$result = mysql_query($query_comments_count);

if ($updates_activated != ‘yes’) { echo ‘UPDATES NOT ACTIVATED. No changes to the database will be made.’.”<br /><br />\n”;
}

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // PERFORM SQL UPDATES AND PRINT A LIST OF THE SQL QUERY STRINGS if ($updates_activated == ‘yes’) { // printf(“parentid: %s count: %s <br />\n”, $row[“parentid”], $row[“count”]); $update_query = ‘UPDATE textpattern SET comments_count = ‘.$row[“count”].’ WHERE id = ‘.$row[“parentid”].’;’; $update_result = mysql_query($update_query); if ($update_result) { $update_query .= ‘ Success!’; } else { $update_query .= ‘ Failed.’; } echo $update_query.”<br />\n”; } // PRINT A LIST OF THE SQL QUERY STRINGS else { // printf(“parentid: %s count: %s <br />\n”, $row[“parentid”], $row[“count”]); $update_query = ‘UPDATE textpattern SET comments_count = ‘.$row[“count”].’ WHERE id = ‘.$row[“parentid”].’;’; // $update_query .= ‘ Updates not activated.’; echo $update_query.”<br />\n”; }
}

mysql_free_result($result);

echo ‘<br />FINISHED’;

</code>
</pre>

Last edited by jmmygoggle (2005-11-14 11:37:21)

Offline

Board footer

Powered by FluxBB