Powered by MediaWiki
Personal tools

Make a skin based on my proper layout

From b2evolution manual

Jump to: navigation, search

This manual page refers to b2evolution version 0.9.x. See Create a new skin for the 1.8+ version of this guide

Lets make a few assuptions :

  1. You want to show blog 2/Blog A/ the first blog after the aggragator/the blog where your posts are in if you upgraded from another tool
  2. Your linkblog is in blog 4. If you don't have posts in blog 4, nothing will show
  3. You want to show your articles 'the blog way', that is the last article entered is shown as first one
  4. You will use skins (of course, that is the purpose of this post) and your skin is named 'MySkin'
  5. You have your own page, you designed your page the way you want, with css-stylesheet or not, you made the layout with tables or divs.
  6. On the place where you want your articles to appear you have a placeholder (you can easily find the place where you want your articles to appear.)

Contents

[edit] Make a stubfile

Make a file, like this one, and save that in the root directory of your blog as mystub.php (yes correct, you made a stubfile) <source lang="php"> <?php $blog = 2; $skin = 'MySkin'; $show_statuses = array(); // this is the way to show published pots to everybody, protected posts to members and private posts to yourself $blogroll_blog = 4; $blogroll_cat = ; $blogroll_catsel = array( ); $timestamp_min = ; $timestamp_max = 'now'; include(dirname(__FILE__)."/b2evocore/_blog_main.php"); ?> </source>

[edit] Fill your own file with the b2e-code

Assuption : you have created a file in the layout that you want, and at the place where you want your articles to appear, you put a placeholder: 'posts appear here'

Now lets move on to those famous skins. Make a copy of the custom skin, and rename it MySkin.

So now we have made a new skinfolder named MySkin

rename _main.php to _main-backup.php (we will use this file a lot in the folowing instructions)

rename your own file to _main.php

open _main.php (that is your file) and put this code on top (as FIRST lines):

<source lang="php"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">   </source>

Replace your title tag with <source lang="php"> <title><?php $Blog->disp('name', 'htmlhead'); single_cat_title( ' - ', 'htmlhead' ); single_month_title( ' - ', 'htmlhead' ); single_post_title( ' - ', 'htmlhead' ); arcdir_title( ' - ', 'htmlhead' ); last_comments_title( ' - ', 'htmlhead' ); stats_title( ' - ', 'htmlhead' ); ?> </title> </source>

Put this in the head-tag It's possible you have other things there, so put these under or above, but between <head> and </head> <source lang="php"> <base href="<?php skinbase(); // Base URL for this skin. You need this to fix relative links! ?>" /> <meta name="description" content="<?php $Blog->disp( 'shortdesc', 'htmlattr' ); ?>" /> <meta name="keywords" content="<?php $Blog->disp( 'keywords', 'htmlattr' ); ?>" /> <meta name="generator" content="b2evolution <?php echo $b2_version ?>" /> <link rel="alternate" type="text/xml" title="RDF" href="<?php $Blog->disp( 'rdf_url', 'raw' ) ?>" /> <link rel="alternate" type="text/xml" title="RSS .92" href="<?php $Blog->disp( 'rss_url', 'raw' ) ?>" /> <link rel="alternate" type="text/xml" title="RSS 2.0" href="<?php $Blog->disp( 'rss2_url', 'raw' ) ?>" /> <link rel="alternate" type="application/atom+xml" title="Atom" href="<?php $Blog->disp( 'atom_url', 'raw' ) ?>" /> <link rel="pingback" href="<?php $Blog->disp( 'pingback_url', 'raw' ) ?>" /> <link rel="stylesheet" href="custom.css" type="text/css" /> </source>

Put this code in stead of your placeholder for the articles :

<source lang="php">

<?php // ------ START OF POSTS if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post if( isset($MainList) ) while( $Item = $MainList->get_item() ) { $MainList->date_if_changed() // you can safely delete this, if you don't want your articles be grouped by date; ?> <div class="bPost" lang="<?php $Item->lang() ?>"> <?php locale_temp_switch( $Item->locale ); // Temporarily switch to post locale $Item->anchor(); // Anchor for permalinks to refer to ?>

<?php $Item->title(); ?>

<?php $Item->content(); ?> <?php link_pages() ?>

         <?php $Item->wordcount(); echo (" "); echo T_('Words');  // the number of words in this article ?>

         <a href="<?php echo url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='. $Item->Author->ID) ?>" title="<?php echo T_('Browse all posts by this author'); ?>"><?php $Item->Author->prefered_name(); ?></a>
         •

<?php $Item->issue_date(); // to show the date of this post ?> • <?php $Item->issue_time(); // to show the time of this post ?> • <a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>" class="permalink_right"><img src="img/chain_link.gif" alt="<?php echo T_('Permalink') ?>" width="14" height="14" border="0" class="middle" /></a>

         •
      	  <?php $Item->feedback_link( 'comments' ) // Link to comments ?>

<?php $Item->edit_link( ' • ' ) // Link to backoffice for editing ?>

<?php // ------------- START OF INCLUDE FOR COMMENTS ------------- $disp_comments = 1; // Display the comments if requested $disp_comment_form = 1; // Display the comments form if comments requested require( dirname(__FILE__).'/_feedback.php' ); // -------- END OF INCLUDE FOR COMMENTS, TRACKBACK, PINGBACK, ETC. ------ locale_restore_previous(); // Restore previous locale (Blog locale) ?> </div> <?php } // ---------------------------------- END OF POSTS ------------------------------------ ?>

<?php posts_nav_link(); ?> <?php // previous_post( '<p class="center">%</p>' ); // next_post( '<p class="center">%</p>' ); ?>

<?php // ---------------- START OF INCLUDES FOR LAST COMMENTS, STATS ETC. ---------------- switch( $disp ) { case 'comments': // this includes the last comments if requested: require( dirname(__FILE__).'/_lastcomments.php' ); break; case 'arcdir': // this includes the archive directory if requested require( dirname(__FILE__).'/_arcdir.php'); break; } // ------------------- END OF INCLUDES FOR LAST COMMENTS, STATS ETC. ------------------- ?> </source>

and place this code at the bottom of your page <source lang="php">