silverstripe contact form on sidebar

I am sure, this question is asked so many time, but i not going to use page_controller instead use TemplateGlobalProvider
http://api.silverstripe.org/3.1/class-TemplateGlobalProvider.html

Other day I was going through silvestripe menu-manager by wilr. And I found TemplateGlobalProvider , which is behind global $Now which use in footer to print date.

So I thought to implement silverstripe contact form on sidebar, using the same global TemplateGlobalProvider.

for source-code
https://github.com/thomaspaulson/silverstripe-contactform

Posted in Uncategorized | Leave a comment

xammp – Couldn’t start MySQL!

my screen
—————
$ sudo /opt/lampp/lampp start
Starting XAMPP for Linux 1.8.0…
XAMPP: Starting Apache with SSL (and PHP5)…
XAMPP: Starting MySQL…
XAMPP: Couldn’t start MySQL!
XAMPP: Starting ProFTPD…
XAMPP for Linux started

below solution from stacloverflow worked for me
http://stackoverflow.com/questions/12507358/couldnt-start-mysql-while-starting-xampp

sudo chmod 755 /opt/lampp/etc/my.cnf
sudo chmod -R 777 /opt/lampp/var/mysql
sudo chown -hR root /opt/lampp
sudo /opt/lampp/lampp restart

Posted in Uncategorized | Leave a comment

Configuring Ubuntu for VirtualBox to detect USB devices

I was searching web to find the solution for detecting usb in virtualb box.

The trouble was setting user-group setting for vboxusers

usermod -a -G vboxusers courtney #change courtney to your username

reference
———-
http://zcourts.com/2013/06/02/configuring-ubuntu-for-virtualbox-to-detect-usb-devices/

Posted in Uncategorized | Leave a comment

silverstripe – listing upcoming events

I recently created a website for stritas public school using silverstripe.

Also wanted to list upcoming events silverstripe-event-calendar developed by uncle cheese in footer, So I have created my own upcoming event listing for silverstripe, so that events can be listing on any other page/footer/section.

https://github.com/thomaspaulson/silverstripe-event-footer

reference
https://github.com/heyday/silverstripe-menumanager

Posted in Uncategorized | Leave a comment

install reliance netconnect on ubuntu

Hello

* supposed CDROM will automatically mount to the patch ie /media/cdrom0 after modem is inserted.

optional – if does automount, try copy the folder ‘install_linux,’ by inserting the modem on windows; make sure reliance netconnect is not installed in window. Then navigate to usb and copy the folder

lets start

installing reliance netconnect on Ubuntu

Navigate to modem folder location

cd media/cdrom0/netconnect/

sudo sh ./install_linux

done, go online

Uninstallation

sudo unztemtapp , I have not tried this command tough

check you netconnect manual for more info

Posted in Uncategorized | Tagged , , , | Leave a comment

install ruby and rubyonrails on fedora18

[Note] I  installed the fedora18 using live fedora18 liveCD

first login using ‘ su ‘.

if gcc compiler is missing, install gcc first ‘yum install gcc’

yum install ruby

yum -y install rubygems

yum install ruby-devel

yum install irb

yum install ri

yum install rdoc

while rubyonrails installation if you get  ‘javascript runtime environment ‘ message. when i googled someone adviced me to nodejs. nodejs  requires ‘gcc-c++’ , so run – ‘ yum install gcc-c++ ‘ first then continue next step

wget http://nodejs.org/dist/v0.10.13/node-v0.10.13.tar.gz

tar zxvf node-v0.10.13.tar.gz
cd node-v0.10.13

./configure
make
make install

exit su login run ‘ exit ‘, continue installing rubygems with normal user account

gem install sqlite3 -v ‘1.3.7’

gem install sqlite3

gem uninstall sqlite3 -a -x -I

gem install rdoc

gem install rdoc-data

gem install rails

rails server

Posted in Uncategorized | Leave a comment

sqlite3/sqlite3_native (LoadError)

Last two days, I was trying to install rubyonrails,
I had installed the rails,ie gems install rail and sqlite3 ie gems
install sqlite3
using su user account, so I thought start the ' rails server ' now. 
But i was getting sqlite3/sqlite3_native (LoadError)

When I installed rails, sqlite3 I was using root user. Unfortunately 
SQLite3 gem does not update the GEM_HOME environment variable
correctly when you are logged in as root.

reference
http://www.petersens.ws/2012/08/ruby-on-rails-and-sqlite3

So I uninstalled the rails and sqlite3, then i logged as user account
and reinstalled the rails and sqlite3, then rerun rails server,  this 
time I got ' execJS autodetect could not find JavaScript '
And the solution to this install 'standalone JavaScript runtime' like
nodejs. Once I installed nodejs and rerun rails server; the server 
started working 'http://localhost:3000/'
http://community.spiceworks.com/topic/255293-linux-rails-server-
errors-with-execjs-autodetect-could-not-find-javascript
Platform 
--------------
ruby 1.9.3
Rails 4.0.0
fedora 18
Posted in Uncategorized | Leave a comment

form validation using zend framework

Zend framework is one of the most popular MVC framework based on php. It has lots of feature listed below
1. Model-View-Controller (MVC)
2. Database adapters
3. Form validatiors
4. Web Services
5. User Authenication and Authorisation.

Form Validation is important component to handle, to ensure required fields are filtered, before the data is store in the database. But in this example data is not stored in the database.

Lets get started. Here i have grouped all the class to ‘default’ module and placed in main ‘modules’ in applcation folder.

To demostrate the form validation I have created a ExampleController with ‘form’ action to process the form validation and once validated it is redirected to example/success page.

class ExampleController extends Zend_Controller_Action
{
public function indexAction(){
}

public function formAction()
{
$form = new Default_Form_Example;
$this->view->form = $form;
// check the request
// run the validators
if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
// valid data: get the filtered and valid values
// do something, save to database or write to file
// display a success view
$values = $form->getValues();
$this->_redirect(‘/example/success’);
} else {
// invalid data: get the error message array
// for manual processing (if needed)
// redisplay the form with errors
$this->view->messages = $form->getMessages();
//var_dump($this->view->messages);
}
}
}

public function successAction(){

}
}

Below the Default_Form_Example, where i have created the form element and set the validation rules. It reside in ‘default/forms’ folder

class Default_Form_Example extends Zend_Form
{
public function init()
{

// initialize form
$this->setAction(‘/example/form’)
->setMethod(‘post’);
// create text input for age
// should contain only integer values between 1 and 100
$age = new Zend_Form_Element_Text(‘age’);
$age->setLabel(‘Age:’)
->setOptions(array(‘size’ => ‘4’))
->setRequired(true)
->addValidator(new Zend_Validate_Int())
->addValidator(new Zend_Validate_Between(1,100));

// create text input for name
// should contain only alphabetic characters and whitespace
$name = new Zend_Form_Element_Text(‘fname’);
$name->setLabel(‘First name:’)
->setOptions(array(‘size’ => ’16’))
->setRequired(true)
->addValidator(new Zend_Validate_Alpha(true));

// create text input for email address
// should contain a valid email address
$email = new Zend_Form_Element_Text(’email’);
$email->setLabel(‘Email address:’)
->setOptions(array(‘size’ => ’16’))
->setRequired(true)
->addValidator(new Zend_Validate_EmailAddress());

// create submit button
$submit = new Zend_Form_Element_Submit(‘submit’);
$submit->setLabel(‘Sign Up’);

// attach elements to form
$this->addElement($age)
->addElement($name)
->addElement($email)
->addElement($submit);
}
}

form view file in created in ‘default\views\scripts\example’ folder. Here we can display the form using the code ‘ echo $this->form; ‘ but i prefer to normal html form to control the form layout.
<form enctype=”application/x-www-form-urlencoded” action=”/example/form” method=”post”>
<p>
<label for=”age”>Age:</label>
<input type=”text” name=”age” id=”age” value=”<?php echo $this->form->getValue(‘age’); ?>” size=”4″>
<?php
//var_dump($this->messages);
if( isset($this->messages[‘age’][‘isEmpty’]) )
echo $this->messages[‘age’][‘isEmpty’] ;
if( isset($this->messages[‘age’][‘notInt’]) )
echo $this->messages[‘age’][‘notInt’] ;
if( isset($this->messages[‘age’][‘notBetween’]) )
echo $this->messages[‘age’][‘notBetween’];
?>
</p>
<p>
<label for=”name”>First name:</label>
<input type=”text” name=”fname” id=”fname” value=”<?php echo $this->form->fname->getValue(); ?>” size=”16″>
<?php
if( isset($this->messages[‘fname’][‘isEmpty’]) )
echo $this->messages[‘fname’][‘isEmpty’] ;
if( isset($this->messages[‘fname’][‘notAlpha’]) )
echo $this->messages[‘fname’][‘notAlpha’] ;
?>
</p>

<p>
<label for=”email”>Email:</label>
<input type=”text” name=”email” id=”email” value=”<?php echo $this->form->getValue(’email’); ?>”” size=”16″>
<?php
if( isset($this->messages[’email’][‘isEmpty’]) )
echo $this->messages[’email’][‘isEmpty’] ;
if( isset($this->messages[’email’][’emailAddressInvalidFormat’]) )
echo $this->messages[’email’][’emailAddressInvalidFormat’] ;
?>
</p>

<p>
<input type=”submit” name=”submit” id=”submit” value=”Sign Up”>
</p>
</form>

 

zend-form-validation

 

Download code

reference
vikram viswani ‘A begginners guide Zend framework’

Posted in Uncategorized | Tagged | Leave a comment

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

 

Posted in Uncategorized | 1 Comment