|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
MrVon Smarty Rookie
Joined: 08 Jul 2011 Posts: 15
|
Posted: Thu Apr 18, 2013 10:50 pm Post subject: What to improve in this code? |
|
|
Is this code from method within class that my developer used. Is that good practice?
Especially including smarty object inside every function of the site to assign values from withing function.
1. I think its nonsense to do so because function in this sense is not even function, its like having procedural code inside **display_hotel.php** it has no other use it cannot be used for any other place on website.
2. Pagination could have been done outside somehow or am i wrong?
Code: | function display_hotel () {
global $objSmarty, $objPage;
if (isset($_POST['page']) && $_POST['page'] != 1 && $_POST['page'] != "") {
$i = ($_POST['page'] * $this->Limit) - $this->Limit + 1;
} else {
$i = 1;
}
$objSmarty->assign("i", $i);
$SelQuery = "SELECT * FROM tbl_managehotel WHERE hotel_id IS NOT NULL ";
$listing_split = new MsplitPageResults($SelQuery, $this->Limit);
if (($listing_split->number_of_rows > 0)) {
$objSmarty->assign("LinkPage", $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_RESULT));
$objSmarty->assign("PerPageNavigation", TEXT_RESULT_PAGE1 . ' ' . $listing_split->display_links($this->Limit, get_all_get_params(array('page', 'info', 'x', 'y'))));
}
if ($listing_split->number_of_rows > 0) {
$rows = 0;
$Res_Tickets = $this->ExecuteQuery($listing_split->sql_query, "select");
}
//print_r($Res_Tickets);
if (!empty($Res_Tickets) && is_array($Res_Tickets)) {
$objSmarty->assign("levels", $Res_Tickets);
}
$listing_count = $this->ExecuteQuery($SelQuery, "select");
$objSmarty->assign("listing_count", $listing_count);
$objSmarty->assign("Country_List", $Country_List);
$objSmarty->assign("objArray", $objArray);
} |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Apr 22, 2013 12:50 pm Post subject: |
|
|
You should not be concerned with "display_"ing anything in your PHP code.
Solution - leave the function out, just write your PHP code, and let the Smarty care for "display_" part. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|