Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Page & Category Menu Bars »

Category description & category classes


  #1  
Old Mar 19, 2009, 02:52 PM
shedhed's Avatar
shedhed
 
52 posts · Mar 2009
Bramhall, UK
I'm trying to modify the category horizontal menu to do two things:-

Firstly to incorporate the category description under the actual category. I appreciate that this is available as a "hover" option but I'm trying to show it permanently.

Secondly I'm looking to limit the categories to 5 of my choice through the theme options (done), set them to 20% width (done) and style their colours/hover colours individually. To do this last bit I think I need individual li classes on each category so that I can style them one by one. Only the current li gets a class.

I've mooched about where this code is generated and I think it's in bfa_hor_cats.php - here's an example:-

Code:
$list_cat_string = preg_replace("/<li class=\"(cat-item|cat-item cat-item-[0-9]+)(.*?)\n<ul class='children'>/i","<li class=\"rMenu-expand\\2\n <ul class=\"rMenu-ver\">",$list_cat_string);
Now using shedhed's law of tinkering with code when you have no idea what you're doing I eventually got round to removing the pipe symbol thus:-

Code:
$list_cat_string = preg_replace("/<li class=\"(cat-item cat-item cat-item-[0-9]+)(.*?)\n<ul class='children'>/i","<li class=\"rMenu-expand\\2\n <ul class=\"rMenu-ver\">",$list_cat_string);
This ends up with with the category li's having a class, eg:-

HTML Code:
<li class="cat-item cat-item-13"><a title="blah." href="http://blah/wordpress/category/blah/">Blah blah</a>
</li>
By doing this have I broken something that I don't know about - I'm a complete php novice and lethal with it. If I have is there a way to get classes on each category?

Any help with either of the above gratefully received.

Thanks, Andy
  #2  
Old Mar 20, 2009, 04:01 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
What you did will be the standard from version 3.2.1 on - I am adding back all extra classes that Wordpress adds throughout a site, and even add some more

I had removed some of the default classes/IDs as they weren't used by Atahualpa but I realized that having classes and an ID on just about any element easily outweighs the disadvantage of a more cluttered code
  #3  
Old Mar 21, 2009, 02:51 PM
shedhed's Avatar
shedhed
 
52 posts · Mar 2009
Bramhall, UK
Flynn,

Thanks for your reply - appreciated.

Having all those classes available in the next issue will be good news.

Do you have any guidance on how to add the category description to the horizontal category menu bar? I'm trying to get the description to appear beneath its menu item permanently rather than rely on the hover.

Thanks in advance,

Andy
  #4  
Old Mar 21, 2009, 03:35 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
In functions/bfa_hor_cats.php change

PHP Code:
if ($titles == "No") { $list_cat_string reg_replace("/title=\"(.*?)\"/i","",$list_cat_string);}
return 
$list_cat_string;
}
?> 
to

PHP Code:
$list_cat_string = preg_replace_callback("|title=\"(.*?)\">(.*?)</a>|","add_title_to_anchor",$list_cat_string);
if ($titles == "No") { $list_cat_string = reg_replace("/title=\"(.*?)\"/i","",$list_cat_string);}
return $list_cat_string;
}
?>
<?php
function add_title_to_anchor($matches) {
return 
'>'.$matches[2].'<br /><span class="cat-descr">'.$matches[1].'</span></a>';
}
?>
And at A. Theme Options -> HTML/CSS Inserts -> CSS Inserts add something like this

HTML Code:
span.cat-descr {
text-transform: none;
font-size: 90%;
color: #dddddd;
}
to style the description text, i.e. make the font smaller and don't capitalize the words (as Atahualpa does with Page and Category names in menu bars, in its default setting)

if you haven't set a description for a category (at Site Admin -> Categories -> Edit -> Description) then the text will be "View all posts filed under [Category Name]". To show the description only if a description was set, and otherwise display nothing instead of "View all posts....", replace the last part in the code above, this one

PHP Code:
 <?php
function add_title_to_anchor($matches) {
return 
'>'.$matches[2].'<br /><span class="cat-descr">'.$matches[1].'</span></a>';
}
?>
with this one:

PHP Code:
 <?php
function add_title_to_anchor($matches) {
if (
strpos($matches[1],'View all posts filed under')!==FALSE) {
return 
'>'.$matches[2].'</a>';
} else {
return 
'>'.$matches[2].'<br /><span class="cat-descr">'.$matches[1].'</span></a>';
}
}
?>
  #5  
Old Mar 22, 2009, 01:25 AM
shedhed's Avatar
shedhed
 
52 posts · Mar 2009
Bramhall, UK
Flynn,

Brilliant - exactly what I was after. Thank you.


Andy

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing category order in category menu bar, not in sidebar cat. list paulae Page & Category Menu Bars 13 Mar 30, 2011 05:36 PM
Combining Category &amp;amp; Pages menu Masselyn Page & Category Menu Bars 12 Mar 2, 2010 05:07 PM
Category title on category page, not on each post excerpt kicker paulae Excerpts, Read more, Pagination 4 Jun 22, 2009 11:33 AM
TUI's Category Description for Archive Not Working sleizure Plugins & Atahualpa 1 May 29, 2009 02:05 PM
Category & Date archives Cosmic Comix & Toys Forum How-To 1 Mar 8, 2009 05:15 AM


All times are GMT -6. The time now is 05:47 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.