We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23754
    • 13 Posts
    I have three lines of PHP code I use to produce random text from flat files in my branding (header) and content at my current site peterwade.com.

    How do I incorporate these in a chunk or snippet? Do I enclose them in normal PHP tages <?php ?> or just paste them in?

    ~~~~~~
            $quote = file("inchrist.txt");
    	srand((double)microtime()*1000000);
    	$inquote = $quote[rand(1,count($quote))];	

    ~~~~~~

    And how do I call them, e.g. <?php $inquote ?> ?

    Thanks,
    Peter
      • 4626
      • 57 Posts
      PHP-code goes into a snippet.

      Create a new snippet (I’ll call it "HeaderSnip"). Paste your code block into the code-area between the PHP-tags. In your template (or in a chunk/in the content) call your snippet with:
      [!HeaderSnip]]

      The exclamation point is there so it doesn’t cahce the result (your code seemed to imply that it should be run on every reload).