The following code will allow you to create 2 objects of different classes at the same time a customer registers, to allow the template to work you will need to create 2 classes each with a field named 'WebUserID'. Your registration page must be dynamic (php).
Code: Alles auswählen
<?php // Start the web user session ?>
<we:sessionStart />
<?php // Save the web user on sign-up ?>
<we:saveRegisteredUser />
<?php // If the sign-up was successful execute the following code ?>
<we:ifRegisteredUser>
<?php // Create a condition to compare the web users ID with a field in the database object ?>
<we:condition name="condition">
<we:conditionAdd field="WebUserID" compare="=" var="ID" type="sessionfield" />
</we:condition>
<?php // Check to see if a database object already exists for the web user ?>
<we:listview type="object" name="Profile1" rows="1" classid="16" condition="\$condition">
<we:ifNotFound>
<?php // If not found create the database object ?>
<we:write type="object" formname="signup" publish="true" classid="16" userid="WebUserID" />
</we:ifNotFound>
</we:listview>
<?php // Check to see if a database object already exists for the web user ?>
<we:listview type="object" name="Profile2" rows="1" classid="17" condition="\$condition">
<we:ifNotFound>
<?php // If not found create the database object ?>
<we:write type="object" formname="signup" publish="true" classid="17" userid="WebUserID" />
</we:ifNotFound>
</we:listview>
</we:ifRegisteredUser>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<we:title></we:title>
<we:description/>
<we:keywords/>
<we:charset defined="UTF-8">UTF-8</we:charset>
<style type="text/css">
body { font-family: sans-serif; }
</style>
</head>
<body>
<we:ifNotRegisteredUser>
<?php // Registration form ?>
<we:form type="object" id="self" name="signup" method="post" classid="16" enctype="multipart/form-data">
<we:sessionField type="hidden" name="ID" />
<p><label for="Username">User name:</label><br />
<we:sessionField name="Username" id="Username" type="textinput" xml="true" /></p>
<p><label for="Password">Password:</label><br />
<we:sessionField name="Password" id="Password" type="password" xml="true" /></p>
<p><input type="submit" value="Sign-up" /></p>
</we:form>
<hr />
<?php // Login form ?>
<we:form name="login" id="self" method="post" xml="true">
<we:ifLoginFailed>
<p><strong>The login has failed. Please try again.</strong></p>
</we:ifLoginFailed>
<p><label for="Username">User name:</label><br />
<we:sessionField name="Username" id="Username" type="textinput" xml="true" /></p>
<p><label for="Password">Password:</label><br />
<we:sessionField name="Password" id="Password" type="password" xml="true" /></p>
<p><input type="submit" value="Login" /></p>
</we:form>
<hr />
</we:ifNotRegisteredUser>
<we:ifRegisteredUser>
<p><we:sessionField type="print" name="Username" /> |
<we:sessionField type="print" name="ID" /> |
<we:sessionLogout id="self">Logout</we:sessionLogout></p>
<?php // Test to see if the database object has been created ?>
<we:listview type="object" name="Profile1" rows="1" classid="16" condition="\$condition">
<we:ifNotFound>
<p>Object 1 not found</p>
<we:else />
<p>Object 1 found</p>
</we:ifNotFound>
</we:listview>
<?php // Test to see if the database object has been created ?>
<we:listview type="object" name="Profile1" rows="1" classid="17" condition="\$condition">
<we:ifNotFound>
<p>Object 2 not found</p>
<we:else />
<p>Object 2 found</p>
</we:ifNotFound>
</we:listview>
</we:ifRegisteredUser>
</body>
</html>
Michael.