Members: 16,996
Threads: 38,867
Posts: 159,477
Online: 39

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Development > Component Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 27.04.2007, 13:05   #1 (permalink)
Baby Mamber
 
Join Date: Apr 2007
Posts: 3
pixeltrace is on a distinguished road
Default 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.
pixeltrace is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 27.04.2007, 13:08   #2 (permalink)
Baby Mamber
 
Join Date: Apr 2007
Posts: 3
pixeltrace is on a distinguished road
Default 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">&nbsp;&nbsp;</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">&nbsp;</th>
<th width="245" class="title">Brand Name</th>
<th width="217" align="center" class="title">&nbsp;</th>
<th width="97" align="center">Published</th>
<th colspan="2">Reorder</th>
<th width="40" align="center">ID</th>
<th width="84">&nbsp;</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">&nbsp;&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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> 


<? } 


}

?>
pixeltrace is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 27.04.2007, 13:10   #3 (permalink)
Baby Mamber
 
Join Date: Apr 2007
Posts: 3
pixeltrace is on a distinguished road
Default 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");
}


?>
pixeltrace is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ReMOSitory Component: How do I add to menu? smallbiz Mambo 4.5.1 'How Do I' Questions 2 07.07.2005 09:14
How to add the editor in a new component avielk Mambo 4.5.1 'How Do I' Questions 4 05.03.2005 18:19
Please help my hosting runs out soon! The Devil Mambo 4.5 Bugs 11 03.09.2004 20:28
Can't add contact component to menu Heavy-Sixer Mambo 4.5 General Talk 0 13.05.2004 16:40
Contact component won't add to menu Heavy-Sixer Mambo 4.5 Bugs 0 13.05.2004 01:09


All times are GMT +2. The time now is 04:39.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.