nathanmiller
Member
Hello! I've read through a ton of addon tutorials and find that I'm having trouble creating what should be fairly simple. I think I'm just missing one piece of understanding, so any help would be greatly appreciated.
I'm trying to create a simple addon that shows "X posts remaining" on the right side of the "1,2,3...Last" navigation bar at the bottom of a thread page (except on the last page).
Here's what I've done so far:
I'm trying to create a simple addon that shows "X posts remaining" on the right side of the "1,2,3...Last" navigation bar at the bottom of a thread page (except on the last page).
Here's what I've done so far:
- Updated config.php to set debug mode to true and development enabled to true. Set defaultAddon as "RemainingPosts"
- php cmd.php xf-addon:create on my server with "RemainingPosts" as the ID for my addon.
- Modified addon.json to add my name, url, and a logo.
- Created a module in the addons folder: /addons/RemainingPosts/Template/TemplateFunctions.php:
PHP:<?php namespace RemainingPosts; class RemainingPosts { public static function remainingPosts($total, $perPage, $page) { if ($total > $perPage) { $totalPages = ceil($total / $perPage); if ($page < $totalPages) { $remaining = $total - ($page * $perPage); $html = '<div class="postsRemaining">' . $remaining . ' More Posts...</div>'; return $html } } return ''; } }
- Found the template that needs to be modified (thread_view) and where I want my function to go (inside <div class="block-outer block-outer--after">, after xf: pagenav and before xf:showignored). And formulated (but did not insert) what I think I want my line to look like:
HTML:<???:remainingPosts page="{$page}" perPage="{$perPage}" total="{{ $thread.reply_count + 1 }}" wrapperclass="block-outer-opposite" />
- Make sure my remainingPosts method is actually accessible to this template (what should go in the ??? for example?)
- Modify the template in an "add-on" fashion rather than directly in the xenForo admin panel so that I can package my TemplateFunctions and the modification together.