inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Dec 26, 2014 7:50:27 GMT -8
I just noticed this the other day when trying to modify one of my small plugins and it seems that now the only place I can insert a variable is in the Javascript Component area.
It was not like this before as I inserted variables either in the Javascript, CSS or Headers/Footers > Saved Changes with no problems.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 26, 2014 8:37:38 GMT -8
You can still use variables in the headers & footers. ( I could last time I tried it ) If you need to use a variable for CSS, you can just add it to your header inside style tags.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Dec 26, 2014 9:56:03 GMT -8
You can still use variables in the headers & footers. ( I could last time I tried it ) If you need to use a variable for CSS, you can just add it to your header inside style tags. Hello PebbleJust tried to insert a variable in the header/footer of a plugin and it just won't do it and as to the CSS in the headers, it won't insert there either.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Dec 26, 2014 11:57:52 GMT -8
Specifically what variable are you trying to insert? If it's a variable created by a setting you've added to your own plugin then it definitely should be available in both JS and any headers/footers component. You can easily tell by clicking on a component then looking to the right where it says "Plugin Assistant" to see all the insertable variables associated with that particular plugin. If you are referring to system variables (the kind you use in layout templates) then as Pebbles stated it has traditionally only been available in the headers/footers sections. Keep in mind that headers/footers are interpreted as HTML so if you want to add CSS or JavaScript then you would need to wrap them in their appropriate HTML tags <style type="text/css"> CSS-RULES-GO-HERE (with backend variable parsing) </style>
<script type="text/javascript"> JAVASCRIPT-CODING-GOES-HERE (with backend variable parsing) </script>
Also keep in mind that system variables are for the most part context-sensitive, so a variable that holds the number of visitors in the last 24 hours may not be available on a page that has no need for that information, or more precisely has no requirement in its layout for that variable's information. There are only a few variables that can be accessed from anywhere (e.g. route, current_user) so that might be a factor in why it might not be working for you but without knowing specifically what variable is being used and on which page then it is all just a big guessing game.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Dec 26, 2014 12:50:18 GMT -8
Hello ChrisThanks for the input, however some of that input is way over my head. Here is a simple Global Header HTML I created long ago, or should I say, to see if I could get the hang of creating my own plugin: Global Header HTML:
<div class="container"> <div class="title-bar"><div align="$[plugin.settings.align]"><h2>$[plugin.settings.title]</h2></div></div> <div class="content pad-all"> <center><span id="d_t" style="font: $[plugin.settings.font_style]; color: #$[plugin.settings.font_color]; font-weight: $[plugin.settings.font_weight];"></span></center> </div> </div>
and this is the variables: (image) I was in the process of creating a new plugin and came across the problem of inserting a variable to it with no results. Just to note, in the early V5 Testing, I had no problems with creating some very small plugins, but now, nothing seems to work with inserting any type of variable with the exception of the javascript area.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Dec 26, 2014 12:59:09 GMT -8
I just went and tested this out and indeed, you can't add the variables on the right to the header / footer section. ( adding them to the CSS part is not meant to work ).This bug was found maybe a month ago and was going to be sorted out but maybe they haven't got round to it yet, or it broke again. I'll tag David Clark for you as he may know something about it... EDIT: Or maybe Tim Camara would know.... Or maybe both!
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Dec 26, 2014 13:03:59 GMT -8
Well that explains it then and thanks much for tagging David and Tim.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Dec 26, 2014 14:38:12 GMT -8
Thanks aRMY83 and Pebble for noticing that. I generally code with an external editor using the list only as a reference so never noticed that insertion had stopped working. @developers, I traced the problem to the fact that the .CodeMirror-textarea for the headers/footers are missing their content-html class, so an error occurs specifically in this line: // ---------------------------------------------- // // Assistant Insert Button // ---------------------------------------------- //
var insertVariables = function (e) { // Make sure there is an active text area and selection. if (!lastSelected || !lastTextArea) { proboards.error('Select a variable from the plugin assistant and click somewhere in a code box to insert.'); return; }
// Assemble the parts for the template variable. var varType = lastSelected.parent('ul').attr('class'); if (varType === 'variables') varType = 'settings'; if ($.inArray(varType, ['images', 'settings', 'keys']) === -1) varType = 'images';
var contentType = $(lastTextArea).attr('class').match(/content\-(\w+)/)[1]; var identifier = $.trim(lastSelected.html());
// Nothing can be inserted into CSS, and keys can only be inserted into javascript if (contentType === 'css') return;
var variable; // Set the variable according to content type (js or html) if (contentType === 'html' && varType != 'keys') { variable = '$[plugin.' + varType + '.' + identifier + ']'; } else if (contentType === 'js' || varType == 'keys') { var code_name = $('#plugin-editor input[name="code_name"]').val(); variable = 'pb.plugin.' + (varType === 'keys' ? 'key(\'' + identifier + '\').get()' : 'get(\'' + code_name + '\').' + varType + '.' + identifier + ''); } // Replace the selection with the template variable. lastTextArea.data('editor').replaceSelection(variable);
// For the insert button, deselect the item if ($(this).is('button')) { lastSelected.removeClass('selected'); lastSelected = null; } // For the items themselves, leave them hilighted else { e.preventDefault(); } };
Firefox 34.0.5
|
|
inherit
The Dream Crusher (Ret.)
164921
0
Apr 1, 2014 11:00:25 GMT -8
Tim Camara
Teach a man to fish, etc., etc.
1,721
March 2011
tcamara
|
Post by Tim Camara on Dec 29, 2014 8:36:02 GMT -8
Thanks for the assist Chris. Added to our bug list, and since it should be straightforward to fix, I'd expect it done sometime this week.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Jan 3, 2015 10:04:52 GMT -8
|
|
inherit
The Great Cinnamon Roll
191518
0
Oct 19, 2016 22:17:44 GMT -8
David Clark
Care for some tai chi with your chai tea?
17,602
March 2013
davidlinc1
|
Post by David Clark on Jan 3, 2015 10:11:07 GMT -8
No idea of an ETA just yet, aRMY83, but I'm happy to inquire with Tim on Monday about where we are on this one. I've made a note to do so
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Jan 3, 2015 10:20:03 GMT -8
Thanks David Clark for the rapid response and will be looking forward to a fix for this.
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Jan 3, 2015 12:21:39 GMT -8
Hello again David ClarkJust realized for the headers/footers, I can place these Variable ID's, as an example: in the appropriate area of the plugin I'm working on for now.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Jan 3, 2015 13:18:30 GMT -8
That is likely the reason it hasn't received any special priority like the theme storage capacity bug for instance aRMY83. The misbehaving feature simply does what you yourself could probably do by hand so would not (in my opinion) be triaged and place above more pressing matters. The confusion factor to newcomers on the plugin scene might lend it a bit of weight but like Pebble said it was first discovered over a month ago yet I knew nothing about it mainly because I rarely use that feature and I, in fact, thought you were discussing the rendering side of things instead of the insertion side when I first saw this thread (e.g "inserted but doesn't work as expected"). It used to be that only keys were insertable in the JS component through the UI but that silly restriction was later rectified as you can see from the posted code (although it still bears the now incorrect comment: "Nothing can be inserted into CSS, and keys can only be inserted into javascript"). One could always insert variables into the Javascript component manually in the form: pb.plugin.get('PLUGIN_ID').settings.VARIABLE_ID
|
|
inherit
First Contributor
66253
0
Mar 18, 2024 11:09:20 GMT -8
aRMY83
2,925
December 2005
army83
|
Post by aRMY83 on Jan 3, 2015 16:28:10 GMT -8
As always Chris, thanks for the information.
|
|