I am a totally noob at CakePHP and have been dealing with this site update from traditional php to CakePHP. In the old website there was a folder for javascript and in there, there was a file called paging.js, then, at then end of where i was doing the table loops and stuff you would add this
echo '<div id="pageNavPosition"></div>
<div> </div>';
echo "<script type='text/javascript'><!--
var pagerAdmin = new PagerAdmin('results', 5);
pagerAdmin.init();
pagerAdmin.showPageNav('pagerAdmin', 'pageNavPosition');
pagerAdmin.showPage(1);
//--></script>";
}
In that website works perfectly, it shows only 5 records and with pagination. But now here in cake PHP I have thi code in my view but its not picking up that portion of code
<?php
echo '<div><h3>Admin - Update Data</h3><p>To update data click on name</p></div>';
print("<table id='results'><tr><th>ID</th><th>Image</th><th>Name</th><th>Price</th><th>Description</th></tr>");
$i =0;
foreach ($dishes as $key => $dish):
print("<tr>");
print("<td width='20px'>");
echo '<p style="font-size:14px; color:blue; padding:0;">'.$dishes[$i]['Dish']['id'].'</p>';
echo '<input type="hidden" name="'.$dishes[$i]['Dish']['dish_name'].'" value="'.$dishes[$i]['Dish']['id'].'" id="DishDishId" />';
print("</td>");
print("<td width='10px'>");
print("<img class='custom_rate' alt='' src='/myweb/img/".$dishes[$i]['Dish']['dish_image']."' />");
print("</td>");
print("<td width='100px'>");
print("<a href='index.php?form_type=admin_manager&id=".$dishes[$i]['Dish']['id']."'>".$dishes[$i]['Dish']['dish_name']."</a> ");
print("</td>");
print("<td width='100px'>");
print($dishes[$i]['Dish']['dish_price']);
print("</td>");
print("<td width='100px'>");
print($dishes[$i]['Dish']['dish_disc']);
print("</td>");
print("</tr>");
$i++;
endforeach;
print("</table>");
if($i> 5)
{
echo '<div id="pageNavPosition"></div>
<div> </div>';
echo "<script type='text/javascript'>" ;
echo "var pagerAdmin = new PagerAdmin('results', 5);";
echo 'pagerAdmin.init();';
echo "pagerAdmin.showPageNav('pagerAdmin', 'pageNavPosition');";
echo 'pagerAdmin.showPage(1);';
echo '</script>";';
}
?>
Any idea how i can make this work again? .Any help would be much appreciated.
Thanks
For anyone who runs into this issue, you just need to create a separate .js file and place it in the webroot/js folder with your js code. Then reference it as follows