Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lokothodida's full-sized avatar

Lawrence Okoth-Odida lokothodida

View GitHub Profile
@lokothodida
lokothodida / jquery.nestedplugin.js
Last active August 29, 2015 14:24
jQuery Nested Plugins
// This piece of code illustrates how you can build a series of jQuery plugins
// nested on your own desired namespace. So if you have a plugin named 'plugin',
// it can have the signature:
// $(selector).plugin(opts)
// and there can exist jQuery plugins 'module1', 'module2', 'module3', ... which
// have the signatures:
// $(selector).plugin().module1(opts)
// $(selector).plugin().module2(opts)
// $(selector).plugin().module3(opts)
// These modules are written almost exactly like normal jQuery plugins bound
@lokothodida
lokothodida / jquery.nestedplugin.bonus.js
Created July 13, 2015 14:57
jQuery Nested Plugins Bonuses
;(function($, window, document, undefined) {
// == BONUS 1 ==
// Others can add to your modules by extending $.fn.plugin.modules literal
// E.g: (accessed with $(selector).plugin().externalModule(opts))
$.fn.plugin.modules.externalModule = function(opts) {
// Code for this plugin ...
};
// == BONUS 2 ==
@lokothodida
lokothodida / jquery.simplei18n.js
Created July 15, 2015 13:32
jQuery Simple Internationalization (i18n) Support
// This snippet shows how to add simple internationalization (i18n)
// functionality to your jQuery plugin
// The concept is general enough to apply to any library and not just jQuery
// This is based slightly on how elFinder does its i18n functionality
;(function($, window, document, undefined) {
// Create your plugin on the $.fn namespace
// We are using @plugin as an alias so that we can attach properties to it
// later on without having to do $.fn.plugin.propertyName etc
var plugin = $.fn.plugin = function(options) {
@lokothodida
lokothodida / elfinder.src.clean.html
Created July 23, 2015 15:44
A cleaned up version of the elFinder 2.x source HTML file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>elFinder 2.x source version with PHP connector</title>
<script src="jquery/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery/jquery-ui-1.10.1.custom.min.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="jquery/ui-themes/smoothness/jquery-ui-1.10.1.custom.css" type="text/css" media="screen" title="no title" charset="utf-8">
@lokothodida
lokothodida / getsimple-tutorial-i18n-news.md
Created August 16, 2015 19:09
GetSimple tutorial for creating a news system with the i18n plugin(s).

Content Management Systems (CMSs) are pretty self-explanatory: they are dynamic ways of maintaining, displaying and publishing content, and they seek to be intuitive, feature-rich and easy to use. One such a system is GetSimple, a CMS with a tiny zip file-size, and an expansive array of useful plugins to enhance its utility.

Now if you have a site that isn't made up of purely static web-pages, you are going to want to show your visitors flag-points of when certain content was produced or published, and the best way that most CMSs do this is with 'blogging' or 'news publishing' software. There are a number of such plugins available on GetSimple's Plugins Repository, but from what I have tested thus far, long-time plugin developer Mvlcek has produced one of the most extensive and useful plugins for achieving this to date. However some may find it a little difficult to get around, because it is primarily a Search Engine Plugin for allowing visitors to easily search the pages of your si
@lokothodida
lokothodida / getsimple-tutorial-i18n-news-v2.md
Created August 16, 2015 19:11
GetSimple tutorial for creating a news system with the i18n plugin(s) (version 2)

If you have a website, chances are that you'll be updating it at some stage. From minuscule punctuation corrections to changing the banner, it's good to keep your viewers up to scratch on the development of your site. Visitors like to know that they were a part of (or at least informed of) the growth of an entity. Blogs are specifically engineered to be as user-friendly and intuitive as possible when it comes to posting updates, but they aren't necessarily the most potent way to achieve this. As noted in the previous version of this article, other Content Management Systems (of which blogs are a variety) provide much more options with regards to the layout of your site, the displaying of content and the organisation of pages. One such CMS is GetSimple, and plugin developer mvlcek has recently updated his i18n Search plugin to become an incredibly useful and powerful news system.

So how does i18n Search work?

Reading this, I'm assuming that you know what GetSimple is, as well as how to insta
@lokothodida
lokothodida / getsimple-tutorial-i18n-news-v2.md
Created August 16, 2015 19:13
GetSimple tutorial for creating a news system with the i18n plugin(s) (version 3)
@lokothodida
lokothodida / getsimple-tutorial-archiving-with-i18n.md
Created August 16, 2015 19:27
GetSimple tutorial for archiving pages (in news/blogging fashion) with i18n.

One feature that I thought was missing from the i18n News system is that of providing automatic archives for news results. However, such a feat is actually achievable with the current i18n Search plugin if you take a moment to think outside of the box...

Plugins you'll need

The importance of tags

Tags are the lifeblood of i18n Search. They are the key to filtering out your results to output exactly the kind of content that you are looking for and ordering them in a sensible way. Initially, tags were simply there as key-words to be involved in the “meta” information of the page – words that would help your site/page be indexed by search engines and found by users. With i18n Search however, these tags can be used to set up virtual categories and a filtering system, provided that you can maintain some kind of logical structure and consistency with the tags that you utilise.

@lokothodida
lokothodida / getsimple-tutorial-sidebars.md
Last active August 29, 2015 14:27
GetSimple tutorial for integrating page-specific sidebars on your site.

GetSimple Tutorial: Sidebars

A common request people have when it comes to having a dynamic site is the ability to create content displayed adjacently to the main content: a “side-bar” if you will. Sometimes it will be content that should be displayed universally, regardless of the page that you're viewing, such as a 'Latest News/Blog/Tweet' block, or a calendar widget. Other times it is a very page-specific piece of content, like an extra menu to a set of relevant links to the main content, or the latest comments made on the current page. The biggest problem that people tend to have is the difficulty of maintenance of such sidebar content – often you have to hard-wire the code into your layout and continually have to edit the content from the template file or as a component, which can be very grating when you have page-specific sidebars and a lot of pages to boot.

This article will outline a way that I think is a pretty efficient way of providing yourself either universal sidebar widgets, page-specific s

@lokothodida
lokothodida / getsimple-tutorial-i18n-customfields-conditional-rendering.md
Last active August 29, 2015 14:27
GetSimple tutorial for rendering a (i18n) custom field conditionally.

GetSimple Tutorial: i18n Custom Fields: Conditional Rendering

Oleg06 of the GetSimple forums once asked about displaying certain content from a Special/Custom field based on whether or not the field is filled.

To do this, you simply form a conditional using the return_special_field function, checking that the result (a string) is non-empty:

<?php
  if (return_special_field($field) !== '') {
    // output