Day 3 – Using your Interfaces in Public Mode with a Template in DB-Toolkit

Posted by David Cramer on Nov 6, 2010

wallsmall-185x185[1]

Part of the beauty of DB-Toolkit, is being able to make your interfaces accessible to the public. You might ask why would i want to do that? Well, in this lesson, I’m going to show you a basic example of making our contacts interface public with a template output. The result is something similar to twitters following pane that shows icons of all the people you follow. While not really the same it will give us the same looking result. This tutorial will introduce the Template tab and Shortcodes. I’m going to asume you have already done Day 1 and Day 2 so I’m going to refer to things covered in those tutorials, you might want to go over them before continuing. So lets get right in!

wallpreview1[1]

The widget based interface we’re going to build

Duplication

contactwallsetting[1]

Settings for our contact wall

Most of the time, when interfacing the same table multiple times, I find it easier to just duplicate the interface and work from there, that way most of the FieldType Allocation is already done. Lets duplicate the Contacts Manager interface as explained in Day 2 and click the Edit to start with your new interface interface.

Title: Contacts Photo Wall
Interface Description: Contacts Photo Wall. We copied the title here because since its not being used as an admin interface, it doesn’t need a distinct title and description. its really up to you on what you call it.
Set as Dashboard Item: leave unchecked, we’ll get to that in another lesson.
Menu Group: since this is a front end item, we don’t need it in a menu group. So make this blank. It will be placed in an ungrouped area in your interface list.
Effective Permissions: These permissions carry through to the front end, so well set it to all, so that the public can view it. If you where to set it to anything else, the interface wont show to the public, but will show if a user of the matching permission was logged in. Very handy!

Now scroll down till you get to the Photo field panel and click the Setup button on the bottom right corner of the panel. This opens the FieldType Config panel as seen below. The 3 sizes here are icon, view and full. Icon, is the size seen in a list view, the second view size is seen when you view a specified entry, and full is when the second view is clicked. Here we’ll set the size of our Icon to 45 and we’ll keep Square Crop checked. this will force our image to be cropped square.

setupphotosize[1]

setup the size of your icons.

Now that that’s done, we head on to the List Template. Scroll all the way up and click on the List Template tab.

Templates

The first thing you see on this tab is “Use Template” make sure its checked. when you check this, it tells the system not to push the data to a table, but rather wrap it up in the code we give it. See. List Templates in the documentation for the anatomy of List Templates.

Scroll down to the Content template box and use this code.

<div style="padding:2px; margin:1px; float:left; border:1px solid #efefef;" title="{{Firstname}} {{Lastname}}">{{Photo}}</div>

the curly braces {{}} are dynamic wrappers. when a field name is wrapped in these, it will get replaced by the content of that field on render. dynamic wrappers can only be used in Content and Footer template box. These two boxes are followed by a usable keys panel that gives reference the keys that can be used. Now scroll down to the Content Wrapper End template box and use this code to end off.

<div style="clear:left;"></div>

this will clear off our left floats.

Settings

we need to turn off a few things to make our interface show only the templated content, so click on Settings tab.

templategeneralsettings[1]

general settings

General Settings Panel I’m not going to mention any of the other settings, just the ones we’re interested in for now.

Hide Frame: Check this. this will make it so there is no framing panel and title around our interface.
Hide new item button: check this. This will disable adding of new entries on this interface.
Items per Page: This is the amount of items shown per page. if there are 16 entries and you show 8, there will then be 2 pages of entries. set this to 8 (or what ever you want for now) leaving this blank means no limit.

Now Scroll down to Toolbar Settings, and check Hide Toolbar, this will make it so the toolbar which holds the Add new button, Show filters etc.. not render. we want only the icons to show so this must go.

Scroll down to the next panel, List Settings and uncheck the Show Footer, we don’t want this to show, we only want to show the icons.

Now scroll right to the bottom and click Save.

photowalltut[1]

our photo wall

You can now go and View your interface and it should look something like the image to the right, depending on how many you captured previously.

Short Code Embedding

We now need to embed the interface into our front end. We are going to do this on a Widget. First we need to get the Short code, so go to your interface list from the DB Toolkit -> Interfaces menu. Copy the Short Code for our Contacts Photo Wall interface. Now lets go to to the Widgets page by clicking on Appearance -> Widgets.

We use the simple Text widget for embedding interfaces, so drag the Text widget to your sidebar of choice where you want your wall to show and in the Title box, type in My Contacts and in the Text box past in the Short Code you copied earlier.

And that’s it! You have created a simple contacts photo wall. You can use either the Capture form we made in Day 2 or the report from Day 1 to add more contacts to the wall.

One thought on “Day 3 – Using your Interfaces in Public Mode with a Template in DB-Toolkit

  • Tuesday November 26th, 2013 at 11:36
    Permalink

    Thank you Jack for these great tutorials about DB toolkit.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *