Jump to content
Macrura

Soundmanager2 Audio for Processwire

Recommended Posts

Soundmanager2 Audio for Processwire

Github:

https://github.com/outflux3/TextformatterSoundmanager

Modules Directory:

http://modules.processwire.com/modules/textformatter-soundmanager/

This module provides most of the free audio player interfaces for Soundmanager2 by Scott Schiller:

  • Bar UI
  • 360 UI
  • 360+ spectrum UI
  • mp3 buttons
  • mp3 links
  • Page Player, muxtape-style UI
  • Cassette Player

The module is a Textformatter that works by allowing you to insert shortcodes which are parsed into audio players.

The players may be placed anywhere in the content (ck editor or other text field) using the shortcode, for example:

[smplayer tag=audio1]

The output will be a default single player (as specificed in the module settings), or if multiple audio files have the same tag, and you don't specify a type (UI), it will default to the Bar UI for the playlist. You may also specify page-player for the type as it also supports playlists.

Here is a more complex tag:

[smplayer tag=audio1 type=bar-ui color=2288CC]

the tags available on shortcodes are:

  • tag - *required to find the audio file on the page
  • type (the type of player)
  • limit (limit the number of files to load when using a playlist)

Player specific tags for Bar UI:

  • bar-ui (options for the bar-ui player)
  • skin (applies to a bar-ui skin to load)
  • extra (when set to true, it will display the extra controls)
  • color (hex value for color - applies to bar-ui and mp3 buttons)
  • compact (makes the player very narrow)
  • playlist-open (make the playlist drawer open instead of needing to click the playlist button to open it.)
  • dark-text (instead of white)
  • flat (remove the faux 3d effect)

When using the shortcode, you can chain the tags using underscore, for exmaple:

[smplayer type=bar-ui bar-ui=flat_playlist-open_dark_text]

Player specific tags for Cassette:

  • cassette (options for the cassette player)

In case you are not familiar with SM2, it powers a lot of major audio on the web, like Soundcloud, LastFM, AllMusic etc). The players are all rock solid and work on a wide range of browsers and devices.

Features

Multiple Audio Formats

SM2 supports many formats, and those can be enabled/disabled in the module config if you want to prevent any from being loaded. So far this module was tested with MP3 and AAC (.m4a).

GetID3 Support

When enabled, ID3 tags from every audio file that pass through the Textformatter are read and cached as arrays using WireCache. Therefore the first load of a page with new audio files may be slow while the tags are read and stored. The tags are indexed by the filename of the audio, so as long as you don't upload multiple files with the same filename, or change the tags, the system will store the metadata permanently. To remove any metadata, you would need to use Soma's Cache Admin module, or clear it from the database.

Schema Support

When enabled, some schema tags relating to audio files will be added to the markup.

CK editor Plugin

Very basic dropdown that inserts some pre-configured player codes into the editor. Copy the plugin into your CK editor plugins folder, enable and add a button for 'soundmanager'.

Edit_Page__Soundmanager2_Audio_Testing_Page_•_localhost.jpg

Instructions

Before you install:

1) You will need a files field that accepts audio files, so set the extensions you want to use, such as mp3, m4a, mp4, wav etc. 2) Also make sure that you enable tags on the files field because the module references the tags for any audio file in the shortcode. 3) Add the files field to your template.

Installation and Setup

1) Install the module and adjust your settings from the module configuration screen.

2) Add the TextformatterSoundmanager textformatter to the field where you want to insert audio (e.g. 'body').

3) Optionally install the CK editor plugin to enable quick access to preconfigured shortcodes.

4) Add a shortcode into the textarea field that has the textformatter applied to.

5) You must reference the tag you entered in the audio file's tag field in the shortcode, and that will create a player for that audio file.

5a) To create a playlist, put the same tag in multiple audio files.

Output

1) In order for the module to output the necessary styles and scripts, you need to echo the $config->styles and $config->scripts arrays into your site's header/footer. Here is an example:

// In Header
foreach($config->styles as $style) echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n";

// In Footer
foreach($config->scripts as $script) echo "<script type='text/javascript' src='{$script}'></script>\n";

 

API Usage

To access the module's player method directly, you would first init the module in your _init.php file:


    $sm2 = $modules->get('TextformatterSoundmanager');

then anywhere in your templates, you can output any audio file with any player, in an configuration like this:

    $options = [
        'type' => 'bar-ui',
        'skin' => 'gradient-fat',
        //'tag' => 'audio1', // tag is not needed when using the API
        //'bar-ui' => 'playlist-open' //all of the classes to apply to the bar ui.
    ];

    foreach($page->audio as $track) {
        $content .= $sm2->player($track, $options);
    }

Advanced Features

  • Using other pages for storing music as playlists. You can create a field to hold a tag for a **page* and then refer to that tag in your shortcode. The shortcode word would be smplaylist instead of smplayer. The module will search the site for pages with that tag in that field. Then it will output all of the audio files in that page's audio field using the player and settings you specify. See the module configuration to select the tag field and adjust your shortcode words.

Caveats

Some player will not work well on the same page as other players.

  • Bar UI and Page Player
  • 360 Player and 360 Visual (large) players

Also note that the cassette player can only occur once on a page. You can have multiple cassettes output, but they will all play the same audio file. The file that the cassette player uses is set in the script tag. In the future the setup may be modified to allow for cassette players to have their own audio files.

About Soundmanager2

http://www.schillmania.com/projects/soundmanager2/

Speak and be heard

More sound, in more places

Despite being one of the senses, sound has largely been missing from the web due to inconsistent technology support. SoundManager 2 bridges this gap, making it easier to use audio across a growing variety of devices and platforms, both desktop and mobile.

HTML5 + flash hybrid

Complexity, reduced

Supporting HTML5 audio can be tedious in modern browsers, let alone legacy ones. With real-world visitors using browsers ranging from mobile Safari to IE 6 across a wide range of devices, there can be many support cases to consider.

SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works."

The ginsu knife: 12 KB

Big features, small footprint

Performance is an important metric, too. SoundManager 2 packs a comprehensive, feature-rich API into as little as 12 KB over the wire when optimized; that's less than 8% of the original, uncompressed file size.

SM2 is self-contained, having no external dependencies, and is compatible with popular JavaScript frameworks.

The source code is BSD-licensed and is provided in fully-commented, non-debug and compiler-optimized "minified" versions appropriate for development and production use.

 

  • Like 20

Share this post


Link to post
Share on other sites

This module is now available on GitHub.

Still beta, but working well on all sites tested on. More documentation coming soon.

If anyone out there needs inline audio on your site, check this out.

** make sure to read the instructions on Github, as those will always be updated to the latest (hard to keep the instructions here sync'd with the module instructions)...

  • Like 4

Share this post


Link to post
Share on other sites

Here are some of the custom skins provided for the Bar-UI, and the shortcodes used:

 

Soundmanager2_Bar_UI.jpg

  • Like 4

Share this post


Link to post
Share on other sites

Here are some of the pre-configured cassette ui players:

Soudmanager2_Cassette.jpg

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for the module. I'am trying to get it to work. Could you please check these settings?

In Header:

<?php foreach($config->styles as $style) echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n"; ?>

Before closing body tag:

<?php foreach($config->scripts as $script) echo "<script type='text/javascript' src='{$script}'></script>\n"; ?>

I created a _init.php located in 'templates'

<?php
include_once("./_func.php"); // include our shared functions

$sm2 = $modules->get('TextformatterSoundmanager');

In my config.php I added

$config->prependTemplateFile = '_init.php';

Files field added to template mp3

1923846095_Schermafbeelding2018-06-29om14_06_48.thumb.png.4e471c6ecaaf1c7dd8058a2d2f2b7cb5.png1923846095_Schermafbeelding2018-06-29om14_06_48.thumb.png.4e471c6ecaaf1c7dd8058a2d2f2b7cb5.png

 

In my template file I added:

<?php $options = [
							        'type' => 'bar-ui',
							        'skin' => 'gradient-fat',
							        //'tag' => 'audio1', // tag is not needed when using the API
							        //'bar-ui' => 'playlist-open' //all of the classes to apply to the bar ui.
							    ];
							
							    foreach($page->audio as $track) {
							        $content .= $sm2->player($track, $options);
							    } ?>

 

Share this post


Link to post
Share on other sites

It all looks correct; you can also just do this:

echo $sm2->player($page->audio, $options);

If you are not getting players showing you'd need to ensure that the settings are all correct in the module config, and then check to make sure the CSS and JS are being output on your page;

then make sure the markup is being output correctly; it would be easier once these things are checked; if you are getting styles & scripts output, and are getting markup output, and still not seeing players, check the console to see if there are any JS errors.

Share this post


Link to post
Share on other sites

How do I get the cassette interface on a page?

The text field has "[smplayer tag=cryplant type=cassette]", cassette options in the module are set to 'cutout' and 'green_color'.

Result is: https://www.performan.org/carl-cryplant/carl-cryplants-christmas-music-vol-1/ filename, a play, rewind, forward and stop button.

Also added all the scripts in header & footer, _init, etc. Probably missed out something somewhere....

Share this post


Link to post
Share on other sites

swfUrl needs to be defined, since that particular player requires flash; but the strange thing is this used to work on my local but is not currently working; i will check and see if there is some way of getting it to work again...

also on your page jquery isn't loading, because of Blocked loading mixed active content

 

Share this post


Link to post
Share on other sites

once you eliminate the errors, if you want to use that player on a page, for now you'll need to manually insert this code in the header, until i can update the module to insert that; I probably had a cached copy of the swf player on my old dev machine which is why it worked without that.. once the module is updated, then it will insert that code into the header when you have a cassette on the page..

		<script type='text/javascript'>
			var swfUrl = '/site/modules/TextformatterSoundmanager/soundmanager2/swf/';
		</script>

 

Share this post


Link to post
Share on other sites

if the tape doesn't look right you might also have to use this css:

.tape * {
  box-sizing: content-box;
}

the next version will have that in the tape css file..

Share this post


Link to post
Share on other sites

Thanks. Guess I solved a few issues but the cassette still doesn't look like a cassette because apparently it's missing something: 

[Error] Failed to load resource: the server responded with a status of 404 (Page Not Found) (ma-r90-mask.png, line 0)
https://www.performan.org/carl-cryplant/christmas-music-vol-1/image/ma-r90-mask.png

 

Share this post


Link to post
Share on other sites

so are you doing this?

) In order for the module to output the necessary styles and scripts, you need to echo the $config->styles and $config->scripts arrays into your site's header/footer. Here is an example:

// In Header
foreach($config->styles as $style) echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n";

// In Footer
foreach($config->scripts as $script) echo "<script type='text/javascript' src='{$script}'></script>\n";

I don't see the cassette css file anywhere on the page; the styles for any given player need to be either hardcoded style link references on the page, or you have to use $config scripts & styles in order for each/any of the players CSS and JS files to load;

Share this post


Link to post
Share on other sites

In Header I have my normal stylesheet ref: <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/cryplant_sets_style.css" />

And added yours as: <?php foreach($config->styles as $style) echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n"; ?>. The CSS and scripts are still in the module folder.

.tape * {
  box-sizing: content-box;
}

went in the first one. 

Everything's there in Footer as well.

I presume I'm messing things up...

Share this post


Link to post
Share on other sites

i don't see the CSS file - cassette-tape-ui.css in your header; if you have Tracy, can you try debugging what is inside $config->styles? on my local machine it all works;

alternately you can hardcode the reference to the css file on that page, like this:

<link rel="stylesheet" href="/site/modules/TextformatterSoundmanager/soundmanager2/cassette-tape/css/cassette-tape-ui.css">

Share this post


Link to post
Share on other sites

Ha! Looks a lot better now. The play/pause button doesn't work, pausing works when you click on the cassette however. Maybe the jscript isn't doing wat it should, like in the example on http://www.schillmania.com/projects/soundmanager2/demo/cassette-tape/.

And for some reason the code "echo $sound->player($page->sound);" doesn't work in the template, gives "Error: Call to a member function player() on null (line 126 of /home/performaaj/www/site/templates/cryplant_sets.php)" . I have it in a text field now: [smplayer tag=cryplant type=cassette]. _init file has "$sound = $modules->get('TextformatterSoundmanager');" and my sound field is called "sound".

Share this post


Link to post
Share on other sites

you have some rules messing up the player; make sure the player CSS is loaded after your site css; The controls shouldn't appear until you hover over the cassette.

Problem 1)

#content p, #content ul, #content ol, #content table {
    margin: 1em 0 1.5em 0;
}

Problem 2)

#content ul li {
    margin: 0 0 0 3em;
    display: list-item;
    list-style: none;
}

problem 3)

#content a {
    color: #f00076;
}

once those are solved you should have it looking like this:

2083216618_ScreenShot2018-12-26at11_58_19AM.jpg.d4d98691a1a405e2a0e2135b0986555a.jpg

for the other issue, you should check to make sure that the variable $sound is not getting overwritten somewhere; for safety you should probably call it $sm2 instead of sound;

Share this post


Link to post
Share on other sites

Ok, solved the problems you mentioned and it looks as promised. The play button only acts as play and not as pause like I thought it should, during playback it acts as rewind. Clicking the cassette makes the sound pause and resume.

echo "$sm2->player($page->sound)"; in the template gives just the filename of the soundfile...

Also somewhat amazing is that the rewind and forward buttons actually jump to the next or previous song although the soundfile is a 44min mix of different tracks made with Traktor in 2006-2007. I suppose SoundManager analyses the file and finds differences in the spectrum or whatever.

Share this post


Link to post
Share on other sites
1 hour ago, BFD Calendar said:

echo "$sm2->player($page->sound)"; in the template gives just the filename of the soundfile...

not sure, it sounds like $sm2 is not the module instance; you'd need to use Tracy Debugger to bd($sm2) at that point and see if it is actually the module;
I will test your code also to see if i can troubleshoot that issue; are you passing any options to the player, or are you setting the default player as the cassette, in the module config?

Share this post


Link to post
Share on other sites
19 hours ago, BFD Calendar said:

echo "$sm2->player($page->sound)"; in the template gives just the filename of the soundfile...

the api access to the cassette ui is working for me; you just need to make sure you supply the options, because there is no way to default to the cassette for the player, because it only supports 1 audio file per page..

Soudmanager2_Cassette___Soundmanager2_Mixed_Types_Testing___My_Great_Site.thumb.jpg.4914641fae6f7fae4a4e5beda59acef6.jpg

Share this post


Link to post
Share on other sites

I did just that, renamed my field to 'audio', just in case 'sound' would conflict with anything.

Code in the template:

	$options = [
		'type' => 'cassette',
		'cassette' => 'ma-r90',
	];
	$track = $page->audio->first();
	$content .= $sm2->player($track, $options);

Result: Error: Call to a member function player() on null (line 128 of /home/performaaj/www/site/templates/cryplant_sets.php) - where line 128 is "$content  .= $sm2->player($track, $options);"

In the module settings I have Default Single Player set to Page Player, no Bar-UI options, Cassette options to ma-r90, all Allowed Formats on.

I installed Tracy Debugger but this is far beyond my skills to operate....

Share this post


Link to post
Share on other sites

right - as i pointed out, the error is because the $sm2 variable is not the instance of the module.  player() on null means that $sm2 is null.

You said this in your init

$sm2 = $modules->get('TextformatterSoundmanager');

You either lost the variable between your init and the template, or you are in a different namespace;

whatever the case, you can easily solve it by just re-referencing the module right before the code; just repeat that code before the other code; none of the other items you mentioned would affect anything, field name,

Share this post


Link to post
Share on other sites

All '_init.php', header and 'cryplant_sets.php' have <?php namespace ProcessWire; on line 1. Running PW 3.0.98 - PHP 5.6.38.

	$sm2 = $modules->get('TextformatterSoundmanager');
	$options = [
		'type' => 'cassette',
		'cassette' => 'ma-r90',
	];
	$track = $page->audio->first();
	$content .= $sm2->player($track, $options);

Above code in the 'cryplant_sets.php' template gives no error but no cassette either.... 

Share this post


Link to post
Share on other sites

well you're probably not doing delayed output, so that code won't output anything; you'd need to echo if you are doing direct output, like

echo $sm2->player($track, $options);

Share this post


Link to post
Share on other sites

for some reason the 2nd one has the wrong class name, it looks like the classname is added 2x - this is what your api version classname looks like: ma-r90ma-r90 but it should only be ma-r90

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By teppo
      Hey folks!
      Took a couple of late nights, but managed to turn this old gist of mine into a proper module. The name is SearchEngine, and currently it provides support for indexing page contents (into a hidden textarea field created automatically), and also includes a helper feature ("Finder") for querying said contents. No fancy features like stemming here yet, but something along those lines might be added later if it seems useful (and if I find a decent implementation to integrate).
      Though the API and selector engine make it really easy to create site search pages, I pretty much always end up duplicating the same features from site to site. Also – since it takes a bit of extra time – it's tempting to skip over some accessibility related things, and leave features like text highlighting out. Overall I think it makes sense to bundle all that into a module, which can then be reused over and over again 🙂
      Note: markup generation is not yet built into the module, which is why the examples below use PageArray::render() method to produce a simple list of results. This will be added later on, as a part of the same module or a separate Markup module. There's also no fancy JS API or anything like that (yet).
      This is an early release, so be kind – I got the find feature working last night (or perhaps this morning), and some final tweaks and updates were made just an hour ago 😅
      GitHub repository: https://github.com/teppokoivula/SearchEngine Modules directory: https://modules.processwire.com/modules/search-engine/ Usage
      Install SearchEngine module. Note: the module will automatically create an index field install time, so be sure to define a custom field (via site config) before installation if you don't want it to be called "search_index". You can change the field name later as well, but you'll have to update the "index_field" option in site config or module settings (in Admin) after renaming it.
      Add the site search index field to templates you want to make searchable. Use selectors to query values in site search index. Note: you can use any operator for your selectors, you will likely find the '=' and '%=' operators most useful here. You can read more about selector operators from ProcessWire's documentation.
      Options
      By default the module will create a search index field called 'search_index' and store values from Page fields title, headline, summary, and body to said index field when a page is saved. You can modify this behaviour (field name and/or indexed page fields) either via the Module config screen in the PocessWire Admin, or by defining $config->SearchEngine array in your site config file or other applicable location:
      $config->SearchEngine = [ 'index_field' => 'search_index', 'indexed_fields' => [ 'title', 'headline', 'summary', 'body', ], 'prefixes' => [ 'link' => 'link:', ], 'find_args' => [ 'limit' => 25, 'sort' => 'sort', 'operator' => '%=', 'query_param' => null, 'selector_extra' => '', ], ]; You can access the search index field just like any other ProcessWire field with selectors:
      if ($q = $sanitizer->selectorValue($input->get->q)) { $results = $pages->find('search_index%=' . $query_string . ', limit=25'); echo $results->render(); echo $results->renderPager(); } Alternatively you can delegate the find operation to the SearchEngine module as well:
      $query = $modules->get('SearchEngine')->find($input->get->q); echo $query->resultsString; // alias for $query->results->render() echo $query->pager; // alias for $query->results->renderPager() Requirements
      ProcessWire >= 3.0.112 PHP >= 7.1.0 Note: later versions of the module may require Composer, or alternatively some additional features may require installing via Composer. This is still under consideration – so far there's nothing here that would really depend on it, but advanced features like stemming most likely would.
      Installing
      It's the usual thing: download or clone the SearchEngine directory into your /site/modules/ directory and install via Admin. Alternatively you can install SearchEngine with Composer by executing composer require teppokoivula/search-engine in your site directory.
    • By teppo
      MarkupMenu is a markup module for generating menu trees. When provided a root page as a starting point, it generates a navigation tree (by default as a HTML "<ul>" element wrapped by a "<nav>" element) from that point onwards. If you've also provided it with current (active) page, the menu will be rendered accordingly, with current item highlighted and items rendered up to that item and its children (unless you disable the "collapsed" option, in which case the full page tree will be rendered instead).
      Modules directory: https://modules.processwire.com/modules/markup-menu/ GitHub repository: https://github.com/teppokoivula/MarkupMenu Usage
      As a markup module, MarkupMenu is intended for front-end use, but you can of course use it in a module as well. Typically you'll only need the render() method, which takes an array of options as its only argument:
      echo $modules->get('MarkupMenu')->render([ 'root_page' => $pages->get(1), 'current_page' => $page, ]); Note: if you omit root_page, site root page is used by default. If you omit current_page, the menu will be rendered, but current (active) page won't be highlighted etc.
      A slightly more complex example, based on what I'm using on one of my own sites to render a (single-level) top menu:
      echo $modules->get('MarkupMenu')->render([ 'current_page' => $page, 'templates' => [ 'nav' => '<nav class="{classes} menu--{menu_class_modifier}" aria-label="{aria_label}">%s</nav>', 'item_current' => '<a class="menu__item menu__item--current" href="{item.url}" tabindex="0" aria-label="Current page: {item.title}">{item.title}</a>', ], 'placeholders' => [ 'menu_class_modifier' => 'top', 'aria_label' => 'Main navigation', ], 'include' => [ 'root_page' => true, ], 'exclude' => [ 'level_greater_than' => 1, ], ]); Note: some things you see above may not be entirely sensible, such as the use of {menu_class_modifier} and {aria_label} placeholders. On the actual site the "nav" template is defined in site config, so I can define just these parts on a case-by-case basis while actual nav markup is maintained in one place.
      Please check out the README file for available render options. I'd very much prefer not to keep this list up to date in multiple places. Basically there are settings for defining "templates" for different parts of the menu (list, item, etc.), include array for defining rules for including in the menu and exclude array for the opposite effect, classes and placeholders arrays for overriding default classes and injecting custom placeholders, etc. 🙂
      MarkupMenu vs. MarkupSimpleNavigation
      TL;DR: this is another take on the same concept. There are many similarities, but also some differences – especially when it comes to the supported options and syntax. If you're currently using MarkupSimpleNavigation then there's probably no reason to switch over.
      I'd be surprised if someone didn't draw lines between this module and Soma's awesome MarkupSimpleNavigation. Simply put I've been using MSN (...) for years, and it's been great – but there are some issues with it, particularly in the markup generation area, and it also does some things in a way that doesn't quite work for me – the xtemplates thing being one of these. In some ways less about features, and more about style, I guess 🙂
      Anyhow, in MarkupMenu I've tried to correct those little hiccups, modernise the default markup, and allow for more flexibility with placeholder variables and additional / different options. MarkupMenu was built for ProcessWire 3.0.112+ and with PHP 7.1+ in mind, it's installable with Composer, and I have a few additional ideas (such as conditional placeholders) still on my todo list.
      One more small(ish) difference is that MarkupMenu supports overriding default options via $config->MarkupMenu. I find myself redefining the default markup for every site, which until now meant that each site had a wrapper function for MarkupSimpleNavigation (to avoid code / config repetition), and this way I've been able to leave that out 🙂
      Requirements
      ProcessWire >= 3.0.112 PHP >= 7.1.0 If you're working on an earlier version of ProcessWire or PHP, use MarkupSimpleNavigation instead.
    • By teppo
      Hey folks!
      I'm happy to finally introduce a project I've been working on for quite a while now: it's called Wireframe, and it is an output framework for ProcessWire.
      Note that I'm posting this in the module development area, maily because this project is still in rather early stage. I've built a couple of sites with it myself, and parts of the codebase have been powering some pretty big and complex sites for many years now, but this should still be considered a soft launch 🙂
      --
      Long story short, Wireframe is a module that provides the "backbone" for building sites (and apps) with ProcessWire using an MVC (or perhaps MVVM – one of those three or four letter abbreviations anyway) inspired methodology. You could say that it's an output strategy, but I prefer the term "output framework" since in my mind the word "strategy" means something less tangible. A way of doing things, rather than a tool that actually does things.
      Wireframe (the module) provides a basic implementation for some familiar MVC concepts, such as Controllers and a View layer – the latter of which consists of layouts, partials, and template-specific views. There's no "model" layer, since in this context ProcessWire is the model. As a module Wireframe is actually quite simple – not even nearly the biggest one I've built – but there's still quite a bit of stuff to "get", so I've put together a demo & documentation site for it at https://wireframe-framework.com/.
      In addition to the core module, I'm also working on a couple of site profiles based on it. My current idea is actually to keep the module very light-weight, and implement most of the "opinionated" stuff in site profiles and/or companion modules. For an example MarkupMenu (which I released a while ago) was developed as one of those "companion modules" when I needed a menu module to use on the site profiles.
      Currently there are two public site profiles based on Wireframe:
      site-wireframe-docs is the demo&docs site mentioned above, just with placeholder content replaced with placeholder content. It's not a particularly complex site, but I believe it's still a pretty nice way to dig into the Wireframe module. site-wireframe-boilerplate is a boilerplate (or starter) site profile based on the docs site. This is still very much a work in progress, but essentially I'm trying to build a flexible yet full-featured starter profile you can just grab and start building upon. There will be a proper build process for resources, it will include most of the basic features one tends to need from site to site, etc. --
      Requirements and getting started:
      Wireframe can be installed just like any ProcessWire module. Just clone or download it to your site/modules/ directory and install. It doesn't, though, do a whole lot of stuff on itself – please check out the documentation site for a step-by-step guide on setting up the directory structure, adding the "bootstrap file", etc. You may find it easier to install one of the site profiles mentioned above, but note that this process involves the use of Composer. In the case of the site profiles you can install ProcessWire as usual and download or clone the site profile directory into your setup, but after that you should run "composer install" to get all the dependencies – including the Wireframe module – in place. Hard requirements for Wireframe are ProcessWire 3.0.112 and PHP 7.1+. The codebase is authored with current PHP versions in mind, and while running it on 7.0 may be possible, anything below that definitely won't work. A feature I added just today to the Wireframe module is that in case ProcessWire has write access to your site/templates/ directory, you can use the module settings screen to create the expected directories automatically. Currently that's all, and the module won't – for an example – create Controllers or layouts for you, so you should check out the site profiles for examples on these. (I'm probably going to include some additional helper features in the near future.)
      --
      This project is loosely based on an earlier project called pw-mvc, i.e. the main concepts (such as Controllers and the View layer) are very similar. That being said, Wireframe is a major upgrade in terms of both functionality and architecture: namespaces and autoloader support are now baked in, the codebase requires PHP 7, Controllers are classes extending \Wireframe\Controller (instead of regular "flat" PHP files), implementation based on a module instead of a collection of drop-in files, etc.
      While Wireframe is indeed still in a relatively early stage (0.3.0 was launched today, in case version numbers matter) for the most part I'm happy with the way it works, and likely won't change it too drastically anytime soon – so feel free to give it a try, and if you do, please let me know how it went. I will continue building upon this project, and I am also constantly working on various side projects, such as the site profiles and a few unannounced helper modules.
      I should probably add that while Wireframe is not hard to use, it is more geared towards those interested in "software development" type methodology. With future updates to the module, the site profiles, and the docs I hope to lower the learning curve, but certain level of "developer focus" will remain. Although of course the optimal outcome would be if I could use this project to lure more folks towards that end of the spectrum... 🙂
      --
      Please let me know what you think – and thanks in advance!
    • By Robin S
      After forgetting the class name of the wonderful AdminPageFieldEditLinks module for what feels like the 100th time I decided I needed to give my failing memory a helping hand...
      Autocomplete Module Class Name
      Provides class name autocomplete suggestions for the "Add Module From Directory" and "Add Module From URL" fields at Modules > New.
      Requires ProcessWire >= v3.0.16.
      Screencast

      Installation
      Install the Autocomplete Module Class Name module.
      Configuration
      Add Module From Directory
      Choose the type of autocomplete suggestions list: "Module class names from directory" or "Custom list of module class names". The latter could be useful if you regularly install some modules and would prefer a shorter list of autocomplete suggestions. The list of class names in the modules directory is generated when the Autocomplete Module Class Name module is installed. It doesn't update automatically (because the retrieval of the class names is quite slow), but you can use the button underneath when you want to retrieve an updated list of class names from the directory. Add Module From URL
      If you want to see autocomplete suggestions for the "Add Module From URL" field then enter them in the following format:
      [autocomplete suggestion] > [module ZIP url]
      Example: RepeaterImages > https://github.com/Toutouwai/RepeaterImages/archive/master.zip Awesomplete options
      The "fuzzy search" option uses custom filter and item functions for Awesomplete so that the characters you type just have to exist in the autocomplete suggestion item and occur after preceding matches but do not need to be contiguous. Uncheck this option if you prefer the standard Awesomplete matching. Custom settings for Awesomplete can be entered in the "Awesomplete options" field if needed. See the Awesomplete documentation for more information.  
      https://github.com/Toutouwai/AutocompleteModuleClassName
      https://modules.processwire.com/modules/autocomplete-module-class-name/
    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
×
×
  • Create New...