PHP store values from a selection (multiple)

Author Message

Felix Laate

Monday 20 March 2006 4:36:12 am

Hi all,

I'm trying to store values from a selection (multiple). This is what I try:

$utvalgString = implode( '-', $utvalg );
$contentObjectAttributes[2]->setAttribute( 'data_text', $utvalgString );
$contentObjectAttributes[2]->store();

But, it doesn't work.

Any help is helpful!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Xavier Dutoit

Monday 20 March 2006 6:52:43 am

Have a look at the datatype original php code. Each datatype stores its content the way it wants (and might be rather creative).

The best source of information is the code. Good luck.

X+

http://www.sydesy.com

Kristof Coomans

Monday 20 March 2006 11:54:24 am

Hi Felix

Can you post the full code? The code you mentioned should work fine for eZSelection, so I think there's something wrong somewhere else.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Felix Laate

Monday 20 March 2006 12:37:47 pm

Hi guys,

thank you for answering..

Here the full code:

include_once( 'lib/ezutils/classes/ezhttptool.php' );
include_once( 'kernel/common/template.php' );
include_once( 'kernel/classes/ezcontentobject.php' );
include_once( "kernel/classes/ezcontentobjecttreenode.php" );
include_once( 'lib/ezutils/classes/ezini.php' );
include_once( 'lib/ezutils/classes/ezmail.php' );
include_once( 'lib/ezutils/classes/ezmailtransport.php' );

$http =& eZHTTPTool::instance();
$tpl =& templateInit();
$ini =& eZINI::instance( 'notifyme.ini.php' );

$Module =& $Params["Module"];

$navn = $http->postVariable( 'navn' );
$epost = $http->postVariable( 'epost' );
$utvalg = $http->postVariable( 'utvalg' );

if ( $Module->isCurrentAction( 'Create' ) ) 
{
	$parentNodeID = 224;
	$params = array( 'ClassFilterType' => 'include',  
					 'ClassFilterArray' => array( 'abonent_epost' ),
					 'AttributeFilter' => array( array(  'abonent_epost/epost', '=', $epost ) ) );
	
	$objects =& eZContentObjectTreeNode::subtree( $params, $parentNodeID ); 
	
	if (count($objects) == 1) 
	{
		// Skriv til logg
		$logtext = 'ABO FINNES FRA FØR';	
		WriteToLog($logtext);
	}
	else
	{
	
		$contentClassId = 40; 
		$class =& eZContentClass::fetch( $contentClassId );

		$userID = 1; 

		$contentObject =& $class->instantiate( $userID, 1 );

		$name = $sender; 
		
		$contentObject->setAttribute( 'name', $name );

		//$parentNodeID = 224; // choose where to put the user

		$nodeAssignment =& eZNodeAssignment::create( array('contentobject_id' => $contentObject->attribute( 'id' ),	'contentobject_version' => $contentObject->attribute( 'current_version' ), 'parent_node' => $parentNodeID, 'sort_field' => 2, 'sort_order' => 0, 'is_main' => 1 ));
		$nodeAssignment->store();

		$version =& $contentObject->version( 1 );

		$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
		$version->store();


		$contentObjectID = $contentObject->attribute( 'id' );
		$contentObjectAttributes =& $version->contentObjectAttributes();

		$contentObjectAttributes[0]->setAttribute( 'data_text', $navn );
		$contentObjectAttributes[0]->store();

		$contentObjectAttributes[1]->setAttribute( 'data_text', $epost );
		$contentObjectAttributes[1]->store();
$utvalgString = implode( '-', $utvalg );

		$contentObjectAttributes[2]->setAttribute( 'data_text', $utvalgString );
		$contentObjectAttributes[2]->store();
$contentObject->store();
		

		// Publish it
		include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
		$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,'version' => 1 ) ); 

I really appreciate you people helping me out. After 3 years of developing ez sites I'm finally able to enjoy making extensions and I'm loving it..

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Kristof Coomans

Monday 20 March 2006 11:02:50 pm

There doesn't seem to be anything wrong with the code you provided. It works here.

I think you're not posting the right values for the multiple selection attribute. You'll have to post the ID's of the options instead of the actual values. See also these topics about eZSelection: http://ez.no/community/forum/developer/image_link_question and http://ez.no/community/forum/setup_design/filter_content_passing_values_from_url

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.