Jump to content

Newsletter on page maintenance block: have you any solutions please?


TOonyTruand
 Share

Recommended Posts

Hello,

I am looking desperately for a solution !

I wish to block the newsletter on my page maintenance. I saw a plugin, but the link no longer works.

So I learned to create a hook, so I got a little late in my misery ... only it does not appear on my page maintenance

In the database I create a name ps_hook maintenance.

I added in header.php 'HOOK_MAINTENANCE' => Module:: hookExec ('now'),
Then I added the following function in the file blocknewsletter.php: function hookMaintenance ($ params) {return $ this-> hookLeftColumn ($ params);}

and in the file maintenance.tpl I added to the desired location: {$} HOOK_MAINTENANCE

I could then graft the module via the admin: in modules / Position

My new and all beautiful hook so well displayed in the back office, the newsletter is well block it, but nothing in my maintenance page!

I also tried''to call''the file block in file maintenance.tpl newsletter this way:

{include file = $ tpl_dir. / blocknewsletter.tpl} div>

The block appears, but nothing happens when you register ...

I miss that he essential?

Have you any ideas please?

Share this post


Link to post
Share on other sites

  • 3 months later...

You need to write two new PHP files. The first should be called 'subscribe.php' and should look like this:

<?php
include('config.php');

// table name
$tbl_name=lm_newsletter;

// Random confirmation code 
$confirm_code=md5(uniqid(rand()));

// values sent from form 
$email=$_POST['email'];
$city=$_POST['city'];

// Insert data into database 
$sql="INSERT INTO $tbl_name(email)VALUES('$email')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email 
if($result){

// ---------------- SEND MAIL TO USER ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Thank You";

// From
$headers = 'From: [email protected]' . "\r\n" .
  'Reply-To: [email protected]' . "\r\n" .

// Your message
$message="You have sucessfuly subscribed to our newsletter. \r\n";
$message="We'll be sending you some exclusive offers and news. \r\n";
$message="- your-domain.com \r\n";

// send email
$sentmail = mail($to,$subject,$message,$headers);
}

// if not found 
else {
echo "There has been an error, please try again later.";
}

// if your email succesfully sent
if($sentmail){
echo "Thank you. You have been subscribed to our newsletter.";

}
else {
echo "Cannot send to your e-mail address. Please click the back button in your browser to try again.";
}

?>



The second should be called 'config.php' and should contain your DB info, like this:

<?php

$host="localhost"; // Host name
$username="user"; // Mysql username
$password="pass"; // Mysql password
$db_name="dbname"; // Database name 


//Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");

?>



Add these to your theme folder.

Make a COPY of 'modules/blocknewsletter/blocknewsletter.tpl' in your theme folder and make the following changes to it:

Look for the following code:

<form action="..." method="post">



And change it to:

<form action="http://www.your-domain.com/themes/YOUR-THEME/subscribe.php" method="post">



Make sure 'subscribe.php', 'config.php' and the COPY of 'blocknewsletter.tpl' are all in your THEME ROOT FOLDER.

open 'maintenance.tpl' (from your theme folder) and add the following line where you want your newsletter signup to appear:

{include file=$tpl_dir./blocknewsletter.tpl}



You're all done. This will add subscribers to the 'ps_newsletter' table in your database.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More