Simple PHP Template Question...

by WillR
5 replies
Warriors,

I am using a simple php include template setup for my website.
In my pages I am calling some variables from another php file by using:

HTML Code:
<?php include("variables.php"); ?>
and then placing the variables in the page wherever I want them to show using the code:

HTML Code:
<?=$ variable1?>  (without the space obviously)
This all works perfectly however I want to be able to show text in the place of those variables if someone is viewing the page offline. So let's say I am looking at the page on my server and one of the variables is the page title. With php all working fine, the page title is pulled from the variables.php file and displays properly.

Now lets say I am viewing that page offline in an html editor or something similar. Obviously because php is not working, if I preview that page offline, no page title will display. Is there a way I could have a page title display for whenever there is no php value available?

Does that make sense?
#php #question #simple #template
  • Profile picture of the author FreeBird85
    PHP is strictly server side so it won't run on your local host unless you install something like XAMPP
    {{ DiscussionBoard.errors[3767076].message }}
  • Profile picture of the author lordspace
    you could save the php output and edit it in the HTML editor and then apply the changes to the php file.
    Signature

    Are you using WordPress? Have you tried qSandbox yet?

    {{ DiscussionBoard.errors[3794481].message }}
    • Profile picture of the author Rovi
      If you want default values to show you could set those in place in your html file, then use javascript to replace them on document load, using values pulled via ajax from a php script.

      Your js would get values by calling ajax -> script.php then on success replace html of divs, tags targeted by id, eg.
      <title id="titletarget">Default</title>

      hth

      Rovi
      {{ DiscussionBoard.errors[3796855].message }}
  • Profile picture of the author CodeMyConcept
    We are sorry but what you are asking is not possible on PHP
    {{ DiscussionBoard.errors[3797447].message }}
    • Profile picture of the author Rovi
      Just to clarify on my earlier post - you would give your html page with default values in place to people for offline viewing, then when the same page is accessed on the server with php running, js would replace those default values with values generated dynamically with ajax/php.

      Would that work for your situation?
      {{ DiscussionBoard.errors[3798221].message }}

Trending Topics