ThemeShaper Forums » Thematic

[closed]

Multiple Blogs to my site

(1 post)
  • Started 4 years ago by fedude
  • This topic is resolved
  1. fedude
    Member

    I’ve seen a few people asking about how to make a site capable of hosting multiple blogs using thematic child themes. Chris pointed to the “page Links To” plugin with the suggestion that you could accomplish this by just filtering on the post category of specific pages. All using a single blog.

    I spent some time implementing this using thematic and I figured I’d share how I did it in hopes of saving someone else time .

    My blog has 4 categories and I wanted to have 4 pages on my site each displaying all the posts for a single category. I also wanted to have these pages seem like they were just normal pages on my site (and not look like post archive pages). The typical category page only includes a snippet of each post and I wanted the entire post on the page. I have ~20 static pages on my site including the start page. The 4 blog pages are nestled deep inside my site.

    First: Install the “Page Links To” plugin. This puts a new option on the bottom of your page editor in the admin panel. The idea is to use this link to point to the page containing a certain category. For instance, you could enter this in the Page Links To entry for a specific page:

    http://mysite.com/blog/category/techposts/

    This page will now show all of a certain category of posts. I did this for all 4 pages.

    If you are happy with the layout of the page, you’re done. Unfortunately, I wasn’t. I wanted the blog pages to fit into the design of the rest of the site. So, I needed to make changes to the layout of the category pages. I could have done a lot of this simple with CSS, but I’m not very fluent in CSS and besides I wanted to learn about the thematic theme structure.

    Next I copied the category.php from the thematic directory into my child theme directory. I now can edit this and when the category.php is called by the link above it will use the one in my child theme first.

    Here is what the final version looked like (not really too much left of it):

    <?php
    global $options;
    foreach ($options as $value) {
        if (get_option( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; }
        else { $$value['id'] = get_option( $value['id'] ); }
        }
    ?>
    <?php get_header() ?>
    	<div id="container">
    		<div id="content">
    			<?php my_news_page_title() ?>
    			<?php thematic_categoryloop() ?>
    		</div><!-- #content -->
    	</div><!-- #container -->
    <?php thematic_sidebar() ?>
    <?php get_footer() ?>

    I took out all but the basics. I can format the basics using CSS, but the problem was that I had to put stuff not normally in the category list into the page. To do that I copied 4 functions from the content-extensions.php file to my functions.php file.

    1. thematic_category_loop()
    2. thematic_page_title()
    3. thematic_postheader()
    4. thematic_content()

    I replaced the text “thematic” with “my_news” in the function names so as not to have namespace collisions. I edited them heavily to include only what I wanted to be in the page when it rendered. Here is what they look like post editing:

    // The Category Loop
    function my_news_category_loop() {
    	while (have_posts()) : the_post(); ?>
    		<?php my_news_postheader()?>
    		<div id="thepost" class="post-class">
    		<div class="entry-content">
    
    		<?php my_news_content(); ?>
    
    		</div><!-- entry-content -->
    		</div><!-- #thepost -->
    
    	<?php endwhile;
    }
    add_action('thematic_categoryloop', 'my_news category_loop');
    
    function my_news_page_title() {
    		$content = '';
    		if (is_category()) {
    				$content .= '<h1 class="entry-title">';
    				$content .= single_cat_title('', FALSE);
    				$content .= '</h1>' . "\n";
    		}
    		$content .= "\n";
    		echo apply_filters('thematic_page_title', $content);
    }
    
    // Send the post title and publish date
    
    function my_news_postheader() {
        global $id, $post, $authordata;
        $posttitle = '<h1 id="post-title">' . get_the_title() . "</h1>\n";
    
        $posttitle = apply_filters('thematic_postheader_posttitle',$posttitle); 
    
        $postmeta = '<div id="post-info">';
        $postmeta .= __('By ', 'thematic');
        $postmeta .= get_the_author();
        $postmeta .= ' | ';
        $postmeta .= ' ' . __('Published: ', 'thematic');
        $postmeta .= get_the_time(thematic_time_display());
    
        $postmeta .= "</div>\n";
        $postmeta = apply_filters('thematic_postheader_postmeta',$postmeta); 
    
        $postheader = $posttitle . $postmeta;    
    
        echo apply_filters( 'thematic_postheader', $postheader );
    } // end my_news_postheader
    
    //creates the post body
    function my_news_content() {
    
    	$content = 'full';
    	$content = apply_filters('thematic_content', $content);
    
    	$post = get_the_content(more_text());
    	$post = apply_filters('the_content', $post);
    	$post = str_replace(']]>', ']]>', $post);
    
    	echo apply_filters('thematic_post', $post);
    
    } // end my_news_content

    So far, so good, but I am seeing two entries for each post in my pages. My updated changes followed by the original post format. To get rid of the original, I had to remove the current action on thematic_categoryloop which you can see gets called from my edited category.php

    function remove_actions() {
    	remove_action('thematic_categoryloop', 'thematic_category_loop');
    }
    add_action('init', 'remove_actions');

    Finally, I had to style the information with CSS. Not easy, but I'm a lot further along than I could have been without these mods.

    One drawback to this is that I can no longer use the category.php file for it’s original design. This isn’t a problem for me but it might be for others

    I hope this helps others. I’m committed to thematic because it looks like a real time saver once I get up-to-speed. If anyone has a better way to do this, I’m all ears. Comments appreciated.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.