| | | |  |  | |  |
27.04.2007, 13:05
|
#1 (permalink)
| | Baby Mamber
Join Date: Apr 2007
Posts: 3
| how to add ordering tool in to a customized component hi,
joomla newbie here.
i got this tutorial called daily message from
w3.jlleblanc.com/content/view/9/54/
and the way it works, its exactly what i needed for my thesis project. unfortunately, it doesnt have a ordering/reorder tool so with that, i need to add it. since i cannot read php codes that well yet, i just took all related codes from other components like com_weblinks but i dont know if i was able to do it right.
the first page (view page) dont have any errors, but when i click on the "new" button, this is the error message that i am getting Code: Warning: Missing argument 3 for HTML_BrandName::edit() in /var/www/html/memoryworld/administrator/components/com_brandname/admin.brandname.html.php on line 6
Warning: Missing argument 4 for HTML_BrandName::edit() in /var/www/html/memoryworld/administrator/components/com_brandname/admin.brandname.html.php on line 6
Brand Name: <br /><b>Notice</b>: Trying to get property of non-object in <b>/var/www/html/memoryworld/administrator/components/com_brandname/admin.brandname.html.php</b> on line <b>14</b><br />
Ordering:
Fatal error: Cannot use object of type BrandName as array in /var/www/html/memoryworld/administrator/components/com_brandname/admin.brandname.html.php on line 19 i have 2 page, admin.brandname.html.php and admin.brandname.php
hope you could help me with this, because i really really need to it fix real soon.
thank you very much and i hope that you guys can help me with this. sorry too if i am asking too much. but i think this is the only place where i can get help. |
| |
27.04.2007, 13:08
|
#2 (permalink)
| | Baby Mamber
Join Date: Apr 2007
Posts: 3
| Re: how to add ordering tool in to a customized component this is the code for admin.brandname.html.php Code: <?
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
class HTML_BrandName{
function edit( $option, &$pageNav, &$lists, &$row) {
?>
<form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>Brand Name: </td>
<td><input type="text" size="50" maxsize="100" name="bname" value="<?php echo $row->bname; ?>" /></td>
</tr>
<tr>
<td>Ordering: </td>
<td><?php echo $lists['ordering']; ?></td>
</tr>
<tr>
<td>Published: </td>
<td><? echo mosHTML::yesnoSelectList( "published", "", $row->published ); ?></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
</form>
<? }
function listConfiguration($option, &$rows)
{
?>
<form action="index2.php" method="post" name="adminForm">
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
<?
$row = $rows[0];
?>
<tr><td>Bold</td><td><? echo mosHTML::yesnoSelectList( "bold", "", $row->bold ); ?></td></tr>
<tr><td>Italic</td><td><? echo mosHTML::yesnoSelectList( "italic", "", $row->italic ); ?></td></tr>
<tr><td>Underline</td><td><? echo mosHTML::yesnoSelectList( "underline", "", $row->underline ); ?></td></tr>
<tr><td>Show Date</td><td><? echo mosHTML::yesnoSelectList( "showdate", "", $row->showdate ); ?></td></tr>
</table>
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="configid" value=<? echo $row->configid ?> />
<input type="hidden" name="act" value="configure" />
</form>
<?
}
function listMessages( $option, &$pageNav, &$rows) {
?>
<form action="index2.php" method="post" name="adminForm">
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
<tr>
<th width="8" align="center" class="title"> </th>
<th width="21" align="center" class="title">#</th>
<th width="20" align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
<th width="28" align="center" class="title"> </th>
<th width="245" class="title">Brand Name</th>
<th width="217" align="center" class="title"> </th>
<th width="97" align="center">Published</th>
<th colspan="2">Reorder</th>
<th width="40" align="center">ID</th>
<th width="84"> </th>
</tr>
<?php
$k = 0;
for ($i=0, $n=count( $rows ); $i < $n; $i++) {
$row = &$rows[$i];
if ($row->ordering !=NULL) {
$img = 'tick.png' ;
}
else
{ $img = 'publish_x.png';
//$task = _EC_INCLUDE . _EC_TASK_ARTICLE;;
}
?>
<tr class="<?php echo "row$k"; ?>">
<td width="8" align="center"> </td>
<td width="21" align="center"><?=$i+$pageNav->limitstart+1;?></td>
<td width="20" align="center"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
<td width="28" align="center"> </td>
<td width="245"><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->bname; ?></a></td>
<td width="217" align="center"> </td>
<td width="97" align="center"><?php
if ($row->published == "1") {
echo "<a href=\"javascript: void(0);\" onClick=\"return listItemTask('cb$i','unpublish')\"><img src=\"images/publish_g.png\" border=\"0\" /></a>";
} else {
echo "<a href=\"javascript: void(0);\" onClick=\"return listItemTask('cb$i','publish')\"><img src=\"images/publish_x.png\" border=\"0\" /></a>";
}
?></td>
<td width="78" align="center"><?php
if ($i > 0) {
?>
<a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','orderup')"><img src="images/uparrow.png" border="0" /></a>
<?php
} // if
?></td>
<td width="76" align="center"><?php
if ($i < count($rows)-1) {
?>
<a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','orderdown')"><img src="images/downarrow.png" border="0" /></a>
<?php
} // if
?></td>
<td width="40" align="center"><?php echo $row->id; ?></td>
<td width="84" align="center"> </td>
<?php $k = 1 - $k; ?>
</tr>
<?php }
?>
</table>
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
</form>
<? }
}
?> |
| |
27.04.2007, 13:10
|
#3 (permalink)
| | Baby Mamber
Join Date: Apr 2007
Posts: 3
| Re: how to add ordering tool in to a customized component and this is the code for the admin.brandname.php Code: <?php
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');
// ensure user has access to this function
if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' )
| $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_brandname' ))) {
mosRedirect( 'index2.php', _NOT_AUTH );
}
require_once( $mainframe->getPath( 'admin_html' ) );
require_once( $mainframe->getPath( 'class' ) );
$id = mosGetParam( $_REQUEST, 'cid', array(0) );
if (!is_array( $id )) {
$id = array(0);
}
switch($act)
{
case "configure":
switch($task) {
case "save":
saveConfiguration($option);
break;
default:
listConfiguration($option);
break;
}
break;
default:
switch ($task) {
case "save" :
save($option);
break;
case "edit" :
edit( $option, $id );
break;
case "new" :
$id = '';
edit( $option, $id);
break;
case "delete" :
del($option, $id);
break;
case "publish" :
publishMessage($option, '1', $id);
break;
case "unpublish" :
publishMessage($option, '0', $id);
break;
case 'orderup':
orderMessage( $option,$cid, -1 );
break;
case 'orderdown':
orderMessage( $option,$cid, 1 );
break;
case "listMessages" :
default:
listMessages($option);
break;
}
break;
}
function saveConfiguration($option) {
global $database;
$row = new BrandNameConf($database);
// bind it to the table
if (!$row -> bind($_POST)) {
echo "<script> alert('"
.$row -> getError()
."'); window.history.go(-1); </script>\n";
exit();
}
// store it in the db
if (!$row -> store()) {
echo "<script> alert('"
.$row -> getError()
."'); window.history.go(-1); </script>\n";
exit();
}
mosRedirect("index2.php?option=$option&act=configure", "Configuration Saved");
}
function listConfiguration($option)
{
global $database;
$database->setQuery("SELECT * FROM #__brandname_conf" );
$rows = $database -> loadObjectList();
if ($database -> getErrorNum()) {
echo $database -> stderr();
return false;
}
HTML_BrandName::listConfiguration($option, $rows);
}
function publishMessage( $option, $publish=1 ,$cid )
{
global $database, $my;
if (!is_array( $cid ) || count( $cid ) < 1) {
$action = $publish ? 'publish' : 'unpublish';
echo "<script> alert('Select an item to $action'); window.history.go(-1);</script>\n";
exit;
}
$cids = implode( ',', $cid );
$database->setQuery( "UPDATE #__brandname SET published='$publish'"
. "\nWHERE id IN ($cids)"
// AND (checked_out=0 OR (checked_out='$my->id')
);
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
mosRedirect( "index2.php?option=$option" );
}
function save($option) {
global $database;
$row = new BrandName($database);
// bind it to the table
if (!$row -> bind($_POST)) {
echo "<script> alert('"
.$row -> getError()
."'); window.history.go(-1); </script>\n";
exit();
}
// store it in the db
if (!$row -> store()) {
echo "<script> alert('"
.$row -> getError()
."'); window.history.go(-1); </script>\n";
exit();
}
mosRedirect("index2.php?option=$option", "Saved");
}
function del($option, $cid) {
global $database;
if (!is_array($cid) || count($cid) < 1) {
echo "<script> alert('Select an item to delete'); window.history.go(-1);</script>\n";
exit();
}
if (count($cid))
{
$ids = implode(',', $cid);
$database->setQuery("DELETE FROM #__brandname \nWHERE id IN ($ids)");
}
if (!$database->query()) {
echo "<script> alert('"
.$database -> getErrorMsg()
."'); window.history.go(-1); </script>\n";
}
mosRedirect("index2.php?option=$option");
}
function edit($option, $id) {
global $database, $my, $mosConfig_absolute_path;
$row = new BrandName( $database );
// load the row from the db table
$row->load( (int)$id );
if($id){
$row -> load($id[0]);
} else {
// initialise new record
$row->published = 1;
$row->order = 0;
}
// build the html select list for ordering
$query = "SELECT ordering AS value"
. "\n FROM #__brandname"
. "\n WHERE id = " . (int) $row->id
. "\n ORDER BY ordering"
;
$lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $id, $query, 1 );
HTML_BrandName::edit($option, $row);
}
function listMessages($option) {
global $database, $mainframe;
$limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 );
$limitstart = $mainframe->getUserStateFromRequest( "viewban{$option}limitstart", 'limitstart', 0 );
// get the total number of records
$database->setQuery( "SELECT count(*) FROM #__brandname");
$total = $database->loadResult();
echo $database->getErrorMsg();
require_once("includes/pageNavigation.php");
$pageNav = new mosPageNav( $total, $limitstart, $limit );
$database->setQuery( "SELECT id, ordering, bname "
. "\nFROM #__brandname"
. "\nORDER BY ordering ASC"
. "\nLIMIT $limitstart, $limit"
);
$rows = $database->loadObjectList();
if(!$result = $database->query()) {
echo $database->stderr();
return false;
}
HTML_BrandName::listMessages($option, $pageNav, $rows);
}
/**
* Moves the order of a record
* @param integer The increment to reorder by
*/
function orderMessage($option, $uid, $inc ) {
global $database;
mylog($uid[0]);
$row = new BrandName( $database );
$row->load( $uid[0] );
mylog($row->ordering);
$row->move( $inc, "" );
mosRedirect( "index2.php?option=$option");
}
?> |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT +2. The time now is 01:19. | | | |