<?php
$this->template()->setHeader('head', array(
'somefile.js' => 'static_script',
'otherfile.js' => 'style_script'
));
And it will be loaded in the head. Notice that the difference is the first param when calling ->setHeader.
Showing posts with label develop. Show all posts
Showing posts with label develop. Show all posts
Friday, September 13, 2013
Recently (version 3.6) we moved all JS files to the end of <body>, this improves performance but there are some cases where you as a developer need to put JS files in <head>, in 3.7 we are introducing a way to do this, from a controller you can now do this:
Friday, June 29, 2012
Phpfox Developers: Correct way of sending mail (multiple languages)
Well we got a bug report today that at first seemed intimidating, the case was that in some mails being sent the script would not take into account the language of the receiver if it was a registered user. The first approach was to open the callback for that one case and scenario and fix it there, 3 lines of code edited no big deal, the problem is that it was a callback, meaning every module implemented, so 3 lines of code times 61 was too much to do by hand, luckily we have a built in method to change the language just for one phrase and the fix turned out to be site wide and implemented in less than 1 minute, here's the recap:
This code is wrong because it will not take the target user's language into account
This next is correct:
That is basically it, since you are passing the user_id in the ->to() function the mail library will pick up the language for that user, and by passing an array instead of the actual phrase the mail library will get the correct phrase, you can also include an array of parameters if you like as a second element in the array:
and it will run the replacements as if you had done a getPhrase. Our fix was to Replace In Files all
->subject(Phpfox::getPhrase
with
->subject(array
and same for
->message.
This code is wrong because it will not take the target user's language into account
Phpfox::getLib('mail')->to($aRow['user_id'])
->subject(Phpfox::getPhrase('module.var'))
->message(Phpfox::getPhrase('module.var'))
This next is correct:
Phpfox::getLib('mail')->to($aRow['user_id'])
->subject(array('module.var'))
->message(array('module.var'))
That is basically it, since you are passing the user_id in the ->to() function the mail library will pick up the language for that user, and by passing an array instead of the actual phrase the mail library will get the correct phrase, you can also include an array of parameters if you like as a second element in the array:
Phpfox::getLib('mail')->to($aRow['user_id'])
->subject(array('module.var', array('param1' => 'val1')))
->message(array('module.var', array('param2' => 'val2')))
and it will run the replacements as if you had done a getPhrase. Our fix was to Replace In Files all
->subject(Phpfox::getPhrase
with
->subject(array
and same for
->message.
Thursday, June 28, 2012
User Group Settings Check
If your custom phpfox module adds user group settings you may want to implement a validation for them, we added a way to run checks based on one bug report related to the custom fields, if you go to the AdminCP and manage settings for a user group, in the "Custom" module there's a setting "Custom field database table name?", this is the name of a table that must exist in the database already, we want to improve this whole routine but meanwhile the admin has to have the table created. So we added a callback in the module "Custom", this function receives an array with two indexes ("variable" and "value") and checks if the table exists. This is how that function looks like:
Remember that callback functions are to be placed in your callback.class.php file in your folder "service".
public function isValidUserGroupSetting($aVal)
{
switch ($aVal['variable'])
{
case 'custom_table_name':
return $this->database()->tableExists($aVal['value']);
default:
return true;
}
}
Remember that callback functions are to be placed in your callback.class.php file in your folder "service".
Subscribe to:
Posts (Atom)