Ever wonder how many pages, words or tt_content element you have in your Typo3 install? I am working with two large Typo3 sites and I was curious so I wrote a little piece of code. It works really well and is super quick. Here is what the output looks like:
Counting Pages
SELECT COUNT(uid) AS num_pages FROM `pages`Counting Pages Not Deleted
SELECT COUNT(uid) AS num_pages FROM `pages` WHERE deleted=’0′
Counting Content
SELECT COUNT(uid) AS num_content FROM `tt_content`
Counting Words
SELECT bodytext FROM `tt_content`
Totals
Num Pages: 4505
Num Pages Not Deleted: 2948
Num Content: 5152
Num Words: 28,394,588
If you would like to implement this yourself I provided the code below, instead of reinventing the wheel yourself.
(I put mine in the typo3conf folder for ease of use)
Counting Pages';
echo '
'.$sql_count_pages;
$result = $mysqli->query($sql_count_pages);
$result = $result->fetch_assoc();
$num_pages = $result['num_pages'];
echo 'Counting Pages Not Deleted';
echo '
'.$sql_count_pages_not_deleted;
$result = $mysqli->query($sql_count_pages_not_deleted);
$result = $result->fetch_assoc();
$num_pages_not_deleted = $result['num_pages'];
echo '
Counting Content';
echo '
'.$sql_count_content;
$result = $mysqli->query($sql_count_content);
$result = $result->fetch_assoc();
$num_content = $result['num_content'];
echo '
Counting Words';
echo '
'.$sql_bodytext;
$result = $mysqli->query($sql_bodytext);
while($r = $result->fetch_assoc()) {
$num_words += str_word_count($r['bodytext']);
}
echo '
Totals';
echo '
Num Pages: ' . $num_pages;
echo '
Num Pages Not Deleted: ' . $num_pages_not_deleted;
echo '
Num Content: ' . $num_content;
echo '
Num Words: ' . number_format($num_words, 0, '.', ',');
$mysqli->close();
?>