Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS 3.0 Global Contact Form


Go to End


5 Posts   2625 Views

Avatar
n0ne

Community Member, 18 Posts

12 September 2012 at 1:56pm

Hi, I'd like to know if how to make a 'quick contact' form in footer of every page (global form).

Avatar
sonet

Community Member, 33 Posts

12 September 2012 at 3:10pm

Follow this tutorial: www.ssbits.com/creating-a-simple-contact-form/

Instead of creating a ContactPage.php add the code to your Page.php and your footer template.

Avatar
mhdesign

Community Member, 216 Posts

17 July 2014 at 11:46am

This is just the sort of thing that I would like on my personal site but I'm having issues -- when I add form code to Page.php I can't rebuild DB. Don't think there's anything deprecated as it looks like fairly standard php expressions -- but then again I'm really a graphic designer, not a programmer per se.

Can somebody please advise:

1. What is the difference between 'private static' and simply 'static'

2. Has the expression 'static' become deprecated in SS3?

3. Do I need to 'thread' (concantenate) form code into code already on Page.php (below)

TIA

<?php
class Page extends SiteTree {

	private static $db = array('SidebarHTML' => 'HTMLText'
	);

	private static $has_one = array(
	);
function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields -> addFieldToTab("Root.Sidebar",new HTMLEditorField("SidebarHTML"));
		return $fields;
	}
	
	
	
}
class Page_Controller extends ContentController {

	/**
	 * An array of actions that can be accessed via a request. Each array element should be an action name, and the
	 * permissions or conditions required to allow the user to access it.
	 *
	 * <code>
	 * array (
	 *     'action', // anyone can access this action
	 *     'action' => true, // same as above
	 *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
	 *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
	 * );
	 * </code>
	 *
	 * @var array
	 */
	private static $allowed_actions = array (
	);

	public function init() {
		parent::init();
		// You can include any CSS or JS required by your project here.
		// See: http://doc.silverstripe.org/framework/en/reference/requirements
		
		// Note: you should use SS template require tags inside your templates 
		// instead of putting Requirements calls here.  However these are 
		// included so that our older themes still work
		
		Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.min.js'); //include jquery 1.7.2 bundled with ss
		//Requirements::javascript('http://code.jquery.com/jquery-1.7.2.min.js');
		Requirements::javascript('themes/'. SSViewer::current_theme() .'/javascript/navscript.js'); //link to js file in current theme folder
			
		//Requirements::themedCSS('reset');
		//Requirements::themedCSS('960-12-col');
		//Requirements::themedCSS('Layout'); 
		//Requirements::themedCSS('Typography'); 
		//Requirements::themedCSS('form'); 
	}
	

}

Avatar
thomas.paulson

Community Member, 107 Posts

22 July 2014 at 5:11am

Avatar
mhdesign

Community Member, 216 Posts

11 June 2015 at 7:44pm

Hi thomas.paulson, would you believe it's taken me almost a year to get back to this? Obviously because it's for my own website!!

Your module works a treat -- almost too easy to install! Just one question though -- I'm wanting to add some sort of captcha (as I'm putting this on every page I could be drowning in spam if I don't). I've looked at SpamProtection Module https://github.com/silverstripe/silverstripe-spamprotection which integrates with Mollum, Recaptcha and other implementations. Only problem is I can't see how to enable this.

Instructions are that I call SpamProtection as follows:

// your existing form code
	$form = new Form( .. );
	$form->enableSpamProtection();

Have tried at bottom of form code itself and also in the footer.ss include. Wherever I put it I see ->enableSpamProtection(); on my page.

Any tips?