MENU

Migrating Company Directory module to LISE

  Previous article

CMS Made Simple continues to develop, meaning there are always more modern, leaner ways to achieve site solutions. As community developers come and go, third party modules can end up without an active developer. Popular modules are being forked by other devs and you can keep on using them.
But there are also those modules that have outlived their usefulness, and that the more experienced site developers in the community have found better solutions for within the CMSMS ecosystem.
One of these better solutions is LISE (short for List It Special Edition). A module by JoMorg that allows you to create lists that you can display throughout your website. A versatile module that you really have to try and see its many features!

This tutorial will give some assistance porting your modules content to the LISE module, an otherwise time consuming job. Templates, categories and/or hierarchy needs to be done manually, it can't be done automated sadly...

Exporting and importing content from one module to another isn't without a risk... Always create a verified back-up of your websites files and database before proceeding. Even better, copy your website to a sub domain and test it there before you touch your life website. Better safe than sorry!


  How to use

LISE has a built-in system to import external data into the module. But not all other modules have an export feature... and if it does, it most certainly doesn't fit for LISE to import...

This method contains a User Defined Tag (UDT) that automatically generates a .csv (comma separated values) file of the content in LISE format, a module template you can adapt to your personal situation and a hidden (secured) content page where you can start the export.


First you create a new User Defined Tag that can be used to export multiple modules.

UDT: ExportLISEformat
cmsms()->set_content_type('text/csv');
header('Content-disposition: attachment;filename=ExportLISEformat' . strftime('%Y-%m-%d-%H.%M') . '.csv');
Blank page template
In Design Manager create a new Core::Page template, with only in the content:

{content wysiwyg=0}

Exporting:

  • Company Directory,
  • CGBlog,
  • News,
  • Products,
  • or another module...

Now that I have your attention. Creating a tutorial like this takes many, many hours of brainstorming, coding, writing and testing to get the best working method. Now you can use it for free and saves you a lot of work/money! Help me helping you, buy me a cup of coffee in return!


Instructions for the Company Directory module

Written and tested in module release 1.23.12. Only items with status "draft" or "published" are exported.

In your LISE instance create the following Field Definitions according to the Company Directory setup:

  • Address (Text Input)
  • Latitude (Text Input)
  • Longitude (Text Input)
  • Telephone (Text Input)
  • Fax (Text Input)
  • Contact Email (Text Input)
  • Website (Text Input)
  • Details (Text Area)

And if needed more custom field definitions, i.e.

  • Foo (Text Input)
Company Directory summary template

In the templates section of the Company Directory admin page, you create a new summary template named ExportLISEformat with the content below. Depending on your requirements you need to add/edit extra custom fields.

{strip}
{* +++ Default LISE fields followed by custom field definitions +++ *}
"item_id",
"alias",
"title",
"url",
"position",
"active",
"create_time",
"modified_time",
"start_time",
"end_time",
"owner",
"key1",
"key2",
"key3",
"Address",
"Latitude",
"Longitude",
"Telephone",
"Fax",
"Contact_Email",
"Website",
"Details",
"Foo"
{"\n"}

{* +++ Attach Company Directory fields to required LISE fields setup +++ *}
{foreach $items as $entry}
    {$line = []}

    {$line[] = ''} {* LISE: item_id (filled by LISE) *}
    {$line[] = $entry->company_name|munge_string_to_url|lower|replace:'.':''} {* LISE: alias *}
    {$line[] = $entry->company_name} {* LISE: title *}
    {$line[] = $entry->url} {* LISE: url *}
    {$line[] = ''} {* LISE: position *}
    {$line[] = "{if $entry->status == 'published'}1{else}0{/if}"} {* LISE: active *}
    {$line[] = $entry->create_date} {* LISE: create_time *}
    {$line[] = $entry->modified_date} {* LISE: modified_time *}
    {$line[] = ''} {* LISE: start_time *}
    {$line[] = ''} {* LISE: end_time *}
    {$line[] = ''} {* LISE: owner *}
    {$line[] = ''} {* LISE: key 1 *}
    {$line[] = ''} {* LISE: key 2 *}
    {$line[] = ''} {* LISE: key 3 *}
   
    {* LISE Field Definitions *}
    {$line[] = $entry->address}
    {$line[] = $entry->latitude}
    {$line[] = $entry->longitude}
    {$line[] = $entry->telephone}
    {$line[] = $entry->fax}
    {$line[] = $entry->contact_email}
    {$line[] = $entry->website}
    {$line[] = $entry->details|replace:'"':"'"}
    {$line[] = $entry->fields.Foo->value} {* Extra custom field in Company Directory module *}
   
    "{implode('","', $line)}"{"\n"}
{/foreach}

{/strip}

Export Company Directory categories can be done with:

$line[] = "{foreach $entry->categories as $category}{$category->item_order}{if !$category@last},{/if}{/foreach}"
Content page

In Content Manager you create a hidden -not in menu and not searchable- content page connected to the Blank Page template. In the content field you put:

{strip}
  {ExportLISEformat}
  {CompanyDirectory summarytemplate='ExportLISEformat' sortby=id showall=1 pagelimit=9999}
{/strip}

Open the page in your browser and the export will be generated and downloaded.
Tip, you can also add the category parameter in the module tag to split up content.

Even though the page is hidden, theoretically it is possible for someone else at the world wide web to download the module content too. If there is any private content in there, you should put CMSMS in maintenance mode first and allow opening the site for logged in administrators only.
But you can also use an IP address lock at the page. Read about it here: Test templates without breaking the frontend »


Importing in LISE:

When you have set up all your required field definitions you can start importing the data in your LISE instance.
Click on "Import items" and select the export file you just created above.
Note: Use for separator a comma, not a semicolon!
In the next screen you can -using the dropdown fields- attach your source and LISE fields to each other.
Double check each field! Is all good, then click "Submit" and the import will start!


Finishing the job:

When you are done exporting, importing and testing the moved content, and the new LISE instance works like in the old module you should delete:

  • The hidden content page(s).
  • The ExportLISEformat User Defined Tag.
  • The add-on module(s) that have become obsolete.

Buy Me A Coffee


  Comment Form

Click here to open the form


  0 Comments

No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Migrating Company Directory module to LISE

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.15
  Last updated: 20-03-2021
  Comments: 0
  http://cms.ms/KcVL


Buy Me A Coffee




Advertisement


Ads help me to help you! Buy products from these advertisers!