Re: [Simplog-devel] modular approach to customizing appearance and behavior
Brought to you by:
f-bomb
From: Jason L. B. <ja...@bu...> - 2004-08-29 14:46:37
|
Jim, Now this would have been a good case for 'propose your changes first, get feedback, and make the changes afterwards'. Although your approach does work, I'm not convinced it's the right approach. simplog's current mechanism for this kind of thing, as seen in the first few lines below, is to check for a file (config.php), then create it from a master or template if it does not exist (via install.php process). Although separating index.php and header.php is probably a good thing, what if the 'new blog' creation process was reformulated to do the same thing? 1. Click 'Blog Admin' 2. Click 'Add Blog' 3. On the 'new blog' form, there would be a checkbox for 'Use custom templates' 4. When the user clicks 'Save', we check the value of the checkbox 5. If selected, we create copies of the blog layout and formatting template files, using the blog_id as part of the file name, then show a message to the user with the names of the files they can now customize. How about that approach? -jason Jim Hu wrote: > To make customizing the appearance and behavior of different blogs > easier (at least for me), I broke up the index.php and header.php > files so that they would call different layout options that I'm > keeping in a subdirectory called layout. > > The new index.php is just: > ------------------------------------------------------------------------ > ---- > <?php > if(!file_exists("config.php")) { > header("Location: install.php"); > exit(0); > } > > session_start(); > require_once("lib.php"); > require_once("class.BlogInfo.php"); > require_once("class.BlogEntry.php"); > > $blogid = $_GET['blogid']; > > if(!isset($blogid)) { > $blogid = 1; #set default blog to see > } > $blogInfo = new BlogInfo($blogid); > include("header.php"); > > $testindexfile = "layout/index".$blogid.".php"; > if (file_exists($testindexfile)){ > $indexfile = $testindexfile; > }else{ > $indexfile = "layout/index0.php"; > } > include($indexfile); > ?> > ------------------------------------------------------------------------ > ---- > The new header.php file is reduced to: > > <?php > header("X-Pingback: $baseurl/api.php\n"); > > if(!isset($blogInfo)) { > $btitle = "Simplog"; > } else { > $btitle = $blogInfo->getBlogTitle(); > $btag = $blogInfo->getBlogTagline(); > } > > if(isLoggedIn()) { > $uid = getUID($_SESSION['login']); > } > > $testheaderfile = "layout/header".$blogid.".php"; > if (file_exists($testheaderfile)){ > $headerfile = $testheaderfile; > }else{ > $headerfile = "layout/header0.php"; > } > > include($headerfile); > > if(isLoggedIn()) { > show_menu(); > } > ?> > <br> > ------------------------------------------------------------------------ > ---- > inside the layout subdirectory I have a series of files named > header0, header1, header11 etc, and index0, index1.... plus the css > files. Only header0 and index0 are necessary > layout/header0.php is the missing pieces of the original header.php: > ------------------------------------------------------------------------ > ---- > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> > <title><?=$btitle?>: <?=$btag?></title> > > <script language="javascript" type="text/javascript" > src="<?=$baseurl?>/simplog.js"></script> > > <link rel="alternate" type="text/xml" title="RSS" > href="<?=$baseurl?>/rss2.php" /> > <link rel="pingback" href="<?=$baseurl?>/api.php" /> > <link rel="stylesheet" href="<?=$baseurl?>/layout/simplog.css" > type="text/css" /> > </head> > <body bgcolor=#ffffff marginwidth=0 marginheight=0 leftmargin=0 > topmargin=0> > <table width=100% border=0 cellspacing=0 cellpadding=5 class=header> > <tr> > <td align=left><span class=blogname><?=$btitle?></span><br><span > class=blogtag><?=$btag?></span></td> > </tr> > </table> > ------------------------------------------------------------------------ > ---- > The alternate headers are customized to modify appearance (I specify > which css to use in each one, so some blogs can share css files), > plus to make a blog require user login (which I want for all the > blogs I'm using to control other websites), I add > > <?php > if(!isLoggedIn()) { > auth(); > } > ?> > to the header. This also makes the headers look different for all > the views of the blog - archives, search results, edit pages etc. > > layout/index0.php is just the missing pieces of the original index.php: > ------------------------------------------------------------------------ > ---- > > <table cellpadding=0 cellspacing=0 border=0 width="100%" > style="height:90%;"> > <tr valign="top"> > <td style="border-right:1px solid #999999;padding-right:24px;"> > <div style="padding:10px;"> > > <?php @include("$baseurl/blog.php?blogid=$blogid"); ?> > > </div> > </td> > <td align="center" width=150 style="padding-left: 24px;"> > > <?php include("blocks.php"); ?> > > </td> > </tr> > </table> > > </body> > </html> > ------------------------------------------------------------------------ > ---- > Obviously, this allows me to alter the appearance of the individual > blog pages, put blocks on the left, add other stuff etc. > > To a naive user, one could just install and use the defaults. > Changing the appearance of different blogs and staying within that > look and feel is easier for the slightly more sophisticated user with > this approach than by feeding blog content to another page, as > internal navigation links don't have to be adjusted at all. Would > this be worth including in the next version? > > Jim > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click > _______________________________________________ > Simplog-devel mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simplog-devel > > !DSPAM:4131891c71631195073659! > |