Forums / Developer / PHP store values from a selection (multiple)

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

eZ debug

Timing: Jan 18 2025 19:25:24
Script start
Timing: Jan 18 2025 19:25:24
Module start 'content'
Timing: Jan 18 2025 19:25:24
Module end 'content'
Timing: Jan 18 2025 19:25:24
Script end

Main resources:

Total runtime0.1865 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0078 587.8516180.8125
Module start 'content' 0.00780.0066 768.6641101.9609
Module end 'content' 0.01440.1719 870.6250530.1250
Script end 0.1863  1,400.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00371.9949200.0002
Check MTime0.00140.7245200.0001
Mysql Total
Database connection0.00140.771810.0014
Mysqli_queries0.134672.16691410.0010
Looping result0.00180.98081390.0000
Template Total0.171491.910.1714
Template load0.00120.632310.0012
Template processing0.170291.297910.1702
Override
Cache load0.00070.393210.0007
Sytem overhead
Fetch class attribute can translate value0.00120.631810.0012
XML
Image XML parsing0.00040.235910.0004
General
dbfile0.00191.0259200.0001
String conversion0.00000.003830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

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

Time used to render debug report: 0.0002 secs