Using a php script to call up random text

 have a site at

On the external pages (homepage) on that site I wish to use a php script that calls up random quotes. I already have this script working on our main site at

However as the external pages on the Elgg powered site are apparently HTML a php script won't run because the page has to be saved with the extension .php.

Has anyone got any ideas how I can achieve this?

Also as a "by the way". When I edit the external pages, the first text editor is for a

lefthand information pane

There's another editor below it that is for a righthand information pane hand. Regardeless of what is entered in the righthand information pane nothing appears on the site.

Can someone clarify why this is please? Or am I missing something here!

Many Thanks,


Many Thanks

  • I am not a coder, and probably other experts on this site would answer this better, but just recently I was able to pull html code within  .php file without any problems.

    I simply added html code in the text editor and saved the file as "filename.php" and voila, it worked like a charm.

    And yes the second editor below the first one is for the right hand external box. And It should show you anything you put there. Text, code, java script, photo, a slideshow, whatever you want. I am not sure why you can't see anything. It's pretty much straight forward. You just add something there, save it and it should show you on the main page (if these external pages are being called on the main page).

  • Thanks Carter,

    Yes I've done the same with another site - simply changed the page file extension from html to php in order to make the page php active. However what I'm trying to do here is insert an includes php line of coding so that the page will insert the contents from a php file which is in the Elgg root directory on the server (in this case random quotes) each time the page is loaded. What I'm trying to get is a new gardening quote each time the site's home page is refreshed. If you look at the site ( )  you'll see where the quote SHOULD appear by looking down the left hand pane to "Gardening Quotes:"

    The text editor in the External pages/ Front page does not retain the snippet of code I put in there to call up the quotes.php file. My immediate assumption was that the External pages are saved as html files and not php so I wanted to find the file and change it's extension name to php. However by doing that I would also need to change references to the new file in other parts of the software otherwise it would not be able to find the original file that it refers to with the html extension - assuming I'm right in my original assumption!

    Re. the right hand pane page. It definately does NOT appear on the site's home page. Perhaps it has something to do with the template I'm using (Chatbuddy). In which case perhaps I need to get hold of the template autor.



  • If you want to add your random quotes thingy to your homepage I recommend that you hardcode it, don't use the external pages admin tool.

    If you're using the custom_index plugin you can go to the following:


    Add the following where you want it to appear:


    $quotes = array(





    echo $quotes[rand(0, count($quotes) - 1)];


    That should do the trick. However from my experience I could never get the array to take php or elgg_echos only standard html.

    Good luck!

  • @Trajan, how can i set the text changes in seconds???

    Thank you...

  • Hi sorry, didn't see this response. It's php not javascript so it happens each time a page is loaded or refreshed.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking