Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Spudley committed Aug 26, 2018
0 parents commit 8574b39
Show file tree
Hide file tree
Showing 8 changed files with 519 additions and 0 deletions.
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions README.md
@@ -0,0 +1,77 @@
Random Strapline
=======================

A small Joomla! module to display a random line of content from the module config.

Written by Simon Champion, August 2018.


Version History
---------------

* v1.0.0 Initial release.


Introduction
------------

This is a very small Joomla! module that allows you to place small single line of text on your page, which is selected at random from a number of lines configured in the module.

I am using this for the strapline of my site (ie a line of text below the site logo). The module allows me to have several possible straplines and display a random one from the list on the page.

As with any module, it can be placed anywhere on your site, so you are of course free to use it for displaying any random text, not just straplines.


Installation
------------

This module should be installed via the Extensions manager in Joomla!'s admin panel. You should also ensure that you have K2 installed in your Joomla! instance, as this module relies on it.


Setup
-----

Configuring the module is very simple. It has two configuration fields:

- HTML Class: This sets the class for the module's content. You can use this for styling the element.

- Straplines: This is the text field where you put the strapline texts. The module will split the text field content into lines, and pick one of them at random to display.


Multiple Instances
------------------

As with all Joomla! modules, you can create duplicates of the module with different config parameters and different publishing positions, etc. This may be useful if you have a lot of categories and want to provide separate lists for groups of related feeds.

Use the "Duplicate" button on the list of modules to achieve this. This is standard Joomla! functionality, so please see the Joomla! documentation for more details.


Who wrote this?
---------------

This code was written by Simon Champion.

All code in this repository is released under the GPLv2 licence. The GPLv2 licence document should be included with the code.



Known bugs and Limitations
--------------------------

- Note that this extension has only been tested against the current versions of Joomla! (3.8.11 at the time of writing).
- If your site uses caching (and it should do), then the module content may only be refreshed whenever the cache expires, rather than on every page load.


Todo
----

* No further work planned.


Trademarks and Licenses
-----------------------

* Joomla!® is a registered trademark of Open Source Matters, Inc.
* Joomla! is distributed under the GPLv2 licence.
* This package is distributed under the GPLv2 licence. The GPLv2 licence document should be included with the code.

15 changes: 15 additions & 0 deletions language/en-GB/en-GB.mod_randomstrapline.ini
@@ -0,0 +1,15 @@
; @package mod_randomstrapline
; @language English
; @version 1.0.0
; @author Simon Champion
; @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html

MOD_RANDOMSTRAPLINES_NAME="Random Strapline"
MOD_RANDOMSTRAPLINES_DESCRIPTION="Outputs a random line from the module config. Useful for dynamic spot content."

MOD_RANDOMSTRAPLINES_HTMLCLASS_LABEL="HTML Class"
MOD_RANDOMSTRAPLINES_HTMLCLASS_DESC="Classname for the strapline element."

MOD_RANDOMSTRAPLINES_STRAPLINES_LABEL="Straplines"
MOD_RANDOMSTRAPLINES_STRAPLINES_DESC="The strapline content. One random line from this content will be displayed."

10 changes: 10 additions & 0 deletions language/en-GB/en-GB.mod_randomstrapline.sys.ini
@@ -0,0 +1,10 @@
; @package mod_randomstrapline
; @language English
; @version 1.0.0
; @author Simon Champion
; @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html

MOD_RANDOMSTRAPLINES="Random Strapline"
MOD_RANDOMSTRAPLINES_NAME="Random Strapline"
MOD_RANDOMSTRAPLINES_DESCRIPTION="Outputs a random line from the module config. Useful for dynamic spot content."

17 changes: 17 additions & 0 deletions mod_randomstrapline.php
@@ -0,0 +1,17 @@
<?php
/**
* @package mod_randomstrapline
*
* @copyright Copyright (C) 2018 Simon Champion.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

$htmlclass = $params->get('htmlclass','strapline');
$straplines = preg_split("~[\n\r]+~",$params->get('straplines'));
shuffle($straplines);
$strapline = array_pop($straplines);

require JModuleHelper::getLayoutPath('mod_randomstrapline', 'default');

31 changes: 31 additions & 0 deletions mod_randomstrapline.xml
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.8" client="site" method="upgrade">
<name>MOD_RANDOMSTRAPLINES_NAME</name>
<author>Simon Champion</author>
<creationDate>August 2018</creationDate>
<copyright>Copyright (C) 2018 Simon Champion.</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<authorEmail>simon@simonchampion.net</authorEmail>
<authorUrl>https://github.com/Spudley</authorUrl>
<version>1.0.0</version>
<description>MOD_RANDOMSTRAPLINES_DESCRIPTION</description>
<files>
<filename module="mod_randomstrapline">mod_randomstrapline.php</filename>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.mod_randomstrapline.sys.ini</language>
<language tag="en-GB">language/en-GB/en-GB.mod_randomstrapline.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="htmlclass" type="text" default="" label="MOD_RANDOMSTRAPLINES_HTMLCLASS_LABEL" description="MOD_RANDOMSTRAPLINES_HTMLCLASS_DESC"/>
<field name="straplines" type="textarea" default="" label="MOD_RANDOMSTRAPLINES_STRAPLINES_LABEL" description="MOD_RANDOMSTRAPLINES_STRAPLINES_DESC"/>
</fieldset>
</fields>
</config>
<updateservers>
<server type="extension" priority="2" name="Random Straplines Updates">https://raw.githubusercontent.com/Spudley/mod_randomstraplines/master/update.xml</server>
</updateservers>
</extension>
13 changes: 13 additions & 0 deletions tmpl/default.php
@@ -0,0 +1,13 @@
<?php
/**
* @package mod_randomstrapline
*
* @copyright Copyright (C) 2018 Simon Champion.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

?>
<div class="<?php echo $htmlclass; ?>"><?php echo $strapline; ?></div>

17 changes: 17 additions & 0 deletions update.xml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<updates>
<update>
<name>Random Strapline</name>
<description>Displays a random single line from a the lines in the module config</description>
<element>randomstrapline</element>
<type>module</type>
<version>1.0.0</version>
<client>0</client>
<infourl title="Random Strapline">https://github.com/Spudley/mod_randomstrapline/releases/tag/1.0.0</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/Spudley/mod_randomstrapline/archive/1.0.0.zip</downloadurl>
</downloads>
<targetplatform name="joomla" version="3.[56789]" />
<php_minimum>5.6.0</php_minimum>
</update>
</updates>

0 comments on commit 8574b39

Please sign in to comment.