Forum breadcrumbs – You are here:Asgaros Support ForumSupportget_link function
Please or Register to create posts and topics.

get_link function

Hallo @asgaros

Sofern ich nicht komplett doof bin sollte ich doch über folgenden code den passenden link bekommen, oder?

global $asgarosforum;
$url = $asgarosforum->get_link('topic', $topic->id);

Leider bekomme ich dort exakt gar nichts. Irgendeine idee?

Hey @quenso,

ja dass ist die richtige Funktion um die URL zu bekommen. Hast du die Variable $topic zuvor irgendwo definiert?

Alternativ kannst du auch die Variable $current_topic verwenden:

global $asgarosforum;
$url = $asgarosforum->get_link('topic', $asgarosforum->current_topic);

 

Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Hey @qualmy91

Im ganzen sieht die Funktion wie folgt aus und wird getriggert durch “asgarosforum_after_add_reaction”:

global $asgarosforum;

$post = $asgarosforum->content->get_post($post_id);
// $url = $asgarosforum->get_link('topic', $post->parent_id) . '#postid-' . $post_id;
$url = $asgarosforum->get_link('topic', $post->parent_id);

// Create notification
if (get_current_user_id() != $post->author_id && self::get_notifications_option($post->author_id, 'notify_reactions')) {		
  // Send notification to post author
  $this->add_notification($user_id, $post->author_id, $title, 'reaction', $topic->id, $url);		
}

Ich verzweifel langsam an der Nummer. Hab schon sämtliche wege probiert die mir einfallen …

Hey @quenso,

kannst bitte mal noch deinen Funktionsaufruf und Funktionskopf mit posten?

Wo genau kommst du nicht weiter? Bei mir die URL richtig ausgegeben?

Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Die ganze funktion inkl. add_action sieht wie folgt aus:

add_action('asgarosforum_after_add_reaction', array(&$this, 'add_reaction_notifications'), 10, 3);

/*
 * Add notification for reactions
 * @param int $post_id		Post ID
 * @param int $user_id		User ID
 * @param string $reaction	Reaction type
 * @return
 */
public function add_reaction_notifications ($post_id, $user_id, $reaction)
{
  global $asgarosforum;
  
  $post = $asgarosforum->content->get_post($post_id);
  // $url = $asgarosforum->get_link('topic', $post->parent_id) . '#postid-' . $post_id;
  $url = $asgarosforum->get_link('topic', $post->parent_id);
  
  // Create notification
  if (get_current_user_id() != $post->author_id && self::get_notifications_option($post->author_id, 'notify_reactions')) {		
    // Send notification to post author
    $this->add_notification($user_id, $post->author_id, 'reaction', $post->parent_id, $url);		
  }
}

Ich bekomme immer einen leeren string zurück

Alles andere funktioniert einwandfrei! nur die get_link funktion nicht.

Hey @quenso,

die get_link Funktion hat Probleme da sie durch die REST API angesprochen wird. Deshalb ist ein Array noch nicht gesetzt, der für die get_link Funktion notwendig ist.

Der Fix ist in diesem Pull Request:

https://github.com/Asgaros/asgaros-forum/pull/290

Asgaros has reacted to this post.
Asgaros
Need professional help with Asgaros Forum? Book an appointment with us at domra Web Solutions for setup and customization services. Learn more about our Toolbox for Asgaros Forum plugin to enhance your forum experience.

Vielen dank! Dann warte ich mit dem Release der nächsten Version noch bis zum update.

Asgaros has reacted to this post.
Asgaros