Hi all, i am new to elgg and learning to make a simple hello_world plugin from cash costello's book, i tried adding a languages and views folder but elgg doesnt seem to respond to that, can ne1 help?
I created a languages folder in root directory of the plugin with en.php, and views > default > plugin_name > temp.php file which i called from pages/world.php file using elgg_view() function...
Is there some other setting that needs to be done for elgg to understand that there is languages and view folder?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Matt Beckett@Beck24

Matt Beckett - 0 likes
- Deepak Sharma@callmedeepak

Deepak Sharma - 0 likes
- Paweł Sroka@srokap

Paweł Sroka - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- Deepak Sharma@callmedeepak

Deepak Sharma - 0 likes
- Brett@brett.profitt

Brett - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- Deepak Sharma@callmedeepak

Deepak Sharma - 0 likes
You must log in to post replies.Elgg caches the locations of views and the language strings. In order to have new stuff registered you need to clear the cache by going to the admin panel and clicking the 'flush caches' button on the control widget.
When doing a lot of development though, it's easier just to turn of caching. Do that in Admin -> Settings -> Advanced Settings
Uncheck the boxes for system cache and simple cache. Then it will register new views and language strings on every pageload. Make sure to have caching turned on for any production environments though.
Thanks a lot Matt, it worked :)
There's one more problem still, I had put the following in en.php
$mapping = array(
'hello:user'=>'Hello, %s',
);
add_translation('en', $mapping);
and when i elgg_echo it using
echo elgg_echo('hello:user', elgg_get_logged_in_user_entity());
it echos Hello, %s instead of replacing %s with logged in username. Any ideas of why its not working as expected?
Second parameter is supposed to be an array: http://reference.elgg.org/engine_2lib_2languages_8php.html#a6edd4daf01b4959806bac3f130714acf
@Deepak Sharma Try this:
@RvR oops actually i have used something like this one only,
while trying to make long story short, I made a mistake, here's what all i have used:
Plugin Name: hello_world
"hello_world/pages/hello_world/world.php" contains :
"hello_world/views/default/hello_world/greetings.php" contains :
"hello_world/start.php" contains :
now, everything's working fine, except, the problem that, i get Hello, %s instead of Hello, username when i load http://website.com/hello/world and i have specified correctly in hello_world/languages/en.php
elgg_echo() still needs an array as the 2nd argument.
@Deepak Sharma Use my above code example in your hello_world/views/default/hello_world/greetings.php
And in hello_world/pages/hello_world/world.php rewrite your code with it:
Thanks a lot vry1, shud have listened at first time, "array reqd as 2nd argument" Sry for such a silly question. :)
changing $vars['name'] to array($vars['name']) made elgg_echo work in greetings.php :)
@RvR: didnt try your way, but logic says that it will obviously work. Thnx for clearing my doubts.