Creating a basic plugin
|Line 2:||Line 2:|
the example plugin:[http://soholaunch.com/media/hello-world.zip download the example plugin]
Revision as of 23:18, 17 October 2013
Download the example plugin: download the example plugin
- A website with Soholaunch (Pro or Ultra) installed on it.
- Your favorite code editor (for php)
- Comfort editing basic php code
- Some comfort with Soholaunch's file structure will help, but is not essential.
- FTP access to your website
Create a folder for your plugin
Create a folder on your computer called hello-world. All of your plugin's files will go in this folder.
Find the hook you want to attach your custom file to
Open Your FTP client and log-in to your test site. For this example, we're going to add code to your soho-created website's html. The file below builds the website's html...
Open that file, and scroll all the way to the bottom. You'll see this line...
# Add stuff to final html eval(hook("pgm-realtime_builder.php:add-to-final-html"));
That's what a hook looks like in the Soholaunch source code. This is where your file will be included. The text inside the hook() function call (pgm-realtime_builder.php:add-to-final-html) is the hook id that you need for your plugin's install_manifest.php file.
Create your include file
Contents of hello-world.php...
<?php $template_footer .= '<script>alert("Hello, World.");</script>'; ?>
Create an install_manifest.php for your plugin
The install_manifest.php is the configuration file for your plugin. Every Soholaunch plugin has an install_manifest.php. This file is read by Soholaunch when the user installs the plugin. It tells Soholaunch how to display your plugin (title, author, etc), and where to hook its files into.
There are two types of content in any given install_manifest.php:
- Information - plugin title, author, etc
- Instructions - "hook me in here, here, and here"
Here's what our install_manifest.php is going to look like...
<?php # This should match your plugin's folder name $plugin_folder = "hello-world"; # These are just for display to the user, you can define them however you see fit (html allowed) $plugin_title = "Hello World"; $plugin_version = "2.0"; $plugin_author = "Soholaunch.com, Inc."; $plugin_homepage = "http://example.com"; $plugin_description = "Adds drag and drop 'Hello World' item to the Page Editor"; /* Include my hello-world.php file at *this* location (specified by hook id found in the Soholaunch source code) */ hook_attach("hello-world.php", "pgm-realtime_builder.php:add-to-final-html"); ?>
Optional: Plugin icon
If you'd like your plugin to have it's own icon displayed next to it's name in the Plugin Manager (instead of the default puzzle piece graphic), include the image file in your plugin folder, and add a line like this to your install_manifest.php...
$plugin_icon = "my_plugin_icon.gif"
Recap: This is what your plugin folder should look like
At this point your plugin is essentially done.
Your plugin folder should look like this now...
hello-world/ install_manifest.php main_menu-helloworld.php
Using winzip, winrar, or other similar archive app, zip-up your hello-world folder (the folder itself, not just the contents). In Windows, you'd right-click on the hello-world folder and click "Add to archive..."
For purposes of example, name your .zip file *hello-world.zip*
Your plugin is finished and ready to rock. Log-in to /sohoadmin and upload/install your hello-world.zip via the Plugin Manager.