Layout creation

Hi,

I have written code to create a layout programmatically when a new user is being created.
I’m able to see the layout details in the layout table but when I login in the corresponding user, I can’t see the layout. The layout is not appearing in the layout grid. Kindly help me with this issue. Below is our code:

$SQL = 'INSERT INTO user (UserName, UserPassword, usertypeid, email, homepage)
                     VALUES (:userName, :password, :userTypeId, :email, :homePage)';

            $insertSth = $dbh->prepare($SQL);
            $insertSth->execute(array(
                'userName' => $this->userName,
                'password' => $password,
                'userTypeId' => $this->userTypeId,
                'email' => $this->email,
                'homePage' => $this->homePage
            ));
			 // Get the ID of the record we just inserted
            $this->userId = $dbh->lastInsertId();
			
			// Creating layout for each user
			$layout = $this->userName.'layout';
			$xml = '<?xml version="1.0"?>
					<layout width="1920" height="1080" resolutionid="9" bgcolor="#000000" schemaVersion="2">
					<region id="18198555971bca45bd" userId="8" width="312" height="283" top="847" left="0">
					<media id="45" type="image" render="native" duration="0" lkid="56" userId="8" schemaVersion="1">                            
					<options>
					<uri>45.png</uri>
					</options>
					<raw/>
					</media>
					</region>					
					<region id="29568555ae4b39ef8d" userId="8" width="1920" height="881" top="0" left="0"/></layout>';
			$userID = $this->userId;
			
			$SQL = 'INSERT INTO layout (layout, xml, userID, createdDT,modifiedDT)
                     VALUES (:layout, :xml, :userID, now(), now())';
			$insertSth = $dbh->prepare($SQL);
            $insertSth->execute(array(
                'layout' => $layout,
                'xml' => $xml,
                'userID' => $userID
                
            ));

Hi,

It is done. :smile: Thank you.

You should really be using the API for this sort of work - or even calling the layout import routine (so you can store you layout as a ZIP file)