News:

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

Main Menu

Content of $topic - Can´t find any documentation

Started by Doctor Asp, May 29, 2021, 06:22:36 AM

Previous topic - Next topic

Doctor Asp

Hi
First post in this forum.  :)
Is there a list off all the content of $topic (and $board) somewhere?
When I search the online documentation for "$topic['new_href']", I get 0 results.

/Doc
/Doctor Asp

Aleksi "Lex" Kilpinen

#1
Unless I'm mistaken, $topic and $board both should only contain the topic or board ID respectively, if defined so if you are in a topic view or a board view.
https://wiki.simplemachines.org/smf/Global_variables
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

live627

Hello and welcome to SMF!

I get the feeling that you are trying to make an integration of some kind—SSI, perhaps? Here is documentation all the SSI functions.

Doctor Asp

Thx for both replies.
I have seen this https://wiki.simplemachines.org/smf/Global_variables but it isn´t very helpful.
I need a list like this:

$topic['new_href'] - The url to the first new message in this topic
$topic['first_post']['link'] - The title with a link to the first message in this topic
$topic['first_post']['id'] - The id number of the first message in this topic
$topic['quick_mod']['modify'] - ?
etc.

I´m working on a Bootstrap 5 theme for SMF 2.1 to use at my existing website.

/Doc
/Doctor Asp

Kindred

I don't believe that $topic is ever populated like that at all

If it is, it would only be when post.php is loaded
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

live627


Doctor Asp

Quote from: live627 on May 31, 2021, 06:25:54 AM
Your best bet is to use var_dump().

Great! var_dump($topic) gave me an array of 48 variables:

array(48) {
  ["id_topic"]=>  string(1) "9"
  ["num_replies"]=>   string(1) "0"
  ["locked"]=>   string(1) "0"
  ["num_views"]=>   string(1) "1"
  ["is_sticky"]=>   bool(true)
  ["id_poll"]=>   string(1) "0"
  ["id_previous_board"]=>   string(1) "0"
  ["new_from"]=>   string(1) "0"
  ["is_posted_in"]=>   string(1) "0"
  ["id_last_msg"]=>   string(2) "12"
  ["approved"]=>   string(1) "1"
  ["unapproved_posts"]=>   string(1) "0"
  ["last_poster_time"]=>   string(10) "1622279678"
..........

If there is no documentation around, then I guess I just have to figure out the use of all 48 variables myself (not all of them are obvious).

As I´m working on a new theme, I need to know what data is at my disposal on each page.

/Doc
/Doctor Asp

Advertisement: