Issue using ckeditor 4.5.9 with php - php

been looking for and trying everything to get this to work but just cannot seem to get it to do so.
Had previous code from some years ago that included an older version of ckeditor. It works fine but wanted to get a newer version going on the site and downloaded the latest (4.5.9).
The older version included the files ckeditor_php4.php, ckeditor_php5.php and ckeditor.php while the newer version has the file ckeditor.js.
Using the sample code given I was able to get this to work with no issues as a straight HTML page but when trying to include it into my PHP code nothing displays?
<script src='lib/ckeditor-new/ckeditor.js'></script>
<form>
<textarea name='editor1' id='editor1' rows='10' cols='80'>
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
CKEDITOR.replace( 'editor1' );
</script>
</form>
Anything I'm missing here? I've tried including the separate HTML file (that works) into the PHP code, dropping out of PHP and back in after the above code, etc. All to no avail.
Thanks!
Edit:
This seems to be working to load the new version in PHP... hope this helps someone in the future or maybe someone will point out a better solution? Thanks for the help!
$ckeditor = new CKEditor();
$ckeditor->basePath = 'lib/ckeditor-new/';
//$ckeditor->config['height'] = 100;
$ckeditor->editor('editor1');

Related

Php inside wordpress pages stopped working after update

I have a wordpress website and it runs with some php code inside the pages. After I updated it stopped working and when I try to edit the code again, it changes the <?php to <!--?php not allowing it to run anymore.
I tested with a simple code like:
<?php
echo "Hello World"
?>
And it's not working after the update.
Is there any easy solution to this? Thanks.
I solved the issue using 2 plugins to insert php and javascript code into the page. Thanks a lot #idlab and #arifullslam for the help!

Including file in Joomla - what is the difference?

Can anyone tell me what is the difference between including the js script file in the following two ways,
I made this inside system plugin in joomla and included the js file inside "onAfterInitialise" function.
1)
<script type="text/javascript" src="<?php echo JURI::base(); ?>/plugins/system/test/script/script.js"></script>
This works fine and including the js file correctly, But when I logged-in from the backend the font size from userlisting and listing from other extensions gets enlarged.This is not the issue in my js script.
2)
$document->addScript(JURI::root(). "plugins/system/test/script/script.js");
This works fine without any issues.
Can anyone explain what goes behind this.
Using the second method is simply using Joomla coding standards and adds your script in between the <head> tags.
There isn't much difference except for where the script gets imported on the page.
JURI::base() and JURI::root() are both the same. They both define the root folder for your Joomla site. If you are unsure which one to use, I would recommend using method 2, as it's always good to get used to Joomla coding standards.
You can see the source of addScript() :) Basicly, if you use first method, your srcipt will be added in the same place you wrote the code. Second method will add link to a inner table in $document and will be 'rendered' at the
<head></head>
section at the end of page processing.

PHP in Netbeans: Is there shortcut to generate the <?php ?> tags

I've just started using Netbeans (7.1.2, php version) to work on a PHP project. Netbeans is really great for editing long stretches of PHP Code.
But in my view files where HTML is mixed up with short bits of PHP I am getting really tired of manually typing:
<?php ?>
In Dreamweaver you just press a button to create these tags, but in Netbeans I can't find anything like a keyboard shortcut. Surely there must be one. Does anybody know what it is?
In Netbeans I had gone to Tools -> Options -> Editor -> Code Templates and looked through all abbreviations for the PHP language. There were lots and lots of abbreviations for pieces of PHP. But the <?php ?> tags weren't there.
After typing out my question it occurred to me that the place such abbreviations would be was for the HTML language instead of PHP. I looked there and there weren't any code templates at all. But it was simple to add one of my own (abbreviation: 'p', expanded text '<?php ?>').
Now when the cursor's in the middle of some HTML, I type p[TAB] and my tags appear!
Update
Thanks to link from #chris in comment above I can change expanded text to <?php echo ${cursor} ?> and the cursor ends up where I want it.
Looked through the guide and didn't see any
http://netbeans.org/project_downloads/www/shortcuts.pdf
I don't think there is, but you can create a macro to do it yourself :)
You just have to click on Edit -> Start Macro Recording then you have to type in <?php ?> and afterwards click on Edit -> Stop Macro Recording.
There isn't one by default. The closest is typing <? and pressing ctrl+space which will suggest you <?php...
Just type php + TAB to have <?php ?> or phpe + TAB for <?php echo ?>
It's works for Netbeans 8 with default Php Package
If you want, you can change that shortcut on Tools -> Options -> Editor -> Code Templates; choose HTML on Language's select box.

Why is my PHP in articles being interpreted literally as a string instead of as PHP?

I am trying to find a way to write pure PHP in my articles with Joomla (currently using 1.5). The closest I got so far was to use a plugin called Sourcerer (see link)
The issue is that the PHP code is actually being rendered as HTML. When I write the below code via the Sourcerer editor:
<?php echo "Hello world"; ?>
This is what is being written to the article:
<span><</span>?php echo "Hello world"; ?<span>></span>
I am afraid that at some point this is going to break my PHP if I come up with more complex code. Also this makes the code hardly readable. Finally the issue with Sourcerer is that you can only insert new code, you can't edit what you previously added.
Does anybody know a way to write pure PHP into articles?
I would like to insist on the fact that it has to be within articles. I already found a way to do it in modules or components, for instance with Jumi.
I have used Sourcerer a couple of times and it does allow one to insert PHP snippets into articles without issues. If your php is being rendered as html, it sounds like the php isn't getting parsed as php - first thing is to make sure that the sourcerer plugin is indeed enabled so it can allow your php scripts to get parsed. (check plugin enabled status here: extensions->plugin manager->sourcerer).
Also, use the sourcerer ("Insert Code") button at the bottom of your WYSIWYG editor when adding your PHP scripts - it keeps the formatting/syntax highlighting and ensures that it is escaped properly with the {source} {/source} tags.
An update, I have the same issue with joomla 3.x, sourcerer, I have tried tinymice, JCKEdidor and JCEEditor. I have now given up with this method.
To insert php code into an article I have used a php include file and all the html is echoed inside this php include file. The php file is then referenced from within the Article Editor.
Those more proficient than me with joomla will no doubt do this correctly using a module or the like.
You can try another plugin called Direct PHP. It's nice and simple to use. Just download and install it and make sure it is enable. After this start writing your php code in joomla article.
Example:
<?php
echo "Hello World!";
?>
it supports all most every PHP functions and you can filter the functions what you don't need it from its settings.
Here is the link for the download.
Download & import plugin sourcerer https://extensions.joomla.org/extension/sourcerer/
{source} [[?php echo "Hello world"; ?]] {/source}
use this. It fine for me.

PHP embedding in HTML problem

I'm having problems embedding php inside an html file.
I first ran in to this problem when I was trying to 'include' a php file inside tags, and thought it was related to css formatting, or something. But now I've broken this down into the simplest php and html possible, with an example from a book that should work, and I'm still getting this problem. Here's the html sample that doesn't work:
<HEAD>
<TITLE>PHP inside HTML tester</TITLE>
</HEAD>
<BODY>
<?php
echo "Hello World";
?>
</BODY>
</HTML>
I'm expecting 'Hello World' to show up in my browsers, but nothing is displayed. When I try to 'view source', I see exactly the text above. I figure that after all the examples of this I've tried, the code is ok, but something is keeping what's inside the from being recognized.
Any suggestions? And thanks for helping me out with what's probably a dumb question.
There is something wrong with your PHP installation. The web server isn't passing requests for PHP pages off to the PHP interpreter.
If you did indeed save the file as an .html file, then your PHP code will never execute because most web servers have their handler mappings set to route only PHP (.php, .phtml, or .inc extensions) files to the PHP interpreter.
Looks like your server is not able to handle php or your server does not know how to handle the file type with - this code is in.

Categories