Creating a Blog Search Page for Lemonstand Simon Stevens wrote this on 11 Sep, 2012

Credit: 96dpiThe default Lemonstand page setup doesn't come with blog pages at all (bizarre I know), however they very helpfully provide documentation which is enough for most people.

One of the missing features though, is a search page!  Oh noes!

It's very easily added though, steps below :)

  1. Duplicate your main Blog Archive page.
  2. Rename it to Blog Search, update the url as you like.
  3. Add the following code at the start of the page:
    You searched for "<?= h(Phpr::$request->getField('search')) ?>"
  4. Add the following code in the Post Action Code section of the Action tab:
    if($search = Phpr::$request->getField('search')){
    	$search = '%' . $search . '%';
    	$posts->where(
    		"title LIKE :search OR 
    		description LIKE :search OR 
    		content LIKE :search", 
    		array('search' => $search)
    	);
    }
  5. .....
  6. Profit!

Now just create a search form that submits to your Blog Search page using a GET method and search variable "search".

Be the first to comment!

The Maybestand Experiment Simon Stevens wrote this on 3 Aug, 2012

The first step in turning a fantastic design in to a usable, refined e-commerce website is experimenting with the various platforms available.  Stumbling on to the winner straight away is nice, but 2 or 3 iterations is more usual.  Eventually you discover the best foundation for your vision.

For the new 3DPixel.net website, we experimented with Wordpress which seemed intially to provide a fantastic platform for the website.  Half way through development though a friend of the company introduced us to the Lemonstand e-Commerce Engine which we immediately recognised as a future industry leader.  It wasn't until we helped develop the new Mountain Valley Wines e-commerce website though that we really realised aside from being fantastic for e-commerce, it's also the best framework we've ever worked with, offering unparalleled customisation that simply removes any restrictions on what is capable with the platform.

Read more

Access Lemonstand's backend login details Simon Stevens wrote this on 24 Jul, 2012

I wanted to access the user session for the backend to use in the frontend so that I could give administrators rights to things that only subscribed members would normally be able to access.

Took a bit of digging, but here it is:

$phpr = new Phpr_Security();
$phpr->userClassName = 'Users_User';
$admin = $phpr->getUser();

By default, the Phpr_Security class uses the Phpr_User model, which isn't as fully featured as the Users_User model.  Fortunately Lemonstand added a way of changing the model that's used, so the following line is used to force it to use Users_User, which then allows us access to methods such as is_administrator();

$phpr->userClassName = 'Users_User';

Be the first to comment!

ifelse() - Output the first argument that exists Simon Stevens wrote this on 23 Mar, 2011

I wrote a tiny function many years ago that simplified echoing out variables into a form for me. It took 2 arguments and output the first variable if it was present, and the 2nd if not. I called it postOrNot(), and it was terrible.

I wrote a tiny function many years ago that simplified echoing out variables into a form for me. It took 2 arguments and output the first variable if it was present, and the 2nd if not. I called it postOrNot(), and it was terrible for 2 reasons:

  1. The function name was bad (now was that an uppercase O or an N?)
  2. It was too limited, sometimes I'd have to nest it

I addressed those issues in the function below. It has a simple, short and memorable function name and takes as many arguments as I needed.

function ifelse(){
	if(func_num_args() < 2) 
		trigger_error("ifelse() requires 2 or more arguements", E_USER_ERROR); 
	else { 
		$args = func_get_args();
		foreach($args as $arg){
			if(isset($arg)) return $arg;
		}
		return false; 
	}
}

It'll return out the first argument that is set or false if none of them.

Enjoy

Be the first to comment!

$_GET() - A function for reading GET variables with Javascript Simon Stevens wrote this on 19 Oct, 2011

I found a great piece of code whilst trying to figure out how to read get variables with Javascript.

function $_GET(q,s) {
	s = s ? s : window.location.search;
	var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i');
	return (s=s.replace(/^?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;
}

Credit goes to Online Aspect

Be the first to comment!