Undefined index: page

im not saying i should use my nooby code im asking how i can use your code but add the added page 's within that media page i dont need code just to display a page i need code to display a page then if &id=new is called aswell display more content/page

thankyou

That was actually what I was asking for a few posts back of exactly what you were trying to do.

Look at this URL. Is this the general idea of what you mean? The page is gallery.php but depending on the link you click, it shows different content.
http://www.sampsontreeservice.com/gallery.php

sort of, i will post more here…

index.php
[php]if (!isset($_GET[‘page’]))
{
// Default Index Page
require PAGES_BASEDIR.$DEFAULT_PAGE;
}
else if (in_array($_GET[‘page’], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET[‘page’].’.php’))
{
// Displays The Called Link
require PAGES_BASEDIR.$_GET[‘page’].’.php’;
}
else
{
http_response_code(404);
// Display Error404 Page
require PAGES_BASEDIR.‘Error404.php’;
}[/php]

then calles a page
in this case Media
media.php is included to index.php
and then from here we are at ?page=media
[php]if (!empty($_GET[‘page’] == ‘media’) && ($_GET[‘id’] == ‘news’) > 0)
{
require MEDIA_BASEDIR.‘media_news.php’;
}
else if (!empty($_GET[‘page’] == ‘media’) && ($_GET[‘id’] == ‘announcements’) > 0)
{
require MEDIA_BASEDIR.‘media_announcements.php’;
}
else if (!empty($_GET[‘page’] == ‘media’) && ($_GET[‘id’] == ‘blueprints’) > 0)
{
require MEDIA_BASEDIR.‘media_blueprints.php’;
}
else if (!empty($_GET[‘page’] == ‘media’) && ($_GET[‘id’] == ‘off_topic’) > 0)
{
require MEDIA_BASEDIR.‘media_news_off_topic.php’;
} else {
require MEDIA_BASEDIR.‘media_announcements.php’;
require MEDIA_BASEDIR.‘media_news.php’;
require MEDIA_BASEDIR.‘media_blueprints.php’;
require MEDIA_BASEDIR.‘media_news_off_topic.php’;
}[/php]

Then, call some more content so ./pages/media/media_news.php will be included to ./pages/media.php
and we will then be at ?page=media&id=news
[php]

<?php // END OF SOME NEWS if (!empty($_GET['page'] == 'media') && ($_GET['id'] == 'news') > 0) { // START OF ALL NEWS ?>

Go Back... &nbsp&nbsp

<?php } else { echo '

All News... &nbsp&nbsp

'; } ?>[/php]

sorry for bad explaining

thankyou

Why are you including multiple pages within the same page instead of going directly to the page?

there not pages within pages, its pages and then in the pages hidden content until called but content could be a sub page because the content still gets a title

its all a work in progress that i cant progress on without stopping this error

thankyou

there is only one header and one footer etc… all the rest happens in the middle

That is exactly what the example link I gave you does but you said no. Did you even look at the source code of that page?

yes but i dont want to do it like that, sorry

i include my news etc on my homepage and IF the page is not called then only 1 news or 1 blueprint will be shown

i actualy said “sort of” - No offence.
thankyou

URL: index.php?page=media&id=news

In media.php
[php]<?php
if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘news’))
{
// news stuff
}
?>[/php]

thankyou i can actualy read it :slight_smile:

is this valid?
[php]

<?php if (isset($_GET['id']) && ($_GET['id'] == 'news')) { // news stuff } else if (isset($_GET['id']) && ($_GET['id'] == 'blueprints')) { // blueprint stuff } else { // default media } ?>[/php]

thankyou

whooo thankyou so much !!

here is the code with no error!
[php]<?php

if ( ! isset($_SERVER[‘HTTPS’])) {
header(‘Location: https://’ . $_SERVER[“SERVER_NAME”] . $_SERVER[‘REQUEST_URI’]);
}
//PAGE NAME

if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘announcements’))
{
$pagename = ‘Media - Announcements’;
}
else if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘blueprints’))
{
$pagename = ‘Media - Blueprints’;
}
else if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘off_topic’))
{
$pagename = ‘Media - Off Topic’;
}
else if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘news’))
{
$pagename = ‘Media - News’;
} else {
$pagename = ‘Media’;
}
//THEME HEADER
THEMEHEADER();

if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘news’))
{
require MEDIA_BASEDIR.‘media_news.php’;
}
else if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘announcements’))
{
require MEDIA_BASEDIR.‘media_announcements.php’;
}
else if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘blueprints’))
{
require MEDIA_BASEDIR.‘media_blueprints.php’;
}
else if (isset($_GET[‘id’]) && ($_GET[‘id’] == ‘off_topic’))
{
require MEDIA_BASEDIR.‘media_news_off_topic.php’;
} else {
require MEDIA_BASEDIR.‘media_announcements.php’;
require MEDIA_BASEDIR.‘media_news.php’;
require MEDIA_BASEDIR.‘media_blueprints.php’;
require MEDIA_BASEDIR.‘media_news_off_topic.php’;
}
//THEME FOOTER
THEMEFOOTER();

?>[/php]

sorry, im not easy to understand but im glad we got there in the end :slight_smile:

thankyou

Valid, but this is better. All your requires need to go in these if’s as well. You are unnecessarily duplicating code.
[php] <?php
if (isset($_GET[‘id’]))
{
if ($_GET[‘id’] == ‘news’)
{
require MEDIA_BASEDIR.‘media_news.php’;
$pagename = ‘Media - News’;
}

if ($_GET['id'] == 'blueprints')
    {
    // blueprint stuff
    }
}

else
{
// default media
}
?>[/php]

ahh i understand, i will edit my code and post back soon,

thankyou again!

;D thankyou it looks so much better now, much cleaner!

[php]<?php

if (!isset($_SERVER[‘HTTPS’])) {
header(‘Location: https://’ . $_SERVER[“SERVER_NAME”] . $_SERVER[‘REQUEST_URI’]);
}

if (isset($_GET[‘id’]))
{
if ($_GET[‘id’] == ‘news’)
{
// MEDIA NEWS
$pagename = ‘Media - News’;
THEMEHEADER();
require MEDIA_BASEDIR.‘media_news.php’;
}
if ($_GET[‘id’] == ‘blueprints’)
{
// MEDIA BLUEPRINTS
$pagename = ‘Media - Blueprints’;
THEMEHEADER();
require MEDIA_BASEDIR.‘media_blueprints.php’;
}
if ($_GET[‘id’] == ‘announcements’)
{
// MEDIA ANNOUNCEMENTS
$pagename = ‘Media - Announcements’;
THEMEHEADER();
require MEDIA_BASEDIR.‘media_announcements.php’;
}
if ($_GET[‘id’] == ‘off_topic’)
{
// MEDIA OFF TOPIC
$pagename = ‘Media - Off Topic’;
THEMEHEADER();
require MEDIA_BASEDIR.‘media_off_topic.php’;
}
}
else
{
// MEDIA
$pagename = ‘Media’;
THEMEHEADER();
require MEDIA_BASEDIR.‘media_announcements.php’;
require MEDIA_BASEDIR.‘media_news.php’;
require MEDIA_BASEDIR.‘media_blueprints.php’;
require MEDIA_BASEDIR.‘media_news_off_topic.php’;
}
THEMEFOOTER();

?>[/php]

thankyou

Still clustered, honestly. You remove the auto handling when you specify things like that.

Oh Jimbo, so close yet so far.

[php]$page = htmlentities($GET[‘page’]);
$subPage = htmlentities($GET[‘id’]);
if (file_exists(MEDIA_BASEDIR . "$page
$subPage.php")){
$pagename = ucfirst($page) . ’ - ’ . ucfirst($subPage);
THEMEHEADER();
include MEDIA_BASEDIR . "$page
$subPage.php";
}[/php]

Auto did…

so iv been going mad here trying to get this right haha
i see what you mean here is my edit…

[php]$MEDIA_ID = array(
// ACTIVE MEDIA
‘News’,
‘Announcements’,
‘Blueprints’,
‘Off_Topic’,
);

if (!isset($_GET[‘id’]))
{
// DEFAULT MEDIA
$pagename = $_GET[‘page’];
THEMEHEADER();
require MEDIA_BASEDIR.‘News.php’;
require MEDIA_BASEDIR.‘Announcements.php’;
require MEDIA_BASEDIR.‘Blueprints.php’;
require MEDIA_BASEDIR.‘Off_Topic.php’;
THEMEFOOTER();
}
else if (in_array($_GET[‘id’], $MEDIA_ID, true) && is_readable(MEDIA_BASEDIR.$_GET[‘id’].’.php’))
{
// DISPLAYS MEDIA ID
$pagename = $_GET[‘page’].’ - ‘.$_GET[‘id’];
THEMEHEADER();
require MEDIA_BASEDIR.$_GET[‘id’].’.php’;
THEMEFOOTER();
}
else
{
// ERROR404
http_response_code(404);
require PAGES_BASEDIR.‘Error404.php’;
}[/php]

is this any better?
im getting no errors here aswell…

thankyou

What is the entirety if the code?

index.php
[php]<?php

// Directory Of Page_Include

const INCLUDE_BASEDIR = DIR.’/page_include/’;
// Directory Of Pages
const PAGES_BASEDIR = DIR.’/pages/’;
// Directory Of Themes
const THEME_BASEDIR = DIR.’/themes/’;
// Directory Of Blocks
const BLOCKS_BASEDIR = DIR.’/page_include/blocks/’;
// Directory Of News
const MEDIA_BASEDIR = DIR.’/pages/media/’;

require_once INCLUDE_BASEDIR.'page_config.php';
require_once THEME_BASEDIR.'/'.$theme_name.'/theme.php';
require_once INCLUDE_BASEDIR.'page_blocks.php';

$PAGES = array(
// Array Of Active Pages
‘Media’,
‘Our_World’,
);

if (!isset($_GET[‘page’]))
{
// Default Index Page
require PAGES_BASEDIR.$DEFAULT_PAGE;
}
else if (in_array($_GET[‘page’], $PAGES, true) && is_readable(PAGES_BASEDIR.$_GET[‘page’].’.php’))
{
// Displays The Called Link
require PAGES_BASEDIR.$_GET[‘page’].’.php’;
}
else
{
http_response_code(404);
// Display Error404 Page
require PAGES_BASEDIR.‘Error404.php’;
}

?>[/php]

pages/media.php
[php]<?php

$MEDIA_ID = array(
// ACTIVE MEDIA
‘News’,
‘Announcements’,
‘Blueprints’,
‘Off_Topic’,
);

if (!isset($_GET[‘id’]))
{
// DEFAULT MEDIA
$pagename = $_GET[‘page’];
THEMEHEADER();
require MEDIA_BASEDIR.‘News.php’;
require MEDIA_BASEDIR.‘Announcements.php’;
require MEDIA_BASEDIR.‘Blueprints.php’;
require MEDIA_BASEDIR.‘Off_Topic.php’;
THEMEFOOTER();
}
else if (in_array($_GET[‘id’], $MEDIA_ID, true) && is_readable(MEDIA_BASEDIR.$_GET[‘id’].’.php’))
{
// DISPLAYS MEDIA ID
$pagename = $_GET[‘page’].’ - ‘.$_GET[‘id’];
THEMEHEADER();
require MEDIA_BASEDIR.$_GET[‘id’].’.php’;
THEMEFOOTER();
}
else
{
// ERROR404
http_response_code(404);
require PAGES_BASEDIR.‘Error404.php’;
}

?>[/php]

pages/media/Off_Topic.php
[php]

<?php $news_title = 'Off Topic Content'; $news_cat = 'Off&nbspTopic'; $news_date_time = ''; THEMENEWSTOP(); ?>

No Off Topic Content Here Yet!

<?php THEMENEWSBOTTOM(); ?> <?php // END OF SOME NEWS if (isset($_GET['id'])) { if ($_GET['id'] == 'Off_Topic') { // START OF ALL NEWS ?>

Go Back... &nbsp&nbsp

<?php } } else { echo '

All Off Topic... &nbsp&nbsp

'; } ?>[/php]

thankyou

Sponsor our Newsletter | Privacy Policy | Terms of Service