Bootstrap Standard

I have to build a new form from scratch to manage a Morphine list.

@brady.miller I am trying to apply the standard_header_template.php file that you created. My base code should be this:

 <?
 require_once("../globals.php");
 ?>
<html>
<head>
<?php html_header_show();?>
<title><?php xl('Morphine List','e') ?></title>
<?php require($GLOBALS['srcdir'] . '/templates/standard_header_template.php'); ?>

</head>
<body>

</body>
</html>   

This should get me off on the right foot in keeping with the bootstrap and new modern coding methods right?

yep,

Some minor things:

  1. for the title use this instead which will prevent cross-scripting attacks:
    <title><?php echo xlt('Morphine List'); ?></title>
  2. use following nomenclature instead to include the template:
    <?php require "{$GLOBALS['srcdir']}/templates/standard_header_template.php"; ?>

This brings in theme, bootstrap, jquery, fontawesome automatically.
(and there’s support to easily bring in other assets such as datetimepicker)

And if you plan to use the datepicker, let me know, and I’ll show you how to set that up.

-brady

There is a little location issue I ran into with number 2. When I copied the standard_header_template.php file, it was in root template folder. As you know {$GLOBALS[‘srcdir’]} points to the library folder.

So where is this template file going to live in the future is my question?

Here’s where it is in the most recent codebase (ie. library/templates/):
https://github.com/openemr/openemr/blob/master/library/templates/standard_header_template.php

As an aside, if your were to place the above file in your rx PR code, then it should work with the changes I am recommended.

I just realized that we can make it even simpler by migrating the html_header_show() to the standard_header_template.php. Then the developers would not need to remember to add the html_header_show() line. I’ll plan to do this soon.
-brady

1 Like

@juggernautsei ,

You no longer need to add the html_header_show() line. This is now automatically taken care of when include the standard_header_template.php :slight_smile:

-brady

1 Like

The link above is not longer working.

I am ready to work on another report where I need the date function. How is that setup now?

Hi @juggernautsei ,

As of yesterday, this feature was converted to a really nice class by @robert.down in the current codebase. Sorry about that. I promise we won’t change it anymore.

So, to get your above script to work, do the following:

  1. Place the following at top of script (good place is above the php includes):
    use OpenEMR\Core\Header;
  2. Replace the line of code with standard_header_template.php in it to the following:
    <?php Header::setupHeader(); ?>

For a bunch of examples, check out the following commit:

(regarding the date widget, I’ll do that in another post in a little bit)

-brady

ok,

Now to setup the datetimepicker :slight_smile:

  1. Place the following at top of script (good place is above the php includes):
    use OpenEMR\Core\Header;
  2. Place the magical class line within the head tags in your script:
    <?php Header::setupHeader('datetime-picker'); ?>
  3. Place the following code if need date widget (without time) in your javascript section(within the jquery $(document).ready(function() { section):
    `$(’.datepicker’).datetimepicker({
<?php $datetimepicker_timepicker = false; ?> <?php $datetimepicker_showseconds = false; ?> <?php $datetimepicker_formatInput = false; ?> <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?> <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>

});`

  1. Place the following code if need date widget (with time) in your javascript section(within the jquery $(document).ready(function() { section):
    `$(’.datetimepicker’).datetimepicker({
<?php $datetimepicker_timepicker = true; ?> <?php $datetimepicker_showseconds = false; ?> <?php $datetimepicker_formatInput = false; ?> <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?> <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>

});`

Note you can support both a datetimepicker with and without time in the same script since they are using different class names.

  1. Then just set the timepicker html element to have the class (datepicker for date only and datetimepicker for date/time)

Here’s an older example where a script was converted to the new date widget:

-brady

I followed as instructed. I inserted the use OpenEMR\Core\Header; and <?php Header::setupHeader(); ?>

I copied the header.php from


Placed it in the same location.

Do I need to run composer to get it to work.

PHP Error log entry.
[31-May-2017 07:12:38 America/New_York] PHP Fatal error: Class ‘openemr\core\header’ not found in C:\emr-wamp\www\openemr\interface\reports\cmsnote_sign.php on line 38

[31-May-2017 07:12:38 America/New_York] PHP Stack trace:

[31-May-2017 07:12:38 America/New_York] PHP 1. {main}() C:\emr-wamp\www\openemr\interface\reports\cmsnote_sign.php:0

[31-May-2017 07:13:31 America/New_York] PHP Fatal error: Class ‘OpenEMR\Core\Header’ not found in C:\emr-wamp\www\openemr\interface\reports\cmsnote_sign.php on line 38

The file that I am building.
cmsnote_sign.php (1.4 KB)

Hi @juggernautsei ,
Only need those 2 lines. Are you using the most recent codebase?
-brady

@juggernautsei ,
btw, your code looks good (just need to ensure using the most recent codebase).
On your code, note you can remove the php html_header_show() line (this hook is now incorporated in the Header::setupHeader call ).
-brady

I am using v5.0.0(3). Production copy. So, more than likely this will not work yet. I’ll revert back to the previous for now.

@juggernautsei,
oh, all the stuff above is only working in the development codebase. For 5.0.0(3), will need to do it the old way (ie. include each needed asset separately).