8 posts by 3 authors in: Forums > CMS Builder
Last Post: September 30   (RSS)

I would love to see a code generator that generated only tags and those tags are click-to-copy.

Output of a detail page would just be something like this:

list($page_elementsRecords, $page_elementsMetaData) = getRecords(array(
'tableName' => 'page_elements',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$page_elementsRecord = @$page_elementsRecords[0]; // get first record

<?php echo htmlencode($page_elementsRecord['num']) ?>
<?php echo $page_elementsRecord['areas_served']; ?>
<?php echo $page_elementsRecord['practice_areas']; ?>
<?php echo $page_elementsRecord['legal_notice']; ?>
<?php echo $page_elementsRecord['feedback']; ?>

<?php foreach ($page_elementsRecord['page_headers'] as $index => $upload): ?>
<?php echo htmlencode($upload['urlPath']) ?>
<?php echo $upload['width'] ?>
<?php echo $upload['height'] ?>
<?php echo htmlencode($upload['info1']) ?>
<?php echo htmlencode($upload['info2']) ?>
<?php echo $upload['extension'] ?>
<?php endforeach ?>

<?php echo $page_elementsMetaData['_listPage'] ?>
<?php echo urlencode(thisPageUrl()) ?>

Using a click-to-copy javascript for each tag so it can be copied and pasted quicker. Right now, I highlight the snippet I need and Ctrl+C and then Ctrl+V. A lot of the time, I just wind up typing out the whole snippet if I think it would be quicker. All of the other text (even in expert mode) is way more than I need and just in the way.

So, is Expert-Expert Mode a possibility?

Thanks,

Kenny H

An "expert expert" mode sounds nice. I'm not really concerned about a "js click-to-copy" though.

By Dave - September 26 - edited: September 26

Hi Guys, 

We actually wrote the code generators as CMSB plugins so you can easily modify and extend them.

Here's how you do that: 

  • Copy a code generator, such as "List Page" from /lib/menus/_codeGenerator/listPage.php to /plugins/customCodeGen_listPage.php
  • Rename the functions by replacing "cg2_listpage" with "codeGenExpert_listpage" (or something else) 
  • Activate the plugin and confirm it shows up on the Code Generator menu under "Other Generators"

You can then optimize it however you like.  Do you want to give that a try? 

If you have any questions about how the code works let me know, and any If you come up with something cool feel free to share it in the forums.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

Nice! Learned another new thing about CMSB today :) Thanks Dave!

Hi KennyH, 

Can you try adding this line at the top? 

require_once SCRIPT_DIR . '/lib/menus/_codeGenerator/generator_functions.php';

// register generator

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com

Getting closer. It let me activate the plugin after adding the code you specified. I went to Code Generator and got the the following error

Fatal error: Cannot redeclare cg_typeByVersion() (previously declared in /home/lawweb/public_html/webadmin/lib/menus/_codeGenerator/generator_functions.php:7) in /home/lawweb/public_html/webadmin/lib/menus/_codeGenerator/generator_functions.php on line 16

Hi Kenny, 

Thanks for the feedback.  Try this fix: 

  • Edit /lib/menus/_codeGenerator\actionHandler.php
  • Replace: include "generator_functions.php";
  • With: require_once "generator_functions.php";

Let me know if that works for you and I'll include that patch in the next release as well.

Dave Edis - Senior Developer
interactivetools.com