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.

Google Tag Manager (GTM) Not Firing Default PageView Event

Posted on 11/08/2017 at 12:21 pmViewed 474 times

We had an interesting issue here today regarding Google Tag Manager not firing the default PageView event.  Instead it was firing the /gtm.js event.  WTF?! Turns out, the system we were using was reading event: 'gtm.js'  in the GTM container snippet as a link to a javascript resource.  So, it was turning the "url" into an absolute path, like...

In PHP, how do you get __toString() Magic Method Result without calling echo?

Posted on 10/13/2017 at 01:49 pmViewed 519 times

I knew this answer at one point, then forgot it.  So, here it is for memory's sake... How can you get __toString() Magic Method Output WITHOUT using echo statement? $echoed = strval($object->property); Cheers, - Kevin Wentworth

Getting output from shell_exec() at all times

Posted on 11/14/2016 at 12:18 pmViewed 1,648 times

Sometimes shell_exec() won't output anything.  This might be because of an error or a silent success.  If you want to see the output, you can always do this: $output = shell_exec('$HOME/aaa/command 2>&1'); echo "<pre>$output</pre>";

CORS Middleware in Cakephp 3

Posted on 10/11/2016 at 09:44 pmViewed 1,676 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 1,714 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...

Read More Posts.

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design