<?xml version="1.0"?>
<rss version="2.0"><channel><title>Invision Community Blog: Community Management</title><link>https://invisioncommunity.com/news/community-management/page/5/?d=34</link><description>Invision Community Blog: Community Management</description><language>en</language><item><title>Theme Tip: Using custom template bits</title><link>https://invisioncommunity.com/news/community-management/theme-tip-using-custom-template-bits-r965/</link><description><![CDATA[<p>
	We frequently encourage people to use custom CSS files when designing their themes. The reason for this is simple: it makes upgrading your site <em>much</em> easier because IPS4 can apply any changes to its own CSS files, and will leave your custom CSS files untouched. If instead you made edits to IPS4's CSS directly, it wouldn't be able to upgrade them automatically, which means more work for you, and a potentially broken UI on each upgrade.
</p>

<p>
	Something that's not quite as common, but that we still strongly suggest, is using custom template bits as much as possible. The most common template you'd edit is <em>globalTemplate</em>, perhaps to include some extra resources in the <em>&lt;head&gt;</em>, a custom header, and maybe some footer pieces. The usual approach would be to simply add all of that custom HTML directly into <em>globalTemplate</em>, but my recommendation is that you instead create each piece as a custom template bit, and then include it.
</p>

<p>
	With templates, it's not quite as much of a clear-cut benefit as with CSS; you'll still need to modify the original template in order to include your custom pieces of course. But there's still good reasons for doing so; it keeps your template as clean as possible, meaning if in a later upgrade you have to revert it to get the latest changes, reapplying your custom pieces is easy - you just add the template includes back in.
</p>

<p>
	We've been taking this approach with all custom themes we've created since IPS4's release (dozens by my last count). We try and keep the naming convention consistent too. All custom templates are named <em>_customABC.phtml</em> and exist in the /front/global/ group in the core application. This puts them in an easy-to-find location, and because of the underscore prefix, they're shown at the top of the directory.
</p>

<div class="ipsPad_half ipsAreaBackground_light ipsType_center">
	<p>
		<img alt="files.png" class="ipsImage ipsImage_thumbnailed" data-fileid="90012" data-unique="7jconv0ga" src="//media.invisioncic.com/a319035/monthly_2016_04/files.png.cacaa0a245f1ad767902e6ffc164e054.png" loading="lazy"></p>

	<p>
		<em>Example custom template bits in a custom theme</em>
	</p>
</div>

<p>
	Using them is simple:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_270_4">
<span class="pln">{template="_customHeader" group="global" app="core"}</span></pre>

<p>
	 
</p>

<p>
	I hope this approach helps you keep your templates clean and more manageable! If you have any tips for working with your templates, please share them in the comments!
</p>]]></description><guid isPermaLink="false">965</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Theme Tip: Advanced uses for Pages database fields</title><link>https://invisioncommunity.com/news/community-management/theme-tip-advanced-uses-for-pages-database-fields-r964/</link><description><![CDATA[<p>
	Our Pages app includes a powerful feature that allows you to create your own databases within the community. Within each database, you create custom fields (we support a number of custom types, from plain text fields, to YouTube embeds and more). And while we provide some generic, simple templates to display your data, custom templates allow you to more precisely control how your database looks in a manner best suited to your site.
</p>

<p>
	Anyone who has created a Pages database will be familiar with using custom fields. You may have created a field for the title of your item, or an upload field so that the item contains a file for users to download. But beyond these straightforward uses, I wanted to explore some more advanced uses of custom fields. Fields don't necessarily have to be displayed to the user - or at least not in the usual way. We can use them as configuration options for our record display, or manipulate the data in order to show it in a different way. Let's take a look at some examples.
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">1. Adding an optional badge to records</span>
</p>

<p>
	We'll start with a fairly simple example. In our <a href="https://invisioncommunity.com/4guides/" rel="">Guides</a> section, we highlight guides that have a video tutorial by showing an 'Includes Video Guide' label on the listing:
</p>

<p>
	<img alt="videoguide.jpg" class="ipsImage ipsImage_thumbnailed" data-fileid="89725" data-unique="ykb0e92pw" src="//media.invisioncic.com/a319035/monthly_2016_04/videoguide.jpg.e84a5edb863c769cd02f050b945f2f14.jpg" loading="lazy"></p>

<p>
	We achieve this simply by having a <em>Yes/No field</em> that we turn on as needed. In the field format, we turn the Yes/No value into the label by setting the format to <em>Custom</em> and using this code:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_887_6">
<span class="pln">{{if $formValue == 1}}
	</span><span class="tag">&lt;span</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">'ipsType_medium'</span><span class="tag">&gt;&lt;i</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">'fa fa-video-camera'</span><span class="tag">&gt;&lt;/i&gt;</span><span class="pln"> </span><span class="tag">&lt;strong&gt;</span><span class="pln">Includes Video Guide</span><span class="tag">&lt;/strong&gt;&lt;/span&gt;</span><span class="pln">
{{endif}}</span></pre>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">2. Using fields as a way to configure the record display</span>
</p>

<p>
	Fields don't necessarily need to be shown to users. Instead, we can use them as a means to configure the record display, giving us some really powerful flexibility in how we show records. In this contrived example, I'm going to create a field that changes the background color of the content.
</p>

<ol><li>
		Create a <em>Select Box</em> field. Each option key will be a hex color, while the value will be the name the record creator will choose.
	</li>
	<li>
		Set the field key to <em>record_background</em>
	</li>
	<li>
		Set the field formatting to <em>Custom</em>, and the format to simply: <span style="font-family:courier new,courier,monospace;">{$formValue}</span>. This means it will output our hex value instead of the color name.
	</li>
	<li>
		In the display template assigned to this database for records, we can use the field like so:
		<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_887_10">
<span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">style</span><span class="pun">=</span><span class="atv">'background-color: #{$record-&gt;</span><span class="pln">customFieldDisplayByKey('record_background', 'listing')|raw}' class='ipsPad'&gt;
  ...rest of the template...
</span><span class="tag">&lt;/div&gt;</span></pre>
	</li>
	<li>
		Now, when you create a record, you can choose a color and that color will be used when the record is shown:<br><img alt="background.png" class="ipsImage ipsImage_thumbnailed" data-fileid="89727" data-unique="aorpj1ovr" src="//media.invisioncic.com/a319035/monthly_2016_04/background.png.8df506def342516a95c7b40059289e5f.png" style="width: 306px; height: 150px;" loading="lazy"></li>
</ol><p>
	You can use this approach in others ways - toggles to control the layout of the record, or options for grid sizes, or even take an upload field for images and set the background of an element as that image.
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">3. Pass data to 3rd-party integrations</span>
</p>

<p>
	Pages has built-in support for several 3rd party integrations, such as Spotify, Soundcloud, YouTube and Google Maps. But using custom fields, you can pass data to other services too. Let's say we wanted to embed an iTunes album widget into each of our records - perhaps the album is relevant to the Pages record in some way and we hope to encourage some click-throughs. In this example, we'll use the embed.ly service. 
</p>

<ol><li>
		Create a <em>URL</em> custom field.
	</li>
	<li>
		Set the field key to <em>itunes_album</em>
	</li>
	<li>
		Set the field formatting to <em>Custom</em>, and the format to:
		<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_5618_8">
<span class="tag">&lt;a</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">"embedly-card"</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">"{$formValue}"</span><span class="tag">&gt;</span><span class="pln">iTunes Album</span><span class="tag">&lt;/a&gt;</span><span class="pln">
</span><span class="tag">&lt;script</span><span class="pln"> </span><span class="atn">async</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"//cdn.embedly.com/widgets/platform.js"</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"UTF-8"</span><span class="tag">&gt;&lt;/script&gt;</span></pre>
	</li>
	<li>
		In your database display template, position the field as desired by adding:
		<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_5618_10">
<span class="pln">{$record-&gt;customFieldDisplayByKey('itunes_album', 'listing')|raw}</span></pre>
	</li>
</ol><p>
	Now when you add an iTunes album link to your record, you'll get an embed automatically!
</p>

<p>
	<a class="ipsAttachLink ipsAttachLink_image" href="https://d3bw7kcgs2yofh.cloudfront.net/monthly_2016_04/itunes.png.15f6f2d0a3b5d89d93ebfdeb74a7441a.png" rel="external nofollow"><img class="ipsImage ipsImage_thumbnailed" data-fileid="89788" data-unique="1uzu0yr26" src="//media.invisioncic.com/a319035/monthly_2016_04/itunes.thumb.png.1546d48c89eec21780c419adfe8925e3.png" style="width: 300px; height: 165px;" alt="itunes.png" loading="lazy"></a>
</p>

<p>
	This approach is great for a range of uses. Perhaps you have an Amazon Associates account and want to add a relevant product link to each of your records so that you earn a commission when users click through. Using database fields and templates in this way, it's easy to set up.
</p>

<p>
	 
</p>

<p>
	I hope that's given you some ideas of other ways you might use database fields in Pages. Share any interesting uses you've come up with in the comments!
</p>]]></description><guid isPermaLink="false">964</guid><pubDate>Mon, 18 Apr 2016 13:06:17 +0000</pubDate></item><item><title>Theme Tip: Using Pages blocks anywhere</title><link>https://invisioncommunity.com/news/community-management/theme-tip-using-pages-blocks-anywhere-r962/</link><description><![CDATA[<p>
	Blocks are an extremely popular feature in IPS4, used by a huge number of customers to great effect. They range from feeds of topics, to statistics, to custom blocks that can contain anything you wish. They're a great way to add dynamic content to your community theme.
</p>

<p>
	What many people don't know is that blocks you create with Pages can be used <em>anywhere</em> in your theme, not just in the designated block containers (in the header, footer &amp; sidebar).
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">The {block} tag</span>
</p>

<p>
	It's really easy to do so. Here's the tag you'd use:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_9745_4">
<span class="pln">{block="block_key"}</span></pre>

<p>
	That's it! The <em>block_key</em> is the one you specify when you're creating the block in Pages (if you don't specify one manually, Pages will auto-generate one for you).
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">Where can you use them?</span>
</p>

<p>
	Block tags can be used anywhere that template logic is supported. That includes:
</p>

<ul><li>
		Theme templates
	</li>
	<li>
		Pages page content
	</li>
	<li>
		Other kinds of templates (e.g. database templates)
	</li>
	<li>
		Even within other blocks!
	</li>
</ul><p>
	 
</p>

<p>
	<span style="font-size:18px;">What can you do with them?</span>
</p>

<p>
	The obvious benefit of blocks is that they are reusable, so in any situation where you need the same content duplicated, it makes sense to put the content in a custom block instead, and simply insert it wherever needed. Then if you need to update the content later, you have one place to do so. Custom menus are a great example of reusing blocks; since blocks have full use of template logic, you can build your menu HTML in a block, use HTML Logic to highlight the correct item, and insert the menu block on each of your pages. We use this approach on our <a href="https://invisioncommunity.com/features/apps" rel="">feature tour</a> section menu. Here's a snippet of the menu block HTML for that page:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted" id="ips_uid_3372_11">
<span class="tag">&lt;nav</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">'elTourNav'</span><span class="tag">&gt;</span><span class="pln">
	</span><span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">'container'</span><span class="tag">&gt;</span><span class="pln">
		</span><span class="tag">&lt;ul</span><span class="pln"> </span><span class="atn">class</span><span class="pun">=</span><span class="atv">'ipsList_inline'</span><span class="tag">&gt;</span><span class="pln">
			</span><span class="tag">&lt;li&gt;&lt;a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">'/features/apps'</span><span class="pln"> {{</span><span class="atn">if</span><span class="pln"> \</span><span class="atn">IPS</span><span class="pln">\</span><span class="atn">Request::i</span><span class="pln">()-</span><span class="tag">&gt;</span><span class="pln">path == 'features/apps'}}class='sSelected'{{endif}}&gt;Our Apps</span><span class="tag">&lt;/a&gt;&lt;/li&gt;</span><span class="pln">
			</span><span class="tag">&lt;li&gt;&lt;a</span><span class="pln"> </span><span class="atn">href</span><span class="pun">=</span><span class="atv">'/features/engagement'</span><span class="pln"> {{</span><span class="atn">if</span><span class="pln"> \</span><span class="atn">IPS</span><span class="pln">\</span><span class="atn">Request::i</span><span class="pln">()-</span><span class="tag">&gt;</span><span class="pln">path == 'features/engagement'}}class='sSelected'{{endif}}&gt;Engagement</span><span class="tag">&lt;/a&gt;&lt;/li&gt;</span><span class="pln">
			</span><span class="com">&lt;!-- ... --&gt;</span><span class="pln">
		</span><span class="tag">&lt;/ul&gt;</span><span class="pln">
	</span><span class="tag">&lt;/div&gt;</span><span class="pln">
</span><span class="tag">&lt;/nav&gt;</span></pre>

<p>
	 
</p>

<p>
	Blocks are useful beyond that, though. A couple of weeks ago, we showed you <a href="https://invisioncommunity.com/news/theme-tip-use-html-logic-to-display-content-to-specific-groups-r957/" rel="">how to use HTML Logic to only show content to certain groups</a>. Using blocks is actually an easier way to do this - simply add the content to a custom block, then check the groups who should see it. We use this technique to show a 'welcome to our community' message to guests on our own community. We created our welcome message as a custom Pages block, set it so that only guests have permission to view it, and then added it to our template header. Simple, effective and easy to manage.
</p>

<p>
	That's just two ways you can use blocks - there's many other creative users too! If you've used blocks in an interesting way, share your example in the comments!
</p>]]></description><guid isPermaLink="false">962</guid><pubDate>Mon, 11 Apr 2016 13:02:41 +0000</pubDate></item><item><title>7 ways to secure your community</title><link>https://invisioncommunity.com/news/community-management/7-ways-to-secure-your-community-r960/</link><description><![CDATA[<p>
	Security should never be an afterthought for your community. All too often, site owners consider beefing up their security only when it's too late and their community has already been compromised. Taking some time now to check and improve the security of your community and server could pay dividends by eliminating the cost and hassle of falling victim to hacking in the first place.
</p>

<p>
	Let's run down 7 ways that you can protect your community with the IPS Community Suite, from security features you may not know about to best practices <em>all</em> communities should be following.
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">1. Be selective when adding administrators</span>
</p>

<p>
	Administrator permissions can be extremely damaging in the wrong hands, and granting administrator powers should only be done with great consideration. Granting access to the AdminCP is like handing someone the keys to your house, so before doing so, be sure you <em>really</em> trust the person and that their role requires access to the AdminCP (for example, would moderator permissions be sufficient for the new staff member?).
</p>

<p>
	Don't forget to remove administrator access promptly when necessary too, such as the member of staff leaving your organization. Always be aware of exactly <em>who</em> has administrator access at any given time, and review regularly. You can list all accounts that have AdminCP access by clicking the <em>List Administrators</em> button on the <em>System -&gt; Security</em> page.
</p>

<p>
	<span style="font-size:18px;">2. Utilize Admin Restrictions</span>
</p>

<p>
	In many organizations, staff roles within the community reflect real-world roles - designers need access to templates, accounting needs access to billing, and so forth. IPS4 allows you to limit administrator access to very specific areas of the AdminCP with the Admin Restrictions feature, and even limit what can be done within those areas. This is a great approach for limiting risk to your data; by giving staff members access to only the areas they need to perform their duties, you reduce the potential impact should their account become compromised in future.
</p>

<p>
	<span style="font-size:18px;">3. Choose good passwords</span>
</p>

<p>
	This seems like an obvious suggestion, but surveys regularly show that people choose passwords that are simply too easy to guess or brute force. Your password is naturally the most basic protection of your AdminCP there is, so making sure you're using a <em>good</em> password is essential.
</p>

<p>
	We recommend using a password manager application such as <a href="https://1password.com/" rel="external nofollow">1password</a> or <a href="https://lastpass.com/" rel="external nofollow">LastPass</a>. These applications generate strong, random passwords for each site you use, and store them so that you don't have to remember them.
</p>

<p>
	Even if you don't use a password manager, make sure the passwords you use for your community are unique and <em>never</em> used for others sites too.
</p>

<p>
	<span style="font-size:18px;">4. Stay up to date</span>
</p>

<p>
	It's a fact of software development that from time to time new security issues are reported and promptly fixed. But if you're running several versions behind, once security issues are made public through responsible disclosure, malicious users can exploit those weaknesses in your community.
</p>

<p>
	When we release new updates - especially if they're marked as a security release in our <a href="https://invisioncommunity.com/release-notes/" rel="">release notes</a> - be sure to update as promptly as you can so you receive the latest fixes. Your AdminCP will also let you know when a new version is ready for download.
</p>

<p>
	<span style="font-size:18px;">5. Use .htaccess protection for your AdminCP</span>
</p>

<p>
	In addition to IPS4's own AdminCP login page, you can set up browser-level authentication, giving you a double layer of protection. This is done via a special <em>.htaccess</em> file which instructs the server to prompt for authentication before access to the page is granted. IPS4 can automatically generate this file for you - simply go to <em>System -&gt; Security</em> in your AdminCP, and enable the "Add a secondary admin password" rule.
</p>

<p>
	And it should go without saying, but to be clear: don't use the same username or password for both your .htaccess login and your admin account, or the measure is redundant!
</p>

<p>
	<span style="font-size:18px;">6. Restrict your AdminCP to an IP range where possible</span>
</p>

<p>
	If your organization has a static IP or requires staff members to use a VPN, you can add an additional layer of security to your community by prohibiting access to the AdminCP unless the user's IP matches your whitelist. This is a server-level feature, so consult your IT team or host to find out how to set it up in your particular environment. If you're a <em>Community in the Cloud</em> customer, contact our support team if you'd like to set up this protection for your account.
</p>

<p>
	<span style="font-size:18px;">7. Properly secure your PHP installation</span>
</p>

<p>
	Many of PHP's built-in functions can leave a server vulnerable to high-impact exploits, and yet many of these functions aren't needed by the vast majority of PHP applications you might run. We therefore recommend that you explicitly <strong>disable</strong> these functions using PHP's <em>disable_functions</em> configuration setting. Here's our recommended configuration, although you or your host may need to tweak the list depending on your exact needs:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted">
<span class="pln">disable_functions = escapeshellarg,escapeshellcmd,exec,ini_alter,parse_ini_file,passthru,pcntl_exec,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,show_source,shell_exec,symlink,system</span></pre>

<p>
	Another critical PHP configuration setting you need to check is that <em>open_basedir</em> is <strong>enabled</strong>, especially if you're hosted on a server that also hosts other websites (known as <em>shared hosting</em>). If another account on the server is comprised and <em>open_basedir</em> is disabled, the attacker can potentially gain access to your files too.
</p>

<p>
	Naturally, <em>Community in the Cloud</em> customers needn't worry about either of these steps - we've already handled it for you!
</p>

<p>
	 
</p>

<p>
	So there we go - a brief overview of 7 common-sense ways you can better protect your community and its users. As software developers, we're constantly working to improve the behind-the-scenes security of our software, but as an administrator, there's also a number of steps you should take to keep your community safe on the web.
</p>

<p>
	If you have any tips related to security, be sure to share them in the comments!
</p>]]></description><guid isPermaLink="false">960</guid><pubDate>Tue, 05 Apr 2016 16:00:00 +0000</pubDate></item><item><title>Theme Tip: Create custom error pages with the Pages app</title><link>https://invisioncommunity.com/news/community-management/theme-tip-create-custom-error-pages-with-the-pages-app-r958/</link><description><![CDATA[<p>
	When IPS4 encounters an error (be it a simple <em>404 Not Found</em> or a more complex configuration issue), the user sees a standard built-in error page. That's fine in many cases, but did you know you can create your own error page using our Pages app?
</p>

<p>
	This is a particularly good approach for communities that use Pages for their website too. If you have built a website theme, the standard error page may not fit with your visual style, so building your own error page allows you to improve it. You might want to show some helpful links to other parts of your website, for example.
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">Creating your error page</span>
</p>

<p>
	The first step is creating your error page in Pages. Note that for this page, <strong>you must create a manual page</strong> - the Page Builder tool can't be used in this case.
</p>

<p>
	In order to show the error on your page, there's two special tags you should insert in the page content. When your page is shown in response to an error, Pages will swap out these tags for the relevant text. They are:
</p>

<ul><li>
		<strong><span style="font-family:'courier new', courier, monospace;">{error_code}</span></strong><br>
		Replaced with the technical error code for this error. This code identifies the exact piece of code that triggered the error, and can be given to IPS support technicians to help diagnose problems.
	</li>
	<li>
		<strong><span style="font-family:'courier new', courier, monospace;">{error_message}</span></strong><br>
		Replaced with a human-friendly description of the error that occurred.
	</li>
</ul><p>
	 
</p>

<p>
	<span style="font-size:18px;">Configuring Pages to use the error page</span>
</p>

<p>
	Next, set Pages to display the error page. You do this in the Pages section; click the Advanced Settings button, and select your page from the list. Note that this will replace <strong>all</strong> error pages across the suite - not just errors triggered by Pages itself!
</p>

<p>
	 
</p>

<p>
	<strong style="font-weight:bold;color:rgb(39,42,52);font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:22.4px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);">Have a request for a theme tip?</strong><span style="color:rgb(39,42,52);font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:22.4px;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;background-color:rgb(255,255,255);"> Let us know in the comments and we'll try and help out in a future tip! </span>
</p>

<p>
	 
</p>]]></description><guid isPermaLink="false">958</guid><pubDate>Mon, 04 Apr 2016 12:24:53 +0000</pubDate></item><item><title>Theme Tip: Use HTML logic to display content to specific groups</title><link>https://invisioncommunity.com/news/community-management/theme-tip-use-html-logic-to-display-content-to-specific-groups-r957/</link><description><![CDATA[<p>
	HTML Logic is our name for the additional tags available in IPS4's templates that allow runtime logic to be executed. It comprises if/then/else statements as well as loops and more.
</p>

<p>
	Since HTML Logic has access to all of the underlying PHP framework in IPS4, it's very powerful and a lot can be achieved with it. One common use is to limit certain content within a template to particular member groups. Let's see how that might be done.
</p>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">Showing or hiding content only to guests</span>
</p>

<p>
	We'll first look at a simpler idea: showing or hiding content specifically to guests (i.e. anyone who isn't logged in). Within IPS4, the <span style="font-family:'courier new', courier, monospace;">\IPS\Member::loggedIn()</span> object contains information about the current user. Guests always have a <span style="font-family:'courier new', courier, monospace;">member_id</span> of <span style="font-family:'courier new', courier, monospace;">NULL</span> (i.e. no value), so we can simply check that value in our logic tag:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted">
<span class="pln">{{if \IPS\Member::loggedIn()-&gt;member_id === NULL}}
	This content *only* shows to guests, since they have a NULL member_id.
{{endif}}

{{if \IPS\Member::loggedIn()-&gt;member_id}}
	This content *only* shows to logged-in users since their member_id is a number, which will equal true.
{{endif}}</span></pre>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">Showing content only to specific groups</span>
</p>

<p>
	Let's go a bit further and this time show content to specific (primary) member groups. First, you need to get the IDs for the group(s) you want to deal with. You can find this by editing the group in the AdminCP, and making a note of the <em>id</em> parameter in the URL. On my installation, the Administrator group is ID 4 so we'll use that in our example.
</p>

<p>
	Once again, we're using the <span style="font-family:'courier new', courier, monospace;">\IPS\Member::loggedIn()</span> object, but this time we're using the <span style="font-family:'courier new', courier, monospace;">member_group_id</span> property.
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted">
<span class="pln">{{if \IPS\Member::loggedIn()-&gt;member_group_id === 4}}
	This content only shows to members in the "Administrators" group (ID 4 in our example)
{{endif}}</span></pre>

<p>
	 
</p>

<p>
	<span style="font-size:18px;">Working with multiple groups at once</span>
</p>

<p>
	Following the code above, you could simply repeat the check against <span style="font-family:'courier new', courier, monospace;">\IPS\Member::loggedIn()-&gt;member_group_id</span> several times, for each ID you want to allow. However, since our templates allow arbitrary PHP expressions to be used, there's a neater way: use an array of member group IDs you want to allow, and check against that using PHP's <span style="font-family:'courier new', courier, monospace;">in_array</span> function. Here's an example where we only show content to group IDs 2, 4 and 6:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted">
<span class="pln">{{if in_array( \IPS\Member::loggedIn()-&gt;member_group_id, array( 2, 4, 6 ) )}}
	This content only shows to members in groups with the ID 2, 4 or 6.
{{endif}}</span></pre>

<p>
	 
</p>

<p>
	<strong>Have a request for a theme tip?</strong> Let us know in the comments and we'll try and help out in a future tip! 
</p>]]></description><guid isPermaLink="false">957</guid><pubDate>Mon, 28 Mar 2016 12:29:32 +0000</pubDate></item><item><title>Theme Tip: Apply CSS to specific Pages databases</title><link>https://invisioncommunity.com/news/community-management/theme-tip-apply-css-to-specific-pages-databases-r955/</link><description><![CDATA[<p>
	When you use custom templates for a Pages database, you'll often need custom CSS to go along with it to provide the styling. There's two main ways of doing this:
</p>

<p>
	<span style="font-size:18px;">CSS files within Pages</span>
</p>

<p>
	Pages allows you to create CSS files, and then associate them with particular custom pages of your community (you create these in the AdminCP, under Pages &gt; Templates &gt; CSS). So simply create your CSS file, and associate it to the page that your database is displayed on.
</p>

<p>
	The benefit of this method is it applies to all themes, so it's great if you want your database to look the same on all themes. Of course, this is also the drawback - you can't easily use it for per-theme customization.
</p>

<p>
	<span style="font-size:18px;">Targeting the database classname in theme CSS</span>
</p>

<p>
	Alternatively, you can target the database classname in your normal theme CSS files. When a database is inserted into a page, IPS4 helpfully adds a classname to the <span style="font-family:courier new,courier,monospace;">body</span> element, which makes it really simple to style that page in particular. If your database key is <em>myDatabase</em>, then the classname added to the body element would be <span style="font-family:courier new,courier,monospace;">cCmsDatabase_myDatabase</span>. Use this in your selectors and you can style everything exactly how you need:
</p>

<pre class="ipsCode prettyprint lang-css prettyprinted" id="ips_uid_2550_4">
<span class="pun">.</span><span class="pln">cCmsDatabase_myDatabase </span><span class="pun">.</span><span class="pln">ipsButton_important </span><span class="pun">{</span><span class="pln">
  </span><span class="com">/* Style important buttons differently in this database, for example */</span><span class="pln">
</span><span class="pun">}</span></pre>

<p>
	<span style="font-size:18px;">Combine both methods!</span>
</p>

<p>
	Of course, you can use <em>both</em> approaches when it makes sense. Create a CSS file within Pages for the basic structural styling that will apply regardless of which theme the user uses, and then in each theme target the database classname to customize it for that particular theme - perfect for the colors, font family and so on.
</p>]]></description><guid isPermaLink="false">955</guid><pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate></item><item><title>Theme Tip: Twitter Embed Block</title><link>https://invisioncommunity.com/news/community-management/theme-tip-twitter-embed-block-r952/</link><description><![CDATA[<p>
	Several clients have asked how we placed the Twitter feed block on the sidebar of our <a href="https://invisioncommunity.com/news" rel="">News page</a>. It's really quite easy and a great demo of how you can place custom HTML in our system. Here is how it was done:
</p>

<ol><li>
		Get the embed code from Twitter
	</li>
	<li>
		Create a custom HTML block in our Pages app
	</li>
	<li>
		Drag and drop that block into the sidebar
	</li>
</ol><p>
	That really is it! Here is a video walkthrough:
</p>

<div class="ipsEmbeddedVideo ipsEmbeddedVideo_limited">
	<div>
		<iframe allowfullscreen="true" frameborder="0" height="1372" src="https://player.vimeo.com/video/158660980" title="Theme Tip: Twitter Embed" width="1658" loading="lazy"></iframe>
	</div>
</div>

<p>
	This is a basic example of a custom HTML block that you can use in so many different ways. You could create a "call to action" the only shows to Guests to get them to register. You might also create text that only displays to your staff with quick links to areas they need.
</p>

<p>
	Here we demo dragging the block into the sidebar. You can also put blocks right in theme templates and use them in many more ways. That will be covered in future theme tips.
</p>]]></description><guid isPermaLink="false">952</guid><pubDate>Mon, 14 Mar 2016 13:06:00 +0000</pubDate></item></channel></rss>
