Newsletter option in contact us in magento - magento

How can I add checkbox functionality when it checked email of contact us form subscribe to the newsletter?

Edit the contact form and add in your own checkbox, and then modify the contacts controller using the method above (Mage_Contacts_IndexController)
You would then add in some code to subscribe to the newsletter using the email address from the posted form:
$status = Mage::getModel('newsletter/subscriber')->subscribe($email);
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
Mage::getSingleton('core/session')
->addSuccess($this->__('Confirmation request has been sent.'));
}
else {
Mage::getSingleton('core/session')
->addSuccess($this->__('Thank you for your subscription.'));
}

Related

In Zoho Creator unable to pass the decision from Zoho Workflow (deluge script) to Zoho Form

I have a calculator whose output i need to display on Submit button. The output comes from a decision tree running in Zoho Workflow module using deluge script.
1) Have tried storing the output in workflow as a string and then passing it back to a form field
2) Tried creating a zoho page for output display but unable to link output of workflow and zoho page
if(input.Price > input.Income)
{
if(input.EMI_Exp < 0.6)
{
info "Take the Personal Loan as you can easily manage the EMI.
If you choose a credit card then you will mess your cashflow";
}
else
{
info "No Personal Loan, No Using Credit Card. You are stretching
yourself by purchasing this";
}
}
else
Need to pass the info information to a decision box ( text) in Zoho form.
On submit of the form, if you are willing to display a message to the user, you can make use of two things page or stateless form.
Page:
Create a page on creator and names it as Message ( You can name it as
you wish )
Add parameters to the page by name recordID ( datatype of
the variable is string & can have any name ).
On page fetch record information from the form and using recordID( convert into
to long as it is string whereas ID is bigint ). i.e
response = FormName[ID == recordID.toLong()]
if(response.EMI_Exp < 0.6)
{
%><p>
Take the Personal Loan as you can easily manage the EMI. <br>
If you choose a credit card then you will mess your cashflow
<p><%
}
else
{
%>
<p>
No Personal Loan, No Using Credit Card. You are stretching
yourself by purchasing this
</p>
<%
}
}else{
%>
<p>
Thank you!!!
</p>
<%
}```
On click of submit button use open url :
openUrl("#page:pageLinkName?zc_LoadIn=dialog&recordID="+input.ID,"same window"), using the script you can open a dialog box
Stateless Form:
Create a stateless form ( Name it as Message or anything you want)
Add two field a single-line text field and name it as recordID and
note field and keep it empty without any value and name it as
Message
On load hide recordID field and using recordID fetch record details
i.e
response = FormName[ID == recordID.toLong()];
if(response.Price > response.Income) {
if(response.EMI_Exp < 0.6)
{
input.Message = "Take the Personal Loan as you can easily manage the EMI.
If you choose a credit card then you will mess your cashflow";
}
else
{
input.Message = "No Personal Loan, No Using Credit Card. You are stretching
yourself by purchasing this";
} }
else{ input.Message= "Thank you !!!" }
On Submit of calculator form using following script :
openUrl("#Form:formLinkName?zc_LoadIn=dialog&recordID="+input.ID,
"same window")```
, using the script you can open a dialog box
Hope this could help you.

send a mail to particular user while clicking on the button from view page in codeigniter

i have one view page called vendor view candidates page..in that page i display all the candidates details from database and i have user_id in that view page..and i gave button called release information..so when user click on the button the page will redirect to edit_candidates page with that particular candidate_id..and they will allow to insert email and phone number..
After they insert email and mobile number and then submit..i want to send mail to particular user_id..
This is my button:(edit candidates page)
<td>Release Contact Info</td>
Controller:
public function edit_candidates($id)
{
$data['editdata']=$this->CandidateModel->candidate($id);
if($this->input->post())
{
$this->CandidateModel->update_candidate($this->input->post(),$id);
redirect(base_url('index.php/Candidate/vendor_view_candidates'));
}
$this->load->view('Candidates/edit_candidate',$data);
}
Can anyone help me...i tried a lot..but i didn't get any idea on how to do this..
Thanks in advance..
Use the following code to fix your issue
public function edit_candidates($id)
{
$data['editdata']=$this->CandidateModel->candidate($id);
if($this->input->post('update_form'))
{
$userEmail = $this->CandidateModel->get_userinfo($data['editdata']->user_id);
//Pass this $userEmail into mail function it will send email
$this->CandidateModel->update_candidate($this->input->post(),$id);
redirect('index.php/Candidate/vendor_view_candidates','refresh');
}
else
{
$this->load->view('Candidates/edit_candidate',$data);
}
}
Let me know if it not fix your issue

Avoiding Robots from registering on your site

I'm in the process of setting up a basic site for cell phone reviews and information. I keep getting these fake accounts registering and posting content on my site that is not appropriate.
I have just installed the CAPTCHA and image CAPTCHA module, but this doesn't seem to be stopping them.
What is the best way to avoid these fake accounts?
Thank you.
Another strategy is to add another field in the user registration form. Most bots wouldn't know which fields are required, so they fill in everything. If the user enters a value into the new field then don't create an account. You can hide the field from the UI with CSS so that real people won't be able to see the field and enter anything into it. Read Easy spam prevention using hidden forms for a detailed explanation.
To implement this feature into your Drupal site, you need to create a module to alter the user registration form and create a validation for it.
Add another field to the user registration form:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'user_register_form') {
$form['field_fname'] = array(
'#title' => 'Answer if you are a bot',
'#type' => 'textfield',
);
$form['#validate'][] = 'mymodule_user_bot_validate';
}
}
Add the validation:
function mymodule_user_bot_validate($form, &$form_state) {
if($form['field_fname']['#value'] != '') {
form_set_error('bot_prevention', t('Could not create your account.'));
drupal_goto('user/register');
}
}
Then hide the field with CSS.

Codeigniter - detect the sender of a request

I'm building a commercial website, with a shopping cart.
On most pages (i.e - product page, category page), I want to display the cart contents on a sidebar, which will get updated via AJAX when an item is added to the cart.
On the "display cart" page I want to show a full version of the contents.
Obviously, it seems logical to use the same model and functions to get and/or update the cart, but send the data to a different view (sidebar or full cart), depending on the caller page.
The question is, in the cart model, how can I detect where did the request come from.
I thought I'd check if the request came via AJAX, like so:
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') // i.e - the request came as AJAX
{
$this->load->view('cart_sidebar_view', $data);
}else{ /* not ajax */
$data['main_content'] = 'cart_view';
$this->load->view('includes/template', $data);
}
But that is not good enough, because I want to use AJAX on the "display cart" page as well, to allow updating the cart from there.
So, is there a way to detect, in the cart model, where did the request come from? Or will I have to send that info in a hidden form field with every "add to cart" or "remove" button?
There is a simple way. when you are sending request from the display cart page send an additional variable. Than in the controller check for this variable if variable is coming call a logic if variable is not coming do something else.
if($this->input->is_ajax_request())
{
$this->load->view('cart_sidebar_view', $data);
}else{
if($this->input->post('another_variable')){
// do something else
}else{
$data['main_content'] = 'cart_view';
$this->load->view('includes/template', $data);
}
}

How to determine the authorization in Joomla

After login i use need to set up redirect to custom page. How to catch this authorization in onAfterRoute event?
You should go to this path:
JOOMLAROOT/components/com_user/controller.php
in function register_save(), find this code:
if ( $useractivation == 1 ) {
$message = JText::_( 'REG_COMPLETE_ACTIVATE' );
} else {
$message = JText::_( 'REG_COMPLETE' );
}
after line put this code:
$this->setRedirect('/Your Custom Page Address', $message);
Why not just use the built in redirect in either the Joomla user login menu item or the standard Joomla login module. Both offer the option to redirect a user after a successful login. In the case of the module, you would need to create a menu item pointing to the custom page, but that's easy enough to do.
Is there something you need to do other than just a simple redirect? If not, then just use the system as it is designed.
I would create a small plugin that handles the redirect after login.
After a user has been logged in, the event onUserLogin is triggered, and you could simply do a redirect when the event is called.
Avoid any core hacks, since you'll allways end up having a hazzle during updates.
The code for a plugin like this could look like this:
class plgAuthenticationMyredirect extends JPlugin{
function onUserLogin ($user, $options){
$link = 'index.php?option=.....';
$msg = 'Message to show after login';
$app = JFactory::getApplication();
$app->redirect($link, $msg);
}
}

Resources