XCART Modules

After requiring the facility of housing a custom slideshow on an XCART project we came to the conclusion that there just did not seem to a decent module free or paid for. So with that conclusion in mind we thought it would be great idea to come up with our own and note down the steps we took to make it happen. Eventually will be moving our XCART modules into a self installer to care of all the steps, but it is useful to note down the steps involved for us and anyone interested in how XCART modules can be produced from scratch.

First point to note that installing XCART modules can be tricky to install and you will notice most providers of third party modules offer an installation service for this very reason (and of course charge for it to be installed!).

Planning is essential as this will make the next modules you produce pretty much a breeze with the outlined steps within your own framework laid out. The idea of using a framework within XCART’s framework is an idea that has caught on as XCART is profoundly a framework that allows any developer to step in and take control over its workings. Using your own core code and interfacing with XCART is the best to route to go to maintain compatibility and be more readily updatable. Plus upgrading XCART then should not break your module!

So our theory side out of the way this is the route we came up with. There are many other ways to do this of course but this enabled us to rapidly produce further XCART modules for ongoing projects which was our goal. Yours may differ of course so you can adapt your own techniques with a bit of theory in place.

So firstly we dropped our own script into the admin folder which would handle the entire admin interface of any of our plug-ins by calling on the module in question, in here we highlight the modules that we have installed so the script can not be miss-used. In this case it is called dcoda.php. In here we outline any of our own modules that are available that we have made which will interact them and call any functions and procedures handled in the admin area.

Modulesgoes in to /admin/dcoda.php

Next we decided to create a separate area in the images directory in which to store our images which appear on the slideshow so we created a directory in images: /images/Dcoda_Slideshow

Next we have our example module called Dcoda_Slideshow which is folder of scripts which is dropped into the modules folder of XCART.

Modules goes into /modules/Dcoda_Slideshow

Next we need our admin template files which will form the viewing of the module in admin. Keeping with the same name convention they are in a folder called Dcoda_Slideshow. These files drop into the skins are section under common_files under the modules directory

Modules goes into /skin/common_files/modules/Dcoda_Slideshow

Then the list file we are using is a custom Smarty plug-in. Smarty is the template engine that XCART uses and has the features to do many things that can be called up on within a template file keeping it separate from your business logic.

Modules goes into /include/templater/plugins/function.Dcoda_Slideshow.php

So now we have all our files in position how do we get the module to show in the admin area and to off course “work”! Unlike some frameworks XCART doesn’t just need files it also needs a bit of TLC on the database (it is not plug and play!) in the table called “xcart_modules”. All that actually needs to happen here is for you to enter a few details as new row which references the module you have just dropped into place. You can used phpMyAdmin for the easiest visual way to insert the new row, or if you are MySQL whiz then you can simply insert the row in the console.









Slide Shows For Use Anywhere on the store



dCODA Digital



What we entered in the module name which as we know in this case is Dcoda_Slideshow, then a description ensure you make sure active is set to ‘N’ as the only way to see if your module has errors or not is at the point you activate it in the admin area. Initiation order by is not important in our case so we left that as zero entered us the author and a few tags separated by a colon for it to be categorised by in admin.

Once you have done this you will then see the module in the admin area. If you activate problem free you have done well. If not it is case of “what did I miss” and looking back and checking each step covered.

You will then see you can access the module by going to the url in admin /admin/dcoda.php?mod=Dcoda_Slideshow

Preview adding a slide show:
Preview One


Preview of the adding an image to the slideshow:
Editing a slide


Preview of the list showing the slides in the slideshow:

There you can now create a slideshow and all the images you wish to it. You can have as many slideshows as you require and unlimited images to each one in case you are wanting to use more than one slideshow across the XCART store.

And finally as we produced the Smarty function we can call this in any of skin templates by using this template function:-

{Dcoda_Slideshow id=1} The id part is the actual id of the slideshow you have created in admin so it is important to have your slideshow set up with images before you add this to your template, otherwise you will not get any slideshow outputting of course.

Preview of fading slideshow in action:
Front end slideshow

Good luck if you are having a go! Happy coding!

Want any more information on XCART Modules get in touch