What is vldPersonals?

vldPersonals is a very easy to use dating/social software. It allows you to create a fully functioning & modern dating website in a matter of minutes. If You think it's too complicated - check vldPersonals!
Know more about how You can become a dating website owner

What is vldCrowd?

vldCrowd.com is the biggest unofficial community of vldPersonals owners. It is a place to share ideas and thoughts about Your dating website. It is a place to answer questions and receive answers.
Do You own a vldPersonals license? Don't hesitate and join!

Connect Today

Community members help each other to take their dating websites to the next level. Can You make your vldPersonals website better? Join and find out...

Connect With More Than 500 Dating Website Owners! Sign Up Today
This is not an easy mod to explain.
 
Sometimes you may want to pass variables from a template to a language call:
 
Like have a string output:
"Welcome Idealists to VldCrowd.com! You can post up to 5 blog posts today."
 
Where:
Idealists is a username
VldCrowd.com is app_title
5 is some limit set somewhere (daily_blog_post_limit)
 
Currently it is not possible to do such language string manipulation within a tpl file itself.
 
All that is required for this example, is a language definition:
 
"vldcrowd_welcome_message" => //MOD
 
"Welcome %1% to %2%! You can post up to %3% blog posts today", //MOD
 
And then within the tpl file you would call the language string normally except now you pass the variables as such (variable 1 to 3, from left to right):
{lang:"custom","vldcrowd_welcome_message",session.username,settings.app_title, session.daily_blog_post_limit}
 
Only change is to replace (backup original ofcourse) the function vldext_lang within your ext.lang.php which is under /includes/ext/core with:
PHP

function vldext_lang ($mod, $key, $value1 = "", $value2 = "", $value3 = "")
{
        global $LANG;
 
        $language_string = isset($LANG[$mod][$key]) ? nl2br($LANG[$mod][$key]) : $key;
       
        $variables = array("%1%", "%2%", "%3%");
       
        $values = array("$value1","$value2","$value3");  
       
        $language_string = str_replace($variables, $values, $language_string);     
       
        return $language_string;
       
}
 

Also this will output the variable name instead of "Unknown field" if the field isn't found within the language definition. A bit more user friendly, and if you name your fields well, it should mean something to a user.
 
You can pass a max of 3 variables (if you know PHP you can easily increase it)
If you only need to pass 1 variable then it would be like:
{lang:"custom","vldcrowd_welcome_message",session.username}
 
If you don't need to pass variable it would be the same as old days, like:
{lang:"custom","vldcrowd_welcome_message"}
 
So no need to change all language calls.

Comments

radioact

  • Posted on 11/08/2009 12:07 AM
What a beautiful mod, I should develop it first!

Log in to leave a comment