SlideShare una empresa de Scribd logo
1 de 17
Using Class Suffixes
                This tutorial was written for Joomla1.5, however the differences to Joomla 1.6 are minor.

This tutorial will show you how to use Page, Module, and Menu Class Suffixes in Joomla! to fine-tune the
appearance of your site. For the tutorial, we will assume you have the Joomla! 1.5.9 Sample site
available.

                        Contents
                         [hide]


1 Background

2 When Would You Use a Class Suffix?

3 Page Class Suffix

 o    3.1 How It Works Without a Page Class Suffix

 o    3.2 Page Class Suffix (No Space)

 o    3.3 Page Class Suffix (With a Leading Space)

 o    3.4 Add CSS Styling to New Class

4 Module Class Suffix

 o    4.1 Be careful not to break existing CSS styling

5 Menu Class Suffix and Menu Tag ID

 o    5.1 Menu Class Suffix

 o    5.2 Menu Tag ID parameter

6 Conclusion

Background
Joomla! creates HTML pages that use Cascading Style Sheets to control the appearance of the page.
This includes things like fonts, colors, margins, and background. The CSS files are part of your template.

When Joomla! creates a page, it creates different CSS classes that are then referenced in the CSS file to
specify which style will apply to which parts of the HTML page. These class names are pre-programmed
into Joomla!. But Joomla! allows you to modify or add CSS classes by way of the Class Suffix
parameters. This lets you fine-tune the appearance of specific pages with no programming and very little
work. The best way to understand this is to see specific examples.

When Would You Use a Class Suffix?
Say, for example, that your website contains a number of Section Blog layouts, each for a different
Section. If you are happy to have all of these pages styled the same way, then you wouldn't need to use a
Page Class Suffix. However, say you want each of these sections styled differently than the others. For
example, maybe you want a different background color or image for each different section.

Or say that you want the heading on your front page to look different than the heading on other pages.

In both of these cases, if you modify the styling in your "template.css" file for the standard CSS classes, it
will affect all Menu Items that use these CSS classes. For example, if you change the style for the CSS
class "componentheading", it will affect all of the Menu Items that use this class.

However, if you add a unique Page Class Suffix to a Menu Item, then Joomla! will create new CSS
classes for each individual Menu Item so you can style each one differently.

Page Class Suffix

Before you start, make sure you have the Joomla! sample website available. Also, make sure the default
template is set to "rhuk_milkyway" (in the Extensions → Template Manager).

How It Works Without a Page Class Suffix
Before we add a Page Class Suffix, let's see how this pages works without one. In the front end, navigate
to Example Pages → Section Blog. In your browser, select the option to view the page source code. For
example, in Firefox, press Ctrl+U. In Internet Explorer, select View → Source. In Safari, select View →
View Source.

Using the "Find" command, find the first occurrence of the word "componentheading". It should look like
the following:


<div class="componentheading">


Browse down the file and find the following tags:


        <table class="blog" cellpadding="0" cellspacing="0">
        <table class="contentpaneopen">
        <td class="contentheading" width="100%">
        <table class="contentpaneopen">


                               Note: The following screenshots were made using the free Firefox add-in
                               called Firebug. Firebug allows you to quickly see the relationship between
                               the HTML elements in your source and the text and graphics shown on the
                               page. It is a very handy tool, and you can get it here. For more information,
                               please watch the free video tutorial on using Firebug with Joomla.
The screenshot below shows you the "componentheading" class. It is the page title
area above the blog article.




This screenshot shows you the entire "blog" class. This is the outer table into which
all of the articles will fit.
The next screenshot shows you the "contentpaneopen" class for an article heading.
This includes the article title and the PDF, Print, and Email icons to the right.
This screenshot shows you the "contentpaneopen" class for the body of the article.
This includes the author and date information as well as the actual article text.
So this gives us a good understanding of how Joomla! allows us to style the
elements on a Section Blog layout. Joomla! writes out these classes as part of the
HTML. And the template contains CSS that provides the styling information for
these various elements and classes.

Page Class Suffix (No Space)
Now that we see how this works without a Page Class Suffix, let's try it with one. In
the back end, navigate to Menus → Example Pages and click on "Section Blog".
This should display the "Menu Item: [Edit]" screen for the Section Blog Layout. Click
Parameters (System) to show the System Parameters. In the "Page Class Suffix"
field enter the value "_myBlogSuffix" and click the Save button.
Now, go back to the front end and again navigate to Example Pages → Section
Blog. Notice right away that we lost the styling for the page and article titles. Let's
look closer to see why.

Using the browser "Find" command, find the first occurrence of "_myBlogSuffix". It
is in a "div" tag and looks like this:


<div class="componentheading_myBlogSuffix">


If you look through the source, you should also see the following
classes: blog_myBlogSuffix, contentpaneopen_myBlogSuffix,
and contentheading_myBlogSuffix.

By adding the Page Class Suffix, we changed all of these class names. That means
that special styling in the CSS file that refers to the "base" class names (like
componentheading, blog, and so on) will not be applied, since those classes no
longer exist on the page.

Now, you can fix this problem by editing your templates CSS file to add the same
styling for the new classes (for example, "componentheading_myBlogSuffix"). But
there is a much easier way to do this -- simply by adding a leading space to the
parameter.

Page Class Suffix (With a Leading Space)
Again in the back end, go back to Menus → Example Pages → Section Blog. We're
going to change the value of the Page Class Suffix. This time we're going to enter in
a leading space and call it <space> + "myBlogClass", as shown below.




Now, go back to the front end and re-display the Example Pages → Section Blog.
Notice that our styling is back! Let's look at the HTML source to see what is going
on. Open the source and find the first occurrence of "myBlogClass". It should like
this:


<div class="componentheadingmyBlogClass">
Because we put a leading space in the Page Class Suffix, we created a second
class instead of changing the name of the first class (which is allowed and
supported by all modern browsers). So we didn't break any of the existing CSS
styling for this page. (One warning: we need to make sure the new class name is
different than any of the other class names used on the page. Otherwise, we might
get styling we don't want.)

Add CSS Styling to New Class
At this point, we've created a new CSS class in the HTML to allow for some new
styling. Now we need to use this new class to actually change the look of our page.
The first thing we need to do is find the applicable CSS file. In this case, it
is <joomla_root>/templates/rhuk_milkyway/css/template.css.

Let's say we want to add a background color, but only to this specific Section Blog.
(Remember, if we wanted to just change all of the Section Blog pages in our site,
we could just change the CSS styling for the base classes, such as
"componentheading" or "blog".) We need to do is figure out which area
("componentheading", "blog", or "contentpaneopen") we want to style. Say we just
wanted to style the "componentheading" area.

First, let's use the CSS selector "div.myBlogClass" and add the following code to
the end of our CSS file:
/* Custom Styling */
div.myBlogClass{
       background-color:#FFE4E1;/* mistyrose */
}

The result is that the page heading now has the background color, as shown below.




Now this works fine in our example, because the other classes are defined for
"table" tags and not "div" tags. But it is normally better to be more specific in our
style selector by styling only those elements that have both the desired base class
and the new class. For example, let's replace the code above with the following
code:
/* Custom Styling */
.blog.myBlogClass{
       background-color:#FAFAD2;/* lightgoldenrod */
}

This specifies that the new style will only be applied to elements that have both the
"blog" and the "myBlogClass" styles. This gives us the background color over the
entire "blog" area, as shown below.




The great thing about creating a new class (with the leading space trick) is that we
don't need to copy all of the existing styling for the base classes. We can just focus
on the new styling that we want.

Now in this example, we focused on the Section Blog layout. The class names for
different components might be different, but the process will be the same. The table
below shows some common Joomla! layouts and a list of class names that can
have Page Class Suffixes added.


           Layout                              CSS Class Names Used



                             componentheading, contentpaneopen, contentheading,
Article Layout
                             contentpagetitle



Category Blog,               componentheading, contentpagetitle, blog, contentpaneopen,
FrontpageBlog, Section Blog   contentheading, readon, blog_more



Category List, Section List   componentheading, contentpane, contentdescription



                              componentheading, contentpane, contentdescription,
Contact Category
                              sectiontablefooter, sectiontableheader, category



Contact Layout                componentheading, contentpaneopen, contentheading


So, to sum up what we have learned about using the Page Class Suffix parameter:


     1. Use a leading space to create a new CSS class. This way you don't have
         to worry about re-doing or breaking existing CSS styles.
     2. Look in the HTML source code to find the locations of the base and new
         classes.
     3. If desired, use Firebug to see which HTML elements correspond to which
         areas on the page.
     4. Add custom styling to the end of the "template.css" file, specifying both the
         name of the desired base class and the custom class in the
         form .baseclass.customclass as in the example above.
Module Class Suffix

The Module Class Suffix parameter works in the same way as the Page Class
Suffix. Let's go through an example using the Latest News module.

In the administrative back end, navigate to Extensions → Module Manager and find
the "Latest News" module. Click on it to open it for editing, and enter <space> +
"customLatestClass" in the Module Class Suffix parameter field, as shown below:
Now, navigate to the home page in the front end and view the page source code.
The screenshot below was made using the Firebug add-in tool. It shows the home
page and the HTML and styling for the customised Latest News module.




In the upper part of the screen, outlined in light blue, is the "div" element for the
module. Below, in the HTML window, we see the HTML as follows:
<div class="moduletablecustomLatestClass">


and then


<ul class="latestnewscustomLatestClass">


The "moduletable" and "latestnews" classes are created automatically. The new
class, "customLatestNews" was created because we started the Module Class
Suffix parameter with a leading space.

Now, let's use our new class to add some custom styling. Again, go to the end of
the templates/rhuk_milkyway/css/template.css file and add the following code:
div.customLatestClass{
       background-color:#FFFFD2;
}

div.customLatestClass
h3,ul.customLatestClass,ul.customLatestClass a {
       color:#8B4513;
}

Save the file and re-display the home page. It should look like the screenshot
below:




The CSS selector div.customLatestClass sets the background color for the
entire area. The three selectors div.customLatestClass h3,
ul.customLatestClass, ul.customLatestClass a select the font color for
the "h3" heading, the bullets ("ul" tag), and the "a" tag, respectively. Note that, if we
only wanted to style the "ul" element, we wouldn't need a Module Class Suffix
unless we had more than one "Latest News" module. Instead, we could just have
defined the CSS using the standard "latestnews" class.

Be careful not to break existing CSS styling
In menus, we need to be careful not to break existing CSS styling.

Let's look at how this works. In the administrative back end, navigate to Extensions
→ Module Manager and open the Main Menu for editing. Click on the Advanced
Parameters. Notice that the Module Class Suffix is set to "_menu", without a leading
space.

Now, go to the Home page in the front end and view the source code (or use
Firebug). The screenshot below shows the HTML for the Main Menu.




Notice that the class is called "module_menu" because of the Module Class Suffix.
Also, notice that there is special styling in the "template.css" and "blue.css" files for
the "module_menu" class. For example, there is a background image that provides
part of the blue border around the menu.

We can confirm this by returning to the back end and changing the Module Class
Suffix to blank. Return to the Home page and refresh. Now the Main Menu will show
without the special "module_menu" styling, as shown below:
This shows an important point. Existing modules, especially menus, may already
have CSS styling that depends on Module Class Suffixes. So we need to be careful
when making changes.

What if we still wanted to add some special styling just to the Main Menu? One way
is to get tricky and add a second CSS class to the existing suffix. To see this, return
to the Module Manager in the back end and open the Main Menu for editing. This
time, in the Module Class suffix, enter _menu, a space, and then myMenuClass, as
shown below:




Now, add the following code to the end of the
templates/rhuk_milkyway/css/template.css file:
div.myNewClass{
       font-size:1.2em;
       }

Go back to the Home page and notice that now the font in the Main Menu is larger,
as shown below.
If we open Firebug, we can see what the HTML and CSS looks like, as shown
below:




By putting a space between the "_menu" and "myNewClass", we added the new
class into the HTML. Then, by selecting the new class in the CSS file, we changed
the font size.

Menu Class Suffix and Menu Tag ID
All core modules allow you to enter a Module Class Suffix, as discussed above.
Menu modules have two additional parameters: Menu Class Suffix and Menu Tag
ID. Let's look at what these parameters do.

Menu Class Suffix
The Menu Class Suffix inserts an extra suffix in the class for the unordered list that
builds up the menu. If unedited, the class is "menu". If adding "_myMenuClass"
under Advanced Parameters → Menu Class Suffix, the new tag will be
"menu_myMenuClass".
(This behaviour is only for the Menu Style "List". If choosing "Legacy - Vertical" or
"Legacy - Horizontal", the class suffix will be added to the links in the table; this
suffix will then be "mainlevel_myMenuClass". When choosing the Legacy Flat List,
the suffix will be added to the links (as on the two other Legacy lists), but it will also
be added to the ul tag, but as an id rather than a class; the id will be
"mainlevel_myMenuClass".)

Menu Tag ID parameter
Now, lets look at the Menu Tag ID parameter. Navigate to the back end, open the
Main Menu module for editing, and enter "myTagID" in the Menu Tag ID parameter.

Add the following code to the end of the templates/rhuk_milkyway/css/template.css
file:
#myTagID{
       list-style-type:square;
}

Now, re-display the Home page to see the change. The bullets for the Main Menu
should now appear as squares, as shown below:




Finally, we can look at the HTML and CSS in Firebug, as shown below.




Joomla! has added the attribute id="myTagID" to the "ul" tag for the Main Menu.
This allowed us to change the style for this ID. Note that, since this is an "id"
attribute, we use the CSS selector #myTagID(with a "#" instead of a ".").
Conclusion
The Class Suffix and Menu Tag ID parameters allow you to fine-tune the CSS
styling of your web site. By using a leading space in the suffix name, we can create
a new class. This is normally the preferred method, since, as long as the new class
name does not conflict with an existing class, no existing styling will be broken.

Más contenido relacionado

La actualidad más candente

Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5ketanraval
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5Ketan Raval
 
How to Use Dreamweaver cs6
How to Use Dreamweaver cs6 How to Use Dreamweaver cs6
How to Use Dreamweaver cs6 Salman Memon
 
Windows Vista
Windows VistaWindows Vista
Windows Vistacartsh
 
Blog Pro 2.0 User Guide
Blog Pro 2.0 User GuideBlog Pro 2.0 User Guide
Blog Pro 2.0 User GuideIgor Goltsov
 
Dreamweaver cs6 step by step
Dreamweaver cs6 step by stepDreamweaver cs6 step by step
Dreamweaver cs6 step by stepzoran Jelinek
 
Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004
Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004
Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004brighteyes
 
Custome page template
Custome page templateCustome page template
Custome page templateLucky Ali
 
CHILD Site Coordinator Training
CHILD Site Coordinator TrainingCHILD Site Coordinator Training
CHILD Site Coordinator Trainingehealth
 
Unit a adobe dreamweaver cs6
Unit a adobe dreamweaver cs6Unit a adobe dreamweaver cs6
Unit a adobe dreamweaver cs6Krista Lawrence
 
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateSean Burgess
 
Intro wordpress (1) copy with dipesh sharma
Intro wordpress (1)   copy with dipesh sharmaIntro wordpress (1)   copy with dipesh sharma
Intro wordpress (1) copy with dipesh sharmadegana2009
 
HTML 5 Complete Reference
HTML 5 Complete ReferenceHTML 5 Complete Reference
HTML 5 Complete ReferenceEPAM Systems
 
Lotus Notes Blog Template
Lotus Notes Blog TemplateLotus Notes Blog Template
Lotus Notes Blog Templateprojectdxguy
 
Unit f adobe dreamweaver cs6
Unit f adobe dreamweaver cs6Unit f adobe dreamweaver cs6
Unit f adobe dreamweaver cs6Krista Lawrence
 
Tags in joomla 3.1 (ENGLISH version) Eric Tiggeler
Tags in joomla 3.1 (ENGLISH version) Eric TiggelerTags in joomla 3.1 (ENGLISH version) Eric Tiggeler
Tags in joomla 3.1 (ENGLISH version) Eric TiggelerEric Tiggeler
 

La actualidad más candente (20)

Master page
Master pageMaster page
Master page
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5
 
How to Use Dreamweaver cs6
How to Use Dreamweaver cs6 How to Use Dreamweaver cs6
How to Use Dreamweaver cs6
 
Windows Vista
Windows VistaWindows Vista
Windows Vista
 
TemplateTutorial
TemplateTutorialTemplateTutorial
TemplateTutorial
 
Blog Pro 2.0 User Guide
Blog Pro 2.0 User GuideBlog Pro 2.0 User Guide
Blog Pro 2.0 User Guide
 
Dreamweaver cs6 step by step
Dreamweaver cs6 step by stepDreamweaver cs6 step by step
Dreamweaver cs6 step by step
 
Dreamweaver
DreamweaverDreamweaver
Dreamweaver
 
Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004
Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004
Using Stylesheets To Design A Web Site In Dreamweaver Mx 2004
 
Custome page template
Custome page templateCustome page template
Custome page template
 
CHILD Site Coordinator Training
CHILD Site Coordinator TrainingCHILD Site Coordinator Training
CHILD Site Coordinator Training
 
Unit a adobe dreamweaver cs6
Unit a adobe dreamweaver cs6Unit a adobe dreamweaver cs6
Unit a adobe dreamweaver cs6
 
SiteMesh
SiteMeshSiteMesh
SiteMesh
 
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
 
Intro wordpress (1) copy with dipesh sharma
Intro wordpress (1)   copy with dipesh sharmaIntro wordpress (1)   copy with dipesh sharma
Intro wordpress (1) copy with dipesh sharma
 
HTML 5 Complete Reference
HTML 5 Complete ReferenceHTML 5 Complete Reference
HTML 5 Complete Reference
 
Lotus Notes Blog Template
Lotus Notes Blog TemplateLotus Notes Blog Template
Lotus Notes Blog Template
 
Unit f adobe dreamweaver cs6
Unit f adobe dreamweaver cs6Unit f adobe dreamweaver cs6
Unit f adobe dreamweaver cs6
 
Tags in joomla 3.1 (ENGLISH version) Eric Tiggeler
Tags in joomla 3.1 (ENGLISH version) Eric TiggelerTags in joomla 3.1 (ENGLISH version) Eric Tiggeler
Tags in joomla 3.1 (ENGLISH version) Eric Tiggeler
 

Similar a Using class suffixes

Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency worldChris Lowe
 
GTU Web Designing Interview Questions And Answers for freshers
GTU Web Designing Interview Questions And Answers for freshersGTU Web Designing Interview Questions And Answers for freshers
GTU Web Designing Interview Questions And Answers for freshersTOPS Technologies
 
Using Wordpress with Reclaim Hosting
Using Wordpress with Reclaim HostingUsing Wordpress with Reclaim Hosting
Using Wordpress with Reclaim HostingCindy Royal
 
Overview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site DesignOverview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site DesignAmy Goodloe
 
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBlog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateSean Burgess
 
Drupal For Dummies
Drupal For DummiesDrupal For Dummies
Drupal For DummiesKoen Delvaux
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.docbutest
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.docbutest
 
Explain how the division element is used to setup the layout of a we.pdf
Explain how the division element is used to setup the layout of a we.pdfExplain how the division element is used to setup the layout of a we.pdf
Explain how the division element is used to setup the layout of a we.pdfSALES97
 
ASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceRandy Connolly
 
Css Founder.com | Cssfounder se
Css Founder.com | Cssfounder seCss Founder.com | Cssfounder se
Css Founder.com | Cssfounder seCss Founder
 

Similar a Using class suffixes (20)

Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency world
 
GTU Web Designing Interview Questions And Answers for freshers
GTU Web Designing Interview Questions And Answers for freshersGTU Web Designing Interview Questions And Answers for freshers
GTU Web Designing Interview Questions And Answers for freshers
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Using Wordpress with Reclaim Hosting
Using Wordpress with Reclaim HostingUsing Wordpress with Reclaim Hosting
Using Wordpress with Reclaim Hosting
 
CSS_GUIDE_Intro
CSS_GUIDE_IntroCSS_GUIDE_Intro
CSS_GUIDE_Intro
 
CSS_GUIDE_Intro
CSS_GUIDE_IntroCSS_GUIDE_Intro
CSS_GUIDE_Intro
 
Overview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site DesignOverview of Using Wordpress for Web Site Design
Overview of Using Wordpress for Web Site Design
 
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBlog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
 
Drupal For Dummies
Drupal For DummiesDrupal For Dummies
Drupal For Dummies
 
Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 
Intermediate Web Design.doc
Intermediate Web Design.docIntermediate Web Design.doc
Intermediate Web Design.doc
 
TemplateTutorial
TemplateTutorialTemplateTutorial
TemplateTutorial
 
Explain how the division element is used to setup the layout of a we.pdf
Explain how the division element is used to setup the layout of a we.pdfExplain how the division element is used to setup the layout of a we.pdf
Explain how the division element is used to setup the layout of a we.pdf
 
ASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites Appearance
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
Css Founder.com | Cssfounder se
Css Founder.com | Cssfounder seCss Founder.com | Cssfounder se
Css Founder.com | Cssfounder se
 
Week 2-intro-html
Week 2-intro-htmlWeek 2-intro-html
Week 2-intro-html
 

Último

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Último (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

Using class suffixes

  • 1. Using Class Suffixes This tutorial was written for Joomla1.5, however the differences to Joomla 1.6 are minor. This tutorial will show you how to use Page, Module, and Menu Class Suffixes in Joomla! to fine-tune the appearance of your site. For the tutorial, we will assume you have the Joomla! 1.5.9 Sample site available. Contents [hide] 1 Background 2 When Would You Use a Class Suffix? 3 Page Class Suffix o 3.1 How It Works Without a Page Class Suffix o 3.2 Page Class Suffix (No Space) o 3.3 Page Class Suffix (With a Leading Space) o 3.4 Add CSS Styling to New Class 4 Module Class Suffix o 4.1 Be careful not to break existing CSS styling 5 Menu Class Suffix and Menu Tag ID o 5.1 Menu Class Suffix o 5.2 Menu Tag ID parameter 6 Conclusion Background Joomla! creates HTML pages that use Cascading Style Sheets to control the appearance of the page. This includes things like fonts, colors, margins, and background. The CSS files are part of your template. When Joomla! creates a page, it creates different CSS classes that are then referenced in the CSS file to specify which style will apply to which parts of the HTML page. These class names are pre-programmed into Joomla!. But Joomla! allows you to modify or add CSS classes by way of the Class Suffix parameters. This lets you fine-tune the appearance of specific pages with no programming and very little work. The best way to understand this is to see specific examples. When Would You Use a Class Suffix? Say, for example, that your website contains a number of Section Blog layouts, each for a different Section. If you are happy to have all of these pages styled the same way, then you wouldn't need to use a
  • 2. Page Class Suffix. However, say you want each of these sections styled differently than the others. For example, maybe you want a different background color or image for each different section. Or say that you want the heading on your front page to look different than the heading on other pages. In both of these cases, if you modify the styling in your "template.css" file for the standard CSS classes, it will affect all Menu Items that use these CSS classes. For example, if you change the style for the CSS class "componentheading", it will affect all of the Menu Items that use this class. However, if you add a unique Page Class Suffix to a Menu Item, then Joomla! will create new CSS classes for each individual Menu Item so you can style each one differently. Page Class Suffix Before you start, make sure you have the Joomla! sample website available. Also, make sure the default template is set to "rhuk_milkyway" (in the Extensions → Template Manager). How It Works Without a Page Class Suffix Before we add a Page Class Suffix, let's see how this pages works without one. In the front end, navigate to Example Pages → Section Blog. In your browser, select the option to view the page source code. For example, in Firefox, press Ctrl+U. In Internet Explorer, select View → Source. In Safari, select View → View Source. Using the "Find" command, find the first occurrence of the word "componentheading". It should look like the following: <div class="componentheading"> Browse down the file and find the following tags: <table class="blog" cellpadding="0" cellspacing="0"> <table class="contentpaneopen"> <td class="contentheading" width="100%"> <table class="contentpaneopen"> Note: The following screenshots were made using the free Firefox add-in called Firebug. Firebug allows you to quickly see the relationship between the HTML elements in your source and the text and graphics shown on the page. It is a very handy tool, and you can get it here. For more information, please watch the free video tutorial on using Firebug with Joomla.
  • 3. The screenshot below shows you the "componentheading" class. It is the page title area above the blog article. This screenshot shows you the entire "blog" class. This is the outer table into which all of the articles will fit.
  • 4. The next screenshot shows you the "contentpaneopen" class for an article heading. This includes the article title and the PDF, Print, and Email icons to the right.
  • 5. This screenshot shows you the "contentpaneopen" class for the body of the article. This includes the author and date information as well as the actual article text.
  • 6. So this gives us a good understanding of how Joomla! allows us to style the elements on a Section Blog layout. Joomla! writes out these classes as part of the HTML. And the template contains CSS that provides the styling information for these various elements and classes. Page Class Suffix (No Space) Now that we see how this works without a Page Class Suffix, let's try it with one. In the back end, navigate to Menus → Example Pages and click on "Section Blog". This should display the "Menu Item: [Edit]" screen for the Section Blog Layout. Click Parameters (System) to show the System Parameters. In the "Page Class Suffix" field enter the value "_myBlogSuffix" and click the Save button.
  • 7. Now, go back to the front end and again navigate to Example Pages → Section Blog. Notice right away that we lost the styling for the page and article titles. Let's look closer to see why. Using the browser "Find" command, find the first occurrence of "_myBlogSuffix". It is in a "div" tag and looks like this: <div class="componentheading_myBlogSuffix"> If you look through the source, you should also see the following classes: blog_myBlogSuffix, contentpaneopen_myBlogSuffix, and contentheading_myBlogSuffix. By adding the Page Class Suffix, we changed all of these class names. That means that special styling in the CSS file that refers to the "base" class names (like componentheading, blog, and so on) will not be applied, since those classes no longer exist on the page. Now, you can fix this problem by editing your templates CSS file to add the same styling for the new classes (for example, "componentheading_myBlogSuffix"). But there is a much easier way to do this -- simply by adding a leading space to the parameter. Page Class Suffix (With a Leading Space) Again in the back end, go back to Menus → Example Pages → Section Blog. We're going to change the value of the Page Class Suffix. This time we're going to enter in a leading space and call it <space> + "myBlogClass", as shown below. Now, go back to the front end and re-display the Example Pages → Section Blog. Notice that our styling is back! Let's look at the HTML source to see what is going on. Open the source and find the first occurrence of "myBlogClass". It should like this: <div class="componentheadingmyBlogClass">
  • 8. Because we put a leading space in the Page Class Suffix, we created a second class instead of changing the name of the first class (which is allowed and supported by all modern browsers). So we didn't break any of the existing CSS styling for this page. (One warning: we need to make sure the new class name is different than any of the other class names used on the page. Otherwise, we might get styling we don't want.) Add CSS Styling to New Class At this point, we've created a new CSS class in the HTML to allow for some new styling. Now we need to use this new class to actually change the look of our page. The first thing we need to do is find the applicable CSS file. In this case, it is <joomla_root>/templates/rhuk_milkyway/css/template.css. Let's say we want to add a background color, but only to this specific Section Blog. (Remember, if we wanted to just change all of the Section Blog pages in our site, we could just change the CSS styling for the base classes, such as "componentheading" or "blog".) We need to do is figure out which area ("componentheading", "blog", or "contentpaneopen") we want to style. Say we just wanted to style the "componentheading" area. First, let's use the CSS selector "div.myBlogClass" and add the following code to the end of our CSS file: /* Custom Styling */ div.myBlogClass{ background-color:#FFE4E1;/* mistyrose */ } The result is that the page heading now has the background color, as shown below. Now this works fine in our example, because the other classes are defined for "table" tags and not "div" tags. But it is normally better to be more specific in our style selector by styling only those elements that have both the desired base class and the new class. For example, let's replace the code above with the following code: /* Custom Styling */
  • 9. .blog.myBlogClass{ background-color:#FAFAD2;/* lightgoldenrod */ } This specifies that the new style will only be applied to elements that have both the "blog" and the "myBlogClass" styles. This gives us the background color over the entire "blog" area, as shown below. The great thing about creating a new class (with the leading space trick) is that we don't need to copy all of the existing styling for the base classes. We can just focus on the new styling that we want. Now in this example, we focused on the Section Blog layout. The class names for different components might be different, but the process will be the same. The table below shows some common Joomla! layouts and a list of class names that can have Page Class Suffixes added. Layout CSS Class Names Used componentheading, contentpaneopen, contentheading, Article Layout contentpagetitle Category Blog, componentheading, contentpagetitle, blog, contentpaneopen,
  • 10. FrontpageBlog, Section Blog contentheading, readon, blog_more Category List, Section List componentheading, contentpane, contentdescription componentheading, contentpane, contentdescription, Contact Category sectiontablefooter, sectiontableheader, category Contact Layout componentheading, contentpaneopen, contentheading So, to sum up what we have learned about using the Page Class Suffix parameter: 1. Use a leading space to create a new CSS class. This way you don't have to worry about re-doing or breaking existing CSS styles. 2. Look in the HTML source code to find the locations of the base and new classes. 3. If desired, use Firebug to see which HTML elements correspond to which areas on the page. 4. Add custom styling to the end of the "template.css" file, specifying both the name of the desired base class and the custom class in the form .baseclass.customclass as in the example above. Module Class Suffix The Module Class Suffix parameter works in the same way as the Page Class Suffix. Let's go through an example using the Latest News module. In the administrative back end, navigate to Extensions → Module Manager and find the "Latest News" module. Click on it to open it for editing, and enter <space> + "customLatestClass" in the Module Class Suffix parameter field, as shown below:
  • 11. Now, navigate to the home page in the front end and view the page source code. The screenshot below was made using the Firebug add-in tool. It shows the home page and the HTML and styling for the customised Latest News module. In the upper part of the screen, outlined in light blue, is the "div" element for the module. Below, in the HTML window, we see the HTML as follows:
  • 12. <div class="moduletablecustomLatestClass"> and then <ul class="latestnewscustomLatestClass"> The "moduletable" and "latestnews" classes are created automatically. The new class, "customLatestNews" was created because we started the Module Class Suffix parameter with a leading space. Now, let's use our new class to add some custom styling. Again, go to the end of the templates/rhuk_milkyway/css/template.css file and add the following code: div.customLatestClass{ background-color:#FFFFD2; } div.customLatestClass h3,ul.customLatestClass,ul.customLatestClass a { color:#8B4513; } Save the file and re-display the home page. It should look like the screenshot below: The CSS selector div.customLatestClass sets the background color for the entire area. The three selectors div.customLatestClass h3, ul.customLatestClass, ul.customLatestClass a select the font color for the "h3" heading, the bullets ("ul" tag), and the "a" tag, respectively. Note that, if we only wanted to style the "ul" element, we wouldn't need a Module Class Suffix unless we had more than one "Latest News" module. Instead, we could just have defined the CSS using the standard "latestnews" class. Be careful not to break existing CSS styling
  • 13. In menus, we need to be careful not to break existing CSS styling. Let's look at how this works. In the administrative back end, navigate to Extensions → Module Manager and open the Main Menu for editing. Click on the Advanced Parameters. Notice that the Module Class Suffix is set to "_menu", without a leading space. Now, go to the Home page in the front end and view the source code (or use Firebug). The screenshot below shows the HTML for the Main Menu. Notice that the class is called "module_menu" because of the Module Class Suffix. Also, notice that there is special styling in the "template.css" and "blue.css" files for the "module_menu" class. For example, there is a background image that provides part of the blue border around the menu. We can confirm this by returning to the back end and changing the Module Class Suffix to blank. Return to the Home page and refresh. Now the Main Menu will show without the special "module_menu" styling, as shown below:
  • 14. This shows an important point. Existing modules, especially menus, may already have CSS styling that depends on Module Class Suffixes. So we need to be careful when making changes. What if we still wanted to add some special styling just to the Main Menu? One way is to get tricky and add a second CSS class to the existing suffix. To see this, return to the Module Manager in the back end and open the Main Menu for editing. This time, in the Module Class suffix, enter _menu, a space, and then myMenuClass, as shown below: Now, add the following code to the end of the templates/rhuk_milkyway/css/template.css file: div.myNewClass{ font-size:1.2em; } Go back to the Home page and notice that now the font in the Main Menu is larger, as shown below.
  • 15. If we open Firebug, we can see what the HTML and CSS looks like, as shown below: By putting a space between the "_menu" and "myNewClass", we added the new class into the HTML. Then, by selecting the new class in the CSS file, we changed the font size. Menu Class Suffix and Menu Tag ID All core modules allow you to enter a Module Class Suffix, as discussed above. Menu modules have two additional parameters: Menu Class Suffix and Menu Tag ID. Let's look at what these parameters do. Menu Class Suffix The Menu Class Suffix inserts an extra suffix in the class for the unordered list that builds up the menu. If unedited, the class is "menu". If adding "_myMenuClass" under Advanced Parameters → Menu Class Suffix, the new tag will be "menu_myMenuClass".
  • 16. (This behaviour is only for the Menu Style "List". If choosing "Legacy - Vertical" or "Legacy - Horizontal", the class suffix will be added to the links in the table; this suffix will then be "mainlevel_myMenuClass". When choosing the Legacy Flat List, the suffix will be added to the links (as on the two other Legacy lists), but it will also be added to the ul tag, but as an id rather than a class; the id will be "mainlevel_myMenuClass".) Menu Tag ID parameter Now, lets look at the Menu Tag ID parameter. Navigate to the back end, open the Main Menu module for editing, and enter "myTagID" in the Menu Tag ID parameter. Add the following code to the end of the templates/rhuk_milkyway/css/template.css file: #myTagID{ list-style-type:square; } Now, re-display the Home page to see the change. The bullets for the Main Menu should now appear as squares, as shown below: Finally, we can look at the HTML and CSS in Firebug, as shown below. Joomla! has added the attribute id="myTagID" to the "ul" tag for the Main Menu. This allowed us to change the style for this ID. Note that, since this is an "id" attribute, we use the CSS selector #myTagID(with a "#" instead of a ".").
  • 17. Conclusion The Class Suffix and Menu Tag ID parameters allow you to fine-tune the CSS styling of your web site. By using a leading space in the suffix name, we can create a new class. This is normally the preferred method, since, as long as the new class name does not conflict with an existing class, no existing styling will be broken.