Jump to content

Can PHP make my life easier?


Recommended Posts

I'm in no way shape or form a savvy web programmer, but recently my fiancée wanted to start her own rabbitry. I offered to help with the website. After beginning the project of making her site I'm finding myself doing a lot of needless work that can be done more efficiently I'm sure.

A while back someone had showed me how to use php as a way to making life easier in regards to making little updates.

Here's her website HillTop Village Rabbitry so, you can at least see what I mean by what I'm asking.

The site requires updates quite frequently from the news posts on the front page to adding/removing links in the side/top navigation to adding photos on various pages.

This person that had showed me a way to basically edit/update one .php file would allow the updates to be made across the board. For example, if I had to edit one of the side or top navigation menus I currently have to edit each .html file individually, which I don't mind doing, but as I stated I'm doing needless work that I'm sure can be done much more efficiently.

Link to comment
Share on other sites


There's a number of approaches that you could take:

  • Consolidate the 6(?) separate pages into one PHP file (Using $_GET variables to switch between 'pages'), would still require manual editing of the source file for updates.
  • Use a CMS such as Wordpress, it looks pretty similar in layout and wouldn't be too difficult to create a theme to look similar
  • Learn PHP and design our own dynamic site with an Administration panel to update the relevant site areas.

Personally, Id choose the latter, as I love creating dynamic PHP projects; forums, blogs, bittorrent trackers, personal sites...

If you're not too hot on PHP, I'd probably recommend using Wordpress for ease.

Let us know how it goes...

http://www.hilltopvillagerabbitry.com/imag...oe_minirex1.jpg

Poor thing looks like it's being interrogated :D

Link to comment
Share on other sites

Ugh... that's a lot of redundant code. Converting that into a PHP based system would be very simple. You'd essentially just be cutting your 6 pages into...9 files - 6 content pages, a header, a sidebar, and a footer (that's how I organize my pages at least). If you need to update the header - you just edit header.php.

For example, this could be the general structure of one of your content pages

<?php include 'header.php'; ?>

<p>This is the main stuff in my page</p>

<?php
include 'sidebar.php';
include 'footer.php';
?>

I'm not saying that it would be exactly like that, but hopefully you get the idea. :)

Link to comment
Share on other sites

Ugh... that's a lot of redundant code. Converting that into a PHP based system would be very simple. You'd essentially just be cutting your 6 pages into...9 files - 6 content pages, a header, a sidebar, and a footer (that's how I organize my pages at least). If you need to update the header - you just edit header.php.

For example, this could be the general structure of one of your content pages

<?php include 'header.php'; ?>

<p>This is the main stuff in my page</p>

<?php
include 'sidebar.php';
include 'footer.php';
?>

I'm not saying that it would be exactly like that, but hopefully you get the idea. :)

For example, would the above code go into my index.html file?

<?php include 'header.php'; ?> is calling for my header.php file which contains everything above the side navagation menus and the post/news boxes?

<p>This is the main stuff in my page</p> is where my post/news boxes go?

include 'sidebar.php'; is calling for my side navigations menus

include 'footer.php'; is calling for anything posted below the side navigation and post/news boxes and copyright notice?

Link to comment
Share on other sites

For example, would the above code go into my index.html file?

<?php include 'header.php'; ?> is calling for my header.php file which contains everything above the side navagation menus and the post/news boxes?

<p>This is the main stuff in my page</p> is where my post/news boxes go?

include 'sidebar.php'; is calling for my side navigations menus

include 'footer.php'; is calling for anything posted below the side navigation and post/news boxes and copyright notice?

Like ripken said, it would be an index.php file. When a webserver sees an HTML file, it just sends it your way, and your browser deals with it. When a server reads a PHP file, it will parse that file as code to figure out how to generate the HTML code that is then sent to you.

And you got all the parts right. Now all you need to do is figure out where the "break points" for each support file is (header, etc). :)

Link to comment
Share on other sites

I've updated the website and all seems to be working fine. I've converted all my files to .php, is this fine? Whether, what I did is the way you more knowledgeable would have done it, probably not as I have messed something up or missed something. I have 15 pages that look like the following the only difference being the content.

<?php include 'header.php'; ?>

<div id="page">
...content of each of the 15 linked pages within the site...
</div>
<!-- end #content -->

<?php
include 'menu.php';
include 'footer.php';
?>

Here's my header.php

<div id="menu">
<ul>
<li class="active"><a href="index.php" accesskey="1" title="Home">Home</a></li>
<li><a href="funzone.php" accesskey="2" title="Fun Zone">Fun Zone</a></li>
<li><a href="photos.php" accesskey="3" title="Photos">Photos</a></li>
<li><a href="salespolicy.php" accesskey="4" title="Sales Policy">Sales Policy</a></li>
<li><a href="about.php" accesskey="5" title="About">About</a></li>
<li><a href="contact.php" accesskey="6" title="Contact">Contact Us</a></li>
</ul>
</div>
<!-- end #menu -->
<!-- Begin Code Amber Ticker code. -->
<div><center>
<p><script language="JavaScript1.2" src="http://www.codeamber.org/js/codea.js">
</script></p></center></div>
<!-- end of Code Amber Ticker code (c)Copyright codeamber.org 2002 - 2007-->
<div id="header">
<div id="logo">
<!-- <h1><a href="#"></a></h1> -->
<!-- <h2><a href="#"></a></h2> -->
</div>
<div id="banner"><!-- <a href="#"></a> --></div>
</div>
<!-- end #header -->
<br /><div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-3187705293081815";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-08-10: HomeTopLeaderboard, hilltopvillagerabbitry.com/
google_ad_channel = "3364369105+3513008004";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
google_ui_features = "rc:6";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>

Here's my menu.php

<div id="sidebar">
<ul>
<li>
<h2>Hop Around</h2>
<ul>
<li class="first"><a href="bbnursery.php">New Arrivals & Upcoming Births</a></li>
<li><a href="forsale.php">Rabbits for Sale</a></li>
<li><a href="wanted.php">Wanted Rabbits</a></li>
<li><a href="http://users3.smartgb.com/g/g.php?a=s&i=g35-01037-d2">Guestbook</a></li>
<li><a href="links.php">Links</a></li>
</ul>
</li>
<li>
<h2>Bunny Breeds</h2>
<ul>
<li class="first"><a href="dutch.php">Dutch</a></li>
<li><a href="minirex.php">Mini Rex</a></li>
<li><a href="netherlanddwarf.php">Netherland Dwarf</a></li>
<li><a href="silver.php">Silver</a></li>
</ul>
</li>
<li>
<h2>Bunny Boot Camp</h2>
<ul>
<li class="first"><a href="bunny411.php">Bunny 411</a></li>
</ul>
</li>
<li>
<h2>Advertising</h2>
<ul>
<li class="first"><script type="text/javascript"><!--
google_ad_client = "pub-3187705293081815";
google_ad_width = 180;
google_ad_height = 90;
google_ad_format = "180x90_0ads_al";
//2007-08-10: HomeTopLeaderboard, hilltopvillagerabbitry.com/
google_ad_channel = "3364369105+3513008004";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></li>
</ul>
</li>
</ul>
</div>
<!-- end #sidebar -->

Here's my footer.php

<div style="clear: both;"> </div>
</div>
<div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-3187705293081815";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
//2007-08-10: HomeTopLeaderboard, hilltopvillagerabbitry.com/
google_ad_channel = "3364369105+3513008004";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
google_ui_features = "rc:6";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<!-- end #page -->
<div id="footer">
<p id="legal">Copyright © 2007 HillTop Village Rabbitry.</p>
<p id="legal">All images are the property of their respective owner.</p>
</div>
<!-- end #footer -->

Link to comment
Share on other sites

Good stuff. I'm not sure if you had this before, but you can use some PHP functions to highlight the correct tab at the top of the page. In your header, you'll have to find out what the page that called it from was, and then highlight the appropriate tab. Not too difficult, and you should be able to find some guides online for a how-to. :)

Link to comment
Share on other sites

There's a number of approaches that you could take:
  • Consolidate the 6(?) separate pages into one PHP file (Using $_GET variables to switch between 'pages'), would still require manual editing of the source file for updates.
  • Use a CMS such as Wordpress, it looks pretty similar in layout and wouldn't be too difficult to create a theme to look similar
  • Learn PHP and design our own dynamic site with an Administration panel to update the relevant site areas.

Personally, Id choose the latter, as I love creating dynamic PHP projects; forums, blogs, bittorrent trackers, personal sites...

If you're not too hot on PHP, I'd probably recommend using Wordpress for ease.

Let us know how it goes...

http://www.hilltopvillagerabbitry.com/imag...oe_minirex1.jpg

Poor thing looks like it's being interrogated :D

nlitened you mentioned using a CMS such as Wordpress and I've looked at that one as my host supports it via an automatic install and the other was Movabletype, now my host doesn't mention support of this so whether that means it just doesn't support it via an automatic install like Wordpress or at all I am not sure.

My fiancee wants to be more involved without always relying on me (basically when I'm slacking is what shes sayin, lol) to update the website without any major editing of code. Would such an option - WP/MT offer her the ability to make a post and add a photo if need be without touching any code? How difficult would it be to turn the current site into a WP/MT site?

P.S. The rabbits are worse than children when getting photos taken, at least with children bribes work, sometimes, and I believe she may have been pregnant at that time. :D

Link to comment
Share on other sites

It sounds like Wordpress or another such CMS would be perfect for your situation. I can't really comment on MovableType as I have limited experience of it, but Wordpress seems to the bill, as it has a very user friendly interface. The only problem I can foresee, as you mentioned it, would be 'converting' your current site into Wordpress. You would need to add the content yourself, for each news item/category etc. Wordpress does have a handy backdating feature so continuity wouldn't be a problem.

At this point, I'd suggest you grab yourself a copy of XAMPP or similar webserver, install it on your computer and create the Wordpress version of your site offline. Once you're happy with the site, and your fiancée feels comfortable with it, just FTP the whole lot to your webspace, remember to backup your current one though ;)

Link to comment
Share on other sites

  • 2 weeks later...
It sounds like Wordpress or another such CMS would be perfect for your situation. I can't really comment on MovableType as I have limited experience of it, but Wordpress seems to the bill, as it has a very user friendly interface. The only problem I can foresee, as you mentioned it, would be 'converting' your current site into Wordpress. You would need to add the content yourself, for each news item/category etc. Wordpress does have a handy backdating feature so continuity wouldn't be a problem.

At this point, I'd suggest you grab yourself a copy of XAMPP or similar webserver, install it on your computer and create the Wordpress version of your site offline. Once you're happy with the site, and your fiancée feels comfortable with it, just FTP the whole lot to your webspace, remember to backup your current one though ;)

nlitened I've been tinkering with WP a little and I've come across an issue where WP seems to only allow me to create links to my other pages in a way that only allows me to display my links in one section not for example a top menu and a side menu.

Many of the WP themes have a top menu, but if I add the page widget I think it's called then I'm just displaying whatever links I have already that are appearing on the top menu now on the side menu.

What I'm trying to ask is there a way to organize my links in any WP theme so that it appears similar to the way my current site is where I have some links on the top menu and then separate links on the side menu?

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...