Smarty Config_load and Custom Function Error resolution method

Source: Internet
Author: User
Smarty Config_load and Custom Function error
Temp.tpl
HTML Code
  
   {config_load file= ". /configs/a.conf "} {#s #}

A.conf
HTML Code
  
   s= ' test test '

Error
Fatal error:uncaught exception ' smartyexception ' with message ' Unable to read config file '. /configs/a.conf ' in c:\wamp\www\smarty\libs\sysplugins\smarty_internal_resource_file.php:68 Stack trace: #0 C:\wamp \www\smarty\libs\sysplugins\smarty_config_source.php (in): Smarty_internal_resource_file->getcontent (Object ( Smarty_config_source)) #1 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_config_file_compiler.php (Bayi): Smarty _config_source->__get (' content ') #2 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_config.php (189): Smarty _internal_config_file_compiler->compilesource (Object (smarty_internal_config)) #3 C:\wamp\www\smarty\libs\ sysplugins\smarty_internal_config.php (214): Smarty_internal_config->compileconfigsource () #4 C:\wamp\www\ Smarty\templates_c\187938f6ec55068ed23f0f2de8d126b1ae3149c7.file.temp.tpl.php (£): Smarty_Internal_Config-> Loadconfigvars (NULL, ' local ') #5 C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php: Content _4fb7f6591b8ab2_26457252 (Object (smarty_internal_template)) #6 c:\w in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_ Resource_file.php on line 68


Custom functions
PHP Code
  
   
  
   Register_function ("Doloop", "myfun");    $smarty->display ("Temp.tpl");? >


Temp.tpl
HTML Code
  
   {Doloop times= "5"}


Error
Fatal error:uncaught exception ' smartyexception ' with message ' "Call of Unknown method ' register_function '. ' In C:\WAMP\WW w\smarty\libs\sysplugins\smarty_internal_templatebase.php:806 Stack Trace: #0 [internal function]: Smarty_internal_ Templatebase->__call (' Register_functi ... ', Array) #1 C:\wamp\www\smarty\smarty.php: Smarty->register_ function (' Doloop ', ' myfun ') #2 {main} thrown in C:\wamp\www\smarty\libs\sysplugins\smarty_internal_templatebase.php On line 806

I downloaded Smarty 3.1.8 [smarty-stable.zip] 20th, 2012 files from the official website of Smarty.
Stable the word is stable. I'm going to get this bag. After decompression, I copied the Libs folder into my Www/smarty directory.
Other like running {$smarty. server.server_addr} In the TEMP.TPL template This statement can be displayed properly, why not run the above config_load and custom functions?


------Solution--------------------
Google a bit, the original is this AH.
3.0 was used register_function to achieve, now is the new method Registerplugin.
$smarty->registerplugin ("function", "Demo", "Demotest");; /development type, where a function call is made, specifying the template function name and PHP function name
function Demotest ($params) {
Extract ($params);//Get the parameters A and B
echo $a. $b;//output
}

Template notation:
{Demo a= "2″b=" "Test"}
Output: 2test

However, the use of {config_load} in the template or error Ah, how to solve?
------Solution--------------------
Ah, Config_load made a mistake and solved it.
I write {config_load file= "a.conf"} directly in the TEMP.TPL template
Create a new Configs folder in the Temp.tpl file and put the a.conf in the folder,
Strange yes, I did not specify a.conf in the Configs folder Ah, how did it find?
It is always written in Temp.tpl {config_load file= ". /configs/a.conf "} That's right, but this is going to be an error.
What's going on?
How did smarty3.0 find it?
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.