I just wanted to let know I figured out my last issue (last as in, for now).
In my navigation.php include file, I had if ($page = about) echo href
I changed it to if ($page == about) echo and it suddenly worked! Imagine
that...
Thanks all for you help, you are celebrities in my book now.
On Wed, Aug 5, 2009 at 1:44 PM, Martin Scotta wrote:
> You are using a value-filled array as a key-filled. Try this snippet
> and look the results...
>
> $pages = array('about' , 'services', 'portfolio', 'contact');
> $page = array_key_exists( 'page', $_GET ) ? $_GET[ 'page' ] : 'about';
> /*if*/ false === array_search( $page, $pages, true ) && (
>$page = 'about'
> );
>
> # note the sintax used to avoid if-statement
> # this has the same behaviour, but with less performance
> $pages = array('about' , 'services', 'portfolio', 'contact');
> $page = array_key_exists( 'page', $_GET ) ? $_GET[ 'page' ] : 'about';
> if( false === array_search( $page, $pages, true ))
> {
>$page = 'about';
> }
>
>
>
> On Wed, Aug 5, 2009 at 5:36 PM, Allen McCabe wrote:
> > Okay, I see how href="?page=contact" would work, and I do indeed have
> only
> > one file (which loads includes), but it still is not working. Clicking a
> > link, be href=?page=contact, href=?page=services, whatever, it still
> loads
> > the page with the ?page=whatever attached to the URL, but it is not
> > subsituting the $page variable within the include snippets, and it just
> > loads the 'about' versions of all includes
> (/phpincludes/about_content.php
> > as opposed to /phpincludes/services_content.php or whichever).
> >
> > This is really stumping me and try as I might I cannot see why it will
> not
> > work. Here is some of my code as it is currently:
> >
> > On default.php:
> >
> > [code=default.php]
> >
> >
> >
> > >
> > $pages = array(
> > // list of includes:
> > 'about' , 'services', 'portfolio', 'contact'
> > );
> > $page = isset($_GET['page']) && isset($pages[$_GET['page']]) ?
> > $_GET['page'] : 'about';
> > // about is default page here
> >
> > ?>
> >
> >
> > [/code]
> >
> > then in the body tags
> >
> > [code=default.php]
> >
> >
> >
> >
> >
> >
> > [/code]
> > [code=nav2.php]
> >
> > SERVICES
> >
> > [/code]
> >
> > It is surprisingly little code and I am starting to wonder if any php
> > settings on my server are inhibiting this. What do you think?
> >
> >
> >
> > 2009/8/5 ollisso
> >
> >> On Wed, 05 Aug 2009 22:08:30 +0300, Allen McCabe >
> >> wrote:
> >>
> >> You can do something like that:
> >>
> >> links:
> >> Contact
> >>
> >> This will work if you have only one file, all the time and it is default
> >> one for current folder. (normally that is index.php, might be
> default.php in
> >> your case)
> >>
> >> Second option is to use more harder approach:
> >>
> >> $pos=
> >>
> min(strpos($_SERVER['QUERY_STRING'],'&'),strpos($_SERVER['QUERY_STRING'],'='));
> >> $act= ($pos!==false) ? substr($_SERVER['QUERY_STRING'], 0, $pos) :
> >> $_SERVER['QUERY_STRING'];
> >> $page = strtolower($act);
> >>
> >> then you can use links like:
> >> href='?contact'
> >> or if you need:
> >> href='?contact=1' (in case of GET forms)
> >>
> >>
> >> Third option is to use mod_rewrite, but this is slightly harder :)
> >>
> >> But then you will be able to use links like:
> >> www.domain.com/contact/
> >> (which will work like: index.php?page=contact internally)
> >>
> >> About checking what is included:
> >> Imagine following scenario:
> >>
> >> $page = isset($_GET['page']) ? $_GET['page'] : 'about';
> >>
> >> include 'modules/'.$page.'.php';
> >>
> >> Problem here is that you can include ANY file.
> >> For example:
> >> ?page=../index
> >> will work as:
> >> include 'modules/../index.php';
> >>
> >> Which is crearly not what is intended.
> >>
> >> There is also much more dangerous scenarios of this.
> >>
> >> I hope this explains something :)
> >>
> >>
> >>
> >> Excellent, your snippet is working nicely. Thank you!
> >>>
> >>> Unfortunately, when I click a link ( http://uplinkdesign.hostzi.com/default.php?page=contact";> ),
> >>> deafult.php?contact shows in the browser, but the default (about)
> content
> >>> is
> >>> loading.
> >>>
> >>> Also, I don't know what you mean by checking what is included.
> >>>
> >>> 2009/8/5 ollisso
> >>>
> >>> On Wed, 05 Aug 2009 20:19:00 +0300, Allen McCabe <
> allenmcc...@gmail.com>
> wrote:
>
> Sure.
>
> >
> > When I load my site, default.php loads ( displaying:
> > http://uplinkdesign.hostzi.com/ in the browser as expected).
> $thisPage
> > is
> > set to "about" via:
> >
> > > if (!isset($thisPage)) {
> > $thisPage="about";
> > } else {
> > $thisPage = addslashes($_GET['page']);
> > }
> > ?>
> >
> > in the tags.
> >
> >
> > I am seeing this:
> >
> > The first 2 includes work just fine, loading to proper middle section
> > and
> > proper right-hand-side page content, the naviga