What's new

Any web expert here? Need help!

MRSN

T20I Star
Joined
Oct 20, 2010
Runs
30,597
I'm working on a project for a news site. so I have an index page full of headlines. The problem comes when I have to load full article. Since I have not done this before so I am not sure what is the right way to handle this. What I am guessing is that I should create a dynamic page which should be initially empty and when the user clicks on a news headline on index page the empty page should retrieve title and detail from the database based on the id passed to this page. is this the right way? Any help would be great.:fz
 
Last edited:
I'm working on a project for a news site. so I have an index page full of headlines. The problem comes when I have to load full article. Since I have not done this before so I am not sure what is the right way to handle this. What I am guessing is that I should create a dynamic page which should be initially empty and when the user clicks on a news headline on index page the empty page should retrieve title and detail from the database based on the id passed to this page. is this the right way? Any help would be great.:fz

What you need is an API which you will make a request to using a web service. Something like below:

https://newsapi.org/

What's the web framework your application is based on?
 
What you need is an API which you will make a request to using a web service. Something like below:

https://newsapi.org/

What's the web framework your application is based on?
just bootstrap at the moment.

API won't work since there is a lot of content that won't be there in the API I guess.
 
just bootstrap at the moment.

API won't work since there is a lot of content that won't be there in the API I guess.

If you want to load dynamic content to your page, you have no other choice but to use an API unless you have a service of your own to load news content from.
There are plenty of APIs you can find online for free that will give you news content including title, image, description etc. You can display them dynamically using AJAX.
 
If you want to load dynamic content to your page, you have no other choice but to use an API unless you have a service of your own to load news content from.
There are plenty of APIs you can find online for free that will give you news content including title, image, description etc. You can display them dynamically using AJAX.

what do you mean by service? API won't work for me since I have to include a lot of custom stuff especially local which I won't find in the APIs.
 
I'm working on a project for a news site. so I have an index page full of headlines. The problem comes when I have to load full article. Since I have not done this before so I am not sure what is the right way to handle this. What I am guessing is that I should create a dynamic page which should be initially empty and when the user clicks on a news headline on index page the empty page should retrieve title and detail from the database based on the id passed to this page. is this the right way? Any help would be great.:fz

Do you want a single page application? Or PP like site where people can click links and navigate to related page?

If you want single page application, try using ReactJS.
 
Do you want a single page application? Or PP like site where people can click links and navigate to related page?

If you want single page application, try using ReactJS.

Vue.js > React. I'm a Laravel guy. :yk
 
just bootstrap at the moment.

API won't work since there is a lot of content that won't be there in the API I guess.

Why don't you just create your own RESTful API on the backend?
 
If i remember correctly from one of your past thread thn i guess you are trying to do this with PHP+MySQL?

Save all the news articles with a unique ID in your DB. Link all those headlines with unique dynamic URLs based on that unique ID and you don't need to create a separate page you can use your index page just make sure to use a condition to see if an ID was in URL so if there was a ID and that ID exist in the DB thn show the news content with that ID instead of the headlines index page.

For example look at this example URL http://www.yourdomain.com/?n=110 now all you need is to extract the ID from URL using $_GET and thn search the database for the news article with that ID and show the content of that article on the page. You can also make the URLs look pretty by using URL rewriting so that the URLs looks friendly and pretty for example http://www.yourdomain.com/my-news-article/ instead of http://www.yourdomain.com/?n=110
 
Last edited:
If i remember correctly from one of your past thread thn i guess you are trying to do this with PHP+MySQL?

Save all the news articles with a unique ID in your DB. Link all those headlines with unique dynamic URLs based on that unique ID and you don't need to create a separate page you can use your index page just make sure to use a condition to see if an ID was in URL so if there was a ID and that ID exist in the DB thn show the news content with that ID instead of the headlines index page.

For example look at this example URL http://www.yourdomain.com/?n=110 now all you need is to extract the ID from URL using $_GET and thn search the database for the news article with that ID and show the content of that article on the page. You can also make the URLs look pretty by using URL rewriting so that the URLs looks friendly and pretty for example http://www.yourdomain.com/my-news-article/ instead of http://www.yourdomain.com/?n=110

Vanilla PHP sucks. It's all about frameworks now.
 
Vanilla PHP sucks. It's all about frameworks now.

Yea but i think he is learning PHP that's what i understand from his similar past threads here that's why i suggested this method. He can also use CMS platforms for his news site to make things easy.
 
Vue.js > React. I'm a Laravel guy. :yk

Recently started learning vue js after Facebook changed license for React adding potential risk of revoking it in future. Although there are alternatives to react js like Preact which work quite well, it is not possible to ensure it works for all implementations. For ex - I was using it with google maps library of react and there were some issues with fitting the boundaries.

I use it with mainly Django framework.
 
Do you want a single page application? Or PP like site where people can click links and navigate to related page?

If you want single page application, try using ReactJS.

no it's definitely multi pages overall but I do need only one page to load all the news content. Do you think it's applicable in this scenario?I have never tried it before so I don't have any experience.
 
no it's definitely multi pages overall but I do need only one page to load all the news content. Do you think it's applicable in this scenario?I have never tried it before so I don't have any experience.

What do you want to use alongwith bootstrap? Your problem is simple, but has multiple solutions and depends on which technology you're comfortable with and planning to use.
 
If i remember correctly from one of your past thread thn i guess you are trying to do this with PHP+MySQL?

Save all the news articles with a unique ID in your DB. Link all those headlines with unique dynamic URLs based on that unique ID and you don't need to create a separate page you can use your index page just make sure to use a condition to see if an ID was in URL so if there was a ID and that ID exist in the DB thn show the news content with that ID instead of the headlines index page.

For example look at this example URL http://www.yourdomain.com/?n=110 now all you need is to extract the ID from URL using $_GET and thn search the database for the news article with that ID and show the content of that article on the page. You can also make the URLs look pretty by using URL rewriting so that the URLs looks friendly and pretty for example http://www.yourdomain.com/my-news-article/ instead of http://www.yourdomain.com/?n=110

yes I'm using PHP to load news from database. Thanks. That's what I was thinking but I was not sure if it was the right way.

one more thing, would searching for a news article on my site from google and clicking it load it same way?
 
What do you want to use alongwith bootstrap? Your problem is simple, but has multiple solutions and depends on which technology you're comfortable with and planning to use.

at the moment I'm using PHP and MySQL for backend with bootstrap for front end. nothing else.
 
are you saying with Reactjs I won't need to use PHP?

I'm not saying that. React is a JavaScript framework, but PHP has it's own frameworks also such as Laravel and Symphony. With Laravel being the most popular one out there. It just makes writing code so much better.

https://laravel.com
 
I'm not saying that. React is a JavaScript framework, but PHP has it's own frameworks also such as Laravel and Symphony. With Laravel being the most popular one out there. It just makes writing code so much better.

https://laravel.com

Thanks. I will look into it. I have not tried php frameworks before. Does these frameworks require great knowledge or intermediate knowledge would be good enough?
 
yes I'm using PHP to load news from database. Thanks. That's what I was thinking but I was not sure if it was the right way.

one more thing, would searching for a news article on my site from google and clicking it load it same way?

Yes and just make sure to generate a sitemap.xml based on all those dyanmic URLs and submit it in Google Webmaster Central for better crawling.
 
Back
Top