Welcome to MainelyDesign.com

Photos of Rockland, Maine. Summer 2009.

A blog mostly about web design

This is the personal blog of Kevin Wentworth.  Topics covered here are web programming, design and internet marketing.

CORS Middleware in Cakephp 3

Posted 2 weeks, 3 days agoViewed 51 times

I didn't end up needing this (yet) but wanted to post here for future reference.  This is CorsMiddleware for CakePHP 3: // Plugin\src\Middleware\CorsMiddleware.php namespace Plugin\Middleware; class CorsMiddleware { public function __invoke($request, $response, $next) { // Calling $next() delegates control to the *next* middleware // In your...

View Layer - Getting count of Entities in View in Cakephp 3

Posted on 06/12/2016 at 01:27 pmViewed 399 times

In my views I'm usually executing code depending on if a variable is empty or not.  For example, I'll fetch all the images in a gallery and only want to output the containing divs when the gallery has images.  You can't do a simple !empty() or if($img) because it will always be "true" because it will be a non-empty object (like Cake\ORM\Query...

Changing URL in beforeRedirect() in Component - Cakephp 3

Posted on 05/23/2016 at 12:21 pmViewed 434 times

Change the URL redirect location using beforeRedirect() in Cakephp 3 I wanted to change the redirect behavior from within a component in my Cakephp 3 application.  The old 1.3 method of returning the new $url didn't work.  Turns out that you need to use Response::location() to modify the location of the redirect.  See my code below: public...

Foundation CSS Framework Resources

Posted on 01/28/2016 at 12:30 pmViewed 754 times

Motion UI Classes (used for animation): https://github.com/zurb/motion-ui/blob/master/docs/classes.md

Change View File from Controller in CakePHP 3

Posted on 01/27/2016 at 10:37 amViewed 832 times

You can change what view.ctp file you want to use in your controller with the following line of code.  I place it at the bottom of my function definition.  Useful for having a simple admin interface or a different view template for each language.  This doesn't change the layout of your page, just the view template the controller uses when...

Read More Posts.

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design