Stop Magento "fixing" html in static blocks - magento

Does anyone know if there's some way to stop Magento "fixing" html that's added via static blocks?
For example, if I wanted to have a space within an existing menu for adding static blocks to, I wouldn't want to use a full < ul > list as it already exists, so I'd just want some additional < li > tags within the block.
However, Magento very helpfully decides to always add in the "missing" < ul > tags for you. Rather annoying.
I've tried tracing this back myself but just can't find where it's happening. I think it could be TinyMce related, as the fixing happens if you hide/show the editor, without a page refresh. I tried changing different instances I found of cleanup:1 to cleanup:0 but none of them so far worked.
Any ideas?

It's not magento that is doing this cleanup but the wysiwyg editor : tiny_mce
You can desactivate this behavior by adding :
cleanup : false
in the js config file (js/mage/adminhtml/wysiwyg/tiny_mce/setup.js)
But this is totally not recommended as it can break all of your pages is an HTML bug is injected in a block or page and you don't have any other HTML tidier on your project ...

Have a look at the tinymce configuration parameter valid_elements and valid_children.
You can define li-tags as valid elements there and define that li-tags may be childs to other thml nodes.

You can also add
valid_elements: '*[*]',
to js/mage/adminhtml/wysiwyg/tiny_mce/setup.js to allow everything.

Related

Magento change space between main navigation links

This should be easy, but I'm not getting any useful results.
www.wilfrednewman.com
I'm trying to edit the menu and keep it on one line. Either forced one line or edit the spacing on my own.
I changed a bunch of margin/padding settings for the ul(got the ul name from top.phtml, then changed skin/frontend/default/blanco/css/menu1.css, but it isn't changing anything.
Using blanco theme. Any ideas to get me started?
Thanks!
Edit: Had to change the name to 'STORE' so it would show up on the same line for the time being. But if I change it to Online Store, instead of pushing the menu items closer together it defaults to two lines!
It looks like you just need #nav > li{padding:8px 15px;} in menu1.css. Change the 15px value up or down to tune the spacing.
If it isn't making any difference check that the CSS file is not cached anywhere (from Magento back-end right through to your browser).

how to disable tag validation in ckeditor?

CKeditor apparently automatically creates matching end tags when you enter a start tag. Is there a way to turn this behavior off?
I have a situation where I am creating two blocks of text in an admin program using CKeditor, then I'm using these to paint a page with the first block, some static content, and then the second block. Now I've got a case where I want to wrap the static content in a table. I was thinking, No problem, I'll just put the <table> tag in the first block and the </table> tag in the second block, and the static content will be inside the table. But no, CKeditor insists on closing the table tag in the first block.
In general, I can go to source mode and enter HTML directly, but CKeditor then decides to reformat my tagging. This seems to rather defeat the purpose of having a source mode. (I hate it when I tell the computer what I want and it tells me, No, you're wrong, I know better than you what you want!)
CKEditor produces valid HTML. Valid HTML has to include both - start and end tags. There's no way to change this behaviour without hacking editor. Note that even if you'll force editor to produce content without one of these tags it will then try to fix this and won't do this as you expect. E.g. load:
<p>foo</p></td></tr></table>
And you'll completely loose this table so only regexp based fix on data loading could help. In the opposite case:
<table><tr><td><p>foo</p>
You'll end up with paragraph wrapped with table, so it's better. But what if someone would remove this table from editor contents?
Therefore you should do this integration outside editor - prepend table to contents of one editor and append to contents of second one. You simply cannot force editor to work on partial HTML.

Cannot make Scrollspy Bootstrap work

I am designing a single page website and want the fixed nav links to change colour whenever the user scrolls to the specified location. Seems pretty easy to do, I thought it was pretty easy to do, but I am having problems making it work.
I only downloaded the Scrollspy JS Plugin, as I am not using the Twitter Bootstrap CSS. I just require the Scrollspy Plugin.
Could you check this jsFiddle and provide some guidance? I have already checked out the documentation here, but I've had no luck. Any help is greatly appreciated :)
http://jsfiddle.net/xjTpk/28/
Ignoring the serious issues with your use of JSFiddle1, and the typographic errors2, the principle things wrong are
You need the .nav class on the <ul> in the navbar, and
The #welcome is not an existing element, causing a JS error.
Here's a fixed demo:
JSFiddle
Oh, and you don't need both data-api and js to initialize the plugin; choose one.
1 Loading Bootstrap 2.0.2 + 2.0.4 at the same time; trying to include a <body> in the html panel
2 Using upperCamelCase on a function that doesn't need it: scrollSpy();
Key thing you are missing is you have to have a "nav" class on the ul element (or some other parent element) as that is used in the scrollspy code as part of a selector.
I couldn't get yours to work for some reason but here is a simplified example:
http://jsfiddle.net/UWzeD/5/
Your ul needs a nav class, but most important for scrollspy to work properly is that your target needs to be one level about the ul. Otherwise I've found that scrollspy doesn't work.

Adding pager to custom collection block

Sorry for the redundancy of this question, but none of the example and solutions have worked for me. I have a custom module that extends Mage_Catalog_Block_Product_List. The only function in it is _getProductCollection which sets the product collection based on which attribute you want to filter on. It's pretty simple and there are no layout updates involved. I put the block on the page by putting the following into the Content section of a CMS page:
{{block type="vps_featured/list" name="vps_featured_list" attribute_name="best_sellers" template="catalog/product/sale_list.phtml"}}
Since it extends Mage_Catalog_Block_Product_List, I get all the bells and whistles for a product list page, including the toolbar. However, the pager isn't there. I've tried a number of different suggestions but none have helped.
I looked in Toolbar.php in the core code and found where it calls getPagerHtml. I put some debug statements in there and determined that it calls this function when putting my custom block on the page but $this->getChild('product_list_toolbar_pager') is not returning the block, presumably because it isn't there. I tried adding the block using a layout update XML file and adding the <frontend><layout><updates>... tags to my config, but this didn't seem to do anything.
I have Alan Storm's CommerceBug extension, so I pulled that up and exported the layout XML for the page. It doesn't contain any toolbar block at all, despite the fact that the toolbar is on the page and only the pager isn't working. If I do the same thing on a category landing page, it shows the toolbar block in the layout xml. So I've clearly missed something here, but I'm at a loss as to what. I hope someone can help :)
Brian
As it turns out, the solution found HERE works great! You have to add the block using the Layout Update XML rather than adding it in the content section. I still don't quite understand why, but it works.
There already was question about Getting pager to show on magento list

changing navigation in magento dynamically

I want to know that can i change the navigation menu dynamically,i am having two tabs on the basis of which i want to render the navigation menu.How can it be done
Thanks in advance
For usability reasons, the global navigation generally shouldn't change. Users will expect to see the same options available to them and will get confused (and leave) if they aren't.
Could you explain the requirement more?
EDIT:
Usability issues aside, try adding all necessary items to the top nav, then use Javascript to toggle between tabs. If you don't want to change the navigation PHTML files to add IDs to them, you can use the existing classes to target which nav items to show and which to hide.
Since Magento stores cannot function without JS anyway, you should be pretty safe with that solution. Preferably, you can change the top nav's template (I believe app/design/frontend/base/default/template/page/template/links.phtml in 1.4) to use IDs for those LIs as well, in which case you can target those instead.
Thanks,
Joe

Resources