#div:normal #div:hover #div:SELECTED? - css

On the "services" and "company" pages I have a right sidebar list. This is being included with PHP. So far I have a CSS class for normal and a CSS class for when you hover each item in the list. I want to have a new class for when each list item is selected. So for example in services, the user clicks on "family planning" and when they get to the family planning page....the family planning list item has a grey background. Is this possible?
http://beulahprint.ie/index.php
Cheers,
Colm

Nothing in CSS will let you match an element based on it's href attribute resolving to the current URL.
Add a class to the menu item (or the body element) server side based on the page, then use a write a selector to match that.

There are a few ways to accomplish this but you'll need a little bit of code. It works like follows:
On your page you should somehow declare which page it is (by using a querystring or session)
Then you should parse this value and write out the class name of the menu dynamiclly.

Yes it is possible, when rendering the sidebar/menu, check if they are in a specific page/namespace and add a class to it which has grey background.
The general design people use for such scenarios is to place all items related to one menu item in one namespace.
like all admin items will be under */admin/*, so that when rendering the menu, they will check the url and add the class to it.

Related

APEX - Setting a CSS class based on a page item rather than a static value?

I'd like to set either the CSS class or an attribute of a region based on the value of a page item. I've tried the following syntax with no real joy:
#P0_CURRENT_SCHEMA#
:P0_CURRENT_SCHEMA
&P0_CURRENT_SCHEMA
Is there a syntax that will allow me to use the value of a page item rather than a static value to set the value of a CSS class (my aim here is to have part of the UI colour code itself based on what environment it is in).
Your substitution syntax isn't quite right. You need the period at the end.
&P0_CURRENT_SCHEMA.
A jQuery approach that would allow for dynamic changing of the class on the fly. It could be added to a dynamic action.
$('#P0_SET_MY_CLASS').addClass($('#P0_CURRENT_SCHEMA').val());

Sitecore 6.5 change user control dynamically

I have a collection of some items. Using * symbol I set user control (ascx) in presentation details for all of them. Now I have a problem because on of this items has to be display in another control. Is there some trick that allow me to change used control dynamically, for example checking url segment?
I'm guessing you're using wildcard item called * with some presentation details defined on it. And now you want to display different components for one you the urls?
If you want to have completely different presentation, you can add another item as a sibling of the * item and put new presentation detail there. This item will be matched before the wildcard item, if the url segment is equal to this item name.
If you want to change only one or few components, you can use personalization for this component and where the item name compares to ... rule.
Marek's answer is preferable, but for completeness I will provide another potential option.
It depends on how you are handling the wildcards. I don't think it will work if you are using the wildcard item module from the Marketplace and it might not play well with some of your existing code, but here goes...
You could place the required presentation details on the target items themselves. Then when you resolve the wildcard, you would need to change the context item to be selected target item. When the page loads, it will use the presentation of the newly set context item.
One way to achieve this would be to create a custom item resolver
class WildCardItemResolver : ItemResolver
{
public override Process(HttpRequestArgsargs args)
{
base.Process(args);
// if Context.Item is as wildcard
// look up the target item
Context.Item = targetItem
}
}

Scala Lift - Sitemap menu builder custom css classes

I've got the following site map defined in Boot.scala:
SiteMap(
Menu(S ? "Home") / "index",
Menu(S ? "About") / "about",
Menu(S ? "Work") / "work",
Menu(S ? "Contact") / "contact"
)
With the following markup:
<lift:Menu.builder />
What I'm trying to do is in someway identify the menu items to style each seperatly.
Is there a way to define a unique class for each sitemap entry or perhaps add the name of the menu item to the title attribute which I could also use to style them?
So the markup is rendered like this:
About
Or
About
Thanks in advance, any help much appreciated :)
UPDATE
Until a more robust way of doing this is found, I've opted to style each link in the menu via simple attribute reference, e.g:
a[href="/about"] { color:#000; }
I would take a look at the Menu.item section here: http://exploring.liftweb.net/master/index-7.html#toc-Subsection-7.2.3
That should allow you to add specific classes to particular items of the SiteMap, which sounds like exactly what you want to do.
If your site menu is not really simple, you can consider to hard-code your menu inside the HTML code. Obviously, Lift's simple menu can't handle everything.
You can also create menu groups and render these groups separately.

Change HTML/CSS from ASP(C# or VB) code

In my case, I have an HTML/CSS Menu in the site master.
So, when you hover your mouse over "Graphics", it highlights it (using CSS onHover).
Now what I need to do is that when you actually click on "Graphics" (and it takes you to the graphics page), it remains highlighted, if possible in a different colour.
I'm thinking of modifying the Site.Master style from C# or VB code.
Any ideas? Thanks.
An idea would be to check what page you are in, and apply a css class:
<li class="<%= this.Page.ToString().ToLower().EndsWith("graphics_aspx") ? "selected" : "normal"%>">
Graphics<li>
Hope it helps!
You can either use the CSS active state if the page you are on directly relates to the link, however if the menu points to sections (i.e. multiple pages) you may need to use a bit of server side code to your master page, that gets the requested URL and determines which link is active. Usual convention is to then add the class 'active' or similar to the outputted html.
You can convert the UL/LI with runat = "server" and finally add styles in the code behind
Example
Control.Style.Add("display", "none");

css tabs that do not require div changes for the active tab

I'm looking to get ideas on how to not change at all the code used to create css tabs (so that I can place it into an include file to avoid duplicating the code across all files that use it), but my current implementation doesn't allow this because I need to select the active tab using id="selectedTab".
The only implementation I found so far that solves this is the following one:
http://unraveled.com/publications/css_tabs/
It requires assigning a class to each tab and uses the body id to determine the active tab.
Is this the only way or is there any other alternatives?
My current code looks like this (the id=noajax" is used to avoid using ajax to load certain pages):
<div class="productTabsBlock2">
<a id="selectedTab" href="/link1" >OVERVIEW</a>
SCREENSHOTS
<a id="noajax" href="/link3" >SPEED TESTS</a>
<a href="/link4" >AWARDS</a>
</div>
EDIT: asp is available as server side and is already used on these pages.
If you're looking for a non-JS solution, then the body class/id provide the easiest way to do what you want.
If you have access to JS library, you can easily add "selected" class to any of the <a> element and modify its appearance.
Just in case you haven't notice, you can use more than one class definition in an element. For example, <a class="noajax selected" /> is valid and both CSS selectors .noajax and .selected will be applied to the element.
An include file for what? If it's a server side programming language like PHP, you can pass a parameter for the selected tab through various methods.
you could use jQuery to add the `selectedTab' id (or class) like so
$('.productTabsBlock2 a').mouseover(function () {
$(this).addClass('selectedTab');
});

Resources