私は自分のサイト(Silverstripeを使用しています)にスーパーフィッシュメニューを使用しています。ここでスーパーフィッシュメニューの例を参照してください。
サイトはすべて正常に機能していますが、連絡先ページでは、$ contactUsFormを入力するたびに、連絡先ページが最初に連絡先フォームを読み込もうとし、スーパーフィッシュメニューの下矢印が数秒間消え、メニューが左。次に矢印が表示され、フォームが読み込まれた後、メニューは再び通常の位置に移動します。
1ページおきに問題ありません。誰かが私にこれが起こっている理由とそれを修正する方法についていくつかのヒントを教えてもらえますか?ありがとう。
これが私のContactPage.phpです。必要に応じて、ここにコードを追加できます。
static $db = array(
"Phone" => "Varchar",
"Email" => "Varchar",
"Address" => "Text",
"Thanks" => "Text",
"Long" => "Int",
"Lat" => "Int",
//added for google map 04012012
"EmbedCode" => "HTMLText"
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.ContactDetails', new TextField('Phone'));
$fields->addFieldToTab('Root.Content.ContactDetails', new TextField('Email'));
$fields->addFieldToTab('Root.Content.ContactDetails', new TextareaField('Address','Address',8,3));
$fields->addFieldToTab('Root.Content.ContactDetails', new TextareaField('Thanks','Thank You Message',8,3));
#$fields->addFieldToTab('Root.Content.Main', new TextField('Long'));
#$fields->addFieldToTab('Root.Content.Main', new TextField('Lat'));
//added for google map 04012012
$fields->addFieldToTab('Root.Content.ContactDetails', new TextareaField('EmbedCode', 'Embed Code'));
return $fields;
}
function HasSentContact() {
return (isset( $_GET['sent'] ) ) ? true : false;
}
function onBeforeWrite() {
$this->EmbedCode = str_replace("></iframe>", "> </iframe>", $this->EmbedCode);
parent::onBeforeWrite();
}
}
class ContactPage_Controller extends Page_Controller {
public function init() {
parent::init();
Requirements::themedCSS('Contact');
}
function contactUsForm() {
$recaptchaField = new RecaptchaField('MyCaptcha');
$recaptchaField->jsOptions = array('theme' => 'white'); // optional it changes the look added 07122011
// Create fields
$fields = new FieldSet(
new TextField('Name'),
new TextField('Surname'),
new TextField('Email', 'Email Address'),
new TextField('Phone', 'Phone Number'),
new TextareaField('Message', 'Enquiry'),
new LabelField('MyCaptcha', 'Please enter the characters below'),
$recaptchaField
//new PhpCaptchaField(),
//new HeaderField ("Please Enter What You See Here, it's not case sensitive", "6")
);
// Create actions
$actions = new FieldSet(
new FormAction('doContactUs', 'Submit')
);
//valididate fields
$validator = new RequiredFields('Name', 'Email', 'Message');
return new Form($this, 'contactUsForm', $fields, $actions, $validator);
}
function doContactUs($data, $form) {
$from = $data['Email'];
$to = $this->Email;
$subject = 'Contact Us Form';
$body = $data['Name'].' '.$data['Surname'].'\n'.$data['Email'].'\n'.$data['Phone'].'\n\n'.$data['Message'];
$email = new Email($from, $to, $subject, $body);
$email->sendPlain();
//Director::redirectBack();
Director::redirect($this->Link().'?sent=1');
}
}
?>
ContactPage.ss:
<div id="intro">
<h1 id="h1_home">$Title</h1>
<% if HasSentContact %>
<div id="Form">
<h2>$Thanks</h2>
</div>
<% else %>
$Content
<div id="Form">
$contactUsForm
</div>
<% end_if %>
<div id="Details">
<h3>GOOGLE MAP</h3>
<!--added 05012011, added divs-->
<div id="googlemap"> {$EmbedCode} </div>
<div id="contactinfo">
<h3>Contact Info</h3>
<table class="alignRight">
<tr>
<td class="width200 alignLeft">Phone</td>
<td>{$Phone}</td>
</tr>
<tr>
<td class="alignLeft">Email</td>
<td><a href="mailto:{$Email}">{$Email}</a></td>
</tr>
<tr>
<td class="alignLeft">Address</td>
<td>{$Address}</td>
</tr>
</table>
</div><!-- contactinfo -->
</div><!--Details-->
$Form
</div><!--intro-->