automatic page nav change
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
I don't know if this was answered adequately, but I think I have a better way to come about this after reading the first four posts.
Here is how I would do it... (The code looks a lot better if you download it and open it with Notepad or Notepad++ or something).
I don't really understand what you mean by other questions you had, but I think that this should help you out a little.
The CSS in the PHP thing should be used to over-ride the css written in the actual stylesheet... unless you want to use this way as the main way. Your choice.
Hope that this helped you out a bit
Here is how I would do it... (The code looks a lot better if you download it and open it with Notepad or Notepad++ or something).
PHP Code: [ Select ]
<?php
// Page name
$page_name = ltrim($_SERVER["PHP_SELF"],'/');
$page_name = rtrim($page_name,'.php');
// Default footer text
$footer = '© 2010 Melted, LLC';
/*
The pages...
You could have different things for different pages...
like what I got going with 'css' and 'title' for each page.
That could be useful for things like javascript and other things
that are page specific or things that other pages just don't need.
I'm expecting here that each page would have it's own CSS and title
element, so I coded in the process after the array that processes
those things. If you are going to have something that is page
specific and wouldn't be defined or neccessary to define elsewhere,
you could use a conditional statement like I did with 'footer' and
'image'.
*/
$pages = array(
'index' => array('css' => '#div_name' => array('background-color' => '#fc0000',
'font-color' => '#000000'
),
'div[class].active_pages' => array('float' => 'right'
),
'title' => 'Page Title for Index'
),
'contact' => array('css' => 'p' => array('background-color' => '#fc0000',
'font-color' => '#000000'
),
'title' => 'Page Title for Contact',
'image' => '<img src="path/to/img.png" alt="An image" />' // This would be written into the HTML part of the code... no need for additional PHP
),
'guestbook' => array('css' => 'span#name' => array('background-color' => '#fc0000',
'font-color' => '#000000'
),
'title' => 'Page Title for Guestbook',
'footer' => 'Driven by Bigwebmaster © 2010 Bigwebmaster.com',
)
);
// Getting the page title for the pages
$page_title = (isset($pages[$page_name]['title'])) ? $pages[$page_name]['title'] : 'Welcome';
// Generating the CSS for this page
$css = null;
foreach($pages[$page_name]['css'] as $css_element => $css_components)
{
$css .= $css_element . ' {\n';
foreach($css_components as $css_rule => $css_value)
{
$css .= " {$css_rule}: {$css_value};\n";
}
$css .= '}\n\n';
}
$css = trim($css);
// Generating the footer
$footer = (isset($pages[$page_name]['footer'])) ? $pages[$page_name]['footer'] : $footer;
?>
// Page name
$page_name = ltrim($_SERVER["PHP_SELF"],'/');
$page_name = rtrim($page_name,'.php');
// Default footer text
$footer = '© 2010 Melted, LLC';
/*
The pages...
You could have different things for different pages...
like what I got going with 'css' and 'title' for each page.
That could be useful for things like javascript and other things
that are page specific or things that other pages just don't need.
I'm expecting here that each page would have it's own CSS and title
element, so I coded in the process after the array that processes
those things. If you are going to have something that is page
specific and wouldn't be defined or neccessary to define elsewhere,
you could use a conditional statement like I did with 'footer' and
'image'.
*/
$pages = array(
'index' => array('css' => '#div_name' => array('background-color' => '#fc0000',
'font-color' => '#000000'
),
'div[class].active_pages' => array('float' => 'right'
),
'title' => 'Page Title for Index'
),
'contact' => array('css' => 'p' => array('background-color' => '#fc0000',
'font-color' => '#000000'
),
'title' => 'Page Title for Contact',
'image' => '<img src="path/to/img.png" alt="An image" />' // This would be written into the HTML part of the code... no need for additional PHP
),
'guestbook' => array('css' => 'span#name' => array('background-color' => '#fc0000',
'font-color' => '#000000'
),
'title' => 'Page Title for Guestbook',
'footer' => 'Driven by Bigwebmaster © 2010 Bigwebmaster.com',
)
);
// Getting the page title for the pages
$page_title = (isset($pages[$page_name]['title'])) ? $pages[$page_name]['title'] : 'Welcome';
// Generating the CSS for this page
$css = null;
foreach($pages[$page_name]['css'] as $css_element => $css_components)
{
$css .= $css_element . ' {\n';
foreach($css_components as $css_rule => $css_value)
{
$css .= " {$css_rule}: {$css_value};\n";
}
$css .= '}\n\n';
}
$css = trim($css);
// Generating the footer
$footer = (isset($pages[$page_name]['footer'])) ? $pages[$page_name]['footer'] : $footer;
?>
- <?php
- // Page name
- $page_name = ltrim($_SERVER["PHP_SELF"],'/');
- $page_name = rtrim($page_name,'.php');
- // Default footer text
- $footer = '© 2010 Melted, LLC';
- /*
- The pages...
- You could have different things for different pages...
- like what I got going with 'css' and 'title' for each page.
- That could be useful for things like javascript and other things
- that are page specific or things that other pages just don't need.
- I'm expecting here that each page would have it's own CSS and title
- element, so I coded in the process after the array that processes
- those things. If you are going to have something that is page
- specific and wouldn't be defined or neccessary to define elsewhere,
- you could use a conditional statement like I did with 'footer' and
- 'image'.
- */
- $pages = array(
- 'index' => array('css' => '#div_name' => array('background-color' => '#fc0000',
- 'font-color' => '#000000'
- ),
- 'div[class].active_pages' => array('float' => 'right'
- ),
- 'title' => 'Page Title for Index'
- ),
- 'contact' => array('css' => 'p' => array('background-color' => '#fc0000',
- 'font-color' => '#000000'
- ),
- 'title' => 'Page Title for Contact',
- 'image' => '<img src="path/to/img.png" alt="An image" />' // This would be written into the HTML part of the code... no need for additional PHP
- ),
- 'guestbook' => array('css' => 'span#name' => array('background-color' => '#fc0000',
- 'font-color' => '#000000'
- ),
- 'title' => 'Page Title for Guestbook',
- 'footer' => 'Driven by Bigwebmaster © 2010 Bigwebmaster.com',
- )
- );
- // Getting the page title for the pages
- $page_title = (isset($pages[$page_name]['title'])) ? $pages[$page_name]['title'] : 'Welcome';
- // Generating the CSS for this page
- $css = null;
- foreach($pages[$page_name]['css'] as $css_element => $css_components)
- {
- $css .= $css_element . ' {\n';
- foreach($css_components as $css_rule => $css_value)
- {
- $css .= " {$css_rule}: {$css_value};\n";
- }
- $css .= '}\n\n';
- }
- $css = trim($css);
- // Generating the footer
- $footer = (isset($pages[$page_name]['footer'])) ? $pages[$page_name]['footer'] : $footer;
- ?>
I don't really understand what you mean by other questions you had, but I think that this should help you out a little.
The CSS in the PHP thing should be used to over-ride the css written in the actual stylesheet... unless you want to use this way as the main way. Your choice.
Hope that this helped you out a bit
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
April 6th, 2010, 7:09 pm
- SB
- Moderator


- Joined: Nov 16, 2004
- Posts: 8670
- Loc: Aberdeen, Scotland
- Status: Offline
The sooner i get this site out of the way the better. I really don't understand what you have just typed Bogey, so trying to work that into the code i currently have is proving to be a bit more irritating than i would like...which is not your fault.
I am very tempted to create a topic in the marketplace forum advertising this site as a job. It may be simple to everyone else but it's just way beyond me and the lack of time i have to actually complete it is also proving to be a pain in the ass.
Thanks for your help Spoof & Bogey.
I am very tempted to create a topic in the marketplace forum advertising this site as a job. It may be simple to everyone else but it's just way beyond me and the lack of time i have to actually complete it is also proving to be a pain in the ass.
Thanks for your help Spoof & Bogey.
1, 2
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 17 posts
- Users browsing this forum: Kurthead+1 and 168 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
