Using templates/partials, some examples, etc.


  • Plugin & Theme Dev

    I believe you should have as many partials in your main template as efficiently as possible to cut down on redundant code. Here I'll write the standard for a good rule of thumb on how you should organize your templates and all the code within in them.

    Any redundant JS scripts should be in their own partial to be reused in other templates if need be.

    Take full advantage of the NBB API so that you extend your template even further. For example using <!-- IF loggedIn --> condition can greatly improve UX and conversions rates on your site. Having some type of call to action or banner within these will let the user know that they aren't logged. OR when they are logged in, show something else. You can come up with some pretty crafty ideas. But yeah, do what you can with the existing API.

    You can only do so much with the templates but is that good enough? Maybe, maybe not, but it does work when you plan out the logical flow and hopefully not get lost in the div's and such. For example on the Majestic Theme, the topic covers are pretty complex and one can easily get lost in the flow of what's going on. Here's a screenshot of the topics UI.

    Screen Shot 2015-03-17 at 8.12.29 AM.png

    Now lets take a little peek at whats under the hood;

    Screen Shot 2015-03-17 at 8.16.46 AM.png

    Screen Shot 2015-03-17 at 8.14.33 AM.png

    Now there's way more to this, but this is just a little example of how I control the topic covers. The only reason why I'm posting this is because I'm quite certain it would take a while to replicate without all of the other partials in this one template (not shown for obvious reasons).

    You can also do stuff like this to take control over pluralization of your template: post<!-- IF !topics.unreplied -->s<!-- ENDIF !topics.unreplied -->
    Which would mean, if you don't have any posts, remove the s in post, otherwise its posts. Neat huh?

    Anyone else have any cool things they've done with the template system so far in their existing theme? Share some of your ideas here. 🙂


 

| |