XF 2.0 Discussions Per Page - Adjust to Higher Number for One Node

I've searched and seen threads from as far back as v1.3, and one old and deleted add-on, about this. I recognize that it requires custom development due to "discussions per page" being a global value.

My question is... is this possible without an add-on being developed? I don't need a generalized abiliity to do this to each forum separately. In fact, I have one node only that needs higher number of threads shown per page.

Is there a template, perhaps, where I can locate where it calls for this global value, and wrap it in a conditional so that this one node is force-fed a higher number? If this is possible, it won't even require any database work. I just for the life of me can't find any such template yet, but I'm still digging.

Any help or suggestions here to put me on the right track?
 
.My question is... is this possible without an add-on being developed?
It does definitly require custom code (specifically a class extensxion for XF\Pub\Controller\Forum), but technically speaking it does not require an Add-on.
Though I'd always strongly recommend to implement this as one.
 
PHP code I can handle to some degree but understanding the Xenforo architecture and developing an add-on and all that is far out of my league.

Can anyone take a guess at how difficult it would be to simply state... "If node = xx, then nodes_per_discussion = xx, else use global value" in add-on form? Would this be likely to break often, infrequently, or never during upgrades? And how hard would it be to fix if that occurred?

If it's simple and cheap, anyone care to take a shot at it?
 
It would be fairly simple to edit the PHP file but it's something which would have to be reapplied after every upgrade.

An add-on would be the best option.
 
@Kirby,
Quick couple of questions:

1) Can I replace "thehobbster" everywhere it's found and rename the folder to something more descriptive of the plugin?
2) Within the _data folder it seems like only class_extensions.xml is doing anything. Must the other xml files be included?

Thanks, I'm asking this in order to learn more and to upload the least amount of bloat possible. Thanks again!
 
You'll have to rename that quite a few times though that should work, yes.

XenForo does generate the _data folder and the ZIP automatically, to be honest I never tested if it would work without the other XMLs - at least it would most likely complain about missing files upon file health check if you don't also modify hashes.json.
I'd just leave it as-is unless there is a pretty good reason not to.

The Add-on consists of only one class extension, so all other XMLs are empty.

Edit
Seems to work just fine without the unneeded XMLs, though personally I'd be way too lazy tp modify hashes.json and to delete teh "empty" XMLs, that takes way loonger than just upladong a few more unneeded bytes :)
 
Last edited:
@Kirby, Works perfectly. Thank you for taking the time. Easy to edit if I want to change the #'s or any other details. Hopefully it lasts through Xen 3.0 and beyond!

Forgot to ask, should I be seeing the "unexpected contents" notice when installing the plugin? I did and installed anyway and it was fine.

EDIT: Yeah, and now the file health check is failing. Any clue what the prob is? I'd like to not have that in the errors list so I know when other problems pop up.
 
Last edited:
I figured I should add more details in case any onlooker can help.

Here are the contents of class_extensions.xml, which is throwing the File Health warning:

Code:
<?xml version="1.0" encoding="utf-8"?>
<class_extensions>
  <extension from_class="XF\Pub\Controller\Forum" to_class="thehobbster\XF\Pub\Controller\Forum" execute_order="10" active="1"/>
</class_extensions>

Anyone see anything wrong with that?
 
Nope. Did you modify the file as announced?
If you did you will have to modify hashes.json as well.

I've tried several variations:

1) When I change the folder name from 'thehobbster' to something else and correct that within all of the files and delete the extra xml files while deleting those lines from the hashes.json, I get 1 file health error as described above on class_extensions.xml

2) When I don't delete the XML files and only change the folder name itself and the name within the files, I get 3 file health errors on Forum.php, class_extensions.xml, and addon.json

3) When I upload it exactly as you sent it in the zip I get no errors.

Do you know what the values are associated with all the keys in the hashes.json (like "e0825d9adb7eaa83034d2963add75276fafd7092380be3ccae2bc7a346eb7c2b")? I wonder if they encode the folder name somehow and that's causing the problem.

Edit - Yeah, I took just addon.json and changed only the "title:" value and it's throwing warnings.

If you saved this within your install, can I private message you the details I'd like changed and have you regenerate it? If not it's not a big deal, I'm just being peculiar, mainly for privacy.

Edit - I believe it's the hashes causing the problem. I found a thread about regenerating it, which I'm about to try - https://xenforo.com/community/threads/how-do-i-create-hashes-json-for-changes-in-an-addon.150464/

Final edit - That took care of it. Just had to rebuild correct checksums as follows:

SSH into your site and navigate to the public_html like cd /home/yourdomain/public_html (where XF is installed) and run the command php cmd.php xf-addon:build-release ADDONID where ADDONID is the name of the folder that you changed all throughout.
 
Last edited:
I've already killed the files as I don't need them.

You can do that, but that will just regenerate a whole ZIP so you'll have to start over deleting "unnecessary" files ;)
As said before, i'd just keep them.

If you still want to remove "unneeded" files and or modify them:
Code:
 php -r 'echo(hash("sha256", str_replace("\r", "", file_get_contents("/path/to/file"))));'
and adjust hashes.json as needed
 
Last edited:
I didn't realize you replied, @Kirby, and was editing my last post. I solved it. I just rebuilt the plugin as mentioned above AFTER changing the folder name and accepting the file health errors. It re-generated the checksum hashes in hashes.json. I did leave the extra xml files in there, though they can be deleted. Like you said, might as well leave it in the format Xenforo creates.
 
@Kirby

The Zip file in this thread is empty now! I was hoping I could use this add-on!

I have a group of sub-forums, about 26 of them that all need an alternate higher setting from the normal threads per page setting. This is the only add-on with that feature, and I was hoping to look at it and hack it if I needed to to make it work.

If it's possible, can I get a copy of this add-on if you still have it?
 
The ZIP is not empty.
Sorry, you weren't wrong. Windows 10 reported an empty zip file, and when I asked it to extract anything it said the Zip was corrupted.

After your message I tried using 7-zip, that detected the file structure of the zip file, so I was mistaken, and now have access to the files! Thanks. Sorry for the misunderstanding.
 
Back
Top Bottom