Implemented Template Hooks

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
Sure that the Beta 3 Templates are ok?

I couldn't find any <xen:hook> in the templates.
We have the code listener but how can we use it without hooks in the templates?
 
Upvote 0
This suggestion has been implemented. Votes are no longer accepted.
A hook to get at the public and private controls on a post would be nice, at the moment you've got to do annoying template edits.

K: 1.0.2

I see this and similar got added, but without a parameter in the hook to the exact message, it's a bit of a nightmare getting the message id out. Seems to be because it's a foreach loop in an include in an include you can get the array of messages but not know where you are in the array.

End up doing an icky regex to get the message id out, unless I'm missing something? :)

K: 1.0.3
 
I see this and similar got added, but without a parameter in the hook to the exact message, it's a bit of a nightmare getting the message id out. Seems to be because it's a foreach loop in an include in an include you can get the array of messages but not know where you are in the array.

End up doing an icky regex to get the message id out, unless I'm missing something? :)
I'm not sure I understand - if we are talking about the hooks around public and private controls in the post template (post_private_controls and post_public_controls) then there is only one thing that the message ID can be - which can be derived from the $post array, which is available to the hook as part of the template parameters.
 
I'm not sure I understand - if we are talking about the hooks around public and private controls in the post template (post_private_controls and post_public_controls) then there is only one thing that the message ID can be - which can be derived from the $post array, which is available to the hook as part of the template parameters.

How do you get at $post?

By doing:

Code:
$params = $template->getParams();

You only get access to:

session, sessionId, requestPaths, visitor, visitorLanguage, xenOptions, xenCache, serverTime, debugMode, controllerName, controllerAction, viewName, visitorStyle, thread, forum, posts, page, postsPerPage, totalPosts, postsRemaining, canReply, canQuickReply, canEditThread, canDeleteThread, canMoveThread, canWatchThread, canViewIps, canViewAttachments, deletedPosts, moderatedPosts, inlineModOptions, firstPost, lastPost, unreadLink, poll, attachmentParams, attachmentConstraints, showPostedNotice, nodeBreadCrumbs, qrEditor, _styleId, session, sessionId, requestPaths, visitor, visitorLanguage, xenOptions, xenCache, serverTime, debugMode, controllerName, controllerAction, viewName, visitorStyle, thread, forum, posts, page, postsPerPage, totalPosts, postsRemaining, canReply, canQuickReply, canEditThread, canDeleteThread, canMoveThread, canWatchThread, canViewIps, canViewAttachments, deletedPosts, moderatedPosts, inlineModOptions, firstPost, lastPost, unreadLink, poll, attachmentParams, attachmentConstraints, showPostedNotice, nodeBreadCrumbs, qrEditor, _styleId

As the template object is actually thread_view
 
Thought I welcome the additions of post_public_controls and post_private_controls, sadly, they have been not useful so far, I need the $post passed to the hook

e.g.
Code:
<xen:hook name="post_private_controls" params="{xen:array 'post={$post}'}">

(that is not available currently)
 
Okay, should be sorted for 1.0.3. Each hook now has $post (post) $profilePost (profile_post) or $message (conversation_message) passed in as a hook parameter.

Also of note is that post_public_controls now no longer surrounds the permalink, as that was not especially useful.
HTML:
<div class="publicControls">
	<a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" class="item muted postNumber hashPermalink" title="{xen:phrase permalink}">#{xen:calc '{$post.position} + 1'}</a>
	<xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
	<xen:if is="{$post.canLike}">
		<a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
	</xen:if>
	<xen:if is="{$canReply}">
		<a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}" data-postUrl="{xen:link posts/quote, $post}" class="ReplyQuote item control reply" title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
	</xen:if>
	</xen:hook>
</div>
 
Next Request => Admin Template addon_list
It would be cool, to be able to add own links into the popup menu.
under:
Code:
<xen:link href="{xen:adminlink 'add-ons/edit', $addOn}" displayif="{$canAccessDevelopment}">{xen:phrase edit}</xen:link>
For example i had to edit the template to add
Code:
<xen:link href="{xen:adminlink 'add-ons/createZip', $addOn}" displayif="{$canAccessDevelopment}">create zip</xen:link>
<xen:link href="{xen:adminlink 'add-ons/editInstallCode', $addOn}" displayif="{$canAccessDevelopment}">link sql tables</xen:link>
pls include this one^^
 
You should be able to that with template_post_render. That data should be available in the extra data array (3rd param).
Hm, not really.
PHP:
if ($templateName == 'addon_list'){

            die($content);
        }
gives me the content of the complete output.

But how should i add to every popup own links?
I could now search for </ul> because this shows the "end of the popup" where i could add something, BUT how can i access the current add-on?

For example:
This is the code for 1 add-on, but i have ATM > 200 add-ons.
Code:
<li class="listItem primaryContent" id="_ragtekdevelopertools">
<a href="admin.php?add-ons/ragtekdevelopertools/delete" class="delete OverlayTrigger secondaryContent" title="Uninstall"><span>Delete...</span></a>

<div class="Popup">
<a class="toolsCtrl" rel="Menu">Controls</a>
<div class="Menu">
<div class="primaryContent menuHeader"><h3>Controls</h3></div>
<ul class="secondaryContent blockLinksList  Left">
<li><a href="admin.php?add-ons/ragtekdevelopertools/upgrade-confirm">Upgrade</a></li>
<li><a href="admin.php?add-ons/ragtekdevelopertools/disable&amp;_xfToken=1%2C1307359600%2C47037f02c17b4121eba412a6519602bdc4e2021b">Disable</a></li>

<li><a href="admin.php?add-ons/ragtekdevelopertools/delete">Uninstall</a></li>
<li><a href="admin.php?add-ons/ragtekdevelopertools/edit">Edit</a></li>
<li><a href="admin.php?add-ons/ragtekdevelopertools/export">Export</a></li>

</ul>

</div>
</div>

<h4>
<a href="admin.php?add-ons/ragtekdevelopertools/edit">
<em>ragtek Developer Tools</em>
<dfn>1.0.5</dfn>
</a></h4>

</li>

Now i need to add to EVERY ADDON this 2 links
Code:
<li><a href="admin.php?add-ons/ADDONID/createZip">zip erstellen</a></li>
<li><a href="admin.php?add-ons/ADDONID/qualityCheck">QA</a></li>

It's AFAIK not possible without a template edit, or a new template which have the manipulated output and where i need to overwrite the controller to send this instead of the original
PHP:
    public function actionIndex()
    {

        $addOnModel = $this->_getAddOnModel();
        $viewParams = array(
            'addOns' => $addOnModel->getAllAddOns(),
            'canAccessDevelopment' => $addOnModel->canAccessAddOnDevelopmentAreas()
        );
        return $this->responseView('XenForo_ViewAdmin_AddOn_List', 'ragtek_addon_list_extended', $viewParams);
    }
 
Admintemplate: user_group_edit

Position: between the to fieldsets to be able to add own settings
Code:
</fieldset>

    <fieldset id="piGroups">

thx:)
 
Admintemplate: style_list

Position: inside the foreach output for the styles because I need to show some data

style.webp
 
Template: forum_view
We have a hook BEFORE the threadlist.

Pls add also a hook AFTER the threadlist
 
no not the that editor ...
I mean in the AdminCP when you edit a template or create new template

Try and set your board to Debug mode. Edit config.php, and add the following lines:

Code:
if ($_SERVER['REMOTE_ADDR'] == 'add.your.ip.here')
{
    $config['debug'] = true;
}

A new menu option called Development will appear in the AdminCP. Click on it, and then Admin Navigation. Here, you can add new navigation items to the AdminCP.
 
Top Bottom