///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
THIS IS AN OLD VERSION. Get the new one at the URL: http://get-simple.info/extend/plugin/itemmanager/936/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Item Manager Extended is a remake of the original Items Manager created by Pyc to simple manage articles, products, services, and other related items.
Source is available now on GitHub at: iManager
REQUIREMENTS:
- GetSimple CMS up to version 3.x and higher.
- GD Library
CHANGES / FEATURES:
- Complete separation of design and logic
- Assigning of customfields to categories
- Pagination of item lists incduded
- Back-end Management has been redesigned and updated
- The custom fields part of Mvlcek Custom Fields plugin has been integrated into the Item Manager environment
- Upload functionality has been changed or added
- Some JavaScript functions removed temporarily
SETUP:
- Make sure to save an older version of Items Manager for the case that you decide to stay with it!
-> Just save a copy of the files to a different location.
-> After that, delete old version data to prevent naming collisions.
- Download 'Item Manager Extended' and unzip its files to the /plugins folder
- While logged in to GS, go to Plugins and activate Item Manager, join to the plugin menu at the top of the 'Item Manager' tab and go through the setup process:
-> It will creates some directories and files.
- After set up you will be told which files have been created. In case of failure of the setup all these files must be added manually to the project.
CONFIGURATIONS MENU:
- Item Manager -> CATEGORIES. Allows you to define new categories for optimizing your item management.
- Item Manager -> CONFIGURE. This menu provides custom fields that you can use to organize your items.
- Item Manager -> ADD NEW. This menu point enables to generate new Items.
- Item Manager -> VIEW ALL. This list contains all the Items that are available at the moment.
To read or output data on front-end you shall to use the appropriate API calls of the Item Manager. Item Manager provides some methods that allow you to save, process and display your own item categories. The implementation are based on the object-oriented approach, which allows the arbitrary combination of this methods. This feature gives Item Manager a great deal of flexibility in how it can be used.
HOW TO USE TEMPLATES:
The Item Manager plugin uses templates to produce all it's front-end and back-end output, therefor it is possible to manipulate the look without knowing PHP at all. Manager templates are bits of static text contained placeholders and stored in '.tpl' files or (at your option) inserted as a string in the source code. You can move any of these pieces around, change their parameters, and adjust their placing. The existing default templates are solely a base structure - if you want your placeholders at the bottom, for instance, move them there! Item Manager doesn't restrict you from doing that. All these templates are located in the 'plugins/imanager/tpl' directory. You can create your own templates or use these standard templates.
USAGE EXAMPLE:
Ok, I'll try to give you an example of how you could use Item Manager to create a simple product catalog that might then look like this: sample.
See also a further example how to use Item Manager as substitute of Fancybox.
One thing before we start, Item Manager is modular, and your product catalog can function in any scope you like. If you don't need any specific part of methods, just skip that.
First off, you'll want to open the CATEGORIES menu, and create a new category, we call it 'rings'.
categories
Next, click the CONFIGURE menu, in this area you will want to customize your category structures by adding custom fields precisely to your specific requirements. So, let us start by creating:
- One textarea for our item description
- 4 upload fields for our thumbnails
- 4 fields for the main images
- A single field 'sequence' to determine the order of products displayed in the catalog
configure
After you have made all of your custom fields, your next step is to add new items to an existing category using the ADD NEW menu point. To see the items you have created, go to the VIEW ALL menu. Your items list will appear as follows.
view all
CREATING CONTROLLER COMPONENTS:
You don't currently have the possibility to specify the item output from the back-end area. For this reason your next step should be creating a suitable front-end snippets that includes several methods for setting and manipulating the output. In our example case, you could use two different viewing modes 'List' and 'Details' view. The easiest way of getting a Manager output on the front-end of your website is just to create two components 'im_list_page_generator' and 'im_details_page_generator'. Include these components in your website template, better still, embed these directly in your GS pages by using DynPages plugin. The 'DynPages' plugin allows you to use a placeholder to include the components on the page by specifying their name: {% im_list_page_generator %}
Sample im_list_page_generator:
PHP Code:
<?php
// create controller instance
$manager = new ImController();
// setup category
ImCategory::setCategory('rings');
// limiting items per page
ImModel::setPref('itemsperpage', 10);
// setup sort by field
ImModel::setPref('sortby', 'sequence');
// setup details page
ImModel::setPref('page', 'item-manager-details-page');
/* Run action: generates item register calculated out of all the mentioned parameters.
For this example's purpose, we'll need two custom fields in our List view: a 'thumb' to
display as a link to our Details page and 'sequence' to determine the order of products
displayed. */
$manager->runModelMethod('gen_register', array('loop-thumb-1', 'sequence'));
/* This method returns an array which contains multiple item data specified by gen_register and
depending on the settings made. */
$items = $manager->getModelValue('items_ordered_struct');
// Returns a page data array based on the settings made
$pagedata = $manager->getModelValue('pagedata');
// templates as strings, just for demonstration
if(!$manager->tplRegister(array('loop' =>
'<div class="im-resultwrap">'
.'<a class="im-itempic" href="[[page]]?item=[[ slug ]]"><img alt="" class="im-pic" src="[[ loop-thumb-1 ]]" /><span class="im-hidden"></span></a>'
.'</div>', 'frontendlist' => '<div id="manager">[[ loop ]][[ paginator ]]</div>')))
{
return;
}
// string append
$loop = '';
foreach($pagedata['itemkeys'] as $key)
{
// Renders the 'loop' template to string concatenation by replacing placeholders
$loop .= $manager->paint('loop', array('loop-thumb-1' => $items[$key]['loop-thumb-1'],
'page' => $pagedata['viewpage'], 'slug' => $items[$key]['slug']));
}
/* If we want to split our item data across several pages, for instance, with 'Previous/Next'
links, for this, we can use already existing default templates. We then call the paginator()
method in a controller action. This method gets passed the default paginator templates by
calling the getTplKit('paginator') before paint() renders the template to output */
echo $manager->paint('frontendlist', array('loop' => $loop,
'paginator' => $manager->paginator(ImModel::getTplKit('paginator'))));
?>
Sample im_details_page_generator:
PHP Code:
<?php
$manager = new ImController();
$id = isset($_GET['item']) ? $_GET['item'] : '';
/* This method returns an array which contains detailed data of a single item
specified by item ID */
if(!$itemdata = $manager->runModelMethod('get_item_data', $id))
{
return;
}
$path = ImModel::getProp('paths', 'siteurl').ITEMUPLOADDIR;
// templates as files for demonstration
if(!$manager->tplRegister(array('details' =>
GSPLUGINPATH.'imanager/tpl/frontend/page.details.tpl',
'detailsloop' => GSPLUGINPATH.'imanager/tpl/frontend/page.details.loop.tpl')))
{
return;
}
$loop = '';
$preload = array();
for($i=1; $i < 6; $i++) {
if(!empty($itemdata->{'loop-thumb-'.$i})) {
$loop .= $manager->paint('detailsloop', array('count' => $i));
}
if(!empty($itemdata->{'image-'.$i})) {
$preload[]= '"[[image-'.$i.']]"';
}
}
$preload = implode(',', $preload);
$manager->tplRegister(array('currloop' => $loop));
$loop = $manager->paint('currloop', array(
'image-1' => $path.basename($itemdata->{'image-1'}),
'image-2' => $path.basename($itemdata->{'image-2'}),
'image-3' => $path.basename($itemdata->{'image-3'}),
'image-4' => $path.basename($itemdata->{'image-4'}),
'image-5' => $path.basename($itemdata->{'image-5'}),
'image-6' => $path.basename($itemdata->{'image-6'}),
'loop-thumb-1' => $path.basename($itemdata->{'loop-thumb-1'}),
'loop-thumb-2' => $path.basename($itemdata->{'loop-thumb-2'}),
'loop-thumb-3' => $path.basename($itemdata->{'loop-thumb-3'}),
'loop-thumb-4' => $path.basename($itemdata->{'loop-thumb-4'}),
'loop-thumb-5' => $path.basename($itemdata->{'loop-thumb-5'}),
'loop-thumb-6' => $path.basename($itemdata->{'loop-thumb-6'}))
);
echo $manager->paint('details', array(
'preload' => $preload,
'image-1' => $path.basename($itemdata->{'image-1'}),
'image-2' => $path.basename($itemdata->{'image-2'}),
'image-3' => $path.basename($itemdata->{'image-3'}),
'image-4' => $path.basename($itemdata->{'image-4'}),
'image-5' => $path.basename($itemdata->{'image-5'}),
'image-6' => $path.basename($itemdata->{'image-6'}),
'title' => stripslashes(html_entity_decode($itemdata->{'title'}, ENT_QUOTES, 'UTF-8')),
'description' => stripslashes(html_entity_decode($itemdata->{'description'}, ENT_QUOTES, 'UTF-8')),
'loop-tpl' => $loop)
);
?>
NOTE: This plugin is in Beta phase, meaning it is incomplete, please tell me describing any bugs or feature requests.