This blog site is not meant to be any information that is distributed to the general public. It is to serve as shared documentation between the DNSTC developers; however, if you find something useful and would like to use it, go right ahead.

Friday, February 18, 2011

Creating a new page type in WSMS

WSMS is a CMS system developed by DNS Technology Consultants, Inc.

The following are the directions on how to add a new page type in WSMS: 

  1. Create the new table (if needed)

  2. Add the new page to the pageTypes table in wsms_wsms

  3. If there is anything special that needs to take place for the page when the page is created, then add it to aj-new-page-add.php.

  4. Add the menu items for the new page into the menuitems table in wsms_wsms.

  5. Create the editor page for the content.

  6. Add a new function in wsms_ajax.js

  7. Go back to the menutiems table in wsms_wsms and add the new function that you created for the editor.

  8. Add a new reference in wsms_display_functions.php

  9. Add the table to the table definitions in wsms_wsms so that it can be installed.

Monday, February 14, 2011

Inserting Page Breaks when Printing Reports

Sometimes we have to create reports that are HTML based. Of course HTML is not conducive to formatted pages when being printed. You can, however, format the output using a combination of CSS code and DIV tags. This will then insert page breaks when the report is sent to the printer. Please be advised, that these page breaks will not be visible on the screen, but will be visible is you do a print preview.


In the CSS of the document or attached CSS add the following:

div.pagebreak {
page-break-after: always;
}

In the body of the document where you want to place the page break at the following:


<div class="pagebreak"> </div>

This will create a page break when the pages are printed.


For more information about CSS page breaks.


http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=909145&SiteID=1

Delete All Records in a MySQL Table – Quick Reference

Occasionally you may need to remove all records from a database table to reset the data. The following code is a quick reference to delete all of the records within a table. It can be copy/paste into a PHP page, then it will work after modify the reference to the database and/or tables.

This is just quick reference to remove all records from a database:

PHP Code:


$deleteSQL = "DELETE FROM inventory";
mysql_select_db($database_database, $databse);
$Result1 = mysql_query($deleteSQL, $database) or die(mysql_error());

Adding or Subtracting Dates in PHP

Working with dates within PHP sometimes come in handy, yet the syntax is not quite something that is easy to remember. You can add or subtract; days, months and years to the current date by using the mktime() function.


Here is some quick PHP code to add a month to the current date:
$next_month = mktime(0, 0, 0, date("m")+1, date("d"), date("y"));
$outDate = date("Y-m-d", $next_month);

For more on the mktime() function: http://php.net/manual/en/function.mktime.php


For more on the date() format function: http://php.net/manual/en/function.date.php

Turning on PHP errors on the Server

By default, if there is a PHP error, it is not displayed on the screen to the user. This is done for security reasons, but it does not aid the programmer in troubleshooting the issue. If you place some code within the .htaccess file, you can turn on the error display. The following code is used to turn on the error display for troubleshooting purposes:



php_flag display_errors on
php_value error_reporting 7


To add this code, perform the following:

  1. Use putty to log into server.
  2. cd to the appropriate /home/<users>/www directory
  3. nano .htaccess
  4. Copy and paste the code above to the file
  5. Save the .htaccess file… control/o

If you now refresh the page, you should see the error and you can be off to troublshoot!

Sunday, February 13, 2011

Submitting e-mail to pop-up window

Problem:

We had an issue with e-mail sending on an ASP Intranet and had to come up with a solution to redirect the sending of mail to a PHP page on the client's website.  The client's website did not have access to sendmail or any other program that could be used to send out the e-mail messages.

Solution:

To do this, we had to submit the data to a PHP page using a pop-up window, the only problem this caused was the form stayed on the screen with the entered data after it was submitted, since we used a pop-up window to submit the data.

I was able to solve this problem by adding the following code as an attribute to the form tag:
onsubmit="window.location='newpage.htm';"

This then changes the page that contains the form at the same time it is submitting the data to a pop-up page.

WYSIWYG Editor

I have purchased a WYSIWYG editor that can be used in any of the programming that DNSTC does and requires an editor.  A WYSIWYG editor is just that... What you see is what your get... this type of editor is used to replace textareas within a form.

The following is the documentation for the WYSIWYG editor that I purchased.

 http://www.wysiwygpro.com/index.php?id=56