Modifying the text on a PHP created webpage

Hi All,

I'm having success modifying the suggested-friends-extended plugin to suggest friends based on a rather novel concept (as a beginner I'm quite proud I've managed to make a small change to plugin PHP code! Whether anyone will be interested in my novel concept is a different matter!).

Anyway, now I need to modify the way my changes appear on the html webpages...

So my question is... where do I find the files that write the html code? For example, suppose I want to change the text on a webpage from "Common interests:" to "Different interests:"

Any guidance/ hints would be gratefully recieved!



  • Most texts come from language files (found in /languages/en.php for example). Search for the text you wish to change in the language file.

    Then you have the language key, and you can search the rest of the php code for where the language key is used. Then you can add a new language key (or override the old one with a new value) and use the new language key where you want.

  • Hi All again (and especially Jerome),

    Thanks for your advice but I am still failing to change a bit of text on my Elgg based social site.

    As I mentioned above I use the suggested-friends-extended plugin which produces the phrase "Common interests" when suggesting friends: but I want to modify that phrase to "Different interests".

    I have tried changing the vale of a key(?) in the language (en) file as shown here:

    'suggested_friends_extended:sex:same' => 'Same sex',    
        'suggested_friends_extended:sex:sameno' => 'Opposite sex',    
        'suggested_friends_extended:age:same' => 'Similar age',    
        'suggested_friends_extended:location:same' => 'Same location',
        'suggested_friends_extended:interests:same' => 'Different interests',
        'suggested_friends_extended:radius_loc:same' => 'Nearby member, less than %s %s',


    ... and yet the html page produced has unchanged text ("Common interests").

    Then I tried changing the key slightly:

    suggested_friends_extended:interests:samech' => 'Different interests'

    ..and similarlly modifying the key name in another file (people.php) which uses that key...

    and the result was the text on the webpage changed (hurrah!) from "Common interests"... but to "suggested_friends_extended:interests:samech" !

    I sure could do with some advice!




  • Hi All once again!

    OK well I've managed to do what I was trying to do! However I do wonder if the manner I did it is "permissible" as good PHP!

    I went back to the "people.php" file in suggested-friends-extended which I'd modified as above and then changed:

    $info .= '<span>' . elgg_echo('suggested_friends_extended:interests:samech') .': ' .substr_replace($person['interest'] ,"",-2). '</span><br />';


    $info .= '<span>' . elgg_echo('Different interests') .': ' .substr_replace($person['interest'] ,"",-2). '</span><br />';

    Is such a "bodge" allowable?



  • elgg_echo('Different interests') is not at all consider best practice.

    You were doing it right the first time. You need to edit the language files. Once done editing, flush your cache and run an upgrade. I believe you missed that step.

  • Thanks for taking the time to reply, Rohit.

    "Once done editing, flush your cache and run an upgrade. I believe you missed that step)".

    So I flushed the browser cache (right?). Is there any other (Elgg related?) cache I should flush?

    I certainly didn't run an upgrade...  If I upgrade all of Elgg (ie reinstall latest version?) won't that overwrite any edits to files that I've made?

    Thanks for your patience with this beginner!


  • I am not talking about the browser cache. I am talking about the elgg cache. The buttons that are available in your admin page.

  • The language strings are cached by Elgg if you have the caching options enabled on the advanced settings page in the admin area of your site. If you keep the caching options enabled while making changes you have to flush the cache (via correponding button on the admin dashboard page in the admin area of your site). Clicking the "Upgrade" button (or calling the upgrade.php script via address bar of the browser) when not having a new version of Elgg installed does not hurt as it would also only flush the cache in this case.

    You should make your changes in the language strings by modifying in language files in any case. Otherwise you will have major problems when upgrading to a newer Elgg version! You wouldn't have to make the changes in every single language file of Elgg and plugins. Instead of making the changes in the original language files you can add all language strings you want to change (and only these) in a new language file in a separate plugin. You can use the "Rename the wire" plugin ( as a starting point. This plugin will contain everything you need to have a working plugin. And then you can just alter the en.php language file it contains by adding the lines of language strings from other plugins' language file and then change the text to be displayed according to your needs. Just delete the lines already present (as an example) that you don't want to be changed. In the same way you can also add/delete language files for other languages (like de.php as an example for a German language file).

  • Wow big thanks iionly and Rohit Gupta!

    I have learnt the necessity of "Flushing the caches"!

    A great success!



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