vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   create custom error message (https://vborg.vbsupport.ru/showthread.php?t=322589)

aminp30 05-10-2016 02:08 AM

create custom error message
 
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:
PHP Code:

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
PHP Code:

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:

PHP Code:

    $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

Quote:

Originally Posted by MarkFL (Post 2570478)
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:

PHP Code:

    $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:

Code:

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


All times are GMT. The time now is 07:19 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01046 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete