Ask experts to answer questions about smarty

Source: Internet
Author: User
I have imported an advertisement file in the smarty template, but I do not know whether the advertisement file exists. if the file does not exist, an error will be reported. how can I not report an error, (Note: I do not want to use assign to pass parameters. because there are many ad files, I cannot determine whether the files exist one by one in the PHP file.) some code in the smarty template is as follows: & lt; div & ask experts to answer questions about smarty
I imported an advertisement file into the smarty template, but I don't know whether the advertisement file exists. if the file does not exist, an error will be reported. how can I avoid an error? (note: I don't want to use assign to pass parameters. because there are a lot of ad files, it is impossible for me to determine whether there is a parameter in the PHP file one by one)

Some code in the smarty template is as follows:
<{Include file = ".../../include/menu_tags_up_button.inc"}>

Error:
Warning: Smarty error: unable to read resource: ".../include/menu_tags_up_button.inc" in .....


As described above, if ".. /.. if the/include/menu_tags_up_button.inc file does not exist, an error will be reported. of course, there will be no problems, so please answer them [color = # FF00FF] [/color]


------ Solution --------------------
Are you sure the file path is correct? since the program says it cannot read the file, or the file does not exist, or the path is wrong for me, what is the problem?
------ Solution --------------------
The smarty error you see is not the php error ?? The smarty throws an exception that is also handled by php. isn't smarty written in php ??
If you do not want to report an error, set the display_error... configuration of php.
------ Solution --------------------
You can check the smarty manual to see if there are any implementation methods. if you are in trouble, you can directly go to the template.
Nested php script

{Php}

If (file_exists (path) {include (path );}

{/Php}
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.