![]() |
Actions for includes in php
hi there,
i was wondering if there was any way i could simply use one page for includes, instead of having to save the normal way. Normally youd alter the includes code to the specific page eg index.php's includes would be indexinc.php,navigation.php,extras.php news includes would be newsinc.php, navigation.php,extras.php Basically what i want to do is for every inc page of my site create an action from the main template that would display the unique included page to each eg index.php?action=news would include newsinc.php and the navigation and extras files index.php?action=freebies would include freeinc.php and the navigation and extras files anyway i can do this? im a total newbie to php |
not sure if i understand you the right way...
try this code: PHP Code:
|
Xenon, Lets have an affair, your an asset
So i would simply create a full compliment of links and type in their function? using if ifelse if else if else if else? it works tops, Im such a newb By the way Xenon, could you tell me a good resource OTHER than php.net for tutorials btw sorry for the triple post :eek: |
Hmm nope, having problems now, can you tell me whats up with this code?
<? if(isset($action) and trim($action)!="home") { include($action."main.php"); } if else(isset($action) and trim($action)!="legal") { include($action."legal.php"); } ?> |
It's elseif not if else and I would just do...
PHP Code:
|
Doh! Shows my talent in the php area then :P
|
by the way, i know the if and elseif statements and the include function, but can people explain actions to me please? and is it possible to set the include main action as the default
|
what do u mean actions? you could try www.php.net, but i dunno what you mean by actions.
|
Thanks for the update, its running more efficently now,
|
what i meab by actions is like
index.php?action=forums or is that simply a user defined function? |
$action is something that PHP automatically does for you, when you do URL.php?action=WHATEVER...it doesn't have to be action either it could be URL.php?url=WHATEVER then you would just replace $action with $url, anyways this is what I do...
PHP Code:
|
i used this to set the homepage as a default. However its not as efficent as id like. You see the problem im having is that i want to set the action of main
if ($action == "home") { include ("http://www.proxymx.com/main.php"); as the loaded include when you load index.php so i set it out like so if ($action == "home") { include ("http://www.proxymx.com/main.php"); } elseif ($action == "legal") { include ("http://www.proxymx.com/legal.php"); } else include ('http://www.proxymx.com/main.php'); However, this presents a problem, if a page isnt found on request, it simply directs the user back to the mainpage. What i want to do is when a user enters the site {index.php} i want them to see the main.php page included. And then use actions such as ?action=forums for other pages the code i used is sufficent to do so, however if ever a page is not found, it simply returns to the mainpage, when i want it to display the standard error pages if a page is not found. So in short what i want to do is set the main.php as the default include when a user loads index.php, However if they type the wrong action i want the standard error messages to show up |
Well you could try this
PHP Code:
|
defeats the purpose :P
|
no it doesn't because it's saying if it doesn't find the page display an error, it just takes a little bit more work and it does exactly what u wanted it to do.
|
But then there would be no way to set the home as a deafult
|
Then try this
PHP Code:
|
All times are GMT. The time now is 11:31 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|