Display Thread Title in Warning Message of Addon "Hide Content"

weberswerner

Member
Registered
Joined
Oct 5, 2021
Messages
13
Points
13

Reputation:

Hey @all of this great community,

I'm currently struggling with displaying the Thread Title in the Warning Message of the Addon "XENTR-HideContent-1.1.0". I am trying to setup a custom warning message to guests/visitors when trying to vieew links and I want to display the thread title in it. I tried several terms with codes like
<xf:title>{$thread.title}</xf:title>

and several other solutions, that I copied from the thead.view template, but unfortunately with no success. It always just displays the raw code "{$thread.title}".
Is there a possibility to add the thread title to addon warning messages?

Thank you very much in advance!
 

weberswerner

Member
Registered
Joined
Oct 5, 2021
Messages
13
Points
13

Reputation:

Not working for me, very strange. It looks like I'm clearly doing something wrong but I'm also quite new to XF. Do I need to give the addon permission to execute codes or something?
I attach a screenshot how the outcome looks at the thread and this is the code I am adding to the warning message of the HideContent Addon:
<xf:title>
<h4 class="textHeading" style="margin-top: 0">{$_thread.title}</h4>
</xf:title>
 

Attachments

  • hidecontent.jpg
    hidecontent.jpg
    39.4 KB · Views: 159

shqawe

Well-known member
Registered
Joined
Jun 30, 2019
Messages
60
Points
28

Reputation:

My friend don't use <xf:title> because when you use it will but the code inside head tag and it will not show inside any template

so try this code

HTML:
<h4 class="textHeading" style="margin-top: 0">{$_thread.title}</h4>
 

weberswerner

Member
Registered
Joined
Oct 5, 2021
Messages
13
Points
13

Reputation:

My friend don't use <xf:title> because when you use it will but the code inside head tag and it will not show inside any template

so try this code

HTML:
<h4 class="textHeading" style="margin-top: 0">{$_thread.title}</h4>
shqaweHey bro,
problem still persists. It seems like all code is ignored inside the warning message. Please have a look at the attached screenshots:

Thank you!!
 

Attachments

  • hidecontent2.jpg
    hidecontent2.jpg
    70.6 KB · Views: 155
  • hidecontent.jpg
    hidecontent.jpg
    43.3 KB · Views: 156
View previous replies…

shqawe

Well-known member
Registered
Joined
Jun 30, 2019
Messages
60
Points
28

Reputation:

Hey bro,
problem still persists. It seems like all code is ignored inside the warning message. Please have a look at the attached screenshots:

Thank you!!
weberswernerYou cant add variable inside any addon options unless it allowed to you otherwise you cant. You should edit addon template and add above code
 

weberswerner

Member
Registered
Joined
Oct 5, 2021
Messages
13
Points
13

Reputation:

Hey bro,
problem still persists. It seems like all code is ignored inside the warning message. Please have a look at the attached screenshots:

Thank you!!
weberswernerI tried everything, the strange thing is when I put the variable inside the template, it doesn't show up in the code, only this part is visible
<h4 class="textHeading" style="margin-top: 0"></h4>
but there is not thread.title displayed and the variable is invisible too!
I edited the template file "xentr_hide_bb_code_tag_url"
I even tried to edit the raw php file of the Addon

/src/addons/XENTR/HideContent/XF/Option/Message.php

without success obviously. Is it possible that the Addon doesn't have access rights to the thread title/thread info etc?
 

shqawe

Well-known member
Registered
Joined
Jun 30, 2019
Messages
60
Points
28

Reputation:

I tried everything, the strange thing is when I put the variable inside the template, it doesn't show up in the code, only this part is visible

but there is not thread.title displayed and the variable is invisible too!
I edited the template file "xentr_hide_bb_code_tag_url"
I even tried to edit the raw php file of the Addon

/src/addons/XENTR/HideContent/XF/Option/Message.php

without success obviously. Is it possible that the Addon doesn't have access rights to the thread title/thread info etc?
weberswernerYou are editing the wrong file you should edit this file
src/addons/XENTR/HideContent/XF/BbCode/Renderer/Html.php

Find this code:

PHP:
return $this->templater->renderTemplate('public:xentr_hide_bb_code_tag_url');

Replace it with this one:

PHP:
$title = $entity->Thread->title;

return $this->templater->renderTemplate('public:xentr_hide_bb_code_tag_url', ['title' => $title]);

Now you can use $title variable in xentr_hide_bb_code_tag_url template.
 

weberswerner

Member
Registered
Joined
Oct 5, 2021
Messages
13
Points
13

Reputation:

You are editing the wrong file you should edit this file
src/addons/XENTR/HideContent/XF/BbCode/Renderer/Html.php

Find this code:

PHP:
return $this->templater->renderTemplate('public:xentr_hide_bb_code_tag_url');

Replace it with this one:

PHP:
$title = $entity->Thread->title;

return $this->templater->renderTemplate('public:xentr_hide_bb_code_tag_url', ['title' => $title]);

Now you can use $title variable in xentr_hide_bb_code_tag_url template.
shqaweThat did the trick! Thank you so so much man, this whole thing was driving me crazy and I'm happy to have it finally running. I have one more question to have maybe a little bit more perfection for the idea I'm working on. Do you know any variable from Xenforo to receive/get the first img url of a thread/post?
 

larryday

Member
Registered
Joined
Jul 8, 2023
Messages
6
Points
3

Reputation:

To show thread title in the warning message, use this code:

<xf:title>{$thread.title}</xf:title>

Edit the addon's template file warning.html located in:
/addons/xentr_hidecontent/templates/

Find this line of code in the file.
 

weberswerner

Member
Registered
Joined
Oct 5, 2021
Messages
13
Points
13

Reputation:

To show thread title in the warning message, use this code:

<xf:title>{$thread.title}</xf:title>

Edit the addon's template file warning.html located in:
/addons/xentr_hidecontent/templates/

Find this line of code in the file.
larrydayThanks for trying to help! Unfortunatly there is no file like "warning.html" existing.
In addition, with your mentioned variable "<xf:title>{$thread.title}</xf:title>" I am just changing the site title, it does not do what I want. I don't wanna get to close to you in case if I am wrong, but your answers sound pretty much like chatgpt :D Thank you anyway
 
Top