Feature Request: Field Editor List Options - advance mysql query
4 posts by 3 authors in: Forums > CMS Builder
Last Post: July 18 (RSS)
Since the option for "get options for MySQL query" uses mysql statements, it would be great if this could be formatted for code with line numbers instead of a no-wrap text box.
USE Case
SELECT 0 as num, "" as title
UNION
SELECT num, title
FROM `<?php echo $TABLE_PREFIX ?>locations`
WHERE use_company_lookup = 1
Hi Jeff,
Sure, here's a quick patch to add that. We can add it to the next version as well.
- Open /lib/menus/database/editField.php
- Search for: Available vars
- Add the code in the <script> tags below
echo t('Available vars: $ESCAPED_FILTER_VALUE, $CURRENT_USER, $RECORD');
?><br><br>
<script>
document.addEventListener("DOMContentLoaded", function () {
textareaToAceEditor('optionsQuery', 'mysql', false, 5, 25);
});
</script>
Let me know if that works for you. Thanks!
interactivetools.com
Unfortunately, this didn't work. I have the following error in the concole.
Uncaught TypeError: Window.getComputedStyle: Argument 1 is not an object.
textareaToAceEditor https://yaaws5.yaa.test/cmsb/lib/admin_functions.js?v=1720050496:585
<anonymous> https://yaaws5.yaa.test/cmsb/admin.php?menu=database&action=editField&tableName=cmsb_bios&fieldname=locations&:681
Hi Jeff,
I am new to CMS Builder but I thought I could pitch in with an answer. Dave's solution will work, but is missing a few more details.
On the textarea element with the name "optionsQuery" a few lines up from the "Available vars" line, add two additional attributes. One is
id="optionsQuery"
and another is...
style="height: 300px;"
So in the end your textarea element should look like the following...
<textarea name="optionsQuery" id="optionsQuery" cols="60" rows="3" style="height: 300px;" class="form-control text-nowrap setAttr-spellcheck-false textareaGrow" data-growsize="10"><?php echo htmlencode($field['optionsQuery']) ?></textarea>
I believe after this change, the JavaScript Dave gave you should turn that box into an editor box with line numbers. Attached is a screenshot.
Now of course I don't know if it is safe to edit these files and if they will be overwritten by future updates, but at least it can get that working for now and perhaps Dave's team can then put it in as part of core.
I hope this is what you were looking to do. :)
Senior Application Developer
TimHurd.com