UtopiaSoftware Forums

Full Version: Only category in news
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It's possible to show only category in my news?, how?. For example, I would like to show one category (for example car) in my page car.php, category trucks in my page trucks.php, etc. Thank you.
This is possible. You would need to make copies of news.php, and call them news-cars.php, news-trucks.php, etc, and simply modify the queries. If you want me to be more specific, tell me what categories you have and what the category ID of each one is.

To tell what the ID for a category is, hover over the links next to it in the categories page and note the number at the end of the URL.

Brian Wrote:
This is possible. You would need to make copies of news.php, and call them news-cars.php, news-trucks.php, etc, and simply modify the queries. If you want me to be more specific, tell me what categories you have and what the category ID of each one is.

To tell what the ID for a category is, hover over the links next to it in the categories page and note the number at the end of the URL.

In my news I have many categories. ¿It's possible to add any code in my news.php (for example, news.php?car, news.php?truck) to show that category that I want?. Thank you.

It is possible, though the way page-including in general works, it will only be effective with PHP includes or iframes.

Anyway, in news.php, you could find:

PHP Code:
isset($_GET['action']) ? $action $_GET['action'] : $action ''

And add below it:

PHP Code:
if (!isset($urlGetCat))
{
isset(
$_GET['category']) ? $urlGetCat $_GET['category'] : $urlGetCat '';


And then in news.php

Find:

PHP Code:
$getnews $DB->query("SELECT * FROM `unp_news` ORDER BY `date` DESC LIMIT $newslimit"); 


Replace with:

PHP Code:
$getnews $DB->query("SELECT * FROM `unp_news` WHERE `catid`='$urlGetCat' ORDER BY `date` DESC LIMIT $newslimit"); 


Now, if you are using frames, just include news.php?category=categorynumber, replacing categorynumber for each instance. If you are using PHP includes, link to your page as normal and add ?category=categorynumber to the link.

Let me know if anything is unclear.

Brian Wrote:
It is possible, though the way page-including in general works, it will only be effective with PHP includes or iframes.

Anyway, in news.php, you could find:

PHP Code:
isset($_GET['action']) ? $action $_GET['action'] : $action ''

And add below it:

PHP Code:
if (!isset($urlGetCat))
{
isset(
$_GET['category']) ? $urlGetCat $_GET['category'] : $urlGetCat '';


And then in news.php

Find:

PHP Code:
$getnews $DB->query("SELECT * FROM `unp_news` ORDER BY `date` DESC LIMIT $newslimit"); 


Replace with:

PHP Code:
$getnews $DB->query("SELECT * FROM `unp_news` WHERE `catid`='$urlGetCat'[/B] ORDER BY `date` DESC LIMIT $newslimit"); 


Now, if you are using frames, just include news.php?category=categorynumber, replacing categorynumber for each instance. If you are using PHP includes, link to your page as normal and add ?category=categorynumber to the link.

Let me know if anything is unclear.


I have this error (I have intalled News Illustrated)

Code:
Database error in Utopia News Pro:

Invalid SQL Query: SELECT * FROM `unp_news` WHERE `catid`=''[/B] ORDER BY `date` DESC LIMIT 10
MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[/B] ORDER BY `date` DESC LIMIT 10' at line 1

MySQL Error Number: 1064

Date: September 27, 2007 12:27 PM
Script: /

Recopy the last line of code I gave and try again. There was a typo in it.
It doesn't work. Not show anything. Thank you.
Can you give me a link to the page your news is being displayed on, and tell me the URL to NewsPro itself? I think all the code is in place to make this work now, and it's just a question of implementation.
Brian, You are super. Thanks very much. I edited my script for the categories and it worked!!!
That's great to hear. Smile
Reference URL's