TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 141
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 92
  • Total: 92

Get message/post id while editing post

Started by Inge Jones, May 12, 2012, 09:44:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Inge Jones

I want a TP php block to appear when a user is posting, and I want this block to know what the message number is.  (I do realise this is not possible when posting a new message, as the message number has not yet been allocated.  )  But anyway this block is meant be used during an *edit* of an existing post, to offer various things that need to know the message number (I won't bore you with details unless asked).

I have tried the established $context['message']['id'] and variations on that.  I have also tried $message = $context['get_message']() and then testing $message['id'] etc  but it all comes back empty, even though the function call itself returns true!

Any other ideas for detecting the number of the post you're editing - or even viewing!

Inge Jones

Ok I decided to do it by topic number instead, which can be accessed easily :)

IchBin

If you do a print_r($context) you'll probably see that there is a key some where in the array that shows you the id of the message that you are editing.

Inge Jones

I did that but I could still only find the message number itself in $context['querystring'] which I have to say surprised me - and I didn't fancy having to parse out that string.  Anyway fortunately when I rethought the project, connecting the procedure with the topic did actually make more sense :)

Inge Jones

#4
...However, now I would really like to find out if current user was author of first post in thread.  Any ideas?  $context['current_topic'] has no subkeys, so I hit a dead end using that to get to first post in the topic.

Later:  Ok I am getting the result by using this:

$previous = $context['previous_posts'];
$lastpos = count($previous) - 1;
$firstpost = $previous[$lastpos];
$topic_owner = $firstpost['poster'];

This website is proudly hosted on Crocweb Cloud Website Hosting.