Skip to main content
Topic: Link to a category (Read 3501 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Link to a category

Hello!

I feel a bit ashamed about asking this :-[  but I have tried it for hours without success.

The portal is the frontpage in our Forum. We allways had a block in portal, which shows links to all the categories in forum. This block is visible for guests and members.

Most of our categories can be collapsed, if you are logged in. The links in the portalblock should expand the category, even if it is collapsed at the moment.

Before something like this was working that way:

Code: [Select]
<a href="http://myforum.de/index.php?action=expand;c=45;sa=expand#45" target="_blank">Category Name</a>

But now it is action=forum first and anything else I have tried, will give an error or will not expand the category. ::)

At the moment my links are looking like this:

Code: [Select]
[url=http://myforum.de/index.php?action=forum#c45]Category Name[/url]

How can I change them, that they will expand the categories?

Re: Link to a category

Reply #1

You can't use a bbc block, you need a php one because the expand/collapse actions need the session id/value...
Do you want to show all the categories?
Bugs creator.
Features destroyer.
Template killer.

Re: Link to a category

Reply #2

I feel really stupid now... O:-)

Yes, I want to show all of them, Emanuele.

But it is a long and narrow block on the left side in Portal and it is not enough space there for the "original" category names. Some of them are very long. So I am used to shorten them, make breaks or use other words for the links.

The links to the categories are sorted in this Block, with headlines (the red ones). They do nothing, they are just headlines. There are 8 "Parts" in our Forum, each with a few categories, wich belong to this part and each part has a headline in this block.

I think it would be not possible ( or very difficult) to do this with a "simple"php-script?

So I will leave it that way for now.

Re: Link to a category

Reply #3

Actually, now that I look closer, SMF has the same session check, so you probably removed it to achieve that behaviour.
That's an option as well, in sources/controllers/BoardIndex.controller.php, close to the end of the page, there is:
Code: [Select]
	public function action_collapse()
{
global $user_info, $context;

// Just in case, no need, no need.
$context['robot_no_index'] = true;

checkSession('request');
remove that last line:
Code: [Select]
checkSession('request');
Bugs creator.
Features destroyer.
Template killer.

Re: Link to a category

Reply #4

Thank you very much, Emanuele. I have tried it, but it is not working. :-\  It is the same as before.

That one will lead you to the category-header, but the category will not expand:

action=forum#c45


That one brings you just somewhere to the forum index:

action=collapse;c=45;sa=expand#45


And those will show nothing:

action=expand;c=45;sa=expand#45
action=expand;c=33;sa=collapse;#33



Oh! It seems to work with my session Id?

action=collapse;c=45;sa=expand;my session-ID#c45

Yes...it is working perfect now! :)  I have tested it with guests and members.


And that one will still do it for categories, wich cannot be collapsed:

action=forum#c33



I changed this post again, because my session-ID was in there before.
Last Edit: May 16, 2016, 04:18:37 am by Ruth

Re: Link to a category

Reply #5

If it does, then there is a bug.
With a "random" it shall not work, otherwise it would be a potential security issue.
Can you please send me the data of an account (a test one, not a real one) and the link to your forum?

ETA: also it would be useful to know any addon you have installed and if you or TE have done changes to the code. :)
Bugs creator.
Features destroyer.
Template killer.

Re: Link to a category

Reply #6

There are no addons until now, Emanuele...only the portal...I have changed nothing to the code, maybe TE did. I don't know.

I changed a lot in the css-files in our theme, but nothing in other files or in the default, except that one here in BoardIndex.controller.php

I think it is a bit "dangerous" to put my session ids in a portal block? 8)

I have sent you a pm.

Last Edit: May 14, 2016, 05:37:10 am by Ruth

Re: Link to a category

Reply #7

So you didn't even change the code as I suggested? O_o
Because testing it now, it works as I said: the checkSession has been removed and the categories can collapse/expand without session.

Quote from: Ruth – I think it is a bit "dangerous" to put my session ids in a portal block? 8)
Yes. It is.
Especially in the "short term", anyone could pick your session id and use it to impersonate you. Aren't you an admin? Then anyone would have the same permissions.

Feel free to delete or at least demote the test account. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Link to a category

Reply #8

Quote from: emanuele – So you didn't even change the code as I suggested? O_o

 ;) I did this change, yes:

Quote from: Ruth – ...except that one here in BoardIndex.controller.php


Quote from: emanuele – Because testing it now, it works as I said: the checkSession has been removed and the categories can collapse/expand without session.

Thank you for testing, Emanuele...

But my links in this portalblock are still not working the way I want them to work. :-\  A collapsed category will not expand  if I use such a link. I have tried it with every variant.

Re: Link to a category

Reply #9

Just an idea, I did not test it yet:

If I create a member-account, his user-name will be "expander" ;)  and he will have no permissions in forum, but he can collapse and expand each category in forum - can I use his session-IDs for the links in our portal-block? Or is this still too dangerous? Or will not work?

You told me, that the links with a session-ID are working is a bug?

Re: Link to a category

Reply #10

In the sideblock you still have:
Code: [Select]
index.php?action=forum#c11
that doesn't do any expand, you have to use:
Code: [Select]
index.php?action=collapse;c=11;sa=expand#c11
and do note that "action" is always "collapse", not "expand", that is the sub-action.
Bugs creator.
Features destroyer.
Template killer.

Re: Link to a category

Reply #11

Thank you for testing again, emanuele.

c11 ist a category wich is allways open. It cannot be collapsed.
but c45 for example can be collapsed. It will not work with

Code: [Select]
index.php?action=collapse;c=45;sa=expand#c45

if it is collapsed. I will see nothing with this link.

I changed it that way a moment before. Would you look again, please?

Re: Link to a category

Reply #12

It is working now!

I swear, it didn't work the days before...



I have changed them all now.

Thank you very much, emanuele!
Last Edit: May 17, 2016, 11:16:50 am by Ruth

Re: Link to a category

Reply #13

Quote from: Ruth – I changed it that way a moment before. Would you look again, please?
Sorry, I keep reading only the first topic in the unread of each board and I always miss all the others... xD :-[
Bugs creator.
Features destroyer.
Template killer.

Re: Link to a category

Reply #14

Oh, don't worry about this, Emanuele. You have such a lot of work here.

I am glad, that the links are working now, as I want them to work.

Thank you for your help! :)