Date.ftl - set current time - alfresco

I'm using date.ftl to display date and time in Alfresco Share 4.2c, with parameter showTime set as true. Default time is 00:00. Is there a way to set current local time as the default time?
Is it better to try to change that in date.ftl or maybe in some associated .js file?
I was looking, but I couldn't find where it is set, so any help will be appreciated.

Changing existing date.ftl is not advisable.Instead of that you should create your own date control(you need to create both ftl and as well as javascript file),In that you need to change below things.
Change in tomcat\webapps\share\components\form\date-picker.js file(this should be file which you have created for your custom control).In onReady() function set the value of text box using javascript.

Related

How to change the number format of all decimal fields?

I want to format all decimals fields in all Module in which some calculations are saved using logic hooks. When I save them in EditView, it shows like 54,679.00000 instead of showing it 54,679.00 .
How do i remove the trailing zeroes ?
SuiteCRM use format_number function from the Currency module to formate different fields(Int, Float and Currency, etc). You can find its definition it this file: modules/Currencies/Currency.php and modify the format_number function according to your needs.
Moreover, you can find different fields definition in this folder: include/SugarFields/Fields/. There will be a folder for every type of field(e.g. custom/include/SugarFields/Fields/Float). You can see that there will be DetailView.tpl, EditView.tpl and a base class PHP file which contains the helping methods of every field type. If you copy include/SugarFields/Fields/<field_type> to the custom folder at the same location(e.g. custom/include/SugarFields/Fields/Float) then you can do the changes in that field type in upgrade safe manner as well.
Hopefully, that will help you to resolve your current issue and you can do the changes in single place :)

APEX dynamically define default filename?

In an APEX application, I have an interactive report.
In Report Attributes > Report Export > Filename, you can specify what file name you the download to have as a default.
Question: Is there a way to dynamically define this default filename?
Yes, I know, the user can change it when they do the download. But my boss wants the user to not to have to change the file name.
What can anyone tell me? Thanks!!
APEX 4.2
Windows 7
IE 11
Yes you can do this. Create a hidden page item (e.g. P1_REPORT_NAME) and set its value to be whatever you want the name of the file to be. You can calculate this in many different ways e.g. - pass a value through a link from another page, using a dynamic action or computation, or setting a default value via static content or pl/sql expression. Then navigate to Report Attributes > Report Export > Filename and set it to &P1_REPORT_NAME. - now the report will be called whatever the value of P1_REPORT_NAME is.

How to refresh after changing ValueNumericOptions.Format?

I'm using the DevExpress xtraChart to display some data. In the CustomDrawSeries event, I'm checking the series name and changing SeriesTemplate.Label.PointOptions.ValueNumericOptions.Format. It works... partially.
The idea is to change ValueNumericOptions.Format from NumericFormat.FixedPoint to NumericFormat.Percent and vice versa based on the name. The problem is the change is not displayed immediately. In order to see the change, the user must select another cell and then the change is visible immediately.
How can I force a refresh to the series and see the changes immediately without needing to select another cell?
Update -
After the change is made via code, I inspected Format and it is being set correctly. This confirms, in my mind anyway, this is a refresh issue.
I do not know what the real cause of the problem, but your approach seems to be not quite optimal. You modify the global settings (template) while your goal is just to change settings for a certain series.
What you want to achieve can be done during the ChartControl initialization, without having to handle events. The following code can be used to apply a percent format to a certain series:
DevExpress.XtraChartsPointOptions pointOptions = new DevExpress.XtraChartsPointOptions();
pointOptions.ValueNumericOptions.Format = DevExpress.XtraCharts.NumericFormat.Percent;
DevExpress.XtraCharts.SideBySideBarSeriesLabel label = new DeveExpress.XtraCharts.SideBySideBarSeriesLabel();
label.PointOptions = pointOptions;
DevExpressXtraChartsSeries series = xtraChart1.Series["Series Name"];
series.Label = label;
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
By the sounds of it you are registering to the Refresh event of the view controller which will change the format of the chart on refresh, assign your code also in the OnViewControlsCreated event to initialize your code upon first creating the view.

How to add more information to first html page sent by meteor server

Is there anyway we can add data like in php echo "something" in the first html page. I want to know the server's timestamp to format a document created time like 2 hours ago, the document already has a property createdTime. When I use Meteor.Collection.find, I cannot add the server time by using transform.
I can use Meteor.method but I may have to format time before the result arrives.
Thank you.
Well, after digging around the code, here is the answer.
You can use the global variable __meteor_runtime_config__ to add more information to the first downloaded html file. In my case, in a server side javascript file, I add __meteor_runtime_config__.now = new Date().getTime() and this value will be available on the client side
the __meteor_runtime_config__ approach is run-once; that is, only changes made at package load time (not Meteor.startup()) are taken into account, and then the __meteor_runtime_config__ snippet is frozen.
To pass run-time (per-page) metadata to the page, it looks like the only option is to set a custom tag on the <html> element using the (public, but undocumented) WebApp.addHtmlAttributeHook API.

Custom date format (callback with php logic)

I want to create a dynamic php date format. Example: show the time of the node if it was published today and only the day/month when older then today. I want this format to be available throughout Drupal like the other predefined date formats in Drupal (not just on theme level).
I found the (D7 only) hook for hook_date_format_types but even that one doesn't seem to allow for a callback where I could define this PHP logic.
Does anyone know which hook would make this possible? Or a module which does this?
In Drupal6, format_date() has the dates and times hardcoded. Also, format_date() does not allow callbacks, but it does allow a custom string. That is where you can apply a trick: instead of hardcoding the string in there, you call a function that returns a string.
function mydate_format($timestamp) {
$now = time();
if (($now - $timestamp) < (60*60*24)) {
return "H:i";
}
else {
return "d:m:Y";
}
}
print format_date($timestamp, 'custom', mydate_format($timestamp));
The second option is to re-define a date-timestamp, but that is both hackish and limited. Date-formats are defined with variable_get(), but don't pass the timestamp along; so your example of switching formats based on the value of timestamp is not possible this way.
In settings.php:
$conf['date_format_long'] = $conf['debug'] ? 'r' : 'l, F j, Y - H:i';
This will switch from one value to another, based on whether your settings.php has a flag "debug" set to TRUE or not. As mentioned: the use for this is limited, since you cannot get any context.
The third alternative is to use Date API which offers onlinle configurable time-formats. But that is both clumsy and insecure (inputting executable PHP in your database). It also depends on a very large module-set. And has the same downside as the first solution: you cannot use format_date, but must use a modified function call, instead of format_date(). See all the options at The Drupal.org date themeing handbook.
GOTCHA In all cases Drupal will not call this function for cached content. If you want to have the dates really dynamic you either need to avoid caching alltogether, or implement the date-formatting in clientside javascript.
TL;DR: You cannot have dynamic date-formats without changing some of the code on theme-level. Using a callback-function to generate the "custom" dateformat is the simplest, working solution.
You can use Date API module to add your custom date formatting. Date API module is inside the Date module. After enabling the Date API module you can go the path "admin/settings/date-time/formats/add" to add your custom format.
"admin/settings/date-time/formats/configure" is the path to configure date formats.
Have a look at these. Happy coding.
Thanks
RT
You can go to node.tpl.php(possibly in sites/all/themes/theme_name/node.tpl.php). Here yo can find $created variable, to reformat date you can use your custom function and change the $created as you want.After this all nodes will use your formatted dates.
Regatds,
Chintan.
Use the features module. Create a feature.
In the resulting feature module, on the [feature].module file, create a hook_nodeapi function and format the field with a conditional statement that takes into account the current date() for how the date will be displayed and feed it into the $node->content var.
And that is the way rockstars would do it (-;

Resources