Search the Community
Showing results for tags 'random headlines'.
-
Hello All, I've added a "Random Articles" block to the bottom of our article pages, at The Significato Journal. The block is under the headline at the bottom, called: "More Headlines You May be Interested In" I have some questions: a) Is my code efficient and the best method to display 4 random headlines? It's of special concern if a site eventually has tens of thousands of articles, because I'm creating an array of all of the articles pages, and then grabbing 4 random ones. It would be better, I think, if I could create an array of only 4, but I don't see how I can do that and still randomly select from all of them. Here's my code: $random_selectors = "custom_template_file.select_value=article_page.php," . "publish_date<=$now, headline_image_name!="; $random_keys = wire('pages')->find("$random_selectors"); $random_pages = $random_keys->findRandom('4'); echo "<table width='100%' cellpadding='0' cellspacing='10'><tr>"; foreach ( $random_pages as $random_page ) { # ... display headline and image } echo "</tr></table>"; b) Every time I reload an article, the headlines change, which is what I want. Does this break the 1-day template cache on the article, or does the headline block get passed through, with the rest of the page still cached? I'd like to keep the cache running. Here's a sample url, so that you can see it in action: http://significatojournal.com/columns/culture-of-heart/the-living-compass-of-kindness-and-compassionate-love/ Thanks for any feedback! Peter