How can I insert XML example code inside a Joomla article? - php

I'm building a site in Joomla 2.5 that covers topics related to programming.
I have tried various plugins and I had no problem to insert java, javascript and php code inside my articles (the classic view with indented line number)
The problem arises when I try to insert XML.
Currently I'm using the plugin Code HighLight (but I found the same thing with other plugins).
To insert the XML code in my article I have to do so in my article:
{code class="brush: xml;"}CODE HERE{/code}
The problem is that, if I insert Java or Js or php code I have no problem, but if I try to insert XML code in this way in my article it appears bad (parts missing)
I also tried to plug it directly into HTML (by pressing the button HTML editor TinyMCE) but, once inserted, when I come back to the WYSIWING editor, this problem occurs again.
In the plugin instruction I can read:
BEWARE of your visual editor (JCE or JCK for example), it can place tags in your code, after this code became invalid!
I use TinyMCE as editor (it is always a WYSIWYG editor) and seems that this is the problem infact if I disable the graphical editor (inside the Joomla global configuration setting the editor as void) or if I choose the CodeMirror editor (that it is a simple HTML editor, not a WYSIWING editor) if I insert the XML code in te previus way...work well !!!
The problem is that I need a graphical editor (to set the styile of my articles text) and at the same time I need to insert XML code snippet inside my articles...
I have observed that behavior using many code snippet plugin...the problem is not a plugin problem but I think it is related to the WYSIWING editor that seems to insert it's tag inside the XML code or at least makes it dirty (eliminates parts and inserts some tags like )
What can I do to have XML code snippet in my articles and at the same time have a WYSIWING editor? (if the problem is TinyMCE I can also try some other WYSIWING editor...)
Thanks
Andrea

You can give extension for code display a try.
Another solution I read about was
1) activate Content - Code Highlighter (GeSHi)
2) generate your code here
3) C&P the generated code in the WYSIWYG editor

You can do either one or the other...you cannot do both.
My suggestion is this: do the WYSIWYG part of the page...toggle the WYSIWYG editor off...then insert your xml...and NEVER go back to that page with the WYSIWYG editor on again.
I have had the same issues inserting xml in my website.
If you have logged out of joomla and log back in...the default is the WYSIWYG editor.
So if you open an article/module/plugin and it opens in WYSIWYG, it clears the xml that you have inserted into the page. Simply toggle the WYSIWYG editor so that it is off...then CLOSE the article (DO NOT SAVE & CLOSE)...just close. Then open the article/module/plugin again...it should be the html editor only...and code away.
I hope this helps.

Related

Some elements missing / changed when trying to change from html to php

I'm asking for help for those who have experience in changing an html file to a php file. I've tried everything I know (and I'm not the smartest I admit) but I don't understand why the following is happening.
Currently: When viewing on mobile, the mobile menu button has gone, the toggle switch which changed prices from monthly to annually, tabs which displayed different content has gone. As a result:
If there was a toggle, both the toggle results are displayed one above the other
If there was a tab, each tab element is displayed underneath the other
The mobile menu button has gone completely
Background:
I purchased an HTML template but it turns out the seller didn't want to help. I wanted to split and convert the page into a php page as I wanted a single header/footer file which I could import. As you will see (if you check the repo) the header.php and footer.php file is getting imported into the page php file.
I created the pages by first:
Renaming the original html file to a php file
Cut the header and footer and import them back into the page php file
That's all I have done. It seemed to work, however another check (after cache cleared) I noticed the issues.
The link to the site page im referring to is:
https://blueboxhosting.co.uk/products-cloud-hosting
But if you look at any of the pages, you'll see errors on all of them now where they're should have been controls (eg toggles, mobile menu, tabs etc)
I've created a snipped so you can view the code and HOPEFULLY spot where I've been a moron:
https://bitbucket.org/snippets/bbhostinguk/7e5qxp
Any help with this would be amazing as I just can't figure it out.
Start by running the HTML generated by PHP through a validator, e.g. https://validator.w3.org/
Your code has numerous stray tags which may or may not affect the rendering.
Another tip is to comment off everything and then uncomment section by section and check when things start to break.

wordpress page.php styling and markup

I have a couple of questions related to building a custom theme with Wordpress.
1) If the website is made up of pages, I can use page .php to run the LOOP and retrieve content. In this case, is it OK to paste the content (of each page) using the backend of word press - I.e. paste all content and HTML markup into the 'text; . Is this a reliable way to enter content and accompanying markup into the database?
I guess the advantage is that users will then be able to edit the content themselves using the visual Tab.
Many thanks,
P
Well this not a recommended way to do it, but yes the editor is there for the same purpose. I wont be using it this way, because in my experience wordpress editor often acts weird with html. By default auto paragraphs are enabled, so everything gets in its own paragraph, even if you disable auto paragraph it still has some issues. For instance if you add html in the text tab, and then goto visual tab and switch back to html, and save the same html, this time it would be styled differently. Secondly its also not good to allow users to add html from a security POV and you cant guarentee the consitency of the website.
I would recommend using custom fields instead and fetch these custom fields in the through your theme files.

Writing <code> snippets with TinyMCE Editor and render using CodeMirror code highlighter

Please have a look at the following URL
http://sribasu.com/blog/2_programming-tutorials/5_getting-value-of-radio-button-and-checkbox-using-jquery-cross-browser.html (fortunately I managed to show the codes properly on this page now, by inserting \n from DB)
I'm using TinyMCE Editor to create content of my web pages. Although, I'm struggling with a strange issue. My Code Highlighter plugin CodeMirror expects newline (\n) character as line separator, instead of tags. But, TinyMCE editor will never let me insert \n as newline. How can I create a HTML content (in my case, my blog post) with TinyMCE editor, so that it renders all the [Enter] key press as \n instead of tag, when I'm writing within tag?
I don't know much about CodeMirror, but is it possible to modify the tinymce code BEFORE you give it to codeMirror? In this case you would have alook at the end of paragraphs and insert a \n there.

Formatting error while publishing the blog from Microsoft Word

I posted this question on wodpress.stackexchange.com without getting any response.
I realized it could be a programming issue in PHP.
I am trying to publish a blog post into wordpress based website from Microsoft Live Writer. Here is the sample text that I added in Microsoft which I published as well.
" Temporary Blog Post
I am adding a temporary blog post here
Let’s see how it goes
Thanks"
However, when I published the post, this is how it looked
/pI am adding a temporary blog post here
/ppLet’s see how it goes
/ppThanks
Notice the \pp tags which is getting added in text.
Any idea the reason behind the formatting error? I thought when you publish from Microsoft word or Microsoft Live Writer, it should look the same as in the Microsoft Word/Live Writer.
Update : I am having the same error when I am posting from other publishing software like Windows Live Writer etc.
By default, WordPress automatically inserts paragraph tags all over the place when displaying ‘the_content’ – this often gets in the way when you’re trying to space out your text, and also creates validation issues (inserting implicit p tag). If you want to strip the automatically inserted paragraph tags from your content, simply insert this line in your template file above ‘the_content’ tag:
<?php remove_filter (‘the_content’, ‘wpautop’); ?>
OR
Use the cleanup_shortcode_fix() function that should help with your issue.
Check out below links for more information,
Remove the p tags auto wrap
Removing <p> and <br/> tags in WordPress posts
wordpress-wrapping-shortcodes-with-p-tags
Disable wpautop
may this help you.
I found this article which seems to deal with the problem, although its very old so my initial question would be what version of wordpress are you using?
To stop wordpress adding the tags simply add:
remove_filter ('the_content', 'wpautop');
To the top of your functions.php
On a side note I don't use the auto publish features of word, I find cut and pasting a document into Ultimate TinyMCE is the best way to keep your formatting, but thats just my opinion.
Paste it in the notepad first then recopy it from the notepad before pasting it to the wordpress editor.
That should do it.
OR if you dont want to use notepad,
There's a button in the editor that allows you to paste content directly from Word. This removes the special formatting Word uses to lay content out on the page and will make things work well on your site. (The button is in the "Kitchen Sink" on the Visual editor and is circled in the image below.) alt text

DB content not coming into tinyMCE textarea

My tinyMCE editor is showing up just fine, but in the form I have a select box and according to what you choose, the textarea is filled with content accordingly.
Like if I choose PHP, then the description for PHP comes into the textarea. It works without tinyMCE, but when I add tinyMCE, nothing shows up in the textarea.
TinyMCE does not display the content of the textarea in real-time. It reads the content on start, and saves it at the end of the work. All the edit work takes place in an iframe element, created on the fly by Tiny. If you update the textarea, you must ask TinyMCE to refresh itself.
In a few minutes I will look up the exact method for you. (It was long time ago when I was using TinyMCE, so I forgot the method names.)
[few minutes have passed..]
Look at the documentation: http://www.tinymce.com/wiki.php/How-to_load/save_with_Ajax_in_TinyMCE
You just need to call setContent method on the TinyMCE editor, instead of (or in addition to) setting the new text in the textarea.
with tiny mce sometimes it dependes the plugins that you in the Init.
Try Removing all the plugins and add one by one and see if this helps you in finding a better solution for this.
Some plugins like the media can strip and not allow tags in the text area, so the textarea is empty if tiny mce doens't allow that tags, or add valid_elemens:'[]' and try if it shows something.
Good luck

Categories