Recent Topics

1 May 17, 2010 02:02    

My b2evolution Version: 3.3.3

I'd like to show the name of a category on top of a page with those posts. I can use request_title, but then it puts "Category: " at the beginning, which seems awkward. I'd rather it just say the name of the category.

In general, I have the hardest time figuring out options for a template tag or other code. What's the best way? The online docs don't seem to do it, such as this one:
http://doc.b2evo.net/HEAD/evocore/_blogs---inc---_core---_template.funcs.php.html

It does list a few for request title, but doesn't list others, like title_before .

Thanks in advance for any help!

2 May 17, 2010 03:47

I'd like to show the name of a category on top of a page with those posts.

Sound like the perfect scenario for an Intro (post type Intro-Cat).

Type what you want it to say at the top of the page... assign the category... boom! You're done.

... almost. ;)

Just comment out the whole request_title() section from your posts.main.php after you make an Intro for every category if you don't like the - Category: Name thing showing up.

Don't know if it will cause problems anywhere else, but it works for me with no bad side effects.

EDIT: Might not be the best solution, as it doesn't take into account Latest Comments or Archives titles.

3 May 17, 2010 09:30

Yep.. there are hell lot of parameters but not one for category text afai see..

#
function request_title( $params = array() )
#
{
#
global $MainList, $preview, $disp;
#

#
$r = array();
#

#
$params = array_merge( array(
#
'auto_pilot' => 'none',
#
'title_before' => '',
#
'title_after' => '',
#
'title_none' => '',
#
'title_single_disp' => true,
#
'title_single_before' => '#',
#
'title_single_after' => '#',
#
'title_page_disp' => true,
#
'title_page_before' => '#',
#
'title_page_after' => '#',
#
'glue' => ' - ',
#
'format' => 'htmlbody',
#
'arcdir_text' => T_('Archive Directory'),
#
'catdir_text' => T_('Category Directory'),
#
'mediaidx_text' => T_('Photo Index'),
#
'postidx_text' => T_('Post Index'),
#
'search_text' => T_('Search'),
#
'sitemap_text' => T_('Site Map'),
#
'msgform_text' => T_('Send an Email Message'),
#
'profile_text' => T_('User Profile'),
#
'user_text' => T_('User'),
#
'subs_text' => T_('Subscriptions'),
#
'comments_text' => T_('Latest Comments'),
#
'feedback-popup_text' => T_('Feedback'),
#
), $params );

no worries though, it's in the TODO.

Todo: make it complete with all possible params!

4 May 17, 2010 10:53

This is already possible. Add the following to your request_title function:

'category_text' 	  => '',

So mine looks like:


					request_title( array(
							'title_before'=> '<h2 class="requesttitle">',
							'title_after' => '</h2>',
							'title_none'  => '',
							'glue'        => ' - ',
							'title_single_disp' => false,
							'title_page_disp' => false,
							'format'      => 'htmlbody',
							'category_text' 	  => '',
						) );

L

5 May 17, 2010 11:42

i kind of remembered sth like that, but couldnt figure what it was , thank you lee.. wonder why it was not in doc. head

6 May 17, 2010 12:08

No worries, not sure about the docs. I'll add it when I have a mo. I tend to bypass the docs and go straight for the code so I didn't realise it wasn't there.

L

7 May 24, 2010 01:10

Thanks! Good to know about 'category_text'

8 May 24, 2010 17:25

One more question -- is there a way for request_title to show a top level category name without showing all of the sub categories? Thanks a lot.

9 May 24, 2010 21:50

webadmin wrote:

One more question -- is there a way for request_title to show a top level category name without showing all of the sub categories? Thanks a lot.

I couldn't think of an easy way to do that, however i agree with you in the necessity of that one.. If you have many sub-cats the title grows too long.

11 Dec 08, 2010 19:26

Are you talking about in the page title ?

L

12 Dec 08, 2010 20:02

Yes, I want the page title to not be "Category-XXX". Just "XXX" would work fine.

13 Dec 08, 2010 20:43

Did you add the

'category_text'      => '', 

to the request_title in the header?

L

14 Aug 02, 2011 21:09

The: 'category_text' => '', addon only works when a category without any subcategories is selected.

Is there a way for a category with sub-categories to display only the current category name, without 'Categories:', or any of the subcategories?

I've checked the _template.funcs.php file, but I don't see where this is being pulled from.

I think it might be defined in the $Blog class, or in the variable $r, which is returned from $Blog->get('name'); function, I think.

I just want *this* category to display... Sounds simple enough. :-/

15 Aug 03, 2011 00:18

Figured it out.

Add: 'categories_text' => '',

i.e. my request looks like this:

request_title( array(
	'title_before'=> '<h2 style="font-size:1.6em">',
	'title_after' => '</h2>',
	'title_none'  => '',
	'glue'        => ' - ',
	'title_single_disp' => true,
	'format'      => 'htmlbody',
	'category_text' => '',
	'categories_text' => '',
) );

Then edit the following file: \inc\items\model\_itemlistlight.class.php

Change lines 947 - 953 from:

foreach( $this->filters['cat_array'] as $cat_ID )
{
	if( ($my_Chapter = & $ChapterCache->get_by_ID($cat_ID, false) ) !== false )
	{ // It is almost never meaningful to die over an invalid cat when generating title
		$cat_names[] = $my_Chapter->name;
	}
}

to:

$cat_ID = current( $this->filters['cat_array'] ); 
if( ($my_Chapter = & $ChapterCache->get_by_ID($cat_ID, false) ) !== false )
{ // It is almost never meaningful to die over an invalid cat when generating title
	$cat_names[] = $my_Chapter->name;
}

This makes the function only return the first category, which will always be the top category.

I've tested this solution on my site, and it works unconditionally so far.


Form is loading...