Jump to content

Recommended Posts

Hey,

 

I created a template system a while back, but I didn't take into account that I might have wanted content titles. Basically, the entire site is linked to the index.php file which includes needed files.

 

Say I have a login page, and now I can make the content-title say login (see the second code box), but I cant make it say login failed. Is there a way to set a variable in the included file, then echo it in savor.php (see below) as the content title?

 

here take a look:

include ('include/savor.php'); // computes the pages  & title based on $_get info

session_start();

// Include the template

include ('template/index.php');

ob_end_flush();	

 

Now, savor.php computes the page info using a switch:

  function page_title() {

    if (isset($_GET['task']))
    {
        switch($_GET['task'])
        {
          case 'page':
                 include('thepage.php');
            break;

            default:
                echo 'Page Not Found';
            break;
}}}

Now that function is then transported to the template file, which basically does the function.

 

I hope I gave enough info,

thanks for the help,

Charlie

 

PS: I also tried using $_SESSION but it echoed the page a page late ( needed to refresh to take affect) meaning it wasnt set until after the template was run

I don't understand specifically why you can't output information between title tags, but it seems as if you're mixing your logic and template code, resulting in this only working on the second trial.

 

On a side note, there are many template systems created that support everything you could possibly imagine, like smarty, are they not good enough for you ?

u have to add more logic to yer template system, especially on forms.

I was working on a template system awhile back, its pretty good.

modules had different pre / main functions. to decide whether to process forms / show errors  / display forms / load different page according to form data

 

First ya have to figure out a way to give which step ya are on.

 

such as

http://www.site.com/index.php?p=register

wud check for any POST information

  No Post Info ---> jump to display page (form)

  else process post info

  is post info ok? Yes, Change the Page load to main/index (or redirect)

                        No, save error codes for form display

Display page (form)

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.