LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-29-2011, 02:03 PM   #1
portia
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 112

Rep: Reputation: 20
websites - news page(s)


I'm doing a website for somebody. One of the pages contains news. The most recent news should be at the top of the page. As there are a lot of news entries (one entry per month over the last 4 years), the page would be extremely long so it's better to split it into a few pages (news.html, news1.html, etc.) The problem is that if I need to update it with new info (which would go at the top, I'd have to update all the pages as well, which makes it a very inefficient solution.

How would I go about solving this problem? I'm sure there's some solutions. Perhaps PHP or jquery?

I'd appreciate pointing me in the right direction.
 
Old 05-29-2011, 02:09 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Use Wordpress to build the website. It gives you that for free.

Last edited by dugan; 05-29-2011 at 02:10 PM.
 
Old 05-29-2011, 02:11 PM   #3
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Rep: Reputation: 19
I would use PHP and MySQL pull the news items from a database ordering chronologically.
You can limit the number news stories on each page using LIMIT and add a next link to pull down the next n queries to fill the page.

You would need:

One input form
One Edit form
1 MySQL database.

That would do it.

Last edited by hyperhead; 05-29-2011 at 02:12 PM.
 
Old 05-29-2011, 02:11 PM   #4
portia
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 112

Original Poster
Rep: Reputation: 20
But it's just one of the subpages. Would it make sense to install a content management system just for that?

---------- Post added 05-29-11 at 02:12 PM ----------

Quote:
Originally Posted by hyperhead View Post
I would use PHP and MySQL pull the news items from a database ordering chronologically.
You can limit the number of queries and add a next link to pull down the next n queries to fill the page.

You would need:

One input form
One Edit form
1 MySQL database.

That would do it.
Sorry, could you elaborate on it? I'm a beginner when it comes to PHP.
 
Old 05-29-2011, 02:22 PM   #5
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Rep: Reputation: 19
Connecting PHP to a MySQL database is pretty easy.

You could pretty much achieve this in one page.

Read this tutorial about breaking up data over pages.

http://www.phpjabbers.com/php--mysql...ges-php25.html

This would give you an idea of the level of work needed (not much)

If however you are not familiar with PHP MySQL, it may take longer.
 
1 members found this post helpful.
Old 05-29-2011, 02:23 PM   #6
portia
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 112

Original Poster
Rep: Reputation: 20
Thanks, I'll look into it.
 
Old 05-29-2011, 02:35 PM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by portia View Post
But it's just one of the subpages. Would it make sense to install a content management system just for that?
Yes, of course it would. You would use the CMS to build the rest of the site too.
 
Old 05-29-2011, 02:38 PM   #8
portia
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 112

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by dugan View Post
Yes, of course it would. You would use the CMS to build the rest of the site too.
The problem is that I spent a lot of time creating this website from scratch (html/css/jquery). I wouldn't want to
just throw it away and start with CMS.
 
Old 05-29-2011, 03:10 PM   #9
portia
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 112

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by hyperhead View Post
Connecting PHP to a MySQL database is pretty easy.

You could pretty much achieve this in one page.

Read this tutorial about breaking up data over pages.

http://www.phpjabbers.com/php--mysql...ges-php25.html

This would give you an idea of the level of work needed (not much)

If however you are not familiar with PHP MySQL, it may take longer.
One more question: how would I initially (and at a later time) populate the database?
 
Old 05-29-2011, 04:07 PM   #10
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by portia View Post
One more question: how would I initially (and at a later time) populate the database?
Excellent question. The answer is that you would have to create forms into which website content could entered. You would also have to create form handlers (in PHP, or in whichever language you are using for the backend) to transfer the data from the posted forms into the database. And you would have to design and build a database to support the functionality you need. Once you've designed and built all this, you've already written a CMS.

Now, I'd like to go back to an earlier point you made:

Quote:
Originally Posted by portia View Post
But it's just one of the subpages. Would it make sense to install a content management system just for that?
I'm going to turn this around. Why would it not be worth it to install a CMS just for that?

If you want to use Wordpress for the rest of your site and not just news, you would have to convert your existing work into a Wordpress theme (and, probably, the Javascript into Wordpress plugins). This is not trivial, but it's not as hard as it sounds. For example, you can keep all of your existing CSS. Your jQuery files would work the same way (and most likely would just need to be repackaged). You just need to write the PHP in the theme to generate the HTML that you have in your current site. It's not any more difficult than the alternative that has been proposed, and it's much more likely to be consistent with database design and security best practices (because those are taken care of for you).

Last edited by dugan; 05-29-2011 at 04:13 PM.
 
Old 05-29-2011, 04:13 PM   #11
hyperhead
Member
 
Registered: Mar 2011
Location: UK
Distribution: Slackware-14.2
Posts: 117

Rep: Reputation: 19
There would be the need for a bit of scripting to get the initial data into the database.

Would basically have to wrap SQL syntax around the content and insert in.

Could be done via MySQL client (do you have SSH access to webserver??) or perhaps PHPMyAdmin if it was installed Then it would be a case of cutting and pasting the inserts or uploading a text file.

Alternatively Im sure a PHP script to upload a whole file of inserts could be found.

Last edited by hyperhead; 05-29-2011 at 04:14 PM.
 
Old 05-29-2011, 04:18 PM   #12
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by portia View Post
The most recent news should be at the top of the page. As there are a lot of news entries (one entry per month over the last 4 years), the page would be extremely long so it's better to split it into a few pages (news.html, news1.html, etc.)
The best solution depends on what you already use, and how you maintain the news content.

One possibility often overlooked is to keep each news entry (the HTML code) in a separate file, with the file name being the search key, with all news files in a dedicated directory. Then you can use a scripting language to pull the HTML news fragment(s) into the page content.

If you want to use client-side Javascript, you can use for example a hidden iframe to load news fragment files, then using DHTML to copy the content HTML to the news pane. This lets you format the news HTML as a complete page, while only using some element of it for the actual display.

If you display news monthly, I recommend you name the HTML news entry files YYYY-M-I.html, where YYYY is the year (2011), M is the month (0 to 11), and I is the index, 1 for the first entry of each month, 2 for a second entry in the same month, and so on; and put them in a dedicated directory. That way you can use the Date object to easily construct the URLs for each news entry. To get the data for each month, start at index 1. If the load succeeds, save the data, and try index 2. If that too succeeds, prepend that to the saved data (so newer news are displayed first), and try the next index, until the load fails. Then, you have the complete data for that month.

Hope this helps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Dynamic Content - News Summary Page - II LXer Syndicated Linux News 0 09-18-2008 02:00 PM
LXer: Dynamic Content - News Summary Page LXer Syndicated Linux News 0 09-08-2008 04:50 PM
computer news/reviews websites sycamorex General 2 11-18-2007 05:14 PM
getting the kontact summary page to display akregator news fibbi Linux - Software 1 09-03-2004 01:41 PM
news on the firts page nakkaya LQ Suggestions & Feedback 3 02-21-2003 09:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration