Grow your CSS skills. Land your dream job.

PHP/TPL Link Opens up As File Not Page

  • # September 11, 2013 at 3:20 am

    Hello.

    I have a small issue trying to work out.

    I am using php and tpl files for my website. tpl are my template files and php my running files.

    think link here opens up as a file when ever i click on it does not go to the page. TPL is a html and php page.

    http://www.********.com/template/contact/contact.tpl

    not sure what to do on the php side of things. home.tpl works fine just not reading the link.

    # September 11, 2013 at 7:29 am

    Your link is broken.

    It sounds like the PHP parser is not being invoked. For .php files, this is unusual (unless your web host does not support php).

    PHP files with a .tpl extension should work fine if they are included via PHP. Such files aren’t generally intended to be accessed directly.

    Invoking the PHP parser can usually be done via your .htaccess file:

    AddHandler php5-script .php .tpl
    

    However, you should ask your web host before trying anything.

    # September 11, 2013 at 8:11 am

    changed it back to php and put base in head now pick up file but here there away to make it only show /contact.php rather than /template/contact/contact.php

    I was looking in to rewrite for php but not sure best way to approach it

    # September 11, 2013 at 10:54 am

    Write “contact.php” in your URLs

    <a href="/contact.php">Contact Me</a>
    

    then use .htaccess to rewrite the requests to point at the correct location:

    RewriteEngine On
    RewriteRule ^contact.php$ /template/contact/contact.php
    
    # September 11, 2013 at 10:30 pm

    here is what I have done

    AddHandler application/x-httpd-php52 .tpl
    
        RewriteEngine On 
        RewriteRule ^contact.php$ /mail/contact.php
    

    If I wanted to add another link just add

    RewriteRule ^about.php$ /info/about.php
    

    Would I need to put RewriteCond or base?

    when have click send button and refresh it show up the old link on mail/contact.php

    # September 12, 2013 at 7:13 pm

    here is what I have done
    AddHandler application/x-httpd-php52 .tpl
    RewriteEngine On
    RewriteRule ^contact.php$ /mail/contact.php

    If I wanted to add another link just add
    RewriteRule ^about.php$ /info/about.php

    Assuming that’s the correct path, then yes.

    If you’re going to have multiple rewrite rules where only one will (or should) apply, you should add the [L] flag (meaning “Last rule”) to the rule so Apache doesn’t bother to continue parsing unnecessarily:

    RewriteRule stop/rewriting /if/this/rule/matches [L]
    

    Would I need to put RewriteCond or base?

    RewriteCond: is your rule conditional? If so, yes. If not, no.

    RewriteBase: do you need to add a common base path to your rewrites? If so, yes. If not, no.

    when have click send button and refresh it show up the old link on mail/contact.php

    Meaning it doesn’t redirect?

    Did you follow this part?

    Write “contact.php” in your URLs

    # September 13, 2013 at 9:09 am

    I am trying to make a template system just modifying some files so I can click on install and it installed db for me

    sort of worked it out here sample php code

    function write_config_files($options) {
        $output  = '<?php' . "\n";
        $output .= '// HTTP' . "\n";
        $output .= 'define(\'HTTP_SERVER\', \'' . $options['http_server'] . '\');' . "\n";
        $output .= 'define(\'HTTP_IMAGE\', \'' . $options['http_server'] . 'image/\');' . "\n";
        $output .= 'define(\'HTTP_ADMIN\', \'' . $options['http_server'] . 'admin/\');' . "\n\n";
    
        $output .= '// HTTPS' . "\n";
        $output .= 'define(\'HTTPS_SERVER\', \'' . $options['http_server'] . '\');' . "\n";
        $output .= 'define(\'HTTPS_IMAGE\', \'' . $options['http_server'] . 'image/\');' . "\n\n";
    
        $output .= '// DIR' . "\n";
        $output .= 'define(\'DIR_APPLICATION\', \'' . DIR_CUSTOMWEB . 'catalog/\');' . "\n";
        $output .= 'define(\'DIR_SYSTEM\', \'' . DIR_CUSTOMWEB. 'system/\');' . "\n";
        $output .= 'define(\'DIR_DATABASE\', \'' . DIR_CUSTOMWEB . 'system/database/\');' . "\n";
        $output .= 'define(\'DIR_LANGUAGE\', \'' . DIR_CUSTOMWEB . 'catalog/language/\');' . "\n";
        $output .= 'define(\'DIR_TEMPLATE\', \'' . DIR_CUSTOMWEB . 'catalog/view/theme/\');' . "\n";
        $output .= 'define(\'DIR_CONFIG\', \'' . DIR_CUSTOMWEB . 'system/config/\');' . "\n";
        $output .= 'define(\'DIR_CACHE\', \'' . DIR_CUSTOMWEB . 'system/cache/\');' . "\n";
        $output .= 'define(\'DIR_LOGS\', \'' . DIR_CUSTOMWEB . 'system/logs/\');' . "\n\n";
    
        $output .= '// DB' . "\n";
        $output .= 'define(\'DB_DRIVER\', \'mysql\');' . "\n";
        $output .= 'define(\'DB_HOSTNAME\', \'' . addslashes($options['db_host']) . '\');' . "\n";
        $output .= 'define(\'DB_USERNAME\', \'' . addslashes($options['db_user']) . '\');' . "\n";
        $output .= 'define(\'DB_PASSWORD\', \'' . addslashes($options['db_password']) . '\');' . "\n";
        $output .= 'define(\'DB_DATABASE\', \'' . addslashes($options['db_name']) . '\');' . "\n";
        $output .= 'define(\'DB_PREFIX\', \'' . addslashes($options['db_prefix']) . '\');' . "\n";
    
    # September 13, 2013 at 12:42 pm

    this seems completely unrelated to the issue we were discussing…?

    # September 13, 2013 at 8:47 pm

    What I mean is instead of using rewrite rule I am modifying a template system to work with tpl and that lets me connect to db.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".