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.

eZ debug

Timing: Jan 31 2025 06:25:55
Script start
Timing: Jan 31 2025 06:25:55
Module start 'layout'
Timing: Jan 31 2025 06:25:55
Module start 'content'
Timing: Jan 31 2025 06:25:55
Module end 'content'
Timing: Jan 31 2025 06:25:55
Script end

Main resources:

Total runtime0.0150 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.2656151.2266
Module start 'layout' 0.00530.0025 739.492236.6797
Module start 'content' 0.00780.0057 776.171998.2188
Module end 'content' 0.01350.0015 874.390637.9922
Script end 0.0150  912.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.7988140.0002
Check MTime0.00127.7439140.0001
Mysql Total
Database connection0.00085.638710.0008
Mysqli_queries0.002617.187230.0009
Looping result0.00000.091910.0000
Template Total0.00117.510.0011
Template load0.00095.805110.0009
Template processing0.00021.636010.0002
Override
Cache load0.00063.936110.0006
General
dbfile0.001610.495980.0002
String conversion0.00000.060240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs