Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-07-23 07:52:31
- Siguo
- Member
- From: Beijing, China
- Registered: 2008-05-22
- Posts: 44
suggestion: all variable names should be lower case
it’s very difficult to remember the variable name cases, I think txp should use lower case for all variable names, html tags, and database fields, it will save lots of work in developping plugins and programming mods.
for example:
function populateArticleData($rs) {
extract($rs);
trace_add(“[“.gTxt(‘Article’).” $ID]”);
$out[‘thisid’] = $ID;
$out[‘posted’] = $uPosted;
$out[‘modified’] = $LastMod;
$out[‘annotate’] = $Annotate;
$out[‘comments_invite’] = $AnnotateInvite;
$out[‘authorid’] = $AuthorID;
$out[‘title’] = $Title;
$out[‘url_title’] = $url_title;
$out[‘category1’] = $Category1;
$out[‘category2’] = $Category2;
$out[‘section’] = $Section;
$out[‘keywords’] = $Keywords;
$out[‘article_image’] = $Image;
$out[‘comments_count’] = $comments_count;
$out[‘body’] = $Body_html;
$out[‘excerpt’] = $Excerpt_html;
$out[‘override_form’] = $override_form;
$out[‘status’] = $Status;
$custom = getCustomFields();
if ($custom) {
foreach ($custom as $i => $name)
$out[$name] = $rs[‘custom_’ . $i];
}
global $thisarticle;
$thisarticle = $out;
}
we can rewrite it as:
function populateArticleData($rs)
{
global $thisarticle;
trace_add(“[“.gTxt(‘Article’).” $ID]”);
$thisarticle = array_filter($rs);
}
or we can just get rid of function populateArticleData.
Last edited by Siguo (2008-07-23 08:14:05)
Offline
Re: suggestion: all variable names should be lower case
youmeanvariableslikethis?
Offline
#3 2008-07-23 08:15:33
- Siguo
- Member
- From: Beijing, China
- Registered: 2008-05-22
- Posts: 44
Re: suggestion: all variable names should be lower case
i_mean_variables_like_this
Last edited by Siguo (2008-07-23 08:18:51)
Offline
Re: suggestion: all variable names should be lower case
Ah. I agree with you for db fields (and their extracted variables), but for temporary, non-tag or database related variables, camelCase is standard (see PEAR style guide).
Renaming the columns will break a number of plugins though. You’ll eventually get used to the inconsistent naming with describe tableName
:).
Offline
#5 2008-07-23 08:55:48
- Siguo
- Member
- From: Beijing, China
- Registered: 2008-05-22
- Posts: 44
Re: suggestion: all variable names should be lower case
thanks jm, I agree with you.
Offline