- About nnhelpers for WordPress
- What you're getting:
- nnhelpers for TYPO3
- Examples:
- Get link to a page (post)
- Get the baseUrl (https://www.site.com/) of the website
- Get the absolute path to a file (/var/www/mysite/path/file.jpg)
- Get the absilute URL to a file (https://www.mysite.de/path/file.jpg)
- Create a thumbnail / crop image to size
- Get list of all categories
- Get categories as hierarchical tree
- Get the extension-configuration
About nnhelpers for WordPress #
The nnhelpers plugin is not the kind of plugin you install and then see a new function or widget for WordPress in the backend.
nnhelpers is a "toolbox" for plugin-developers to add some of the missing concepts to WordPress. It comes with a huge collection of very smart "one-liners" to speed up the development of your plugin.
If you have been developing extensions or plugins in other CM-systems like TYPO3 or Joomla, it will be easy to understand the idea behind nnhelpers.
What you're getting: #
The plugin ships with many features that developers desperately miss in WordPress:
- Convention over Configuration. Most of the configuration is done automatically, just by putting the files in the right place and sticking to the conventions. This makes it easy to find Templates, Controllers and ViewHelpers inside of your plugin – and any other, third-party-plugin based on nnhelpers.
- A huge collection of useful onelines which can be used in your plugin. Have a look at some examples and the available Helper-Utilities - documentation is in the code (translation and examples coming soon)
- Namespacing and a centralized way of registering and resolving new namespaces using
spl_autoload_register()
- A real Template Engine (Fluid) to keep the Controller separated from the View and render templates without the ugly "php-inline-and-echo" syntax. You can use everything you know from Fluid in WordPress: templateRootPaths, Partials, Layout and custom ViewHelpers.
- An FAL / SysFile-Model and a
<f:image />
ViewHelper that can resize and crop images on-the-fly and from inside of your Fluid-Template. Don't worry: The images get cached in the filesystem for better performance. - Adding Custom Post Types (CPT) using configuration arrays instead of PHP. You can define all forms and fields in the array without having to manually create form-elements in PHP like you are forced to if you use the Core functions of WordPress.
- Adding Custom Blocks and Widget - again using nothing but an configuration array.
- Missing Models, Repositories? Here they are.
- An object-oriented QueryBuilder which can be chained and which has field-names that are based on the real database-field names, not like the options for
WP_Query
(why'p'=>'..'
??)
nnhelpers for TYPO3 #
This project is based on our extension "nnhelpers for TYPO3". The vision was to be able to adopt WordPress-plugins for TYPO3 and vice-versa without having to change a lot of code.
nnhelpers is the "common abstraction layer" for both CM-Systems. Later we plan to add additional Frameworks and CMS. No matter which Content-Management-System or Framework you are using: The same Helper-Utilities will have the same syntax and do the same thing in any systems, even if the underlying layer has a different logic – or the logic changes in the core after a major update of the CMS!
Examples: #
All of the following examples use the (almost) identical syntax – no matter if you are working on an extension in TYPO3 with nnhelpers
or a WordPress plugin with nnhelpers
for WordPress installed!
Get link to a page (post) #
// In WordPress:
\nn\wp::Page()->getLink( $postID );
// In TYPO3:
\nn\t3::Page()->getLink( $pageUid );
Get the baseUrl (https://www.site.com/) of the website #
// In WordPress:
\nn\wp::Environment()->getBaseURL();
// In TYPO3:
\nn\t3::Environment()->getBaseURL();
Get the absolute path to a file (/var/www/mysite/path/file.jpg) #
// In WordPress:
\nn\wp::File()->absPath('EXT:myplugin/path/file.jpg');
// In TYPO3:
\nn\t3::File()->absPath('EXT:myextension/path/file.jpg');
Get the absilute URL to a file (https://www.mysite.de/path/file.jpg) #
// In WordPress:
\nn\wp::File()->absUrl('EXT:myplugin/path/file.jpg');
// In TYPO3:
\nn\t3::File()->absUrl('EXT:myextension/path/file.jpg');
Create a thumbnail / crop image to size #
// In WordPress:
\nn\wp::File()->process( 'EXT:myplugin/images/file.jpg', ['maxWidth'=>200] );
// In TYPO3:
\nn\t3::File()->process( 'EXT:myplugin/images/file.jpg', ['maxWidth'=>200] );
Get list of all categories #
// In WordPress:
\nn\wp::SysCategory()->findAll();
// In TYPO3:
\nn\t3::SysCategory()->findAll();
Get categories as hierarchical tree #
// In WordPress:
\nn\wp::SysCategory()->getTree();
// In TYPO3:
\nn\t3::SysCategory()->getTree();
Get the extension-configuration #
// In WordPress:
\nn\wp::Settings()->getExtConf( 'pluginname' );
// In TYPO3:
\nn\wp::Settings()->getExtConf( 'extensionname' );
Got the idea?