I want to improve my coding style, any suggestions??
Posted: Fri Mar 02, 2007 12:36 pm
Hello forums,
Here i am mentioning the style of my coding.
This is for the admin section,
Suppose i had any section(say portfolio in this case) which i had manage
ie
ie
and separate .tpl files for HTML section
ie
And i perform operations ie list | add | edit | delete in listSection.php
My listSection.php (say listPortfolio.php in this case)
addPortfolio.php:
editPortfolio.php:
(here i didnt mention the .tpl files to reduce bulkiness)
----------------------------------------------------------------------------------------------------------------
My this style seems easy to maintain but its time consuming and doesnt look pro type coding..
Is there any suggestion ie any style for managing sections with ease creating less file ??
Thanks in advance to all of you !!
Here i am mentioning the style of my coding.
This is for the admin section,
Suppose i had any section(say portfolio in this case) which i had manage
ie
For that I always make the four files for every sectionlist | add | edit | delete
ie
Code: Select all
listSection.php (for listing)
addSection.php (for add section)
editSection.php (for edit section)
deleteSection.php (for delete section)and separate .tpl files for HTML section
ie
Code: Select all
listSection.tpl
addSection.tpl
editSection.tplAnd i perform operations ie list | add | edit | delete in listSection.php
My listSection.php (say listPortfolio.php in this case)
Code: Select all
<?php
/********************************************************
* PORTFOLIO OPERATIONS
********************************************************/
/* DELETE */
if(isset($_GET['mode']) &&
$_GET['mode'] == "deletePortfolio" &&
isset($_GET['deleteID']))
{
$deleteID = $_GET['deleteID'];
$portfolioObj->delete($deleteID);
}
/* ADD */
if(isset($_POST['mode']) &&
$_POST['mode'] == "addPortfolio")
{
$portfolio_name = $_POST['portfolio_name'];
//print_r($_POST);
$portfolioObj->insert($portfolio_name);
}
/* EDIT */
if(isset($_POST['mode']) &&
$_POST['mode'] == "editPortfolio" &&
isset($_GET['editID']))
{
$editID = $_GET['editID'];
$portfolio_name = $_POST['portfolio_name'];
$portfolioObj->update($editID,$portfolio_name);
}
?>
<?PHP
/* FETCH ALL THE PORTFOLIOS */
$listPortfolio = $portfolioObj->selectAll();
//echo $listPortfolio[0];
//print_r($listPortfolio[1]);
if($listPortfolio[0] == 0)
{
$smarty->assign("error","No existing portfolio !!");
$smarty->display("errorDisplay.tpl");
$smarty->display("addPortfolio.tpl");
}
else
{
$listPortfolio = $listPortfolio[1];
$smarty->assign("listPortfolio",$listPortfolio);
$smarty->display("listPortfolio.tpl");
}
?>Code: Select all
<?php
$smarty->display("addPortfolio.tpl");
?>Code: Select all
<?php
/* FETCH THE REQUIRED PORTFOLIO */
if(isset($_GET['editID']))
{
$editID = $_GET['editID'];
$getPortfolio = $portfolioObj->selectOne($editID);
$smarty->assign("getPortfolio",$getPortfolio);
$smarty->display("editPortfolio.tpl");
}
else
{
$smarty->assign("error","Error Occurred");
$smarty->display("errorDisplay.tpl");
}
?>----------------------------------------------------------------------------------------------------------------
My this style seems easy to maintain but its time consuming and doesnt look pro type coding..
Is there any suggestion ie any style for managing sections with ease creating less file ??
Thanks in advance to all of you !!