• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

1-2 Template Questions

Jeremy

Well-known member
#1
OK, so this is the first add-on with a template for me (Cezz did most of the templates for Shorten URL). Here's my template:

HTML:
<xen:title>~Custom BB Codes~</xen:title>

<xen:topctrl>
	<a href="{xen:adminlink 'add-ons/install-confirm'}" class="button">+ ~Create New BB Code~</a>
</xen:topctrl>

<link rel="xenforo_stylesheet" type="text/css" href="filter_list.css" />
<xen:require js="js/xenforo/filter_list.js" />

<xen:form action="{xen:adminlink add-ons}" class="section">

	<xen:if is="{$codes}">
		<h2 class="subHeading">
			<link rel="xenforo_template" type="text/html" href="filter_list_controls.html" />
			~Custom BB Codes~
		</h2>

		<ol class="FilterList">
			<xen:foreach loop="$codes" value="$addOn">
				<xen:listitem id="{$.addon_id}"
					label="{$codes.title}"
					labelclass="{xen:if '!{codes.active}', 'disabled'}"
					snippet="{$codes.tag}"
					href="{xen:if $customBBCodes, {xen:adminlink 'add-ons/edit', $codes}}"
					delete="{xen:adminlink 'add-ons/delete', $codes}"
					deletehint="{xen:phrase uninstall}">
					<xen:popup title="{xen:phrase controls}" ctrlclass="toolsCtrl">
						<xen:link href="{xen:adminlink 'custom-bb-codes/delete', $codes}">{xen:phrase delete}</xen:link>
						<xen:link href="{xen:adminlink 'custom-bb-codes/disable', $codes, '_xfToken={$visitor.csrf_token_page}'}" displayif="{$codes.active}">{xen:phrase disable}</xen:link>
						<xen:link href="{xen:adminlink 'custom-bb-codes/enable', $codes, '_xfToken={$visitor.csrf_token_page}'}" displayif="!{$codes.active}">{xen:phrase enable}</xen:link>
						<xen:link href="{xen:adminlink 'custom-bb-codes/edit', $codes}" displayif="{$customBBCodes}">{xen:phrase edit}</xen:link>
					</xen:popup>
				</xen:listitem>
			</xen:foreach>
		</ol>

		<p class="sectionFooter">{xen:phrase showing_x_of_y_items, 'count=<span class="FilterListCount">{xen:count $codes}</span>', 'total={xen:count $codes}'}</p>

	<xen:else />
		<div class="noResults">~You have no custom BB Codes~</div>
	</xen:if>

</xen:form>
However, I have a problem.
  1. href="{xen:if $customBBCodes, {xen:adminlink 'add-ons/edit', $codes}}" doesn't work. I'm using a custom Admin Permission for this...
  2. Edit link doesn't show, is it the same problem as 1?
Do I need to check the permission value in my controller class and add it to viewParams?
 

Mike

XenForo developer
Staff member
#2
It's hard to say what the problem is without at least seeing what you're passing to the view ($viewParams). If $customBBCodes is passed, you should be fine.

BTW, your labelclass is missing the $ on the variable.
 

Jeremy

Well-known member
#3
Thanks, and you just answered my question. My view params is just $codes. Thanks. :) How do I check permissions... I haven't done that yet...

Edit:

Accomplished Via:
PHP:
XenForo_Visitor::getInstance()->hasAdminPermission('customBBCodes');