Development BlogChanging the core template in an extension

Post Reply
User avatar
Topic Starter
Restless Rancor
Great Britain

Site Admin
New Member
Posts: 48
Joined: October 15th, 2018, 3:14 pm
Age: 25
Location: Hampshire, England

Changing the core template in an extension


Post by Restless Rancor » October 19th, 2018, 8:17 pm

I had a very specific place I wanted my User's Post Count on Index extension to display the post count: opposite 'Mark Forums Read'.

The trouble with this is I have to edit a core template location, which extensions can't do- you have to get creative.

Code: Select all

<!-- EVENT index_body_markforums_before -->
	<div class="action-bar compact">
		<a href="{U_MARK_FORUMS}" class="mark-read rightside" accesskey="m" data-ajax="mark_forums_read">{L_MARK_FORUMS_READ}</a>
<!-- ENDIF -->
<!-- EVENT index_body_markforums_after -->
One option would be to include a <div style="visibility: hidden;"> in index_body_markforums_before.html and a closing </div> in index_body_markforums_after.html, with the extensions template code after or before, but if another extension does exactly the same it could cancel the second out, or, depending on the <div> placement, they could cancel each other out.

I took a look at what Tabbed Stat-Block 1.0.2 does to replace the index statistics, as the extension has no listener: it's pure html and css.

The author had used .css to hide the statistics:

Code: Select all

.tab-stat-block ~,
.tab-stat-block ~ .stat-block.birthday-list,
.tab-stat-block ~ .stat-block.statistics {
	display: none;
And redefine the stat block css:

Code: Select all {
	font-size: 1em;
} p {
	font-size: 1.1em;
	line-height: 1.3em;
So, after some research into exactly what that css was doing, I adopted the same method:

Code: Select all

.postcountonindex-block ~ .action-bar {
	display: none;

.postcountonindex-block {
	font-size: 11px;
	margin: 4px 0;
And hey presto, I achieved my desired effect exactly.

I'm going to look more into this method (and also the core css) to see if this could potentially cause problems I'm currently unaware of, but the next step for the extension is to add language files. It doesn't really need any, but it'll be a vital part of the learning process.

I've also been told I could change my php and html to not require the {% if USER_POST_COUNT == '1' %}, so will look more into that before I progress.

Once I've accomplished these optimizations, I can look at adding ACP options so the administrator can chose where the post count is displayed.

These aren't the droids you're looking for.

Post Reply

Topic Subscribers

1 user subscribed to this topic: Restless Rancor