主題: [已解決]文章無法顯示,出現fatal error
作者: polaristin 於 七月 13, 2006, 10:19:21 上午
今天發現首頁掛了 http://stin.csie.org/lifetype/ 卡在右方的最近文章等等的 好像是文章的地方出了問題 錯誤訊息是 Fatal error: Call to a member function on a non-object in c:\appserv\www\lifetype\class\net\prettyrequestgenerator.class.php on line 40 而去找出line 40是 $permaLink = $this->getBaseUrl()."/post/".$this->_blogInfo->getId()."/".$post->getId(); 還是不太能理解哪裡錯 煩請指點 @@ 謝謝
我的架站環境 Windows XP Sp1 AppServ 2.4.4a Apache Web Server Version 1.3.33 PHP Script Language Version 4.3.11 MySQL Database Version 4.0.24 phpMyAdmin Database Manager Version 2.5.7-pl1
主題: Re: 文章無法顯示,出現fatal error
作者: markwu 於 七月 13, 2006, 11:21:29 上午
你能把那一部份的模版貼出來嗎?看起來是 $post 沒有傳入 ...
Mark
主題: Re: 文章無法顯示,出現fatal error
作者: polaristin 於 七月 13, 2006, 06:02:06 下午
是指prettyrequestgenerator.class.php嗎? <?php
/** * @package net */
include_once( PLOG_CLASS_PATH."class/net/baserequestgenerator.class.php" );
/** * \ingroup Net * * Generates prettier but non-customizable requests. * * @see RequestGenerator * @see BaseRequestGenerator */ class PrettyRequestGenerator extends BaseRequestGenerator {
/** * Constructor. * * @param blogInfo A BlogInfo object */ function PrettyRequestGenerator( $blogInfo ) { $this->BaseRequestGenerator( $blogInfo );
}
/** * Returns the permalink for a post * * @param post The Article object * @return The link for the permalink */ function postPermalink( $post ) { $permaLink = $this->getBaseUrl()."/post/".$this->_blogInfo->getId()."/".$post->getId();
return $permaLink; }
/** * generates an archive link given a date. * * @param date A Timestamp object * @return A valid archive link */ function getArchiveLink( $date ) { $archiveLink = $this->getBaseUrl()."/archives"; if( $this->_blogInfo != null ) $archiveLink .= "/".$this->_blogInfo->getId(); $archiveLink .= "/$date";
return $archiveLink; }
/** * Returns the comment link for a post * * @param post The Article object * @return The correct string */ function postCommentLink( $post ) { $commentLink = $this->getBaseUrl()."/comment/".$this->_blogInfo->getId()."/".$post->getId();
return $commentLink; }
/** * Returns the link for the post * * @param post The Article object * @return The link for the post */ function postLink( $post ) {
$postLink = $this->postPermalink( $post );
return $postLink; }
/** * Returns the link for the post. This is kind of a dirty trick... :( This is only meant to be * used in the template that generates the rss feed for a blog. * * @param post The Article object * @return The link for the post */ function postRssLink( $post ) { $postLink = $this->postPermalink($post);
return $postLink; }
/** * Returns the link of a category. * * @param post The post from which we'll fetch the category and then generate the right link. * @return The url pointing to the page with only the posts belonging to that category. * @see Article * @see categoryLink */ function postCategoryLink( $post ) { throw( new Exception( "DEPRECATED!")); die(); }
/** * Returns the link but given a category. Does the same as postCategoryLink but this time we don't need * a post but an ArticleCategory object. * * @see postCategoryLink * @see ArticleCategory * @param An ArticleCategory object containing the information regarding the category. * @return A string with the correct url pointing to the page that will show only the posts that belong * to the given category. */ function categoryLink( $category ) { $categoryLink = $this->getBaseUrl()."/category/".$this->_blogInfo->getId()."/".$category->getId();
return $categoryLink; }
/** * Returns a link to only the articles of the user * * @param user The user whose posts we would like to see * @return A string containing the right url to only the posts of the user. * @see UserInfo * @see ArticleCategory */ function postUserLink( $user ) { $userLink = $this->getBaseUrl()."/user/".$this->_blogInfo->getId()."/".$user->getId();
return $userLink; }
/** * Returns the url of the host where the blog is running * * @return Returns the url where the blog is running. */ function blogLink( $blogInfo = null ) { $config =& Config::getConfig(); // if subdomains are enabled, there is no need to do much more here... if( $config->getValue( "subdomains_enabled" )) { $link = $this->getBaseUrl(); } else { // if not, we need some additional logic $disableApacheErrorHandler = $config->getValue( "disable_apache_error_handler" ); if( $disableApacheErrorHandler ) $path = "/blog/"; else $path = "/"; if( $blogInfo == null ) { if( $config->getValue( "pretty_urls_force_use_username" )) { $userInfo = $this->_blogInfo->getOwnerInfo(); $link = $this->getBaseUrl().$path.$userInfo->getUsername(); } else { $link = $this->getBaseUrl().$path.$this->_blogInfo->getId(); } } else { $link = $this->getBaseUrl().$path.$blogInfo->getId(); } }
return $link; }
/** * Returns the url where the rss feed is running * * @param blogInfo A BlogInfo object containing information about the blog. * @param profile The RSS profile we'd like to use. It defaults to none. * @return The url pointing to the rss feed of the journal. * @see BlogInfo */ function rssLink( $profile = "", $blogInfo = null ) { $rssBase = $this->getBaseUrl()."/rss/"; if( $profile != "" ) $rssBase .= $profile."/";
if( $blogInfo == null ) $rssLink = $rssBase.$this->_blogInfo->getId(); else $rssLink = $rssBase.$blogInfo->getId();
return $rssLink; }
/** * Returns the url for the rss feed of a category * * @param category The ArticleCategory object with information about the category * whose RSS feed we'd like to generate * @ram profile The profile we'd like to generate: RSS 0.90, RSS 1.0, RSS 2.0 * or XML. * @param blogInfo A BlogInfo object containing information about the blog. * @return The url pointing to the rss feed of the journal. * @see BlogInfo */ function categoryRssLink( $category, $profile = "", $blogInfo = null ) { $rssBase = $this->getBaseUrl()."/rss/";
if( $profile != "" ) $rssBase .= $profile."/";
if( $blogInfo == null ) $rssLink = $rssBase.$this->_blogInfo->getId(); else $rssLink = $rssBase.$blogInfo->getId();
$rssLink .= "/".$category->getId();
return $rssLink; }
/** * Returns the trackback link for a given post. * * @param post The post with the necessary information. * @return A string representing the rdf trackback link. */ function postTrackbackLink( $post ) { $rdfHeader = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
$trackbackLink = $this->getTrackbackUrl()."?id=".$post->getId(); $rdfBody = "<rdf:Description rdf:about=\"".$this->postLink($post)."\" dc:identifier=\"".$this->postLink($post)."\" dc:title=\"".$post->getTopic()."\" trackback:ping=\"".$trackbackLink."\"/>"; $rdfFooter = "</rdf:RDF>";
return $rdfHeader.$rdfBody.$rdfFooter; }
/** * Returns the url to reply to a given comment. * * @param post An Article object with information about the post * @param commen A UserComment object containing information about the post we'd like to reply to. * @return The right url to reply to this comment. * @see UserComment * @see Article */ function replyCommentLink( $post, $comment ) { $replyCommentLink = $this->getIndexUrl()."?op=Comment&articleId=".$post->getId()."&parentId=".$comment->getId()."&blogId=".$this->_blogInfo->getId();
return $replyCommentLink; }
/** * Returns the link to the page showing the trackback statistics for a given post. * * @param post The post with the information. * @return Returns a string with the valid link. */ function postTrackbackStatsLink( $post ) { $tbStatsLink = $this->getBaseUrl()."/trackbacks/".$this->_blogInfo->getId()."/".$post->getId();
return $tbStatsLink; }
/** * Returns the link to an album * * @param album The GalleryAlbum object. */ function albumLink( $album = null ) { if( $album == null ) $albumLink = $this->getBaseUrl()."/album/".$this->_blogInfo->getId()."/0"; else $albumLink = $this->getBaseUrl()."/album/".$this->_blogInfo->getId()."/".$album->getId();
return $albumLink; }
/** * Given an album, generates a link to its parent. Must be implemented by child classes to generate * a valid URL. * * @param album The album */ function parentAlbumLink( $album ) { $albumLink = $this->getBaseUrl()."/album/".$this->_blogInfo->getId()."/".$album->getParentId();
return $albumLink; }
/** * Given the name of a template file, generate the right link to it. Must be implemented by child * classes to generate a valid URL. * * @param template * @return A link to the given template file/static page */ function templatePage( $template ) { $templatePage = $this->getBaseUrl()."/static/".$this->_blogInfo->getId()."/".$template;
return $templatePage; }
/** * Returns the link to a resource * * @param album Generates the correct link to fetch a resource */ function resourceLink( $resource ) { $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId()); return $resourceLink = $this->getBaseUrl()."/resource/".$blogId."/".$resource->getId(); }
/** * Returns the link to a resource preview * * @param album Generates the correct link to fetch a resource preview */ function resourcePreviewLink( $resource ) { $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId()); return $resourceLink = $this->getBaseUrl()."/resserver.php?blogId=".$blogId."&resource=".rawurlencode($resource->getFileName())."&mode=preview"; } /** * Returns the link to a resource preview * * @param album Generates the correct link to fetch a resource preview */ function resourceMediumSizePreviewLink( $resource ) { $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
return $resourceLink = $this->getBaseUrl()."/resserver.php?blogId=".$blogId."&resource=".rawurlencode($resource->getFileName())."&mode=medium"; }
/** * Returns the link to a resource * * @param resource Generates the correct link to fetch a resource */ function resourceDownloadLink( $resource ) { $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId()); return $resourceLink = $this->getBaseUrl()."/get/".$blogId."/".rawurlencode($resource->getFileName()); }
/** * Returns a string representing the request * * @return A String object representing the request */ function getRequest() { throw( new Exception( "PrettyRequestGenerator::getRequest: function not implemented" )); die(); } } ?>
主題: Re: 文章無法顯示,出現fatal error
作者: lss 於 七月 13, 2006, 07:17:22 下午
mark 是要你貼出出問題地方的模版,就是你的模版裡的 sidebar-l.template 裡的這一段: <!--Top Read Posts--> {if $topreadposts->isEnabled()} <h3>熱門文章</h3> <ul> {assign var=readposts value=$topreadposts->getTopReadPosts()} {foreach from=$readposts item=readpost} <li><a href="{$url->postLink($readpost)}">{$readpost->getTopic()}</a> [{$readpost->getNumReads()} 次]</li> {/foreach} </ul> {/if} 依我判斷,問題出在你的 topreadposts 外掛並沒有傳回任何文章( 就是 $readpost 是 null ) ,所以才會出現錯誤訊息裡那一行: $permaLink = $this->getBaseUrl()."/post/".$this->_blogInfo->getId()."/".$post->getId(); 裡面的 $post 是一個 null 而非物件,才會造成錯誤。 你可以這樣改: <!--Top Read Posts--> {if $topreadposts->isEnabled()} <h3>熱門文章</h3> <ul> {assign var=readposts value=$topreadposts->getTopReadPosts()} {if !empty($readposts) } {foreach from=$readposts item=readpost} <li><a href="{$url->postLink($readpost)}">{$readpost->getTopic()}</a> [{$readpost->getNumReads()} 次]</li> {/foreach} {/if} </ul> {/if} 應該就可以了。 提供詳細資訊,可以省很多事。不是什麼時候都有空可以看這麼仔細的。 lss
主題: Re: 文章無法顯示,出現fatal error
作者: polaristin 於 七月 13, 2006, 09:48:46 下午
謝謝回應 不過我有試著把最多閱讀、最新文章那些通通移掉 結果還是差不多 所以才覺得應該不是那裡的程式碼出了問題 覺得有點像是mark所說的$post的問題 而這我不知道該怎麼找起 也附上sidebar-l.template <div id="avmenu"> <h2 class="hide">Menu:</h2>
<h3>關於我</h3> <ul> <img src="{$url->getTemplateFile("images/me.jpg")}" align="left" hspace="5"> <p> polaristin<br/> 綽號小p<br/> 1985/07/23<br /> Taipei, Taiwan<br /> <a href="http://stin.csie.org/lifetype/"><img src="{$url->getUrl("/imgs/PsLove.png")}" vspace="5" alt="P's & Love" /></a></p> <p>台南人,現於台北念書,明年即將考研究所的苦悶(?)大三生...</p> <center><a href="mailto:polaristin@gmail.com"><img vspace="3" src="http://services.nexodyne.com/email/icon/x7oHr%2BhGHHDU0A%3D%3D/YwkQ%2Bu4%3D/R01haWw%3D/0/image.png"></a></center> </ul>
<h3>{$locale->tr("search")}</h3> <center> <form method="post" action="{$url->getIndexUrl()}"> <input type="text" name="searchTerms" value="" size="20" /> <input type="hidden" name="op" value="Search" /> <input type="hidden" name="blogId" value="{$blog->getId()}"/> <input type="submit" name="Search" value="搜尋" /> </form> </center>
<h3>最新文章</h3> <ul> {foreach from=$recentposts item=recentpost} <li><a title="{$recentpost->getText()|truncate:100:"..."|strip_tags|escape}" href="{$url->postLink($recentpost)}">{$recentpost->getTopic()}</a> [{$recentpost->getNumReads()} 次]</li> {/foreach} </ul>
<!--Top Read Posts--> {if $topreadposts->isEnabled()} <h3>熱門文章</h3> <ul> {assign var=readposts value=$topreadposts->getTopReadPosts()} {if !empty($readposts) } {foreach from=$readposts item=readpost} <li><a href="{$url->postLink($readpost)}">{$readpost->getTopic()}</a> [{$readpost->getNumReads()} 次]</li> {/foreach} {/if} </ul> {/if}
{if $recentcomments->isEnabled()} <h3>最新迴響</h3> {assign var=comments value=$recentcomments->getRecentComments()} <ul> {foreach from=$comments item=comment} {assign var=commentpostid value=$comment->getArticleId()} {assign var=commentpost value=$recentcomments->getArticle($commentpostid)} <li> {if $comment->getUserUrl() != ""} <b><a href="{$comment->getUserUrl()}"}>{$comment->getUsername()}</a></b> {else} <b>{$comment->getUsername()}</b> {/if} :<a title="View comments by {$comment->getUsername()}" href="{$url->postPermalink($commentpost)}#{$comment->getId()}">{$comment->getText()|truncate:80:"..."|strip_tags}</a></li> {/foreach} </ul> {/if}
<!--categories 文章分類--> <h3>{$locale->tr("categories")}</h3> <ul> {foreach from=$articlecategories item=articleCategory} <li><a href="{$url->categoryRssLink($articleCategory)}"><img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" style="border:0px;" alt="RSS 0.90" align="middle" /></a> <a href="{$url->categoryLink($articleCategory)}">{$articleCategory->getName()}</a> [{$articleCategory->getNumArticles()}]</li> {/foreach} </ul>
<h3>訂閱部落格</h3> <ul> <!-- <a class="nodecoration" title="Link to the RSS 0.90 feed." href="http://feeds.feedburner.com/PsLove/rss09"><img src="{$url->getUrl("/imgs/rss090_logo.gif")}" style="border:0px;" alt="RSS 0.90" /></a> <a class="nodecoration" title="Link to the RSS 1.0 feed." href="http://feeds.feedburner.com/PsLove/rss1"><img src="{$url->getUrl("/imgs/rss10_logo.gif")}" style="border:0px;" alt="RSS 1.0" /></a><br/> --> <a class="nodecoration" title="Link to the RSS 2.0 feed." href="http://feeds.feedburner.com/PsLove/rss2"><img src="{$url->getUrl("/imgs/rss20_logo.gif")}" style="border:0px;" alt="RSS 2.0" /></a> <a class="nodecoration" title="Link to the Atom 0.3 feed." href="http://feeds.feedburner.com/PsLove/atom"><img src="{$url->getUrl("/imgs/atom_logo.png")}" style="border:0px;" alt="Atom 0.3" /></a><br/> <a href="http://fusion.google.com/add?feedurl=http://feeds.feedburner.com/PsLove/rss2"><img src="{$url->getUrl("/imgs/add-to-google.jpg")}" alt="Google Reader or Homepage" border="0"></a> <a href="http://add.my.yahoo.com/rss?url=http://feeds.feedburner.com/PsLove/rss2"><img src="{$url->getUrl("/imgs/add-yahoo.jpg")}" border="0" alt="Add to My Yahoo!"></a><br> <a href="http://my.msn.com/addtomymsn.armx?id=rss&ut=http://feeds.feedburner.com/PsLove/rss2&ru=http://stin.csie.org/lifetype/"><img src="{$url->getUrl("/imgs/add-msn.gif")}" border="0"></a> <a href="http://www.feedster.com/myfeedster.php?action=addrss&rssurl=http://feeds.feedburner.com/PsLove/rss2&confirm=no"><img src="{$url->getUrl("/imgs/feedster.gif")}" alt="myFeedster" border="0" /></a><br> <a href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http://feeds.feedburner.com/PsLove/rss2"><img src="http://www.newsgator.com/images/ngsub1.gif" alt="Subscribe in NewsGator Online" border="0"></a> <a href="http://www.bloglines.com/sub/http://feeds.feedburner.com/PsLove/rss2"><img src="{$url->getUrl("/imgs/add-bloglines.gif")}" alt="Subscribe with Bloglines" border="0" /></a><br> <a href="http://del.icio.us/post?url=http://stin.csie.org/lifetype/&title=P\'s & Love" target="_blank"><IMG alt="del.icio.us P\'s & Love" src="{$url->getUrl("/imgs/add-delicious.gif")}" border=0></a> <a href="http://www.furl.net/storeIt.jsp?u=http://stin.csie.org/lifetype/" target="_blank"><IMG alt="Furl P\'s & Love" src="{$url->getUrl("/imgs/furlit.gif")}" border=0></a><br /> <a href="http://feeds.feedburner.com/PsLove/rss2"><img src="http://feeds.feedburner.com/~fc/PsLove/rss2?bg=99CCFF&fg=444444&anim=1" height="26" width="88" style="border:0" alt="" /></a></ul>
<h3>貼紙連結</h3> <ul> <a href="http://www.mybloglog.com/members/memstats.php?mblID=2006022706273439" target="_blank"><img src="http://www.mybloglog.com/images/b3.gif" style="border:0px;" alt=" View My Public Stats on MyBlogLog.com " /></a> <a href="https://www.feedburner.net/fb/a/myfeeds" target="_blank"><img src="{$url->getUrl("/imgs/feedburner.gif")}" style="border:0px;" alt="RSS 1.0" /></a><br> <a href="http://del.icio.us/polaristin" target="_blank"><img src="{$url->getUrl("/imgs/delicious.png")}" border="0"></a> <a href="http://www.newsgator.com/ngs/subscriber/WebEd2.aspx" target="_blank"><img src="{$url->getUrl("/imgs/newsgator.gif")}" border="0"></a><br> <a href="http://blog.catseyes.com.tw/1" target="_blank"><img src="http://blog.catseyes.com.tw/imgs/blog-joskcat.png"></a> <a href="http://tomky.blogspot.com" target="_blank"><img src="http://homepage.ntu.edu.tw/~b92901007/tomky-blog.png"></a><br> <a href="http://blog.yam.com/lifeshot/archives/1372095.html" target="_blank"><img alt="我是台灣人" src="http://img156.imageshack.us/img156/5001/taiwanese0qb6rd.gif" width="80" height="15" border="0"></a> </ul>
<!--Statistics--> <h3>資料統計</h3> <ul> <li>文章總數:{$blog->getTotalPosts()}</li> <li>迴響總數:{$blog->getTotalComments()}</li> <li>引用總數:{$blog->getTotalTrackbacks()}</li> <li>閱讀總數:{$blog->getViewedTotal()}</li> <br> <!-- Site Meter --> <script type="text/javascript" src="http://s23.sitemeter.com/js/counter.js?site=s23polaristin"><br /> </script> <noscript> <a href="http://s23.sitemeter.com/stats.asp?site=s23polaristin" target="_blank"> <img src="http://s23.sitemeter.com/meter.asp?site=s23polaristin" alt="Site Meter" border="0"/></a><br /> </noscript> <!-- Copyright (c)2006 Site Meter --> <!-- Begin Users Online --> <!-- URL: http://www.twospots.com/ --> <table width="76" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="39"><a href="http://www.twospots.com/free-users-online-counter/" target="_blank"><img src="http://www.tscounter.com/images/users-online/users-online6.gif" width="39" height="21" border="0" alt="Number of online users in last 3 minutes"></a></td> <td width="37"><script type="text/javascript">document.write('<a href="http://www.twospots.com/free-users-online-counter/" target="_blank"><img src="http://www.tscounter.com/uow3c/?id=mNtlQYuP2XsKMD2+ayXHOQ==" width="37" height="21" border="0" alt="Number of online users in last 3 minutes"></ a>');</script><noscript> <a href="http://www.twospots.com/web-services/web-design/" style="style: none;"><img src="http://www.tscounter.com/uow3c/?id=mNtlQYuP2XsKMD2+ayXHOQ==" width="37" height="21" border="0" alt="website design"></a></noscript></td> </tr> </table> <!-- End Users Online --> </ul>
</div>
主題: Re: 文章無法顯示,出現fatal error
作者: polaristin 於 七月 17, 2006, 10:49:37 下午
抱歉 看來我沒有好好搜尋 剛用其他字搜尋後發現了這篇 http://forum.lifetype.org.tw/index.php?topic=1259.0 已照著方法解決了問題 再次謝謝mark跟lss ^^
主題: Re: [已解決]文章無法顯示,出現fatal error
作者: markwu 於 七月 17, 2006, 11:09:40 下午
不會吧!這是完全不同的問題耶!呵呵!
還好你有去看 plog_articles,否則這問題可能就成了懸案了!
恭喜你解決了! :-)
Mark
|