Two Questions - Area Variables and Auto-Nav

Permalink 1 user found helpful
I'm brand new to C5...coming from Joomla, so I'm trying to learn the terminology and whatnot.

Anyways. First two things that hit me are these:

1.) In the Auto-Nav, how can I add custom CSS classes to individual list items? Many times I'll want to use background images for my navigation items and each item will need a different image. How can I make the nav item for "Home" have a class of .home? Or "About" have a class of .about?

2.) Looking at the default theme installed, in each of the spots where a new area is created, what does $a, $as, $ai and $ah stand for? For example:
<?php 
         $as = new Area('Sidebar');
         $as->display($c);
         ?>


Or:

<?php  $ai = new Area('Blog Post Footer'); $ai->display($c); ?>


Thanks! :)

leinteractive
 
SVijay replied on at Permalink Reply
SVijay
leinteractive replied on at Permalink Reply
leinteractive
I'm sorry...maybe I'm not drawing the connections but I don't see how those links answer my questions?

I just want to know what the different variable mean in the New Area code ($as, $a, $ai, $ah, etc.)

And also how to add a uniqe CSS class to individual LI items in the AutoNav.

Thanks!
olliephillips replied on at Permalink Best Answer Reply
olliephillips
There's a ton of good info on here, but it's not always that easy to find. Do stick at it - I'll bet you don't go back to Joomla!

Re your questions..

1) All blocks, including Auto-Nav, support custom templates. Custom templates might be provided with the core Concrete5 block (see 'Set Custom Template' menu option when you click on a block in Edit Mode). Auto-Nav has 2 custom templates I think.

But, if you need to do something with a block's presentation that isn't available to you in the core block (or provided custom templates) you can create your own custom template very easilly. Put that template in a certain place in your sites path, and it'll be available to you from the 'Set Custom Template' menu option mentioned above.

Adding your specfic CSS selectors can be done in the new template you create. Look up custom templates on here for more information.

2) Re your second Q. The variable names are insignificant (as long as they don't conflict). They're just objects for displaying content. Naming conventions might reflect where they are being used $ah (area header? a guess) but you can use anything.

Hope that helps you.
leinteractive replied on at Permalink Reply
leinteractive
Thanks....from what I've learned it seems I'm going to be best off just jumping in and doing and letting it "click" naturally.

In regards to #2 -
You said as long as the variable names don't conflict...what do you mean? In the templates I was looking at, the variable $as was used to create two different areas on the same page. Is that not a conflict?
olliephillips replied on at Permalink Reply
olliephillips
Re learning by doing - definitely. I'm approaching it the same way!

re the $as variable, might you be mis-interpreting that? I think first use might be object creation and then the next, a method call?

You can reuse object variables, but if you want to work with the objects represented by them, non conflicting names are good.
jordanlev replied on at Permalink Reply
jordanlev
This is not true in this case -- you can (and I always do) re-use the same variable name over and over again.
This is ok in this situation because once you call the "$a->display()" function, you don't need to keep the area object around anymore (because it's done its job and you don't need it for anything else later on), so the next time you call "$a = new Area()", it just overwrites the old object with the new one.

Also see this thread:
http://www.concrete5.org/community/forums/customizing_c5/adding-edi...
olliephillips replied on at Permalink Reply
olliephillips
Ah yes. I see what you mean. In the context of a theme it doesn't matter. Cheers for putting me on the right track too! Might adopt that approach going forward myself.
leinteractive replied on at Permalink Reply
leinteractive
In what other context would it matter?
jordanlev replied on at Permalink Reply
jordanlev
In a theme page type template it wouldn't matter -- but in general if you have code that is instantiating objects or setting variables, you wouldn't want to re-instantiate the object or assign something else to the variable before you're "done using it".