Announcement

Collapse
No announcement yet.

HOW DO I: test to see if a file exists in a template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HOW DO I: test to see if a file exists in a template

    What XHTML code ( or other) would you use in a vB3 template to test if a certain file exists.

    Here is the logic:
    Code:
     <If exists ("/path/to/foo.txt")>
       	do something
       </if>
    Would this have to be done with a PHP include? If so, how?
    Thanks

  • #2
    PHP's file_exists() function cannot be used directly in a template. Here's how you would do it with a PHP Include template:

    Open the phpinclude_start template and add:

    PHP Code:
    if (file_exists('/path/to/a/file.txt'))
    {
         
    $file_exists true;

    Then in the template you want to check for the file's existence, use the following conditional:

    HTML Code:
    <if condition="$file_exists">
         do some stuff here
    </if>
    Bugdar: PHP bug tracking software that is beautiful, fast, and robust.

    Comment

    Loading...
    Working...
    X