XF 1.5 How to put Forum.Node_ID in thread title for Reported Content

ainwood

Member
We have all our reported content generating a post in a reports forum. I would like to have the node / forum id name from the originating post report be able to have the moderators be able to see at a glance which forums the reports have come from.

I tried to modify the "reported content" phrase to include {node} and {$forum.node_ID}, but this didn't work. I am relatively new to xenforo, so not sure how to do it. Any steer appreciated!
 
Any reply on this. I also have this same issue.

In vB4 the default phrase was

Reported Post by $reportinfo[rusername]

Not much info, but they had the variables so that I could change it to this:
$reportinfo[pusername] - $reportinfo[forumtitle] - Post Reported by $reportinfo[rusername]

Any options to do this in XenForo?
 
Last edited:
Thanks. As far as I can see, this is not a template, but a phrase that needs to be modified. How do we work out which variables are accessible to a phrase? Is it based on the template used to generate the report? (eg. the post?)
 
In /library/XenForo/ReportHandler/Abstract.php public function prepareReport(array $report) after
PHP:
$contentInfo = unserialize($report['content_info']);
add
PHP:
$report['node_id'] = isset($contentInfo["node_id"]) ? $contentInfo["node_id"] : "";
In report_list template replace
HTML:
                <a href="{xen:link reports, $report}"><xen:if is="{$report.isVisible}">{xen:string wrap, {xen:escape $report.contentTitle, false}, 50}<xen:else />{xen:phrase unknown_content}</xen:if></a>
with
HTML:
                <a href="{xen:link reports, $report}"><xen:if is="{$report.isVisible}">{xen:string wrap, {xen:escape $report.contentTitle, false}, 50} <xen:if is="{$report.node_id}">in node {$report.node_id}</xen:if><xen:else />{xen:phrase unknown_content}</xen:if></a>
 
HTML:
<a href="{xen:link reports, $report}"><xen:if is="{$report.isVisible}">{xen:string wrap, {xen:escape $report.contentTitle, false}, 50}<xen:else />{xen:phrase unknown_content}</xen:if></a>
does not appear in our report_list template. The line seems to have been changed to:
HTML:
<xen:topctrl><a href="{xen:link 'reports/closed'}" class="callToAction"><span>{xen:phrase closed_reports}</span></a></xen:topctrl>
I think that is because we are using a custom style from @ThemeHouse . Any suggestions on how to map the feature to a different template?
 
Look for a line which containts {xen:link reports, $report} and then only add
<xen:if is="{$report.node_id}">in node {$report.node_id}</xen:if>
within the title part of the line. Otherwise, you'll have to ask your style creator for help.
 
When a post is reported, a thread is generated in the reported post forum. The phrase reported_thread_message generates the new post/thread. We need the node name or linked node name as a variable in that template. If Abstract.php is the script that generates the variables then @yoloswaggerino hack should be able to capture it. I don't know how to put it all together since I don't know which template I need to modify.

The actual message content in our reported posts forum is from the very strange looking phrase reported_thread_message. However, if I search templates for that phrase, it is not found. This is the phrase itself with my odd ball edit in it. (I have tried lots of variant on node_id.)

When I found the phrase, I thought I could use a parameter and provide it from the template but I cannot find a template so there must be some other mechanism for generating the post in the reported posts forum.
HTML:
[url='{link}']{title}[/url] by [url='{userLink}']{username}[/url] has been reported by [url='{reporterLink}']{reporter}[/url] in {node_id}. Reason given:
[quote]{reportReason}[/quote]

Content being reported:
[quote]{message}[/quote]
{extraDetails}
 
i was able to add the name of the forum containing a reported post by adding this to the textarea tag in the post_report template:

Code:
&nbsp;&nbsp;&nbsp;({xen:raw $forum.title})

i was going to get fancy and move the cursor to after the forum name, but the three non-breaking spaces mean the moderators can just start typing the reason they're reporting the post as they're used to doing, and all will get a forum-name-at-a-glance-in-parens reference with the report.
 
To elaborate, I'm assuming I need to be editing report_content_post and/or report_create. However, when I try to edit my child style template of those, I'm getting the "Oops..." message.
 
In /library/XenForo/ReportHandler/Abstract.php public function prepareReport(array $report) after

I've solved my issue building upon the suggestion here from S Thomas.

In my case, I went to the Post.php in /src/XF/Report folder on the server

From there I added the following:

. ' (' . $content->Thread->Forum->Node->title . ')'

into the two lines of $threadTitle =


Code:
    public function setupReportEntityContent(Report $report, Entity $content)
    {
        if (!empty($content->Thread->prefix_id) && $content->Thread->Prefix)
        {
            $threadTitle = $content->Thread->Prefix->title . ' - ' . $content->Thread->title . ' (' . $content->Thread->Forum->Node->title . ')';
        }
        else
        {
            $threadTitle = $content->Thread->title . ' (' . $content->Thread->Forum->Node->title . ')';
        }

We may play a little with formatting, and if we want to call the node_title or node_name, but yeah, problem solved!
 
That works great! Thanks!

I tried playing around with the parameters (sent in $report->content_info). In post.php I added a function
Code:
public function getContentNodeTitle(Report $report)
    {
        return $report->content_info['node_title'];
    }
Then called it in AbstractHandler.php, in the array returned by the getContentForThreadReport function:
Code:
return [
            'link' => $this->getContentLink($report),
            'title' => $this->getContentTitle($report),
            'node_title' => $this->getContentNodeTitle($report),

It works fine in the report post itself, but couldn't find a way to send the node_title as a parameter to the title.
 
Back
Top Bottom