[solved]turning "posted in [category]" into a link

If you have any problems with Fusion News, post your problems here and we'll help you out as soon as possible.

[solved]turning "posted in [category]" into a link

Postby UndercoverAndrey » Fri Jan 01, 2010 11:04 pm

When editing templates, you use the {cat_name} tag to show the category name... so I'm guessing you have to go deeper into other files to turn it into a link (when clicked on goes to news in that category)

no clue where to even start to look
User avatar
UndercoverAndrey
FN User
 
Posts: 35
Joined: Thu Dec 24, 2009 11:18 pm

Re: turning "posted in [category]" into a link

Postby joshua.s.belanger » Mon Jan 04, 2010 3:20 pm

(moved into Help & Support)
---
The easiest way to do this is to make a page per category and name the page the same name as your category and put them in your website root NOT the FN folder. Example:

Categories:
1. General
2. News

Page:
1. youurl.com/general.php
2. yoururl.com/news.php

On each page just include on the category you want to include... For my examples I would have:

General.php:
Code: Select all
<?php

$fn_category = array (1);
include 'News/news.php';

?>


News.php:
Code: Select all
[code]<?php

$fn_category = array (2);
include 'News/news.php';

?>[/code]


To make the cat_name linked open functions.php

Inside find:
Code: Select all
$cat_name = $category['name'];

and replace with:
Code: Select all
$cat_name = '<a href="'. $category['name'] .'.php">'. $category['name'] .'</a>';


Now your cat name will link to each page...

Let me know if that works for you.
-Josh
User avatar
joshua.s.belanger
FN Follower
 
Posts: 249
Joined: Wed Jun 03, 2009 2:54 pm

Re: [solved]turning "posted in [category]" into a link

Postby UndercoverAndrey » Sat Jan 23, 2010 10:32 am

in the last part of the code, would it be possible to have the link not be the same name as the category, if that makes sense

some of my categories have commas and spaces in them, I'd like to avoid having file names formatted like that
User avatar
UndercoverAndrey
FN User
 
Posts: 35
Joined: Thu Dec 24, 2009 11:18 pm

Re: [solved]turning "posted in [category]" into a link

Postby Blackshadow » Sat Jan 23, 2010 11:42 am

In that case the easiest way would be to create a specialised file which expects the category ID in the URL (like show-category.php?category=2).

In your website's home directory, create a file called show_category.php. You can name this file anything you want, but in these instructions I'll refer to it as show_category.php. In this file, add this:
Code: Select all
<?php

$fn_category = isset ($_GET['category']) ? (int)$_GET['category'] : 0;
include 'news/news.php';

?>

Now any time you go to show_category.php?category=<category id>, where <category_id> is the category id, it will display only the news posts for that category.

In functions.php, find:
Code: Select all
$cat_name = $category['name'];

And replace with:
Code: Select all
$cat_name = '<a href="show_category.php?category='. $category['category_id'] .'">'. $category['name'] .'</a>';


Each category name should be linked to the show_category.php file now :)
~ Blackshadow
Fusion News Developer
User avatar
Blackshadow
Fusion News Developer
 
Posts: 1296
Joined: Tue Oct 17, 2006 8:10 pm
Location: UK

Re: [solved]turning "posted in [category]" into a link

Postby UndercoverAndrey » Sat Jan 23, 2010 10:02 pm

awesome, this is getting exactly where i want =]

one more thing

the category linking is working.. now I just need to have it open within my page and not on a separate one where you can't see the layout (if that makes sense)

so right now, it takes me to a page such as this:

http://www.clearnonsense.com/show_categ ... category=6

what I want it to do is open like this:

http://www.clearnonsense.com/index.php?id=tvfilm

(the pages in the second method are linked to from a category navigation on the website)


sorry if this is a pain in the ass
User avatar
UndercoverAndrey
FN User
 
Posts: 35
Joined: Thu Dec 24, 2009 11:18 pm

Re: [solved]turning "posted in [category]" into a link

Postby UndercoverAndrey » Sun Oct 24, 2010 12:56 pm

bumping this after a long time, because i still cant figure out the last question
User avatar
UndercoverAndrey
FN User
 
Posts: 35
Joined: Thu Dec 24, 2009 11:18 pm

Re: [solved]turning "posted in [category]" into a link

Postby Blackshadow » Sun Oct 24, 2010 11:15 pm

Unfortunately there's not really any easy way to do what you're asking. The reason is how do you associate the id 'tvshows' with the category id 6? The FN code needs to know about this association, but there's no way to tell FN about it. Hopefully FN4 will make it easier to do something along these lines, but it will be a long wait.
~ Blackshadow
Fusion News Developer
User avatar
Blackshadow
Fusion News Developer
 
Posts: 1296
Joined: Tue Oct 17, 2006 8:10 pm
Location: UK

Re: [solved]turning "posted in [category]" into a link

Postby UndercoverAndrey » Mon Oct 25, 2010 1:46 pm

/sigh


alright, thank you for your help though
User avatar
UndercoverAndrey
FN User
 
Posts: 35
Joined: Thu Dec 24, 2009 11:18 pm

Re: turning "posted in [category]" into a link

Postby dayara » Fri Jan 25, 2013 11:50 am

joshua.s.belanger wrote:(moved into Help & Support)
---
The easiest way to do this is to make a page per category and name the page the same name as your category and put them in your website root NOT the FN folder. Example:

Categories:
1. General
2. News

Page:
1. youurl.com/general.php
2. yoururl.com/news.php

On each page just include on the category you want to include... For my examples I would have:

General.php:
Code: Select all
<?php

$fn_category = array (1);
include 'News/news.php';

?>


News.php:
Code: Select all
[code]<?php

$fn_category = array (2);
include 'News/news.php';

?>[/code]


To make the cat_name linked open functions.php

Inside find:
Code: Select all
$cat_name = $category['name'];

and replace with:
Code: Select all
$cat_name = '<a href="'. $category['name'] .'.php">'. $category['name'] .'</a>';


Now your cat name will link to each page...

Let me know if that works for you.



Thanks a lot, i was looking for this.
I just needed one small tweek if that was possible.
Instead of linking the categories to {cat_name} is it possible to link it to {cat_icon}??
dayara
Newbie
 
Posts: 2
Joined: Wed Dec 12, 2012 4:38 pm


Return to Help and Support

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron