Are you a member? sign in or take a minute to sign up

Cancel
User Id: Password:
Pages: 123

Generating Static Site Snapshots Using PHP and Smarty

24 Jan 12

One of the reasons why I really like Phalanger PHP for .NET is that it allows me to use the Smarty template engine with Syrinx CS. I have not seen a template engine in .NET as good as Smarty and it's documentation is fantastic. Rather than building site pages using ASPX, we can now build pages using PHP and Smarty in the .NET environment.  The PHP can use the Syrinx CS class libraries like they are PHP libraries, which I find amazing.

What is Smarty?

Smarty is a PHP template engine that can take a template and some data and blend it together to create an output.  One obvious use for this is to have html templates, that use Syrinx CS data like articles, products, events, etc. to make html pages that have the content embeded directly.  At that point, the generated html page can be viewed without needing to query Syrinx CS for the content again.  Smarty is a very powerful template engine that can easily be used to build elaborate web sites.

One cool aspect of Smarty is that you can render a template to a string rather than being sent to the browser. By writing the template output to an html file, the rendered content can then be viewed direct in the browser itself. The new page becomes a static snapshot of whatever content was rendered by the template.

I spent some time experimenting and was able to create a smarty theme, a few smarty templates, and a little PHP and recreated the SCS Admin and Developer documentation that was originally built using ASPX that used .NET controls. The pages are still dynamic like the ASPX, with the only difference being that its PHP and smarty templates rather than ASPX and .NET controls. As the user navigates the documentation, the PHP is executing and the templates are being rendered just like the ASPX.

I then built a php function that would loop through a list of articles and generate a new html page per article using a Smarty template. By writing a few helper functions, I was able to use the same template from the dynamic PHP version. Within just a few seconds, it generated a collection of html pages that looked just like the dynamic PHP.

You can see the static version of the SCS documentation with the link below, but note that it wont always be showing the latest version of the documentation as it is just a proof of concept.

View Static Admin Guide versus View ASPX Dynamic Admin Guide

There are several benefits from being able to generate a static snapshot of site pages like this. The main benefit is that the content can be viewed without SCS and its database. Getting SCS up and running on a web server does take some time, and requires a certain technical experience. Viewing static html files from your local storage is as basic as it can get. Any PC running Windows, Linux, Mac, etc., can view those files.

Another benefit is that those files require no server resources if hosted within a live site. Running any system like SCS (such as WordPress, Drupal, etc.) where content is generated per page request takes server resources per request that is typically much higher than the resources needed to send a static html file. For certain types of content, there is no reason to regenerate the pages per page request.

This is the first step for the static build system I want to create for SCS. The static build contains a collection of steps, with each step generating some aspect of the static site pages. There would be another admin page to help trigger the build process, and perhaps it would offer the ability to pick the specific steps to be executed rather than just running the whole build.

With a good static build system in SCS, a site owner can generate a static snapshot of their site, which along with site backup zips, should give them the assurance that they have a copy of their site that they can do something with.
 

Getting the new Syrinx CS up and running

24 Jan 11

I am happy to see that Syrinx CS has finally started to move over to its own web site and its new domain, syrinxcs.com.  I am going to move my past blogs located on the syrinx.ph site to here and start posting more regularly about various things happening with SCS. 

My Journey to add Google Map Support into Syrinx CS

11 Jul 09

Its been a busy two months, working on a variety of new features for Syrinx Community Server. The product has really made some big gains during this time, including some great support for Google maps, a new Calendaring feature, beefed up e-commerce and more. We've had some good client projects that have helped us push things along.

We wanted to add Google map support after seeing another site running it for their AirSoft tournaments (http://www.airbana.co.uk/airsoft/Skirmish). It was a nice usage of Google maps and I wasnt aware of all that could be done with the API that Google exposes for it. The AirSoft site was showing contact and calendar event information as push pins that when clicked would show a tabbed popup with detailed information. After spending some time looking over the map API fro Google, I knew we could add support for it in Syrinx CS and set it up to use Ajax.

Syrinx CS has support Google maps via the FCK editor plug by Martinez Delizarrondo, which allowed a map to be dropped into an article, but that was it. This latest round of work added map support on three new ways. I wanted the Map support to run deep within the Syrinx CS product. While I didnt want to make Syrinx CS totally dependent on the map system I wanted maps to be used beyond simple eye candy; I wanted it to provided meaningful and useful insights into the data contained within a SCS based application.

Maps in Contact Management

We had recently added a nice contact management feature in Syrinx CS, and we added a map view tab directly in the contact management page. This allows you to see the set of contacts shown in the grid. Its a good way to get a spatial understanding of the contacts. When the contacts are from sales order out of the ecommerce system you can get a clearer picture of where your sales are coming from.

My intent is to extend this so that the warehouse locations would be shown in relationship to sales order shipping locations with the Google map polyline function drawing lines from the location an order was shipped from to the location products were shipped to. That is work slated for the next round of development, with the ultimate goal to be able to the supply chain on the map and interact with the data shown on it.

Maps in Calendar Management

Another feature we added recently was calendar management, and we wanted to add support for viewing calendar events in the map. When a calendar event has an address, you can set the exact latitude and longitude with our popup address pinpoint window. Later, when viewing the calendar event as an article, users can see the map of the event location and even get directions to the event from their address.

We plan on using this in sites that sell access to events at specific locations, such as training events at a conference center, diving trips at specific dive spots and so forth. For basic events with locations, the calendar is good for getting directions and understand the location of the event. However, for businesses that sell access to events, the Map can provide detailed information needed to make the decision to buy into the event. The best example for this is a dive group offering ocean diving at various dive spots. That type of event can indicate the locations at a diving trip will go to, along with rich information about the location. Google map's overlay features allow the application to add addition information about the area, which can really give the customer all the information they need to make the decision to buy.

In the next round of work in this area, we intend to allow an SCS site to add overlays onto a specific type of map that would allow for more detailed information. The general maps dont have much information about diving spots, so this would be an important addition to support that type of usage and a dive shop that offered that type of web site would stand out amongst its competition.

Integrated Map View

We built a new standard MapView page that combines contacts and calendar events into one interactive display. Standard users can filter the items shown, with a small filter display at the top of the screen. This view was taken after the AirSoft site that sparked the idea of adding Google map support. One of the things I added into this view was the ability to edit contacts and calendar events directly within the view. If you are logged in and have security privilege to edit contact or calendar events, you will be able to turn on edit mode and the map pin popups will show editors within them, including the FCK editor for editing the body of content that is shown for the contact or event.

Custom Map Pins

Calendar event types, contact types and address types can have a custom map pin assigned to them. When editing the types in the grid, you can use the map pin toolbar button to pick an image to use for the push pin. Any image can be used, and SCS will create a map pin size version of it to use on the map. This is a great way to distinguish between the various types of things being shown on the map.

My Experience with the Google Map API

Overall I can say I am very impressed with the map API. The power of it is amazing. One area I still need to work on is the ability to consolidate multiple map pins into one pin at various levels of zoom. The map API does have the ability to consolidate multiple map pins with its MarkerManager class, but it doesnt really assist with the ability to only download the information needed for the amount of map pins showing on the screen at any given time. I designed the map integration of SCS to be able to download map point information in ajax calls, and in the next rev of my work I'm going to only download the pins that are needed at the moment and do the consolidation on the server.

For example, if you have 500 pins in a small area and then zoom out, rather than having to download 500 pins of information to allow the MarkerManager class to consolidate them for you, I'll do that work on the server and only download the consolidated information into the browser. This way, when zoomed out, the 500 pins in one area may be represented as one pin and the popup window shown when clicked on would show consolidated information about the contacts or calendar events. This will allow for a much larger number of data points to be used within the map without slowing down the user experience. In reality, to do map pin consolidation well takes some serious though in how the data should be represented at different zoom levels. Its also a big programming task to get it done and working well within an Ajax environment.

Over the coming months we really want to take the Google map experience to a new level not seen in other web sites. However, we intend to do this is a way that follows our general design philosophy in SWAF; abstract the map interface and implement support for Google map as just another implementation of the map abstraction such that another "map provider" could be brought in and used over Google maps.

Grabbing content from an existing web site to populate a SCS site

09 May 09

We've been getting more and more web sites being built on Syrinx Community Server lately and an issue we've seen come up is getting content from their old site into the new site built with SCS. Some are forums that have had tens of thousands of posts. Rather than trying to write code to use some other products db directly, such as moving a forum from phpbb to SCS, we wrote a configurable utility feature that can browse to their current site and grab the content from the web pages and populate the new site's normalized database.

With this we can read all of a client's blog posts directly from their blog site and create articles from them in their new SCS site. We can create contacts, articles, products, forum posts, blogs and photo albums from content contained in other sites. It will even download all the images found in content being converted and fix the image tags in the new site to use the images from the local site.

After 3 iterations of development on the design and code for this feature, it has really come a long way in its flexibility in finding content in an existing web site and getting it in place within the new site. It can be configured with a user id and password to log into a site and keep track of the cookies as it goes to various pages on the site.

The feature is designed to look for lists of objects on a page, and then follow links to get details about the object before it inserts the object into the SCS database. For example, it can find a list of blog entries on the page and follow the links to the full post for each blog entry and then create an article in the SCS database for each of those articles. If the blog entries had images, those would get downloaded and placed into the SCS media library.

Each site that is going to be processed like this needs its own XML configuration that defines the site url, what user id/password to use, regular expressions to match against html to find the elements of data desired, and a few other options. You have to have a good grasp of how to use regular expressions if you want to write a configuration.

When the code is grabbing pages from a site, it can either work with one page at a time with a single site session or the parallel processing option can be turned on to allow it to grab as many web pages from the site at the same time as it can. This can make a big difference in the time it takes to grab all the desired content. As an example, a news site with 97 different news stories and images in a small percentage of them took 27 seconds to completely grab all the content when run in parallel, but too a minute and 30 seconds when run sequentially.

If you'd like to get the code for this, it comes with Syrinx Community Server. You can also read the developing documentation on the topic at:
syrinx.ph/Developer.aspx#gArt1_311FE53F-8587-4637-B6BA-15BE177FF2A6
 

Adding User Comments in Syrinx CS

23 Mar 09

We finally added universal user comments into Syrinx CS, which allows users to add comments to any type of business object in Syrinx CS. For example, users can add comments to blog entries like this one. In fact, the Syrinx site blogs now allow user comments because the Syrinx site is using this new feature.

Administrators of a Syrinx CS site can setup the level of support for user comments on any type of object through the company security settings. For example, they can allow anonymous users to add comments for blog entries and they can allow administrators to edit and delete any user comment. At the same time, general articles could be setup to not allow anyone to add user comments, or only registered users could add comments to general articles.

Whenever non-authenticated users add comments, they will also be presented with a captcha display. Users that have logged in can add comments without seeing the captcha display.

User comments for any given business object ultimately are a forum thread. Administrators can see all user comments created on any business object via an admin forum view of user comments. This makes it very easy to see new comments and manage them.

User comments also pass through the content filtering options of the company, so you can fully control what type of content the user tries to put into user comments. Anonymous users may only be allowed basics like bold and italic while administrators adding comments can be allowed to put anything including scripts, flash objects and others.
This was written so that it can also be used for other kinds of user comments. For example, users could have comments from other users about their profile. Contacts could have "phone records" for each time someone communicated with the contact.

I've noticed other sites connect with external technologies like "My Blog Log" from yahoo which will allow users who register on your site to provide a common profile from the yahoo site. It does a lot more than that, but one thing it can do is profile a profile image for users. Other sites hooking into this are able to show the user profile info in the user comments on their blog (I believe Word Press can do this, but could require an extension). I'd like to see Syrinx CS have this support as well. I'll add that to the big TODO list for Syrinx CS.
 

Pages: 123
Powered by Syrinx CS