Recent Topics

1 Aug 06, 2006 03:30    

How can I include subcategories in the linkblog, or post titles in the categories?

2 Aug 08, 2006 21:40

This is just not working for me, trying to merge the _categories.php and _linkblog.php files. Now I have the posts simply stripped down to title and content, and sorted by category. But I'd like to at least make category group titles between the categories. Any suggestions?

3 Sep 10, 2006 22:28

I DID IT! I DID IT!

I created a file called content.php and replaced the posts section of the _main.php with it. I used [url=http://www.mattkruse.com/javascript/mktree/]this script by Matt Kruse[/url] to make the categories collapsable.

The content.php file is a combination of the _categories.php and _linkblog.php files. I changed this to make the main categories appear in bold print:

	/**
	 * callback to display sublist element
	 */
	function cat_list_before_each( $cat_ID, $level )
	{	// callback to display sublist element
		global $blogfilename, $cat_array, $cat_line_start, $cat_line_checkbox;
		$cat = get_the_category_by_ID( $cat_ID );
		echo $cat_line_start;
		
if( $level == 0) {
		echo '<b>'.format_to_output($cat['cat_name'], 'htmlbody').'</b>';echo "\n";
}
else {
		echo ''.format_to_output($cat['cat_name'], 'htmlbody').' <span class="dimmed">('.$cat['cat_postcount'].')</span>';echo "\n";
}

}

Then I stuck the linkblog stuff in here:

	/**
	 * callback to display sublist element
	 */

	function cat_list_after_each( $cat_ID, $level )
	{	// callback to display sublist element
global $cat_line_end;
		
if( $level > 0) {

echo '<ul>'; 

// Load the linkblog blog:
	$LinkblogList = & new ItemList( '8', array(), '', '', '', $cat_ID, $linkblog_catsel, '', 'ASC', 'category title', '', '', '', '', '', '', '', '', $linkblog_limit, 'posts', $timestamp_min, $timestamp_max );

	// Dirty trick until we get everything into objects:
	$saved_blog = $blog;  
	$blog = $linkblog;
		
	$previous_cat = '';
	$linkblog_cat = '';	

	while( $Item = $LinkblogList->get_category_group( ) ) 
	{	
	while( $Item = $LinkblogList->get_item() ) 
		{
echo $cat_line_end; 
echo '<li>'; 
$Item->title();
echo '</li>'; 

		}
	}	

	// Restore after dirty trick:
	$blog = $saved_blog;	

echo '</ul>'; 
echo $cat_line_end;

   }
}

The key was to put in the blog ID in the ItemList parameters ("8") and to change $linkblog_cat to $cat_ID. Once I figured that out, the rest was just cosmetics. One other bit was adding the "Expand" and "Collapse" links:

		echo '<span class="bSmallHead">* <a href="javascript:expandTree('contree')">Expand</a> * <a href="javascript:collapseTree('contree')">Collapse</a> *</span><p></p>';


One limit it has is that I can't have any links/posts directly under the main categories, because then all the ones in the subcategories show up under the main category too (IOW, show up twice). But it works exactly like I want it to, so YIPPEE!!!

I may still make some minor cosmetic changes, and still have content to add, but have a look: http://moonchild.ch/blog/bookmarks.php

4 Jan 07, 2007 16:49

Here's an example of an easy table of contents, simply using the current blog as linkblog.
Change this line in _linkblog.php:

		$Item->title( '', '', true );

to:

	$Item->permanent_link( '#title#' );

This is also a useful way to make a post-by-post archive (esp. when your app settings are monthly). You could jiggle the categories, orderby, limit and/or class. I'm using it for a [url=http://www.moonchild.ch/Tarot/faq/index.php?blog=5]Tarot FAQ[/url] and also for an "About Me" page.

5 Jan 07, 2007 17:15

Here's an example of a more complicated table of contents:
[url=http://moonchild.ch/iFAQ/index.php?blog=5]inFrequently Asked Questions[/url]

I have the content in blog 2 and the toc in blog 5, so I had to really hack (read: hatchet!) the thing. I created a content.php file to include in the main area. It's mostly copied from the categories file, so I had to change "cat" to "cont" so as not to screw up my categories. Also had to give it its own class.

<?php
	if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

	# You can customize the following as you wish:
	if(!isset($cont_all)) $cont_all = '';	// Set to empty to hide
	# global category list delimiters:
	if(!isset($cont_main_start)) $cont_main_start = '';
	if(!isset($cont_main_end)) $cont_main_end = '';
	# Category delimiters:
	if(!isset($cont_line_start)) $cont_line_start = '<li class="liOpen">'; // to load the tree as expanded
	if(!isset($cont_line_end)) $cont_line_end = '</li>';
	# Category group delimiters:
	if(!isset($cont_group_start)) $cont_group_start = '<ul>';
	if(!isset($cont_group_end)) $cont_group_end = '</ul>';
   # Category delimiters:  //RH
   if(!isset($maincat_group_start)) $maincat_group_start = '<ul class="contree" id="contree">';
   if(!isset($maincat_group_end)) $maincat_group_end = '</ul>';

	
	// ----------------- START RECURSIVE CAT LIST ----------------
	cat_query();	// make sure the caches are loaded
	if( ! isset( $cat_array ) ) $cat_array = array();
	
	/**
	 * callback to start sublist
	 */
	function cat_list_before_first( $parent_cat_ID, $level )
	{	// callback to start sublist
		global $cont_group_start;
		if( $level > 0 ) echo "\n",$cont_group_start,"\n";
	}
	
	/**
	 * callback to display sublist element
	 */
	function cat_list_before_each( $cat_ID, $level )
	{	// callback to display sublist element
		global $blogfilename, $cat_array, $cont_line_start, $cat_line_checkbox;
		$cat = get_the_category_by_ID( $cat_ID );
		echo $cont_line_start;

// link category headers
		echo '<b><a href="http://moonchild.ch/iFAQ/index.php?blog=2&cat='.$cat_ID.'">'.format_to_output($cat['cat_name'], 'htmlbody').'</b></a>';echo "\n";
}
	
	/**
	 * callback to display sublist element
	 */

	function cat_list_after_each( $cat_ID, $level )
	{	// callback to display sublist element
global $cont_line_end;

echo '<ul>'; 

// Load the linkblog blog:
	$LinkblogList = & new ItemList( '2', array(), '', '', '', $cat_ID, $linkblog_catsel, '', 'DESC', 'datemodified', $linkblog_limit, '', '', '', '', '', '', '', 'posts', $timestamp_min, $timestamp_max );

	// Dirty trick until we get everything into objects:
	$saved_blog = $blog;  
	$blog = $linkblog;
		
	$previous_cat = '';
	$linkblog_cat = '';	

	while( $Item = $LinkblogList->get_category_group( ) ) 
	{	
	while( $Item = $LinkblogList->get_item() ) 
		{
echo $cat_line_end; 
echo '<li>'; 
		$Item->permanent_link( '#title#' );
echo '</li>'; 

		}	

	// Restore after dirty trick:
	$blog = $saved_blog;	

echo '</ul>'; 
echo $cont_line_end;

   }
}
	
	/**
	 * callback to end sublist
	 */
	function cat_list_after_last( $parent_cat_ID, $level )
	{	// callback to end sublist
		global  $cont_group_end;
		if( $level > 0 ) echo $cont_group_end,"\n";
	}
	
	// Start global list:
	echo $cont_main_start;
	if( $blog > 1 )
	{	// We want to display cats for one blog
		echo "\n",$maincat_group_start,"\n"; 

		 // echo '<span class="bSmallHead">* <a href="javascript:expandTree('contree')">Expand</a> * <a href="javascript:collapseTree('contree')">Collapse</a> *</span><p></p>';


		cat_children( $cache_categories, '2', NULL, 'cat_list_before_first', 'cat_list_before_each', 'cat_list_after_each', 'cat_list_after_last', 0 );


		echo "\n",$cont_group_end,"\n";
	}

	
	// End global list:
	echo $cont_main_end;	// Close the global list

	// ----------------- END RECURSIVE CAT LIST ----------------
		// echo '<span class="bSmallHead">* <a href="javascript:expandTree('contree')">Expand</a> * <a href="javascript:collapseTree('contree')">Collapse</a> *</span><p></p>';


?>


The Expand and Collapse links are for later, when there is more content.

Then I ran into the problem of the linked categories in the TOC not matching the sidebar categories, so I added to the skin/_categories.php:

		// Call the Categories plugin:
	$Plugins->call_by_code( 'evo_Cats', array(	// Add parameters below:
$blog = 2,
$page = '',
'link_type'=>context,
'option_all'=>$cat_all,
'block_start'=>'<div class="bSideCats">',

There was also some miscellaneous style tweaking, which really isn't finished yet. But I wanted to post this before I forget! I've gotten so much help on this forum, but there is really no useful info on TOCs (that I've found). So I hope this info will help others who want to try something similar.

6 Jan 07, 2007 21:58

Hey these look good to me. Can you show the line you're adding to your _main.php file in order to call the content.php file? Oh and I would suggest renaming it "_content.php" just to go with the flow re file name conventions.

7 Jan 07, 2007 23:37

	<div class="bPost">

	<?php // ------------------- TABLE OF CONTENTS INCLUDED HERE --------------
		require( dirname(__FILE__).'/_content.php' );
		// --------------------- END OF TABLE OF CONTENTS ---------------- ?>
			
	</div>


That's it.
I'm so excited that I am able to do this! Now I have to start on the other half of my project--the unanswered iFAQ, which may be a bit more challenging. I love it. = P

8 Jul 23, 2007 01:35

I just realized something I overlooked when writing previously about using the linkblog as a TOC. I had to change this line in _linkblog.php:

		$Item->title( '', '', true );

to:

	$Item->permanent_link( '#title#' );

This is also a useful way to make a post-by-post archive (esp. when your app settings are monthly). You could jiggle the categories, orderby and/or limit. I'm using it for an "About Me" page.

9 Jul 23, 2007 14:33

Moonchild, maybe it would be nice if you edited your first post to sum up what you are doing... :)

10 Jul 23, 2007 16:33

Done, but now how do I delete the recent post?

12 Jul 23, 2007 17:23

No, the post I edited is #48891. The one(s) I want deleted would be the post I made yesterday ("recent," i.e. June 22) that you replied to (and after). See?

13 Jul 24, 2007 00:22

Deletion of posts doesn't matter most of the time. Makes more sense over time to leave things where they are - unless the whole topic is going to go away. My two cents eh?

14 Oct 06, 2007 02:04

The tables of contents I've made using the _content.php file are restricted in that each post can only be assigned to one category. In the first instance ([url=http://moonchild.ch/blog/bookmarks.php]bookmarks[/url]), they are all assigned to parent categories, and the post titles are linked to their individual urls. In the second instance ([url=http://www.moonchild.ch/Tarot/faq/index.php?blog=3]Tarot FAQ[/url]), they are all assigned to child categories, and the post titles are linked to their permanent links. Using the linkblog as a table of contents puts children categories on the same level with parent categories, so with that I can only use parent categories as well.

Now I've got one that lists permalinked titles under parent categories and ignores children. This is useful to me because I have a [url=http://moonchild.ch/sales/index.php?blog=7&skin=custom]used books for sale[/url] blog. I had to create a bunch of subcategories for ebay listings. I don't want to get rid of those subcategories right away, but didn't want them showing up on my [url=http://moonchild.ch/sales/index.php?blog=7&disp=arcdir]complete list of titles by genre.[/url]

I basically trimmed the _content.php file and put it in _arcdir.php. I used the LinkblogList to set the order and number of posts. The posts are listed by author, or "titleby"--a field I added. The file is basically an archive bit, inside a linkblog thing, in the middle of the recursive categories list. I probably should just change the word linkblog wherever it appears, to reduce confusion. I don't think there's anything of the linkblog left.

<?php
	/**
	 * This is the template that displays post titles by category 
	 *
	 * This file is not meant to be called directly.
	 * It is meant to be called by an include in the _main.php template.
	 *
	 * b2evolution - {@link http://b2evolution.net/}
	 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
	 * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
	 *
	 * @package evoskins
	 */

# global category list delimiters:
	if(!isset($cat_main_start)) $cat_main_start = '<div>';
	if(!isset($cat_main_end)) $cat_main_end = '</div>';
	# Category delimiters:
	if(!isset($cat_line_start)) $cat_line_start = '<li>';
	if(!isset($cat_line_end)) $cat_line_end = '</li>';
	# Category group delimiters:
	if(!isset($cat_group_start)) $cat_group_start = '<ul>';
	if(!isset($cat_group_end)) $cat_group_end = '</ul>';
	
	// --- //

	/*
	 * WARNING: the category list is displayed recursively.
	 * This is a little tricky. Don't modify below unless you really know what you're doing!
	 */
	
	// ----------------- START RECURSIVE CAT LIST ----------------
	cat_query( '', 'T_posts', 'post_', 'post_ID');	// make sure the caches are loaded
	if( ! isset( $cat_array ) ) $cat_array = array();
	
	/**
	 * callback to start sublist
	 */
	function cont_list_before_first( $parent_cat_ID, $level )
	{	// callback to start sublist
		global $cat_group_start;
		echo "\n",$cat_group_start,"\n";
	}
	
	/**
	 * callback to display sublist element
	 */
	function cont_list_before_each( $cat_ID, $level )
	{	// callback to display sublist element
		global $tab, $blog, $cat_array, $cat_line_start, $cat_line_end;
		$cat = get_the_category_by_ID( $cat_ID );

if( $level == 0) {
		echo "\n",$cat_line_start,"\n";
		echo '<span class="mainCat">'.format_to_output($cat['cat_name'], 'htmlbody').'</span> <span class="dimmed">('.$cat['cat_postcount'].')</span>';echo "\n";
		
echo '<ul><!-- item list start-->';

// Load the linkblog blog:
   $LinkblogList = & new ItemList( $blog, array(), '', '', '', $cat_ID, '', '', 'ASC', 'titleby', '99');

   while( $Item = $LinkblogList->get_item() )
      {

echo '<li><!-- item start-->';
echo $Item->titleby(); echo ' -- '; 
echo '<a href="';
				permalink_link( '', 'id', $post_ID );
				echo '">';
				$Item->title('', '', false);
echo '</a>';
echo '<!-- item end--></li>';

      }

echo "<!-- item list end--></ul>\n";

echo "\n",$cat_line_end,"\n";
}

	}
	
	/**
	 * callback to end sublist element
	 */
	function cont_list_after_each ( $cat_ID, $level ) {;}
	
	/**
	 * callback to end sublist
	 */
	function cont_list_after_last( $parent_cat_ID, $level )
	{	// callback to end sublist
		global  $cat_group_end;
		echo "\n",$cat_group_end,"\n";
	}
	
	// Start global list:
	echo $cat_main_start;
	if( $blog > 1 )
	{	// We want to display cats for one blog
		cat_children( $cache_categories, $blog, NULL, 'cont_list_before_first', 'cont_list_before_each', 'cont_list_after_each', 'cont_list_after_last', 0 );
	}


	// ----------------- END RECURSIVE CAT LIST ----------------
	
	
	// End global list:
	echo $cat_main_end;	// Close the global list

?>


In _main.php, I put the link under the categories in the sidebar.

<?php
$realurl = sprintf("%s%s%s","http://",$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI']);
?>
			<h3><a href="<?php echo $realurl ?>&disp=arcdir">Complete list of titles</a></h3>

Also added a mainCat class to the .css, to make the category names stand out.

The ebay subcategories (in the sidebar) are for a template I created to paste into the item description field on ebay. VERY useful! Thank you, b2evolution! If you want to see that, click on one of the categories, then type onto the url "[url=http://moonchild.ch/sales/index.php?blog=7&cat=46&skin=ebay]&skin=ebay[/url]&quot;.


Form is loading...