Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 05-10-2016, 02:08 AM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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'));} 
Reply With Quote
  #2  
Old 05-10-2016, 02:37 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Благодарность от:
MarkFL
  #3  
Old 05-10-2016, 03:48 PM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #4  
Old 05-10-2016, 04:02 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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()); 
Reply With Quote
Благодарность от:
Lynne
  #5  
Old 05-10-2016, 04:30 PM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
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}
Reply With Quote
  #6  
Old 05-10-2016, 04:37 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 05-11-2016, 01:24 AM
aminp30 aminp30 is offline
 
Join Date: Jul 2013
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Благодарность от:
MarkFL
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:35 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03778 seconds
  • Memory Usage 2,247KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (3)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete