News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Link directly to forum category?

Started by NoRad, October 30, 2005, 07:07:30 AM

Previous topic - Next topic

NoRad

I'm assimilating another local community website into our site. I created a category for them with a few sub-boards. I want to have their existing URL redirect directly to the new category so that when they hit the site the first thing they see is their own specific boards.

However, clicking on the category collapses it as opposed to takes me where I need to go. I have tried to use the search feature on SMF for three days, but everytime I try it says that the server is under stress. So, I tried Google and limited it to the SMF domain and still couldn't find anything directly related to this (the closest I found was a topic about a link on the main page taking you to a new page (like the photo gallery).

Any ideas on how I can make this happen, or if there is a way to do it?

Thanks!!

Mystica

Go into one forum in that category and then use the category link displayed at the top in the location navigation. That link will take you directly to the category.
~ there's nothing wrong with me, this is how I'm supposed to be ~

NoRad

#2
Very weird, but that doesn't seem to work on my website? http://www.louipimps.com

Quite possibly due to the Joomla wrapper? However, I found out that my direct link is http://www.louipimps.com/index.php?option=com_smf&Itemid=74#7

The problem with this is that it's the last category and doesn't really show up at the top like I want. I'd rather be drilled directly down into the category so they only see the two boards in that category and have to back out to get to all of the rest.

strongy

this is exactly what we need to, but no one has programmed it in to the script.
its only a target link rather than a link to that category that shows only the forums within that category

NoRad


bloc

I posted this code before the server move, but it seems it got lost. :)

Anyway , here it is again..open BoardIndex.template.php and find:
foreach ($context['categories'] as $category)
{
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="5">
<tr>
<td colspan="4" class="catbg', $category['new'] ? '2' : '', '" height="18">';

// If this category even can collapse, show a link to collapse it.
if ($category['can_collapse'])
echo '
<a href="', $category['collapse_href'], '">', $category['collapse_image'], '</a>';

echo '
', $category['link'], '
</td>
</tr>';

// Assuming the category hasn't been collapsed...


to:
foreach ($context['categories'] as $category)
{
if((!isset($_GET['viewcat'])) || (isset($_GET['viewcat']) && $_GET['viewcat']==$category['id']))
{
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="5">
<tr>
<td colspan="4" class="catbg', $category['new'] ? '2' : '', '" height="18">';

// If this category even can collapse, show a link to collapse it.
if ($category['can_collapse'])
echo '
<a href="', $category['collapse_href'], '">', $category['collapse_image'], '</a>';

echo '
', $category['link'], '
</td>
</tr>';

// Assuming the category hasn't been collapsed...


and find this:
echo '
</table></div>
<br />';
}
if ($context['user']['is_logged'])


to:
echo '
</table></div>
<br />';
}
}

if ($context['user']['is_logged'])


What this does: if you type http://www.louipimps.com/index.php?option=com_smf&Itemid=74 you will see all categories+boards as usual, but if you do http://www.louipimps.com/index.php?option=com_smf&Itemid=74&viewcat=7 you will only see boards within category with id 7.


Of course pressing the linktree will go back to usual display on this.

NoRad

#6
You absolutely rock. Thank you Bloc. This works like a charm.

Somebody should really make this into a mod, or perhaps it should be a feature in the next release?
Maybe it could be so that if you click the arrow next to a category it shrinks it, but if you click the name it takes you to that specific category like this mod does?

Tony Reid

Very nice tip - something I've often liked about other forums but never got around to requesting  :)

Could be further improved by adding multiple category selection like viewcat=1,2,3

But then maybe Im just being a crazy fool ;D

Thanks to both of you!
Tony Reid

bloc

Quote from: Radianation on November 07, 2005, 03:11:43 AM
You absolutely rock. Thank you Bloc. This works like a charm.

Somebody should really make this into a mod, or perhaps it should be a feature in the next release?
Maybe it could be so that if you click the arrow next to a category it shrinks it, but if you click the name it takes you to that specific category like this mod does?

Just a matter of adding that "&viewcat=xx" to the category link I assume, having a separate link(collapse routine) for the arrow. If it were made into a mod, the easiest  would be to do just one-liner change in BoardIndex.php - just to insert the extra stuff to the link there, and of course the template check. 

Several categories...it could work in just the same way, but the syntax is important then..missing an comma would not show the right ones..but here goes:

http://www.louipimps.com/index.php?option=com_smf&Itemid=74&viewcat=7,2,3

foreach ($context['categories'] as $category)
{
if(isset($_GET['viewcat']))
$viewcat = explode(",",$_GET['viewcat']);

if((!isset($viewcat)) || (isset($viewcat) && in_array($category['id'], $viewcat)))
{
echo '
<div class="tborder"><table border="0" width="100%" cellspacing="1" cellpadding="5">
<tr>
<td colspan="4" class="catbg', $category['new'] ? '2' : '', '" height="18">';


Although where to use this link is more vague..it would have to be used manually.

Tony Reid

Wow - thanks :)

I'm looking forward to adding this tonight :)

Tony
Tony Reid

EPages

Quote from: strongy on November 05, 2005, 09:12:01 PM
this is exactly what we need to, but no one has programmed it in to the script.
its only a target link rather than a link to that category that shows only the forums within that category

I also vote for this to be a default feature....or option!

NoRad

The additional request that lists multiple categories grouped together could be handy when users are clicking the "Show Unread Posts since last visit". Perhaps the user can have a preference of which forums they are interested in, and then by default when they click the show unread / show new replies they will see only the posts from categories that interest them.

bloc

Thats something else really..this "hack" only hides the categories/forums in BoardIndex. Unread is on another page altogether and have mixed boards/categories. Sorting out there will need to be done in the source file, to get the pagination correct.

NoRad

Question, when a user logs in after hitting this link can we make it take them back there?

bloc

Thats not possible..the login goes from a form(Login.template) to a second login screen (action=login2) before redirecting to a page again. It would mean to carry over the viewcat variable in all those places.

NoRad

Bummer. If this becomes an integrated feature in SMF they should consider that. ; )

Advertisement: