How to change main page slideshow.

The network theme has that nice slideshow that shows all of the other sites on the network. (Awesome.) What I need to do is change what image and text is generated for the subsites.
Were it shows an image from a post on the subsite, I'd like it to display a logo from the subsite.
Were it has the post excerpt I'd like it to echo 'bloginfo(name)' and were it currently shows the subsite's name, I'd like it echo 'bloginfo(description)' .
I imagine this will be pretty easy to do, if I knew which file to edit. I do not know which file to edit.

  • Timothy Bowers

    Hey there Josh.

    The function which does this is get_recent_posts and you can find that around line 387 in the following file:

    /network/library/functions/custom-functions.php

    I presume with your knowledge of those functions that you should be fine to code that up, please do let us know how you get on, perhaps even share your site url once done. It might inspire others. :slight_smile:

    Take care.

  • Josh Pollock

    Timothy-

    Thanks for the help.

    So I edited the function "get recent posts." I'm pretty sure that is what you were referring to. I pasted it below, my changes are in the end of the huge last line (not sure why it shows up that way) I was just aiming to get the bloginfo(name) and bloginfo(description) to show up as I wanted them to. I am going to need to find/ create a function for defining a logo for each blog to replace the post thumbnail in this function with for that.
    What I changed did not have any effect on the main page slideshow nor did it cauce any errors... Hmmm, maybe I needed to mess with the "get_list_of_blogs()" function that is 2 functions above it. I dunno, I'm royally confused.

    -Josh

    function get_recent_posts($how_many=10000, $how_long=0, $homepage_show_thumbnails = "yes", $titleOnly=true, $begin_wrap="\n<li>", $end_wrap="</li>") {
    	global $wpdb;
    	global $table_prefix;
    	global $blog_id;
    	$blog = $blog_id;
    	$counter = 0;
    
    	if ($blog != 1){
    		$blogOptionsTable = $wpdb->base_prefix.$blog."_options";
    		$blogPostsTable = $wpdb->base_prefix.$blog."_posts";
    		$blogPostsMetaTable = $wpdb->base_prefix.$blog."_postmeta";
    	}
    	else{
    		$blogOptionsTable = $wpdb->base_prefix."options";
    	   	$blogPostsTable = $wpdb->base_prefix."posts";
    	}
    
    	if ($how_long > 0) {
    		$thisposts = $wpdb->get_results("SELECT ID, post_title
    			FROM $blogPostsTable WHERE post_status = 'publish'
    			AND ID > 0
    			AND post_type = 'post'
    			AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL $how_long DAY)
    			ORDER BY id DESC LIMIT $how_many");
    	} else {
    		$thisposts = $wpdb->get_results("SELECT ID, post_title
    			FROM $blogPostsTable WHERE post_status = 'publish'
    			AND ID > 0
    			AND post_type = 'post'
    			ORDER BY id DESC LIMIT $how_many");
    
    	}
    
    	$default_thumbnail_url = get_option('dev_network_homepage_default_thumbnail_url');
    
    	if (sizeof($thisposts) > 0) { 
    
    		$options = $wpdb->get_results("SELECT option_value FROM
    			$blogOptionsTable WHERE option_name IN ('siteurl','blogname')
    			ORDER BY option_name DESC");
    
    		foreach ($thisposts as $thispost) {
    			$thispermalink = get_permalink($thispost->ID);
    					if ($homepage_show_thumbnails == "yes") { 
    
    					?>
    					<li class="withthumb">
    
    					<?php
    
    					} else {
    
    					?>
    					<li>
    					<?php
    					}
    
    			if ($homepage_show_thumbnails != "no") {
    				if(is_multisite()){
    				switch_to_blog($blog);
    			}
    					$thumbnail = get_image_path($thispost->ID, $blog);
    						if(is_multisite()){
    						restore_current_blog();
    					}
    
    			?>
    		<?php
    			if ( is_multisite() ) {
    
    				if ($thumbnail != '') { ?>
    						<img src="<?php bloginfo('template_directory'); ?>/library/functions/timthumb.php?src=<?php echo $thumbnail; ?>&h=108&w=227&zc=1&multisite=false&blogdirid=<?php echo $blog; ?>" alt="" style="width:227px; height: 108px;" />
    					<?php } else if ($default_thumbnail_url != '') { ?>
    						<div class="thumb"><a href="<?php $thispermalink; ?>"><img src="<?php echo $default_thumbnail_url; ?>" alt="" /></a></div>
    					<?php } 	else { ?>
    								<div class="thumb"><a href="<?php echo $thispermalink; ?>"><img src="<?php bloginfo('template_directory'); ?>/_inc/images/placeholders/article.jpg" alt="" /></a></div>
    							<?php }
    						}
    			else{
    				if ($thumbnail != '') { ?>
    							<img src="<?php bloginfo('template_directory'); ?>/library/functions/timthumb.php?src=<?php echo $thumbnail; ?>&h=108&w=227&zc=1&multisite=false&blogdirid=<?php echo $blog; ?>" alt="" style="width:227px; height: 108px;" />
    					<?php } else if ($default_thumbnail_url != '') { ?>
    						<div class="thumb"><a href="<?php $thispermalink; ?>"><img src="<?php echo $default_thumbnail_url; ?>" alt="" /></a></div>
    					<?php } else { ?>
    							<div class="thumb"><a href="<?php echo $thispermalink; ?>"><img src="<?php bloginfo('template_directory'); ?>/_inc/images/placeholders/article.jpg" alt="" /></a></div>
    						<?php }
    			}
    
    			?>
    
    					<?php }
    
    					?>
    
    						<h2><a href="<?php echo $thispermalink; ?>"><?php echo 'bloginfo(name)';?></a></h2>
    			<?php
    				if (isset($options) && sizeof($options) > 0 && $options[0]->option_value != '') {
    			?>
    
    			<h3><?php echo 'bloginfo(description)'; ?></a></h3>
    			<?php
    			}
    
    			echo '
    				  </li>';
    
    		}
    		if($counter >= $how_many) {
    			break;
    		}
    	}
    
    }
  • Timothy Bowers

    I'd have to have a play but before doing so I just want to make sure I have this right.

    For the image, if you want a custom site logo you would need to create some function and input options for that. Just letting it use the posts image would be easiest.

    Anyway, so:

    IMAGE
    bloginfo(name)
    bloginfo(description)

    You don't want any article content right? What happens if a site released multiple articles, it would mean their image, name and desc would appear multiple times on the front page.

    Would you want that?

    Take care.

  • Josh Pollock

    Timothy, thanks again for your help. You are right about how the layout of the slideshow cards should go. I don't want to use the post image beacuse then it would change every time time there is a new post. What I want to show are logos for the subsites on my network.

    I'm attaching my most basic flowchart for this project. I will have one parent site, which will use the network theme and 90% of the time will only show the main site. It will show links to the subsites in the slideshow. I want the admin of each subset to be able to change what shows up in that slideshow on the parent site, without being an admin of the parent site. I figured by using bloginfo() each subsite's admin could set the name and description in the general settings in their subsite's dashboard.
    I was planning on using this function:

    function replace-wp-logo() {
        echo '<style type=&quot;text/css&quot;>
        h1 a { background-image:url('.get_bloginfo('template_directory').'/images/logo.png) !important; }
        </style>';
        }
        add_action('login_head', 'replace-wp-logo');

    (which I found here:http://wordpress.org/support/topic/functionsphp-change-logo-and-link-login-page) for changing the login page image anyways, so I figured I could just use that same url from the function ('background-image:url('.get_bloginfo('template_directory':wink:.'/images/logo.png) !important;':wink: for putting the logo into the parent site using the function we are talking about editing.

  • Timothy Bowers

    Looking into this further, I see I was mistaken. It is actually on line 529 and its function multisite_recent_posts().

    I only suggested keeping the article image because otherwise if a site made ten updates their logo would dominate your front page.

    The thumbnail is made on line 608:

    <?php if ($thumbnail != '') { ?>
    					<img src="<?php bloginfo('template_directory'); ?>/library/functions/timthumb.php?src=<?php echo $thumbnail; ?>&h=108&w=227&zc=1&multisite=true&blogdirid=<?php echo $blog; ?>" alt="" style="width:227px; height: 108px;" />
    					<?php } else if ($default_thumbnail_url != '') { ?>
    						<div class="thumb"><a href="<?php $thispermalink; ?>"><img src="<?php echo $default_thumbnail_url; ?>" alt="" /></a></div>
    					<?php } 	else { ?>
    							<div class="thumb"><a href="<?php echo $thispermalink; ?>"><img src="<?php bloginfo('template_directory'); ?>/_inc/images/placeholders/article.jpg" alt="" /></a></div>
    						<?php } ?>

    And the current text is line 618:

    <h2><a href="<?php echo $thispermalink; ?>"><?php echo limit_words($thispost[0]->post_title, 5); ?></a></h2>
    						<h3><a href="<?php echo $options[0]->option_value; ?>"><?php echo $options[1]->option_value; ?></a></h3>

    That should give you clear guidance, it is those parts you need to replace to suit your needs.

    Let me know if you still need any further guidance.

    Take care.

  • Josh Pollock

    So, I set the slideshow to ignore posts from every site but itself. Now I think I have two options:
    A nonautomated system: Everythime a subsite was created I could create a page (on the parent site) that redirects to the homepage of that site using the page links to plugin. I could then add the logo for the subsite to that group.
    Or I could figure out how to automate this process as part of the site creation process.

    The first option will work for building a demonstration version of the site, but I'll need that second option eventually.

  • Timothy Bowers

    You could style the plugin directly from your theme files if needed.

    You could even mess around with the layout code as well. Just keep in mind the more core files you edit the more you have to do upon every update.

    You could continue with the Network theme, I see what you are looking for now. Perhaps the directory plugin will give you some ideas for the code to use.

    The way the Network theme works there is it doesn't display new sites, it displays new content. So you would need to consider making a totally custom function for just pulling the latest and newest blog.

    Take care.

  • aecnu

    Greetings josh_pollock,

    We have not heard back from you as to the status of this issue.

    If you are still having an issue please let us know so that we may try to get you fixed up as soon as possible by choosing to check mark this ticket as unresolved below and posting any new errors or symptoms you are noticing.

    This action will also bring your ticket up front back in plain view again within the ticket system.

    Thank you for being a WPMU Dev member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.