Excuse my bad english.
I am using FOSCKEditorBundle bundle with easyadmin 4 in symfony 6.
I can't override the ckeditor_widget.html.twig file as shown on this documentation:
https://symfony.com/bundles/FOSCKEditorBundle/current/usage/append-javascript.html
The original file lies for me here : C:\wamp\www\monsite\vendor\friendsofsymfony\ckeditor-bundle\src\Resources\views\Form\ckeditor_widget.html.twig
I created the file for overloaded at this address: C:\wamp\www\monsite\Ressources\views\Form\ckeditor_widget.html.twig
And in my file : C:\wamp\www\monsite\config\packages\fos_ckeditor.yaml, i added this:
twig:
form_themes:
- "::Form/ckeditor_widget.html.twig"
But nothing to do, it is always the original file that is taken into account.
Is it in fos_ckeditor.yaml that you have to indicate the path to the theme ?
Do you see something wrong ? Maybe I'm wrong in the location of the new ckeditor_widget.html.twig file... I admit that I don't quite understand the paths indicated.
Thanks
Related
My english is a colander and my programming skills in Javascript the same. I have in a specific folder of Google Drive several PDF files (about 10). Once a day, near midnight, I have to move these files separately (one for one) in specific Google Drive folders.
Actually I make this activity by hand, so I tried to automate it with a simple script.
I'm able to point to the specific folder, but NOT to the specific file.
In the samples I found around in Internet all files contained in a folder are moved to another folder, so the filesIterator technique are used.
But I don't need to iterate, I need to point the specific file and move it to anther folder.
Here my five (confused) program lines:
function moveFiles(source_folder, dest_folder) {
var source_folder = DriveApp.getFolderById('0B42Jhhzp_5X7QUlMdE9SZS0wMms');
var dest_folder = DriveApp.getFolderById('0B42Jhhzp_5X7TFZBMXpfeWpZNFk');
var file = getFilesByName('caa20170829.pdf');
// var files = source_folder.getFiles();
// Logger.log(file.getAs(MimeType.HTML).getDataAsString());
dest_folder.addFile(file);
source_folder.removeFile(file);
}
The error message I'm getting:
ReferenceError: "getFilesByName" not defined. (line 6, file "move")
Any help would be appreciated!
As suggested from Max Deepfield (thanks, Max), I edited the line 6 as follows
var file = DriveApp.getFilesByName('caa20170829.pdf');
and the error message changed to
Impossible to find the method addFile(FileIterator). (line 11, file "move")
Now i edited the 11. line as follows
DriveApp.dest_folder.addFile(file);
and the error message changes another time...
TypeError: Impossible to call the method "addFile" of undefined. (line 11, file "move")
Thanks to Hassan too, i am studying the examples he suggested.
But if someone would give further help... I thank in advance.
The problem is that the DriveApp Api doesn't have any methods to return single File. So you have to pass by the FileIterator.
First you don't have to put parameters in function moveFiles(source_folder, dest_folder), source_folder and dest_folder are defined inside the function. But I think you did this mistake du to the code you find on internet :)
Moreover, there is some wrong advice here: when you call DriveApp.getFolderById(), the API will return you a Folder. So you don't need to call DriveApp on this var anymore (for example DriveApp.dest_folder.addFile(file); is a bad call because the method addFile() is for Folder type, and dest_folder is already a Folder.
So you could try this, it works for me:
source_folder= DriveApp.getFolderById('YourFolderID1')
dest_folder=DriveApp.getFolderById('YourFolderID2')
var files = source_folder.getFilesByName("YourFileName").next();
dest_folder.addFile(files);
source_folder.removeFile(files);
I hope it helped you :)
I have this stupid problem with Yii where my local dev caches css and js files. When I try edit the file, it doesn't show up the changes, but the fire does get corrupted and breaks everything. This happens for some indiscriminate amount of time and then it fixes itself.
My Yii config is like this for the assetManager:
$config['components']['assetManager']['forceCopy'] = true;
$config['components']['assetManager']['appendTimestamp'] = true;
$config['components']['assetManager']['linkAssets'] = true;
As you can see below, the JS file just ends after making a small colour change to one of the mouse over fields.
The timestamp doesn't seem to be appended to the JS file when including it like all the other resources.
<script src="/custom/infobox.js?v=1427807792"></script>
<script src="/js/neighbourhoods-map.js"></script>
<script src="/js/search-block.js?v=1423510537"></script>
The file is included by calling registerJsFile() in the view file.
$this->registerJsFile('/js/neighbourhoods-map.js', [
'depends' => ['\app\assets\MapsAsset'],
'position' => View::POS_END]
);
I changed the above to include a timestamp, but the problem is still happening.
$this->registerJsFile('/js/neighbourhoods-map.js?v='.time(), [
'depends' => ['\app\assets\MapsAsset'],
'position' => View::POS_END]
);
This is soooooo frustrating to deal with. Can anyone shed some light on what the issue is here?
I encountered this issue while I was using Vagrant with nginx.
The solution was to just turn off sendfile directive from nginx configuration.
sendfile off;
I would like to change (or add if it doesn't exist) to a PDF file with multiple pages the setting that will force the PDF to be opened in two page mode (PageLayout : TwoPageLeft for example).
I tried with that kind of JavaScript (given with Enfocus FullSwitch as example) :
if(($error == null) && ($doc != null))
{
try
{
$outfile = $outfolder + '/' + $filename + ".pdf";
$doc.layout = "TwoPageLeft";
$doc.saveAs( {cPath : $outfile, bCopy : true});
$outfiles.push($outfile);
}
catch(theError)
{
$error = theError;
$doc.closeDoc( {bNoSave : true} );
}
}
But it doesn't work as I would like (it will be opened with Acrobat Pro and saved as a new file without including the setting about the layout).
Does anyone can help me to correct that code to let JS open the PDF file, set the layout inside the PDF datas and save it out?
The readable information inside the PDF file should looks like this:
PageLayout/TwoPageLeft/Type/Catalog/ViewerPreferences
For information, I'm using FullSwitch (Enfocus) to handle files in a workflow, with Acrobat Pro, and at this time, it's only saving the file without adding the setting.
I can't find myself the answer over all the Web I searched recently, so I askā¦
Thanks in advance!
I think you copied the "this.layout = ..." line out of the Acrobat JavaScript reference documentation, correct?
When you write a JavaScript for Switch to execute (or rather for Switch to instruct Acrobat to execute for you), you should use the "$doc" variable to refer to the document Switch is processing.
So try changing the line:
$this.layout = "TwoColumnLeft";
to
$doc.layout = "TwoColumnLeft";
As you say the rest of the code works and the document is saved without errors I assume the rest of your code is correct. The change proposed here will make the adjustment in the document you're looking for.
We can modify the document root directory path for PHP using
$_SERVER['DOCUMENT_ROOT'] = "to/some/new/directory";
//Now the "/" which represent the ^(above) path
in .htaccess we have
RewriteBase "/to/some/new/directory"
Now, I need to modify the root directory path to use in javascript. How to do it?
Currently, I am declaring a variable containing static path to the my personalized root directory and using it as
var root = "../to/new/path";
document.location = root+"/somepage.php";
Scenario
I think i should tell a little bit about the scenario, for you guys to catch my idea
Default Web Root Directory
http_docs/
inside it contain a main folder
http_docs/application <-- contains the actual application
http_docs/js <-- contains the script
http_docs/index.html
Now, the application also contains ajax feature for updating, editing, loading new content, or other resources, which if accessed at "/" will represent at /some/path/i/called not /application/some/path/i/called,
To come around this problem
I can define a static variable like
var root = "application/";
and use it somewhere like
$.post(....., function(data) { $(body).append("<img src='"+root+"resources/img1.jpg"); });
But for a single use, defining the path as static, might not be a big deal, but, when the application grows, and certain modification would cause me to change all the paths i give in the js part. I thought, it would be sensible, just like, I do it in PHP, using <img src="/resources/img1.jpg" />
I tried my best to explain this question, if still is not understandable, please community, lets help them understand. I welcome you to edit my question.
EDITED: Trying to answer the updated question
Assuming the JavaScript is called included from the index.html file, if you insert a img tag and use relative urls, they will be relative to the path of the index file. So <img src='application/resources/img1.jpg'> would work just fine. If the script should work for several sublevels (e.g. if the page "application/etc/etc2/somePage.html" needs images from "application/resources/")it may be easier to use absolute urls, and you could include a javascript block on every page generated by php that holds the absolute url to the "root" of the application, like:
<!-- included by php in all html pages, e.g. in defautlHeadter.php -->
<script type="text/javascript">
var rootUrl = "<?= getTheRootUrl() ?>";
</script>
Where getTheRootUrl() is a method or server variable that gives the root url you need. If the url is translated/remapped (by apache etc. outside of what is visible to php) you may need to hardcode the root url in the php method but at least it will be only one file to change if you ever change the root directory.
Then you can use the root url to specify absolute paths anywhere in the application/website using rootUrl + "/some/relative/path" in anywhere in the application.
I once made something like this, to set
window.app_absolute = '<?php echo GetRelativePath(dirname(__FILE__)); ?>'
I also use something like this
static function GetRelativePath($path)
{
$dr = $_SERVER['DOCUMENT_ROOT']; //Probably Apache situated
if (empty($dr)) //Probably IIS situated
{
//Get the document root from the translated path.
$pt = str_replace('\\\\', '/', Server::GetVar('PATH_TRANSLATED',
Server::GetVar('ORIG_PATH_TRANSLATED')));
$dr = substr($pt, 0, -strlen(Server::GetVar('SCRIPT_NAME')));
}
$dr = str_replace('\\\\', '/', $dr);
return substr(str_replace('\\', '/', str_replace('\\\\', '/', $path)), strlen($dr));
}
... Something along those lines, hacked up for demonstration purposes.
is there a method in JavaScript by which I can find out the path/uri of the executing script.
For example:
index.html includes a JavaScript file stuff.js and since stuff.js file depends on ./commons.js, it wants to include it too in the page. Problem is that stuff.js only knows the relative path of ./commons.js from itself and has no clue of full url/path.
index.html includes stuff.js file as <script src="http://example.net/js/stuff.js?key=value" /> and stuff.js file wants to read the value of key. How to?
UPDATE: Is there any standard method to do this? Even in draft status? (Which I can figure out by answers, that answer is "no". Thanks to all for answering).
This should give you the full path to the current script (might not work if loaded on request etc.)
var scripts = document.getElementsByTagName("script");
var thisScript = scripts[scripts.length-1];
var thisScriptsSrc = thisScript.src;
If your script knows that it's called "stuff.js", then it can look at all the script tags in the DOM.
var scripts = document.getElementsByTagName('script');
and then it can look at the "src" attributes for its name. Kind-of a hack, however, and to me it seems like something you should really work out server-side.
script.aculo.us (source) solves a similar problem. here is the relevant code
var js = /scriptaculous\.js(\?.*)?$/;
$$('script[src]').findAll(function(s) {
return s.src.match(js);
}).each(function(s) {
var path = s.src.replace(js, ''),
includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
(some parts of this like .each require prototype)