Custom Page with custom style

For support and discussion related to templates, themes, and imagesets in phpBB 3.0.
Suggested Hosts
Ciao121
Registered User
Posts: 239
Joined: Wed Jan 28, 2004 1:08 pm

Custom Page with custom style

Post by Ciao121 »

Hi all,
I made a custom page using this tutorial.
But it uses the board default style. How can I specify to use a different style?

Thank you :)
Last edited by prototech on Tue Apr 20, 2010 11:24 pm, edited 1 time in total.
Reason: Topic icon changed
Apri il tuo forum gratuito in 1 minuto.

NathanFtw
Registered User
Posts: 247
Joined: Mon Jun 15, 2009 7:59 am

Re: Custom Page with custom style

Post by NathanFtw »

Which tutorial did you use, also did you do the edits (either subsilver or prosilver, depending whichever your style is based on) to your custom style?

Ciao121
Registered User
Posts: 239
Joined: Wed Jan 28, 2004 1:08 pm

Re: Custom Page with custom style

Post by Ciao121 »

Sorry, I forgot the link:
http://www.phpbb.com/kb/article/add-a-n ... -to-phpbb/

My Board uses prosilver style as default one.
I want my custom page (only the custom page) to use a different style.
Apri il tuo forum gratuito in 1 minuto.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51931
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Custom Page with custom style

Post by Brf »

When you call $user->setup() on that page, pass the style number as the second parameter:

Code: Select all

$user->setup('',4);

Ciao121
Registered User
Posts: 239
Joined: Wed Jan 28, 2004 1:08 pm

Re: Custom Page with custom style

Post by Ciao121 »

Brf wrote:When you call $user->setup() on that page, pass the style number as the second parameter:

Code: Select all

$user->setup('',4);
That solved my problem. Thank you :)
Apri il tuo forum gratuito in 1 minuto.

conan_troutman
Registered User
Posts: 222
Joined: Mon Jul 19, 2010 11:06 am

Re: Custom Page with custom style

Post by conan_troutman »

Hi

I have used the guide on how to create a custom page and I am having a small issue.

instead of defaulting to the boards custom style as it does I would like the page to open in the users own style that they are using.

any advice on what to add

I tried to add

Code: Select all

$user->setup('viewforum', $forum_data['forum_style']);
instead of

Code: Select all

$user->setup();

but it didnt work

any help please

User avatar
prototech
Former Team Member
Posts: 5406
Joined: Mon Mar 19, 2007 2:04 pm
Location: Southern California

Re: Custom Page with custom style

Post by prototech »

If you followed the tutorial from the knowledge base, it should already be doing that without requiring any changes since that is the default behavior of the setup() function.
Need help with MOD/style installations or other phpBB problems? Contact me for a quote.

conan_troutman
Registered User
Posts: 222
Joined: Mon Jul 19, 2010 11:06 am

Re: Custom Page with custom style

Post by conan_troutman »

it does if the user chooses it from with in the user CP but if a user choices to try a new style from the drop down box via the portal then when they get the the custom pages it defaults back to the default style from with in the user cp

it does keep the

Code: Select all

?style=8
at the end of the url on custom pages

conan_troutman
Registered User
Posts: 222
Joined: Mon Jul 19, 2010 11:06 am

Re: Custom Page with custom style

Post by conan_troutman »

still having an issue with this script.

hopefully some can see what I have done wrong and help

basically I have a form which when filled in correctly send me an email the user gets a success message all in the forum style

how ever, I can get it to make an error message in the forum style

I really am at a loss here

I have the from.php

Code: Select all

    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
	    

    page_header('Fair Play Form');

    $template->set_filenames(array(
        'body' => 'fpcform.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
    ?>
and the from.html

Code: Select all

<!-- INCLUDE overall_header.html -->


<body>
<div class="panel">
   <div class="inner"><span class="corners-top"><span></span></span>

   <div ALIGN=CENTER class="content">
   <p>
   
   <h1>Fair Play Clans Form</h1>
      <form name="contactform" method="post" action="send_application_email.php">

<table width="600px">
</tr>
<tr>
 <td valign="top">
  <label for="first_name">Clan Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="first_name" maxlength="50" size="50">
 </td>
</tr>
 
<tr>
 <td valign="top"">
  <label for="last_name">Contact Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="50">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email Address *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="50">
 </td>
 
</tr>
<tr>
 <td valign="top">
  <label for="telephone">Website *</label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="50">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="comments">About Your Clan *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="50" rows="10"></textarea>
 </td>
 
</tr>
</table>
<table>
<tr>
	    <script type="text/javascript"
     src="http://www.google.com/recaptcha/api/challenge?k=public key">
  </script>
  <noscript>
     <iframe src="http://www.google.com/recaptcha/api/noscript?k=public key"
         height="300" width="500" frameborder="0"></iframe><br>
     <textarea name="recaptcha_challenge_field" rows="3" cols="40">
     </textarea>
     <input type="hidden" name="recaptcha_response_field"
         value="manual_challenge">
  </noscript>
 <td colspan="4" style="text-align:center">
<input type="submit" value="Submit">   
 </td>
</tr>
</table>

</form>
</p>
   </div>

   <span class="corners-bottom"><span></span></span></div>
</div>

<!-- INCLUDE breadcrumbs.html -->
<!-- INCLUDE overall_footer.html -->

on clicking submit the following script runs

Code: Select all

<?php

require_once('recaptchalib.php');
  $privatekey = "private key";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
   die ("$resp->error");
	
  } else {
    // Your code here to handle a successful verification
  

if(isset($_POST['email'])) {
     
    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "the_management@p3l-clan.co.uk";
    $email_subject = "Fair Play Clans";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
     
    $error_message = "";
    $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "^[a-z .'-]+$";
  if(!eregi($string_exp,$first_name)) {
    $error_message .= 'The Clan Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
    $error_message .= 'The Contact Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'You did not tell us about your clan.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
  } else {
    // Your code here to handle a successful verification
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "Clan Name: ".clean_string($first_name)."\n";
    $email_message .= "Contact Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Website: ".clean_string($telephone)."\n";
    $email_message .= "About Your Clan: ".clean_string($comments)."\n";
     
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 

    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
	    

    page_header('Success');

    $template->set_filenames(array(
        'body' => 'success.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();

}
}
?>
if successful they will see this success.html

Code: Select all

<!-- INCLUDE overall_header.html -->
<script language="javascript" type="text/javascript">
function closeWindow() {
window.open('','_parent','');
window.close();
}
</script> 


<div class="panel">
   <div class="inner"><span class="corners-top"><span></span></span>

   <div ALIGN=CENTER class="content">
      <p>
	  <h1><font size="6">Your form has been submitted</font></h1>
<br>
<br>	  
<font size="4">Thank you for contacting us. We will be in touch with you very soon.
</font>
<a href="javascript:closeWindow();">you may now close this tab</a>

      </p>
   </div>

   <span class="corners-bottom"><span></span></span></div>
</div>

<!-- INCLUDE breadcrumbs.html -->
<!-- INCLUDE overall_footer.html -->

how ever if they leave any entry blank or get the captcha wrong the script also generates an erros message, but this is on a blank white screen

I want the message to show in a custom style so it fits with the site but also so I can add

Code: Select all

<A HREF="javascript:history.go(-1)">Go Back</A>
the error message to make it easier for them to go back with out losing any data as this information is not stored in any database

please please some one help me, I have researched and gone as far as I can alone to get this far

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51931
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Custom Page with custom style

Post by Brf »

Instead of using

Code: Select all

die($error_message);
you should be using

Code: Select all

trigger_error($error_message);

conan_troutman
Registered User
Posts: 222
Joined: Mon Jul 19, 2010 11:06 am

Re: Custom Page with custom style

Post by conan_troutman »

thank you I will try that ... once I see how it works when I change it I should be able to work the rest out ...gif not I'll be doing Arnie impressions

conan_troutman
Registered User
Posts: 222
Joined: Mon Jul 19, 2010 11:06 am

Re: Custom Page with custom style

Post by conan_troutman »

Please skip to next post, I figured it out to a degree have new issue
Last edited by conan_troutman on Wed Feb 16, 2011 4:20 pm, edited 1 time in total.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51931
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Custom Page with custom style

Post by Brf »

Here:

Code: Select all

  if(!eregi($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "^[a-z .'-]+$";
  if(!eregi($string_exp,$first_name)) {
    $error_message .= 'The Clan Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
    $error_message .= 'The Contact Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'You did not tell us about your clan.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }

conan_troutman
Registered User
Posts: 222
Joined: Mon Jul 19, 2010 11:06 am

Re: Custom Page with custom style

Post by conan_troutman »

Brf wrote:Here:

Code: Select all

  if(!eregi($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "^[a-z .'-]+$";
  if(!eregi($string_exp,$first_name)) {
    $error_message .= 'The Clan Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
    $error_message .= 'The Contact Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'You did not tell us about your clan.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }

I should ahve refreshed before I edited the last post...

can I put that in the body of the HTML?

I have the recaptcha message now showing, but not got the messages showing that you have posted here... they still show but not on a custom template

my new code looks like

Code: Select all

<?php
require_once('recaptchalib.php');
  $privatekey = "private key";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
	
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
	    

    page_header('No Success');

    $template->set_filenames(array(
        'body' =>'nosuccess.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
	

  } else {
    // Your code here to handle a successful verification
  

if(isset($_POST['email'])) {
     
    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "the_management@p3l-clan.co.uk";
    $email_subject = "Fair Play Clans";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }
     
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
     
    $error_message = "";
    $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!eregi($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "^[a-z .'-]+$";
  if(!eregi($string_exp,$first_name)) {
    $error_message .= 'The Clan Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
    $error_message .= 'The Contact Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'You did not tell us about your clan.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
  
  } else {
    // Your code here to handle a successful verification
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "Clan Name: ".clean_string($first_name)."\n";
    $email_message .= "Contact Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Website: ".clean_string($telephone)."\n";
    $email_message .= "About Your Clan: ".clean_string($comments)."\n";
     
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 

    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
	    

    page_header('Success');

    $template->set_filenames(array(
        'body' => 'success.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();

}
}
?>
I think I am too old to get my head round this language...

just when I think I have it understood it throws me a curve ball

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51931
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Custom Page with custom style

Post by Brf »

I am not sure what you are trying to accomplish by having phpBB sessions code in multiple places in your script. It should only be in there once -- at the very top. Then at the spot you are trying to display the error message, use the trigger_error with your message.

Locked

Return to “[3.0.x] Styles Support & Discussion”