[dba-Tech] Question about such tools as WordPress

Peter Brawley peter.brawley at earthlink.net
Thu Jun 14 16:54:23 CDT 2018


On 6/14/2018 12:46, Arthur Fuller wrote:
> More generally, I guess, this question concerns how such web pages as The
> New York Times  <https://www.nytimes.com/> are laid out. When a story
> continues elsewhere, what does the creator do, in practice?

Depends on the app language, and on how the document to be presented is 
formatted. The articles at https://www.artfulsoftware.com/queries.php 
are text with some embedded html. After a few full articles have been 
shown, the page uses a little func that returns a pointer to the end of 
15 lines in the text or the beginning of a preformatted block, or null 
if neither is found ...

function txtbreak( $s, $len, $n ) {

   $found=0; $start=0;

   while( $start<$len && $found<$n ) {

     $ip = stripos( $s, "<pre", $start );

     if( $ip !== FALSE ) {

       $end = stripos( $s, "</pre", $ip+5 );

       if( empty($end)) break;

       $prelines = (int) floor( $end - $ip ) / 25;  // ESTIMATE

       $found += $prelines;

       $start = $end+6;

       if( $found > $n ) break;

       continue;

     }

     $ib = stripos( $s, "<br", $start ); if( $ib === FALSE ) $ib = 999999;

     $in = strpos( $s, "\n", $start ); if( $in === FALSE ) $in = 999999;

     $x = min( $ib, $in );

     if( $x < 999999 ) {

       $found++;

       $start = $x + 2;

     }

     else {

       $start = 0;

       break;

     }

   }

   return ( $start > 2 ) ? $start-2 : $start;

}


The article renderer then says ...

           $cut = txtbreak( $out, $len, 15 );

           if( $cut ) $out = substr( $out, 0, $cut );

           if( ( substr_count( $out, "<pre>" ) - substr_count( $out, 
"</pre>" )) % 2 )

             $out .= "</pre>";

           if( ( substr_count( $out, "<code>" ) - substr_count( $out, 
"</code>" )) % 2 )

             $out .= "</code>";

           $tease = "<p><b><i><a href='qrytip.php?id=$j'>" .

                        "Read the entire item</a></i></b></p>\n";


I think WordPress is meant to make such coding unnecessary, so it 
prob'ly has a parameterised func to do such.

PB

-----

>   Start with the
> entire article, give it a page name, then cut the title and first
> paragraph, and paste that into a frame on the main page? And, finally, add
> an URL at the bottom that points to the rest of the article?
>
> That seems like a lot of work, particularly when multiplied by the number
> of articles mentioned on the main page. I imagine there's a much simpler
> technique. Do you know what it is?
>



More information about the dba-Tech mailing list