Question for PHP Gurus (spinning content)

avatar33

e-Hustler
Dec 5, 2009
3,838
52
48
Calgary, AB
Hello coding ninjas,

I have installed a business directory on one of my websites (similar to Yellow Pages) and it generates thousands of category pages, basically one for each city and state in the U.S. It also includes a small "intro text" at the top of each category page.

The problem though is that all these pages have the same intro text. The H1 header is the only thing that's different (c.f. Name of the City/State)

I want to be able to spin the intro text that is rendered using a PHP spinning function, so that each category page has slightly unique content. I googled it and was able to find this page: Spin Text For SEO - A PHP Spinner

The problem I can see with this code though is that every time I press F5, the spinning text will run again and the content of the page will be different.

Is there a way to fix this? Anyone ever done something like this before?
 


I'm in this thread, but I'm a little drunk and can't answer right now. If you need help PM me.
 
^ Yup, spin it once, cache it as static HTML, retrieve it when needed. The cache filename could be a md5() of current URL - somethine like:

Code:
$cache_file = 'cache/'.md5($_SERVER['REQUEST_URI']);
if(file_exists($cache_file)) {
   // cache exists, retrieve
   $content = file_get_contents($cache_file);
} else {
   // cache doesn't exist, generate it
   $content = getSpunContent();
   file_put_contents($cache_file, $content);
}

echo $content;
 
Read the link you posted... It's in there (Update).

Code:
# Optional, always show a particular combination on the page
    if($seedPageName)
    {
        mt_srand(crc32($_SERVER['REQUEST_URI']));
    }

Yea I know but it doesn't seem to work though.

I copy-pasted the entire function in my functions.php file (which is included in all pages) and the spinning works fine but everytime I hit refresh it re-spins the content. I don't know what I'm doing wrong...

I'm in this thread, but I'm a little drunk and can't answer right now. If you need help PM me.

I'll PM your drunk ass right now lol

just have it spin it once and spit out a static HTML page of your spun shit.. problem solved.

Sounds good, but this goes beyond my PHP skills. I really wanted to make the code in the OP work since it looks so simple.