You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

Please create a new Ticket and we will get back to you as soon as we can.

#99925 How to fill in code as text ?

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by HGH on Tuesday, 14 May 2019 20:59 BST

HGH
Hi Ryan,

is there a way put put "code [html/php and others]" as text into an joomla-article?
Just like doing something with tags like "</>" here.

Background: I'm writing a tutorial an want to put code as text into it, so the user can easily copy the code.

Ryan
I have made a Joomla plugin for the highlightjs library - https://github.com/widgetfactory/wf-highlight - and a JCE plugin for adding the code highlighting in the editor - https://github.com/widgetfactory/editor-highlight

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

HGH
Hi Ryan, thanks for the links to the plugins, but I still have probs. I want to showup something like this.

<?php /*HGH*/ ?>	<div class="control-group">
<?php /*HGH*/ ?>		<div class="control-label">
<?php /*HGH*/ ?>			 <?php echo $this--->form->getLabel('custom_data'); ?>
<?php /*HGH*/ ?>		</div>
<?php /*HGH*/ ?>		<div class="controls">
<?php /*HGH*/ ?> 			<?php echo $this--->form->getInput('custom_data'); ?>
<?php /*HGH*/ ?>		</div>
<?php /*HGH*/ ?>	</div>
But the div's are always rendered. -> see here I have this in the code-view tab:

<pre><code class="html">
<?php /*HGH*/ ?>	<div class="control-group">
<?php /*HGH*/ ?>		<div class="control-label">
<?php /*HGH*/ ?>			 <?php echo $this--->form->getLabel('custom_data'); ?>
<?php /*HGH*/ ?>		</div>
<?php /*HGH*/ ?>		<div class="controls">
<?php /*HGH*/ ?> 			<?php echo $this--->form->getInput('custom_data'); ?>
<?php /*HGH*/ ?>		</div>
<?php /*HGH*/ ?>   </div>
</code></pre>
The '<?php' statement is only rendered but not executed by the php-processor.

Ryan
Ok, here is a different set of plugins, using the Prism library - https://prismjs.com/

First, install and enable the wf_prism Joomla plugin - https://github.com/widgetfactory/wf-prism - then the JCE CodeSample plugin - https://github.com/widgetfactory/jce-editor-codesample

Assign the CodeSample icon the editor toolbar.

In the editor, click on the CodeSample button to open the dialog, then paste your code into the textarea. Select the language type and click Insert.

To edit the code, click to select the code box, then click on the CodeSample button again.

To delete the code, click to select the code box and press the Delete key.

https://cdn.joomlacontenteditor.net/tmp/99925-fill-in-code-as-text.gif

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

Ryan
Also, you will need to install JCE Pro 2.7.14 Beta 4 - https://www.joomlacontenteditor.net/downloads/editor/pro/development

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

HGH
Greate, that's it. 😃
Many, many thanks for that new feature of JCE.:)