Updating your Banner Slideshows Module

Posted September 3rd, 2012 in Lemonstand

One week from this post I will be publishing an update for my Banner Slideshows module for LemonStand which upgrades it to use the newly released Nivoslider 3. This will provide a few nice benefits however the implementation isn’t completely backwards compatible so your frontend code may need updating. Details inside.

What do I need to do?

Simply press the Update slideshow button on your slideshow page in the Administration:

Hit the update button indicated above

Hit the update button indicated above

Then remove your existing slideshow code on your sites frontend and follow the instructions on the marketplace page (to be updated when the module update is released) to add the new version.

How does this benefit me?

The biggest benefit is its new responsive design which resizes with your browser – making it easier to build sites that scale from a desktop monitor all the way down to a mobile phone. I’ve whipped up a live demo to see this feature in action. Open it up and resize your browser window. Notice the slideshow resizes with the window.

Also new in this version of the module is full HTML support for slide descriptions:

HTML support for slide descriptions

HTML support for slide descriptions

Read More »

Creating your first LemonStand Widget

Posted August 22nd, 2012 (Updated 1 Sep 2012) in Lemonstand

Creating custom widgets with the Widgets module for Lemonstand is a quick and painless process. Below, I’ll describe how to build a widget for Lemonstands Contact module. I’ll call this module Simple Contact Widget.

Download the completed module from my GitHub repo.

While this tutorial will go over everything you need to do to build a complete and working module, it would be very beneficial to also know the basics of module development, naming conventions and so on. Take a look at the documentation Developing LemonStand Modules if you haven’t already done so.

Read More »

LemonStand: Maximum function nesting level of ’100′ reached

Posted January 12th, 2012 (Updated 3 Sep 2012) in Lemonstand, PHP

Last night I was getting a strange error in LemonStand administration area when attempting to edit a product or category:

Fatal error: Maximum function nesting level of ’100′ reached, aborting! in /path/to/phproad/modules/phpr/helpers/phpr_inflector.php on line 322

If you’re also experiencing this error, it’s caused by XDebug and can be solved by adding

1
ini_set('xdebug.max_nesting_level', 200);

to your config/config.php file.

Thanks to Aleksey Bobkov and EHLOVader for their help in solving this issue. Here is the official LemonStand forum thread on the issue.

Read More »

Getting Module AJAX Events Working in the Front End in LemonStand

Posted November 9th, 2011 (Updated 3 Sep 2012) in Lemonstand, PHP

I had a bit of an issue with this and the documentation wasn’t of much help so I thought I’d post about the process. I currently have CampaignMonitor and MailChimp modules in the LemonStand marketplace and wanted to allow customers to create subscription forms on their sites that AJAX submit.

Firstly, here is the documentation page on custom events. The docs show that you need two things:

  • A subscribeEvents() method in your module’s setup class containing an addEvent() call.
  • A method containing the code you want to execute, which will be triggered by your event.

I attempted to do the above with the following backend code:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
class MyModule_Module extends Core_ModuleBase
{
	public function subscribeEvents()
	{
		Backend::$events->addEvent('MyModule_Module:onSubmit', $this, 'on_submit');
	}
 
	public function onSubmit()
	{
		//...
	}
}

And frontend code:

1
2
3
<form onsubmit="return $(this).sendRequest('MyModule_Module:onSubmit')" action="/" method="post">
	<input type='submit' name='submit' value='Submit' />
</form>

I submitted the form and was greeted with an error message:

An AJAX error occurred: AJAX handler not found.

After a little digging I came across the function excuted when you perform an AJAX query. Important lines are highlighted:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public static function execAjaxHandler($name, $controller)
{
	$parts = explode(':', $name);
	if (count($parts) != 2)
		throw new Phpr_ApplicationException("Invalid event handler identifier: $name");
 
	$className = ucfirst($parts[0]).'_Actions';	if (!Phpr::$classLoader->load($className))
		throw new Phpr_ApplicationException("Actions scope class is not found: $className");
 
	$method = $parts[1];
	$isEventHandler = preg_match('/^on_/', $method);	if (!$isEventHandler)
		throw new Phpr_ApplicationException("Specified method is not AJAX event handler: $method");
 
	$obj = new $className();
	if (!method_exists($obj, $method))
		throw new Phpr_ApplicationException("AJAX handler not found: $name");
 
	$obj->copy_context_from($controller);
	try
	{
		$result = $obj->$method();
		$controller->copy_context_from($obj);
		return $result;
	}
	catch (Exception $ex)
	{
		$controller->copy_context_from($obj);
		throw $ex;
	}
}

There’s a couple of things to note here.

  • Your second and third arguments in addEvent() are ignored.
  • _Actions is concatenated onto the end of your class name
  • Your method name must start with on_

With the above in mind, it’s time for some rewriting:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
 
class MyModule_Module extends Core_ModuleBase
{
	public function subscribeEvents()
	{
		Backend::$events->addEvent('MyModule:on_submit', $this, 'on_submit');
	}
}
 
class MyModule_Actions extends Cms_ActionScope
{
	public function on_submit()
	{
		//...
	}
}

That worked like a charm. Good luck to all the module developers for LS out there – I’ve found LemonStand a number of quirks like this and we’ll just have to tackle them one at a time :)

Read More »

Converting the Default URL Separator to Dashes in Lemonstand

Posted June 1st, 2010 (Updated 3 Sep 2012) in Database, Lemonstand, PHP

When it comes to online shopping carts, LemonStand is the hot new thing. Still in beta, this piece of software boasts a surprisingly large feature set and high level of customization options usually only seen in much larger CMS’s. The one narking issue I’ve had with it so far is its choice of URL separator – preferring underscores over dashes. After speaking to the very polite and friendly developer behind LemonStand, a solution was quickly devised.

To convert the default URL separator in LemonStand from underscores to dashes simply add the following line of code to your config/config.php file.

	$CONFIG['URL_SEPARATOR'] = '-';

Update 3 Jun 2010: I’ve received word from the author behind LemonStand that he’ll be publishing an update later today changing the default URL separator from underscores to dashes. The change will not affect any existing installations and only apply to new installations. For developers wishing to change the default separator on new pages on existing installations, the fix above still applies. This is great news that I’m sure many developers out there will be pleased with.

Read More »