Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
So now that my site is looking the way I want it the contact page doesn't match an overall aesthetic I have going. All my about, info, services pages are now publisher driven stages that have a constantly moving image gallery at the top as a graphic. Then the block is written into the publisher and some custom css for each page for responsive layouts. see http://ce4.studiothomas.org/galleries/about/.
What I would like to do is use the same publisher driven template but add a hook to put the contact form onto the page. I've got the hook setup and placed correctly. see http://ce4.studiothomas.org/pages/contact/
I cant seem to figure out how much code to steal from the plain contact page to add to my phplugins. There is a lot going on in there. Its difficult to work on as well since of anything at all is wrong it just does nothing. Any help would be greatly appreciated. I think it could be pretty nice if the contact from could be a phplugin to put wherever you want using the hooks to put it there.
Offline
Hi Evan, the contact-us code is not amenable to being moved into phplugins. The code is already quite convoluted so that it can work with the Pages web module and TTG BE yet operate as a single PHP page, and it will likely break if inserted into a function.
Your best approach would be to either try add the Publisher-managed portion of pages/contact/ into the contact.php page, or copy and paste chunks of contact.php into the file you have at pages/contact/.
If doing the latter, you'd want to copy all the lines through to line 80 of contact.php and the 40 or so lines from
<?php if (isset($_GET['a']) && $_GET['a'] == 'success') {
to
<?php } ?>
The second set of lines forms the success message and form.
Offline
So far no go on hooking the contact form into another page. I cant even get it to properly get through those first 80 lines. It stops at the $message array and I've no idea why.
see http://ce4.studiothomas.org/pages/contact/
// TARGET SPECIFIC PAGE IN TTG CE4 PAGES
function ttg_block_bottom( $style, $path ) {
/* Contact Form
==================== */
if (G_SLUG == 'contact') {
echo '
<p>loading ttg contact php</p>
';
define('APPLICATION', 'admin');
echo '<p>1</p> ';
require_once('lib.php');
echo '<p>2</p> ';
$fields = array(
array(
'name' => 'NAME',
'param' => 'name',
'type' => 'input-text',
'required' => true
),
array(
'name' => 'EMAIL',
'param' => 'email',
'type' => 'input-text',
'required' => true,
'format' => 'email'
),
array(
'name' => 'Address',
'param' => 'address',
'type' => 'input-text',
'required' => false
),
array(
'name' => 'TELEPHONE',
'param' => 'custom1',
'type' => 'input-text',
'required' => false
),
array(
'name' => 'MESSAGE',
'param' => 'message',
'type' => 'textarea',
'required' => true
),
);
echo '<p>3</p> ';
$messages = array(
ContactDelegate::$MESSAGE_ENTER_REQUIRED_FIELDS => 'Please complete the required fields.',
ContactDelegate::$MESSAGE_VALID_EMAIL_REQUIRED => 'Please enter a valid email address.',
ContactDelegate::$MESSAGE_EMAIL_ERROR => 'The message could not be sent. Please contact the photographer by phone or direct email.',
ContactDelegate::$MESSAGE_SUCCESS => 'Thanks for your message. Someone will reply to you soon.'
);
echo '<p>4</p> ';
if (FormHelper::submitted()) {
$form = array();
foreach ($fields as $field) {
if (isset($_POST[$field['param']])) {
$form[$field['param']] = trim($_POST[$field['param']]);
}
}
$form['fromPage'] = URLHelper::currentPageURL();
$delegate = new ContactDelegate();
$result = $delegate->contact($form, $fields);
if ($result['status'] == 'success' || (isset($result['message']) && $result['message'] == ContactDelegate::$MESSAGE_SPAM)) {
header('Location: '.$_SERVER['REQUEST_URI'].'?a=success');
}
} else {
$result = array();
$form = array();
}
echo '<p>5</p> ';
function formValue($form, $param){
return isset($form[$param]) ? $form[$param] : '';
}
echo '<p>6</p> ';
function message($code){
global $messages;
return isset($messages[$code]) ? $messages[$code] : '';
}
echo '
<h1 style="text-align:center">ttg Contact php loaded!</h1>
';
return false; // Place ttg contact into publisher contact page
echo '<p>end php section</p> ';
}
Offline
I wonder if the lib.php file isn't doing what it needs to do. That file is the magic sauce, that finds where ttg-be is and initialises the application. I'm assuming that it's there under /pages/contact/? (it should have failed at 1. if it wasn't).
Can you provide me with FTP access via the Email link under my name, so that I can try and work it out?
Offline
Thanks for the login. I've fixed this for you, with details in my PM reply.
Offline