News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Way to check if a topic is from a board?

Started by Nirose, September 19, 2017, 05:23:33 AM

Previous topic - Next topic

Nirose

I'm trying to add additional content to some of the board and I couldn't find a way to check whether a topic belongs to a specific board.

So I ended up using titles to run them:
if (strpos($context['page_title_html_safe'], 'STRINGS') !== FALSE){
//run this
}


is there a better way to handle this with board IDs?

Thanks

Arantor

Where are you trying to show this? If you are in a topic, $board will contain some useful stuff. If you are in a board, $board will contain some useful stuff.

Note you might need to global these to use them depending on where you are trying to use them.

Illori

Quote from: Arantor on September 19, 2017, 05:59:29 AM
Where are you trying to show this? If you are in a topic, $board will contain some useful stuff. If you are in a board, $board will contain some useful stuff.

do you mean if in a topic $topic will contain some useful stuff?

Arantor

No, $board should too. $topic will just contain the topic id, with $topicinfo containing stuff about the topic.

Nirose

Quote from: Arantor on September 19, 2017, 05:59:29 AM
Where are you trying to show this? If you are in a topic, $board will contain some useful stuff. If you are in a board, $board will contain some useful stuff.

Note you might need to global these to use them depending on where you are trying to use them.

Thanks!
I'm editing the index.template.php file for my theme inside <header>. just trying to show content on the header for topics on specific boards.  I'll look into $board, is there any link referencing what this variable holds?


Arantor

Not really because its content varies depending on context. Sometimes it will be just a number and this will be the board id, other times it will be an array of things.

What exactly do you want to alter where? I'm not trying to be awkward, just that knowing exactly and specifically what you're trying to do, especially here, is relevant. There are possibly better ways to do what you want.

Nirose

Hi,

Sorry i was researching a bit. I found that $context['current_board'] returns the id of the board inside the topic. so i'm using to match the filter. I haven't found any mod that does this, but i'll be happy to know about it.

I was able to achieve the filter by using

if ($context['current_topic']){
    $theboardid = array(1,2,3);
if (in_array($context['current_board'],$theboardid)){
        //something for the topic
       }
}

I'll be glad to hear if there are some suggestions. I'll mark this as solved.

Arantor

How can I possibly suggest something when you have been so evasive about what you're trying to do, when all you talk about is how you think you have to solve it?

For example, I could imagine a portal doing this just fine without any custom modifications but that would require actually knowing what you're trying to do.

Nirose

sorry i missed that part. i was trying to add a <meta> tag onto the header for topics inside a board.

Arantor


Advertisement: