The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 861 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED Reading time
#1
I will show the reading time on a blog post.
The first step is strip all the unnecessary characters from the content in the xml-file.
Try it with this code:

Code:
strip_tags(html_entity_decode(get_page_content()));


But it doesn't work.
Someone knows how the content text convert to raw text, so i can put it in a variable.
Reply
#2
(2023-02-22, 06:43:55)tuxy Wrote: I will show the reading time on a blog post.
The first step is strip all the unnecessary characters from the content in the xml-file.
Try it with this code:

Code:
strip_tags(html_entity_decode(get_page_content()));


But it doesn't work.
Someone knows how the content text convert to raw text, so i can put it in a variable.

In getSimple the get-Functions mostly (and misleadingly) echo something, while the return-Functions return a value that you can store in a variable. E.g. see http://get-simple.info/wiki/themes:template_tags: you should be able to use returnPageContent(return_page_slug()).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
(2023-02-23, 02:35:59)mvlcek Wrote:
(2023-02-22, 06:43:55)tuxy Wrote: I will show the reading time on a blog post.
The first step is strip all the unnecessary characters from the content in the xml-file.
Try it with this code:

Code:
strip_tags(html_entity_decode(get_page_content()));


But it doesn't work.
Someone knows how the content text convert to raw text, so i can put it in a variable.

In getSimple the get-Functions mostly (and misleadingly) echo something, while the return-Functions return a value that you can store in a variable. E.g. see http://get-simple.info/wiki/themes:template_tags: you should be able to use returnPageContent(return_page_slug()).

Hi mvlcek,

This works perfect, thanks for help me thinking the right direction (omg my english ? )

Here the complete snippet, maybe useful for other GS-users...


Code:
<?php
// ------ READING TIME ------
                     
$rawText = strip_tags( returnPageContent(return_page_slug()) );// convert content to raw text

$wordCount = str_word_count($rawText);// getting the number of words
$minutesToRead = round($wordCount / 200);// getting the number of minutes

if($minutesToRead < 1){// if the time is less than a minute
 $minutes = 'less than a minute reading time';
}else{
  $minutes = $minutesToRead . ' minutes reading time';// saving the time in the variable
}
echo $minutes;
?>
Reply




Users browsing this thread: 1 Guest(s)