View Full Version : create custom error message
aminp30
05-10-2016, 02:08 AM
Hi
I just created custom page in my vb 4. Now I need show error message in this page but this error involve to all pages.
what should I do?
I used this function:
if(TIMENOW-$last_quiz_date<864000){eval(standard_error('no permission'));}
Lynne
05-10-2016, 02:37 PM
So you want to add a No Permission message only to your custom page but it is showing up on all pages? Where did you put that code you posted above? If it is in your custom php page, then it should only show on that page. We need a little more information here I think.
aminp30
05-10-2016, 03:48 PM
thanks for your attention Lynne,
yes that's right. in fact I need no permission message with custom message
I created a page named quiz.php. as you know I need create a template for it too.
in this template I need load some data from database so I created subpage. I used plugin at global_start hook location
ob_start();
require_once('quiz/quiz_detail.php');
$php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('quiz',array('php_include ' => $php_include));
I used this code in quiz_detail.php file at 15th line after connecting to database
I think my hook location made this problem. am I right?
MarkFL
05-10-2016, 04:02 PM
If you need to query the database and register the results stored in variables, then what I would do is query the database in "quiz.php", and then register the variables in your custom template immediately afterwards. You don't want to run the query globally, this would cause unnecessary server strain.
As an example, I have a product for reporting profiles. I use a custom template to display the input form, and I use the following code to send that needed data to the template (after querying the database), and then render the template:
$templater = vB_Template::create('markfl_reportprofile_form');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('reporteduserid', $reporteduserid);
$templater->register('reporteruserid', $reporteruserid);
$templater->register('reportedusername', $reportedusername);
$templater->register('rp_checkboxes', $rp_checkboxes);
$templater->register('text_height', $text_height);
$templater->register('rp_condition', $rp_condition);
print_output($templater->render());
aminp30
05-10-2016, 04:30 PM
If you need to query the database and register the results stored in variables, then what I would do is query the database in "quiz.php", and then register the variables in your custom template immediately afterwards. You don't want to run the query globally, this would cause unnecessary server strain.
As an example, I have a product for reporting profiles. I use a custom template to display the input form, and I use the following code to send that needed data to the template (after querying the database), and then render the template:
$templater = vB_Template::create('markfl_reportprofile_form');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('reporteduserid', $reporteduserid);
$templater->register('reporteruserid', $reporteruserid);
$templater->register('reportedusername', $reportedusername);
$templater->register('rp_checkboxes', $rp_checkboxes);
$templater->register('text_height', $text_height);
$templater->register('rp_condition', $rp_condition);
print_output($templater->render());
thank you Mark
how should I use this variables in template? {vb:raw variablename}
for example in your code if I need to use $text_height I should write this code?
{vb:raw text_height}
MarkFL
05-10-2016, 04:37 PM
Yes, in my custom template "markfl_reportprofile_form" I use that variable in a CSS selector as follows:
textarea {
resize: none;
height: {vb:raw text_height}px;
width: 100%;
font-size: 14px;
font-family: Arial;
}
Any variable you register can be used in the template that way. :)
aminp30
05-11-2016, 01:24 AM
thank you Mark. you learned me very special and usefull method
it worked perfect, but it made me a lot of change in my codes :D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.