CKEditor ShowProtected moves handlebars code - ckeditor

If you are using CKEditor with handlebars code, you can mark handlebars code as protected using
config.protectedSource.push(/{{[/|#][\s\S]*?}}/g);
This works well but hides the handlebars code in the main WYSIWYG editor.
The showprotected plugin (https://ckeditor.com/cke4/addon/showprotected) can then be used to display an icon whenever there is handlebars code.
But, if you have code like
<ul>
{{#each Books}}
<li>{{Title}}</li>
{{/each}}
</ul>
the CKEditor changes the HTML into this:
{{#each Books}}{{/each}}
<ul>
<li>{{Title}}</li>
</ul>
I have set
config.allowedContent = true;
but this does not help. Any ideas?

The problem is the CKEditor DTD which controls how HTML elements are allowed to be nested.
When the CKEditor displays in WYSIWYG mode, the showprotected plugin displays a small icon instead of the handlebars code. This effectively creates the following html:
<ul>
<img class='cke_protected'..../>
<li>{{Title}}</li>
<img class='cke_protected'..../>
</ul>
Images are not allowed to be placed directly inside UL tags and so CKEditor rearranges it into
<img class='cke_protected'..../><img class='cke_protected'..../>
<ul>
<li>{{Title}}</li>
</ul>
You can fix this problem by telling the DTD that image tags are allowed inside the UL tags
CKEDITOR.dtd['ul']['img'] = true;

Related

Prevent TinyMce in Joomla to modify inserted html code

I'm using joomla (last version) and just added this template in tinymce :
<a href="/test" class="darkimagediv">
<img src="/images/logo2.png">
<div>
<div>
Test
</div>
</div>
</a>
It displays fine in the popup dialog just before inserting, but when I do it is inserted like that:
<p><a class="darkimagediv" href="test"> <img src="images/logo2.png" /></a></p>
<div>
<div>Test</div>
</div>
<p> </p>
Which is very bad.
I'm superuser and text filtering is off in the global configuration. I don't find any cleanup option in tinymce, so I need to find which script modify my html but I don't even know if I must search tinymce or joomla itself.
If you are pasting code Don't use a rich text editor.
The editor is doing what it is supposed to and correcting your incorrect markup. Either way, if you want to insert markup, incorrect or not, then don't use a rich text editor.

Magento and Fancybox - Block CMS loading inline

Situation:
We have several small icons on our Magento Product page. After clicking one, a fancybox opens with content from a CMS Block.
Problem:
It seems that fancybox isn't "compiling" the block content properly. The magento variables aren't converted into "readable" code.
Here's the code:
http://pastebin.com/24qyYinD
Output:
<div id="data-winddicht">
<div class`enter code here`="technologie_lightbox">
<div class="image"><img src="{{media url="wysiwyg/Technology/Wasserdicht.png"}}" alt="" /></div>
<p>LOREM TEST</p>
</div>
{{media url=""}} wasn't converted into html code.
any hints?
Solution is here:
magentocommerce.com/boards/viewthread/210263/#t399724
Thanks to Kalpesh Mehta
Code:
From
echo $block->getContent();
to
echo $this->helper('cms')->getBlockTemplateProcessor()->filter($block->getContent());

place span tag between anchor tag using Action Link Helper

I got website templates and using it for my website. I am new to asp.net mvc 3 and razor. It is very difficult to modify html tag using html helper. How can I place the span tag between anchor tag using ActionLink Helper. I have used razor and html helper for producing link.
I want to produce following tags:
<li><span class="glyph logout"></span> Logout</li>
I have try this
<li>#Html.ActionLink("<span class='glyph logout'></span> Log out", "LogOff", "Account") </li>
I am confuse how to do that. It is not the correct way that produces span tag as string. How can I produce correct tags.
What you want to use is #Url.Action to create the URL while having your custom HTML.
<li>
<a href="#Url.Action("LogOff","Account")" title="Logout">
<span class="glyph logout"></span> Logout
</a>
</li>
This way you have control over the URL and be able to add your own custom HTML. #Html.ActionLink doesn't allow you to add custom HTML inside the tags natively.
If you need to customize, what's inside your anchor tag, you should use the Html.Action method instead of the Html.ActionLink
<li>
<a href="#Html.Action("LogOff", "Account")" title="Logout">
<span class="glyph logout"></span> Log
</a>
</li>

Starting ColorBox slideshow using a link

I would like to have a page with both an image gallery and a slideshow. The slideshow should be started when I click the link, the normal ColorBox should be used when I click one of the images.
What I do now is group all the images with a rel. For the slideshow link I use the following code:
<a rel="slideshow" href="#">Display slideshow</a>
In the configuration for colorbox I define rel as the rel I use for the images. This works almost, the problem I have with this is that I get an extra empty page at the beginning.
How can I start a slideshow of an image gallery, using a text link?
I searched for how to do this for a long time, and finally found the answer on - where else - the F.A.Q for Colorbox. The example is worded a bit differently though so it wasn't as easy to find as you might think. Especially if you're asking question in these terms, like I was.
<div style="display:none;"> <!-- optionally hide this div -->
<a rel="gallery" href="/slideshow/one.jpg">Caption 1</a>
<a rel="gallery" href="/slideshow/two.jpg">Caption 2</a>
<a rel="gallery" href="/slideshow/three.jpg">Caption 3</a>
</div>
<a id="openGallery" href="#">Display slideshow</a>
<script type="text/javascript">
var $gallery = $("a[rel=gallery]").colorbox();
$("a#openGallery").click(function(e){
e.preventDefault();
$gallery.eq(0).click();
});
</script>
http://jacklmoore.com/colorbox/faq/#faq-click

JQ Touch and AJAX

I am a little new to this so apologies if I am a little vaugue but I will do my best.
I am attempting to create an iphone friendly version of a site using JQtouch. I understand that normally this would be done all in one HTML file with pages seperated by DIV's. However, I am wanting to load the content from exisitng pages of a website.
The next part to the problem is that my iphone.html page does not sit in the same directory as my current website, so the normal behaviour of JQtouch doesnt seem to work.
So far I have set up a page as follows:
<div id="home">
<div class="toolbar">
<h1>Title</h1></div>
<ul class="rounded">
<li class="arrow"> HOME</li>
<li class="arrow"> ABOUT US</li>
<li class="arrow"> GNWR</li>
<li class="arrow"> GNER</li>
<li class="arrow"> NEWS</li>
<li class="arrow"> FAQS</li>
<li class="arrow"> CONTACT</li>
</ul>
</div>
<div id="content"></div>
<div id="about"></div>
<div id="journal"></div>
<div id="faqs"></div>
<div id="contact"></div>
</body>
</html>
I then have :
<script>
$(document).ready(function(){
$('#content').load('http://www.mysite.co.uk' + ' #content');
$('#about').load('http://www.mysite.co.uk/about' + ' #content');
}
</script>
This loads the content I am after and the page animations work fine. The only problem is that a couple of links exist in the content I am loading and when clicked they obviously dont work.
Is there a way I can check the href of a link when clicked and if it points to www.mysite.co.uk/about change it to point to #about and force it to navigate there?
Hope this makes sense if you need more info let me know.
Regards
Chris.
You are asking quite a few questions inside a single question... You should really break them up into several questions. It's easier for people to answer. Anyways, I'll give it a shot.
First of all, you don't have to have all contents in one html; you can load contents via AJAX. See the AJAX > "GET Example" in this demo, as well as the page content loaded via AJAX.
As far as I know, the pages you want to load do not have to be in the same directory structure. The pages you want to load via AJAX need to contain a valid jQTouch page, i.e. the whole page is enclosed in a <div>.
Is there a way I can check the href of
a link when clicked and if it points
to www.mysite.co.uk/about change it to
point to #about and force it to
navigate there?
If I understand you correctly, you essentially want to replace all the links to www.mysite.co.uk/about with #about. This has to be done with jQuery:
$('a[href="http://www.mysite.co.uk/about"]').attr('href', '#about');
You may want to do that when each page loads:
$(document).ready(function(e){
$('body>div').bind('pageAnimationEnd', function(event, info){
$('a[href="http://www.mysite.co.uk/about"]').attr('href', '#about');
})
});

Resources