MainelyDesign.com Blog

Showing articles 1 - 10 (145 total)

Change Order of Loaded Behaviors in CakePHP 3

Posted 5 days, 3 hours ago | Viewed 20 times | 0 comments

Turns out it's really easy to change the order of how behaviors are loaded in CakePHP 3.  Wait, I'm actually sort of lying.  You can't change the order of loaded behaviors. (BOO!).  In previous versions of Cake this was a problem... however, with the fully implemented Events subsystem in Cake3, all you need to do is change the priority of the...

CakePHP 3 - Accept JSON Header Only Working When Debug False

Posted on 05/29/2018 at 09:20 am | Viewed 530 times | 0 comments

Strange thing... when you have debug disabled you may find that your application works fine when dealing with json routes without the extension.  Instead of accessing /posts.json, you would access /posts and send an Accept: application/json header and the same thing is achieved. Debug On - Json View Templates Don't Load - Same Accept Header I...

Remove All Events from Google Calendar (Reset Calendar)

Posted on 05/23/2018 at 09:29 pm | Viewed 328 times | 0 comments

I've been doing a lot of programming with the Google Calendar API lately and ran into an issue when I was ready to "go live" with the site.  The Google Calendar was loaded with tons of test data!  I searched around and found plenty of sites giving the same answer.  The problem with the answer- it was incomplete.  If you want to reset a calendar...

Google Tag Manager (GTM) Not Firing Default PageView Event

Posted on 11/08/2017 at 12:21 pm | Viewed 1,428 times | 0 comments

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 pm | Viewed 1,145 times | 0 comments

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 pm | Viewed 2,262 times | 0 comments

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 pm | Viewed 2,548 times | 0 comments

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 pm | Viewed 2,374 times | 0 comments

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 pm | Viewed 2,459 times | 0 comments

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 pm | Viewed 2,368 times | 0 comments

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

<< newer    1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9   

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design