Smart Sites allow you to import entire custom collections or add fields to existing collections.
Anyway, you will access this data through $db or Template Behaviors (see also: “Importing Data“).
In following example we will import an entire new collection from scratch, for example out products list (products.csv).
Let start importing.
1. You need some data to import
First of all we prepare a products.csv file containing a list of products we need in our site.
To produce the file I use Open Office (yes, I’m an Open-Source maniac), but you can use also Ms Excel or what ever you want.
This is an excerpt of my file (click on the image below to download the file):
Ensure you have an _id column or the system will add new one during import.
If you provide your own _id column and values, you can import and update data many times overwriting existing, otherwise the import procedure will append data to existing collection (duplicating contents).
2. Copy the file to import into Smart Sites import folder
Now you are ready to copy the file into import folder.
On my Windows 7 machine the path is:
C:\Users\angelo.geminiani\beeingstore\smartsiteclient\data\import
Where:
- C:\Users\angelo.geminiani\: is my user folder. This will change in you machine accordingly to your username and Operating System
- \beeingstore\smartsiteclient\data\import: This is SmartSite path into standard BEEing repository (BEEing is another Open-Source Platform).
3. Run SmartSiteLib with –import option
Simply type in console:
java -jar SmartSiteLib.jar –import
You should obtain a response like this:
Imported:
C:\Users\angelo.geminiani\beeingstore\smartsiteclient\data\import\products.csv
4. Open JSON editor and check imported data.
Open JSON editor from utils folder. It shoul be into
[...USER-PATH...]\beeingstore\smartsiteclient\utils.
On my machine it is:
C:\Users\angelo.geminiani\beeingstore\smartsiteclient\utils
Then Open db.json with a text editor, copy content and past into JSON editor.
The editor show you imported data:
That’s all.
Now you can start using your data with $db reference or declaring a custom Template Behavior.
5. Using imported Data
You can use your imported data by:
- $db.find() methods
- Through Template Expression
In following sample I create a loop on all items in “products” collection and than print some HTML (Unordered List) with item description:

The function $product.opt(“Item Description”) returns value of field “Item Description” of current product item in loop. You can use both opt(“field-name”) or get(“field-name”), the difference is that opt() returns null if item has not “field-name” property, while get() throws an Exception.
This is the output:


