TYPO3 Menu - Different layout for specific uid - typo3

In my main menu, I need everything under a specific first level item to have a completely different layout.
In the past I have given a specific item a different wrap like this:
IFSUB = 1
IFSUB {
wrapItemAndSub.cObject = CASE
wrapItemAndSub.cObject {
key.field = uid
default = TEXT
default.value = <li>|</li>
1234 = TEXT
1234.value = <li class="mega">|</li>
}
}
But I need to do something different for level 2, 3, and 4 if they are children of uid 1234. Can I rewrite the above to say "if any pid = 1234 above this one then..."?

Wheres the problem then?
ul li a {
color: green;
}
ul li.mega li a {
color: blue; /* color for second level */
}
ul li.mega li li a {
color: pink; /* color for third level */
}
ul li.mega li li li a {
color: fuchsia; /* color for fourth level */
}

Related

Set name/label for custom links in TYPO3 RTE

I added a new link class to the TYPO3 (6.2.14) RTE like shown below
RTE {
classesAnchor {
myNewClass {
class = very-long-class additional-class
type = page
}
}
default {
proc.allowedClasses := addToList(very-long-class additional-class)
buttons {
link.properties.class.allowedClasses := addToList(very-long-class additional-class)
}
}
}
Everything works fine and the editor can choose the new link style when he selects some text in the RTE and creates a link (shown below).
My problem is, that the link name is not really understandable. Is it possible to define a name or label for the link (changing the class-name is not an option), so the "Style" field will show a more understandable name?
The names are set in "classes" of the RTE object. The value are any CSS-styles to give a hint, how it looks like.
RTE.classes {
your-class-name {
name = Your Awesome Class Name
value = margin: 2px; padding: 2px; background: #00b5dc; color: #fff; border: 1px solid #3a6674;
}
}

Generating nested lists

I'm pretty much new to typoscript. I know about wrapping but how do you generate well-formed nested lists?
Here is the code I'm using at the moment:
// Side menu with each li acting as a category
lib.subMenu.1 {
NO.allWrap=<li class="category">|</li>
// (...)
lib.subMenu {
2 < .1
// LI placed just underneath and wrapped inside a UL.
// Ideally the UL should be inside the LI described above.
2.wrap = <li><ul class="items">|</ul></li>
you need to use wrapItemAndSub for wrapping items
lib.subMenu = HMENU
lib.submenu {
1 = TMENU
1 {
wrap = <ul>|</ul>
NO.wrapItemAndSub = <li>|</li>
}
2 < .1
2.wrap = <ul class="level_2">|</ul>
}

Zend_Navigation_Container set separator

Is there a way when using Zend_Navigation to set a separator for pages?
For example, I call $this->navigation()->menu() in my view to render a navigation menu in a form of an unordered list. I would like there to be a separator between all menu items, for example |.
So, every menu item which is not last, would end with:
</a> | </li>
You can do it in CSS like this.
li:before {
content: "|";
}
li:first-child:before {
content: "";
}
li:first-child a {
margin-left: 0;
}
li a {
margin: 0 0 0 2mm;
}
The reverse logic here is for browser compatibility. IE < 9 doesn't support last-child but supports first-child.

jquery ui connected sortables: cancel, disable, destroy... nada

I have two connected sortable lists.
For the sake of my question, when I start dragging an item from #sortable1 to #sortable2, in the start event I want to cancel/ disable/ the drop in #sortable2
Nothing works?
$("#sortable1, #sortable2").sortable({
connectWith: "#sortable1, #sortable2",
start: startDrag
});
function startDrag(event, ui) {
$("#sortable2").css("opacity","0.5");
// $("#sortable2").sortable("cancel"); // goes whooooo
/* docs say:
If the sortable item is being moved from one connected sortable to another:
$(ui.sender).sortable('cancel');
will cancel the change. Useful in the 'receive' callback.
*/
// $("#sortable1").sortable("cancel"); // I only want to cancel dropping in sortable2...
// $("#sortable2").sortable("disable"); // disables only after the drop event
// $("#sortable2").sortable("destroy"); // same as "disable"
}
function stopDrag(event, ui) {
$("#sortable2").css("opacity","1.0");
// $("#sortable2").sortable("enable");
}
My JSFiddle here: http://jsfiddle.net/tunafish/m32XW/
I have found 2 more questions like mine:
jQuery sortable('disable') from start event not entirely working like expected
http://forum.jquery.com/topic/disable-a-sortable-while-dragging-with-connectedlists
No responses..
Anything appreciated!
EDIT: I also tried to overlay a div like a modal on the sortable, but can still be dragged to that way. The only thing that worked is a show/hide, but that's not an option for me.
OK here is my app; two lists of images, sortable and you can copy over from the connected list.
If an item already exists in the target it's disabled.
Hopefully useful to someone...
JSFiffle here: http://jsfiddle.net/tunafish/VBG5V/
CSS:
.page { width: 410px; padding: 20px; margin: 0 auto; background: darkgray; }
.album { list-style: none; overflow: hidden;
width: 410px; margin: 0; padding: 0; padding-top: 5px;
background: gray;
}
.listing { margin-bottom: 10px; }
.album li { float: left; outline: none;
width: 120px; height: 80px; margin: 0 0 5px 5px; padding: 5px;
background: #222222;
}
li.placeholder { background: lightgray; }
JS:
$("ul, li").disableSelection();
$(".album, .favorites").sortable({
connectWith: ".album, .favorites",
placeholder: "placeholder",
forcePlaceholderSize: true,
revert: 300,
helper: "clone",
stop: uiStop,
receive: uiReceive,
over: uiOver
});
$(".album li").mousedown(mStart);
var iSender, iTarget, iIndex, iId, iSrc, iCopy;
var overCount = 0;
/* everything starts here */
function mStart() {
// remove any remaining .copy classes
$(iSender + " li").removeClass("copy");
// set vars
if ($(this).parent().hasClass("listing")) { iSender = ".listing"; iTarget = ".favorites"; }
else { iSender = ".favorites"; iTarget = ".listing"; }
iIndex = $(this).index();
iId = $(this).attr("id");
iSrc = $(this).find("img").attr("src");
iCopy = $(iTarget + " li img[src*='" + iSrc + "']").length > 0; // boolean, true if there is allready a copy in the target list
// disable target if item is allready in there
if (iCopy) { $(iTarget).css("opacity","0.5").sortable("disable"); }
}
/* when sorting has stopped */
function uiStop(event, ui) {
// enable target
$(iTarget).css("opacity","1.0").sortable("enable");
// reset item vars
iSender = iTarget = iIndex = iId = iSrc = iCopy = undefined;
overCount = 0;
// reinit mousedown, live() did not work to disable
$(".album li").mousedown(mStart);
}
/* rolling over the receiver - over, out, over etc. */
function uiOver(event, ui) {
// only if item in not allready in the target
if (!iCopy) {
// counter for over/out (numbers even/uneven)
overCount++;
// if even [over], clone to original index in sender, show and fadein (sortables hides it)
if (overCount%2) {
if (iIndex == 0) { ui.item.clone().addClass("copy").attr("id", iId).prependTo(iSender).fadeIn("slow"); }
else { ui.item.clone().addClass("copy").attr("id", iId).insertAfter(iSender + " li:eq(" + iIndex + ")").fadeIn("slow"); }
}
// else uneven [out], remove copies
else { $(iSender + " li.copy").remove(); }
}
// else whoooooo
}
/* list transfers, fix ID's here */
function uiReceive(event, ui) {
(iTarget == ".favorites") ? liPrefix = "fli-" : liPrefix = "lli-";
// set ID with index for each matched element
$(iTarget + " li").each(function(index) {
$(this).attr("id", liPrefix + (index + 1)); // id's start from 1
});
}
HTML:
<div class="page">
<div class="container">
<h2>Photo Album</h2>
<ul class="listing album">
<li id="li-1"><img src="tn/001.jpg" /></li>
<li id="li-2"><img src="tn/002.jpg" /></li>
<li id="li-3"><img src="tn/003.jpg" /></li>
<li id="li-4"><img src="tn/004.jpg" /></li>
<li id="li-5"><img src="tn/005.jpg" /></li>
</ul>
</div>
<div style="clear:both;"></div>
<div class="container">
<h2>Favorites</h2>
<ul class="favorites album">
<li id="fli-1"><img src="tn/001.jpg" /></li>
<li id="fli-2"><img src="tn/002.jpg" /></li>
<li id="fli-3"><img src="tn/010.jpg" /></li>
</ul>
</div>
</div>
/* docs say:
If the sortable item is being moved from one connected sortable to another:
$(ui.sender).sortable('cancel');
will cancel the change. Useful in the 'receive' callback.
*/
This code was what I spent 30 minutes looking for!
Ok I found some sort of hack for this.
When an item is moved from #sortable1 to #sortable2, when dragged over #sortable2 there is a list item added with class .placeholder
So in UI's over event I did
$("#sortable2 li.placeholder").hide();
Than set it back with UI's stop event
$("#sortable2 li.placeholder").show();
This is only for visuals though.. The item is still moved into #sortable2 so you need to remove() it there. To mimic copying you need to add a clone() back in #sortable2. You can get it's original index() in UI's start event and than use insertAfter(id - 1)
At the moment I can only clone in UI's receive event, I would prefer in UI's over but can't get it to work..

Display an icon in jQuery UI autocomplete results

I'm using the jQuery UI Autocomplete plugin (version 1.8), and I'd like to customize the way the suggestions show up. Specifically, I want to display not only some text, but an icon as well. However, when I send the <img> tag, it just gets rendered as plain text in the results list.
Is there some way to change this behavior? Alternatively, can you suggest a different way to include images in the returned results and have them show up in the suggestions?
Taken from here
$("#search_input").autocomplete({source: "/search",
minLength: 3,
select: function (event, ui) {
document.location = ui.item.url;
}
})
.data("autocomplete")._renderItem = function (ul, item) {
//As per recent documemtation above line should be
//.autocomplete( "instance" )._renderItem = function (ul, item) {
return $('<li class="ui-menu-item-with-icon"></li>')
.data("item.autocomplete", item)
.append('<a><span class="' + item.type + '-item-icon"></span>' + item.label + '</a>')
.appendTo(ul);
};
And the CSS:
.ui-menu .ui-menu-item-with-icon a {
padding-left: 20px;
}
span.group-item-icon,
span.file-item-icon {
display: inline-block;
height: 16px;
width: 16px;
margin-left: -16px;
}
span.group-item-icon {
background: url("/image/icons/group.png") no-repeat left 4px;
}
span.product-item-icon {
background: url("/image/icons/product.png") no-repeat left 7px;
}