User Tools

Site Tools


products:stewhunt

What is Hunt?

StewHunt hooks into the template engine, and wraps every template with silent markup.

At the end of the page, a new section in your debug output lists of all templates used to build the page.

Each one is a link that will take you to the element on the page and attempt to make it pop out at you.

We say “attempt” because there are edge cases (more on those later)., But for the most part, it gives you a very good head start.

Or you can simply “view source” and then search for STEWHUNT. Each one is a marker in a comment showing exactly where within the page a given template started and ended it's output.

Here is a sample page when the hunt is on:

In this case we clicked on FIND next to block_feed_form in the list on the bottom of the page.

The code for the template is changed to yellow, and a red link is inserted before.

That gives a pretty good visual clue where to look !

If we then open up the developer console, we can see the markup is surrounded by a span with the id STEWHUNT, and a matching ENDHUNT comment.

Clicking on CACHE or SOURCE will find and display the cached script or source template. Assuming they are in the local file system! If you have memcached for cache and the database for templates, this will not fly. You will have to find your template normally given the name in the list.

Requirements

Notice that Kint recommend the debugging tool for development only.

Not recommended for live servers. Install in production at your own risk.

The mod installs normally for phpfox version 3.7.0 and up (in the V3 series)

Versions 3.0 - 3.6 do not have all the hooks in place. We have provided instructions on the installation section of this page if you want to put them in yourself.

If you do not wish to upgrade the the latest right now, you can add the hooks yourself.

UNTESTED using templates in the database. We assume you have your own theme in the file system.

Enabling kint and hunt

There are three different ways to start using Kint and Hunt.

On the fly

As a general rule, you may turn hunting on early in your experience, then find you need it less and less as you gain familiarity with the product.

Later, when you have all the flags off, if you want to hunt on a page again, you need to switch on hunting and clear cache.

Or you can add one or all of these extra parameters to the uri:

  • stewhunt_on
  • stewkint_on
  • cache_clear

EG /marketplace/stewhunt_on/cache_clear

That turns on hunting (or kinting or both) for that page, just that once, only. In additional the template cache will be cleared before the page is generated, so every template has the hunting tags on that page.

Very convenient!

Some caveats:

Clearing template cache and not all the others may lead to strange behaviour for some sites. If that bites you, just clear cache normally and carry on ;)

There are a few cases where fox tries to interpret the extra switches as something else. Depending on your setup it might be different, but the usual suspects are index-member and index-visitor (because if there is anything extra for those urls, fox will assume it is a profile name…)

For that, the two methods below have you covered.

AminCP Settings

After installation you have two new settings in your adminCP under StewHunt.

Turn on Kint? Yes or No.

Turn on Hunt? Yes or no.

These are simple switches that behave as you might expect. Clear your cache and now every page you visit will have hunt and kint enabled.

dev.sett.php

define('STEWHUNT_HUNT', true);

define('STEWHUNT_KINT', true);

Your may place these in dev.sett.php or server.sett.php to enable site-wide without using admin switches.

Comment or delete them to disable.

Installation

3.7.0 - 3.7.final

Installs like every other add-on:

  • Unzip the product file.
  • Copy or ftp the contents of the upload folder to your website root folder
  • In adminCP go to Extension > Manage Products > Install new product

After installation you will see your new setting available in the StewHunt group. And if you go to /stewhunt/on the front end you will see a “hello world” page that can also be used to check what flags are currently set.

3.5.0 - 3.6.final

You must add the plugin lines yourself. Phpfox will void your warranty and send you to hell. But this is a debug tool intended for development sites.

ALWAYS BACKUP FIRST

Copy this line:

(($sPlugin = Phpfox_Plugin::get('get_master_files')) ? eval($sPlugin) : false);

Insert as shown below into /include/library/phpfox/phpfox/phpfox.class.php

3.0 to 3.4 final

You must add the plugin lines yourself. Phpfox will void your warranty and send you to hell. But this is a debug tool intended for development sites.

ALWAYS BACKUP FIRST

Copy this line:

 if ($sPlugin = Phpfox_Plugin::get('library_template_cache_compile__1')){eval($sPlugin);if (isset($aPluginReturn)){return $aPluginReturn;}}

Insert as shown below into /include/library/phpfox/template/cache.class.php

The line (in yellow) is found near the end of the method named public function compile

Last step here (REQUIRED) for all installs

You cannot see anything until you add these lines to your templates:

        {plugin call='stewhunt.kint'}
        {plugin call='stewhunt.hunt'}

We suggest you put them in your main theme template just before the closing body, eg

/theme/frontend/MYTHEME/template/template.html.php:

        {plugin call='stewhunt.kint'}
        {plugin call='stewhunt.hunt'}
    </body>
  </html>

If you put them in different templates and different places that may help you find a particular issue, since they will work with whatever they have so far.

But the intention is that they remain at the bottom of the main page, so they have all information on the page.

These have no effect unless enabled. So you could leave them in production templates. But remember anybody that knows about this product could hunt or kint at your site. Be sure you have you user group permissions set to eliminate that possibility.

Customizing colours

StewHunt needs to make a part of your page pop out at you. So you can see where the template is within the page.

We have used primary colours that stand out against the default template.

If your site uses those colours heavily, it is hardly going to pop out at you!

A very simple style sheet in included at /stewhunt/include/static/css/default/default/stewhunt.css

You may change those colours directly.

Permissions

User group permission Can hunt/find and inspect templates at runtime is initially set True for Administrators, False for all other groups.

You may need to enable permissions for an additional user group.

Edge Cases

We spoke earlier of “edge cases”

1. Templates in the header may not highlight/pop out if you have a really funky theme

2. Templates within markup cannot be hilighted. EG

<div id="content" {content_class}>

In these cases, the template supplies content for markup, not content.

Since we cannot insert markup within markup, we can't cope.

Probably best not to mention this at all, just gonna confuse people.

Better yet solve the problem.

Point to take away: It cannot work perfectly for every case, there are going to be places where markup is hidden or overridden or who knows what. This is a 98% tool. It covers almost all cases. The remaining cases are not worth the time to fix. It's just a tool, and it gets you closer than working by hand.

PROBLEM SOLVED In the latter case, we use the new HTML5 data attribute to store the template name within the markup. In that case (and other edge cases) just use your browser to view source. Searching for data-hunt-tpl will find you all the tag content generated by templates.

At first release, this is only these two templates:

$aOpenList=array(
    'block_template-contentclass',
    'block_template-holdername'
    );

If anyone finds more, just add them to the list in /module/stewhunt/include/plugin/library_template_cache_parse__1.php


Possible Futures

  • Support templates from the database if there is any demand
  • View source/cache would be nicer in a pop-up
  • Hover on page to show template names
  • Sort list of templates alphabetically. Currently shown in compiled order (which can be useful) but when looking for a specific template an alpha list would help
  • Put the list is as pop-up/drown-down floating component
  • Mark which link was checked so we have a visual clue relating list to highlighted block
  • Jump to admincp template editor (does anybody use that?)

Download

Demo

http://demo.stewfoxdev.com/v377/stewhunt/index.php?do=/ (scroll to the bottom of the page)

To support continuing development

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G57CPQAZVFFQ2

products/stewhunt.txt · Last modified: 2015/07/05 07:44 by steward