how to make php template

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vindesign
Forum Newbie
Posts: 3
Joined: Wed Jan 05, 2011 6:03 am

how to make php template

Post by vindesign »

:( hai iam newbie in php. so i want to make a template for side menu

include("sidemenu.php"); just like this when i use this in subfolders getting 404 error how can i get rid of this.
please help me and i'm also want to span the same page how can i use sidemenu.php template in all pages.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: how to make php template

Post by josh »

A 404 error means you mis-typed the URL, there is no PHP issue.
vindesign
Forum Newbie
Posts: 3
Joined: Wed Jan 05, 2011 6:03 am

Re: how to make php template

Post by vindesign »

hey bro i just want to know
in this page folder1/page1.php
index.php linked as ../index.php
if using php template for side menu
the link is ../index.php
if
using folder1/another_folder/apage.php
here the link of index.php would be ../../index.php
so
the template link not work

how can i fix this using one template for all pages.........
and
also
in folder1/another_folder/apage.php the same page link not work in that page, i also want to config in the same page..... how can i code yaar please help me
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: how to make php template

Post by kalpesh.mahida »

It would be better if you define some named constant using define() and use them out in loading file resources of your application.

like below you can have few named constant, that can help you out to load resources.

[syntax=php]<?php

define('APP_ROOT', 'Put value as per your need'); // path to your root directory
define('PATH_LIB', 'Put value as per your need'); // path to your library directory
define('PATH_MODULE', 'Put value as per your need'); // path to your module directory

......
?>[/syntax]
Last edited by Benjamin on Thu Jan 13, 2011 3:03 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
vindesign
Forum Newbie
Posts: 3
Joined: Wed Jan 05, 2011 6:03 am

Re: how to make php template

Post by vindesign »

thanks
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: how to make php template

Post by s.dot »

How about just:

Code: Select all

include $_SERVER['DOCUMENT_ROOT'] . '/sidemenu.php';
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply