Jump to content
Killersites Community
Sign in to follow this  
Ant

changing parts of website pages that recur

Recommended Posts

I am about to begin laying out all my pages for a redesign of an existing site.

 

My plan,(as I thought it was done) is to take my home page and use that as a main template for every other page.

 

Right now my main idea is to have a navigation at the top with a 2 column layout beneath.

The left column is my main content area. The smaller right column is going to be used for NEW product highlights,etc

 

I want the new products right column to appear on the majority of my other pages.

 

My question is, how would I update the right column to reflect recent updates if they appear on multiple pages?

 

I cant imagine I would have to change each page individually.

 

I cant figure out how CSS would help me with CONTENT. I understand how I can use it to do overall changes to the fonts,color, etc of the site.... but content???

 

Actually now that I think about how would I change say, the logo in the header. I realize i could just change the logo and use the same name, but...

 

What if I wanted to add another DIV to the right column on every page?

 

 

 

 

Thanks

Ant

Share this post


Link to post
Share on other sites

CSS handles styling of the content, but not the content itself. For controlling the content, you'd want to use a server side programming language like PHP. Usually you'd do what you are trying to achieve using PHP includes.

 

Take a look here for more info/links: http://www.killersites.com/community/index.php?/topic/2648-updating-sidebar-and-footer-across-all-pages/

Share this post


Link to post
Share on other sites

Falken, thanks.

 

I'm not sure why, but it seems all the things I WANT to do with my FIRST website build is not as simple as CSS/HTML.

 

I have chosen a path for my design and that path seems to be the most complicated. Every turn I make keeps adding another scary language (PHP) ;)

 

 

 

Thanks

Ant

Share this post


Link to post
Share on other sites

PHP isn't all that scary, I promise. To use PHP includes, basically all you need to do is name your HTML files with the .php extension, and add the include line:

 

<?php include("filename.extension"); ?>

 

The filename.extension part is the path to the file that you want PHP to include.

 

Stef has a two part screencast on it (linked in the forum topic above) and http://www.tizag.com/phpT/include.php is also a good reference.

Share this post


Link to post
Share on other sites

Thanks Falken.

 

I am watching part 2.

 

The first part really showed how powerful it is to use the php include. That addresses my design needs perfectly.

 

So, would only the pages that use PHP need to be renamed .php?

 

Or should I just go ahead and name all my HTML pages that I create .php to prepare to possibly use PHP on all the pages?

 

Ant

Share this post


Link to post
Share on other sites
So, would only the pages that use PHP need to be renamed .php?

 

Or should I just go ahead and name all my HTML pages that I create .php to prepare to possibly use PHP on all the pages?

Technically, you only need to rename your files with the .php extension if you are using PHP code within them. However, I would suggest renaming them all -- it may save you time in the long run if you need to add PHP code later, and it'll be less confusing when linking various files if the extensions are consistent. Otherwise, you may waste time checking if the file ends in .php or .html.

Share this post


Link to post
Share on other sites

I want to add that at times - say for a redesign - renaming all the pages from .html to .php could be an issue. All internal and external links would suddenly need to be updated as well. An easy workaround is to leave the pages as html, but add a simple line to the .htaccess file that makes the browser read .html pages as .php.

 

I'd put this line here, but first, I don't remember and would have to google it, and second, I have learned that exactly HOW this line needs to be written can vary from server to server. So it's best to look for the detail on your server's help pages.

Share this post


Link to post
Share on other sites

I want to add that at times - say for a redesign - renaming all the pages from .html to .php could be an issue. All internal and external links would suddenly need to be updated as well. An easy workaround is to leave the pages as html, but add a simple line to the .htaccess file that makes the browser read .html pages as .php.

 

Good point. Here's on way to do that (though it may depend on the server setup) http://snippets.dzone.com/posts/show/459

Share this post


Link to post
Share on other sites

OK.

 

I got the example that Stefan outlined in the tutorial to work.

 

Whats weird is both files are .php My original index.html is now index.php. HOWEVER it also includes javascript and HTML ALONG with some PHP code thats a link to an external PHP file.

 

The external PHP file is just PHP.

 

Is that right?

 

 

So the extension PHP, covers files that have HTML, JAVASCRIPT etc. AND some that are JUST PHP??

 

 

How do I add my originally planned CSS style for my footer to my "footer include" PHP file?

Can I just link it inside the PHP file? That doesn't seem right.

 

 

 

 

Ant

Share this post


Link to post
Share on other sites
So the extension PHP, covers files that have HTML, Javascript etc. AND some that are JUST PHP??

Correct.

 

How do I add my originally planned CSS style for my footer to my "footer include" PHP file?

Can I just link it inside the PHP file? That doesn't seem right.

You'd do it as you would normally -- within the CSS file that you include within the <head> section of the page. The stylesheet will apply to the entire page, whether it uses includes or not.

Share this post


Link to post
Share on other sites

So even thought the HTML for my footer is no longer on my index.php page, my linked css still effects the linked PHP that has the html for the footer in it?

 

I assume the statement that "the HTML for my footer is not on my index.php page" is correct ?

 

Ant

Share this post


Link to post
Share on other sites
o even thought the HTML for my footer is no longer on my index.php page, my linked css still effects the linked PHP that has the html for the footer in it?

Correct.

 

The files may be physically separated on the server, but the browser only sees the complete rendered code. Even if you have multiple includes in your index.php file, the browser still understands that they all are part of the same page.

Share this post


Link to post
Share on other sites

Thanks Guys.

 

I got it working.

 

I have a question about file handling.

 

I have my files on a server, ONLY because I need them there so I can preview them with PHP funtionality

I have copies of those files (not the supporting graphics) on my desktop.

SO when I work on the local files all the images are missing. Personally thats a pain. I hate not being able to see the completed page.

 

I edit the files on my desktop USING DW and then drag and drop them onto the server. I preview them through a bookmark on my browsers.

 

Is that the best way to do things.

 

If I wasn't using PHP, I would create a folder on my desktop with ALL my files, then when i was done I would load all the files onto the server MINUS the original ROOT folder.

 

I think I can work on files that reside on the server through DW, but I'm not sure how that actually works. The last time I did that, DW asked if I wanted to IMPORT(or something like that) the supporting graphics. However i never knew where DW was storing those supporting files. Either way it just seemed to get complicated when i did that, especially with the file paths, etc.

 

 

Thanks

Ant

Share this post


Link to post
Share on other sites

You could put a copy of the images in a local folder to match the path you're using - or you could use an absolute path (http://www.toyourwebsite.com/....) so both the online and offline pages would display the online images.

Share this post


Link to post
Share on other sites

I don't know what's norm, but I view everything online only. I make my changes in Dreamweaver, save, put, and go see.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×