How to tell what file is producing what HTML in Concrete5 - tip not a question.

Permalink
For what it's worth I wanted to post a way that I use to tell what Concrete5 file produces what HTML when I want to make some changes to the produced HTML code.

Please be aware that this method can potentially break C5 temporarily (until you remove the change to a file you have just placed it in) so use at your own risk.

Change index.php to be the following (you are adding a define statement).

<?php
define('CGC_DEBUG_COMMENTS', true);
require('concrete/dispatcher.php');


Then let's take footer.php inside a custom theme elements directory.

Replace the usual first PHP line in the file with...

<?php
defined('C5_EXECUTE') or die("Access Denied.");
if (defined('CGC_DEBUG_COMMENTS')):
   if (CGC_DEBUG_COMMENTS == true):
      echo "<!-- START /themes/custom_themes/elements/footer.php ------------------------>".chr(10);
   endif;
endif;
?>


Then at the end add...

<?php
if (defined('CGC_DEBUG_COMMENTS')):
   if (CGC_DEBUG_COMMENTS == true):
      echo "<!-- END /themes/custom_theme/elements/footer.php -------------------------->".chr(10);
   endif;
endif;
?>


Note: the chr(10) is just a newline allowing your debug comments to appear nicely inside the rendered HTML without running into the surrounding code.

Finally go to a page and access it in your browser and press Ctrl+U to look at the source code.

Look for the START and END comment. The HTML in between these comments is that which was produced by footer.php.

The above may seem like a lot of work for such a basic thing but when you have multiple files in Concrete5 producing the final HTML it's a bit tough to tell what does what and having such comments inserted into the output can help make heads or tails of what it is doing.

If you have any questions just ask. If you all want to see more of these tips please speak up and I may post more of them from time to time.

If this is not something you might ever use or if it seems like gibberish nonsense...hmm...well...have a good day I guess LOL.

Carlos