Applying code snippets automatically
11 posts by 4 authors in: Forums > CMS Builder
Last Post: February 18, 2010 (RSS)
Hi Dave,
Sorry for the delay.
I'm using Dreamweaver CS3.
I’ve gotten into the habit of including tests for blank fields and spaces in my text based fields,
or
similar tests for date fields,
or
and a similar test for blank upload fields
as well as an http:// test for all fields that contain a URL (I’ve reserved the field name characters _url_ , _url , and url_ for fields that actually contain a URL)
or
These are the ones that are universal (for me anyway).
I'm not sure what the downsides would be if they were automatically generated, but I'm sure I'm missing something in the way others work.
Hope that helps clarify my thoughts.
Best,
Jerry
Sorry for the delay.
I'm using Dreamweaver CS3.
I’ve gotten into the habit of including tests for blank fields and spaces in my text based fields,
<?php if ($record['my_field'] && !ctype_space($record[''my_field'])): ?>
or
<?php if ($my_tableRecord['my_field'] && !ctype_space($my_tableRecord[''my_field'])): ?>
similar tests for date fields,
<?php if ($record['my_date_field'] && $record['my_date_field'] != '0000-00-00 00:00:00'): ?>
or
<?php if ($my_tableRecord['my_date_field'] && $my_tableRecord['my_date_field'] != '0000-00-00 00:00:00'): ?>
and a similar test for blank upload fields
<?php if ($my_tableRecord['my_image_field']): ?>
as well as an http:// test for all fields that contain a URL (I’ve reserved the field name characters _url_ , _url , and url_ for fields that actually contain a URL)
<?php if (!preg_match("/^http:\/\//", $record['my_url_field'])) {
$record['my_url_field'] = "http://" . $record['my_url_field']; } ?>
or
<?php if (!preg_match("/^http:\/\//", $my_tableRecord['my_url_field'])) {
$my_tableRecord['my_url_field'] = "http://" . $my_tableRecord['my_url_field']; } ?>
These are the ones that are universal (for me anyway).
I'm not sure what the downsides would be if they were automatically generated, but I'm sure I'm missing something in the way others work.
Hope that helps clarify my thoughts.
Best,
Jerry
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php